gecko-dev/dom/media/test/AutoplayTestUtils.js
Chris Pearce 514d5fd12b Bug 1441424 - Fix autoplay activation test. r=kamidphish
Post landing of bug 1193394 test_autoplay_policy_activation was failing.
This is because we weren't clicking the child frame properly in the test.

Fix the test, and re-enable.

MozReview-Commit-ID: Ius4GWIX8Ng

--HG--
extra : source : f2ef9db8bbcf8a045b6da1e7f7e283e234174401
extra : amend_source : 4e0790690f077c0b20537da131d9a9e337394112
2018-03-01 17:21:09 +13:00

38 lines
948 B
JavaScript

function playAndPostResult(muted, parent_window) {
let element = document.createElement("video");
element.preload = "auto";
element.muted = muted;
element.src = "short.mp4";
element.id = "video";
document.body.appendChild(element);
element.play().then(
() => {
parent_window.postMessage({played: true}, "*");
},
() => {
parent_window.postMessage({played: false}, "*");
}
);
}
function nextEvent(eventTarget, eventName) {
return new Promise(function(resolve, reject) {
let f = function(event) {
eventTarget.removeEventListener(eventName, f, false);
resolve(event);
};
eventTarget.addEventListener(eventName, f, false);
});
}
function nextWindowMessage() {
return nextEvent(window, "message");
}
function log(msg) {
var log_pane = document.body;
log_pane.appendChild(document.createTextNode(msg));
log_pane.appendChild(document.createElement("br"));
}