Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>
A test to make sure checkerboard severity isn't reported for non-scrollable
OOP iframe
</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="helper_fission_utils.js"></script>
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script>
function getEventPromise(eventName) {
return new Promise(resolve => {
const listener = event => {
if (event.data === eventName) {
window.removeEventListener("message", listener);
resolve();
}
}
window.addEventListener("message", listener);
});
}
function getClickPromise() {
return new Promise(resolve => {
let listener = event => {
let data = JSON.parse(event.data);
if ("type" in data && data.type === "clicked") {
window.removeEventListener("message", listener);
resolve([data.x, data.y]);
}
};
window.addEventListener("message", listener);
});
}
function getIframeDisplayport(iframe) {
return SpecialPowers.spawn(iframe, [], () => {
return content.wrappedJSObject.getLastContentDisplayportFor("fission_empty_docelement", false);
});
}
async function installClickListener(iframe) {
let clickListenerReady = getEventPromise("clickListenerReady");
await SpecialPowers.spawn(iframe, [], () => {
const listener = event => {
content.document.removeEventListener("click", listener);
let data = JSON.stringify({
type: "clicked",
x: event.clientX,
y: event.clientY
});
content.window.parent.postMessage(data, "*");
}
content.document.addEventListener("click", listener);
content.window.parent.postMessage("clickListenerReady", "*");
});
await clickListenerReady;
}
async function test() {
await SpecialPowers.spawnChrome([], () => {
Services.telemetry.getHistogramById("CHECKERBOARD_SEVERITY").clear();
});
const iframe = document.getElementById("testframe");
await setupCrossOriginIFrame(iframe, "helper_fission_plain.html");
// Skip for isolate high value configurations
const remoteType = await SpecialPowers.spawn(iframe, [], async () => {
return await SpecialPowers.spawnChrome([], () => {
return windowGlobalParent.domProcess.remoteType;
});
});
if (remoteType === "web") {
is(SpecialPowers.effectiveIsolationStrategy(), SpecialPowers.ISOLATION_STRATEGY.IsolateHighValue);
ok(true, "Skipping this test since the document on example.com got loaded in the same content process");
return;
}
const [scrollMaxX, scrollMaxY] = await SpecialPowers.spawn(iframe, [], () => {
return [content.window.scrollMaxX, content.window.scrollMaxY];
});
is(scrollMaxX, 0, "The iframe content should not be scrollable");
is(scrollMaxY, 0, "The iframe content should not be scrollable");
// Since bug 1709460 any visible OOP iframe initially has set the displayport.
let displayport = await getIframeDisplayport(iframe);
is(displayport.width, 400, "displayport.width should be 400");
is(displayport.height, 300, "displayport.height should be 300");
await installClickListener(iframe);
let clickReceived = getClickPromise();
await synthesizeNativeMouseEventWithAPZ(
{ type: "click", target: iframe, offsetX: 10, offsetY: 10 },
() => dump("Finished synthesizing click, waiting for OOPIF message...\n")
);
const [clickX, clickY] = await clickReceived;
dump(`OOPIF click data respsone: (x: ${clickX}, y: ${clickY})\n`);
// Now the displayport size should have been set.
displayport = await getIframeDisplayport(iframe);
is(displayport.width, 400, "The displayport size should be same as the iframe size");
is(displayport.height, 300, "The displayport size should be same as the iframe size");
// Wait 100ms to give a chance to deliver the checkerboard event.
SimpleTest.requestFlakyTimeout("No other way to wait for checkerboard severity being set");
await new Promise(resolve => {
setTimeout(resolve, 100);
});
const hasCheckerboardSeverity = await SpecialPowers.spawnChrome([], () => {
const histograms = Services.telemetry.getSnapshotForHistograms(
"main",
true /* clear the histograms after taking this snapshot*/).parent;
return histograms.hasOwnProperty("CHECKERBOARD_SEVERITY");
});
ok(!hasCheckerboardSeverity, "there should be no checkerboard severity data");
}
if (!SpecialPowers.Services.appinfo.fissionAutostart) {
ok(true, "This test doesn't need to run with disabling Fission");
subtestDone();
} else {
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
}
</script>
<style>
iframe {
width: 400px;
height: 300px;
border: none;
}
</style>
</head>
<body>
<iframe id="testframe"></iframe>
</body>
</html>