зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1599803 - Factor out repeated logic in Picture-in-Picture tests. r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D90020
This commit is contained in:
Родитель
9e07fbde4d
Коммит
8298880157
|
@ -49,17 +49,7 @@ add_task(async function test_pip_keyboard_shortcut() {
|
|||
|
||||
ok(pipWin, "Got Picture-in-Picture window.");
|
||||
|
||||
try {
|
||||
await assertShowingMessage(browser, VIDEO_ID, true);
|
||||
} finally {
|
||||
let uaWidgetUpdate = BrowserTestUtils.waitForContentEvent(
|
||||
browser,
|
||||
"UAWidgetSetupOrChange",
|
||||
true /* capture */
|
||||
);
|
||||
await BrowserTestUtils.closeWindow(pipWin);
|
||||
await uaWidgetUpdate;
|
||||
}
|
||||
await ensureMessageAndClosePiP(browser, VIDEO_ID, pipWin, false);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -22,17 +22,7 @@ add_task(async () => {
|
|||
let pipWin = await triggerPictureInPicture(browser, videoID);
|
||||
ok(pipWin, "Got Picture-in-Picture window.");
|
||||
|
||||
try {
|
||||
await assertShowingMessage(browser, videoID, true);
|
||||
} finally {
|
||||
let uaWidgetUpdate = BrowserTestUtils.waitForContentEvent(
|
||||
browser,
|
||||
"UAWidgetSetupOrChange",
|
||||
true /* capture */
|
||||
);
|
||||
await BrowserTestUtils.closeWindow(pipWin);
|
||||
await uaWidgetUpdate;
|
||||
}
|
||||
await ensureMessageAndClosePiP(browser, videoID, pipWin, false);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -40,19 +40,7 @@ add_task(async () => {
|
|||
let pipWin = await triggerPictureInPicture(iframeBc, videoID);
|
||||
ok(pipWin, "Got Picture-in-Picture window.");
|
||||
|
||||
try {
|
||||
await assertShowingMessage(iframeBc, videoID, true);
|
||||
} finally {
|
||||
let uaWidgetUpdate = SpecialPowers.spawn(iframeBc, [], async () => {
|
||||
await ContentTaskUtils.waitForEvent(
|
||||
content.windowRoot,
|
||||
"UAWidgetSetupOrChange",
|
||||
true /* capture */
|
||||
);
|
||||
});
|
||||
await BrowserTestUtils.closeWindow(pipWin);
|
||||
await uaWidgetUpdate;
|
||||
}
|
||||
await ensureMessageAndClosePiP(iframeBc, videoID, pipWin, true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -763,3 +763,39 @@ async function promiseFullscreenExited(window, asyncFn) {
|
|||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that ensures that the "This video is
|
||||
* playing in Picture-in-Picture mode" message works,
|
||||
* then closes the player window
|
||||
*
|
||||
* @param {Element} browser The <xul:browser> that has the <video> loaded in it.
|
||||
* @param {String} videoID The ID of the video that has the toggle.
|
||||
* @param {Element} pipWin The Picture-in-Picture window that was opened
|
||||
* @param {Boolean} iframe True if the test is on an Iframe, which modifies
|
||||
* the test behavior
|
||||
*/
|
||||
async function ensureMessageAndClosePiP(browser, videoID, pipWin, isIframe) {
|
||||
try {
|
||||
await assertShowingMessage(browser, videoID, true);
|
||||
} finally {
|
||||
let uaWidgetUpdate = null;
|
||||
if (isIframe) {
|
||||
uaWidgetUpdate = SpecialPowers.spawn(browser, [], async () => {
|
||||
await ContentTaskUtils.waitForEvent(
|
||||
content.windowRoot,
|
||||
"UAWidgetSetupOrChange",
|
||||
true /* capture */
|
||||
);
|
||||
});
|
||||
} else {
|
||||
uaWidgetUpdate = BrowserTestUtils.waitForContentEvent(
|
||||
browser,
|
||||
"UAWidgetSetupOrChange",
|
||||
true /* capture */
|
||||
);
|
||||
}
|
||||
await BrowserTestUtils.closeWindow(pipWin);
|
||||
await uaWidgetUpdate;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче