mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
0d460e3432
This is split from the previous changeset since if we include dom/ the file size is too large for phabricator to handle. This is an autogenerated commit to handle scripts loading mochitest harness files, in the simple case where the script src is on the same line as the tag. This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170 using the `--part 2` argument. Differential Revision: https://phabricator.services.mozilla.com/D27457 --HG-- extra : moz-landing-system : lando
86 lines
2.6 KiB
HTML
86 lines
2.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
|
|
<head>
|
|
<title>Autoplay policy window</title>
|
|
<style>
|
|
video {
|
|
width: 50%;
|
|
height: 50%;
|
|
}
|
|
</style>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<script type="text/javascript" src="manifest.js"></script>
|
|
<script type="text/javascript" src="AutoplayTestUtils.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<pre id="test">
|
|
<script>
|
|
|
|
window.ok = window.opener.ok;
|
|
window.is = window.opener.is;
|
|
window.info = window.opener.info;
|
|
|
|
async function testEventDownActivates(eventNames, activator) {
|
|
let element = document.createElement("video");
|
|
element.preload = "auto";
|
|
element.src = "short.mp4";
|
|
document.body.appendChild(element);
|
|
|
|
await once(element, "loadedmetadata");
|
|
|
|
let played = await element.play().then(() => true, () => false);
|
|
ok(!played, "Document should start out not activated, with playback blocked.");
|
|
|
|
let x = eventNames.map(
|
|
(eventName) => {
|
|
return new Promise(async function (resolve, reject) {
|
|
window.addEventListener(eventName, async function (event) {
|
|
let played = await element.play().then(() => true, () => false);
|
|
ok(played, "Expect to be activated already in " + eventName);
|
|
resolve();
|
|
}, false);
|
|
});
|
|
});
|
|
|
|
activator();
|
|
|
|
await Promise.all(x);
|
|
|
|
removeNodeAndSource(element);
|
|
}
|
|
|
|
nextWindowMessage().then(
|
|
async (event) => {
|
|
try {
|
|
if (event.data == "run keydown test") {
|
|
await testEventDownActivates(["keydown", "keypress", "keyup"], () => {
|
|
document.body.focus();
|
|
synthesizeKey(" ");
|
|
});
|
|
} else if (event.data == "run mousedown test") {
|
|
let events = ["mousedown", "mouseup", "click"];
|
|
if (getAndroidVersion() < 0) {
|
|
// Non-Android, also listen on pointer events.
|
|
events.push("pointerdown", "pointerup");
|
|
}
|
|
await testEventDownActivates(events, () => {
|
|
synthesizeMouseAtCenter(document.body, {});
|
|
});
|
|
} else {
|
|
ok(false, "unexpected message");
|
|
}
|
|
} catch (e) {
|
|
ok(false, "Caught exception " + e + " " + e.message + " " + e.stackTrace);
|
|
}
|
|
event.source.postMessage("done", "*");
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
|
|
</html>
|