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>Test to ensure touch events for OOP iframes</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 waitForTouchEvent(aType) {
return promiseOneEvent(window, "message", function (e) {
return e.data === aType;
});
}
async function test() {
const iframe = document.querySelector("iframe");
await setupCrossOriginIFrame(iframe, "helper_fission_plain.html");
let readyPromise = new Promise(resolve => {
window.addEventListener("message", event => {
if (event.data === "listenerready") {
resolve();
}
});
});
let result = await SpecialPowers.spawn(iframe, [], async () => {
let listener = function (e) {
content.window.parent.postMessage(e.type, "*");
}
content.document.addEventListener("touchstart", listener, { once: true });
content.document.addEventListener("touchmove", listener, { once: true });
content.document.addEventListener("touchend", listener, { once: true });
content.window.parent.postMessage("listenerready", "*");
return true;
});
ok(result, "Successfully installed event listeners in OOP iframe");
await readyPromise;
let touchPromises = Promise.all(
[waitForTouchEvent("touchstart"),
waitForTouchEvent("touchmove"),
waitForTouchEvent("touchend")]
);
await synthesizeNativeTouchSequences(document.body,
[[{ x: 100, y: 100 }], [{ x: 150, y: 150 }], [{ x: 150, y: 150 }]], function () {
dump("Finished synthesizing touch tap, waiting for OOPIF message...\n");
});
await touchPromises;
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
<style>
body,
html {
margin: 0;
}
div {
width: 500px;
}
iframe {
width: 400px;
height: 300px;
border: solid 1px black;
}
</style>
</head>
<body>
<div><iframe id="testframe"></iframe></div>
</body>
</html>