blob: 5588b3a7752c55a63fbb8cc59ba16e971b80cf5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Helper function that tries to use the mouse to open the Picture-in-Picture
* player window for a video with and without the built-in controls.
*
* @param {Element} tab The tab to be tested.
* @return Promise
* @resolves When the toggles for both the video-with-controls and
* video-without-controls have been tested.
*/
async function testToggleForTab(tab) {
for (let videoID of ["with-controls", "no-controls"]) {
let browser = tab.linkedBrowser;
info(`Testing ${videoID} case.`);
await testToggleHelper(browser, videoID, true);
}
}
/**
* Tests that the Picture-in-Picture toggle still works after tearing out the
* tab into a new window, or tearing in a tab from one window to another.
*/
add_task(async () => {
// The startingTab will be torn out and placed in the new window.
let startingTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
TEST_PAGE
);
// Tear out the starting tab into its own window...
let newWinLoaded = BrowserTestUtils.waitForNewWindow();
let win2 = gBrowser.replaceTabWithWindow(startingTab);
await newWinLoaded;
// Let's maximize the newly opened window so we don't have to worry about
// the videos being visible.
if (win2.windowState != win2.STATE_MAXIMIZED) {
let resizePromise = BrowserTestUtils.waitForEvent(win2, "resize");
win2.maximize();
await resizePromise;
}
await SimpleTest.promiseFocus(win2);
await testToggleForTab(win2.gBrowser.selectedTab);
// Now bring the tab back to the original window.
let dragInTab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
gBrowser.swapBrowsersAndCloseOther(dragInTab, win2.gBrowser.selectedTab);
await SimpleTest.promiseFocus(window);
await testToggleForTab(dragInTab);
BrowserTestUtils.removeTab(dragInTab);
});
|