зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438118 - Do not show open in netmonitor context menu entry in browser console; r=bgrins.
We also add a test to make sure we have the expected context menu on log and network message in the browser console. MozReview-Commit-ID: E2woQj5clJF --HG-- extra : rebase_source : a3de488ed61e8124ad743983eeb23791df911716
This commit is contained in:
Родитель
2a77281049
Коммит
699a7a874f
|
@ -172,6 +172,7 @@ skip-if = true # Bug 1437807
|
|||
skip-if = true # Bug 1437843
|
||||
[browser_console_consolejsm_output.js]
|
||||
skip-if = true # Bug 1437844
|
||||
[browser_console_context_menu_entries.js]
|
||||
[browser_console_dead_objects.js]
|
||||
skip-if = true # Bug 1437845
|
||||
[browser_console_error_source_click.js]
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Check that we display the expected context menu entries.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
|
||||
"new-console-output/test/mochitest/test-console.html";
|
||||
|
||||
add_task(async function () {
|
||||
// Enable net messages in the console for this test.
|
||||
await pushPref("devtools.browserconsole.filter.net", true);
|
||||
|
||||
await addTab(TEST_URI);
|
||||
const hud = await HUDService.toggleBrowserConsole();
|
||||
|
||||
info("Reload the content window to produce a network log");
|
||||
const onNetworkMessage = waitForMessage(hud, "test-console.html");
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
|
||||
content.wrappedJSObject.location.reload();
|
||||
});
|
||||
const networkMessage = await onNetworkMessage;
|
||||
|
||||
info("Open and check the context menu for the network message");
|
||||
let menuPopup = await openContextMenu(hud, networkMessage.node);
|
||||
ok(menuPopup, "The context menu is displayed on a network message");
|
||||
|
||||
let expectedContextMenu = [
|
||||
"#console-menu-copy-url (a)",
|
||||
"#console-menu-open-url (T)",
|
||||
"#console-menu-store (S) [disabled]",
|
||||
"#console-menu-copy (C)",
|
||||
"#console-menu-copy-object (o) [disabled]",
|
||||
"#console-menu-select (A)"
|
||||
];
|
||||
is(getSimplifiedContextMenu(menuPopup).join("\n"), expectedContextMenu.join("\n"),
|
||||
"The context menu has the expected entries for a network message");
|
||||
|
||||
info("Logging a text message in the content window");
|
||||
const onLogMessage = waitForMessage(hud, "simple text message");
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
|
||||
content.wrappedJSObject.console.log("simple text message");
|
||||
});
|
||||
|
||||
const logMessage = await onLogMessage;
|
||||
menuPopup = await openContextMenu(hud, logMessage.node);
|
||||
ok(menuPopup, "The context menu is displayed on a log message");
|
||||
|
||||
expectedContextMenu = [
|
||||
"#console-menu-store (S) [disabled]",
|
||||
"#console-menu-copy (C)",
|
||||
"#console-menu-copy-object (o) [disabled]",
|
||||
"#console-menu-select (A)"
|
||||
];
|
||||
is(getSimplifiedContextMenu(menuPopup).join("\n"), expectedContextMenu.join("\n"),
|
||||
"The context menu has the expected entries for a simple log message");
|
||||
|
||||
await hideContextMenu(hud);
|
||||
});
|
||||
|
||||
function getSimplifiedContextMenu(popupElement) {
|
||||
return [...popupElement.querySelectorAll("menuitem")]
|
||||
.map(entry => {
|
||||
const key = entry.getAttribute("accesskey");
|
||||
const disabled = entry.hasAttribute("disabled");
|
||||
return `#${entry.id} (${key})${disabled ? " [disabled]": ""}`
|
||||
});
|
||||
}
|
|
@ -242,7 +242,8 @@ async function openContextMenu(hud, element) {
|
|||
let onConsoleMenuOpened = hud.ui.newConsoleOutput.once("menu-open");
|
||||
synthesizeContextMenuEvent(element);
|
||||
await onConsoleMenuOpened;
|
||||
return hud.ui.newConsoleOutput.toolbox.doc.getElementById("webconsole-menu");
|
||||
const doc = hud.ui.newConsoleOutput.owner.chromeWindow.document;
|
||||
return doc.getElementById("webconsole-menu");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +255,8 @@ async function openContextMenu(hud, element) {
|
|||
* @return promise
|
||||
*/
|
||||
function hideContextMenu(hud) {
|
||||
let popup = hud.ui.newConsoleOutput.toolbox.doc.getElementById("webconsole-menu");
|
||||
const doc = hud.ui.newConsoleOutput.owner.chromeWindow.document;
|
||||
let popup = doc.getElementById("webconsole-menu");
|
||||
if (!popup) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
@ -69,17 +69,15 @@ function createContextMenu(jsterm, parentNode, {
|
|||
}));
|
||||
|
||||
// Open Network message in the Network panel.
|
||||
menu.append(new MenuItem({
|
||||
id: "console-menu-open-in-network-panel",
|
||||
label: l10n.getStr("webconsole.menu.openInNetworkPanel.label"),
|
||||
accesskey: l10n.getStr("webconsole.menu.openInNetworkPanel.accesskey"),
|
||||
visible: source === MESSAGE_SOURCE.NETWORK,
|
||||
click: () => {
|
||||
if (request && serviceContainer.openNetworkPanel) {
|
||||
serviceContainer.openNetworkPanel(message.messageId);
|
||||
}
|
||||
},
|
||||
}));
|
||||
if (serviceContainer.openNetworkPanel && request) {
|
||||
menu.append(new MenuItem({
|
||||
id: "console-menu-open-in-network-panel",
|
||||
label: l10n.getStr("webconsole.menu.openInNetworkPanel.label"),
|
||||
accesskey: l10n.getStr("webconsole.menu.openInNetworkPanel.accesskey"),
|
||||
visible: source === MESSAGE_SOURCE.NETWORK,
|
||||
click: () => serviceContainer.openNetworkPanel(message.messageId)
|
||||
}));
|
||||
}
|
||||
|
||||
// Open URL in a new tab for a network request.
|
||||
menu.append(new MenuItem({
|
||||
|
|
Загрузка…
Ссылка в новой задаче