author | fanny <fannyvieira082@gmail.com> |
Mon, 04 Mar 2019 10:36:11 +0000 | |
changeset 462237 | 4565c0c6aea8295b8f5df972fb12098752d43e19 |
parent 462236 | 664b3bc4a44924722ff985840ac1041bd45f3e74 |
child 462238 | 817014bcd372fd598b5f44c62070069076544c42 |
push id | 79511 |
push user | nchevobbe@mozilla.com |
push date | Mon, 04 Mar 2019 14:10:21 +0000 |
treeherder | autoland@4565c0c6aea8 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nchevobbe |
bugs | 1457111 |
milestone | 67.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_link_location.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_link_location.js @@ -18,28 +18,39 @@ add_task(async function() { await pushPref("devtools.webconsole.filter.net", true); const hud = await openNewTabAndConsole(TEST_URI); hud.ui.clearOutput(); info("Test Copy URL menu item for text log"); info("Logging a text message in the content window"); - const onLogMessage = waitForMessage(hud, "simple text message"); + const onLogMessage = waitForMessage(hud, "stringLog"); await ContentTask.spawn(gBrowser.selectedBrowser, null, () => { - content.wrappedJSObject.console.log("simple text message"); + content.wrappedJSObject.stringLog(); }); let message = await onLogMessage; ok(message, "Text log found in the console"); info("Open and check the context menu for the logged text message"); let menuPopup = await openContextMenu(hud, message.node); + let copyURLItem = menuPopup.querySelector(CONTEXT_MENU_ID); ok(!copyURLItem, "Copy URL menu item is hidden for a simple text message"); + info("Open and check the context menu for the logged text message"); + const locationElement = message.node.querySelector(".frame-link-source-inner"); + menuPopup = await openContextMenu(hud, locationElement); + copyURLItem = menuPopup.querySelector(CONTEXT_MENU_ID); + ok(copyURLItem, "The Copy Link Location entry is displayed"); + + info("Click on Copy URL menu item and wait for clipboard to be updated"); + await waitForClipboardPromise(() => copyURLItem.click(), TEST_URI); + ok(true, "Expected text was copied to the clipboard."); + await hideContextMenu(hud); hud.ui.clearOutput(); info("Test Copy URL menu item for network log"); info("Reload the content window to produce a network log"); const onNetworkMessage = waitForMessage(hud, "test-console.html"); await ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
--- a/devtools/client/webconsole/utils/context-menu.js +++ b/devtools/client/webconsole/utils/context-menu.js @@ -43,16 +43,17 @@ function createContextMenu(webConsoleUI, clipboardText, variableText, message, serviceContainer, openSidebar, rootActorId, executionPoint, toolbox, + url, }) { const win = parentNode.ownerDocument.defaultView; const selection = win.getSelection(); const { source, request } = message || {}; const menu = new Menu({ id: "webconsole-menu", @@ -202,12 +203,21 @@ function createContextMenu(webConsoleUI, disabled: false, click: () => { const threadClient = toolbox.threadClient; threadClient.timeWarp(executionPoint); }, })); } + if (url) { + menu.append(new MenuItem({ + id: "console-menu-copy-url", + label: l10n.getStr("webconsole.menu.copyURL.label"), + accesskey: l10n.getStr("webconsole.menu.copyURL.accesskey"), + click: () => clipboardHelper.copyString(url), + })); + } + return menu; } exports.createContextMenu = createContextMenu;
--- a/devtools/client/webconsole/webconsole-wrapper.js +++ b/devtools/client/webconsole/webconsole-wrapper.js @@ -193,16 +193,19 @@ class WebConsoleWrapper { // is available in the current scope and we can pass it into // `createContextMenu` method. serviceContainer.openContextMenu = (e, message) => { const { screenX, screenY, target } = e; const messageEl = target.closest(".message"); const clipboardText = getElementText(messageEl); + const linkEl = target.closest("a[href]"); + const url = linkEl && linkEl.href; + const messageVariable = target.closest(".objectBox"); // Ensure that console.group and console.groupCollapsed commands are not captured const variableText = (messageVariable && !(messageEl.classList.contains("startGroup")) && !(messageEl.classList.contains("startGroupCollapsed"))) ? messageVariable.textContent : null; // Retrieve closes actor id from the DOM. @@ -228,16 +231,17 @@ class WebConsoleWrapper { clipboardText, variableText, message, serviceContainer, openSidebar, rootActorId, executionPoint, toolbox: this.toolbox, + url, }); // Emit the "menu-open" event for testing. menu.once("open", () => this.emit("menu-open")); menu.popup(screenX, screenY, { doc: this.hud.chromeWindow.document }); return menu; };