зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1543940 - Update tests to use toolbox.topDoc to query context-menu elements r=ochameau
Depends on D27695 Differential Revision: https://phabricator.services.mozilla.com/D27696 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
92f2dbb1c8
Коммит
8aa6f3861d
|
@ -15,7 +15,7 @@ add_task(async function() {
|
|||
|
||||
const { document, tab, window } = await openAboutDebugging();
|
||||
await selectThisFirefoxPage(document, window.AboutDebugging.store);
|
||||
const { devtoolsDocument, devtoolsTab, devtoolsWindow } =
|
||||
const { 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(() => devtoolsDocument.querySelector("#node-menu-edithtml"));
|
||||
await waitUntil(() => toolbox.topDoc.querySelector("#node-menu-edithtml"));
|
||||
ok(true, "Context menu of markup view should be shown");
|
||||
|
||||
await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
|
||||
|
|
|
@ -82,13 +82,13 @@ async function testMenuPopup(toolbox) {
|
|||
|
||||
menu.popup(0, 0, toolbox.doc);
|
||||
|
||||
ok(toolbox.doc.querySelector("#menu-popup"), "A popup is in the DOM");
|
||||
ok(toolbox.topDoc.querySelector("#menu-popup"), "A popup is in the DOM");
|
||||
|
||||
const menuSeparators =
|
||||
toolbox.doc.querySelectorAll("#menu-popup > menuseparator");
|
||||
toolbox.topDoc.querySelectorAll("#menu-popup > menuseparator");
|
||||
is(menuSeparators.length, 1, "A separator is in the menu");
|
||||
|
||||
const menuItems = toolbox.doc.querySelectorAll("#menu-popup > menuitem");
|
||||
const menuItems = toolbox.topDoc.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.win);
|
||||
EventUtils.synthesizeMouseAtCenter(menuItems[0], {}, toolbox.topWindow);
|
||||
await closed;
|
||||
ok(clickFired, "Click has fired");
|
||||
|
||||
ok(!toolbox.doc.querySelector("#menu-popup"), "Popup removed from the DOM");
|
||||
ok(!toolbox.topDoc.querySelector("#menu-popup"), "Popup removed from the DOM");
|
||||
}
|
||||
|
||||
async function testSubmenu(toolbox) {
|
||||
|
@ -144,11 +144,11 @@ async function testSubmenu(toolbox) {
|
|||
}));
|
||||
|
||||
menu.popup(0, 0, toolbox.doc);
|
||||
ok(toolbox.doc.querySelector("#menu-popup"), "A popup is in the DOM");
|
||||
is(toolbox.doc.querySelectorAll("#menu-popup > menuitem").length, 0,
|
||||
ok(toolbox.topDoc.querySelector("#menu-popup"), "A popup is in the DOM");
|
||||
is(toolbox.topDoc.querySelectorAll("#menu-popup > menuitem").length, 0,
|
||||
"No menuitem children");
|
||||
|
||||
const menus = toolbox.doc.querySelectorAll("#menu-popup > menu");
|
||||
const menus = toolbox.topDoc.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.win);
|
||||
EventUtils.synthesizeMouseAtCenter(subMenuItems[0], {}, toolbox.topWindow);
|
||||
|
||||
await closed;
|
||||
ok(clickFired, "Click has fired");
|
||||
|
|
|
@ -33,7 +33,7 @@ add_task(async function checkMenuEntryStates() {
|
|||
synthesizeContextMenuEvent(inspector.searchBox);
|
||||
await onContextMenuPopup;
|
||||
|
||||
const textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
const textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
let textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
ok(!textboxContextMenu, "The menu is still closed");
|
||||
}
|
||||
|
||||
async function checkTextBox(textBox, toolbox) {
|
||||
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
let textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc, menu);
|
||||
await getButtonAndMenuInfo(toolbox, menu);
|
||||
|
||||
switch (menuType) {
|
||||
case "native":
|
||||
|
@ -116,7 +116,8 @@ add_task(async function() {
|
|||
* - arrowBounds {DOMRect|null} Bounds of the arrow. Only set when
|
||||
* menuType is "doorhanger", null otherwise.
|
||||
*/
|
||||
async function getButtonAndMenuInfo(doc, menuButton) {
|
||||
async function getButtonAndMenuInfo(toolbox, menuButton) {
|
||||
const { doc, topDoc } = toolbox;
|
||||
info("Show popup menu with click event.");
|
||||
EventUtils.sendMouseEvent(
|
||||
{
|
||||
|
@ -135,7 +136,7 @@ async function getButtonAndMenuInfo(doc, menuButton) {
|
|||
await waitUntil(() => menuPopup.classList.contains("tooltip-visible"));
|
||||
} else {
|
||||
menuType = "native";
|
||||
const popupset = doc.querySelector("popupset");
|
||||
const popupset = topDoc.querySelector("popupset");
|
||||
await waitUntil(() => {
|
||||
menuPopup = popupset.querySelector("menupopup[menu-api=\"true\"]");
|
||||
return !!menuPopup && menuPopup.state === "open";
|
||||
|
|
|
@ -3260,6 +3260,13 @@ Toolbox.prototype = {
|
|||
menu.popup(x, y, this.doc);
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve the current textbox context menu, if available.
|
||||
*/
|
||||
getTextBoxContextMenu: function() {
|
||||
return this.topDoc.getElementById("toolbox-menu");
|
||||
},
|
||||
|
||||
/**
|
||||
* Connects to the Gecko Profiler when the developer tools are open. This is
|
||||
* necessary because of the WebConsole's `profile` and `profileEnd` methods.
|
||||
|
|
|
@ -29,7 +29,7 @@ add_task(async function() {
|
|||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
let searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
|
|
|
@ -28,7 +28,7 @@ add_task(async function() {
|
|||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
let searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
|
|
|
@ -25,7 +25,7 @@ add_task(async function() {
|
|||
synthesizeContextMenuEvent(searchBox);
|
||||
await onContextMenuOpen;
|
||||
|
||||
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
let searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
searchContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
let textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
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.doc.getElementById("toolbox-menu");
|
||||
textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
ok(!textboxContextMenu, "The menu is closed again");
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ async function checkContextMenuOnSearchbox(inspector, toolbox) {
|
|||
synthesizeContextMenuEvent(searchbox);
|
||||
await onContextMenu;
|
||||
|
||||
const textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
const textboxContextMenu = toolbox.getTextBoxContextMenu();
|
||||
info("Wait until menu items are rendered");
|
||||
const pasteElement = textboxContextMenu.querySelector("#editmenu-paste");
|
||||
await waitUntil(() => !!pasteElement.getAttribute("label"));
|
||||
|
|
|
@ -11,11 +11,10 @@ add_task(async function() {
|
|||
const { tab, monitor } = await initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
const { document, store, windowRequire, parent } = monitor.panelWin;
|
||||
const { document, store, windowRequire } = 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));
|
||||
|
||||
|
@ -38,7 +37,7 @@ add_task(async function() {
|
|||
info("Captured normal request");
|
||||
// Mark as blocked
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
|
||||
const contextBlock = parentDocument.querySelector("#request-list-context-block-url");
|
||||
const contextBlock = getContextMenuItem(monitor, "request-list-context-block-url");
|
||||
contextBlock.click();
|
||||
info("Set request to blocked");
|
||||
}
|
||||
|
@ -64,7 +63,7 @@ add_task(async function() {
|
|||
// Mark as unblocked
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
|
||||
const contextUnblock =
|
||||
parentDocument.querySelector("#request-list-context-unblock-url");
|
||||
getContextMenuItem(monitor, "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, parent, windowRequire } = monitor.panelWin;
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
|
@ -51,8 +51,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
document.querySelector(`#requests-list-${column}-button`));
|
||||
|
||||
const menuItem =
|
||||
parent.document.querySelector(`#request-list-header-${column}-toggle`);
|
||||
const menuItem = getContextMenuItem(monitor, `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, parent, windowRequire } = monitor.panelWin;
|
||||
const { document, store, 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"));
|
||||
|
||||
parent.document.querySelector("#request-list-header-reset-columns").click();
|
||||
getContextMenuItem(monitor, "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, parent, connector, windowRequire } = monitor.panelWin;
|
||||
const { document, store, 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, parent);
|
||||
await testVisibleColumnContextMenuItem(column, document, monitor);
|
||||
testColumnsAlignment(headers, requestsContainer);
|
||||
await testHiddenColumnContextMenuItem(column, document, parent);
|
||||
await testHiddenColumnContextMenuItem(column, document, monitor);
|
||||
} else {
|
||||
await testHiddenColumnContextMenuItem(column, document, parent);
|
||||
await testHiddenColumnContextMenuItem(column, document, monitor);
|
||||
testColumnsAlignment(headers, requestsContainer);
|
||||
await testVisibleColumnContextMenuItem(column, document, parent);
|
||||
await testVisibleColumnContextMenuItem(column, document, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
columns = store.getState().ui.columns;
|
||||
for (const column in columns) {
|
||||
if (columns[column]) {
|
||||
await testVisibleColumnContextMenuItem(column, document, parent);
|
||||
await testVisibleColumnContextMenuItem(column, document, monitor);
|
||||
// Right click on the white-space for the context menu to appear
|
||||
// and toggle column visibility
|
||||
await testWhiteSpaceContextMenuItem(column, document, parent);
|
||||
await testWhiteSpaceContextMenuItem(column, document, monitor);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function testWhiteSpaceContextMenuItem(column, document, parent) {
|
||||
async function testWhiteSpaceContextMenuItem(column, document, monitor) {
|
||||
ok(!document.querySelector(`#requests-list-${column}-button`),
|
||||
`Column ${column} should be hidden`);
|
||||
|
||||
|
@ -65,10 +65,10 @@ async function testWhiteSpaceContextMenuItem(column, document, parent) {
|
|||
|
||||
// Wait for next tick to do stuff async and force repaint.
|
||||
await waitForTick();
|
||||
await toggleAndCheckColumnVisibility(column, document, parent);
|
||||
await toggleAndCheckColumnVisibility(column, document, monitor);
|
||||
}
|
||||
|
||||
async function testVisibleColumnContextMenuItem(column, document, parent) {
|
||||
async function testVisibleColumnContextMenuItem(column, document, monitor) {
|
||||
ok(document.querySelector(`#requests-list-${column}-button`),
|
||||
`Column ${column} should be visible`);
|
||||
|
||||
|
@ -79,7 +79,7 @@ async function testVisibleColumnContextMenuItem(column, document, parent) {
|
|||
|
||||
await waitForTick();
|
||||
|
||||
const menuItem = parent.document.querySelector(`#request-list-header-${column}-toggle`);
|
||||
const menuItem = getContextMenuItem(monitor, `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, parent) {
|
|||
`Column ${column} should be hidden`);
|
||||
}
|
||||
|
||||
async function testHiddenColumnContextMenuItem(column, document, parent) {
|
||||
async function testHiddenColumnContextMenuItem(column, document, monitor) {
|
||||
ok(!document.querySelector(`#requests-list-${column}-button`),
|
||||
`Column ${column} should be hidden`);
|
||||
|
||||
|
@ -107,11 +107,11 @@ async function testHiddenColumnContextMenuItem(column, document, parent) {
|
|||
document.querySelector("#requests-list-waterfall-button"));
|
||||
|
||||
await waitForTick();
|
||||
await toggleAndCheckColumnVisibility(column, document, parent);
|
||||
await toggleAndCheckColumnVisibility(column, document, monitor);
|
||||
}
|
||||
|
||||
async function toggleAndCheckColumnVisibility(column, document, parent) {
|
||||
const menuItem = parent.document.querySelector(`#request-list-header-${column}-toggle`);
|
||||
async function toggleAndCheckColumnVisibility(column, document, monitor) {
|
||||
const menuItem = getContextMenuItem(monitor, `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 = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-as-curl");
|
||||
const copyUrlParamsNode = getContextMenuItem(monitor,
|
||||
"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 = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-as-fetch");
|
||||
const copyAsFetchNode = getContextMenuItem(monitor,
|
||||
"request-list-context-copy-as-fetch");
|
||||
is(!!copyAsFetchNode, true,
|
||||
"The \"Copy as Fetch\" context menu item should not be hidden.");
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@ add_task(async function() {
|
|||
].join("\n");
|
||||
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-request-headers").click();
|
||||
getContextMenuItem(monitor, "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/, "");
|
||||
|
@ -70,8 +69,7 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[0]);
|
||||
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#response-list-context-copy-response-headers").click();
|
||||
getContextMenuItem(monitor, "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,8 +22,7 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[5]);
|
||||
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-image-as-data-uri").click();
|
||||
getContextMenuItem(monitor, "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 = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-url-params");
|
||||
const copyUrlParamsNode = getContextMenuItem(monitor,
|
||||
"request-list-context-copy-url-params");
|
||||
is(!!copyUrlParamsNode, !hidden,
|
||||
"The \"Copy URL Parameters\" context menu item should" + (hidden ? " " : " not ") +
|
||||
"be hidden.");
|
||||
|
@ -79,8 +79,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
document.querySelectorAll(".request-list-item")[index]);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-url-params").click();
|
||||
getContextMenuItem(monitor, "request-list-context-copy-url-params").click();
|
||||
}, queryString);
|
||||
ok(true, "The url query string copied from the selected item is correct.");
|
||||
}
|
||||
|
@ -90,8 +89,8 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[index]);
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
document.querySelectorAll(".request-list-item")[index]);
|
||||
const copyPostDataNode = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-post-data");
|
||||
const copyPostDataNode = getContextMenuItem(monitor,
|
||||
"request-list-context-copy-post-data");
|
||||
is(!!copyPostDataNode, !hidden,
|
||||
"The \"Copy POST Data\" context menu item should" + (hidden ? " " : " not ") +
|
||||
"be hidden.");
|
||||
|
@ -102,8 +101,8 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[index]);
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
document.querySelectorAll(".request-list-item")[index]);
|
||||
const copyPostDataNode = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-post-data");
|
||||
const copyPostDataNode = getContextMenuItem(monitor,
|
||||
"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");
|
||||
}
|
||||
|
@ -122,8 +121,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
document.querySelectorAll(".request-list-item")[index]);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-post-data").click();
|
||||
getContextMenuItem(monitor, "request-list-context-copy-post-data").click();
|
||||
}, postData);
|
||||
ok(true, "The post data string copied from the selected item is correct.");
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[3]);
|
||||
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-response").click();
|
||||
getContextMenuItem(monitor, "request-list-context-copy-response").click();
|
||||
}, EXPECTED_RESULT);
|
||||
|
||||
await teardown(monitor);
|
||||
|
|
|
@ -27,8 +27,7 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[0]);
|
||||
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-image-as-data-uri").click();
|
||||
getContextMenuItem(monitor, "request-list-context-copy-image-as-data-uri").click();
|
||||
}, function check(text) {
|
||||
return text.startsWith("data:") && !/undefined/.test(text);
|
||||
});
|
||||
|
|
|
@ -27,8 +27,7 @@ add_task(async function() {
|
|||
const requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-url").click();
|
||||
getContextMenuItem(monitor, "request-list-context-copy-url").click();
|
||||
}, requestItem.url);
|
||||
|
||||
await teardown(monitor);
|
||||
|
|
|
@ -11,11 +11,10 @@ add_task(async function() {
|
|||
const { tab, monitor } = await initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
const { document, store, windowRequire, parent } = monitor.panelWin;
|
||||
const { document, store, windowRequire } = 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));
|
||||
|
||||
|
@ -31,7 +30,7 @@ add_task(async function() {
|
|||
await waitForHeaders;
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
|
||||
const firstRequestState = getSelectedRequest(store.getState());
|
||||
const contextResend = parentDocument.querySelector("#request-list-context-resend");
|
||||
const contextResend = getContextMenuItem(monitor, "request-list-context-resend");
|
||||
contextResend.click();
|
||||
|
||||
// Waits for "Edit & Resend" panel to appear > New request "Cancel"
|
||||
|
|
|
@ -15,8 +15,7 @@ add_task(async function() {
|
|||
const { tab, monitor } = await initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
const { document, store, windowRequire, parent } = monitor.panelWin;
|
||||
const parentDocument = parent.document;
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
|
@ -34,7 +33,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
|
||||
|
||||
// Open "New Request" form
|
||||
const contextResend = parentDocument.querySelector("#request-list-context-resend");
|
||||
const contextResend = getContextMenuItem(monitor, "request-list-context-resend");
|
||||
contextResend.click();
|
||||
await waitUntil(() => document.querySelector("#custom-headers-value"));
|
||||
const headersTextarea = document.querySelector("#custom-headers-value");
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
add_task(async function() {
|
||||
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);
|
||||
|
||||
const { document, store, windowRequire, parent } = monitor.panelWin;
|
||||
const parentDocument = parent.document;
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
|
@ -32,7 +31,7 @@ add_task(async function() {
|
|||
|
||||
// Open context menu and execute "Edit & Resend".
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, xhrRequestItem);
|
||||
parentDocument.querySelector("#request-list-context-resend").click();
|
||||
getContextMenuItem(monitor, "request-list-context-resend").click();
|
||||
|
||||
// Click Resend
|
||||
await waitUntil(() => document.querySelector("#custom-request-send-button"));
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
add_task(async function() {
|
||||
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);
|
||||
|
||||
const { document, store, windowRequire, parent } = monitor.panelWin;
|
||||
const parentDocument = parent.document;
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
|
@ -30,7 +29,7 @@ add_task(async function() {
|
|||
|
||||
// Context Menu > "Edit & Resend"
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, xhrRequest);
|
||||
parentDocument.querySelector("#request-list-context-resend").click();
|
||||
getContextMenuItem(monitor, "request-list-context-resend").click();
|
||||
|
||||
// Waits for "Edit & Resend" panel to appear > New request "Send"
|
||||
document.querySelector("#custom-request-send-button").click();
|
||||
|
|
|
@ -12,7 +12,6 @@ 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));
|
||||
|
@ -20,15 +19,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 wait;
|
||||
await waitUntil(() =>
|
||||
getContextMenuItem(monitor, "request-list-context-open-in-debugger"));
|
||||
|
||||
const onDebuggerReady = toolbox.once("jsdebugger-ready");
|
||||
contextMenuDoc.querySelector("#request-list-context-open-in-debugger").click();
|
||||
getContextMenuItem(monitor, "request-list-context-open-in-debugger").click();
|
||||
await onDebuggerReady;
|
||||
|
||||
ok(true, "Debugger has been open");
|
||||
|
|
|
@ -12,7 +12,6 @@ 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));
|
||||
|
@ -20,16 +19,15 @@ 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 wait;
|
||||
await waitUntil(() =>
|
||||
getContextMenuItem(monitor, "request-list-context-open-in-style-editor"));
|
||||
|
||||
const onStyleEditorReady = toolbox.once("styleeditor-ready");
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-open-in-style-editor").click();
|
||||
getContextMenuItem(monitor, "request-list-context-open-in-style-editor").click();
|
||||
await onStyleEditorReady;
|
||||
|
||||
ok(true, "Style Editor has been open");
|
||||
|
|
|
@ -12,7 +12,6 @@ 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;
|
||||
|
||||
|
@ -46,16 +45,15 @@ 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 wait;
|
||||
await waitUntil(() =>
|
||||
getContextMenuItem(monitor, "request-list-context-newtab"));
|
||||
|
||||
const onTabOpen = once(gBrowser.tabContainer, "TabOpen", false);
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-newtab").click();
|
||||
getContextMenuItem(monitor, "request-list-context-newtab").click();
|
||||
await onTabOpen;
|
||||
info("A new tab has been opened");
|
||||
|
||||
|
|
|
@ -33,16 +33,14 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
objectRow);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#properties-view-context-menu-copy").click();
|
||||
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
|
||||
}, `{"obj":{"type":"string"}}`);
|
||||
|
||||
/* Test for copy all */
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
objectRow);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#properties-view-context-menu-copyall").click();
|
||||
getContextMenuItem(monitor, "properties-view-context-menu-copyall").click();
|
||||
}, `{"JSON":{"obj":{"type":"string"}},` +
|
||||
`"Response payload":{"EDITOR_CONFIG":{"text":` +
|
||||
`"{\\"obj\\": {\\"type\\": \\"string\\" }}","mode":"application/json"}}}`);
|
||||
|
@ -51,8 +49,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
stringRow);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#properties-view-context-menu-copy").click();
|
||||
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
|
||||
}, "type: string");
|
||||
|
||||
await teardown(monitor);
|
||||
|
@ -100,8 +97,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
cur);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#properties-view-context-menu-copy").click();
|
||||
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
|
||||
}, JSON.stringify(expectedResponseCookies[i]));
|
||||
}
|
||||
|
||||
|
@ -111,8 +107,7 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
cur);
|
||||
await waitForClipboardPromise(function setup() {
|
||||
monitor.panelWin.parent.document
|
||||
.querySelector("#properties-view-context-menu-copy").click();
|
||||
getContextMenuItem(monitor, "properties-view-context-menu-copy").click();
|
||||
}, expectedRequestCookies[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
add_task(async function() {
|
||||
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);
|
||||
|
||||
const { document, store, windowRequire, parent } = monitor.panelWin;
|
||||
const parentDocument = parent.document;
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
|
@ -29,7 +28,7 @@ add_task(async function() {
|
|||
|
||||
// Context Menu > "Resend"
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest);
|
||||
parentDocument.querySelector("#request-list-context-resend-only").click();
|
||||
getContextMenuItem(monitor, "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 { parent, document, store, windowRequire } = monitor.panelWin;
|
||||
const { 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"));
|
||||
parent.document.querySelector("#request-list-header-reset-sorting").click();
|
||||
getContextMenuItem(monitor, "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"));
|
||||
parent.document.querySelector("#request-list-header-reset-columns").click();
|
||||
getContextMenuItem(monitor, "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.
|
||||
monitor.panelWin.parent.document.querySelector("#request-list-context-resend").click();
|
||||
getContextMenuItem(monitor, "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 } = await initNetMonitor(SIMPLE_URL);
|
||||
const { monitor, toolbox } = await initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
|
@ -26,7 +26,10 @@ add_task(async function() {
|
|||
ok(!snapshot.parent, "No events have been logged for the main process");
|
||||
|
||||
document.getElementById("network-throttling-menu").click();
|
||||
monitor.panelWin.parent.document.querySelector("menuitem[label='GPRS']").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();
|
||||
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 = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-use-as-fetch");
|
||||
const useAsFetchNode = getContextMenuItem(monitor,
|
||||
"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, parent } = monitor.panelWin;
|
||||
const { document } = 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);
|
||||
parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
|
||||
getContextMenuItem(monitor, `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, parent } = monitor.panelWin;
|
||||
const { document } = 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);
|
||||
parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
|
||||
getContextMenuItem(monitor, `request-list-header-${column}-toggle`).click();
|
||||
await onHeaderAdded;
|
||||
|
||||
ok(document.querySelector(`#requests-list-${column}-button`),
|
||||
|
@ -867,3 +867,12 @@ 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);
|
||||
}
|
||||
|
|
|
@ -32,12 +32,6 @@ class NetworkThrottlingMenu extends PureComponent {
|
|||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
useTopLevelWindow: false,
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.onShowThrottlingMenu = this.onShowThrottlingMenu.bind(this);
|
||||
|
@ -68,7 +62,7 @@ class NetworkThrottlingMenu extends PureComponent {
|
|||
click: () => onChangeNetworkThrottling(false, ""),
|
||||
});
|
||||
|
||||
showMenu(menuItems, { button: event.target, useTopLevelWindow });
|
||||
showMenu(menuItems, { button: event.target });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -32,5 +32,5 @@ async function openTextBoxContextMenu(toolbox, element) {
|
|||
const onConsoleMenuOpened = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(element);
|
||||
await onConsoleMenuOpened;
|
||||
return toolbox.doc.getElementById("toolbox-menu");
|
||||
return toolbox.getTextBoxContextMenu();
|
||||
}
|
||||
|
|
|
@ -297,8 +297,7 @@ async function openContextMenu(hud, element) {
|
|||
const onConsoleMenuOpened = hud.ui.wrapper.once("menu-open");
|
||||
synthesizeContextMenuEvent(element);
|
||||
await onConsoleMenuOpened;
|
||||
const doc = hud.chromeWindow.document;
|
||||
return doc.getElementById("webconsole-menu");
|
||||
return _getContextMenu(hud);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,8 +309,7 @@ async function openContextMenu(hud, element) {
|
|||
* @return promise
|
||||
*/
|
||||
function hideContextMenu(hud) {
|
||||
const doc = hud.chromeWindow.document;
|
||||
const popup = doc.getElementById("webconsole-menu");
|
||||
const popup = _getContextMenu(hud);
|
||||
if (!popup) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
@ -321,6 +319,12 @@ 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче