mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +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
67 lines
2.4 KiB
HTML
67 lines
2.4 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>
|
|
|
|
function testAutoplayInWindow(test_case, parent_window) {
|
|
log("testAutoplayInWindow: " + test_case.name);
|
|
playAndPostResult(test_case.muted, parent_window);
|
|
}
|
|
|
|
async function testAutoplayInChildFrame(test_case, parent_window) {
|
|
log("testAutoplayInChildFrame: " + test_case.name);
|
|
// Create a child iframe...
|
|
var frame = document.createElement("iframe");
|
|
var origin = test_case.same_origin_child
|
|
? "http://mochi.test:8888" : "http://example.org";
|
|
frame.src = origin + "/tests/dom/media/test/file_autoplay_policy_activation_frame.html";
|
|
// Wait for it to load...
|
|
document.body.appendChild(frame);
|
|
is((await nextWindowMessage()).data, "ready", "Expected a 'ready' message");
|
|
// Click the iframe to activate if appropriate.
|
|
if (test_case.activated_child) {
|
|
frame.contentWindow.postMessage("click", "*");
|
|
}
|
|
// Ask the child iframe to try to play video.
|
|
let play_message = test_case.muted ? "play-muted" : "play-audible";
|
|
frame.contentWindow.postMessage(play_message, "*");
|
|
// Wait for the iframe to tell us whether it could play video.
|
|
let result = await nextWindowMessage();
|
|
// Report whether the iframe could play to the parent.
|
|
parent_window.postMessage(result.data, "*");
|
|
}
|
|
|
|
nextWindowMessage().then(
|
|
(event) => {
|
|
let test_case = event.data;
|
|
// Click the window to activate if appropriate.
|
|
if (test_case.activated_parent) {
|
|
synthesizeMouseAtCenter(document.body, {});
|
|
}
|
|
let parent_window = event.source;
|
|
if (test_case.same_origin_child === undefined) {
|
|
testAutoplayInWindow(test_case, parent_window);
|
|
} else {
|
|
testAutoplayInChildFrame(test_case, parent_window);
|
|
}
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|