| <!doctype HTML> |
| |
| <style> |
| #container { |
| contain: style layout; |
| width: 150px; |
| height: 150px; |
| background: lightblue; |
| } |
| #child { |
| width: 50px; |
| height: 50px; |
| background: lightgreen; |
| } |
| </style> |
| |
| <div id="log"></div> |
| <div id="container"></div> |
| |
| <script> |
| // TODO(vmpstr): In WPT this needs to be replaced with reftest-wait. |
| if (window.testRunner) |
| window.testRunner.waitUntilDone(); |
| |
| function finishTest(status_string) { |
| if (document.getElementById("log").innerHTML === "") |
| document.getElementById("log").innerHTML = status_string; |
| if (window.testRunner) |
| window.testRunner.notifyDone(); |
| } |
| |
| function runTest() { |
| let container = document.getElementById("container"); |
| container.displayLock.acquire({ timeout: Infinity }).then(() => { |
| // Update, then disconnect the element, and commit. |
| let update_promise = container.displayLock.update(); |
| container.remove(); |
| let commit_promise = container.displayLock.commit(); |
| |
| // The update promise should reject and commit one should succeed. |
| Promise.all([ |
| new Promise((resolve, reject) => update_promise.then(reject, resolve)), |
| commit_promise |
| ]).then( |
| () => finishTest("PASS"), |
| () => finishTest("FAIL")); |
| }); |
| } |
| |
| window.onload = runTest; |
| </script> |