зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1495944) for DevTools failures in devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_menubar.js
Backed out changeset 52e5f0d01900 (bug 1495944) Backed out changeset 025ffd6f441f (bug 1495944) Backed out changeset df656c9d03b1 (bug 1495944) Backed out changeset be64b571b600 (bug 1495944) Backed out changeset 9418ac4c2fa1 (bug 1495944)
This commit is contained in:
Родитель
7a8b0165bc
Коммит
5e7e061044
|
@ -425,21 +425,12 @@ nsContextMenu.prototype = {
|
|||
this.showItem("context-viewpartialsource-selection",
|
||||
this.isContentSelected);
|
||||
|
||||
const {gBrowser} = this.browser.ownerGlobal;
|
||||
// Hide menu that opens devtools when the window is showing `about:devtools-toolbox`.
|
||||
// This is to avoid displaying multiple devtools at the same time. See bug 1495944.
|
||||
const isAboutDevtoolsToolbox = gBrowser &&
|
||||
gBrowser.currentURI &&
|
||||
gBrowser.currentURI.scheme === "about" &&
|
||||
gBrowser.currentURI.filePath === "devtools-toolbox";
|
||||
|
||||
var shouldShow = !(this.isContentSelected ||
|
||||
this.onImage || this.onCanvas ||
|
||||
this.onVideo || this.onAudio ||
|
||||
this.onLink || this.onTextInput);
|
||||
|
||||
var showInspect = this.inTabBrowser &&
|
||||
!isAboutDevtoolsToolbox &&
|
||||
Services.prefs.getBoolPref("devtools.inspector.enabled", true) &&
|
||||
!Services.prefs.getBoolPref("devtools.policy.disabled", false);
|
||||
|
||||
|
|
|
@ -40,9 +40,6 @@ skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug
|
|||
[browser_aboutdebugging_debug-target-pane_empty.js]
|
||||
[browser_aboutdebugging_debug-target-pane_usb_runtime.js]
|
||||
[browser_aboutdebugging_devtools.js]
|
||||
[browser_aboutdebugging_devtoolstoolbox_contextmenu.js]
|
||||
[browser_aboutdebugging_devtoolstoolbox_menubar.js]
|
||||
[browser_aboutdebugging_devtoolstoolbox_shortcuts.js]
|
||||
[browser_aboutdebugging_navigate.js]
|
||||
[browser_aboutdebugging_persist_connection.js]
|
||||
[browser_aboutdebugging_routes.js]
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Test context menu on about:devtools-toolbox page.
|
||||
*/
|
||||
add_task(async function() {
|
||||
info("Force all debug target panes to be expanded");
|
||||
prepareCollapsibilitiesTest();
|
||||
|
||||
const { document, tab, window } = await openAboutDebugging();
|
||||
|
||||
info("Show about:devtools-toolbox page");
|
||||
const target = findDebugTargetByText("about:debugging", document);
|
||||
ok(target, "about:debugging tab target appeared");
|
||||
const inspectButton = target.querySelector(".js-debug-target-inspect-button");
|
||||
ok(inspectButton, "Inspect button for about:debugging appeared");
|
||||
inspectButton.click();
|
||||
await Promise.all([
|
||||
waitUntil(() => tab.nextElementSibling),
|
||||
waitForRequestsToSettle(window.AboutDebugging.store),
|
||||
gDevTools.once("toolbox-ready"),
|
||||
]);
|
||||
|
||||
info("Wait for about:devtools-toolbox tab will be selected");
|
||||
const devtoolsTab = tab.nextElementSibling;
|
||||
await waitUntil(() => gBrowser.selectedTab === devtoolsTab);
|
||||
info("Check whether the menu item which opens devtools is disabled");
|
||||
const rootDocument = devtoolsTab.ownerDocument;
|
||||
await assertContextMenu(rootDocument, gBrowser.selectedBrowser,
|
||||
".debug-target-info", false);
|
||||
|
||||
info("Force to select about:debugging page");
|
||||
gBrowser.selectedTab = tab;
|
||||
info("Check whether the menu item which opens devtools is enabled");
|
||||
await assertContextMenu(rootDocument, gBrowser.selectedBrowser, "#mount", true);
|
||||
|
||||
await removeTab(devtoolsTab);
|
||||
await waitForRequestsToSettle(window.AboutDebugging.store);
|
||||
await removeTab(tab);
|
||||
});
|
||||
|
||||
async function assertContextMenu(rootDocument, browser, targetSelector, shouldBeEnabled) {
|
||||
// Show content context menu.
|
||||
const contextMenu = rootDocument.getElementById("contentAreaContextMenu");
|
||||
const popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
|
||||
BrowserTestUtils.synthesizeMouseAtCenter(targetSelector,
|
||||
{ type: "contextmenu" }, browser);
|
||||
await popupShownPromise;
|
||||
|
||||
// Check hidden attribute of #context-inspect.
|
||||
const inspectMenuItem = rootDocument.getElementById("context-inspect");
|
||||
is(inspectMenuItem.hidden, !shouldBeEnabled,
|
||||
'"hidden" attribute of #context-inspect should be correct');
|
||||
|
||||
// Hide content context menu.
|
||||
const popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
|
||||
contextMenu.hidePopup();
|
||||
await popupHiddenPromise;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Test the status of menu items when open about:devtools-toolbox.
|
||||
*/
|
||||
add_task(async function() {
|
||||
info("Force all debug target panes to be expanded");
|
||||
prepareCollapsibilitiesTest();
|
||||
|
||||
const { document, tab, window } = await openAboutDebugging();
|
||||
|
||||
info("Show about:devtools-toolbox page");
|
||||
const target = findDebugTargetByText("about:debugging", document);
|
||||
ok(target, "about:debugging tab target appeared");
|
||||
const inspectButton = target.querySelector(".js-debug-target-inspect-button");
|
||||
ok(inspectButton, "Inspect button for about:debugging appeared");
|
||||
inspectButton.click();
|
||||
await Promise.all([
|
||||
waitUntil(() => tab.nextElementSibling),
|
||||
waitForRequestsToSettle(window.AboutDebugging.store),
|
||||
gDevTools.once("toolbox-ready"),
|
||||
]);
|
||||
|
||||
info("Wait for about:devtools-toolbox tab will be selected");
|
||||
const devtoolsTab = tab.nextElementSibling;
|
||||
await waitUntil(() => gBrowser.selectedTab === devtoolsTab);
|
||||
info("Check whether the menu items are disabled");
|
||||
const rootDocument = devtoolsTab.ownerDocument;
|
||||
await assertMenusItems(rootDocument, false);
|
||||
|
||||
info("Force to select about:debugging page");
|
||||
gBrowser.selectedTab = tab;
|
||||
info("Check whether the menu items are enabled");
|
||||
await assertMenusItems(rootDocument, true);
|
||||
|
||||
await removeTab(devtoolsTab);
|
||||
await waitForRequestsToSettle(window.AboutDebugging.store);
|
||||
await removeTab(tab);
|
||||
});
|
||||
|
||||
async function assertMenusItems(rootDocument, shouldBeEnabled) {
|
||||
const menuItem = rootDocument.getElementById("menu_devToolbox");
|
||||
// Wait for hidden attribute changed since the menu items will update asynchronously.
|
||||
await waitUntil(() => menuItem.hidden === !shouldBeEnabled);
|
||||
|
||||
assertMenuItem(rootDocument, "menu_devToolbox", shouldBeEnabled);
|
||||
|
||||
for (const toolDefinition of gDevTools.getToolDefinitionArray()) {
|
||||
if (!toolDefinition.inMenu) {
|
||||
continue;
|
||||
}
|
||||
|
||||
assertMenuItem(rootDocument, "menuitem_" + toolDefinition.id, shouldBeEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
function assertMenuItem(rootDocument, menuItemId, shouldBeEnabled) {
|
||||
const menuItem = rootDocument.getElementById(menuItemId);
|
||||
is(menuItem.hidden, !shouldBeEnabled,
|
||||
`"hidden" attribute of menu item(${ menuItemId }) should be correct`);
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Test shortcut keys on about:devtools-toolbox page.
|
||||
*/
|
||||
add_task(async function() {
|
||||
info("Force all debug target panes to be expanded");
|
||||
prepareCollapsibilitiesTest();
|
||||
|
||||
const { document, tab, window } = await openAboutDebugging();
|
||||
|
||||
info("Show about:devtools-toolbox page");
|
||||
const target = findDebugTargetByText("about:debugging", document);
|
||||
ok(target, "about:debugging tab target appeared");
|
||||
const inspectButton = target.querySelector(".js-debug-target-inspect-button");
|
||||
ok(inspectButton, "Inspect button for about:debugging appeared");
|
||||
inspectButton.click();
|
||||
await Promise.all([
|
||||
waitUntil(() => tab.nextElementSibling),
|
||||
waitForRequestsToSettle(window.AboutDebugging.store),
|
||||
gDevTools.once("toolbox-ready"),
|
||||
]);
|
||||
|
||||
info("Wait for about:devtools-toolbox tab will be selected");
|
||||
const devtoolsTab = tab.nextElementSibling;
|
||||
await waitUntil(() => gBrowser.selectedTab === devtoolsTab);
|
||||
info("Check whether the shortcut keys which opens devtools is disabled");
|
||||
await assertShortcutKeys(gBrowser.selectedBrowser, false);
|
||||
|
||||
info("Force to select about:debugging page");
|
||||
gBrowser.selectedTab = tab;
|
||||
info("Check whether the shortcut keys which opens devtools is enabled");
|
||||
await assertShortcutKeys(gBrowser.selectedBrowser, true);
|
||||
|
||||
await removeTab(devtoolsTab);
|
||||
await waitForRequestsToSettle(window.AboutDebugging.store);
|
||||
await removeTab(tab);
|
||||
});
|
||||
|
||||
async function assertShortcutKeys(browser, shouldBeEnabled) {
|
||||
await assertShortcutKey(browser.contentWindow, "VK_F12", {}, shouldBeEnabled);
|
||||
await assertShortcutKey(browser.contentWindow, "I", {
|
||||
accelKey: true,
|
||||
shiftKey: !navigator.userAgent.match(/Mac/),
|
||||
altKey: navigator.userAgent.match(/Mac/),
|
||||
}, shouldBeEnabled);
|
||||
}
|
||||
|
||||
async function assertShortcutKey(win, key, modifiers, shouldBeEnabled) {
|
||||
info(`Assert shortcut key [${ key }]`);
|
||||
|
||||
if (shouldBeEnabled) {
|
||||
await assertShortcutKeyEnabled(win, key, modifiers);
|
||||
} else {
|
||||
await assertShortcutKeyDisabled(win, key, modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
async function assertShortcutKeyDisabled(win, key, modifiers) {
|
||||
let isReadyCalled = false;
|
||||
const toolboxListener = () => {
|
||||
isReadyCalled = true;
|
||||
};
|
||||
gDevTools.on("toolbox-ready", toolboxListener);
|
||||
|
||||
EventUtils.synthesizeKey(key, modifiers, win);
|
||||
await wait(1000);
|
||||
ok(!isReadyCalled, `Devtools should not be opened by ${ key }`);
|
||||
|
||||
gDevTools.off("toolbox-ready", toolboxListener);
|
||||
}
|
||||
|
||||
async function assertShortcutKeyEnabled(win, key, modifiers) {
|
||||
// Open devtools
|
||||
const onToolboxReady = gDevTools.once("toolbox-ready");
|
||||
EventUtils.synthesizeKey(key, modifiers, win);
|
||||
await onToolboxReady;
|
||||
ok(true, `Devtools should be opened by ${ key }`);
|
||||
|
||||
// Close devtools
|
||||
const onToolboxDestroyed = gDevTools.once("toolbox-destroyed");
|
||||
EventUtils.synthesizeKey(key, modifiers, win);
|
||||
await onToolboxDestroyed;
|
||||
ok(true, `Devtopls should be closed by ${ key }`);
|
||||
}
|
|
@ -299,51 +299,3 @@ exports.removeMenus = function(doc) {
|
|||
// unregistering each tool.
|
||||
removeTopLevelItems(doc);
|
||||
};
|
||||
|
||||
/**
|
||||
* This is used for about:devtools-toolbox and that we are hiding the main toolbox toggle
|
||||
* menu item, as well as all the tool items displayed on the menu. But we keep the
|
||||
* non-toolbox menu items such as Scratchpad, Browser Console etc.
|
||||
*
|
||||
* @param {XULDocument} doc
|
||||
* @param {boolean} isEnabled
|
||||
*/
|
||||
function setDevtoolsMenuItemsEnabled(doc, isEnabled) {
|
||||
setMenuItemEnabled(doc, "menu_devToolbox", isEnabled);
|
||||
|
||||
for (const toolDefinition of gDevTools.getToolDefinitionArray()) {
|
||||
if (!toolDefinition.inMenu) {
|
||||
continue;
|
||||
}
|
||||
setMenuItemEnabled(doc, "menuitem_" + toolDefinition.id, isEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
function setMenuItemEnabled(doc, menuItemId, isEnabled) {
|
||||
const menuItem = doc.getElementById(menuItemId);
|
||||
if (menuItem) {
|
||||
if (isEnabled) {
|
||||
menuItem.removeAttribute("hidden");
|
||||
} else {
|
||||
menuItem.setAttribute("hidden", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable all devtools menu items.
|
||||
*
|
||||
* @param {XULDocument} doc
|
||||
*/
|
||||
exports.enableDevtoolsMenuItems = function(doc) {
|
||||
setDevtoolsMenuItemsEnabled(doc, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable all devtools menu items.
|
||||
*
|
||||
* @param {XULDocument} doc
|
||||
*/
|
||||
exports.disableDevtoolsMenuItems = function(doc) {
|
||||
setDevtoolsMenuItemsEnabled(doc, false);
|
||||
};
|
||||
|
|
|
@ -242,16 +242,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
* `Cu.now()` timing.
|
||||
*/
|
||||
async onKeyShortcut(window, key, startTime) {
|
||||
// Avoid to open devtools when the about:devtools-toolbox page is showing
|
||||
// on the window now.
|
||||
if (gDevToolsBrowser._isAboutDevtoolsToolbox(window) &&
|
||||
(key.toolId ||
|
||||
key.id === "toggleToolbox" ||
|
||||
key.id === "toggleToolboxF12" ||
|
||||
key.id === "inspectorMac")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is a toolbox's panel key shortcut, delegate to selectToolCommand
|
||||
if (key.toolId) {
|
||||
await gDevToolsBrowser.selectToolCommand(window.gBrowser, key.toolId, startTime);
|
||||
|
@ -599,10 +589,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
|
||||
for (const win of gDevToolsBrowser._trackedBrowserWindows) {
|
||||
BrowserMenus.insertToolMenuElements(win.document, toolDefinition, prevDef);
|
||||
// If we are on a page where devtools menu items are hidden such as
|
||||
// about:devtools-toolbox, we need to call _updateMenuItems to update the
|
||||
// visibility of the newly created menu item.
|
||||
gDevToolsBrowser._updateMenuItems(win);
|
||||
}
|
||||
|
||||
if (toolDefinition.id === "jsdebugger") {
|
||||
|
@ -621,50 +607,22 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Update developer tools menu items and the "Toggle Tools" checkbox. This is
|
||||
* Update the "Toggle Tools" checkbox in the developer tools menu. This is
|
||||
* called when a toolbox is created or destroyed.
|
||||
*/
|
||||
_updateMenu() {
|
||||
_updateMenuCheckbox() {
|
||||
for (const win of gDevToolsBrowser._trackedBrowserWindows) {
|
||||
gDevToolsBrowser._updateMenuItems(win);
|
||||
const hasToolbox = gDevToolsBrowser.hasToolboxOpened(win);
|
||||
|
||||
const menu = win.document.getElementById("menu_devToolbox");
|
||||
if (hasToolbox) {
|
||||
menu.setAttribute("checked", "true");
|
||||
} else {
|
||||
menu.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Update developer tools menu items and the "Toggle Tools" checkbox of XULWindow.
|
||||
*
|
||||
* @param {XULWindow} win
|
||||
*/
|
||||
_updateMenuItems(win) {
|
||||
if (gDevToolsBrowser._isAboutDevtoolsToolbox(win)) {
|
||||
BrowserMenus.disableDevtoolsMenuItems(win.document);
|
||||
return;
|
||||
}
|
||||
|
||||
BrowserMenus.enableDevtoolsMenuItems(win.document);
|
||||
|
||||
const hasToolbox = gDevToolsBrowser.hasToolboxOpened(win);
|
||||
|
||||
const menu = win.document.getElementById("menu_devToolbox");
|
||||
if (hasToolbox) {
|
||||
menu.setAttribute("checked", "true");
|
||||
} else {
|
||||
menu.removeAttribute("checked");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether the window is showing about:devtools-toolbox page or not.
|
||||
*
|
||||
* @param {XULWindow} win
|
||||
* @return {boolean} true: about:devtools-toolbox is showing
|
||||
* false: otherwise
|
||||
*/
|
||||
_isAboutDevtoolsToolbox(win) {
|
||||
const currentURI = win.gBrowser.currentURI;
|
||||
return currentURI.scheme === "about" && currentURI.filePath === "devtools-toolbox";
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the menuitem for a tool to all open browser windows.
|
||||
*
|
||||
|
@ -717,7 +675,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case "TabSelect":
|
||||
gDevToolsBrowser._updateMenu();
|
||||
gDevToolsBrowser._updateMenuCheckbox();
|
||||
break;
|
||||
case "unload":
|
||||
// top-level browser window unload
|
||||
|
@ -769,8 +727,8 @@ gDevTools.on("tool-unregistered", function(toolId) {
|
|||
gDevToolsBrowser._removeToolFromWindows(toolId);
|
||||
});
|
||||
|
||||
gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenu);
|
||||
gDevTools.on("toolbox-destroyed", gDevToolsBrowser._updateMenu);
|
||||
gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenuCheckbox);
|
||||
gDevTools.on("toolbox-destroyed", gDevToolsBrowser._updateMenuCheckbox);
|
||||
|
||||
Services.obs.addObserver(gDevToolsBrowser, "quit-application");
|
||||
Services.obs.addObserver(gDevToolsBrowser, "browser-delayed-startup-finished");
|
||||
|
|
Загрузка…
Ссылка в новой задаче