Files
sousa-gecko/devtools/client/responsive/test/browser/browser_menu_item_01.js
T
Emilio Cobos Álvarez e833a1757b Bug 2033243 - Replace ownerGlobal with documentGlobal, and stop exposing ownerGlobal to JS. r=firefox-desktop-core-reviewers ,webidl,joschmidt,perftest-reviewers,sparky,smaug,mossop ,webidl,joschmidt,perftest-reviewers,sparky,smaug,mossop
Bug 2033191 made sure we only call ownerGlobal on nodes.

As per the discussion in dev-platform, the front-end ~always wants
.documentGlobal. This removes ownerGlobal from the bindings. Following
patch will rename internal GetOwnerGlobal in gecko to GetRelevantGlobal
as per the HTML spec terminology.

Differential Revision: https://phabricator.services.mozilla.com/D297183
2026-05-02 22:04:13 +00:00

68 lines
1.6 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test RDM menu item is checked when expected, on multiple tabs.
const TEST_URL = "data:text/html;charset=utf-8,";
const {
startup,
} = require("resource://devtools/client/responsive/utils/window.js");
const activateTab = tab =>
new Promise(resolve => {
const { gBrowser } = tab.documentGlobal;
const { tabContainer } = gBrowser;
tabContainer.addEventListener("TabSelect", function listener({ type }) {
tabContainer.removeEventListener(type, listener);
resolve();
});
gBrowser.selectedTab = tab;
});
const isMenuChecked = () => {
const menu = document.getElementById("menu_responsiveUI");
return menu.hasAttribute("checked");
};
add_task(async function () {
await startup(window);
ok(!isMenuChecked(), "RDM menu item is unchecked by default");
});
let tab2;
addRDMTaskWithPreAndPost(
TEST_URL,
function pre_task() {
ok(!isMenuChecked(), "RDM menu item is unchecked for new tab");
},
async function task({ browser }) {
ok(isMenuChecked(), "RDM menu item is checked with RDM open");
tab2 = await addTab(TEST_URL);
ok(!isMenuChecked(), "RDM menu item is unchecked for new tab");
const tab = gBrowser.getTabForBrowser(browser);
await activateTab(tab);
ok(
isMenuChecked(),
"RDM menu item is checked for the tab where RDM is open"
);
},
function post_task() {
ok(!isMenuChecked(), "RDM menu item is unchecked after RDM is closed");
}
);
add_task(async function () {
await removeTab(tab2);
});