зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1665527
- part4 : add new testcase for 'browser_stop_control_after_media_reaches_to_end.js'. r=chunmin
Differential Revision: https://phabricator.services.mozilla.com/D90773
This commit is contained in:
Родитель
ddadb81a93
Коммит
f0457c5e96
|
@ -10,9 +10,11 @@ add_task(async function setupTestingPref() {
|
|||
|
||||
/**
|
||||
* This test is used to ensure that we would stop controlling media after it
|
||||
* reaches to the end.
|
||||
* reaches to the end when a controller doesn't have an active media session.
|
||||
* If a controller has an active media session, it would keep active despite
|
||||
* media reaches to the end.
|
||||
*/
|
||||
add_task(async function testControlShouldStopAfterMediaReachesToTheEnd() {
|
||||
add_task(async function testControllerShouldStopAfterMediaReachesToTheEnd() {
|
||||
info(`open media page and play media until the end`);
|
||||
const tab = await createTabAndLoad(PAGE_URL);
|
||||
await Promise.all([
|
||||
|
@ -24,6 +26,21 @@ add_task(async function testControlShouldStopAfterMediaReachesToTheEnd() {
|
|||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function testControllerWontStopAfterMediaReachesToTheEnd() {
|
||||
info(`open media page and create media session`);
|
||||
const tab = await createTabAndLoad(PAGE_URL);
|
||||
await createMediaSession(tab);
|
||||
|
||||
info(`play media until the end`);
|
||||
await playMediaUntilItReachesToTheEnd(tab);
|
||||
|
||||
info(`controller is still active because of having active media session`);
|
||||
await checkControllerIsActive(tab);
|
||||
|
||||
info(`remove tab`);
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
/**
|
||||
* The following are helper functions.
|
||||
*/
|
||||
|
@ -77,3 +94,15 @@ function playMediaUntilItReachesToTheEnd(tab) {
|
|||
await new Promise(r => (video.onended = r));
|
||||
});
|
||||
}
|
||||
|
||||
function createMediaSession(tab) {
|
||||
return SpecialPowers.spawn(tab.linkedBrowser, [], _ => {
|
||||
// simply create a media session, which would become the active media session later.
|
||||
content.navigator.mediaSession;
|
||||
});
|
||||
}
|
||||
|
||||
function checkControllerIsActive(tab) {
|
||||
const controller = tab.linkedBrowser.browsingContext.mediaController;
|
||||
ok(controller.isActive, `controller is active`);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче