blob: cbb8bebd928ebe27bb82e806c7d11aab2cfa6c7b [file] [log] [blame]
<!doctype HTML>
<!--
Runs an acquireDisplayLock, which changes DOM and suspends the context.
DOM changes should never be visible.
-->
<style>
#container {
contain: content;
width: 150px;
height: 150px;
background: lightblue;
}
#child {
width: 50px;
height: 50px;
background: red;
}
</style>
<div id="log"></div>
<script>
if (window.testRunner)
window.testRunner.waitUntilDone();
function modifyDom(context) {
let child = document.createElement("div");
child.id = "child";
context.lockedElement.appendChild(child);
}
function finishTest(status_string) {
if (document.getElementById("log").innerHTML === "")
document.getElementById("log").innerHTML = status_string;
if (window.testRunner)
window.testRunner.notifyDone();
}
function acquire() {
let container = document.createElement("div");
container.id = "container";
container.acquireDisplayLock(
(context) => {
modifyDom(context);
context.suspend();
}).then(
() => { finishTest("FAIL"); },
() => { finishTest("FAIL"); });
document.body.appendChild(container);
setTimeout(() => { finishTest("PASS"); }, 100);
}
window.onload = acquire;
</script>