Backed out 5 changesets (bug 1543940) for failing browser_menu_api.js on a CLOSED TREE

Backed out changeset aaa0f827616a (bug 1543940)
Backed out changeset 590b72185b69 (bug 1543940)
Backed out changeset 42e2136f684f (bug 1543940)
Backed out changeset a66967f17042 (bug 1543940)
Backed out changeset b1e6e932873c (bug 1543940)
This commit is contained in:
Andreea Pavel 2019-05-08 20:49:43 +03:00
Родитель 349aacd444
Коммит 95a481edab
58 изменённых файлов: 293 добавлений и 274 удалений

Просмотреть файл

@ -15,7 +15,7 @@ add_task(async function() {
const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);
const { devtoolsTab, devtoolsWindow } =
const { devtoolsDocument, devtoolsTab, devtoolsWindow } =
await openAboutDevtoolsToolbox(document, tab, window);
info("Select inspector tool");
@ -29,7 +29,7 @@ add_task(async function() {
markupDocument.ownerGlobal);
info("Check whether proper context menu of markup view will be shown");
await waitUntil(() => toolbox.topDoc.querySelector("#node-menu-edithtml"));
await waitUntil(() => devtoolsDocument.querySelector("#node-menu-edithtml"));
ok(true, "Context menu of markup view should be shown");
await closeAboutDevtoolsToolbox(document, devtoolsTab, window);

Просмотреть файл

@ -203,7 +203,7 @@ class AccessibilityRow extends Component {
}));
}
menu.popup(e.screenX, e.screenY, gToolbox.doc);
menu.popup(e.screenX, e.screenY, gToolbox);
if (gTelemetry) {
gTelemetry.scalarAdd(TELEMETRY_ACCESSIBLE_CONTEXT_MENU_OPENED, 1);

Просмотреть файл

@ -15,7 +15,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -36,7 +36,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -57,7 +57,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -78,7 +78,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -99,7 +99,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -120,7 +120,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -141,7 +141,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}

28
devtools/client/debugger/dist/vendors.js поставляемый
Просмотреть файл

@ -2610,12 +2610,12 @@ function showMenu(evt, items) {
});
if (inToolbox()) {
menu.popup(evt.screenX, evt.screenY, window.parent.document);
menu.popup(evt.screenX, evt.screenY, { doc: window.parent.document });
return;
}
menu.on("open", (_, popup) => onShown(menu, popup));
menu.popup(evt.clientX, evt.clientY, document);
menu.popup(evt.clientX, evt.clientY, { doc: document });
}
function createSubMenu(subItems) {
@ -2712,11 +2712,6 @@ function inToolbox() {
}
}
// Copied from m-c DevToolsUtils.
function getTopWindow(win) {
return win.windowRoot ? win.windowRoot.ownerGlobal : win.top;
}
/**
* A partial implementation of the Menu API provided by electron:
* https://github.com/electron/electron/blob/master/docs/api/menu.md.
@ -2768,16 +2763,11 @@ Menu.prototype.insert = function (pos, menuItem) {
*
* @param {int} screenX
* @param {int} screenY
* @param {Document} doc
* The document that should own the context menu.
* @param Toolbox toolbox (non standard)
* Needed so we in which window to inject XUL
*/
Menu.prototype.popup = function (screenX, screenY, doc) {
// The context-menu will be created in the topmost window to preserve keyboard
// navigation. See Bug 1543940. Keep a reference on the window owning the menu to hide
// the popup on unload.
const win = doc.defaultView;
doc = getTopWindow(doc.defaultView).document;
Menu.prototype.popup = function (screenX, screenY, toolbox) {
let doc = toolbox.doc;
let popupset = doc.querySelector("popupset");
if (!popupset) {
popupset = doc.createXULElement("popupset");
@ -2800,15 +2790,9 @@ Menu.prototype.popup = function (screenX, screenY, doc) {
}
this._createMenuItems(popup);
// The context menu will be created in the topmost chrome window. Hide it manually when
// the owner document is unloaded.
const onWindowUnload = () => popup.hidePopup();
win.addEventListener("unload", onWindowUnload);
// Remove the menu from the DOM once it's hidden.
popup.addEventListener("popuphidden", e => {
if (e.target === popup) {
win.removeEventListener("unload", onWindowUnload);
popup.remove();
this.emit("close", popup);
}

Просмотреть файл

@ -53,7 +53,7 @@
"babel-plugin-transform-imports": "^1.5.0",
"codemirror": "^5.28.0",
"devtools-environment": "^0.0.6",
"devtools-launchpad": "^0.0.152",
"devtools-launchpad": "^0.0.151",
"devtools-linters": "^0.0.4",
"devtools-reps": "0.23.0",
"devtools-source-map": "0.16.0",

Просмотреть файл

@ -38,7 +38,7 @@
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-preset-react": "^6.24.1",
"devtools-config": "^0.0.16",
"devtools-launchpad": "^0.0.152",
"devtools-launchpad": "^0.0.150",
"devtools-license-check": "^0.7.0",
"devtools-modules": "~1.1.0",
"devtools-services": "^0.0.1",

Просмотреть файл

@ -1380,13 +1380,13 @@ async function clickGutter(dbg, line) {
function selectContextMenuItem(dbg, selector) {
// the context menu is in the toolbox window
const doc = dbg.toolbox.topDoc;
const doc = dbg.toolbox.win.document;
// there are several context menus, we want the one with the menu-api
const popup = doc.querySelector('menupopup[menu-api="true"]');
const item = popup.querySelector(selector);
return EventUtils.synthesizeMouseAtCenter(item, {}, dbg.toolbox.topWindow);
return EventUtils.synthesizeMouseAtCenter(item, {}, dbg.toolbox.win);
}
async function typeInPanel(dbg, text) {

Просмотреть файл

@ -3270,17 +3270,15 @@ devtools-config@^0.0.16:
version "0.0.16"
resolved "https://registry.yarnpkg.com/devtools-config/-/devtools-config-0.0.16.tgz#e7251788422f42a16aa1372b6adbebfcb7a74994"
devtools-connection@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/devtools-connection/-/devtools-connection-1.0.7.tgz#16f23256f842dce339038cdc273c49c473ef83e0"
integrity sha512-SrBHnM4nVhTrSfI4WnqcmppDOwB5iQvoEjqVNpwv63puGdKGtcdfWqv4+4gqfRYKHrdGB8tJfWJV2n+EyXb1Xw==
devtools-connection@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/devtools-connection/-/devtools-connection-1.0.6.tgz#f099c23ec7b16620214756739fd58ae9a5c6eedb"
devtools-contextmenu@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/devtools-contextmenu/-/devtools-contextmenu-1.0.5.tgz#b9f9687ada3030b5813d947c4288d7e976c9578a"
integrity sha512-e5QPL/P6vIkpdI3KU9G7OoTqoMF7joERZhq97ZKU0qgqczsbZh/OeM9scR1cQ4vrckN75WUzw+/Ucmly+kn2lw==
devtools-contextmenu@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/devtools-contextmenu/-/devtools-contextmenu-1.0.3.tgz#3a13a555a493df5c4f0123d414bee287e4625122"
dependencies:
devtools-modules "~1.1.2"
devtools-modules "~1.1.1"
devtools-environment@^0.0.5:
version "0.0.5"
@ -3290,10 +3288,9 @@ devtools-environment@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/devtools-environment/-/devtools-environment-0.0.6.tgz#11584f5b1ead784c2356d8da647a630fed591a4e"
devtools-launchpad@^0.0.152:
version "0.0.152"
resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.152.tgz#bbd9526c0933adb3d61baa9bb5d56231adc1e318"
integrity sha512-OX/c1LmYLV4BDlTGqTe/zMJvtLdp0vn9WXuTkRXmbSBELMT3ojNv1CAvX3r90iMEeE8PO20bF0IQMUAE/OqjMw==
devtools-launchpad@^0.0.150:
version "0.0.150"
resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.150.tgz#3091dacceb061583dc053512b836232afa5de3d5"
dependencies:
amd-loader "0.0.8"
autoprefixer "^7.1.2"
@ -3318,12 +3315,83 @@ devtools-launchpad@^0.0.152:
css-loader "^0.26.1"
debug "^3.1.0"
devtools-config "^0.0.16"
devtools-connection "^1.0.7"
devtools-contextmenu "~1.0.5"
devtools-connection "^1.0.6"
devtools-contextmenu "~1.0.3"
devtools-environment "^0.0.5"
devtools-license-check "^0.7.0"
devtools-mc-assets "^0.0.7"
devtools-modules "~1.1.2"
devtools-modules "~1.1.1"
devtools-sprintf-js "^1.0.3"
express "^4.13.4"
express-static "^1.2.5"
extract-text-webpack-plugin "^3.0.0"
fs-extra "^2.0.0"
fuzzaldrin-plus "^0.4.0"
geckodriver "=1.12.2"
immutable "^3.7.6"
json-loader "^0.5.4"
md5 "^2.2.1"
mime-types "^2.1.18"
minimist "^1.2.0"
mustache "^2.2.1"
node-static "^0.7.7"
postcss "^6.0.6"
postcss-class-namespace "^0.1.0"
postcss-loader "^2.0.6"
postcss-url-mapper "^1.2.0"
prop-types "^15.6.0"
properties-parser "^0.3.1"
ps-node "^0.1.4"
raw-loader "^0.5.1"
react "^16.4.1"
react-dom "^16.4.1"
react-dom-factories "^1.0.2"
react-redux "^5.0.6"
redux "^3.7.2"
selenium-webdriver "=3.6.0"
style-loader "^0.18.2"
svg-inline-loader "^0.8.0"
svg-inline-react "3.0.0"
url-loader "^0.5.9"
webpack "^3.3.0"
webpack-dev-middleware "^1.11.0"
webpack-env-loader-plugin "^1.0.0"
webpack-hot-middleware "^2.18.2"
ws "^1.0.1"
devtools-launchpad@^0.0.151:
version "0.0.151"
resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.151.tgz#b7b3a5592b0b4369566e1a82802252a3f55b93f3"
dependencies:
amd-loader "0.0.8"
autoprefixer "^7.1.2"
babel-cli "^6.7.5"
babel-core "^6.25.0"
babel-eslint "^7.1.0"
babel-loader "^7.1.1"
babel-plugin-module-resolver "^2.2.0"
babel-plugin-transform-async-to-generator "^6.16.0"
babel-plugin-transform-flow-strip-types "^6.14.0"
babel-plugin-transform-runtime "^6.7.5"
babel-plugin-webpack-alias "^2.1.1"
babel-polyfill "^6.7.4"
babel-preset-es2015 "^6.24.1"
babel-preset-react "^6.24.1"
babel-register "^6.18.0"
body-parser "^1.15.2"
check-node-version "^3.2.0"
chrome-remote-interface "0.17.0"
classnames "^2.2.5"
co "=4.6.0"
css-loader "^0.26.1"
debug "^3.1.0"
devtools-config "^0.0.16"
devtools-connection "^1.0.6"
devtools-contextmenu "~1.0.3"
devtools-environment "^0.0.5"
devtools-license-check "^0.7.0"
devtools-mc-assets "^0.0.7"
devtools-modules "~1.1.1"
devtools-sprintf-js "^1.0.3"
express "^4.13.4"
express-static "^1.2.5"
@ -3411,10 +3479,9 @@ devtools-modules@~1.1.0:
devtools-services "0.0.1"
punycode "^2.1.0"
devtools-modules@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/devtools-modules/-/devtools-modules-1.1.2.tgz#3a1f2134469858330461a62ede80fe361dd2174f"
integrity sha512-RW1AVqQOXkrBCxHQcIUR5dn7oeECoCzFhdQlGQ+fTRZYVGkdmDv2GEmR3P/s+31ae4khxjKs6g9I7is7vFynWg==
devtools-modules@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/devtools-modules/-/devtools-modules-1.1.1.tgz#c93a1ed858d93d48b61f3f470d39460805f07bfe"
dependencies:
devtools-services "0.0.1"
punycode "^2.1.0"
@ -3507,11 +3574,6 @@ domelementtype@1, domelementtype@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2"
domelementtype@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.1.tgz#d048c44b37b0d10a7f2a3d5fee3f4333d790481f"
integrity sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==
domelementtype@~1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b"
@ -3941,15 +4003,6 @@ eslint-plugin-mozilla@1.1.3:
ini-parser "0.0.2"
sax "1.2.4"
eslint-plugin-mozilla@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-mozilla/-/eslint-plugin-mozilla-1.2.1.tgz#8aa80dca43bd45f300188d4ee53bc5a983aac0ba"
integrity sha512-i6SAWTPgKI6T50L6Gy41efR3StjPGR3IWkFOW/4aGsJtpl+OmJVaOmUfhp5PGis3ZbDisNvQ/vzLiNicAWC7nw==
dependencies:
htmlparser2 "3.10.1"
ini-parser "0.0.2"
sax "1.2.4"
eslint-plugin-prettier@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz#f6b823e065f8c36529918cdb766d7a0e975ec30c"
@ -4620,10 +4673,9 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
flow-bin@0.97.0:
version "0.97.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.97.0.tgz#036ffcfc27503367a9d906ec9d843a0aa6f6bb83"
integrity sha512-jXjD05gkatLuC4+e28frH1hZoRwr1iASP6oJr61Q64+kR4kmzaS+AdFBhYgoYS5kpoe4UzwDebWK8ETQFNh00w==
flow-bin@0.96.0:
version "0.96.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.96.0.tgz#3b0379d97304dc1879ae6db627cd2d6819998661"
flush-write-stream@^1.0.0:
version "1.0.3"
@ -5368,18 +5420,6 @@ htmlparser2@3.10.0:
inherits "^2.0.1"
readable-stream "^3.0.6"
htmlparser2@3.10.1:
version "3.10.1"
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f"
integrity sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==
dependencies:
domelementtype "^1.3.1"
domhandler "^2.3.0"
domutils "^1.5.1"
entities "^1.1.1"
inherits "^2.0.1"
readable-stream "^3.1.1"
htmlparser2@^3.9.1, htmlparser2@^3.9.2:
version "3.9.2"
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338"
@ -9391,15 +9431,6 @@ readable-stream@^3.0.6:
string_decoder "^1.1.1"
util-deprecate "^1.0.1"
readable-stream@^3.1.1:
version "3.3.0"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.3.0.tgz#cb8011aad002eb717bf040291feba8569c986fb9"
integrity sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==
dependencies:
inherits "^2.0.3"
string_decoder "^1.1.1"
util-deprecate "^1.0.1"
readable-stream@~2.0.6:
version "2.0.6"
resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e"

Просмотреть файл

@ -6,7 +6,6 @@
"use strict";
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const EventEmitter = require("devtools/shared/event-emitter");
const { getCurrentZoom } = require("devtools/shared/layout/utils");
@ -60,11 +59,11 @@ Menu.prototype.insert = function(pos, menuItem) {
*
* @param {int} x
* @param {int} y
* @param {Document} doc
* @param Toolbox toolbox
*/
Menu.prototype.popupWithZoom = function(x, y, doc) {
const zoom = getCurrentZoom(doc);
this.popup(x * zoom, y * zoom, doc);
Menu.prototype.popupWithZoom = function(x, y, toolbox) {
const zoom = getCurrentZoom(toolbox.doc);
this.popup(x * zoom, y * zoom, toolbox);
};
/**
@ -76,15 +75,11 @@ Menu.prototype.popupWithZoom = function(x, y, doc) {
*
* @param {int} screenX
* @param {int} screenY
* @param {Document} doc
* The document that should own the context menu.
* @param Toolbox toolbox (non standard)
* Needed so we in which window to inject XUL
*/
Menu.prototype.popup = function(screenX, screenY, doc) {
// The context-menu will be created in the topmost window to preserve keyboard
// navigation (see Bug 1543940).
// Keep a reference on the window owning the menu to hide the popup on unload.
const win = doc.defaultView;
doc = DevToolsUtils.getTopWindow(doc.defaultView).document;
Menu.prototype.popup = function(screenX, screenY, toolbox) {
const doc = toolbox.doc;
let popupset = doc.querySelector("popupset");
if (!popupset) {
@ -110,15 +105,9 @@ Menu.prototype.popup = function(screenX, screenY, doc) {
}
this._createMenuItems(popup);
// The context menu will be created in the topmost chrome window. Hide it manually when
// the owner document is unloaded.
const onWindowUnload = () => popup.hidePopup();
win.addEventListener("unload", onWindowUnload);
// Remove the menu from the DOM once it's hidden.
popup.addEventListener("popuphidden", (e) => {
if (e.target === popup) {
win.removeEventListener("unload", onWindowUnload);
popup.remove();
this.emit("close");
}
@ -170,11 +159,6 @@ Menu.prototype._createMenuItems = function(parent) {
});
};
Menu.getMenuElementById = function(id, doc) {
const menuDoc = DevToolsUtils.getTopWindow(doc.defaultView).document;
return menuDoc.getElementById(id);
};
Menu.setApplicationMenu = () => {
throw Error("Not implemented");
};

Просмотреть файл

@ -80,15 +80,15 @@ async function testMenuPopup(toolbox) {
visible: false,
}));
menu.popup(0, 0, toolbox.doc);
menu.popup(0, 0, toolbox);
ok(toolbox.topDoc.querySelector("#menu-popup"), "A popup is in the DOM");
ok(toolbox.doc.querySelector("#menu-popup"), "A popup is in the DOM");
const menuSeparators =
toolbox.topDoc.querySelectorAll("#menu-popup > menuseparator");
toolbox.doc.querySelectorAll("#menu-popup > menuseparator");
is(menuSeparators.length, 1, "A separator is in the menu");
const menuItems = toolbox.topDoc.querySelectorAll("#menu-popup > menuitem");
const menuItems = toolbox.doc.querySelectorAll("#menu-popup > menuitem");
is(menuItems.length, MENU_ITEMS.length, "Correct number of menuitems");
is(menuItems[0].id, MENU_ITEMS[0].id, "Correct id for menuitem");
@ -109,11 +109,11 @@ async function testMenuPopup(toolbox) {
await once(menu, "open");
const closed = once(menu, "close");
EventUtils.synthesizeMouseAtCenter(menuItems[0], {}, toolbox.topWindow);
EventUtils.synthesizeMouseAtCenter(menuItems[0], {}, toolbox.win);
await closed;
ok(clickFired, "Click has fired");
ok(!toolbox.topDoc.querySelector("#menu-popup"), "Popup removed from the DOM");
ok(!toolbox.doc.querySelector("#menu-popup"), "Popup removed from the DOM");
}
async function testSubmenu(toolbox) {
@ -143,12 +143,12 @@ async function testSubmenu(toolbox) {
disabled: true,
}));
menu.popup(0, 0, toolbox.doc);
ok(toolbox.topDoc.querySelector("#menu-popup"), "A popup is in the DOM");
is(toolbox.topDoc.querySelectorAll("#menu-popup > menuitem").length, 0,
menu.popup(0, 0, toolbox);
ok(toolbox.doc.querySelector("#menu-popup"), "A popup is in the DOM");
is(toolbox.doc.querySelectorAll("#menu-popup > menuitem").length, 0,
"No menuitem children");
const menus = toolbox.topDoc.querySelectorAll("#menu-popup > menu");
const menus = toolbox.doc.querySelectorAll("#menu-popup > menu");
is(menus.length, 2, "Correct number of menus");
ok(!menus[0].hasAttribute("label"), "No label: should be set by localization");
ok(!menus[0].hasAttribute("disabled"), "Correct disabled state");
@ -180,7 +180,7 @@ async function testSubmenu(toolbox) {
await shown;
info("Clicking the submenu item");
EventUtils.synthesizeMouseAtCenter(subMenuItems[0], {}, toolbox.topWindow);
EventUtils.synthesizeMouseAtCenter(subMenuItems[0], {}, toolbox.win);
await closed;
ok(clickFired, "Click has fired");

Просмотреть файл

@ -33,7 +33,7 @@ add_task(async function checkMenuEntryStates() {
synthesizeContextMenuEvent(inspector.searchBox);
await onContextMenuPopup;
const textboxContextMenu = toolbox.getTextBoxContextMenu();
const textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(textboxContextMenu, "The textbox context menu is loaded in the toolbox");
const cmdUndo = textboxContextMenu.querySelector("#editmenu-undo");
@ -84,7 +84,7 @@ add_task(async function automaticallyBindTexbox() {
});
async function checkNonTextInput(input, toolbox) {
let textboxContextMenu = toolbox.getTextBoxContextMenu();
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(!textboxContextMenu, "The menu is closed");
info("Simulating context click on the non text input and expecting no menu to open");
@ -95,12 +95,12 @@ async function checkNonTextInput(input, toolbox) {
info("Waiting for event");
await eventBubbledUp;
textboxContextMenu = toolbox.getTextBoxContextMenu();
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(!textboxContextMenu, "The menu is still closed");
}
async function checkTextBox(textBox, toolbox) {
let textboxContextMenu = toolbox.getTextBoxContextMenu();
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(!textboxContextMenu, "The menu is closed");
info("Simulating context click on the textbox and expecting the menu to open");
@ -108,7 +108,7 @@ async function checkTextBox(textBox, toolbox) {
synthesizeContextMenuEvent(textBox);
await onContextMenu;
textboxContextMenu = toolbox.getTextBoxContextMenu();
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(textboxContextMenu, "The menu is now visible");
info("Closing the menu");
@ -116,6 +116,6 @@ async function checkTextBox(textBox, toolbox) {
EventUtils.sendKey("ESCAPE", toolbox.win);
await onContextMenuHidden;
textboxContextMenu = toolbox.getTextBoxContextMenu();
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(!textboxContextMenu, "The menu is closed again");
}

Просмотреть файл

@ -61,7 +61,7 @@ add_task(async function() {
for (const menu of menuList) {
const { buttonBounds, menuType, menuBounds, arrowBounds } =
await getButtonAndMenuInfo(toolbox, menu);
await getButtonAndMenuInfo(toolbox.doc, menu);
switch (menuType) {
case "native":
@ -116,8 +116,7 @@ add_task(async function() {
* - arrowBounds {DOMRect|null} Bounds of the arrow. Only set when
* menuType is "doorhanger", null otherwise.
*/
async function getButtonAndMenuInfo(toolbox, menuButton) {
const { doc, topDoc } = toolbox;
async function getButtonAndMenuInfo(doc, menuButton) {
info("Show popup menu with click event.");
EventUtils.sendMouseEvent(
{
@ -136,7 +135,7 @@ async function getButtonAndMenuInfo(toolbox, menuButton) {
await waitUntil(() => menuPopup.classList.contains("tooltip-visible"));
} else {
menuType = "native";
const popupset = topDoc.querySelector("popupset");
const popupset = doc.querySelector("popupset");
await waitUntil(() => {
menuPopup = popupset.querySelector("menupopup[menu-api=\"true\"]");
return !!menuPopup && menuPopup.state === "open";

Просмотреть файл

@ -390,10 +390,6 @@ Toolbox.prototype = {
return DevToolsUtils.getTopWindow(this.win);
},
get topDoc() {
return this.topWindow.document;
},
/**
* Shortcut to the document containing the toolbox UI
*/
@ -3248,20 +3244,13 @@ Toolbox.prototype = {
* @param {Number} y
*/
openTextBoxContextMenu: function(x, y) {
const menu = createEditContextMenu(this.topWindow, "toolbox-menu");
const menu = createEditContextMenu(this.win, "toolbox-menu");
// Fire event for tests
menu.once("open", () => this.emit("menu-open"));
menu.once("close", () => this.emit("menu-close"));
menu.popup(x, y, this.doc);
},
/**
* Retrieve the current textbox context menu, if available.
*/
getTextBoxContextMenu: function() {
return this.topDoc.getElementById("toolbox-menu");
menu.popup(x, y, { doc: this.doc });
},
/**

Просмотреть файл

@ -87,7 +87,7 @@ class ChangesContextMenu {
});
menu.append(menuitemSelectAll);
menu.popup(screenX, screenY, this.inspector.toolbox.doc);
menu.popup(screenX, screenY, this.inspector.toolbox);
return menu;
}

Просмотреть файл

@ -29,7 +29,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchField);
await onContextMenuOpen;
let searchContextMenu = toolbox.getTextBoxContextMenu();
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(searchContextMenu,
"The search filter context menu is loaded in the computed view");
@ -63,7 +63,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchField);
await onContextMenuOpen;
searchContextMenu = toolbox.getTextBoxContextMenu();
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
await waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
@ -77,7 +77,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchField);
await onContextMenuOpen;
searchContextMenu = toolbox.getTextBoxContextMenu();
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");

Просмотреть файл

@ -752,7 +752,7 @@ class MarkupContextMenu {
menu.append(menuitem);
}
menu.popup(screenX, screenY, this.toolbox.doc);
menu.popup(screenX, screenY, this.toolbox);
return menu;
}
@ -768,8 +768,7 @@ class MarkupContextMenu {
const hasA11YProps = await this.walker.hasAccessibilityProperties(
this.selection.nodeFront);
if (hasA11YProps) {
const menuItemEl = Menu.getMenuElementById(menuItem.id, this.toolbox.doc);
menuItemEl.disabled = menuItem.disabled = false;
this.toolbox.doc.getElementById(menuItem.id).disabled = menuItem.disabled = false;
}
this.inspector.emit("node-menu-updated");

Просмотреть файл

@ -28,7 +28,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchField);
await onContextMenuOpen;
let searchContextMenu = toolbox.getTextBoxContextMenu();
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(searchContextMenu,
"The search filter context menu is loaded in the rule view");
@ -62,7 +62,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchField);
await onContextMenuOpen;
searchContextMenu = toolbox.getTextBoxContextMenu();
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
await waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
@ -76,7 +76,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchField);
await onContextMenuOpen;
searchContextMenu = toolbox.getTextBoxContextMenu();
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");

Просмотреть файл

@ -238,7 +238,7 @@ StyleInspectorMenu.prototype = {
});
menu.append(menuitemSources);
menu.popup(screenX, screenY, this.inspector.toolbox.doc);
menu.popup(screenX, screenY, this.inspector._toolbox);
return menu;
},

Просмотреть файл

@ -25,7 +25,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchBox);
await onContextMenuOpen;
let searchContextMenu = toolbox.getTextBoxContextMenu();
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(searchContextMenu,
"The search filter context menu is loaded in the computed view");
@ -60,7 +60,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchBox);
await onContextMenuOpen;
searchContextMenu = toolbox.getTextBoxContextMenu();
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
await waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
@ -74,7 +74,7 @@ add_task(async function() {
synthesizeContextMenuEvent(searchBox);
await onContextMenuOpen;
searchContextMenu = toolbox.getTextBoxContextMenu();
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");

Просмотреть файл

@ -81,7 +81,7 @@ add_task(async function() {
});
async function checkTextBox(textBox, toolbox) {
let textboxContextMenu = toolbox.getTextBoxContextMenu();
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(!textboxContextMenu, "The menu is closed");
info("Simulating context click on the textbox and expecting the menu to open");
@ -89,7 +89,7 @@ async function checkTextBox(textBox, toolbox) {
synthesizeContextMenuEvent(textBox);
await onContextMenu;
textboxContextMenu = toolbox.getTextBoxContextMenu();
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(textboxContextMenu, "The menu is now visible");
info("Closing the menu");
@ -97,6 +97,6 @@ async function checkTextBox(textBox, toolbox) {
EventUtils.sendKey("ESCAPE", toolbox.win);
await onContextMenuHidden;
textboxContextMenu = toolbox.getTextBoxContextMenu();
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
ok(!textboxContextMenu, "The menu is closed again");
}

Просмотреть файл

@ -31,7 +31,7 @@ async function checkContextMenuOnSearchbox(inspector, toolbox) {
synthesizeContextMenuEvent(searchbox);
await onContextMenu;
const textboxContextMenu = toolbox.getTextBoxContextMenu();
const textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
info("Wait until menu items are rendered");
const pasteElement = textboxContextMenu.querySelector("#editmenu-paste");
await waitUntil(() => !!pasteElement.getAttribute("label"));

Просмотреть файл

@ -11,10 +11,11 @@ add_task(async function() {
const { tab, monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, windowRequire, parent } = monitor.panelWin;
const {
getSelectedRequest,
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -37,7 +38,7 @@ add_task(async function() {
info("Captured normal request");
// Mark as blocked
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
const contextBlock = getContextMenuItem(monitor, "request-list-context-block-url");
const contextBlock = parentDocument.querySelector("#request-list-context-block-url");
contextBlock.click();
info("Set request to blocked");
}
@ -63,7 +64,7 @@ add_task(async function() {
// Mark as unblocked
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
const contextUnblock =
getContextMenuItem(monitor, "request-list-context-unblock-url");
parentDocument.querySelector("#request-list-context-unblock-url");
contextUnblock.click();
info("Set request to unblocked");
}

Просмотреть файл

@ -12,7 +12,7 @@ add_task(async function() {
const { monitor, tab } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, parent, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -51,7 +51,8 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector(`#requests-list-${column}-button`));
const menuItem = getContextMenuItem(monitor, `request-list-header-${column}-toggle`);
const menuItem =
parent.document.querySelector(`#request-list-header-${column}-toggle`);
ok(menuItem.disabled, "Last visible column menu item should be disabled.");
}
});

Просмотреть файл

@ -11,7 +11,7 @@ add_task(async function() {
const { monitor, tab } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, parent, windowRequire } = monitor.panelWin;
const { Prefs } = windowRequire("devtools/client/netmonitor/src/utils/prefs");
const prefBefore = Prefs.visibleColumns;
@ -29,7 +29,7 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector("#requests-list-contentSize-button"));
getContextMenuItem(monitor, "request-list-header-reset-columns").click();
parent.document.querySelector("#request-list-header-reset-columns").click();
await onRequestsFinished;
ok(JSON.stringify(prefBefore) === JSON.stringify(Prefs.visibleColumns),

Просмотреть файл

@ -10,7 +10,7 @@ add_task(async function() {
const { monitor, tab } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, connector, windowRequire } = monitor.panelWin;
const { document, store, parent, connector, windowRequire } = monitor.panelWin;
const { requestData } = connector;
const {
getSortedRequests,
@ -34,28 +34,28 @@ add_task(async function() {
let columns = store.getState().ui.columns;
for (const column in columns) {
if (columns[column]) {
await testVisibleColumnContextMenuItem(column, document, monitor);
await testVisibleColumnContextMenuItem(column, document, parent);
testColumnsAlignment(headers, requestsContainer);
await testHiddenColumnContextMenuItem(column, document, monitor);
await testHiddenColumnContextMenuItem(column, document, parent);
} else {
await testHiddenColumnContextMenuItem(column, document, monitor);
await testHiddenColumnContextMenuItem(column, document, parent);
testColumnsAlignment(headers, requestsContainer);
await testVisibleColumnContextMenuItem(column, document, monitor);
await testVisibleColumnContextMenuItem(column, document, parent);
}
}
columns = store.getState().ui.columns;
for (const column in columns) {
if (columns[column]) {
await testVisibleColumnContextMenuItem(column, document, monitor);
await testVisibleColumnContextMenuItem(column, document, parent);
// Right click on the white-space for the context menu to appear
// and toggle column visibility
await testWhiteSpaceContextMenuItem(column, document, monitor);
await testWhiteSpaceContextMenuItem(column, document, parent);
}
}
});
async function testWhiteSpaceContextMenuItem(column, document, monitor) {
async function testWhiteSpaceContextMenuItem(column, document, parent) {
ok(!document.querySelector(`#requests-list-${column}-button`),
`Column ${column} should be hidden`);
@ -65,10 +65,10 @@ async function testWhiteSpaceContextMenuItem(column, document, monitor) {
// Wait for next tick to do stuff async and force repaint.
await waitForTick();
await toggleAndCheckColumnVisibility(column, document, monitor);
await toggleAndCheckColumnVisibility(column, document, parent);
}
async function testVisibleColumnContextMenuItem(column, document, monitor) {
async function testVisibleColumnContextMenuItem(column, document, parent) {
ok(document.querySelector(`#requests-list-${column}-button`),
`Column ${column} should be visible`);
@ -79,7 +79,7 @@ async function testVisibleColumnContextMenuItem(column, document, monitor) {
await waitForTick();
const menuItem = getContextMenuItem(monitor, `request-list-header-${column}-toggle`);
const menuItem = parent.document.querySelector(`#request-list-header-${column}-toggle`);
is(menuItem.getAttribute("type"), "checkbox",
`${column} menu item should have type="checkbox" attribute`);
@ -97,7 +97,7 @@ async function testVisibleColumnContextMenuItem(column, document, monitor) {
`Column ${column} should be hidden`);
}
async function testHiddenColumnContextMenuItem(column, document, monitor) {
async function testHiddenColumnContextMenuItem(column, document, parent) {
ok(!document.querySelector(`#requests-list-${column}-button`),
`Column ${column} should be hidden`);
@ -107,11 +107,11 @@ async function testHiddenColumnContextMenuItem(column, document, monitor) {
document.querySelector("#requests-list-waterfall-button"));
await waitForTick();
await toggleAndCheckColumnVisibility(column, document, monitor);
await toggleAndCheckColumnVisibility(column, document, parent);
}
async function toggleAndCheckColumnVisibility(column, document, monitor) {
const menuItem = getContextMenuItem(monitor, `request-list-header-${column}-toggle`);
async function toggleAndCheckColumnVisibility(column, document, parent) {
const menuItem = parent.document.querySelector(`#request-list-header-${column}-toggle`);
is(menuItem.getAttribute("type"), "checkbox",
`${column} menu item should have type="checkbox" attribute`);

Просмотреть файл

@ -133,8 +133,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[0]);
/* Ensure that the copy as cURL option is always visible */
const copyUrlParamsNode = getContextMenuItem(monitor,
"request-list-context-copy-as-curl");
const copyUrlParamsNode = monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-as-curl");
is(!!copyUrlParamsNode, true,
"The \"Copy as cURL\" context menu item should not be hidden.");

Просмотреть файл

@ -53,8 +53,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[0]);
/* Ensure that the copy as fetch option is always visible */
const copyAsFetchNode = getContextMenuItem(monitor,
"request-list-context-copy-as-fetch");
const copyAsFetchNode = monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-as-fetch");
is(!!copyAsFetchNode, true,
"The \"Copy as Fetch\" context menu item should not be hidden.");

Просмотреть файл

@ -47,7 +47,8 @@ add_task(async function() {
].join("\n");
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-request-headers").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-request-headers").click();
}, function validate(result) {
// Sometimes, a "Cookie" header is left over from other tests. Remove it:
result = String(result).replace(/Cookie: [^\n]+\n/, "");
@ -69,7 +70,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[0]);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "response-list-context-copy-response-headers").click();
monitor.panelWin.parent.document
.querySelector("#response-list-context-copy-response-headers").click();
}, function validate(result) {
// Fake the "Last-Modified" and "Date" headers because they will vary:
result = String(result)

Просмотреть файл

@ -22,7 +22,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[5]);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-image-as-data-uri").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-image-as-data-uri").click();
}, TEST_IMAGE_DATA_URI);
ok(true, "Clipboard contains the currently selected image as data uri.");

Просмотреть файл

@ -66,8 +66,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[index]);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[index]);
const copyUrlParamsNode = getContextMenuItem(monitor,
"request-list-context-copy-url-params");
const copyUrlParamsNode = monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-url-params");
is(!!copyUrlParamsNode, !hidden,
"The \"Copy URL Parameters\" context menu item should" + (hidden ? " " : " not ") +
"be hidden.");
@ -79,7 +79,8 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[index]);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-url-params").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-url-params").click();
}, queryString);
ok(true, "The url query string copied from the selected item is correct.");
}
@ -89,8 +90,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[index]);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[index]);
const copyPostDataNode = getContextMenuItem(monitor,
"request-list-context-copy-post-data");
const copyPostDataNode = monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-post-data");
is(!!copyPostDataNode, !hidden,
"The \"Copy POST Data\" context menu item should" + (hidden ? " " : " not ") +
"be hidden.");
@ -101,8 +102,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[index]);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[index]);
const copyPostDataNode = getContextMenuItem(monitor,
"request-list-context-copy-post-data");
const copyPostDataNode = monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-post-data");
is(copyPostDataNode.attributes.label.value, "Copy " + method + " Data",
"The \"Copy Data\" context menu item should have label - Copy " + method + " Data");
}
@ -121,7 +122,8 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[index]);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-post-data").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-post-data").click();
}, postData);
ok(true, "The post data string copied from the selected item is correct.");
}

Просмотреть файл

@ -24,7 +24,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[3]);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-response").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-response").click();
}, EXPECTED_RESULT);
await teardown(monitor);

Просмотреть файл

@ -27,7 +27,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[0]);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-image-as-data-uri").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-image-as-data-uri").click();
}, function check(text) {
return text.startsWith("data:") && !/undefined/.test(text);
});

Просмотреть файл

@ -27,7 +27,8 @@ add_task(async function() {
const requestItem = getSortedRequests(store.getState()).get(0);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "request-list-context-copy-url").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-copy-url").click();
}, requestItem.url);
await teardown(monitor);

Просмотреть файл

@ -11,10 +11,11 @@ add_task(async function() {
const { tab, monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, windowRequire, parent } = monitor.panelWin;
const {
getSelectedRequest,
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -30,7 +31,7 @@ add_task(async function() {
await waitForHeaders;
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
const firstRequestState = getSelectedRequest(store.getState());
const contextResend = getContextMenuItem(monitor, "request-list-context-resend");
const contextResend = parentDocument.querySelector("#request-list-context-resend");
contextResend.click();
// Waits for "Edit & Resend" panel to appear > New request "Cancel"

Просмотреть файл

@ -15,7 +15,8 @@ add_task(async function() {
const { tab, monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, windowRequire, parent } = monitor.panelWin;
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -33,7 +34,7 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
// Open "New Request" form
const contextResend = getContextMenuItem(monitor, "request-list-context-resend");
const contextResend = parentDocument.querySelector("#request-list-context-resend");
contextResend.click();
await waitUntil(() => document.querySelector("#custom-headers-value"));
const headersTextarea = document.querySelector("#custom-headers-value");

Просмотреть файл

@ -12,7 +12,8 @@
add_task(async function() {
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, windowRequire, parent } = monitor.panelWin;
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -31,7 +32,7 @@ add_task(async function() {
// Open context menu and execute "Edit & Resend".
EventUtils.sendMouseEvent({ type: "contextmenu" }, xhrRequestItem);
getContextMenuItem(monitor, "request-list-context-resend").click();
parentDocument.querySelector("#request-list-context-resend").click();
// Click Resend
await waitUntil(() => document.querySelector("#custom-request-send-button"));

Просмотреть файл

@ -11,7 +11,8 @@
add_task(async function() {
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, windowRequire, parent } = monitor.panelWin;
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -29,7 +30,7 @@ add_task(async function() {
// Context Menu > "Edit & Resend"
EventUtils.sendMouseEvent({ type: "contextmenu" }, xhrRequest);
getContextMenuItem(monitor, "request-list-context-resend").click();
parentDocument.querySelector("#request-list-context-resend").click();
// Waits for "Edit & Resend" panel to appear > New request "Send"
document.querySelector("#custom-request-send-button").click();

Просмотреть файл

@ -12,6 +12,7 @@ add_task(async function() {
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const contextMenuDoc = monitor.panelWin.parent.document;
// Avoid async processing
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -19,15 +20,15 @@ add_task(async function() {
// Execute requests.
await performRequests(monitor, tab, CONTENT_TYPE_WITHOUT_CACHE_REQUESTS);
wait = waitForDOM(contextMenuDoc, "#request-list-context-open-in-debugger");
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll(".request-list-item")[2]);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[2]);
await waitUntil(() =>
getContextMenuItem(monitor, "request-list-context-open-in-debugger"));
await wait;
const onDebuggerReady = toolbox.once("jsdebugger-ready");
getContextMenuItem(monitor, "request-list-context-open-in-debugger").click();
contextMenuDoc.querySelector("#request-list-context-open-in-debugger").click();
await onDebuggerReady;
ok(true, "Debugger has been open");

Просмотреть файл

@ -12,6 +12,7 @@ add_task(async function() {
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const contextMenuDoc = monitor.panelWin.parent.document;
// Avoid async processing
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -19,15 +20,16 @@ add_task(async function() {
// Execute requests.
await performRequests(monitor, tab, CONTENT_TYPE_WITHOUT_CACHE_REQUESTS);
wait = waitForDOM(contextMenuDoc, "#request-list-context-open-in-style-editor");
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll(".request-list-item")[1]);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelectorAll(".request-list-item")[1]);
await waitUntil(() =>
getContextMenuItem(monitor, "request-list-context-open-in-style-editor"));
await wait;
const onStyleEditorReady = toolbox.once("styleeditor-ready");
getContextMenuItem(monitor, "request-list-context-open-in-style-editor").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-open-in-style-editor").click();
await onStyleEditorReady;
ok(true, "Style Editor has been open");

Просмотреть файл

@ -12,6 +12,7 @@ add_task(async function() {
info("Starting test...");
const { document, store, windowRequire } = monitor.panelWin;
const contextMenuDoc = monitor.panelWin.parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
let newTab;
@ -45,15 +46,16 @@ add_task(async function() {
// OpenLastRequestInTab by ContextMenu
async function openLastRequestInTab() {
const wait = waitForDOM(contextMenuDoc, "#request-list-context-newtab");
const requestItems = document.querySelectorAll(".request-list-item");
const lastRequest = requestItems[requestItems.length - 1];
EventUtils.sendMouseEvent({ type: "mousedown" }, lastRequest);
EventUtils.sendMouseEvent({ type: "contextmenu" }, lastRequest);
await waitUntil(() =>
getContextMenuItem(monitor, "request-list-context-newtab"));
await wait;
const onTabOpen = once(gBrowser.tabContainer, "TabOpen", false);
getContextMenuItem(monitor, "request-list-context-newtab").click();
monitor.panelWin.parent.document
.querySelector("#request-list-context-newtab").click();
await onTabOpen;
info("A new tab has been opened");

Просмотреть файл

@ -33,14 +33,16 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
objectRow);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
monitor.panelWin.parent.document
.querySelector("#properties-view-context-menu-copy").click();
}, `{"obj":{"type":"string"}}`);
/* Test for copy all */
EventUtils.sendMouseEvent({ type: "contextmenu" },
objectRow);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "properties-view-context-menu-copyall").click();
monitor.panelWin.parent.document
.querySelector("#properties-view-context-menu-copyall").click();
}, `{"JSON":{"obj":{"type":"string"}},` +
`"Response payload":{"EDITOR_CONFIG":{"text":` +
`"{\\"obj\\": {\\"type\\": \\"string\\" }}","mode":"application/json"}}}`);
@ -49,7 +51,8 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
stringRow);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
monitor.panelWin.parent.document
.querySelector("#properties-view-context-menu-copy").click();
}, "type: string");
await teardown(monitor);
@ -97,7 +100,8 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
cur);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
monitor.panelWin.parent.document
.querySelector("#properties-view-context-menu-copy").click();
}, JSON.stringify(expectedResponseCookies[i]));
}
@ -107,7 +111,8 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" },
cur);
await waitForClipboardPromise(function setup() {
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
monitor.panelWin.parent.document
.querySelector("#properties-view-context-menu-copy").click();
}, expectedRequestCookies[i]);
}

Просмотреть файл

@ -10,7 +10,8 @@
add_task(async function() {
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);
const { document, store, windowRequire } = monitor.panelWin;
const { document, store, windowRequire, parent } = monitor.panelWin;
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
@ -28,7 +29,7 @@ add_task(async function() {
// Context Menu > "Resend"
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
getContextMenuItem(monitor, "request-list-context-resend-only").click();
parentDocument.querySelector("#request-list-context-resend-only").click();
// Selects request that was resent
const selectedRequest = getSelectedRequest(store.getState());

Просмотреть файл

@ -17,7 +17,7 @@ add_task(async function() {
// of the heavy dom manipulation associated with sorting.
requestLongerTimeout(2);
const { document, store, windowRequire } = monitor.panelWin;
const { parent, document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
const {
getDisplayedRequests,
@ -69,7 +69,7 @@ add_task(async function() {
info("Testing sort reset using context menu 'Reset Sorting'");
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector("#requests-list-contentSize-button"));
getContextMenuItem(monitor, "request-list-header-reset-sorting").click();
parent.document.querySelector("#request-list-header-reset-sorting").click();
testHeaders();
await testContents([0, 2, 4, 3, 1]);
@ -78,7 +78,7 @@ add_task(async function() {
info("Testing sort reset using context menu 'Reset Columns'");
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector("#requests-list-contentSize-button"));
getContextMenuItem(monitor, "request-list-header-reset-columns").click();
parent.document.querySelector("#request-list-header-reset-columns").click();
testHeaders();
// add columns because verifyRequestItemTarget expects some extra columns
showColumn(monitor, "protocol");

Просмотреть файл

@ -39,7 +39,7 @@ add_task(async function() {
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
// Open "New Request" form and resend.
getContextMenuItem(monitor, "request-list-context-resend").click();
monitor.panelWin.parent.document.querySelector("#request-list-context-resend").click();
await waitUntil(() => document.querySelector("#custom-request-send-button"));
document.querySelector("#custom-request-send-button").click();

Просмотреть файл

@ -11,7 +11,7 @@ const ALL_CHANNELS = Ci.nsITelemetry.DATASET_ALL_CHANNELS;
* Test the throttle_change telemetry event.
*/
add_task(async function() {
const { monitor, toolbox } = await initNetMonitor(SIMPLE_URL);
const { monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
@ -26,10 +26,7 @@ add_task(async function() {
ok(!snapshot.parent, "No events have been logged for the main process");
document.getElementById("network-throttling-menu").click();
// Throttling menu items cannot be retrieved by id so we can't use getContextMenuItem
// here. Instead use querySelector on the toolbox top document, where the context menu
// will be rendered.
toolbox.topWindow.document.querySelector("menuitem[label='GPRS']").click();
monitor.panelWin.parent.document.querySelector("menuitem[label='GPRS']").click();
await waitFor(monitor.panelWin.api, EVENTS.THROTTLING_CHANGED);
// Verify existence of the telemetry event.

Просмотреть файл

@ -53,8 +53,8 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[0]);
/* Ensure that the use as fetch option is always visible */
const useAsFetchNode = getContextMenuItem(monitor,
"request-list-context-use-as-fetch");
const useAsFetchNode = monitor.panelWin.parent.document
.querySelector("#request-list-context-use-as-fetch");
is(!!useAsFetchNode, true,
"The \"Use as Fetch\" context menu item should not be hidden.");

Просмотреть файл

@ -730,14 +730,14 @@ function testColumnsAlignment(headers, requestList) {
}
async function hideColumn(monitor, column) {
const { document } = monitor.panelWin;
const { document, parent } = monitor.panelWin;
info(`Clicking context-menu item for ${column}`);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector(".requests-list-headers"));
const onHeaderRemoved = waitForDOM(document, `#requests-list-${column}-button`, 0);
getContextMenuItem(monitor, `request-list-header-${column}-toggle`).click();
parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
await onHeaderRemoved;
ok(!document.querySelector(`#requests-list-${column}-button`),
@ -745,14 +745,14 @@ async function hideColumn(monitor, column) {
}
async function showColumn(monitor, column) {
const { document } = monitor.panelWin;
const { document, parent } = monitor.panelWin;
info(`Clicking context-menu item for ${column}`);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector(".requests-list-headers"));
const onHeaderAdded = waitForDOM(document, `#requests-list-${column}-button`, 1);
getContextMenuItem(monitor, `request-list-header-${column}-toggle`).click();
parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
await onHeaderAdded;
ok(document.querySelector(`#requests-list-${column}-button`),
@ -867,12 +867,3 @@ function queryTelemetryEvents(query) {
// Return the `extra` field (which is event[5]e).
return filtersChangedEvents.map(event => event[5]);
}
/**
* Retrieve the context menu element corresponding to the provided id, for the provided
* netmonitor instance.
*/
function getContextMenuItem(monitor, id) {
const Menu = require("devtools/client/framework/menu");
return Menu.getMenuElementById(id, monitor.panelWin.document);
}

Просмотреть файл

@ -53,6 +53,7 @@ class DevicePixelRatioMenu extends PureComponent {
showMenu(menuItems, {
button: event.target,
useTopLevelWindow: true,
});
}

Просмотреть файл

@ -73,6 +73,7 @@ class DeviceSelector extends PureComponent {
showMenu(menuItems, {
button: event.target,
useTopLevelWindow: true,
});
}

Просмотреть файл

@ -87,6 +87,7 @@ class SettingsMenu extends PureComponent {
showMenu(menuItems, {
button: event.target,
useTopLevelWindow: true,
});
}

Просмотреть файл

@ -147,6 +147,7 @@ class Toolbar extends PureComponent {
NetworkThrottlingMenu({
networkThrottling,
onChangeNetworkThrottling,
useTopLevelWindow: true,
}),
dom.div({ className: "devtools-separator" }),
this.renderUserAgent(),

Просмотреть файл

@ -7,6 +7,8 @@
const Menu = require("devtools/client/framework/menu");
const MenuItem = require("devtools/client/framework/menu-item");
loader.lazyRequireGetter(this, "getTopLevelWindow", "devtools/client/responsive.html/utils/window", true);
/**
* Helper function for opening context menu.
*
@ -19,6 +21,9 @@ const MenuItem = require("devtools/client/framework/menu-item");
* Screen x coordinate of the menu on the screen.
* @property {Number} screenY
* Screen y coordinate of the menu on the screen.
* @property {Boolean} useTopLevelWindow
* Whether or not the top level window needs to be fetched. This option is used
* by RDM.
*/
function showMenu(items, options) {
if (items.length === 0) {
@ -59,7 +64,14 @@ function showMenu(items, options) {
screenY = rect.bottom + defaultView.mozInnerScreenY;
}
menu.popup(screenX, screenY, window.document);
let doc;
if (options.useTopLevelWindow) {
doc = getTopLevelWindow(window).document;
} else {
doc = window.parent.document;
}
menu.popup(screenX, screenY, { doc });
}
module.exports = {

Просмотреть файл

@ -300,7 +300,7 @@ class Tabbar extends Component {
const screenX = target.ownerDocument.defaultView.mozInnerScreenX;
const screenY = target.ownerDocument.defaultView.mozInnerScreenY;
menu.popupWithZoom(rect.left + screenX, rect.bottom + screenY,
this.props.menuDocument);
{ doc: this.props.menuDocument });
return menu;
}

Просмотреть файл

@ -28,6 +28,13 @@ class NetworkThrottlingMenu extends PureComponent {
return {
networkThrottling: PropTypes.shape(Types.networkThrottling).isRequired,
onChangeNetworkThrottling: PropTypes.func.isRequired,
useTopLevelWindow: PropTypes.bool,
};
}
static get defaultProps() {
return {
useTopLevelWindow: false,
};
}
@ -40,6 +47,7 @@ class NetworkThrottlingMenu extends PureComponent {
const {
networkThrottling,
onChangeNetworkThrottling,
useTopLevelWindow,
} = this.props;
const menuItems = throttlingProfiles.map(profile => {
@ -60,7 +68,7 @@ class NetworkThrottlingMenu extends PureComponent {
click: () => onChangeNetworkThrottling(false, ""),
});
showMenu(menuItems, { button: event.target });
showMenu(menuItems, { button: event.target, useTopLevelWindow });
}
render() {

Просмотреть файл

@ -201,7 +201,7 @@ StyleEditorUI.prototype = {
this._optionsButton.removeAttribute("open");
});
this._optionsMenu.popup(screenX, screenY, this._toolbox.doc);
this._optionsMenu.popup(screenX, screenY, this._toolbox);
},
/**

Просмотреть файл

@ -32,5 +32,5 @@ async function openTextBoxContextMenu(toolbox, element) {
const onConsoleMenuOpened = toolbox.once("menu-open");
synthesizeContextMenuEvent(element);
await onConsoleMenuOpened;
return toolbox.getTextBoxContextMenu();
return toolbox.doc.getElementById("toolbox-menu");
}

Просмотреть файл

@ -297,7 +297,8 @@ async function openContextMenu(hud, element) {
const onConsoleMenuOpened = hud.ui.wrapper.once("menu-open");
synthesizeContextMenuEvent(element);
await onConsoleMenuOpened;
return _getContextMenu(hud);
const doc = hud.chromeWindow.document;
return doc.getElementById("webconsole-menu");
}
/**
@ -309,7 +310,8 @@ async function openContextMenu(hud, element) {
* @return promise
*/
function hideContextMenu(hud) {
const popup = _getContextMenu(hud);
const doc = hud.chromeWindow.document;
const popup = doc.getElementById("webconsole-menu");
if (!popup) {
return Promise.resolve();
}
@ -319,12 +321,6 @@ function hideContextMenu(hud) {
return onPopupHidden;
}
function _getContextMenu(hud) {
const toolbox = gDevTools.getToolbox(hud.target);
const doc = toolbox ? toolbox.topWindow.document : hud.chromeWindow.document;
return doc.getElementById("webconsole-menu");
}
function loadDocument(url, browser = gBrowser.selectedBrowser) {
BrowserTestUtils.loadURI(browser, url);
return BrowserTestUtils.browserLoaded(browser);

Просмотреть файл

@ -256,7 +256,7 @@ class WebConsoleWrapper {
// Emit the "menu-open" event for testing.
menu.once("open", () => this.emit("menu-open"));
menu.popup(screenX, screenY, this.hud.chromeWindow.document);
menu.popup(screenX, screenY, { doc: this.hud.chromeWindow.document });
return menu;
};
@ -266,7 +266,7 @@ class WebConsoleWrapper {
const menu = createEditContextMenu(window, "webconsole-menu");
// Emit the "menu-open" event for testing.
menu.once("open", () => this.emit("menu-open"));
menu.popup(screenX, screenY, this.hud.chromeWindow.document);
menu.popup(screenX, screenY, { doc: this.hud.chromeWindow.document });
return menu;
};