blob: fa774cb848d53ca1a419d2dd78590d738f428db5 [file] [log] [blame]
<!doctype HTML>
<html class="reftest-wait">
<meta charset="utf8">
<title>Display Locking: acquire, update, disconnect, commit</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://github.com/WICG/display-locking">
<link rel="match" href="pass-ref.html">
<script src="/common/reftest-wait.js"></script>
<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>
function finishTest(status_string) {
if (document.getElementById("log").innerHTML === "")
document.getElementById("log").innerHTML = status_string;
takeScreenshot();
}
function runTest() {
const container = document.getElementById("container");
container.displayLock.acquire({ timeout: Infinity }).then(() => {
// Update, then disconnect the element, and commit.
const update_promise = container.displayLock.update();
container.remove();
const 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>
</html>