Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<html id="html">
<title>Test for displayport supression during page load</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
iframe {
width: 500px;
height: 500px;
border: none;
}
</style>
<body>
<iframe></iframe>
</body>
<script>
async function test() {
const readyPromise = new Promise(resolve => {
window.addEventListener("message", event => {
if (event.data === "ready") {
resolve();
}
});
});
// Load the iframe content that loading it will take 3s.
const iframe = document.querySelector("iframe");
let iframeURL = SimpleTest.getTestFileURL("slow_content.sjs");
iframe.src = iframeURL.replace(window.location.origin, "https://example.com");
await readyPromise;
await SpecialPowers.spawn(iframe, [], async () => {
await SpecialPowers.contentTransformsReceived(content);
});
await promiseApzFlushedRepaints();
const displayport = await SpecialPowers.spawn(iframe, [], () => {
return content.wrappedJSObject.getLastContentDisplayportFor(content.document.documentElement.id);
});
let [ innerWidth, innerHeight] = await SpecialPowers.spawn(iframe, [], () => {
return [ content.window.innerWidth, content.window.innerHeight ];
});
isfuzzy(displayport.width, innerWidth, 1,
"The displayport width should equal to the window visible area");
isfuzzy(displayport.height, innerHeight, 1,
"The displayport height should equal to the window visible area");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</html>