| <!doctype HTML> |
| |
| <style> |
| #parent { |
| contain: paint; |
| width: 150px; |
| height: 150px; |
| background: lightblue; |
| } |
| #child { |
| width: 50px; |
| height: 50px; |
| background: lightgreen; |
| } |
| </style> |
| |
| <div id="log"></div> |
| <div id="parent"></div> |
| |
| <script> |
| if (window.testRunner) |
| window.testRunner.waitUntilDone(); |
| |
| function modifyDom(context) { |
| let child = document.createElement("div"); |
| child.id = "child"; |
| document.getElementById("parent").appendChild(child); |
| } |
| |
| function acquire() { |
| document.getElementById("parent").acquireDisplayLock(modifyDom).then( |
| () => { |
| document.getElementById("log").innerHTML = "PASS"; |
| if (window.testRunner) |
| window.testRunner.notifyDone(); |
| }, |
| () => { |
| document.getElementById("log").innerHTML = "FAIL"; |
| if (window.testRunner) |
| window.testRunner.notifyDone(); |
| }); |
| } |
| |
| window.onload = acquire; |
| </script> |