From 14478454d569fd0ac32096d522e9fa8da95f6859 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Tue, 5 Dec 2017 09:49:22 +0100 Subject: [PATCH] Bug 1401944 - Delete browser_webconsole_copy_link_location in new console frontend; r=jdescottes. The test was already migrated. Took this as an opportunity to refactor the migrated test a bit. MozReview-Commit-ID: CjbBelrWjS8 --HG-- extra : rebase_source : 76d93bd71d9b48a46a40b6539bafd590a253db74 --- .../test/mochitest/browser.ini | 2 - ...console_context_menu_copy_link_location.js | 10 +- .../browser_webconsole_copy_link_location.js | 107 ------------------ 3 files changed, 6 insertions(+), 113 deletions(-) delete mode 100644 devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_copy_link_location.js diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini index 2cbeaf6f176e..9c64eadc62c5 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini @@ -259,8 +259,6 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 subsuite = clipboard [browser_webconsole_context_menu_open_url.js] [browser_webconsole_context_menu_store_as_global.js] -[browser_webconsole_copy_link_location.js] -skip-if = true # Bug 1401944 [browser_webconsole_csp_ignore_reflected_xss_message.js] skip-if = (e10s && debug) || (e10s && os == 'win') # Bug 1221499 enabled these on windows [browser_webconsole_cspro.js] diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_context_menu_copy_link_location.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_context_menu_copy_link_location.js index f02bb2efd68e..52c1feba80ec 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_context_menu_copy_link_location.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_context_menu_copy_link_location.js @@ -22,14 +22,15 @@ add_task(async function() { info("Test Copy URL menu item for text log"); info("Logging a text message in the content window"); + let onLogMessage = waitForMessage(hud, "simple text message"); await ContentTask.spawn(gBrowser.selectedBrowser, null, () => { content.wrappedJSObject.console.log("simple text message"); }); - let message = await waitFor(() => findMessage(hud, "simple text message")); + 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); + 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"); @@ -39,15 +40,16 @@ add_task(async function() { info("Test Copy URL menu item for network log"); info("Reload the content window to produce a network log"); + let onNetworkMessage = waitForMessage(hud, "test-console.html"); await ContentTask.spawn(gBrowser.selectedBrowser, null, () => { content.wrappedJSObject.location.reload(); }); - message = await waitFor(() => findMessage(hud, "test-console.html")); + message = await onNetworkMessage; ok(message, "Network log found in the console"); info("Open and check the context menu for the logged network message"); - menuPopup = await openContextMenu(hud, message); + menuPopup = await openContextMenu(hud, message.node); copyURLItem = menuPopup.querySelector(CONTEXT_MENU_ID); ok(copyURLItem, "Copy url menu item is available in context menu"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_copy_link_location.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_copy_link_location.js deleted file mode 100644 index e309b36e7b82..000000000000 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_copy_link_location.js +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Test for the "Copy link location" context menu item shown when you right -// click network requests in the output. See Bug 638949. - -"use strict"; - -add_task(function* () { - const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" + - "test/test-console.html?_date=" + Date.now(); - const COMMAND_NAME = "consoleCmd_copyURL"; - const CONTEXT_MENU_ID = "#menu_copyURL"; - - registerCleanupFunction(() => { - Services.prefs.clearUserPref("devtools.webconsole.filter.networkinfo"); - }); - - Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", true); - - yield loadTab(TEST_URI); - let hud = yield openConsole(); - let output = hud.outputNode; - let menu = hud.iframeWindow.document.getElementById("output-contextmenu"); - - hud.jsterm.clearOutput(); - content.console.log("bug 638949"); - - // Test that the "Copy Link Location" command is disabled for non-network - // messages. - let [result] = yield waitForMessages({ - webconsole: hud, - messages: [{ - text: "bug 638949", - category: CATEGORY_WEBDEV, - severity: SEVERITY_LOG, - }], - }); - - output.focus(); - let message = [...result.matched][0]; - - goUpdateCommand(COMMAND_NAME); - ok(!isEnabled(), COMMAND_NAME + " is disabled"); - - // Test that the "Copy Link Location" menu item is hidden for non-network - // messages. - yield waitForContextMenu(menu, message, () => { - let isHidden = menu.querySelector(CONTEXT_MENU_ID).hidden; - ok(isHidden, CONTEXT_MENU_ID + " is hidden"); - }); - - hud.jsterm.clearOutput(); - // Reloading will produce network logging - content.location.reload(); - - // Test that the "Copy Link Location" command is enabled and works - // as expected for any network-related message. - // This command should copy only the URL. - [result] = yield waitForMessages({ - webconsole: hud, - messages: [{ - text: "test-console.html", - category: CATEGORY_NETWORK, - severity: SEVERITY_LOG, - }], - }); - - output.focus(); - message = [...result.matched][0]; - hud.ui.output.selectMessage(message); - - goUpdateCommand(COMMAND_NAME); - ok(isEnabled(), COMMAND_NAME + " is enabled"); - - info("expected clipboard value: " + message.url); - - let deferred = defer(); - - waitForClipboard((aData) => { - return aData.trim() == message.url; - }, () => { - goDoCommand(COMMAND_NAME); - }, () => { - deferred.resolve(null); - }, () => { - deferred.reject(null); - }); - - yield deferred.promise; - - // Test that the "Copy Link Location" menu item is visible for network-related - // messages. - yield waitForContextMenu(menu, message, () => { - let isVisible = !menu.querySelector(CONTEXT_MENU_ID).hidden; - ok(isVisible, CONTEXT_MENU_ID + " is visible"); - }); - - // Return whether "Copy Link Location" command is enabled or not. - function isEnabled() { - let controller = top.document.commandDispatcher - .getControllerForCommand(COMMAND_NAME); - return controller && controller.isCommandEnabled(COMMAND_NAME); - } -});