Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Errors

/* Any copyright is dedicated to the Public Domain.
"use strict";
/**
* Tests that a video being emptied while it is no longer rendered, but still
* has a src, is handled correctly based on the auto close pref
*/
add_task(async () => {
for (let autoCloseEnabledPref of [true, false]) {
await SpecialPowers.pushPrefEnv({
set: [
[AUTO_CLOSE_ENABLED_PREF, autoCloseEnabledPref],
[AUTO_CLOSE_TIMEOUT_PREF, 0],
],
});
for (let videoID of ["with-controls", "no-controls"]) {
info(`Testing ${videoID} case.`);
await BrowserTestUtils.withNewTab(
{
url: TEST_PAGE,
gBrowser,
},
async browser => {
let pipWin = await triggerPictureInPicture(browser, videoID);
Assert.ok(pipWin, "Got PiP window.");
Assert.ok(!pipWin.closed, "PiP window should be open.");
await SpecialPowers.spawn(browser, [videoID], async videoID => {
let doc = content.document;
let video = doc.querySelector(`#${videoID}`);
let emptied = ContentTaskUtils.waitForEvent(video, "emptied");
video.style.display = "none";
video.load();
await emptied;
});
if (autoCloseEnabledPref) {
await TestUtils.waitForCondition(
() => pipWin.closed,
"Player window closed."
);
Assert.ok(pipWin.closed, "PiP window should be closed.");
} else {
Assert.ok(!pipWin.closed, "PiP window should still be open.");
await BrowserTestUtils.closeWindow(pipWin);
}
}
);
}
}
});