blob: ab977bc370a179d52be01369a7d3bc8c22e47bb0 [file] [log] [blame]
<!doctype HTML>
<!--
Runs an acquireDisplayLock, which appends the first child and schedules two
continuations. The continuations append second and third children as well
as scheduling two more continuations each, for a total of 7 children.
-->
<style>
#container {
contain: content;
width: 150px;
height: 150px;
background: lightblue;
}
.child {
width: 20px;
height: 20px;
background: lightgreen;
}
</style>
<div id="log"></div>
<script>
if (window.testRunner)
window.testRunner.waitUntilDone();
function createChild(id) {
let child = document.createElement("div");
child.classList = "child";
child.innerHTML = "" + id;
return child;
}
function addChild(id, context) {
context.lockedElement.appendChild(createChild(id));
if (id > 3)
return;
context.schedule((context) => { addChild(id * 2, context); });
context.schedule((context) => { addChild(id * 2 + 1, context); });
}
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) => { addChild(1, context) }).then(
() => { finishTest("PASS"); },
() => { finishTest("FAIL"); });
document.body.appendChild(container);
}
window.onload = acquire;
</script>