зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1480738 - part2 : add test. r=cpearce
MozReview-Commit-ID: 8GwifOpAQNf --HG-- extra : rebase_source : 8f21f469894deb5ae815582dcb7c50625c7b50b8
This commit is contained in:
Родитель
7a58a577d5
Коммит
c9a517ec96
|
@ -12,12 +12,33 @@ function setup_test_preference() {
|
|||
|
||||
function checkIsVideoDocumentAutoplay(browser) {
|
||||
return ContentTask.spawn(browser, null, async () => {
|
||||
let video = content.document.getElementsByTagName("video")[0];
|
||||
let played = video && await video.play().then(() => true, () => false);
|
||||
const video = content.document.getElementsByTagName("video")[0];
|
||||
const played = video && await video.play().then(() => true, () => false);
|
||||
ok(played, "Should be able to play in video document.");
|
||||
});
|
||||
}
|
||||
|
||||
async function checkIsIframeVideoDocumentAutoplay(browser) {
|
||||
info("- create iframe video document -");
|
||||
await ContentTask.spawn(browser, PAGE, async (pageURL) => {
|
||||
const iframe = content.document.createElement("iframe");
|
||||
iframe.src = pageURL;
|
||||
content.document.body.appendChild(iframe);
|
||||
const iframeLoaded = new Promise((resolve, reject) => {
|
||||
iframe.addEventListener("load", e => resolve(), {once: true});
|
||||
});
|
||||
await iframeLoaded;
|
||||
});
|
||||
|
||||
info("- check whether iframe video document starts playing -");
|
||||
await ContentTask.spawn(browser, null, async () => {
|
||||
const iframe = content.document.querySelector("iframe");
|
||||
const video = iframe.contentDocument.querySelector("video");
|
||||
ok(video.paused, "Subdoc video should not have played");
|
||||
is(video.played.length, 0, "Should have empty played ranges");
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async () => {
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
|
@ -31,3 +52,16 @@ add_task(async () => {
|
|||
});
|
||||
});
|
||||
|
||||
add_task(async () => {
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: "about:blank",
|
||||
}, async (browser) => {
|
||||
info("- setup test preference -");
|
||||
await setup_test_preference();
|
||||
|
||||
info(`- check whether video document in iframe is autoplay -`);
|
||||
await checkIsIframeVideoDocumentAutoplay(browser);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче