mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 1553769 - Add a test for switching a tab via window.focus() on a related tab. r=dao
Differential Revision: https://phabricator.services.mozilla.com/D32396 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
25f075630a
commit
5f33ea86d5
@ -86,3 +86,5 @@ skip-if = os == 'mac'
|
||||
[browser_viewsource_of_data_URI_in_file_process.js]
|
||||
[browser_visibleTabs_bookmarkAllTabs.js]
|
||||
[browser_visibleTabs_contextMenu.js]
|
||||
[browser_tabswitch_window_focus.js]
|
||||
support-files = open_window_in_new_tab.html
|
||||
|
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
// Allow to open popups without any kind of interaction.
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_flip", false]]});
|
||||
|
||||
const FILE = getRootDirectory(gTestPath) + "open_window_in_new_tab.html";
|
||||
|
||||
add_task(async function() {
|
||||
info("Opening first tab: " + FILE);
|
||||
let firstTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, FILE);
|
||||
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, FILE + "?opened", true);
|
||||
info("Opening second tab using a click");
|
||||
await ContentTask.spawn(firstTab.linkedBrowser, "", async function() {
|
||||
content.document.querySelector("#open").click();
|
||||
});
|
||||
|
||||
info("Waiting for the second tab to be opened");
|
||||
let secondTab = await promiseTabOpened;
|
||||
|
||||
info("Going back to the first tab");
|
||||
await BrowserTestUtils.switchTab(gBrowser, firstTab);
|
||||
|
||||
info("Focusing second tab by clicking on the first tab");
|
||||
await BrowserTestUtils.switchTab(gBrowser, async function() {
|
||||
await ContentTask.spawn(firstTab.linkedBrowser, "", async function() {
|
||||
content.document.querySelector("#focus").click();
|
||||
});
|
||||
});
|
||||
|
||||
is(gBrowser.selectedTab, secondTab, "Should've switched tabs");
|
||||
|
||||
BrowserTestUtils.removeTab(firstTab);
|
||||
BrowserTestUtils.removeTab(secondTab);
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<!doctype html>
|
||||
<script>
|
||||
function openWindow() {
|
||||
window.childWindow = window.open(location.href + "?opened", "", "");
|
||||
}
|
||||
</script>
|
||||
<button id="open" onclick="openWindow()">Open window</button>
|
||||
<button id="focus" onclick="window.childWindow.focus()">Focus window</button>
|
Loading…
Reference in New Issue
Block a user