--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -94,24 +94,18 @@ Tools.inspector = {
build: function(iframeWindow, toolbox) {
return new InspectorPanel(iframeWindow, toolbox);
}
};
Tools.webConsole = {
id: "webconsole",
accesskey: l10n("webConsoleCmd.accesskey"),
ordinal: 2,
- oldWebConsoleURL: "chrome://devtools/content/webconsole/old/webconsole.xul",
- newWebConsoleURL: "chrome://devtools/content/webconsole/webconsole.html",
- get browserConsoleURL() {
- if (Services.prefs.getBoolPref("devtools.browserconsole.new-frontend-enabled")) {
- return "chrome://devtools/content/webconsole/browserconsole.xul";
- }
- return Tools.webConsole.oldWebConsoleURL;
- },
+ url: "chrome://devtools/content/webconsole/webconsole.html",
+ browserConsoleURL: "chrome://devtools/content/webconsole/browserconsole.xul",
icon: "chrome://devtools/skin/images/tool-webconsole.svg",
label: l10n("ToolboxTabWebconsole.label"),
menuLabel: l10n("MenuWebconsole.label"),
panelLabel: l10n("ToolboxWebConsole.panelLabel"),
get tooltip() {
return l10n("ToolboxWebconsole.tooltip2",
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
l10n("webconsole.commandkey"));
@@ -131,29 +125,16 @@ Tools.webConsole = {
isTargetSupported: function() {
return true;
},
build: function(iframeWindow, toolbox) {
return new WebConsolePanel(iframeWindow, toolbox);
}
};
-function switchWebconsole() {
- if (Services.prefs.getBoolPref("devtools.webconsole.new-frontend-enabled")) {
- Tools.webConsole.url = Tools.webConsole.newWebConsoleURL;
- } else {
- Tools.webConsole.url = Tools.webConsole.oldWebConsoleURL;
- }
-}
-switchWebconsole();
-
-Services.prefs.addObserver(
- "devtools.webconsole.new-frontend-enabled",
- { observe: switchWebconsole }
-);
Tools.jsdebugger = {
id: "jsdebugger",
accesskey: l10n("debuggerMenu.accesskey"),
ordinal: 3,
icon: "chrome://devtools/skin/images/tool-debugger.svg",
url: "chrome://devtools/content/debugger/debugger.xul",
label: l10n("ToolboxDebugger.label"),
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -367,21 +367,16 @@ OptionsPanel.prototype = {
let isNightly = AppConstants.NIGHTLY_BUILD;
if (!isNightly) {
return;
}
// Labels for these new buttons are nightly only and mostly intended for working on
// devtools.
let prefDefinitions = [{
- pref: "devtools.webconsole.new-frontend-enabled",
- label: L10N.getStr("toolbox.options.enableNewConsole.label"),
- id: "devtools-new-webconsole",
- parentId: "webconsole-options"
- }, {
pref: "devtools.debugger.new-debugger-frontend",
label: L10N.getStr("toolbox.options.enableNewDebugger.label"),
id: "devtools-new-debugger",
parentId: "debugger-options"
}, {
pref: "devtools.performance.new-panel-enabled",
label: "Enable new performance recorder (then re-open DevTools)",
id: "devtools-new-performance",
--- a/devtools/client/framework/toolbox-process-window.js
+++ b/devtools/client/framework/toolbox-process-window.js
@@ -97,17 +97,16 @@ function setPrefDefaults() {
Services.prefs.setBoolPref("devtools.performance.ui.show-platform-data", true);
Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true);
Services.prefs.setBoolPref("browser.dom.window.dump.enabled", true);
Services.prefs.setBoolPref("devtools.command-button-noautohide.enabled", true);
Services.prefs.setBoolPref("devtools.scratchpad.enabled", true);
// Bug 1225160 - Using source maps with browser debugging can lead to a crash
Services.prefs.setBoolPref("devtools.debugger.source-maps-enabled", false);
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", true);
- Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", true);
Services.prefs.setBoolPref("devtools.preference.new-panel-enabled", false);
Services.prefs.setBoolPref("layout.css.emulate-moz-box-with-flex", false);
}
window.addEventListener("load", async function() {
let cmdClose = document.getElementById("toolbox-cmd-close");
cmdClose.addEventListener("command", onCloseCommand);
setPrefDefaults();
// Reveal status message if connecting is slow or if an error occurs.
--- a/devtools/client/jar.mn
+++ b/devtools/client/jar.mn
@@ -5,17 +5,16 @@
devtools.jar:
% content devtools %content/
content/shared/vendor/d3.js (shared/vendor/d3.js)
content/shared/vendor/dagre-d3.js (shared/vendor/dagre-d3.js)
content/shared/widgets/widgets.css (shared/widgets/widgets.css)
content/shared/widgets/VariablesView.xul (shared/widgets/VariablesView.xul)
content/webconsole/webconsole.html (webconsole/webconsole.html)
content/webconsole/browserconsole.xul (webconsole/browserconsole.xul)
-* content/webconsole/old/webconsole.xul (webconsole/old/webconsole.xul)
* content/scratchpad/scratchpad.xul (scratchpad/scratchpad.xul)
content/scratchpad/scratchpad.js (scratchpad/scratchpad.js)
content/shared/splitview.css (shared/splitview.css)
content/shared/theme-switching.js (shared/theme-switching.js)
* content/styleeditor/styleeditor.xul (styleeditor/styleeditor.xul)
* content/storage/storage.xul (storage/storage.xul)
content/inspector/inspector.js (inspector/inspector.js)
content/inspector/markup/markup.xhtml (inspector/markup/markup.xhtml)
--- a/devtools/client/locales/en-US/toolbox.properties
+++ b/devtools/client/locales/en-US/toolbox.properties
@@ -202,12 +202,8 @@ toolbox.sourceMapFailure=Source map erro
# The text of the error: %1$S
# The URL of the source: %2$S
toolbox.sourceMapSourceFailure=Error while fetching an original source: %1$S\nSource URL: %2$S
# LOCALIZATION NOTE (toolbox.options.enableNewDebugger.label): Label of the options panel
# checkbox to enable the new debugger frontend. Displayed only in Nightly and local
# builds.
toolbox.options.enableNewDebugger.label=Enable new debugger frontend
-
-# LOCALIZATION NOTE (toolbox.options.enableNewConsole.label): Label of the options panel
-# checkbox to enable the new console frontend. Displayed only in Nightly and local builds.
-toolbox.options.enableNewConsole.label=Enable new console frontend
deleted file mode 100644
--- a/devtools/client/locales/en-US/webConsole.dtd
+++ /dev/null
@@ -1,96 +0,0 @@
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this
- - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<!-- LOCALIZATION NOTE : FILE The correct localization of this file might be to
- - keep it in English, or another language commonly spoken among web developers.
- - You want to make that choice consistent across the developer tools.
- - A good criteria is the language in which you'd find the best
- - documentation on web development on the web. -->
-<!ENTITY window.title "Web Console">
-<!-- LOCALIZATION NOTE (openURL.label): You can see this string in the Web
- - Console context menu. -->
-<!ENTITY openURL.label "Open URL in New Tab">
-<!ENTITY openURL.accesskey "T">
-<!-- LOCALIZATION NOTE (btnPageNet.label): This string is used for the menu
- - button that allows users to toggle the network logging output.
- - This string and the following strings toggle various kinds of output
- - filters. -->
-<!ENTITY btnPageNet.label "Net">
-<!ENTITY btnPageNet.tooltip "Log network access">
-<!ENTITY btnPageNet.accesskey "N">
-<!-- LOCALIZATION NOTE (btnPageNet.accesskeyMacOSX): This string is used as
- - access key for the menu button that allows users to toggle the network
- - logging output. On MacOSX accesskeys are available with Ctrl-*. Please make
- - sure you do not use the following letters: A, E, N and P. These are used
- - for editing commands in text inputs. -->
-<!ENTITY btnPageNet.accesskeyMacOSX "t">
-<!ENTITY btnPageCSS.label "CSS">
-<!ENTITY btnPageCSS.tooltip2 "Log CSS errors and warnings">
-<!ENTITY btnPageCSS.accesskey "C">
-<!ENTITY btnPageJS.label "JS">
-<!ENTITY btnPageJS.tooltip "Log JavaScript exceptions">
-<!ENTITY btnPageJS.accesskey "J">
-<!ENTITY btnPageSecurity.label "Security">
-<!ENTITY btnPageSecurity.tooltip "Log security errors and warnings">
-<!ENTITY btnPageSecurity.accesskey "u">
-
-<!-- LOCALIZATION NOTE (btnPageLogging): This is used as the text of the
- - the toolbar. It shows or hides messages that the web developer inserted on
- - the page for debugging purposes, using calls such console.log() and
- - console.error(). -->
-<!ENTITY btnPageLogging.label "Logging">
-<!ENTITY btnPageLogging.tooltip "Log messages sent to the window.console object">
-<!ENTITY btnPageLogging.accesskey3 "L">
-<!ENTITY btnConsoleErrors "Errors">
-<!ENTITY btnConsoleInfo "Info">
-<!ENTITY btnConsoleWarnings "Warnings">
-<!ENTITY btnConsoleLog "Log">
-<!ENTITY btnConsoleXhr "XHR">
-<!ENTITY btnConsoleReflows "Reflows">
-
-<!-- LOCALIZATION NOTE (btnServerLogging): This is used as the text of the
- - the toolbar. It shows or hides messages that the web developer inserted on
- - the page for debugging purposes, using calls on the HTTP server. -->
-<!ENTITY btnServerLogging.label "Server">
-<!ENTITY btnServerLogging.tooltip "Log messages received from a web server">
-<!ENTITY btnServerLogging.accesskey "S">
-<!ENTITY btnServerErrors "Errors">
-<!ENTITY btnServerInfo "Info">
-<!ENTITY btnServerWarnings "Warnings">
-<!ENTITY btnServerLog "Log">
-
-<!-- LOCALIZATION NODE (btnConsoleSharedWorkers) the term "Shared Workers"
- - should not be translated. -->
-<!ENTITY btnConsoleSharedWorkers "Shared Workers">
-<!-- LOCALIZATION NODE (btnConsoleServiceWorkers) the term "Service Workers"
- - should not be translated. -->
-<!ENTITY btnConsoleServiceWorkers "Service Workers">
-<!-- LOCALIZATION NODE (btnConsoleWindowlessWorkers) the term "Workers"
- - should not be translated. -->
-<!ENTITY btnConsoleWindowlessWorkers "Add-on or Chrome Workers">
-
-<!ENTITY filterOutput.placeholder "Filter output">
-<!ENTITY btnClear.label "Clear">
-<!ENTITY btnClear.tooltip "Clear the Web Console output">
-<!ENTITY btnClear.accesskey "r">
-
-<!ENTITY fullZoomEnlargeCmd.commandkey "+">
-<!ENTITY fullZoomEnlargeCmd.commandkey2 "="> <!-- + is above this key on many keyboards -->
-<!ENTITY fullZoomEnlargeCmd.commandkey3 "">
-
-<!ENTITY fullZoomReduceCmd.commandkey "-">
-<!ENTITY fullZoomReduceCmd.commandkey2 "">
-
-<!ENTITY fullZoomResetCmd.commandkey "0">
-<!ENTITY fullZoomResetCmd.commandkey2 "">
-
-<!ENTITY copyURLCmd.label "Copy Link Location">
-<!ENTITY copyURLCmd.accesskey "a">
-
-<!ENTITY closeCmd.key "W">
-<!ENTITY findCmd.key "F">
-<!ENTITY clearOutputCtrl.key "L">
-<!ENTITY openInVarViewCmd.label "Open in Variables View">
-<!ENTITY openInVarViewCmd.accesskey "V">
-<!ENTITY storeAsGlobalVar.label "Store as global variable">
-<!ENTITY storeAsGlobalVar.accesskey "S">
--- a/devtools/client/locales/en-US/webconsole.properties
+++ b/devtools/client/locales/en-US/webconsole.properties
@@ -9,67 +9,37 @@
# documentation on web development on the web.
# LOCALIZATION NOTE (browserConsole.title): shown as the
# title when opening the browser console popup
browserConsole.title=Browser Console
# LOCALIZATION NOTE (timestampFormat): %1$02S = hours (24-hour clock),
# %2$02S = minutes, %3$02S = seconds, %4$03S = milliseconds.
timestampFormat=%02S:%02S:%02S.%03S
helperFuncUnsupportedTypeError=Can’t call pprint on this type of object.
-# LOCALIZATION NOTE (NetworkPanel.durationMS): this string is used to
-# show the duration between two network events (e.g request and response
-# header or response header and response body). Parameters: %S is the duration.
-NetworkPanel.durationMS=%Sms
ConsoleAPIDisabled=The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.
# LOCALIZATION NOTE (webConsoleXhrIndicator): the indicator displayed before
# a URL in the Web Console that was requested using an XMLHttpRequest.
-# Should probably be the same as &btnConsoleXhr; in webConsole.dtd
webConsoleXhrIndicator=XHR
-# LOCALIZATION NOTE (webConsoleMixedContentWarning): the message displayed
-# after a URL in the Web Console that has been flagged for Mixed Content (i.e.
-# http content in an https page).
-webConsoleMixedContentWarning=Mixed Content
-
# LOCALIZATION NOTE (webConsoleMoreInfoLabel): the more info tag displayed
# after security related web console messages.
webConsoleMoreInfoLabel=Learn More
-# LOCALIZATION NOTE (scratchpad.linkText): the text used in the right hand
-# side of the Web Console command line when JavaScript is being entered, to
-# indicate how to jump into scratchpad mode.
-scratchpad.linkText=Shift+RETURN - Open in Scratchpad
-
-# LOCALIZATION NOTE (reflow.*): the console displays reflow activity.
-# We can get 2 kind of lines: with JS link or without JS link. It looks like
-# that:
-# reflow: 12ms
-# reflow: 12ms function foobar, file.js line 42
-# The 2nd line, from "function" to the end of the line, is a link to the
-# JavaScript debugger.
-reflow.messageWithNoLink=reflow: %Sms
-reflow.messageWithLink=reflow: %Sms\u0020
-reflow.messageLinkText=function %1$S, %2$S line %3$S
-
# LOCALIZATION NOTE (stacktrace.anonymousFunction): this string is used to
# display JavaScript functions that have no given name - they are said to be
# anonymous. Test console.trace() in the webconsole.
stacktrace.anonymousFunction=<anonymous>
# LOCALIZATION NOTE (stacktrace.asyncStack): this string is used to
# indicate that a given stack frame has an async parent.
# %S is the "Async Cause" of the frame.
stacktrace.asyncStack=(Async: %S)
-# LOCALIZATION NOTE (timerStarted): this string is used to display the result
-# of the console.time() call. Parameters: %S is the name of the timer.
-timerStarted=%S: timer started
-
# LOCALIZATION NOTE (timeEnd): this string is used to display the result of
# the console.timeEnd() call. Parameters: %1$S is the name of the timer, %2$S
# is the number of milliseconds.
timeEnd=%1$S: %2$Sms
# LOCALIZATION NOTE (consoleCleared): this string is displayed when receiving a
# call to console.clear() to let the user know the previous messages of the
# console have been removed programmatically.
@@ -87,29 +57,16 @@ noGroupLabel=<no group label>
# string containing anchor doesn't matches to any property in the content.
Autocomplete.blank= <- no result
maxTimersExceeded=The maximum allowed number of timers in this page was exceeded.
timerAlreadyExists=Timer “%S†already exists.
timerDoesntExist=Timer “%S†doesn’t exist.
timerJSError=Failed to process the timer name.
-# LOCALIZATION NOTE (maxCountersExceeded): Error message shown when the maximum
-# number of console.count()-counters was exceeded.
-maxCountersExceeded=The maximum allowed number of counters in this page was exceeded.
-
-# LOCALIZATION NOTE (longStringEllipsis): the string displayed after a long
-# string. This string is clickable such that the rest of the string is
-# retrieved from the server.
-longStringEllipsis=[…]
-
-# LOCALIZATION NOTE (longStringTooLong): the string displayed after the user
-# tries to expand a long string.
-longStringTooLong=The string you are trying to view is too long to be displayed by the Web Console.
-
# LOCALIZATION NOTE (connectionTimeout): message displayed when the Remote Web
# Console fails to connect to the server due to a timeout.
connectionTimeout=Connection timeout. Check the Error Console on both ends for potential error messages. Reopen the Web Console to try again.
# LOCALIZATION NOTE (propertiesFilterPlaceholder): this is the text that
# appears in the filter text box for the properties view container.
propertiesFilterPlaceholder=Filter properties
@@ -149,39 +106,23 @@ selfxss.okstring=allow pasting
# you hover the arrow for expanding/collapsing the message details. For
# console.error() and other messages we show the stacktrace.
messageToggleDetails=Show/hide message details.
# LOCALIZATION NOTE (groupToggle): the text that is displayed when
# you hover the arrow for expanding/collapsing the messages of a group.
groupToggle=Show/hide group.
-# LOCALIZATION NOTE (emptySlotLabel): the text is displayed when an Array
-# with empty slots is printed to the console.
-# This is a semi-colon list of plural forms.
-# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
-# #1 number of empty slots
-# example: 1 empty slot
-# example: 5 empty slots
-emptySlotLabel=#1 empty slot;#1 empty slots
-
# LOCALIZATION NOTE (table.index, table.iterationIndex, table.key, table.value):
# the column header displayed in the console table widget.
table.index=(index)
table.iterationIndex=(iteration index)
table.key=Key
table.value=Values
-# LOCALIZATION NOTE (severity.error, severity.warn, severity.info, severity.log):
-# tooltip for icons next to console output
-severity.error=Error
-severity.warn=Warning
-severity.info=Info
-severity.log=Log
-
# LOCALIZATION NOTE (level.error, level.warn, level.info, level.log, level.debug):
# tooltip for icons next to console output
level.error=Error
level.warn=Warning
level.info=Info
level.log=Log
level.debug=Debug
@@ -211,22 +152,16 @@ webconsole.menu.openURL.label=Open URL i
webconsole.menu.openURL.accesskey=T
# LOCALIZATION NOTE (webconsole.menu.openInNetworkPanel.label)
# Label used for a context-menu item displayed for network message logs. Clicking on it
# opens the network message in the Network panel
webconsole.menu.openInNetworkPanel.label=Open in Network Panel
webconsole.menu.openInNetworkPanel.accesskey=N
-# LOCALIZATION NOTE (webconsole.menu.openInVarView.label)
-# Label used for a context-menu item displayed for object/variable logs. Clicking on it
-# opens the webconsole variable view for the logged variable.
-webconsole.menu.openInVarView.label=Open in Variables View
-webconsole.menu.openInVarView.accesskey=V
-
# LOCALIZATION NOTE (webconsole.menu.storeAsGlobalVar.label)
# Label used for a context-menu item displayed for object/variable logs. Clicking on it
# creates a new global variable pointing to the logged variable.
webconsole.menu.storeAsGlobalVar.label=Store as global variable
webconsole.menu.storeAsGlobalVar.accesskey=S
# LOCALIZATION NOTE (webconsole.menu.copyMessage.label)
# Label used for a context-menu item displayed for any log. Clicking on it will copy the
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -6,17 +6,16 @@
var Services = require("Services");
loader.lazyRequireGetter(this, "Utils", "devtools/client/webconsole/utils", true);
loader.lazyRequireGetter(this, "extend", "devtools/shared/extend", true);
loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
loader.lazyRequireGetter(this, "Tools", "devtools/client/definitions", true);
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
-loader.lazyRequireGetter(this, "WebConsoleFrame", "devtools/client/webconsole/old/webconsole", true);
loader.lazyRequireGetter(this, "NewWebConsoleFrame", "devtools/client/webconsole/new-webconsole", true);
loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/debugger-client", true);
loader.lazyRequireGetter(this, "showDoorhanger", "devtools/client/shared/doorhanger", true);
loader.lazyRequireGetter(this, "viewSource", "devtools/client/shared/view-source");
loader.lazyRequireGetter(this, "l10n", "devtools/client/webconsole/webconsole-l10n");
const BC_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
@@ -188,20 +187,16 @@ HUD_SERVICE.prototype =
let win = Services.ww.openWindow(null, browserConsoleURL, "_blank",
BC_WINDOW_FEATURES, null);
await new Promise(resolve => {
win.addEventListener("DOMContentLoaded", resolve, {once: true});
});
win.document.title = l10n.getStr("browserConsole.title");
- if (browserConsoleURL === Tools.webConsole.oldWebConsoleURL) {
- return {iframeWindow: win, chromeWindow: win};
- }
-
let iframe = win.document.querySelector("iframe");
await new Promise(resolve => {
iframe.addEventListener("DOMContentLoaded", resolve, {once: true});
});
return {iframeWindow: iframe.contentWindow, chromeWindow: win};
}
@@ -268,21 +263,17 @@ function WebConsole(target, iframeWindow
this.chromeWindow = chromeWindow;
this.hudId = "hud_" + ++gHudId;
this.target = target;
this.browserWindow = this.chromeWindow.top;
let element = this.browserWindow.document.documentElement;
if (element.getAttribute("windowtype") != gDevTools.chromeWindowType) {
this.browserWindow = HUDService.currentContext();
}
- if (iframeWindow.location.href === Tools.webConsole.newWebConsoleURL) {
- this.ui = new NewWebConsoleFrame(this);
- } else {
- this.ui = new WebConsoleFrame(this);
- }
+ this.ui = new NewWebConsoleFrame(this);
}
WebConsole.prototype = {
iframeWindow: null,
chromeWindow: null,
browserWindow: null,
hudId: null,
target: null,
ui: null,
--- a/devtools/client/webconsole/moz.build
+++ b/devtools/client/webconsole/moz.build
@@ -2,17 +2,16 @@
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += [
'actions',
'components',
- 'old',
'reducers',
'selectors',
'test',
'utils',
]
DevToolsModules(
'console-commands.js',
'constants.js',
deleted file mode 100644
--- a/devtools/client/webconsole/old/console-output.js
+++ /dev/null
@@ -1,3544 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const {Ci} = require("chrome");
-
-loader.lazyImporter(this, "VariablesView", "resource://devtools/client/shared/widgets/VariablesView.jsm");
-loader.lazyImporter(this, "escapeHTML", "resource://devtools/client/shared/widgets/VariablesView.jsm");
-
-loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
-loader.lazyRequireGetter(this, "TableWidget", "devtools/client/shared/widgets/TableWidget", true);
-loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/object-client");
-
-const XHTML_NS = "http://www.w3.org/1999/xhtml";
-
-const WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
-const { getSourceNames } = require("devtools/client/shared/source-utils");
-const l10n = require("devtools/client/webconsole/webconsole-l10n");
-const nodeConstants = require("devtools/shared/dom-node-constants");
-const {PluralForm} = require("devtools/shared/plural-form");
-const {extend} = require("devtools/shared/extend");
-const defer = require("devtools/shared/defer");
-
-const MAX_STRING_GRIP_LENGTH = 36;
-const {ELLIPSIS} = require("devtools/shared/l10n");
-
-const validProtocols = /^(http|https|ftp|data|javascript|resource|chrome):/i;
-
-// Constants for compatibility with the Web Console output implementation before
-// bug 778766.
-// TODO: remove these once bug 778766 is fixed.
-const COMPAT = {
- // The various categories of messages.
- CATEGORIES: {
- NETWORK: 0,
- CSS: 1,
- JS: 2,
- WEBDEV: 3,
- INPUT: 4,
- OUTPUT: 5,
- SECURITY: 6,
- SERVER: 7,
- },
-
- // The possible message severities.
- SEVERITIES: {
- ERROR: 0,
- WARNING: 1,
- INFO: 2,
- LOG: 3,
- },
-
- // The preference keys to use for each category/severity combination, indexed
- // first by category (rows) and then by severity (columns).
- //
- // Most of these rather idiosyncratic names are historical and predate the
- // division of message type into "category" and "severity".
- /* eslint-disable no-multi-spaces */
- /* eslint-disable max-len */
- PREFERENCE_KEYS: [
- // Error Warning Info Log
- [ "network", "netwarn", null, "networkinfo", ], // Network
- [ "csserror", "cssparser", null, null, ], // CSS
- [ "exception", "jswarn", null, "jslog", ], // JS
- [ "error", "warn", "info", "log", ], // Web Developer
- [ null, null, null, null, ], // Input
- [ null, null, null, null, ], // Output
- [ "secerror", "secwarn", null, null, ], // Security
- [ "servererror", "serverwarn", "serverinfo", "serverlog", ], // Server Logging
- ],
- /* eslint-enable max-len */
- /* eslint-enable no-multi-spaces */
-
- // The fragment of a CSS class name that identifies each category.
- CATEGORY_CLASS_FRAGMENTS: [ "network", "cssparser", "exception", "console",
- "input", "output", "security", "server" ],
-
- // The fragment of a CSS class name that identifies each severity.
- SEVERITY_CLASS_FRAGMENTS: [ "error", "warn", "info", "log" ],
-
- // The indent of a console group in pixels.
- GROUP_INDENT: 12,
-};
-
-// A map from the console API call levels to the Web Console severities.
-const CONSOLE_API_LEVELS_TO_SEVERITIES = {
- error: "error",
- exception: "error",
- assert: "error",
- warn: "warning",
- info: "info",
- log: "log",
- clear: "log",
- trace: "log",
- table: "log",
- debug: "log",
- dir: "log",
- dirxml: "log",
- group: "log",
- groupCollapsed: "log",
- groupEnd: "log",
- time: "log",
- timeEnd: "log",
- count: "log"
-};
-
-// Array of known message source URLs we need to hide from output.
-const IGNORED_SOURCE_URLS = ["debugger eval code"];
-
-// The maximum length of strings to be displayed by the Web Console.
-const MAX_LONG_STRING_LENGTH = 200000;
-
-// Regular expression that matches the allowed CSS property names when using
-// the `window.console` API.
-const RE_ALLOWED_STYLES = new RegExp(["^(?:-moz-)?(?:background|border|box|clear|" +
- "color|cursor|display|float|font|line|margin|" +
- "padding|text|transition|outline|white-space|" +
- "word|writing|(?:min-|max-)?width|" +
- "(?:min-|max-)?height)"]);
-
-// Regular expressions to search and replace with 'notallowed' in the styles
-// given to the `window.console` API methods.
-const RE_CLEANUP_STYLES = [
- // url(), -moz-element()
- /\b(?:url|(?:-moz-)?element)[\s('"]+/gi,
-
- // various URL protocols
- /['"(]*(?:chrome|resource|about|app|data|https?|ftp|file):+\/*/gi,
-];
-
-// Maximum number of rows to display in console.table().
-const TABLE_ROW_MAX_ITEMS = 1000;
-
-// Maximum number of columns to display in console.table().
-const TABLE_COLUMN_MAX_ITEMS = 10;
-
-/**
- * The ConsoleOutput object is used to manage output of messages in the Web
- * Console.
- *
- * @constructor
- * @param object owner
- * The console output owner. This usually the WebConsoleFrame instance.
- * Any other object can be used, as long as it has the following
- * properties and methods:
- * - window
- * - document
- * - outputMessage(category, methodOrNode[, methodArguments])
- * TODO: this is needed temporarily, until bug 778766 is fixed.
- */
-function ConsoleOutput(owner) {
- this.owner = owner;
- this._onFlushOutputMessage = this._onFlushOutputMessage.bind(this);
-}
-
-ConsoleOutput.prototype = {
- _dummyElement: null,
-
- /**
- * The output container.
- * @type DOMElement
- */
- get element() {
- return this.owner.outputNode;
- },
-
- /**
- * The document that holds the output.
- * @type DOMDocument
- */
- get document() {
- return this.owner ? this.owner.document : null;
- },
-
- /**
- * The DOM window that holds the output.
- * @type Window
- */
- get window() {
- return this.owner.window;
- },
-
- /**
- * Getter for the debugger WebConsoleClient.
- * @type object
- */
- get webConsoleClient() {
- return this.owner.webConsoleClient;
- },
-
- /**
- * Getter for the current toolbox debuggee target.
- * @type Target
- */
- get toolboxTarget() {
- return this.owner.owner.target;
- },
-
- /**
- * Release an actor.
- *
- * @private
- * @param string actorId
- * The actor ID you want to release.
- */
- _releaseObject: function(actorId) {
- this.owner._releaseObject(actorId);
- },
-
- /**
- * Add a message to output.
- *
- * @param object ...args
- * Any number of Message objects.
- * @return this
- */
- addMessage: function(...args) {
- for (let msg of args) {
- msg.init(this);
- this.owner.outputMessage(msg._categoryCompat, this._onFlushOutputMessage,
- [msg]);
- }
- return this;
- },
-
- /**
- * Message renderer used for compatibility with the current Web Console output
- * implementation. This method is invoked for every message object that is
- * flushed to output. The message object is initialized and rendered, then it
- * is displayed.
- *
- * TODO: remove this method once bug 778766 is fixed.
- *
- * @private
- * @param object message
- * The message object to render.
- * @return DOMElement
- * The message DOM element that can be added to the console output.
- */
- _onFlushOutputMessage: function(message) {
- return message.render().element;
- },
-
- /**
- * Get an array of selected messages. This list is based on the text selection
- * start and end points.
- *
- * @param number [limit]
- * Optional limit of selected messages you want. If no value is given,
- * all of the selected messages are returned.
- * @return array
- * Array of DOM elements for each message that is currently selected.
- */
- getSelectedMessages: function(limit) {
- let selection = this.window.getSelection();
- if (selection.isCollapsed) {
- return [];
- }
-
- if (selection.containsNode(this.element, true)) {
- return Array.slice(this.element.children);
- }
-
- let anchor = this.getMessageForElement(selection.anchorNode);
- let focus = this.getMessageForElement(selection.focusNode);
- if (!anchor || !focus) {
- return [];
- }
-
- let start, end;
- if (anchor.timestamp > focus.timestamp) {
- start = focus;
- end = anchor;
- } else {
- start = anchor;
- end = focus;
- }
-
- let result = [];
- let current = start;
- while (current) {
- result.push(current);
- if (current == end || (limit && result.length == limit)) {
- break;
- }
- current = current.nextSibling;
- }
- return result;
- },
-
- /**
- * Find the DOM element of a message for any given descendant.
- *
- * @param DOMElement elem
- * The element to start the search from.
- * @return DOMElement|null
- * The DOM element of the message, if any.
- */
- getMessageForElement: function(elem) {
- while (elem && elem.parentNode) {
- if (elem.classList && elem.classList.contains("message")) {
- return elem;
- }
- elem = elem.parentNode;
- }
- return null;
- },
-
- /**
- * Select all messages.
- */
- selectAllMessages: function() {
- let selection = this.window.getSelection();
- selection.removeAllRanges();
- let range = this.document.createRange();
- range.selectNodeContents(this.element);
- selection.addRange(range);
- },
-
- /**
- * Add a message to the selection.
- *
- * @param DOMElement elem
- * The message element to select.
- */
- selectMessage: function(elem) {
- let selection = this.window.getSelection();
- selection.removeAllRanges();
- let range = this.document.createRange();
- range.selectNodeContents(elem);
- selection.addRange(range);
- },
-
- /**
- * Open an URL in a new tab.
- * @see WebConsole.openLink() in hudservice.js
- */
- openLink: function() {
- this.owner.owner.openLink.apply(this.owner.owner, arguments);
- },
-
- openLocationInDebugger: function({url, line}) {
- return this.owner.owner.viewSourceInDebugger(url, line);
- },
-
- /**
- * Open the variables view to inspect an object actor.
- * @see JSTerm.openVariablesView() in webconsole.js
- */
- openVariablesView: function() {
- this.owner.jsterm.openVariablesView.apply(this.owner.jsterm, arguments);
- },
-
- /**
- * Destroy this ConsoleOutput instance.
- */
- destroy: function() {
- this._dummyElement = null;
- this.owner = null;
- },
-}; // ConsoleOutput.prototype
-
-/**
- * Message objects container.
- * @type object
- */
-var Messages = {};
-
-/**
- * The BaseMessage object is used for all types of messages. Every kind of
- * message should use this object as its base.
- *
- * @constructor
- */
-Messages.BaseMessage = function() {
- this.widgets = new Set();
- this._onClickAnchor = this._onClickAnchor.bind(this);
- this._repeatID = { uid: gSequenceId() };
- this.textContent = "";
-};
-
-Messages.BaseMessage.prototype = {
- /**
- * Reference to the ConsoleOutput owner.
- *
- * @type object|null
- * This is |null| if the message is not yet initialized.
- */
- output: null,
-
- /**
- * Reference to the parent message object, if this message is in a group or if
- * it is otherwise owned by another message.
- *
- * @type object|null
- */
- parent: null,
-
- /**
- * Message DOM element.
- *
- * @type DOMElement|null
- * This is |null| if the message is not yet rendered.
- */
- element: null,
-
- /**
- * Tells if this message is visible or not.
- * @type boolean
- */
- get visible() {
- return this.element && this.element.parentNode;
- },
-
- /**
- * The owner DOM document.
- * @type DOMElement
- */
- get document() {
- return this.output.document;
- },
-
- /**
- * Holds the text-only representation of the message.
- * @type string
- */
- textContent: null,
-
- /**
- * Set of widgets included in this message.
- * @type Set
- */
- widgets: null,
-
- // Properties that allow compatibility with the current Web Console output
- // implementation.
- _categoryCompat: null,
- _severityCompat: null,
- _categoryNameCompat: null,
- _severityNameCompat: null,
- _filterKeyCompat: null,
-
- /**
- * Object that is JSON-ified and used as a non-unique ID for tracking
- * duplicate messages.
- * @private
- * @type object
- */
- _repeatID: null,
-
- /**
- * Initialize the message.
- *
- * @param object output
- * The ConsoleOutput owner.
- * @param object [parent=null]
- * Optional: a different message object that owns this instance.
- * @return this
- */
- init: function(output, parent = null) {
- this.output = output;
- this.parent = parent;
- return this;
- },
-
- /**
- * Non-unique ID for this message object used for tracking duplicate messages.
- * Different message kinds can identify themselves based their own criteria.
- *
- * @return string
- */
- getRepeatID: function() {
- return JSON.stringify(this._repeatID);
- },
-
- /**
- * Render the message. After this method is invoked the |element| property
- * will point to the DOM element of this message.
- * @return this
- */
- render: function() {
- if (!this.element) {
- this.element = this._renderCompat();
- }
- return this;
- },
-
- /**
- * Prepare the message container for the Web Console, such that it is
- * compatible with the current implementation.
- * TODO: remove this once bug 778766 is fixed.
- *
- * @private
- * @return Element
- * The DOM element that wraps the message.
- */
- _renderCompat: function() {
- let doc = this.output.document;
- let container = doc.createElementNS(XHTML_NS, "div");
- container.id = "console-msg-" + gSequenceId();
- container.className = "message";
- if (this.category == "input") {
- // Assistive technology tools shouldn't echo input to the user,
- // as the user knows what they've just typed.
- container.setAttribute("aria-live", "off");
- }
- container.category = this._categoryCompat;
- container.severity = this._severityCompat;
- container.setAttribute("category", this._categoryNameCompat);
- container.setAttribute("severity", this._severityNameCompat);
- container.setAttribute("filter", this._filterKeyCompat);
- container.clipboardText = this.textContent;
- container.timestamp = this.timestamp;
- container._messageObject = this;
-
- return container;
- },
-
- /**
- * Add a click callback to a given DOM element.
- *
- * @private
- * @param Element element
- * The DOM element to which you want to add a click event handler.
- * @param function [callback=this._onClickAnchor]
- * Optional click event handler. The default event handler is
- * |this._onClickAnchor|.
- */
- _addLinkCallback: function(element, callback = this._onClickAnchor) {
- // This is going into the WebConsoleFrame object instance that owns
- // the ConsoleOutput object. The WebConsoleFrame owner is the WebConsole
- // object instance from hudservice.js.
- // TODO: move _addMessageLinkCallback() into ConsoleOutput once bug 778766
- // is fixed.
- this.output.owner._addMessageLinkCallback(element, callback);
- },
-
- /**
- * The default |click| event handler for links in the output. This function
- * opens the anchor's link in a new tab.
- *
- * @private
- * @param Event event
- * The DOM event that invoked this function.
- */
- _onClickAnchor: function(event) {
- this.output.openLink(event.target.href);
- },
-
- destroy: function() {
- // Destroy all widgets that have registered themselves in this.widgets
- for (let widget of this.widgets) {
- widget.destroy();
- }
- this.widgets.clear();
- }
-};
-
-/**
- * The NavigationMarker is used to show a page load event.
- *
- * @constructor
- * @extends Messages.BaseMessage
- * @param object response
- * The response received from the back end.
- * @param number timestamp
- * The message date and time, milliseconds elapsed since 1 January 1970
- * 00:00:00 UTC.
- */
-Messages.NavigationMarker = function(response, timestamp) {
- Messages.BaseMessage.call(this);
-
- // Store the response packet received from the server. It might
- // be useful for extensions customizing the console output.
- this.response = response;
- this._url = response.url;
- this.textContent = "------ " + this._url;
- this.timestamp = timestamp;
-};
-
-Messages.NavigationMarker.prototype = extend(Messages.BaseMessage.prototype, {
- /**
- * The address of the loading page.
- * @private
- * @type string
- */
- _url: null,
-
- /**
- * Message timestamp.
- *
- * @type number
- * Milliseconds elapsed since 1 January 1970 00:00:00 UTC.
- */
- timestamp: 0,
-
- _categoryCompat: COMPAT.CATEGORIES.NETWORK,
- _severityCompat: COMPAT.SEVERITIES.LOG,
- _categoryNameCompat: "network",
- _severityNameCompat: "info",
- _filterKeyCompat: "networkinfo",
-
- /**
- * Prepare the DOM element for this message.
- * @return this
- */
- render: function() {
- if (this.element) {
- return this;
- }
-
- let url = this._url;
- let pos = url.indexOf("?");
- if (pos > -1) {
- url = url.substr(0, pos);
- }
-
- let doc = this.output.document;
- let urlnode = doc.createElementNS(XHTML_NS, "a");
- urlnode.className = "url";
- urlnode.textContent = url;
- urlnode.title = this._url;
- urlnode.href = this._url;
- urlnode.draggable = false;
- this._addLinkCallback(urlnode);
-
- let render = Messages.BaseMessage.prototype.render.bind(this);
- render().element.appendChild(urlnode);
- this.element.classList.add("navigation-marker");
- this.element.url = this._url;
- this.element.appendChild(doc.createTextNode("\n"));
-
- return this;
- },
-});
-
-/**
- * The Simple message is used to show any basic message in the Web Console.
- *
- * @constructor
- * @extends Messages.BaseMessage
- * @param string|Node|function message
- * The message to display.
- * @param object [options]
- * Options for this message:
- * - category: (string) category that this message belongs to. Defaults
- * to no category.
- * - severity: (string) severity of the message. Defaults to no severity.
- * - timestamp: (number) date and time when the message was recorded.
- * Defaults to |Date.now()|.
- * - link: (string) if provided, the message will be wrapped in an anchor
- * pointing to the given URL here.
- * - linkCallback: (function) if provided, the message will be wrapped in
- * an anchor. The |linkCallback| function will be added as click event
- * handler.
- * - location: object that tells the message source: url, line, column
- * and lineText.
- * - stack: array that tells the message source stack.
- * - className: (string) additional element class names for styling
- * purposes.
- * - private: (boolean) mark this as a private message.
- * - filterDuplicates: (boolean) true if you do want this message to be
- * filtered as a potential duplicate message, false otherwise.
- */
-Messages.Simple = function(message, options = {}) {
- Messages.BaseMessage.call(this);
-
- this.category = options.category;
- this.severity = options.severity;
- this.location = options.location;
- this.stack = options.stack;
- this.timestamp = options.timestamp || Date.now();
- this.prefix = options.prefix;
- this.private = !!options.private;
-
- this._message = message;
- this._className = options.className;
- this._link = options.link;
- this._linkCallback = options.linkCallback;
- this._filterDuplicates = options.filterDuplicates;
-
- this._onClickCollapsible = this._onClickCollapsible.bind(this);
-};
-
-Messages.Simple.prototype = extend(Messages.BaseMessage.prototype, {
- /**
- * Message category.
- * @type string
- */
- category: null,
-
- /**
- * Message severity.
- * @type string
- */
- severity: null,
-
- /**
- * Message source location. Properties: url, line, column, lineText.
- * @type object
- */
- location: null,
-
- /**
- * Holds the stackframes received from the server.
- *
- * @private
- * @type array
- */
- stack: null,
-
- /**
- * Message prefix
- * @type string|null
- */
- prefix: null,
-
- /**
- * Tells if this message comes from a private browsing context.
- * @type boolean
- */
- private: false,
-
- /**
- * Custom class name for the DOM element of the message.
- * @private
- * @type string
- */
- _className: null,
-
- /**
- * Message link - if this message is clicked then this URL opens in a new tab.
- * @private
- * @type string
- */
- _link: null,
-
- /**
- * Message click event handler.
- * @private
- * @type function
- */
- _linkCallback: null,
-
- /**
- * Tells if this message should be checked if it is a duplicate of another
- * message or not.
- */
- _filterDuplicates: false,
-
- /**
- * The raw message displayed by this Message object. This can be a function,
- * DOM node or a string.
- *
- * @private
- * @type mixed
- */
- _message: null,
-
- /**
- * The message's "attachment" element to be displayed under the message.
- * Used for things like stack traces or tables in console.table().
- *
- * @private
- * @type DOMElement|null
- */
- _attachment: null,
-
- _objectActors: null,
- _groupDepthCompat: 0,
-
- /**
- * Message timestamp.
- *
- * @type number
- * Milliseconds elapsed since 1 January 1970 00:00:00 UTC.
- */
- timestamp: 0,
-
- get _categoryCompat() {
- return this.category ?
- COMPAT.CATEGORIES[this.category.toUpperCase()] : null;
- },
- get _severityCompat() {
- return this.severity ?
- COMPAT.SEVERITIES[this.severity.toUpperCase()] : null;
- },
- get _categoryNameCompat() {
- return this.category ?
- COMPAT.CATEGORY_CLASS_FRAGMENTS[this._categoryCompat] : null;
- },
- get _severityNameCompat() {
- return this.severity ?
- COMPAT.SEVERITY_CLASS_FRAGMENTS[this._severityCompat] : null;
- },
-
- get _filterKeyCompat() {
- return this._categoryCompat !== null && this._severityCompat !== null ?
- COMPAT.PREFERENCE_KEYS[this._categoryCompat][this._severityCompat] :
- null;
- },
-
- init: function() {
- Messages.BaseMessage.prototype.init.apply(this, arguments);
- this._groupDepthCompat = this.output.owner.groupDepth;
- this._initRepeatID();
- return this;
- },
-
- /**
- * Tells if the message can be expanded/collapsed.
- * @type boolean
- */
- collapsible: false,
-
- /**
- * Getter that tells if this message is collapsed - no details are shown.
- * @type boolean
- */
- get collapsed() {
- return this.collapsible && this.element && !this.element.hasAttribute("open");
- },
-
- _initRepeatID: function() {
- if (!this._filterDuplicates) {
- return;
- }
-
- // Add the properties we care about for identifying duplicate messages.
- let rid = this._repeatID;
- delete rid.uid;
-
- rid.category = this.category;
- rid.severity = this.severity;
- rid.prefix = this.prefix;
- rid.private = this.private;
- rid.location = this.location;
- rid.link = this._link;
- rid.linkCallback = this._linkCallback + "";
- rid.className = this._className;
- rid.groupDepth = this._groupDepthCompat;
- rid.textContent = "";
- },
-
- getRepeatID: function() {
- // No point in returning a string that includes other properties when there
- // is a unique ID.
- if (this._repeatID.uid) {
- return JSON.stringify({ uid: this._repeatID.uid });
- }
-
- return JSON.stringify(this._repeatID);
- },
-
- render: function() {
- if (this.element) {
- return this;
- }
-
- let timestamp = new Widgets.MessageTimestamp(this, this.timestamp).render();
-
- let icon = this.document.createElementNS(XHTML_NS, "span");
- icon.className = "icon";
- icon.title = l10n.getStr("severity." + this._severityNameCompat);
- if (this.stack) {
- icon.addEventListener("click", this._onClickCollapsible);
- }
-
- let prefixNode;
- if (this.prefix) {
- prefixNode = this.document.createElementNS(XHTML_NS, "span");
- prefixNode.className = "prefix devtools-monospace";
- prefixNode.textContent = this.prefix + ":";
- }
-
- // Apply the current group by indenting appropriately.
- // TODO: remove this once bug 778766 is fixed.
- let indent = this._groupDepthCompat * COMPAT.GROUP_INDENT;
- let indentNode = this.document.createElementNS(XHTML_NS, "span");
- indentNode.className = "indent";
- indentNode.style.width = indent + "px";
-
- let body = this._renderBody();
-
- Messages.BaseMessage.prototype.render.call(this);
- if (this._className) {
- this.element.className += " " + this._className;
- }
-
- this.element.appendChild(timestamp.element);
- this.element.appendChild(indentNode);
- this.element.appendChild(icon);
- if (prefixNode) {
- this.element.appendChild(prefixNode);
- }
-
- if (this.stack) {
- let twisty = this.document.createElementNS(XHTML_NS, "a");
- twisty.className = "theme-twisty";
- twisty.href = "#";
- twisty.title = l10n.getStr("messageToggleDetails");
- twisty.addEventListener("click", this._onClickCollapsible);
- this.element.appendChild(twisty);
- this.collapsible = true;
- this.element.setAttribute("collapsible", true);
- }
-
- this.element.appendChild(body);
-
- this.element.clipboardText = this.element.textContent;
-
- if (this.private) {
- this.element.setAttribute("private", true);
- }
-
- // TODO: handle object releasing in a more elegant way once all console
- // messages use the new API - bug 778766.
- this.element._objectActors = this._objectActors;
- this._objectActors = null;
-
- return this;
- },
-
- /**
- * Render the message body DOM element.
- * @private
- * @return Element
- */
- _renderBody: function() {
- let bodyWrapper = this.document.createElementNS(XHTML_NS, "span");
- bodyWrapper.className = "message-body-wrapper";
-
- let bodyFlex = this.document.createElementNS(XHTML_NS, "span");
- bodyFlex.className = "message-flex-body";
- bodyWrapper.appendChild(bodyFlex);
-
- let body = this.document.createElementNS(XHTML_NS, "span");
- body.className = "message-body devtools-monospace";
- bodyFlex.appendChild(body);
-
- let anchor, container = body;
- if (this._link || this._linkCallback) {
- container = anchor = this.document.createElementNS(XHTML_NS, "a");
- anchor.href = this._link || "#";
- anchor.draggable = false;
- this._addLinkCallback(anchor, this._linkCallback);
- body.appendChild(anchor);
- }
-
- if (typeof this._message == "function") {
- container.appendChild(this._message(this));
- } else if (this._message instanceof Ci.nsIDOMNode) {
- container.appendChild(this._message);
- } else {
- container.textContent = this._message;
- }
-
- // do this before repeatNode is rendered - it has no effect afterwards
- this._repeatID.textContent += "|" + container.textContent;
-
- let repeatNode = this._renderRepeatNode();
- let location = this._renderLocation();
-
- if (repeatNode) {
- bodyFlex.appendChild(this.document.createTextNode(" "));
- bodyFlex.appendChild(repeatNode);
- }
- if (location) {
- bodyFlex.appendChild(this.document.createTextNode(" "));
- bodyFlex.appendChild(location);
- }
-
- bodyFlex.appendChild(this.document.createTextNode("\n"));
-
- if (this.stack) {
- this._attachment = new Widgets.Stacktrace(this, this.stack).render().element;
- }
-
- if (this._attachment) {
- bodyWrapper.appendChild(this._attachment);
- }
-
- return bodyWrapper;
- },
-
- /**
- * Render the repeat bubble DOM element part of the message.
- * @private
- * @return Element
- */
- _renderRepeatNode: function() {
- if (!this._filterDuplicates) {
- return null;
- }
-
- let repeatNode = this.document.createElementNS(XHTML_NS, "span");
- repeatNode.setAttribute("value", "1");
- repeatNode.className = "message-repeats";
- repeatNode.textContent = 1;
- repeatNode._uid = this.getRepeatID();
- return repeatNode;
- },
-
- /**
- * Render the message source location DOM element.
- * @private
- * @return Element
- */
- _renderLocation: function() {
- if (!this.location) {
- return null;
- }
-
- let {url, line, column} = this.location;
- if (IGNORED_SOURCE_URLS.includes(url)) {
- return null;
- }
-
- // The ConsoleOutput owner is a WebConsoleFrame instance from webconsole.js.
- // TODO: move createLocationNode() into this file when bug 778766 is fixed.
- return this.output.owner.createLocationNode({url, line, column });
- },
-
- /**
- * The click event handler for the message expander arrow element. This method
- * toggles the display of message details.
- *
- * @private
- * @param nsIDOMEvent ev
- * The DOM event object.
- * @see this.toggleDetails()
- */
- _onClickCollapsible: function(ev) {
- ev.preventDefault();
- this.toggleDetails();
- },
-
- /**
- * Expand/collapse message details.
- */
- toggleDetails: function() {
- let twisty = this.element.querySelector(".theme-twisty");
- if (this.element.hasAttribute("open")) {
- this.element.removeAttribute("open");
- twisty.removeAttribute("open");
- } else {
- this.element.setAttribute("open", true);
- twisty.setAttribute("open", true);
- }
- },
-}); // Messages.Simple.prototype
-
-/**
- * The Extended message.
- *
- * @constructor
- * @extends Messages.Simple
- * @param array messagePieces
- * The message to display given as an array of elements. Each array
- * element can be a DOM node, function, ObjectActor, LongString or
- * a string.
- * @param object [options]
- * Options for rendering this message:
- * - quoteStrings: boolean that tells if you want strings to be wrapped
- * in quotes or not.
- */
-Messages.Extended = function(messagePieces, options = {}) {
- Messages.Simple.call(this, null, options);
-
- this._messagePieces = messagePieces;
-
- if ("quoteStrings" in options) {
- this._quoteStrings = options.quoteStrings;
- }
-
- this._repeatID.quoteStrings = this._quoteStrings;
- this._repeatID.messagePieces = JSON.stringify(messagePieces);
- this._repeatID.actors = new Set(); // using a set to avoid duplicates
-};
-
-Messages.Extended.prototype = extend(Messages.Simple.prototype, {
- /**
- * The message pieces displayed by this message instance.
- * @private
- * @type array
- */
- _messagePieces: null,
-
- /**
- * Boolean that tells if the strings displayed in this message are wrapped.
- * @private
- * @type boolean
- */
- _quoteStrings: true,
-
- getRepeatID: function() {
- if (this._repeatID.uid) {
- return JSON.stringify({ uid: this._repeatID.uid });
- }
-
- // Sets are not stringified correctly. Temporarily switching to an array.
- let actors = this._repeatID.actors;
- this._repeatID.actors = [...actors];
- let result = JSON.stringify(this._repeatID);
- this._repeatID.actors = actors;
- return result;
- },
-
- render: function() {
- let result = this.document.createDocumentFragment();
-
- for (let i = 0; i < this._messagePieces.length; i++) {
- let separator = i > 0 ? this._renderBodyPieceSeparator() : null;
- if (separator) {
- result.appendChild(separator);
- }
-
- let piece = this._messagePieces[i];
- result.appendChild(this._renderBodyPiece(piece));
- }
-
- this._message = result;
- this._messagePieces = null;
- return Messages.Simple.prototype.render.call(this);
- },
-
- /**
- * Render the separator between the pieces of the message.
- *
- * @private
- * @return Element
- */
- _renderBodyPieceSeparator: function() {
- return null;
- },
-
- /**
- * Render one piece/element of the message array.
- *
- * @private
- * @param mixed piece
- * Message element to display - this can be a LongString, ObjectActor,
- * DOM node or a function to invoke.
- * @return Element
- */
- _renderBodyPiece: function(piece, options = {}) {
- if (piece instanceof Ci.nsIDOMNode) {
- return piece;
- }
- if (typeof piece == "function") {
- return piece(this);
- }
-
- return this._renderValueGrip(piece, options);
- },
-
- /**
- * Render a grip that represents a value received from the server. This method
- * picks the appropriate widget to render the value with.
- *
- * @private
- * @param object grip
- * The value grip received from the server.
- * @param object options
- * Options for displaying the value. Available options:
- * - noStringQuotes - boolean that tells the renderer to not use quotes
- * around strings.
- * - concise - boolean that tells the renderer to compactly display the
- * grip. This is typically set to true when the object needs to be
- * displayed in an array preview, or as a property value in object
- * previews, etc.
- * - shorten - boolean that tells the renderer to display a truncated
- * grip.
- * @return DOMElement
- * The DOM element that displays the given grip.
- */
- _renderValueGrip: function(grip, options = {}) {
- let isPrimitive = VariablesView.isPrimitive({ value: grip });
- let isActorGrip = WebConsoleUtils.isActorGrip(grip);
- let noStringQuotes = !this._quoteStrings;
- if ("noStringQuotes" in options) {
- noStringQuotes = options.noStringQuotes;
- }
-
- if (isActorGrip) {
- this._repeatID.actors.add(grip.actor);
-
- if (!isPrimitive) {
- return this._renderObjectActor(grip, options);
- }
- if (grip.type == "longString") {
- let widget = new Widgets.LongString(this, grip, options).render();
- return widget.element;
- }
- }
-
- let unshortenedGrip = grip;
- if (options.shorten) {
- grip = this.shortenValueGrip(grip);
- }
-
- let result = this.document.createElementNS(XHTML_NS, "span");
- if (isPrimitive) {
- if (Widgets.URLString.prototype.containsURL(grip)) {
- let widget = new Widgets.URLString(this, grip, unshortenedGrip).render();
- return widget.element;
- }
-
- let className = this.getClassNameForValueGrip(grip);
- if (className) {
- result.className = className;
- }
-
- result.textContent = VariablesView.getString(grip, {
- noStringQuotes: noStringQuotes,
- concise: options.concise,
- });
- } else {
- result.textContent = grip;
- }
-
- return result;
- },
-
- /**
- * Shorten grips of the type string, leaves other grips unmodified.
- *
- * @param object grip
- * Value grip from the server.
- * @return object
- * Possible values of object:
- * - A shortened string, if original grip was of string type.
- * - The unmodified input grip, if it wasn't of string type.
- */
- shortenValueGrip: function(grip) {
- let shortVal = grip;
- if (typeof (grip) == "string") {
- shortVal = grip.replace(/(\r\n|\n|\r)/gm, " ");
- if (shortVal.length > MAX_STRING_GRIP_LENGTH) {
- shortVal = shortVal.substring(0, MAX_STRING_GRIP_LENGTH - 1) + ELLIPSIS;
- }
- }
-
- return shortVal;
- },
-
- /**
- * Get a CodeMirror-compatible class name for a given value grip.
- *
- * @param object grip
- * Value grip from the server.
- * @return string
- * The class name for the grip.
- */
- getClassNameForValueGrip: function(grip) {
- let map = {
- "number": "cm-number",
- "longstring": "console-string",
- "string": "console-string",
- "regexp": "cm-string-2",
- "boolean": "cm-atom",
- "-infinity": "cm-atom",
- "infinity": "cm-atom",
- "null": "cm-atom",
- "undefined": "cm-comment",
- "symbol": "cm-atom"
- };
-
- let className = map[typeof grip];
- if (!className && grip && grip.type) {
- className = map[grip.type.toLowerCase()];
- }
- if (!className && grip && grip.class) {
- className = map[grip.class.toLowerCase()];
- }
-
- return className;
- },
-
- /**
- * Display an object actor with the appropriate renderer.
- *
- * @private
- * @param object objectActor
- * The ObjectActor to display.
- * @param object options
- * Options to use for displaying the ObjectActor.
- * @see this._renderValueGrip for the available options.
- * @return DOMElement
- * The DOM element that displays the object actor.
- */
- _renderObjectActor: function(objectActor, options = {}) {
- let Widget = Widgets.ObjectRenderers.byClass[objectActor.class];
-
- let { preview } = objectActor;
- if ((!Widget || (Widget.canRender && !Widget.canRender(objectActor)))
- && preview
- && preview.kind) {
- Widget = Widgets.ObjectRenderers.byKind[preview.kind];
- }
-
- if (!Widget || (Widget.canRender && !Widget.canRender(objectActor))) {
- Widget = Widgets.JSObject;
- }
-
- let instance = new Widget(this, objectActor, options).render();
- return instance.element;
- },
-}); // Messages.Extended.prototype
-
-/**
- * The JavaScriptEvalOutput message.
- *
- * @constructor
- * @extends Messages.Extended
- * @param object evalResponse
- * The evaluation response packet received from the server.
- * @param string [errorMessage]
- * Optional error message to display.
- * @param string [errorDocLink]
- * Optional error doc URL to link to.
- */
-Messages.JavaScriptEvalOutput = function(evalResponse, errorMessage, errorDocLink) {
- let severity = "log", msg, quoteStrings = true;
-
- // Store also the response packet from the back end. It might
- // be useful to extensions customizing the console output.
- this.response = evalResponse;
-
- if (typeof (errorMessage) !== "undefined") {
- severity = "error";
- msg = errorMessage;
- quoteStrings = false;
- } else {
- msg = evalResponse.result;
- }
-
- let options = {
- className: "cm-s-mozilla",
- timestamp: evalResponse.timestamp,
- category: "output",
- severity: severity,
- quoteStrings: quoteStrings,
- };
-
- let messages = [msg];
- if (errorDocLink) {
- messages.push(errorDocLink);
- }
-
- Messages.Extended.call(this, messages, options);
-};
-
-Messages.JavaScriptEvalOutput.prototype = Messages.Extended.prototype;
-
-/**
- * The ConsoleGeneric message is used for console API calls.
- *
- * @constructor
- * @extends Messages.Extended
- * @param object packet
- * The Console API call packet received from the server.
- */
-Messages.ConsoleGeneric = function(packet) {
- let options = {
- className: "cm-s-mozilla",
- timestamp: packet.timeStamp,
- category: packet.category || "webdev",
- severity: CONSOLE_API_LEVELS_TO_SEVERITIES[packet.level],
- prefix: packet.prefix,
- private: packet.private,
- filterDuplicates: true,
- location: {
- url: packet.filename,
- line: packet.lineNumber,
- column: packet.columnNumber
- },
- };
-
- switch (packet.level) {
- case "count": {
- let counter = packet.counter, label = counter.label;
- if (!label) {
- label = l10n.getStr("noCounterLabel");
- }
- Messages.Extended.call(this, [label + ": " + counter.count], options);
- break;
- }
- default:
- Messages.Extended.call(this, packet.arguments, options);
- break;
- }
-
- this._repeatID.consoleApiLevel = packet.level;
- this._repeatID.styles = packet.styles;
- this.stack = this._repeatID.stacktrace = packet.stacktrace;
- this._styles = packet.styles || [];
-};
-
-Messages.ConsoleGeneric.prototype = extend(Messages.Extended.prototype, {
- _styles: null,
-
- _renderBodyPieceSeparator: function() {
- return this.document.createTextNode(" ");
- },
-
- render: function() {
- let result = this.document.createDocumentFragment();
- this._renderBodyPieces(result);
-
- this._message = result;
- this._stacktrace = null;
-
- Messages.Simple.prototype.render.call(this);
-
- return this;
- },
-
- _renderBodyPieces: function(container) {
- let lastStyle = null;
- let stylePieces = this._styles.length > 0 ? this._styles.length : 1;
-
- for (let i = 0; i < this._messagePieces.length; i++) {
- // Pieces with an associated style definition come from "%c" formatting.
- // For body pieces beyond that, add a separator before each one.
- if (i >= stylePieces) {
- container.appendChild(this._renderBodyPieceSeparator());
- }
-
- let piece = this._messagePieces[i];
- let style = this._styles[i];
-
- // No long string support.
- lastStyle = (style && typeof style == "string") ?
- this.cleanupStyle(style) : null;
-
- container.appendChild(this._renderBodyPiece(piece, lastStyle));
- }
-
- this._messagePieces = null;
- this._styles = null;
- },
-
- _renderBodyPiece: function(piece, style) {
- // Skip quotes for top-level strings.
- let options = { noStringQuotes: true };
- let elem = Messages.Extended.prototype._renderBodyPiece.call(this, piece, options);
- let result = elem;
-
- if (style) {
- if (elem.nodeType == nodeConstants.ELEMENT_NODE) {
- elem.style = style;
- } else {
- let span = this.document.createElementNS(XHTML_NS, "span");
- span.style = style;
- span.appendChild(elem);
- result = span;
- }
- }
-
- return result;
- },
-
- /**
- * Given a style attribute value, return a cleaned up version of the string
- * such that:
- *
- * - no external URL is allowed to load. See RE_CLEANUP_STYLES.
- * - only some of the properties are allowed, based on a whitelist. See
- * RE_ALLOWED_STYLES.
- *
- * @param string style
- * The style string to cleanup.
- * @return string
- * The style value after cleanup.
- */
- cleanupStyle: function(style) {
- for (let r of RE_CLEANUP_STYLES) {
- style = style.replace(r, "notallowed");
- }
-
- let dummy = this.output._dummyElement;
- if (!dummy) {
- dummy = this.output._dummyElement =
- this.document.createElementNS(XHTML_NS, "div");
- }
- dummy.style = style;
-
- let toRemove = [];
- for (let i = 0; i < dummy.style.length; i++) {
- let prop = dummy.style[i];
- if (!RE_ALLOWED_STYLES.test(prop)) {
- toRemove.push(prop);
- }
- }
-
- for (let prop of toRemove) {
- dummy.style.removeProperty(prop);
- }
-
- style = dummy.style.cssText;
-
- dummy.style = "";
-
- return style;
- },
-}); // Messages.ConsoleGeneric.prototype
-
-/**
- * The ConsoleTrace message is used for console.trace() calls.
- *
- * @constructor
- * @extends Messages.Simple
- * @param object packet
- * The Console API call packet received from the server.
- */
-Messages.ConsoleTrace = function(packet) {
- let options = {
- className: "cm-s-mozilla",
- timestamp: packet.timeStamp,
- category: packet.category || "webdev",
- severity: CONSOLE_API_LEVELS_TO_SEVERITIES[packet.level],
- private: packet.private,
- filterDuplicates: true,
- location: {
- url: packet.filename,
- line: packet.lineNumber,
- },
- };
-
- Messages.Simple.call(this, null, options);
-
- this._repeatID.consoleApiLevel = packet.level;
- this._stacktrace = this._repeatID.stacktrace = packet.stacktrace;
- this._arguments = packet.arguments;
-};
-
-Messages.ConsoleTrace.prototype = extend(Messages.Simple.prototype, {
- /**
- * Holds the stackframes received from the server.
- *
- * @private
- * @type array
- */
- _stacktrace: null,
-
- /**
- * Holds the arguments the content script passed to the console.trace()
- * method. This array is cleared when the message is initialized, and
- * associated actors are released.
- *
- * @private
- * @type array
- */
- _arguments: null,
-
- init: function() {
- let result = Messages.Simple.prototype.init.apply(this, arguments);
-
- // We ignore console.trace() arguments. Release object actors.
- if (Array.isArray(this._arguments)) {
- for (let arg of this._arguments) {
- if (WebConsoleUtils.isActorGrip(arg)) {
- this.output._releaseObject(arg.actor);
- }
- }
- }
- this._arguments = null;
-
- return result;
- },
-
- render: function() {
- this._message = this._renderMessage();
- this._attachment = this._renderStack();
-
- Messages.Simple.prototype.render.apply(this, arguments);
- this.element.setAttribute("open", true);
- return this;
- },
-
- /**
- * Render the console messageNode
- */
- _renderMessage: function() {
- let cmvar = this.document.createElementNS(XHTML_NS, "span");
- cmvar.className = "cm-variable";
- cmvar.textContent = "console";
-
- let cmprop = this.document.createElementNS(XHTML_NS, "span");
- cmprop.className = "cm-property";
- cmprop.textContent = "trace";
-
- let frag = this.document.createDocumentFragment();
- frag.appendChild(cmvar);
- frag.appendChild(this.document.createTextNode("."));
- frag.appendChild(cmprop);
- frag.appendChild(this.document.createTextNode("():"));
-
- return frag;
- },
-
- /**
- * Render the stack frames.
- *
- * @private
- * @return DOMElement
- */
- _renderStack: function() {
- return new Widgets.Stacktrace(this, this._stacktrace).render().element;
- },
-}); // Messages.ConsoleTrace.prototype
-
-/**
- * The ConsoleTable message is used for console.table() calls.
- *
- * @constructor
- * @extends Messages.Extended
- * @param object packet
- * The Console API call packet received from the server.
- */
-Messages.ConsoleTable = function(packet) {
- let options = {
- className: "cm-s-mozilla",
- timestamp: packet.timeStamp,
- category: packet.category || "webdev",
- severity: CONSOLE_API_LEVELS_TO_SEVERITIES[packet.level],
- private: packet.private,
- filterDuplicates: false,
- location: {
- url: packet.filename,
- line: packet.lineNumber,
- },
- };
-
- this._populateTableData = this._populateTableData.bind(this);
- this._renderMessage = this._renderMessage.bind(this);
- Messages.Extended.call(this, [this._renderMessage], options);
-
- this._repeatID.consoleApiLevel = packet.level;
- this._arguments = packet.arguments;
-};
-
-Messages.ConsoleTable.prototype = extend(Messages.Extended.prototype, {
- /**
- * Holds the arguments the content script passed to the console.table()
- * method.
- *
- * @private
- * @type array
- */
- _arguments: null,
-
- /**
- * Array of objects that holds the data to log in the table.
- *
- * @private
- * @type array
- */
- _data: null,
-
- /**
- * Key value pair of the id and display name for the columns in the table.
- * Refer to the TableWidget API.
- *
- * @private
- * @type object
- */
- _columns: null,
-
- /**
- * A promise that resolves when the table data is ready or null if invalid
- * arguments are provided.
- *
- * @private
- * @type promise|null
- */
- _populatePromise: null,
-
- init: function() {
- let result = Messages.Extended.prototype.init.apply(this, arguments);
- this._data = [];
- this._columns = {};
-
- this._populatePromise = this._populateTableData();
-
- return result;
- },
-
- /**
- * Sets the key value pair of the id and display name for the columns in the
- * table.
- *
- * @private
- * @param array|string columns
- * Either a string or array containing the names for the columns in
- * the output table.
- */
- _setColumns: function(columns) {
- if (columns.class == "Array") {
- let items = columns.preview.items;
-
- for (let item of items) {
- if (typeof item == "string") {
- this._columns[item] = item;
- }
- }
- } else if (typeof columns == "string" && columns) {
- this._columns[columns] = columns;
- }
- },
-
- /**
- * Retrieves the table data and columns from the arguments received from the
- * server.
- *
- * @return Promise|null
- * Returns a promise that resolves when the table data is ready or
- * null if the arguments are invalid.
- */
- _populateTableData: function() {
- let deferred = defer();
-
- if (this._arguments.length <= 0) {
- return deferred.reject();
- }
-
- let data = this._arguments[0];
- if (data.class != "Array" && data.class != "Object" &&
- data.class != "Map" && data.class != "Set" &&
- data.class != "WeakMap" && data.class != "WeakSet") {
- return deferred.reject();
- }
-
- let hasColumnsArg = false;
- if (this._arguments.length > 1) {
- if (data.class == "Object" || data.class == "Array") {
- this._columns._index = l10n.getStr("table.index");
- } else {
- this._columns._index = l10n.getStr("table.iterationIndex");
- }
-
- this._setColumns(this._arguments[1]);
- hasColumnsArg = true;
- }
-
- if (data.class == "Object" || data.class == "Array") {
- // Get the object properties, and parse the key and value properties into
- // the table data and columns.
- this.client = new ObjectClient(this.output.owner.jsterm.hud.proxy.client,
- data);
- this.client.getPrototypeAndProperties(response => {
- let {ownProperties} = response;
- let rowCount = 0;
- let columnCount = 0;
-
- for (let index of Object.keys(ownProperties || {})) {
- // Avoid outputting the length property if the data argument provided
- // is an array
- if (data.class == "Array" && index == "length") {
- continue;
- }
-
- if (!hasColumnsArg) {
- this._columns._index = l10n.getStr("table.index");
- }
-
- if (data.class == "Array") {
- if (index == parseInt(index, 10)) {
- index = parseInt(index, 10);
- }
- }
-
- let property = ownProperties[index].value;
- let item = { _index: index };
-
- if (property.class == "Object" || property.class == "Array") {
- let {preview} = property;
- let entries = property.class == "Object" ?
- preview.ownProperties : preview.items;
-
- for (let key of Object.keys(entries)) {
- let value = property.class == "Object" ?
- preview.ownProperties[key].value : preview.items[key];
-
- item[key] = this._renderValueGrip(value, { concise: true });
-
- if (!hasColumnsArg && !(key in this._columns) &&
- (++columnCount <= TABLE_COLUMN_MAX_ITEMS)) {
- this._columns[key] = key;
- }
- }
- } else {
- // Display the value for any non-object data input.
- item._value = this._renderValueGrip(property, { concise: true });
-
- if (!hasColumnsArg && !("_value" in this._columns)) {
- this._columns._value = l10n.getStr("table.value");
- }
- }
-
- this._data.push(item);
-
- if (++rowCount == TABLE_ROW_MAX_ITEMS) {
- break;
- }
- }
-
- deferred.resolve();
- });
- } else if (data.class == "Map" || data.class == "WeakMap") {
- let entries = data.preview.entries;
-
- if (!hasColumnsArg) {
- this._columns._index = l10n.getStr("table.iterationIndex");
- this._columns._key = l10n.getStr("table.key");
- this._columns._value = l10n.getStr("table.value");
- }
-
- let rowCount = 0;
- for (let [key, value] of entries) {
- let item = {
- _index: rowCount,
- _key: this._renderValueGrip(key, { concise: true }),
- _value: this._renderValueGrip(value, { concise: true })
- };
-
- this._data.push(item);
-
- if (++rowCount == TABLE_ROW_MAX_ITEMS) {
- break;
- }
- }
-
- deferred.resolve();
- } else if (data.class == "Set" || data.class == "WeakSet") {
- let entries = data.preview.items;
-
- if (!hasColumnsArg) {
- this._columns._index = l10n.getStr("table.iterationIndex");
- this._columns._value = l10n.getStr("table.value");
- }
-
- let rowCount = 0;
- for (let entry of entries) {
- let item = {
- _index: rowCount,
- _value: this._renderValueGrip(entry, { concise: true })
- };
-
- this._data.push(item);
-
- if (++rowCount == TABLE_ROW_MAX_ITEMS) {
- break;
- }
- }
-
- deferred.resolve();
- }
-
- return deferred.promise;
- },
-
- render: function() {
- this._attachment = this._renderTable();
- Messages.Extended.prototype.render.apply(this, arguments);
- this.element.setAttribute("open", true);
- return this;
- },
-
- _renderMessage: function() {
- let cmvar = this.document.createElementNS(XHTML_NS, "span");
- cmvar.className = "cm-variable";
- cmvar.textContent = "console";
-
- let cmprop = this.document.createElementNS(XHTML_NS, "span");
- cmprop.className = "cm-property";
- cmprop.textContent = "table";
-
- let frag = this.document.createDocumentFragment();
- frag.appendChild(cmvar);
- frag.appendChild(this.document.createTextNode("."));
- frag.appendChild(cmprop);
- frag.appendChild(this.document.createTextNode("():"));
-
- return frag;
- },
-
- /**
- * Render the table.
- *
- * @private
- * @return DOMElement
- */
- _renderTable: function() {
- let result = this.document.createElementNS(XHTML_NS, "div");
-
- if (this._populatePromise) {
- this._populatePromise.then(() => {
- if (this._data.length > 0) {
- let widget = new Widgets.Table(this, this._data, this._columns).render();
- result.appendChild(widget.element);
- }
-
- result.scrollIntoView();
- this.output.owner.emit("messages-table-rendered");
-
- // Release object actors
- if (Array.isArray(this._arguments)) {
- for (let arg of this._arguments) {
- if (WebConsoleUtils.isActorGrip(arg)) {
- this.output._releaseObject(arg.actor);
- }
- }
- }
- this._arguments = null;
- });
- }
-
- return result;
- },
-}); // Messages.ConsoleTable.prototype
-
-var Widgets = {};
-
-/**
- * The base widget class.
- *
- * @constructor
- * @param object message
- * The owning message.
- */
-Widgets.BaseWidget = function(message) {
- this.message = message;
-};
-
-Widgets.BaseWidget.prototype = {
- /**
- * The owning message object.
- * @type object
- */
- message: null,
-
- /**
- * The DOM element of the rendered widget.
- * @type Element
- */
- element: null,
-
- /**
- * Getter for the DOM document that holds the output.
- * @type Document
- */
- get document() {
- return this.message.document;
- },
-
- /**
- * The ConsoleOutput instance that owns this widget instance.
- */
- get output() {
- return this.message.output;
- },
-
- /**
- * Render the widget DOM element.
- * @return this
- */
- render: function() { },
-
- /**
- * Destroy this widget instance.
- */
- destroy: function() { },
-
- /**
- * Helper for creating DOM elements for widgets.
- *
- * Usage:
- * this.el("tag#id.class.names"); // create element "tag" with ID "id" and
- * two class names, .class and .names.
- *
- * this.el("span", { attr1: "value1", ... }) // second argument can be an
- * object that holds element attributes and values for the new DOM element.
- *
- * this.el("p", { attr1: "value1", ... }, "text content"); // the third
- * argument can include the default .textContent of the new DOM element.
- *
- * this.el("p", "text content"); // if the second argument is not an object,
- * it will be used as .textContent for the new DOM element.
- *
- * @param string tagNameIdAndClasses
- * Tag name for the new element, optionally followed by an ID and/or
- * class names. Examples: "span", "div#fooId", "div.class.names",
- * "p#id.class".
- * @param string|object [attributesOrTextContent]
- * If this argument is an object it will be used to set the attributes
- * of the new DOM element. Otherwise, the value becomes the
- * .textContent of the new DOM element.
- * @param string [textContent]
- * If this argument is provided the value is used as the textContent of
- * the new DOM element.
- * @return DOMElement
- * The new DOM element.
- */
- el: function(tagNameIdAndClasses) {
- let attrs, text;
- if (typeof arguments[1] == "object") {
- attrs = arguments[1];
- text = arguments[2];
- } else {
- text = arguments[1];
- }
-
- let tagName = tagNameIdAndClasses.split(/#|\./)[0];
-
- let elem = this.document.createElementNS(XHTML_NS, tagName);
- for (let name of Object.keys(attrs || {})) {
- elem.setAttribute(name, attrs[name]);
- }
- if (text !== undefined && text !== null) {
- elem.textContent = text;
- }
-
- let idAndClasses = tagNameIdAndClasses.match(/([#.][^#.]+)/g);
- for (let idOrClass of (idAndClasses || [])) {
- if (idOrClass.charAt(0) == "#") {
- elem.id = idOrClass.substr(1);
- } else {
- elem.classList.add(idOrClass.substr(1));
- }
- }
-
- return elem;
- },
-};
-
-/**
- * The timestamp widget.
- *
- * @constructor
- * @param object message
- * The owning message.
- * @param number timestamp
- * The UNIX timestamp to display.
- */
-Widgets.MessageTimestamp = function(message, timestamp) {
- Widgets.BaseWidget.call(this, message);
- this.timestamp = timestamp;
-};
-
-Widgets.MessageTimestamp.prototype = extend(Widgets.BaseWidget.prototype, {
- /**
- * The UNIX timestamp.
- * @type number
- */
- timestamp: 0,
-
- render: function() {
- if (this.element) {
- return this;
- }
-
- this.element = this.document.createElementNS(XHTML_NS, "span");
- this.element.className = "timestamp devtools-monospace";
- this.element.textContent = l10n.timestampString(this.timestamp) + " ";
-
- return this;
- },
-}); // Widgets.MessageTimestamp.prototype
-
-/**
- * The URLString widget, for rendering strings where at least one token is a
- * URL.
- *
- * @constructor
- * @param object message
- * The owning message.
- * @param string str
- * The string, which contains at least one valid URL.
- * @param string unshortenedStr
- * The unshortened form of the string, if it was shortened.
- */
-Widgets.URLString = function(message, str, unshortenedStr) {
- Widgets.BaseWidget.call(this, message);
- this.str = str;
- this.unshortenedStr = unshortenedStr;
-};
-
-Widgets.URLString.prototype = extend(Widgets.BaseWidget.prototype, {
- /**
- * The string to format, which contains at least one valid URL.
- * @type string
- */
- str: "",
-
- render: function() {
- if (this.element) {
- return this;
- }
-
- // The rendered URLString will be a <span> containing a number of text
- // <spans> for non-URL tokens and <a>'s for URL tokens.
- this.element = this.el("span", {
- class: "console-string"
- });
- this.element.appendChild(this._renderText("\""));
-
- // As we walk through the tokens of the source string, we make sure to preserve
- // the original whitespace that separated the tokens.
- let tokens = this.str.split(/\s+/);
- let textStart = 0;
- let tokenStart;
- for (let i = 0; i < tokens.length; i++) {
- let token = tokens[i];
- let unshortenedToken;
- tokenStart = this.str.indexOf(token, textStart);
- if (this._isURL(token)) {
- // The last URL in the string might be shortened. If so, get the
- // real URL so the rendered link can point to it.
- if (i === tokens.length - 1 && this.unshortenedStr) {
- unshortenedToken = this.unshortenedStr.slice(tokenStart).split(/\s+/, 1)[0];
- }
- this.element.appendChild(this._renderText(this.str.slice(textStart, tokenStart)));
- textStart = tokenStart + token.length;
- this.element.appendChild(this._renderURL(token, unshortenedToken));
- }
- }
-
- // Clean up any non-URL text at the end of the source string.
- const rendered = this._renderText(this.str.slice(textStart, this.str.length));
- this.element.appendChild(rendered);
- this.element.appendChild(this._renderText("\""));
-
- return this;
- },
-
- /**
- * Determines whether a grip is a string containing a URL.
- *
- * @param string grip
- * The grip, which may contain a URL.
- * @return boolean
- * Whether the grip is a string containing a URL.
- */
- containsURL: function(grip) {
- if (typeof grip != "string") {
- return false;
- }
-
- let tokens = grip.split(/\s+/);
- return tokens.some(this._isURL);
- },
-
- /**
- * Determines whether a string token is a valid URL.
- *
- * @param string token
- * The token.
- * @return boolean
- * Whenther the token is a URL.
- */
- _isURL: function(token) {
- try {
- if (!validProtocols.test(token)) {
- return false;
- }
- new URL(token);
- return true;
- } catch (e) {
- return false;
- }
- },
-
- /**
- * Renders a string as a URL.
- *
- * @param string url
- * The string to be rendered as a url.
- * @param string fullUrl
- * The unshortened form of the URL, if it was shortened.
- * @return DOMElement
- * An element containing the rendered string.
- */
- _renderURL: function(url, fullUrl) {
- let unshortened = fullUrl || url;
- let result = this.el("a", {
- class: "url",
- title: unshortened,
- href: unshortened,
- draggable: false
- }, url);
- this.message._addLinkCallback(result);
- return result;
- },
-
- _renderText: function(text) {
- return this.el("span", text);
- },
-}); // Widgets.URLString.prototype
-
-/**
- * Widget used for displaying ObjectActors that have no specialised renderers.
- *
- * @constructor
- * @param object message
- * The owning message.
- * @param object objectActor
- * The ObjectActor to display.
- * @param object [options]
- * Options for displaying the given ObjectActor. See
- * Messages.Extended.prototype._renderValueGrip for the available
- * options.
- */
-Widgets.JSObject = function(message, objectActor, options = {}) {
- Widgets.BaseWidget.call(this, message);
- this.objectActor = objectActor;
- this.options = options;
- this._onClick = this._onClick.bind(this);
-};
-
-Widgets.JSObject.prototype = extend(Widgets.BaseWidget.prototype, {
- /**
- * The ObjectActor displayed by the widget.
- * @type object
- */
- objectActor: null,
-
- render: function() {
- if (!this.element) {
- this._render();
- }
-
- return this;
- },
-
- _render: function() {
- let str = VariablesView.getString(this.objectActor, this.options);
- let className = this.message.getClassNameForValueGrip(this.objectActor);
- if (!className && this.objectActor.class == "Object") {
- className = "cm-variable";
- }
-
- this.element = this._anchor(str, { className: className });
- },
-
- /**
- * Render a concise representation of an object.
- */
- _renderConciseObject: function() {
- this.element = this._anchor(this.objectActor.class,
- { className: "cm-variable" });
- },
-
- /**
- * Render the `<class> { ` prefix of an object.
- */
- _renderObjectPrefix: function() {
- let { kind } = this.objectActor.preview;
- this.element = this.el("span.kind-" + kind);
- this._anchor(this.objectActor.class, { className: "cm-variable" });
- this._text(" { ");
- },
-
- /**
- * Render the ` }` suffix of an object.
- */
- _renderObjectSuffix: function() {
- this._text(" }");
- },
-
- /**
- * Render an object property.
- *
- * @param String key
- * The property name.
- * @param Object value
- * The property value, as an RDP grip.
- * @param nsIDOMNode container
- * The container node to render to.
- * @param Boolean needsComma
- * True if there was another property before this one and we need to
- * separate them with a comma.
- * @param Boolean valueIsText
- * Add the value as is, don't treat it as a grip and pass it to
- * `_renderValueGrip`.
- */
- _renderObjectProperty: function(
- key,
- value,
- container,
- needsComma,
- valueIsText = false
- ) {
- if (needsComma) {
- this._text(", ");
- }
-
- container.appendChild(this.el("span.cm-property", key));
- this._text(": ");
-
- if (valueIsText) {
- this._text(value);
- } else {
- let valueElem = this.message._renderValueGrip(value, {
- concise: true,
- shorten: true
- });
- container.appendChild(valueElem);
- }
- },
-
- /**
- * Render this object's properties.
- *
- * @param nsIDOMNode container
- * The container node to render to.
- * @param Boolean needsComma
- * True if there was another property before this one and we need to
- * separate them with a comma.
- */
- _renderObjectProperties: function(container, needsComma) {
- let { preview } = this.objectActor;
- let { ownProperties, safeGetterValues } = preview;
-
- let shown = 0;
-
- let getValue = desc => {
- if (desc.get) {
- return "Getter";
- } else if (desc.set) {
- return "Setter";
- }
- return desc.value;
- };
-
- for (let key of Object.keys(ownProperties || {})) {
- this._renderObjectProperty(key, getValue(ownProperties[key]), container,
- shown > 0 || needsComma,
- ownProperties[key].get || ownProperties[key].set);
- shown++;
- }
-
- let ownPropertiesShown = shown;
-
- for (let key of Object.keys(safeGetterValues || {})) {
- this._renderObjectProperty(key, safeGetterValues[key].getterValue,
- container, shown > 0 || needsComma);
- shown++;
- }
-
- if (typeof preview.ownPropertiesLength == "number" &&
- ownPropertiesShown < preview.ownPropertiesLength) {
- this._text(", ");
-
- let n = preview.ownPropertiesLength - ownPropertiesShown;
- let str = VariablesView.stringifiers._getNMoreString(n);
- this._anchor(str);
- }
- },
-
- /**
- * Render an anchor with a given text content and link.
- *
- * @private
- * @param string text
- * Text to show in the anchor.
- * @param object [options]
- * Available options:
- * - onClick (function): "click" event handler.By default a click on
- * the anchor opens the variables view for the current object actor
- * (this.objectActor).
- * - href (string): if given the string is used as a link, and clicks
- * on the anchor open the link in a new tab.
- * - appendTo (DOMElement): append the element to the given DOM
- * element. If not provided, the anchor is appended to |this.element|
- * if it is available. If |appendTo| is provided and if it is a falsy
- * value, the anchor is not appended to any element.
- * @return DOMElement
- * The DOM element of the new anchor.
- */
- _anchor: function(text, options = {}) {
- if (!options.onClick) {
- // If the anchor has an URL, open it in a new tab. If not, show the
- // current object actor.
- options.onClick = options.href ? this._onClickAnchor : this._onClick;
- }
-
- options.onContextMenu = options.onContextMenu || this._onContextMenu;
-
- let anchor = this.el("a", {
- class: options.className,
- draggable: false,
- href: options.href || "#",
- }, text);
-
- this.message._addLinkCallback(anchor, options.onClick);
-
- anchor.addEventListener("contextmenu", options.onContextMenu.bind(this));
-
- if (options.appendTo) {
- options.appendTo.appendChild(anchor);
- } else if (!("appendTo" in options) && this.element) {
- this.element.appendChild(anchor);
- }
-
- return anchor;
- },
-
- openObjectInVariablesView: function() {
- this.output.openVariablesView({
- label: VariablesView.getString(this.objectActor, { concise: true }),
- objectActor: this.objectActor,
- autofocus: true,
- });
- },
-
- storeObjectInWindow: function() {
- let evalString = `{ let i = 0;
- while (this.hasOwnProperty("temp" + i) && i < 1000) {
- i++;
- }
- this["temp" + i] = _self;
- "temp" + i;
- }`;
- let options = {
- selectedObjectActor: this.objectActor.actor,
- };
-
- this.output.owner.jsterm.requestEvaluation(evalString, options).then((res) => {
- this.output.owner.jsterm.focus();
- this.output.owner.jsterm.setInputValue(res.result);
- });
- },
-
- /**
- * The click event handler for objects shown inline.
- * @private
- */
- _onClick: function() {
- this.openObjectInVariablesView();
- },
-
- _onContextMenu: function(ev) {
- // TODO offer a nice API for the context menu.
- // Probably worth to take a look at Firebug's way
- // https://github.com/firebug/firebug/blob/master/extension/content/firebug/chrome/menu.js
- let doc = ev.target.ownerDocument;
- let cmPopup = doc.getElementById("output-contextmenu");
-
- let openInVarViewCmd = doc.getElementById("menu_openInVarView");
- let openVarView = this.openObjectInVariablesView.bind(this);
- openInVarViewCmd.addEventListener("command", openVarView);
- openInVarViewCmd.removeAttribute("disabled");
- cmPopup.addEventListener("popuphiding", function() {
- openInVarViewCmd.removeEventListener("command", openVarView);
- openInVarViewCmd.setAttribute("disabled", "true");
- }, {once: true});
-
- // 'Store as global variable' command isn't supported on pre-44 servers,
- // so remove it from the menu in that case.
- let storeInGlobalCmd = doc.getElementById("menu_storeAsGlobal");
- if (!this.output.webConsoleClient.traits.selectedObjectActor) {
- storeInGlobalCmd.remove();
- } else if (storeInGlobalCmd) {
- let storeObjectInWindow = this.storeObjectInWindow.bind(this);
- storeInGlobalCmd.addEventListener("command", storeObjectInWindow);
- storeInGlobalCmd.removeAttribute("disabled");
- cmPopup.addEventListener("popuphiding", function() {
- storeInGlobalCmd.removeEventListener("command", storeObjectInWindow);
- storeInGlobalCmd.setAttribute("disabled", "true");
- }, {once: true});
- }
- },
-
- /**
- * Add a string to the message.
- *
- * @private
- * @param string str
- * String to add.
- * @param DOMElement [target = this.element]
- * Optional DOM element to append the string to. The default is
- * this.element.
- */
- _text: function(str, target = this.element) {
- target.appendChild(this.document.createTextNode(str));
- },
-}); // Widgets.JSObject.prototype
-
-Widgets.ObjectRenderers = {};
-Widgets.ObjectRenderers.byKind = {};
-Widgets.ObjectRenderers.byClass = {};
-
-/**
- * Add an object renderer.
- *
- * @param object obj
- * An object that represents the renderer. Properties:
- * - byClass (string, optional): this renderer will be used for the given
- * object class.
- * - byKind (string, optional): this renderer will be used for the given
- * object kind.
- * One of byClass or byKind must be provided.
- * - extends (object, optional): the renderer object extends the given
- * object. Default: Widgets.JSObject.
- * - canRender (function, optional): this method is invoked when
- * a candidate object needs to be displayed. The method is invoked as
- * a static method, as such, none of the properties of the renderer
- * object will be available. You get one argument: the object actor grip
- * received from the server. If the method returns true, then this
- * renderer is used for displaying the object, otherwise not.
- * - initialize (function, optional): the constructor of the renderer
- * widget. This function is invoked with the following arguments: the
- * owner message object instance, the object actor grip to display, and
- * an options object. See Messages.Extended.prototype._renderValueGrip()
- * for details about the options object.
- * - render (function, required): the method that displays the given
- * object actor.
- */
-Widgets.ObjectRenderers.add = function(obj) {
- let extendObj = obj.extends || Widgets.JSObject;
-
- let constructor = function() {
- if (obj.initialize) {
- obj.initialize.apply(this, arguments);
- } else {
- extendObj.apply(this, arguments);
- }
- };
-
- let proto = WebConsoleUtils.cloneObject(obj, false, function(key) {
- if (key == "initialize" || key == "canRender" ||
- (key == "render" && extendObj === Widgets.JSObject)) {
- return false;
- }
- return true;
- });
-
- if (extendObj === Widgets.JSObject) {
- proto._render = obj.render;
- }
-
- constructor.canRender = obj.canRender;
- constructor.prototype = extend(extendObj.prototype, proto);
-
- if (obj.byClass) {
- Widgets.ObjectRenderers.byClass[obj.byClass] = constructor;
- } else if (obj.byKind) {
- Widgets.ObjectRenderers.byKind[obj.byKind] = constructor;
- } else {
- throw new Error("You are adding an object renderer without any byClass or " +
- "byKind property.");
- }
-};
-
-/**
- * The widget used for displaying Date objects.
- */
-Widgets.ObjectRenderers.add({
- byClass: "Date",
-
- render: function() {
- let {preview} = this.objectActor;
- this.element = this.el("span.class-" + this.objectActor.class);
-
- let anchorText = this.objectActor.class;
- let anchorClass = "cm-variable";
- if (preview && "timestamp" in preview && typeof preview.timestamp != "number") {
- anchorText = new Date(preview.timestamp).toString(); // invalid date
- anchorClass = "";
- }
-
- this._anchor(anchorText, { className: anchorClass });
-
- if (!preview || !("timestamp" in preview) || typeof preview.timestamp != "number") {
- return;
- }
-
- this._text(" ");
-
- let elem = this.el("span.cm-string-2", new Date(preview.timestamp).toISOString());
- this.element.appendChild(elem);
- },
-});
-
-/**
- * The widget used for displaying Function objects.
- */
-Widgets.ObjectRenderers.add({
- byClass: "Function",
-
- render: function() {
- let grip = this.objectActor;
- this.element = this.el("span.class-" + this.objectActor.class);
-
- // TODO: Bug 948484 - support arrow functions and ES6 generators
- let name = grip.userDisplayName || grip.displayName || grip.name || "";
- name = VariablesView.getString(name, { noStringQuotes: true });
-
- if (this.options.concise) {
- this._anchor(name || "function", {
- className: name ? "cm-variable" : "cm-keyword",
- });
- if (!name) {
- this._text(" ");
- }
- } else if (name) {
- this.element.appendChild(this.el("span.cm-keyword", "function"));
- this._text(" ");
- this._anchor(name, { className: "cm-variable" });
- } else {
- this._anchor("function", { className: "cm-keyword" });
- this._text(" ");
- }
-
- this._text("(");
-
- // TODO: Bug 948489 - Support functions with destructured parameters and
- // rest parameters
- let params = grip.parameterNames || [];
- let shown = 0;
- for (let param of params) {
- if (shown > 0) {
- this._text(", ");
- }
- this.element.appendChild(this.el("span.cm-def", param));
- shown++;
- }
-
- this._text(")");
- },
-
- _onClick: function() {
- let location = this.objectActor.location;
- let url = location && location.url;
- if (url && !IGNORED_SOURCE_URLS.includes(url)) {
- this.output.openLocationInDebugger(location);
- } else {
- this.openObjectInVariablesView();
- }
- }
-}); // Widgets.ObjectRenderers.byClass.Function
-
-/**
- * The widget used for displaying ArrayLike objects.
- */
-Widgets.ObjectRenderers.add({
- byKind: "ArrayLike",
-
- render: function() {
- let {preview} = this.objectActor;
- let {items} = preview;
- this.element = this.el("span.kind-" + preview.kind);
-
- this._anchor(this.objectActor.class, { className: "cm-variable" });
-
- if (!items || this.options.concise) {
- this._text("[");
- this.element.appendChild(this.el("span.cm-number", preview.length));
- this._text("]");
- return this;
- }
-
- this._text(" [ ");
-
- let isFirst = true;
- let emptySlots = 0;
- // A helper that renders a comma between items if isFirst == false.
- let renderSeparator = () => !isFirst && this._text(", ");
-
- for (let item of items) {
- if (item === null) {
- emptySlots++;
- } else {
- renderSeparator();
- isFirst = false;
-
- if (emptySlots) {
- this._renderEmptySlots(emptySlots);
- emptySlots = 0;
- }
-
- let elem = this.message._renderValueGrip(item, { concise: true, shorten: true });
- this.element.appendChild(elem);
- }
- }
-
- if (emptySlots) {
- renderSeparator();
- this._renderEmptySlots(emptySlots, false);
- }
-
- let shown = items.length;
- if (shown < preview.length) {
- this._text(", ");
-
- let n = preview.length - shown;
- let str = VariablesView.stringifiers._getNMoreString(n);
- this._anchor(str);
- }
-
- this._text(" ]");
-
- return this;
- },
-
- _renderEmptySlots: function(numSlots, appendComma = true) {
- let slotLabel = l10n.getStr("emptySlotLabel");
- let slotText = PluralForm.get(numSlots, slotLabel);
- this._text("<" + slotText.replace("#1", numSlots) + ">");
- if (appendComma) {
- this._text(", ");
- }
- },
-
-}); // Widgets.ObjectRenderers.byKind.ArrayLike
-
-/**
- * The widget used for displaying MapLike objects.
- */
-Widgets.ObjectRenderers.add({
- byKind: "MapLike",
-
- render: function() {
- let {preview} = this.objectActor;
- let {entries} = preview;
-
- let container = this.element = this.el("span.kind-" + preview.kind);
- this._anchor(this.objectActor.class, { className: "cm-variable" });
-
- if (!entries || this.options.concise) {
- if (typeof preview.size == "number") {
- this._text("[");
- container.appendChild(this.el("span.cm-number", preview.size));
- this._text("]");
- }
- return;
- }
-
- this._text(" { ");
-
- let shown = 0;
- for (let [key, value] of entries) {
- if (shown > 0) {
- this._text(", ");
- }
-
- let keyElem = this.message._renderValueGrip(key, {
- concise: true,
- noStringQuotes: true,
- });
-
- // Strings are property names.
- if (keyElem.classList && keyElem.classList.contains("console-string")) {
- keyElem.classList.remove("console-string");
- keyElem.classList.add("cm-property");
- }
-
- container.appendChild(keyElem);
-
- this._text(": ");
-
- let valueElem = this.message._renderValueGrip(value, { concise: true });
- container.appendChild(valueElem);
-
- shown++;
- }
-
- if (typeof preview.size == "number" && shown < preview.size) {
- this._text(", ");
-
- let n = preview.size - shown;
- let str = VariablesView.stringifiers._getNMoreString(n);
- this._anchor(str);
- }
-
- this._text(" }");
- },
-}); // Widgets.ObjectRenderers.byKind.MapLike
-
-/**
- * The widget used for displaying objects with a URL.
- */
-Widgets.ObjectRenderers.add({
- byKind: "ObjectWithURL",
-
- render: function() {
- this.element = this._renderElement(this.objectActor,
- this.objectActor.preview.url);
- },
-
- _renderElement: function(objectActor, url) {
- let container = this.el("span.kind-" + objectActor.preview.kind);
-
- this._anchor(objectActor.class, {
- className: "cm-variable",
- appendTo: container,
- });
-
- if (!VariablesView.isFalsy({ value: url })) {
- this._text(" \u2192 ", container);
- let shortUrl = getSourceNames(url)[this.options.concise ? "short" : "long"];
- this._anchor(shortUrl, { href: url, appendTo: container });
- }
-
- return container;
- },
-}); // Widgets.ObjectRenderers.byKind.ObjectWithURL
-
-/**
- * The widget used for displaying objects with a string next to them.
- */
-Widgets.ObjectRenderers.add({
- byKind: "ObjectWithText",
-
- render: function() {
- let {preview} = this.objectActor;
- this.element = this.el("span.kind-" + preview.kind);
-
- this._anchor(this.objectActor.class, { className: "cm-variable" });
-
- if (!this.options.concise) {
- this._text(" ");
- this.element.appendChild(this.el("span.theme-fg-color6",
- VariablesView.getString(preview.text)));
- }
- },
-});
-
-/**
- * The widget used for displaying DOM event previews.
- */
-Widgets.ObjectRenderers.add({
- byKind: "DOMEvent",
-
- render: function() {
- let {preview} = this.objectActor;
-
- let container = this.element = this.el("span.kind-" + preview.kind);
-
- this._anchor(preview.type || this.objectActor.class,
- { className: "cm-variable" });
-
- if (this.options.concise) {
- return;
- }
-
- if (preview.eventKind == "key" && preview.modifiers &&
- preview.modifiers.length) {
- this._text(" ");
-
- let mods = 0;
- for (let mod of preview.modifiers) {
- if (mods > 0) {
- this._text("-");
- }
- container.appendChild(this.el("span.cm-keyword", mod));
- mods++;
- }
- }
-
- this._text(" { ");
-
- let shown = 0;
- if (preview.target) {
- container.appendChild(this.el("span.cm-property", "target"));
- this._text(": ");
- let target = this.message._renderValueGrip(preview.target, { concise: true });
- container.appendChild(target);
- shown++;
- }
-
- for (let key of Object.keys(preview.properties || {})) {
- if (shown > 0) {
- this._text(", ");
- }
-
- container.appendChild(this.el("span.cm-property", key));
- this._text(": ");
-
- let value = preview.properties[key];
- let valueElem = this.message._renderValueGrip(value, { concise: true });
- container.appendChild(valueElem);
-
- shown++;
- }
-
- this._text(" }");
- },
-}); // Widgets.ObjectRenderers.byKind.DOMEvent
-
-/**
- * The widget used for displaying DOM node previews.
- */
-Widgets.ObjectRenderers.add({
- byKind: "DOMNode",
-
- canRender: function(objectActor) {
- let {preview} = objectActor;
- if (!preview) {
- return false;
- }
-
- switch (preview.nodeType) {
- case nodeConstants.DOCUMENT_NODE:
- case nodeConstants.ATTRIBUTE_NODE:
- case nodeConstants.TEXT_NODE:
- case nodeConstants.COMMENT_NODE:
- case nodeConstants.DOCUMENT_FRAGMENT_NODE:
- case nodeConstants.ELEMENT_NODE:
- return true;
- default:
- return false;
- }
- },
-
- render: function() {
- const {preview} = this.objectActor;
-
- switch (preview.nodeType) {
- case nodeConstants.DOCUMENT_NODE:
- this._renderDocumentNode();
- break;
- case nodeConstants.ATTRIBUTE_NODE: {
- this.element = this.el("span.attributeNode.kind-" + preview.kind);
- let attr = this._renderAttributeNode(preview.nodeName, preview.value, true);
- this.element.appendChild(attr);
- break;
- }
- case nodeConstants.TEXT_NODE:
- this._renderTextNode();
- break;
- case nodeConstants.COMMENT_NODE:
- this._renderCommentNode();
- break;
- case nodeConstants.DOCUMENT_FRAGMENT_NODE:
- this._renderDocumentFragmentNode();
- break;
- case nodeConstants.ELEMENT_NODE:
- this._renderElementNode();
- break;
- default:
- throw new Error("Unsupported nodeType: " + preview.nodeType);
- }
- },
-
- _renderDocumentNode: function() {
- let fn =
- Widgets.ObjectRenderers.byKind.ObjectWithURL.prototype._renderElement;
- this.element = fn.call(this, this.objectActor,
- this.objectActor.preview.location);
- this.element.classList.add("documentNode");
- },
-
- _renderAttributeNode: function(nodeName, nodeValue, addLink) {
- let value = VariablesView.getString(nodeValue, { noStringQuotes: true });
-
- let fragment = this.document.createDocumentFragment();
- if (addLink) {
- this._anchor(nodeName, { className: "cm-attribute", appendTo: fragment });
- } else {
- fragment.appendChild(this.el("span.cm-attribute", nodeName));
- }
-
- this._text("=\"", fragment);
- fragment.appendChild(this.el("span.theme-fg-color6", escapeHTML(value)));
- this._text("\"", fragment);
-
- return fragment;
- },
-
- _renderTextNode: function() {
- let {preview} = this.objectActor;
- this.element = this.el("span.textNode.kind-" + preview.kind);
-
- this._anchor(preview.nodeName, { className: "cm-variable" });
- this._text(" ");
-
- let text = VariablesView.getString(preview.textContent);
- this.element.appendChild(this.el("span.console-string", text));
- },
-
- _renderCommentNode: function() {
- let {preview} = this.objectActor;
- let comment = "<!-- " + VariablesView.getString(preview.textContent, {
- noStringQuotes: true,
- }) + " -->";
-
- this.element = this._anchor(comment, {
- className: "kind-" + preview.kind + " commentNode cm-comment",
- });
- },
-
- _renderDocumentFragmentNode: function() {
- let {preview} = this.objectActor;
- let {childNodes} = preview;
- let container = this.element = this.el("span.documentFragmentNode.kind-" +
- preview.kind);
-
- this._anchor(this.objectActor.class, { className: "cm-variable" });
-
- if (!childNodes || this.options.concise) {
- this._text("[");
- container.appendChild(this.el("span.cm-number", preview.childNodesLength));
- this._text("]");
- return;
- }
-
- this._text(" [ ");
-
- let shown = 0;
- for (let item of childNodes) {
- if (shown > 0) {
- this._text(", ");
- }
-
- let elem = this.message._renderValueGrip(item, { concise: true });
- container.appendChild(elem);
- shown++;
- }
-
- if (shown < preview.childNodesLength) {
- this._text(", ");
-
- let n = preview.childNodesLength - shown;
- let str = VariablesView.stringifiers._getNMoreString(n);
- this._anchor(str);
- }
-
- this._text(" ]");
- },
-
- _renderElementNode: function() {
- let {attributes, nodeName} = this.objectActor.preview;
-
- this.element = this.el("span." + "kind-" + this.objectActor.preview.kind +
- ".elementNode");
-
- this._text("<");
- let openTag = this.el("span.cm-tag");
- this.element.appendChild(openTag);
-
- let tagName = this._anchor(nodeName, {
- className: "cm-tag",
- appendTo: openTag
- });
-
- if (this.options.concise) {
- if (attributes.id) {
- tagName.appendChild(this.el("span.cm-attribute", "#" + attributes.id));
- }
- if (attributes.class) {
- const joinedClasses = "." + attributes.class.split(/\s+/g).join(".");
- tagName.appendChild(this.el("span.cm-attribute", joinedClasses));
- }
- } else {
- for (let name of Object.keys(attributes)) {
- let attr = this._renderAttributeNode(" " + name, attributes[name]);
- this.element.appendChild(attr);
- }
- }
-
- this._text(">");
-
- // Register this widget in the owner message so that it gets destroyed when
- // the message is destroyed.
- this.message.widgets.add(this);
-
- this.linkToInspector().catch(console.error);
- },
-
- /**
- * If the DOMNode being rendered can be highlit in the page, this function
- * will attach mouseover/out event listeners to do so, and the inspector icon
- * to open the node in the inspector.
- * @return a promise that resolves when the node has been linked to the
- * inspector, or rejects if it wasn't (either if no toolbox could be found to
- * access the inspector, or if the node isn't present in the inspector, i.e.
- * if the node is in a DocumentFragment or not part of the tree, or not of
- * type nodeConstants.ELEMENT_NODE).
- */
- async linkToInspector() {
- if (this._linkedToInspector) {
- return;
- }
-
- // Checking the node type
- if (this.objectActor.preview.nodeType !== nodeConstants.ELEMENT_NODE) {
- throw new Error("The object cannot be linked to the inspector as it " +
- "isn't an element node");
- }
-
- // Checking the presence of a toolbox
- let target = this.message.output.toolboxTarget;
- this.toolbox = gDevTools.getToolbox(target);
- if (!this.toolbox) {
- // In cases like the browser console, there is no toolbox.
- return;
- }
-
- // Checking that the inspector supports the node
- await this.toolbox.initInspector();
- this._nodeFront = await this.toolbox.walker.getNodeActorFromObjectActor(
- this.objectActor.actor);
- if (!this._nodeFront) {
- throw new Error("The object cannot be linked to the inspector, the " +
- "corresponding nodeFront could not be found");
- }
-
- // At this stage, the message may have been cleared already
- if (!this.document) {
- throw new Error("The object cannot be linked to the inspector, the " +
- "message was got cleared away");
- }
-
- // Check it again as this method is async!
- if (this._linkedToInspector) {
- return;
- }
- this._linkedToInspector = true;
-
- this.highlightDomNode = this.highlightDomNode.bind(this);
- this.element.addEventListener("mouseover", this.highlightDomNode);
- this.unhighlightDomNode = this.unhighlightDomNode.bind(this);
- this.element.addEventListener("mouseout", this.unhighlightDomNode);
-
- this._openInspectorNode = this._anchor("", {
- className: "open-inspector",
- onClick: this.openNodeInInspector.bind(this)
- });
- this._openInspectorNode.title = l10n.getStr("openNodeInInspector");
- },
-
- /**
- * Highlight the DOMNode corresponding to the ObjectActor in the page.
- * @return a promise that resolves when the node has been highlighted, or
- * rejects if the node cannot be highlighted (detached from the DOM)
- */
- async highlightDomNode() {
- await this.linkToInspector();
- let isAttached = await this.toolbox.walker.isInDOMTree(this._nodeFront);
- if (isAttached) {
- await this.toolbox.highlighterUtils.highlightNodeFront(this._nodeFront);
- } else {
- throw new Error("Node is not attached.");
- }
- },
-
- /**
- * Unhighlight a previously highlit node
- * @see highlightDomNode
- * @return a promise that resolves when the highlighter has been hidden
- */
- unhighlightDomNode: function() {
- return this.linkToInspector().then(() => {
- return this.toolbox.highlighterUtils.unhighlight();
- }).catch(console.error);
- },
-
- /**
- * Open the DOMNode corresponding to the ObjectActor in the inspector panel
- * @return a promise that resolves when the inspector has been switched to
- * and the node has been selected, or rejects if the node cannot be selected
- * (detached from the DOM). Note that in any case, the inspector panel will
- * be switched to.
- */
- async openNodeInInspector() {
- await this.linkToInspector();
- await this.toolbox.selectTool("inspector");
-
- let isAttached = await this.toolbox.walker.isInDOMTree(this._nodeFront);
- if (isAttached) {
- let onReady = defer();
- this.toolbox.inspector.once("inspector-updated", onReady.resolve);
- await this.toolbox.selection.setNodeFront(this._nodeFront, { reason: "console" });
- await onReady.promise;
- } else {
- throw new Error("Node is not attached.");
- }
- },
-
- destroy: function() {
- if (this.toolbox && this._nodeFront) {
- this.element.removeEventListener("mouseover", this.highlightDomNode);
- this.element.removeEventListener("mouseout", this.unhighlightDomNode);
- this._openInspectorNode.removeEventListener("mousedown",
- this.openNodeInInspector,
- true);
-
- if (this._linkedToInspector) {
- this.unhighlightDomNode().then(() => {
- this.toolbox = null;
- this._nodeFront = null;
- });
- } else {
- this.toolbox = null;
- this._nodeFront = null;
- }
- }
- },
-}); // Widgets.ObjectRenderers.byKind.DOMNode
-
-/**
- * The widget user for displaying Promise objects.
- */
-Widgets.ObjectRenderers.add({
- byClass: "Promise",
-
- render: function() {
- let { ownProperties, safeGetterValues } = this.objectActor.preview || {};
- if ((!ownProperties && !safeGetterValues) || this.options.concise) {
- this._renderConciseObject();
- return;
- }
-
- this._renderObjectPrefix();
- let container = this.element;
- let addedPromiseInternalProps = false;
-
- if (this.objectActor.promiseState) {
- const { state, value, reason } = this.objectActor.promiseState;
-
- this._renderObjectProperty("<state>", state, container, false);
- addedPromiseInternalProps = true;
-
- if (state == "fulfilled") {
- this._renderObjectProperty("<value>", value, container, true);
- } else if (state == "rejected") {
- this._renderObjectProperty("<reason>", reason, container, true);
- }
- }
-
- this._renderObjectProperties(container, addedPromiseInternalProps);
- this._renderObjectSuffix();
- }
-}); // Widgets.ObjectRenderers.byClass.Promise
-
-/*
- * A renderer used for wrapped primitive objects.
- */
-
-function WrappedPrimitiveRenderer() {
- let { ownProperties, safeGetterValues } = this.objectActor.preview || {};
- if ((!ownProperties && !safeGetterValues) || this.options.concise) {
- this._renderConciseObject();
- return;
- }
-
- this._renderObjectPrefix();
-
- let elem =
- this.message._renderValueGrip(this.objectActor.preview.wrappedValue);
- this.element.appendChild(elem);
-
- this._renderObjectProperties(this.element, true);
- this._renderObjectSuffix();
-}
-
-/**
- * The widget used for displaying Boolean previews.
- */
-Widgets.ObjectRenderers.add({
- byClass: "Boolean",
-
- render: WrappedPrimitiveRenderer,
-});
-
-/**
- * The widget used for displaying Number previews.
- */
-Widgets.ObjectRenderers.add({
- byClass: "Number",
-
- render: WrappedPrimitiveRenderer,
-});
-
-/**
- * The widget used for displaying String previews.
- */
-Widgets.ObjectRenderers.add({
- byClass: "String",
-
- render: WrappedPrimitiveRenderer,
-});
-
-/**
- * The widget used for displaying generic JS object previews.
- */
-Widgets.ObjectRenderers.add({
- byKind: "Object",
-
- render: function() {
- let { ownProperties, safeGetterValues } = this.objectActor.preview || {};
- if ((!ownProperties && !safeGetterValues) || this.options.concise) {
- this._renderConciseObject();
- return;
- }
-
- this._renderObjectPrefix();
- this._renderObjectProperties(this.element, false);
- this._renderObjectSuffix();
- },
-}); // Widgets.ObjectRenderers.byKind.Object
-
-/**
- * The long string widget.
- *
- * @constructor
- * @param object message
- * The owning message.
- * @param object longStringActor
- * The LongStringActor to display.
- * @param object options
- * Options, such as noStringQuotes
- */
-Widgets.LongString = function(message, longStringActor, options) {
- Widgets.BaseWidget.call(this, message);
- this.longStringActor = longStringActor;
- this.noStringQuotes = (options && "noStringQuotes" in options) ?
- options.noStringQuotes : !this.message._quoteStrings;
-
- this._onClick = this._onClick.bind(this);
- this._onSubstring = this._onSubstring.bind(this);
-};
-
-Widgets.LongString.prototype = extend(Widgets.BaseWidget.prototype, {
- /**
- * The LongStringActor displayed by the widget.
- * @type object
- */
- longStringActor: null,
-
- render: function() {
- if (this.element) {
- return this;
- }
-
- let result = this.element = this.document.createElementNS(XHTML_NS, "span");
- result.className = "longString console-string";
- this._renderString(this.longStringActor.initial);
- result.appendChild(this._renderEllipsis());
-
- return this;
- },
-
- /**
- * Render the long string in the widget element.
- * @private
- * @param string str
- * The string to display.
- */
- _renderString: function(str) {
- this.element.textContent = VariablesView.getString(str, {
- noStringQuotes: this.noStringQuotes,
- noEllipsis: true,
- });
- },
-
- /**
- * Render the anchor ellipsis that allows the user to expand the long string.
- *
- * @private
- * @return Element
- */
- _renderEllipsis: function() {
- let ellipsis = this.document.createElementNS(XHTML_NS, "a");
- ellipsis.className = "longStringEllipsis";
- ellipsis.textContent = l10n.getStr("longStringEllipsis");
- ellipsis.href = "#";
- ellipsis.draggable = false;
- this.message._addLinkCallback(ellipsis, this._onClick);
-
- return ellipsis;
- },
-
- /**
- * The click event handler for the ellipsis shown after the short string. This
- * function expands the element to show the full string.
- * @private
- */
- _onClick: function() {
- let longString = this.output.webConsoleClient.longString(this.longStringActor);
- let toIndex = Math.min(longString.length, MAX_LONG_STRING_LENGTH);
-
- longString.substring(longString.initial.length, toIndex, this._onSubstring);
- },
-
- /**
- * The longString substring response callback.
- *
- * @private
- * @param object response
- * Response packet.
- */
- _onSubstring: function(response) {
- if (response.error) {
- console.error("LongString substring failure: " + response.error);
- return;
- }
-
- this.element.lastChild.remove();
- this.element.classList.remove("longString");
-
- this._renderString(this.longStringActor.initial + response.substring);
-
- this.output.owner.emit("new-messages", new Set([{
- update: true,
- node: this.message.element,
- response: response,
- }]));
-
- let toIndex = Math.min(this.longStringActor.length, MAX_LONG_STRING_LENGTH);
- if (toIndex != this.longStringActor.length) {
- this._logWarningAboutStringTooLong();
- }
- },
-
- /**
- * Inform user that the string he tries to view is too long.
- * @private
- */
- _logWarningAboutStringTooLong: function() {
- let msg = new Messages.Simple(l10n.getStr("longStringTooLong"), {
- category: "output",
- severity: "warning",
- });
- this.output.addMessage(msg);
- },
-}); // Widgets.LongString.prototype
-
-/**
- * The stacktrace widget.
- *
- * @constructor
- * @extends Widgets.BaseWidget
- * @param object message
- * The owning message.
- * @param array stacktrace
- * The stacktrace to display, array of frames as supplied by the server,
- * over the remote protocol.
- */
-Widgets.Stacktrace = function(message, stacktrace) {
- Widgets.BaseWidget.call(this, message);
- this.stacktrace = stacktrace;
-};
-
-Widgets.Stacktrace.prototype = extend(Widgets.BaseWidget.prototype, {
- /**
- * The stackframes received from the server.
- * @type array
- */
- stacktrace: null,
-
- render() {
- if (this.element) {
- return this;
- }
-
- let result = this.element = this.document.createElementNS(XHTML_NS, "div");
- result.className = "stacktrace devtools-monospace";
-
- if (this.stacktrace) {
- const target = this.message.output.toolboxTarget;
- const toolbox = gDevTools.getToolbox(target);
- this.output.owner.ReactDOM.render(this.output.owner.StackTraceView({
- stacktrace: this.stacktrace,
- onViewSourceInDebugger: frame => this.output.openLocationInDebugger(frame),
- sourceMapService: toolbox ? toolbox.sourceMapURLService : null,
- }), result);
- }
-
- return this;
- }
-});
-
-/**
- * The table widget.
- *
- * @constructor
- * @extends Widgets.BaseWidget
- * @param object message
- * The owning message.
- * @param array data
- * Array of objects that holds the data to log in the table.
- * @param object columns
- * Object containing the key value pair of the id and display name for
- * the columns in the table.
- */
-Widgets.Table = function(message, data, columns) {
- Widgets.BaseWidget.call(this, message);
- this.data = data;
- this.columns = columns;
-};
-
-Widgets.Table.prototype = extend(Widgets.BaseWidget.prototype, {
- /**
- * Array of objects that holds the data to output in the table.
- * @type array
- */
- data: null,
-
- /**
- * Object containing the key value pair of the id and display name for
- * the columns in the table.
- * @type object
- */
- columns: null,
-
- render: function() {
- if (this.element) {
- return this;
- }
-
- let result = this.element = this.document.createElementNS(XHTML_NS, "div");
- result.className = "consoletable devtools-monospace";
-
- this.table = new TableWidget(result, {
- wrapTextInElements: true,
- initialColumns: this.columns,
- uniqueId: "_index",
- firstColumn: "_index"
- });
-
- for (let row of this.data) {
- this.table.push(row);
- }
-
- return this;
- }
-}); // Widgets.Table.prototype
-
-function gSequenceId() {
- return gSequenceId.n++;
-}
-gSequenceId.n = 0;
-
-exports.ConsoleOutput = ConsoleOutput;
-exports.Messages = Messages;
-exports.Widgets = Widgets;
deleted file mode 100644
--- a/devtools/client/webconsole/old/jsterm.js
+++ /dev/null
@@ -1,1867 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const {Utils: WebConsoleUtils} =
- require("devtools/client/webconsole/utils");
-const defer = require("devtools/shared/defer");
-const Debugger = require("Debugger");
-const Services = require("Services");
-const {KeyCodes} = require("devtools/client/shared/keycodes");
-
-loader.lazyServiceGetter(this, "clipboardHelper",
- "@mozilla.org/widget/clipboardhelper;1",
- "nsIClipboardHelper");
-loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
-loader.lazyRequireGetter(this, "AutocompletePopup", "devtools/client/shared/autocomplete-popup");
-loader.lazyRequireGetter(this, "ToolSidebar", "devtools/client/framework/sidebar", true);
-loader.lazyRequireGetter(this, "Messages", "devtools/client/webconsole/old/console-output", true);
-loader.lazyRequireGetter(this, "asyncStorage", "devtools/shared/async-storage");
-loader.lazyRequireGetter(this, "EnvironmentClient", "devtools/shared/client/environment-client");
-loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/object-client");
-loader.lazyImporter(this, "VariablesView", "resource://devtools/client/shared/widgets/VariablesView.jsm");
-loader.lazyImporter(this, "VariablesViewController", "resource://devtools/client/shared/widgets/VariablesViewController.jsm");
-loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
-loader.lazyRequireGetter(this, "NotificationBox", "devtools/client/shared/components/NotificationBox", true);
-loader.lazyRequireGetter(this, "PriorityLevels", "devtools/client/shared/components/NotificationBox", true);
-
-const l10n = require("devtools/client/webconsole/webconsole-l10n");
-
-// Constants used for defining the direction of JSTerm input history navigation.
-const HISTORY_BACK = -1;
-const HISTORY_FORWARD = 1;
-
-const XHTML_NS = "http://www.w3.org/1999/xhtml";
-
-const HELP_URL = "https://developer.mozilla.org/docs/Tools/Web_Console/Helpers";
-
-const VARIABLES_VIEW_URL = "chrome://devtools/content/shared/widgets/VariablesView.xul";
-
-const PREF_INPUT_HISTORY_COUNT = "devtools.webconsole.inputHistoryCount";
-const PREF_AUTO_MULTILINE = "devtools.webconsole.autoMultiline";
-
-/**
- * Create a JSTerminal (a JavaScript command line). This is attached to an
- * existing HeadsUpDisplay (a Web Console instance). This code is responsible
- * with handling command line input, code evaluation and result output.
- *
- * @constructor
- * @param object webConsoleFrame
- * The WebConsoleFrame object that owns this JSTerm instance.
- */
-function JSTerm(webConsoleFrame) {
- this.hud = webConsoleFrame;
- this.hudId = this.hud.hudId;
- this.inputHistoryCount = Services.prefs.getIntPref(PREF_INPUT_HISTORY_COUNT);
-
- this.lastCompletion = { value: null };
- this._loadHistory();
-
- this._objectActorsInVariablesViews = new Map();
-
- this._keyPress = this._keyPress.bind(this);
- this._inputEventHandler = this._inputEventHandler.bind(this);
- this._focusEventHandler = this._focusEventHandler.bind(this);
- this._onKeypressInVariablesView = this._onKeypressInVariablesView.bind(this);
- this._blurEventHandler = this._blurEventHandler.bind(this);
-
- EventEmitter.decorate(this);
-}
-
-JSTerm.prototype = {
- SELECTED_FRAME: -1,
-
- /**
- * Load the console history from previous sessions.
- * @private
- */
- _loadHistory: function() {
- this.history = [];
- this.historyIndex = this.historyPlaceHolder = 0;
-
- this.historyLoaded = asyncStorage.getItem("webConsoleHistory")
- .then(value => {
- if (Array.isArray(value)) {
- // Since it was gotten asynchronously, there could be items already in
- // the history. It's not likely but stick them onto the end anyway.
- this.history = value.concat(this.history);
-
- // Holds the number of entries in history. This value is incremented
- // in this.execute().
- this.historyIndex = this.history.length;
-
- // Holds the index of the history entry that the user is currently
- // viewing. This is reset to this.history.length when this.execute()
- // is invoked.
- this.historyPlaceHolder = this.history.length;
- }
- }, console.error);
- },
-
- /**
- * Clear the console history altogether. Note that this will not affect
- * other consoles that are already opened (since they have their own copy),
- * but it will reset the array for all newly-opened consoles.
- * @returns Promise
- * Resolves once the changes have been persisted.
- */
- clearHistory: function() {
- this.history = [];
- this.historyIndex = this.historyPlaceHolder = 0;
- return this.storeHistory();
- },
-
- /**
- * Stores the console history for future console instances.
- * @returns Promise
- * Resolves once the changes have been persisted.
- */
- storeHistory: function() {
- return asyncStorage.setItem("webConsoleHistory", this.history);
- },
-
- /**
- * Stores the data for the last completion.
- * @type object
- */
- lastCompletion: null,
-
- /**
- * Array that caches the user input suggestions received from the server.
- * @private
- * @type array
- */
- _autocompleteCache: null,
-
- /**
- * The input that caused the last request to the server, whose response is
- * cached in the _autocompleteCache array.
- * @private
- * @type string
- */
- _autocompleteQuery: null,
-
- /**
- * The frameActorId used in the last autocomplete query. Whenever this changes
- * the autocomplete cache must be invalidated.
- * @private
- * @type string
- */
- _lastFrameActorId: null,
-
- /**
- * The Web Console sidebar.
- * @see this._createSidebar()
- * @see Sidebar.jsm
- */
- sidebar: null,
-
- /**
- * The Variables View instance shown in the sidebar.
- * @private
- * @type object
- */
- _variablesView: null,
-
- /**
- * Tells if you want the variables view UI updates to be lazy or not. Tests
- * disable lazy updates.
- *
- * @private
- * @type boolean
- */
- _lazyVariablesView: true,
-
- /**
- * Holds a map between VariablesView instances and sets of ObjectActor IDs
- * that have been retrieved from the server. This allows us to release the
- * objects when needed.
- *
- * @private
- * @type Map
- */
- _objectActorsInVariablesViews: null,
-
- /**
- * Last input value.
- * @type string
- */
- lastInputValue: "",
-
- /**
- * Tells if the input node changed since the last focus.
- *
- * @private
- * @type boolean
- */
- _inputChanged: false,
-
- /**
- * Tells if the autocomplete popup was navigated since the last open.
- *
- * @private
- * @type boolean
- */
- _autocompletePopupNavigated: false,
-
- /**
- * History of code that was executed.
- * @type array
- */
- history: null,
- autocompletePopup: null,
- inputNode: null,
- completeNode: null,
-
- /**
- * Getter for the element that holds the messages we display.
- * @type nsIDOMElement
- */
- get outputNode() {
- return this.hud.outputNode;
- },
-
- /**
- * Getter for the debugger WebConsoleClient.
- * @type object
- */
- get webConsoleClient() {
- return this.hud.webConsoleClient;
- },
-
- COMPLETE_FORWARD: 0,
- COMPLETE_BACKWARD: 1,
- COMPLETE_HINT_ONLY: 2,
- COMPLETE_PAGEUP: 3,
- COMPLETE_PAGEDOWN: 4,
-
- /**
- * Initialize the JSTerminal UI.
- */
- init: function() {
- let autocompleteOptions = {
- onSelect: this.onAutocompleteSelect.bind(this),
- onClick: this.acceptProposedCompletion.bind(this),
- listId: "webConsole_autocompletePopupListBox",
- position: "top",
- theme: "auto",
- autoSelect: true
- };
-
- let doc = this.hud.document;
- let toolbox = gDevTools.getToolbox(this.hud.owner.target);
- let tooltipDoc = toolbox ? toolbox.doc : doc;
- // The popup will be attached to the toolbox document or HUD document in the case
- // such as the browser console which doesn't have a toolbox.
- this.autocompletePopup = new AutocompletePopup(tooltipDoc, autocompleteOptions);
- let inputContainer = doc.querySelector(".jsterm-input-container");
- this.completeNode = doc.querySelector(".jsterm-complete-node");
- this.inputNode = doc.querySelector(".jsterm-input-node");
- this.inputBorderSize = this.inputNode.getBoundingClientRect().height -
- this.inputNode.clientHeight;
- // Update the character width and height needed for the popup offset
- // calculations.
- this._updateCharSize();
-
- if (this.hud.isBrowserConsole &&
- !Services.prefs.getBoolPref("devtools.chrome.enabled")) {
- inputContainer.style.display = "none";
- } else {
- this.inputNode.addEventListener("keypress", this._keyPress);
- this.inputNode.addEventListener("input", this._inputEventHandler);
- this.inputNode.addEventListener("keyup", this._inputEventHandler);
- this.inputNode.addEventListener("focus", this._focusEventHandler);
- }
-
- if (!this.hud.isBrowserConsole) {
- let okstring = l10n.getStr("selfxss.okstring");
- let msg = l10n.getFormatStr("selfxss.msg", [okstring]);
- this._onPaste = WebConsoleUtils.pasteHandlerGen(this.inputNode,
- this.getNotificationBox(), msg, okstring);
- this.inputNode.addEventListener("paste", this._onPaste);
- this.inputNode.addEventListener("drop", this._onPaste);
- }
-
- this.hud.window.addEventListener("blur", this._blurEventHandler);
- this.lastInputValue && this.setInputValue(this.lastInputValue);
- },
-
- focus: function() {
- if (!this.inputNode.getAttribute("focused")) {
- this.inputNode.focus();
- }
- },
-
- /**
- * The JavaScript evaluation response handler.
- *
- * @private
- * @param function [callback]
- * Optional function to invoke when the evaluation result is added to
- * the output.
- * @param object response
- * The message received from the server.
- */
- _executeResultCallback: function(callback, response) {
- if (!this.hud) {
- return;
- }
- if (response.error) {
- console.error("Evaluation error " + response.error + ": " +
- response.message);
- return;
- }
- let errorMessage = response.exceptionMessage;
- let errorDocURL = response.exceptionDocURL;
-
- let errorDocLink;
- if (errorDocURL) {
- errorMessage += " ";
- errorDocLink = this.hud.document.createElementNS(XHTML_NS, "a");
- errorDocLink.className = "learn-more-link webconsole-learn-more-link";
- errorDocLink.textContent = `[${l10n.getStr("webConsoleMoreInfoLabel")}]`;
- errorDocLink.title = errorDocURL.split("?")[0];
- errorDocLink.href = "#";
- errorDocLink.draggable = false;
- errorDocLink.addEventListener("click", () => {
- this.hud.owner.openLink(errorDocURL);
- });
- }
-
- // Wrap thrown strings in Error objects, so `throw "foo"` outputs
- // "Error: foo"
- if (typeof response.exception === "string") {
- errorMessage = new Error(errorMessage).toString();
- }
- let result = response.result;
- let helperResult = response.helperResult;
- let helperHasRawOutput = !!(helperResult || {}).rawOutput;
-
- if (helperResult && helperResult.type) {
- switch (helperResult.type) {
- case "clearOutput":
- this.clearOutput();
- break;
- case "clearHistory":
- this.clearHistory();
- break;
- case "inspectObject":
- this.inspectObjectActor(helperResult.object);
- break;
- case "error":
- try {
- errorMessage = l10n.getStr(helperResult.message);
- } catch (ex) {
- errorMessage = helperResult.message;
- }
- break;
- case "help":
- this.hud.owner.openLink(HELP_URL);
- break;
- case "copyValueToClipboard":
- clipboardHelper.copyString(helperResult.value);
- break;
- }
- }
-
- // Hide undefined results coming from JSTerm helper functions.
- if (!errorMessage && result && typeof result == "object" &&
- result.type == "undefined" &&
- helperResult && !helperHasRawOutput) {
- callback && callback();
- return;
- }
-
- if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- this.hud.newConsoleOutput.dispatchMessageAdd(response, true).then(callback);
- return;
- }
- let msg = new Messages.JavaScriptEvalOutput(response,
- errorMessage, errorDocLink);
- this.hud.output.addMessage(msg);
-
- if (callback) {
- let oldFlushCallback = this.hud._flushCallback;
- this.hud._flushCallback = () => {
- callback(msg.element);
- if (oldFlushCallback) {
- oldFlushCallback();
- this.hud._flushCallback = oldFlushCallback;
- return true;
- }
-
- return false;
- };
- }
-
- msg._objectActors = new Set();
-
- if (WebConsoleUtils.isActorGrip(response.exception)) {
- msg._objectActors.add(response.exception.actor);
- }
-
- if (WebConsoleUtils.isActorGrip(result)) {
- msg._objectActors.add(result.actor);
- }
- },
-
- inspectObjectActor: function(objectActor) {
- if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- this.hud.newConsoleOutput.dispatchMessageAdd({
- helperResult: {
- type: "inspectObject",
- object: objectActor
- }
- }, true);
- return this.hud.newConsoleOutput;
- }
-
- return this.openVariablesView({
- objectActor,
- label: VariablesView.getString(objectActor, {concise: true}),
- });
- },
-
- /**
- * Execute a string. Execution happens asynchronously in the content process.
- *
- * @param string [executeString]
- * The string you want to execute. If this is not provided, the current
- * user input is used - taken from |this.getInputValue()|.
- * @param function [callback]
- * Optional function to invoke when the result is displayed.
- * This is deprecated - please use the promise return value instead.
- * @returns Promise
- * Resolves with the message once the result is displayed.
- */
- execute: async function(executeString, callback) {
- let deferred = defer();
- let resultCallback;
- if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- resultCallback = (msg) => deferred.resolve(msg);
- } else {
- resultCallback = (msg) => {
- deferred.resolve(msg);
- if (callback) {
- callback(msg);
- }
- };
- }
-
- // attempt to execute the content of the inputNode
- executeString = executeString || this.getInputValue();
- if (!executeString) {
- return null;
- }
-
- // Append a new value in the history of executed code, or overwrite the most
- // recent entry. The most recent entry may contain the last edited input
- // value that was not evaluated yet.
- this.history[this.historyIndex++] = executeString;
- this.historyPlaceHolder = this.history.length;
-
- if (this.history.length > this.inputHistoryCount) {
- this.history.splice(0, this.history.length - this.inputHistoryCount);
- this.historyIndex = this.historyPlaceHolder = this.history.length;
- }
- this.storeHistory();
- WebConsoleUtils.usageCount++;
- this.setInputValue("");
- this.clearCompletion();
-
- let selectedNodeActor = null;
- let inspectorSelection = this.hud.owner.getInspectorSelection();
- if (inspectorSelection && inspectorSelection.nodeFront) {
- selectedNodeActor = inspectorSelection.nodeFront.actorID;
- }
-
- if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- const { ConsoleCommand } = require("devtools/client/webconsole/types");
- let message = new ConsoleCommand({
- messageText: executeString,
- });
- this.hud.proxy.dispatchMessageAdd(message);
- } else {
- let message = new Messages.Simple(executeString, {
- category: "input",
- severity: "log",
- });
- this.hud.output.addMessage(message);
- }
- let onResult = this._executeResultCallback.bind(this, resultCallback);
-
- let options = {
- frame: this.SELECTED_FRAME,
- selectedNodeActor: selectedNodeActor,
- };
-
- const mappedString = await this.hud.owner.getMappedExpression(executeString);
- this.requestEvaluation(mappedString, options).then(onResult, onResult);
-
- return deferred.promise;
- },
-
- /**
- * Request a JavaScript string evaluation from the server.
- *
- * @param string str
- * String to execute.
- * @param object [options]
- * Options for evaluation:
- * - bindObjectActor: tells the ObjectActor ID for which you want to do
- * the evaluation. The Debugger.Object of the OA will be bound to
- * |_self| during evaluation, such that it's usable in the string you
- * execute.
- * - frame: tells the stackframe depth to evaluate the string in. If
- * the jsdebugger is paused, you can pick the stackframe to be used for
- * evaluation. Use |this.SELECTED_FRAME| to always pick the
- * user-selected stackframe.
- * If you do not provide a |frame| the string will be evaluated in the
- * global content window.
- * - selectedNodeActor: tells the NodeActor ID of the current selection
- * in the Inspector, if such a selection exists. This is used by
- * helper functions that can evaluate on the current selection.
- * @return object
- * A promise object that is resolved when the server response is
- * received.
- */
- requestEvaluation: function(str, options = {}) {
- let deferred = defer();
-
- function onResult(response) {
- if (!response.error) {
- deferred.resolve(response);
- } else {
- deferred.reject(response);
- }
- }
-
- let frameActor = null;
- if ("frame" in options) {
- frameActor = this.getFrameActor(options.frame);
- }
-
- let evalOptions = {
- bindObjectActor: options.bindObjectActor,
- frameActor: frameActor,
- selectedNodeActor: options.selectedNodeActor,
- selectedObjectActor: options.selectedObjectActor,
- };
-
- this.webConsoleClient.evaluateJSAsync(str, onResult, evalOptions);
- return deferred.promise;
- },
-
- /**
- * Copy the object/variable by invoking the server
- * which invokes the `copy(variable)` command and makes it
- * available in the clipboard
- * @param evalString - string which has the evaluation string to be copied
- * @param options - object - Options for evaluation
- * @return object
- * A promise object that is resolved when the server response is
- * received.
- */
- copyObject: function(evalString, evalOptions) {
- return this.webConsoleClient.evaluateJSAsync(`copy(${evalString})`,
- null, evalOptions);
- },
-
- /**
- * Retrieve the FrameActor ID given a frame depth.
- *
- * @param number frame
- * Frame depth.
- * @return string|null
- * The FrameActor ID for the given frame depth.
- */
- getFrameActor: function(frame) {
- let state = this.hud.owner.getDebuggerFrames();
- if (!state) {
- return null;
- }
-
- let grip;
- if (frame == this.SELECTED_FRAME) {
- grip = state.frames[state.selected];
- } else {
- grip = state.frames[frame];
- }
-
- return grip ? grip.actor : null;
- },
-
- /**
- * Opens a new variables view that allows the inspection of the given object.
- *
- * @param object options
- * Options for the variables view:
- * - objectActor: grip of the ObjectActor you want to show in the
- * variables view.
- * - rawObject: the raw object you want to show in the variables view.
- * - label: label to display in the variables view for inspected
- * object.
- * - hideFilterInput: optional boolean, |true| if you want to hide the
- * variables view filter input.
- * - targetElement: optional nsIDOMElement to append the variables view
- * to. An iframe element is used as a container for the view. If this
- * option is not used, then the variables view opens in the sidebar.
- * - autofocus: optional boolean, |true| if you want to give focus to
- * the variables view window after open, |false| otherwise.
- * @return object
- * A promise object that is resolved when the variables view has
- * opened. The new variables view instance is given to the callbacks.
- */
- openVariablesView: function(options) {
- // Bail out if the side bar doesn't exist.
- if (!this.hud.document.querySelector("#webconsole-sidebar")) {
- return Promise.resolve(null);
- }
-
- let onContainerReady = (window) => {
- let container = window.document.querySelector("#variables");
- let view = this._variablesView;
- if (!view || options.targetElement) {
- let viewOptions = {
- container: container,
- hideFilterInput: options.hideFilterInput,
- };
- view = this._createVariablesView(viewOptions);
- if (!options.targetElement) {
- this._variablesView = view;
- window.addEventListener("keypress", this._onKeypressInVariablesView);
- }
- }
- options.view = view;
- this._updateVariablesView(options);
-
- if (!options.targetElement && options.autofocus) {
- window.focus();
- }
-
- this.emit("variablesview-open", {view, options});
- return view;
- };
-
- let openPromise;
- if (options.targetElement) {
- let deferred = defer();
- openPromise = deferred.promise;
- let document = options.targetElement.ownerDocument;
- let iframe = document.createElementNS(XHTML_NS, "iframe");
-
- iframe.addEventListener("load", function() {
- iframe.style.visibility = "visible";
- deferred.resolve(iframe.contentWindow);
- }, {capture: true, once: true});
-
- iframe.flex = 1;
- iframe.style.visibility = "hidden";
- iframe.setAttribute("src", VARIABLES_VIEW_URL);
- options.targetElement.appendChild(iframe);
- } else {
- if (!this.sidebar) {
- this._createSidebar();
- }
- openPromise = this._addVariablesViewSidebarTab();
- }
-
- return openPromise.then(onContainerReady);
- },
-
- /**
- * Create the Web Console sidebar.
- *
- * @see devtools/framework/sidebar.js
- * @private
- */
- _createSidebar: function() {
- let tabbox = this.hud.document.querySelector("#webconsole-sidebar");
- this.sidebar = new ToolSidebar(tabbox, this, "webconsole");
- this.sidebar.show();
- this.emit("sidebar-opened");
- },
-
- /**
- * Add the variables view tab to the sidebar.
- *
- * @private
- * @return object
- * A promise object for the adding of the new tab.
- */
- _addVariablesViewSidebarTab: function() {
- let deferred = defer();
-
- let onTabReady = () => {
- let window = this.sidebar.getWindowForTab("variablesview");
- deferred.resolve(window);
- };
-
- let tabPanel = this.sidebar.getTabPanel("variablesview");
- if (tabPanel) {
- if (this.sidebar.getCurrentTabID() == "variablesview") {
- onTabReady();
- } else {
- this.sidebar.once("variablesview-selected", onTabReady);
- this.sidebar.select("variablesview");
- }
- } else {
- this.sidebar.once("variablesview-ready", onTabReady);
- this.sidebar.addTab("variablesview", VARIABLES_VIEW_URL, {selected: true});
- }
-
- return deferred.promise;
- },
-
- /**
- * The keypress event handler for the Variables View sidebar. Currently this
- * is used for removing the sidebar when Escape is pressed.
- *
- * @private
- * @param nsIDOMEvent event
- * The keypress DOM event object.
- */
- _onKeypressInVariablesView: function(event) {
- let tag = event.target.nodeName;
- if (event.keyCode != KeyCodes.DOM_VK_ESCAPE || event.shiftKey ||
- event.altKey || event.ctrlKey || event.metaKey ||
- ["input", "textarea", "select", "textbox"].indexOf(tag) > -1) {
- return;
- }
-
- this._sidebarDestroy();
- this.focus();
- event.stopPropagation();
- },
-
- /**
- * Create a variables view instance.
- *
- * @private
- * @param object options
- * Options for the new Variables View instance:
- * - container: the DOM element where the variables view is inserted.
- * - hideFilterInput: boolean, if true the variables filter input is
- * hidden.
- * @return object
- * The new Variables View instance.
- */
- _createVariablesView: function(options) {
- let view = new VariablesView(options.container);
- view.toolbox = gDevTools.getToolbox(this.hud.owner.target);
- view.searchPlaceholder = l10n.getStr("propertiesFilterPlaceholder");
- view.emptyText = l10n.getStr("emptyPropertiesList");
- view.searchEnabled = !options.hideFilterInput;
- view.lazyEmpty = this._lazyVariablesView;
-
- VariablesViewController.attach(view, {
- getEnvironmentClient: grip => {
- return new EnvironmentClient(this.hud.proxy.client, grip);
- },
- getObjectClient: grip => {
- return new ObjectClient(this.hud.proxy.client, grip);
- },
- getLongStringClient: grip => {
- return this.webConsoleClient.longString(grip);
- },
- releaseActor: actor => {
- this.hud._releaseObject(actor);
- },
- simpleValueEvalMacro: simpleValueEvalMacro,
- overrideValueEvalMacro: overrideValueEvalMacro,
- getterOrSetterEvalMacro: getterOrSetterEvalMacro,
- });
-
- // Relay events from the VariablesView.
- view.on("fetched", (type, variableObject) => {
- this.emit("variablesview-fetched", variableObject);
- });
-
- return view;
- },
-
- /**
- * Update the variables view.
- *
- * @private
- * @param object options
- * Options for updating the variables view:
- * - view: the view you want to update.
- * - objectActor: the grip of the new ObjectActor you want to show in
- * the view.
- * - rawObject: the new raw object you want to show.
- * - label: the new label for the inspected object.
- */
- _updateVariablesView: function(options) {
- let view = options.view;
- view.empty();
-
- // We need to avoid pruning the object inspection starting point.
- // That one is pruned when the console message is removed.
- view.controller.releaseActors(actor => {
- return view._consoleLastObjectActor != actor;
- });
-
- if (options.objectActor &&
- (!this.hud.isBrowserConsole ||
- Services.prefs.getBoolPref("devtools.chrome.enabled"))) {
- // Make sure eval works in the correct context.
- view.eval = this._variablesViewEvaluate.bind(this, options);
- view.switch = this._variablesViewSwitch.bind(this, options);
- view.delete = this._variablesViewDelete.bind(this, options);
- } else {
- view.eval = null;
- view.switch = null;
- view.delete = null;
- }
-
- let { variable, expanded } = view.controller.setSingleVariable(options);
- variable.evaluationMacro = simpleValueEvalMacro;
-
- if (options.objectActor) {
- view._consoleLastObjectActor = options.objectActor.actor;
- } else if (options.rawObject) {
- view._consoleLastObjectActor = null;
- } else {
- throw new Error(
- "Variables View cannot open without giving it an object display.");
- }
-
- expanded.then(() => {
- this.emit("variablesview-updated", view, options);
- });
- },
-
- /**
- * The evaluation function used by the variables view when editing a property
- * value.
- *
- * @private
- * @param object options
- * The options used for |this._updateVariablesView()|.
- * @param object variableObject
- * The Variable object instance for the edited property.
- * @param string value
- * The value the edited property was changed to.
- */
- _variablesViewEvaluate: function(options, variableObject, value) {
- let updater = this._updateVariablesView.bind(this, options);
- let onEval = this._silentEvalCallback.bind(this, updater);
- let string = variableObject.evaluationMacro(variableObject, value);
-
- let evalOptions = {
- frame: this.SELECTED_FRAME,
- bindObjectActor: options.objectActor.actor,
- };
-
- this.requestEvaluation(string, evalOptions).then(onEval, onEval);
- },
-
- /**
- * The property deletion function used by the variables view when a property
- * is deleted.
- *
- * @private
- * @param object options
- * The options used for |this._updateVariablesView()|.
- * @param object variableObject
- * The Variable object instance for the deleted property.
- */
- _variablesViewDelete: function(options, variableObject) {
- let onEval = this._silentEvalCallback.bind(this, null);
-
- let evalOptions = {
- frame: this.SELECTED_FRAME,
- bindObjectActor: options.objectActor.actor,
- };
-
- this.requestEvaluation("delete _self" +
- variableObject.symbolicName, evalOptions).then(onEval, onEval);
- },
-
- /**
- * The property rename function used by the variables view when a property
- * is renamed.
- *
- * @private
- * @param object options
- * The options used for |this._updateVariablesView()|.
- * @param object variableObject
- * The Variable object instance for the renamed property.
- * @param string newName
- * The new name for the property.
- */
- _variablesViewSwitch: function(options, variableObject, newName) {
- let updater = this._updateVariablesView.bind(this, options);
- let onEval = this._silentEvalCallback.bind(this, updater);
-
- let evalOptions = {
- frame: this.SELECTED_FRAME,
- bindObjectActor: options.objectActor.actor,
- };
-
- let newSymbolicName =
- variableObject.ownerView.symbolicName + '["' + newName + '"]';
- if (newSymbolicName == variableObject.symbolicName) {
- return;
- }
-
- let code = "_self" + newSymbolicName + " = _self" +
- variableObject.symbolicName + ";" + "delete _self" +
- variableObject.symbolicName;
-
- this.requestEvaluation(code, evalOptions).then(onEval, onEval);
- },
-
- /**
- * A noop callback for JavaScript evaluation. This method releases any
- * result ObjectActors that come from the server for evaluation requests. This
- * is used for editing, renaming and deleting properties in the variables
- * view.
- *
- * Exceptions are displayed in the output.
- *
- * @private
- * @param function callback
- * Function to invoke once the response is received.
- * @param object response
- * The response packet received from the server.
- */
- _silentEvalCallback: function(callback, response) {
- if (response.error) {
- console.error("Web Console evaluation failed. " + response.error + ":" +
- response.message);
-
- callback && callback(response);
- return;
- }
-
- if (response.exceptionMessage) {
- let message = new Messages.Simple(response.exceptionMessage, {
- category: "output",
- severity: "error",
- timestamp: response.timestamp,
- });
- this.hud.output.addMessage(message);
- message._objectActors = new Set();
- if (WebConsoleUtils.isActorGrip(response.exception)) {
- message._objectActors.add(response.exception.actor);
- }
- }
-
- let helper = response.helperResult || { type: null };
- let helperGrip = null;
- if (helper.type == "inspectObject") {
- helperGrip = helper.object;
- }
-
- let grips = [response.result, helperGrip];
- for (let grip of grips) {
- if (WebConsoleUtils.isActorGrip(grip)) {
- this.hud._releaseObject(grip.actor);
- }
- }
-
- callback && callback(response);
- },
-
- /**
- * Clear the Web Console output.
- *
- * This method emits the "messages-cleared" notification.
- *
- * @param boolean clearStorage
- * True if you want to clear the console messages storage associated to
- * this Web Console.
- */
- clearOutput: function(clearStorage) {
- let hud = this.hud;
-
- if (hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- hud.newConsoleOutput.dispatchMessagesClear();
- } else {
- let outputNode = hud.outputNode;
- let node;
- while ((node = outputNode.firstChild)) {
- hud.removeOutputMessage(node);
- }
-
- hud.groupDepth = 0;
- hud._outputQueue.forEach(hud._destroyItem, hud);
- hud._outputQueue = [];
- hud._repeatNodes = {};
- }
- this.webConsoleClient.clearNetworkRequests();
- if (clearStorage) {
- this.webConsoleClient.clearMessagesCache();
- }
- this._sidebarDestroy();
- this.focus();
- this.emit("messages-cleared");
- },
-
- /**
- * Remove all of the private messages from the Web Console output.
- *
- * This method emits the "private-messages-cleared" notification.
- */
- clearPrivateMessages: function() {
- if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- this.hud.newConsoleOutput.dispatchPrivateMessagesClear();
- } else {
- let nodes = this.hud.outputNode.querySelectorAll(".message[private]");
- for (let node of nodes) {
- this.hud.removeOutputMessage(node);
- }
- }
- this.emit("private-messages-cleared");
- },
-
- /**
- * Updates the size of the input field (command line) to fit its contents.
- *
- * @returns void
- */
- resizeInput: function() {
- let inputNode = this.inputNode;
-
- // Reset the height so that scrollHeight will reflect the natural height of
- // the contents of the input field.
- inputNode.style.height = "auto";
-
- // Now resize the input field to fit its contents.
- // TODO: remove `inputNode.inputField.scrollHeight` when the old
- // console UI is removed. See bug 1381834
- let scrollHeight = inputNode.inputField ?
- inputNode.inputField.scrollHeight : inputNode.scrollHeight;
-
- if (scrollHeight > 0) {
- inputNode.style.height = (scrollHeight + this.inputBorderSize) + "px";
- }
- },
-
- /**
- * Sets the value of the input field (command line), and resizes the field to
- * fit its contents. This method is preferred over setting "inputNode.value"
- * directly, because it correctly resizes the field.
- *
- * @param string newValue
- * The new value to set.
- * @returns void
- */
- setInputValue: function(newValue) {
- this.inputNode.value = newValue;
- this.lastInputValue = newValue;
- this.completeNode.value = "";
- this.resizeInput();
- this._inputChanged = true;
- this.emit("set-input-value");
- },
-
- /**
- * Gets the value from the input field
- * @returns string
- */
- getInputValue: function() {
- return this.inputNode.value || "";
- },
-
- /**
- * The inputNode "input" and "keyup" event handler.
- * @private
- */
- _inputEventHandler: function() {
- if (this.lastInputValue != this.getInputValue()) {
- this.resizeInput();
- this.complete(this.COMPLETE_HINT_ONLY);
- this.lastInputValue = this.getInputValue();
- this._inputChanged = true;
- }
- },
-
- /**
- * The window "blur" event handler.
- * @private
- */
- _blurEventHandler: function() {
- if (this.autocompletePopup) {
- this.clearCompletion();
- }
- },
-
- /* eslint-disable complexity */
- /**
- * The inputNode "keypress" event handler.
- *
- * @private
- * @param nsIDOMEvent event
- */
- _keyPress: function(event) {
- let inputNode = this.inputNode;
- let inputValue = this.getInputValue();
- let inputUpdated = false;
-
- if (event.ctrlKey) {
- switch (event.charCode) {
- case 101:
- // control-e
- if (Services.appinfo.OS == "WINNT") {
- break;
- }
- let lineEndPos = inputValue.length;
- if (this.hasMultilineInput()) {
- // find index of closest newline >= cursor
- for (let i = inputNode.selectionEnd; i < lineEndPos; i++) {
- if (inputValue.charAt(i) == "\r" ||
- inputValue.charAt(i) == "\n") {
- lineEndPos = i;
- break;
- }
- }
- }
- inputNode.setSelectionRange(lineEndPos, lineEndPos);
- event.preventDefault();
- this.clearCompletion();
- break;
-
- case 110:
- // Control-N differs from down arrow: it ignores autocomplete state.
- // Note that we preserve the default 'down' navigation within
- // multiline text.
- if (Services.appinfo.OS == "Darwin" &&
- this.canCaretGoNext() &&
- this.historyPeruse(HISTORY_FORWARD)) {
- event.preventDefault();
- // Ctrl-N is also used to focus the Network category button on
- // MacOSX. The preventDefault() call doesn't prevent the focus
- // from moving away from the input.
- this.focus();
- }
- this.clearCompletion();
- break;
-
- case 112:
- // Control-P differs from up arrow: it ignores autocomplete state.
- // Note that we preserve the default 'up' navigation within
- // multiline text.
- if (Services.appinfo.OS == "Darwin" &&
- this.canCaretGoPrevious() &&
- this.historyPeruse(HISTORY_BACK)) {
- event.preventDefault();
- // Ctrl-P may also be used to focus some category button on MacOSX.
- // The preventDefault() call doesn't prevent the focus from moving
- // away from the input.
- this.focus();
- }
- this.clearCompletion();
- break;
- default:
- break;
- }
- return;
- } else if (event.keyCode == KeyCodes.DOM_VK_RETURN) {
- let autoMultiline = Services.prefs.getBoolPref(PREF_AUTO_MULTILINE);
- if (event.shiftKey ||
- (!Debugger.isCompilableUnit(inputNode.value) && autoMultiline)) {
- // shift return or incomplete statement
- return;
- }
- }
-
- switch (event.keyCode) {
- case KeyCodes.DOM_VK_ESCAPE:
- if (this.autocompletePopup.isOpen) {
- this.clearCompletion();
- event.preventDefault();
- event.stopPropagation();
- } else if (this.sidebar) {
- this._sidebarDestroy();
- event.preventDefault();
- event.stopPropagation();
- }
- break;
-
- case KeyCodes.DOM_VK_RETURN:
- if (this._autocompletePopupNavigated &&
- this.autocompletePopup.isOpen &&
- this.autocompletePopup.selectedIndex > -1) {
- this.acceptProposedCompletion();
- } else {
- this.execute();
- this._inputChanged = false;
- }
- event.preventDefault();
- break;
-
- case KeyCodes.DOM_VK_UP:
- if (this.autocompletePopup.isOpen) {
- inputUpdated = this.complete(this.COMPLETE_BACKWARD);
- if (inputUpdated) {
- this._autocompletePopupNavigated = true;
- }
- } else if (this.canCaretGoPrevious()) {
- inputUpdated = this.historyPeruse(HISTORY_BACK);
- }
- if (inputUpdated) {
- event.preventDefault();
- }
- break;
-
- case KeyCodes.DOM_VK_DOWN:
- if (this.autocompletePopup.isOpen) {
- inputUpdated = this.complete(this.COMPLETE_FORWARD);
- if (inputUpdated) {
- this._autocompletePopupNavigated = true;
- }
- } else if (this.canCaretGoNext()) {
- inputUpdated = this.historyPeruse(HISTORY_FORWARD);
- }
- if (inputUpdated) {
- event.preventDefault();
- }
- break;
-
- case KeyCodes.DOM_VK_PAGE_UP:
- if (this.autocompletePopup.isOpen) {
- inputUpdated = this.complete(this.COMPLETE_PAGEUP);
- if (inputUpdated) {
- this._autocompletePopupNavigated = true;
- }
- } else {
- this.hud.outputScroller.scrollTop =
- Math.max(0,
- this.hud.outputScroller.scrollTop -
- this.hud.outputScroller.clientHeight
- );
- }
- event.preventDefault();
- break;
-
- case KeyCodes.DOM_VK_PAGE_DOWN:
- if (this.autocompletePopup.isOpen) {
- inputUpdated = this.complete(this.COMPLETE_PAGEDOWN);
- if (inputUpdated) {
- this._autocompletePopupNavigated = true;
- }
- } else {
- this.hud.outputScroller.scrollTop =
- Math.min(this.hud.outputScroller.scrollHeight,
- this.hud.outputScroller.scrollTop +
- this.hud.outputScroller.clientHeight
- );
- }
- event.preventDefault();
- break;
-
- case KeyCodes.DOM_VK_HOME:
- if (this.autocompletePopup.isOpen) {
- this.autocompletePopup.selectedIndex = 0;
- event.preventDefault();
- } else if (inputValue.length <= 0) {
- this.hud.outputScroller.scrollTop = 0;
- event.preventDefault();
- }
- break;
-
- case KeyCodes.DOM_VK_END:
- if (this.autocompletePopup.isOpen) {
- this.autocompletePopup.selectedIndex =
- this.autocompletePopup.itemCount - 1;
- event.preventDefault();
- } else if (inputValue.length <= 0) {
- this.hud.outputScroller.scrollTop =
- this.hud.outputScroller.scrollHeight;
- event.preventDefault();
- }
- break;
-
- case KeyCodes.DOM_VK_LEFT:
- if (this.autocompletePopup.isOpen || this.lastCompletion.value) {
- this.clearCompletion();
- }
- break;
-
- case KeyCodes.DOM_VK_RIGHT:
- let cursorAtTheEnd = this.inputNode.selectionStart ==
- this.inputNode.selectionEnd &&
- this.inputNode.selectionStart ==
- inputValue.length;
- let haveSuggestion = this.autocompletePopup.isOpen ||
- this.lastCompletion.value;
- let useCompletion = cursorAtTheEnd || this._autocompletePopupNavigated;
- if (haveSuggestion && useCompletion &&
- this.complete(this.COMPLETE_HINT_ONLY) &&
- this.lastCompletion.value &&
- this.acceptProposedCompletion()) {
- event.preventDefault();
- }
- if (this.autocompletePopup.isOpen) {
- this.clearCompletion();
- }
- break;
-
- case KeyCodes.DOM_VK_TAB:
- // Generate a completion and accept the first proposed value.
- if (this.complete(this.COMPLETE_HINT_ONLY) &&
- this.lastCompletion &&
- this.acceptProposedCompletion()) {
- event.preventDefault();
- } else if (this._inputChanged) {
- this.updateCompleteNode(l10n.getStr("Autocomplete.blank"));
- event.preventDefault();
- }
- break;
- default:
- break;
- }
- },
- /* eslint-enable complexity */
-
- /**
- * The inputNode "focus" event handler.
- * @private
- */
- _focusEventHandler: function() {
- this._inputChanged = false;
- },
-
- /**
- * Go up/down the history stack of input values.
- *
- * @param number direction
- * History navigation direction: HISTORY_BACK or HISTORY_FORWARD.
- *
- * @returns boolean
- * True if the input value changed, false otherwise.
- */
- historyPeruse: function(direction) {
- if (!this.history.length) {
- return false;
- }
-
- // Up Arrow key
- if (direction == HISTORY_BACK) {
- if (this.historyPlaceHolder <= 0) {
- return false;
- }
- let inputVal = this.history[--this.historyPlaceHolder];
-
- // Save the current input value as the latest entry in history, only if
- // the user is already at the last entry.
- // Note: this code does not store changes to items that are already in
- // history.
- if (this.historyPlaceHolder + 1 == this.historyIndex) {
- this.history[this.historyIndex] = this.getInputValue() || "";
- }
-
- this.setInputValue(inputVal);
- } else if (direction == HISTORY_FORWARD) {
- // Down Arrow key
- if (this.historyPlaceHolder >= (this.history.length - 1)) {
- return false;
- }
-
- let inputVal = this.history[++this.historyPlaceHolder];
- this.setInputValue(inputVal);
- } else {
- throw new Error("Invalid argument 0");
- }
-
- return true;
- },
-
- /**
- * Test for multiline input.
- *
- * @return boolean
- * True if CR or LF found in node value; else false.
- */
- hasMultilineInput: function() {
- return /[\r\n]/.test(this.getInputValue());
- },
-
- /**
- * Check if the caret is at a location that allows selecting the previous item
- * in history when the user presses the Up arrow key.
- *
- * @return boolean
- * True if the caret is at a location that allows selecting the
- * previous item in history when the user presses the Up arrow key,
- * otherwise false.
- */
- canCaretGoPrevious: function() {
- let node = this.inputNode;
- if (node.selectionStart != node.selectionEnd) {
- return false;
- }
-
- let multiline = /[\r\n]/.test(node.value);
- return node.selectionStart == 0 ? true :
- node.selectionStart == node.value.length && !multiline;
- },
-
- /**
- * Check if the caret is at a location that allows selecting the next item in
- * history when the user presses the Down arrow key.
- *
- * @return boolean
- * True if the caret is at a location that allows selecting the next
- * item in history when the user presses the Down arrow key, otherwise
- * false.
- */
- canCaretGoNext: function() {
- let node = this.inputNode;
- if (node.selectionStart != node.selectionEnd) {
- return false;
- }
-
- let multiline = /[\r\n]/.test(node.value);
- return node.selectionStart == node.value.length ? true :
- node.selectionStart == 0 && !multiline;
- },
-
- /**
- * Completes the current typed text in the inputNode. Completion is performed
- * only if the selection/cursor is at the end of the string. If no completion
- * is found, the current inputNode value and cursor/selection stay.
- *
- * @param int type possible values are
- * - this.COMPLETE_FORWARD: If there is more than one possible completion
- * and the input value stayed the same compared to the last time this
- * function was called, then the next completion of all possible
- * completions is used. If the value changed, then the first possible
- * completion is used and the selection is set from the current
- * cursor position to the end of the completed text.
- * If there is only one possible completion, then this completion
- * value is used and the cursor is put at the end of the completion.
- * - this.COMPLETE_BACKWARD: Same as this.COMPLETE_FORWARD but if the
- * value stayed the same as the last time the function was called,
- * then the previous completion of all possible completions is used.
- * - this.COMPLETE_PAGEUP: Scroll up one page if available or select the
- * first item.
- * - this.COMPLETE_PAGEDOWN: Scroll down one page if available or select
- * the last item.
- * - this.COMPLETE_HINT_ONLY: If there is more than one possible
- * completion and the input value stayed the same compared to the
- * last time this function was called, then the same completion is
- * used again. If there is only one possible completion, then
- * the this.getInputValue() is set to this value and the selection
- * is set from the current cursor position to the end of the
- * completed text.
- * @param function callback
- * Optional function invoked when the autocomplete properties are
- * updated.
- * @returns boolean true if there existed a completion for the current input,
- * or false otherwise.
- */
- complete: function(type, callback) {
- let inputNode = this.inputNode;
- let inputValue = this.getInputValue();
- let frameActor = this.getFrameActor(this.SELECTED_FRAME);
-
- // If the inputNode has no value, then don't try to complete on it.
- if (!inputValue) {
- this.clearCompletion();
- callback && callback(this);
- this.emit("autocomplete-updated");
- return false;
- }
-
- // Only complete if the selection is empty.
- if (inputNode.selectionStart != inputNode.selectionEnd) {
- this.clearCompletion();
- callback && callback(this);
- this.emit("autocomplete-updated");
- return false;
- }
-
- // Update the completion results.
- if (this.lastCompletion.value != inputValue ||
- frameActor != this._lastFrameActorId) {
- this._updateCompletionResult(type, callback);
- return false;
- }
-
- let popup = this.autocompletePopup;
- let accepted = false;
-
- if (type != this.COMPLETE_HINT_ONLY && popup.itemCount == 1) {
- this.acceptProposedCompletion();
- accepted = true;
- } else if (type == this.COMPLETE_BACKWARD) {
- popup.selectPreviousItem();
- } else if (type == this.COMPLETE_FORWARD) {
- popup.selectNextItem();
- } else if (type == this.COMPLETE_PAGEUP) {
- popup.selectPreviousPageItem();
- } else if (type == this.COMPLETE_PAGEDOWN) {
- popup.selectNextPageItem();
- }
-
- callback && callback(this);
- this.emit("autocomplete-updated");
- return accepted || popup.itemCount > 0;
- },
-
- /**
- * Update the completion result. This operation is performed asynchronously by
- * fetching updated results from the content process.
- *
- * @private
- * @param int type
- * Completion type. See this.complete() for details.
- * @param function [callback]
- * Optional, function to invoke when completion results are received.
- */
- _updateCompletionResult: function(type, callback) {
- let frameActor = this.getFrameActor(this.SELECTED_FRAME);
- if (this.lastCompletion.value == this.getInputValue() &&
- frameActor == this._lastFrameActorId) {
- return;
- }
-
- let requestId = gSequenceId();
- let cursor = this.inputNode.selectionStart;
- let input = this.getInputValue().substring(0, cursor);
- let cache = this._autocompleteCache;
-
- // If the current input starts with the previous input, then we already
- // have a list of suggestions and we just need to filter the cached
- // suggestions. When the current input ends with a non-alphanumeric
- // character we ask the server again for suggestions.
-
- // Check if last character is non-alphanumeric
- if (!/[a-zA-Z0-9]$/.test(input) || frameActor != this._lastFrameActorId) {
- this._autocompleteQuery = null;
- this._autocompleteCache = null;
- }
-
- if (this._autocompleteQuery && input.startsWith(this._autocompleteQuery)) {
- let filterBy = input;
- // Find the last non-alphanumeric other than _ or $ if it exists.
- let lastNonAlpha = input.match(/[^a-zA-Z0-9_$][a-zA-Z0-9_$]*$/);
- // If input contains non-alphanumerics, use the part after the last one
- // to filter the cache
- if (lastNonAlpha) {
- filterBy = input.substring(input.lastIndexOf(lastNonAlpha) + 1);
- }
-
- let newList = cache.sort().filter(function(l) {
- return l.startsWith(filterBy);
- });
-
- this.lastCompletion = {
- requestId: null,
- completionType: type,
- value: null,
- };
-
- let response = { matches: newList, matchProp: filterBy };
- this._receiveAutocompleteProperties(null, callback, response);
- return;
- }
-
- this._lastFrameActorId = frameActor;
-
- this.lastCompletion = {
- requestId: requestId,
- completionType: type,
- value: null,
- };
-
- let autocompleteCallback =
- this._receiveAutocompleteProperties.bind(this, requestId, callback);
-
- this.webConsoleClient.autocomplete(
- input, cursor, autocompleteCallback, frameActor);
- },
-
- /**
- * Handler for the autocompletion results. This method takes
- * the completion result received from the server and updates the UI
- * accordingly.
- *
- * @param number requestId
- * Request ID.
- * @param function [callback=null]
- * Optional, function to invoke when the completion result is received.
- * @param object message
- * The JSON message which holds the completion results received from
- * the content process.
- */
- _receiveAutocompleteProperties: function(requestId, callback, message) {
- let inputNode = this.inputNode;
- let inputValue = this.getInputValue();
- if (this.lastCompletion.value == inputValue ||
- requestId != this.lastCompletion.requestId) {
- return;
- }
- // Cache whatever came from the server if the last char is
- // alphanumeric or '.'
- let cursor = inputNode.selectionStart;
- let inputUntilCursor = inputValue.substring(0, cursor);
-
- if (requestId != null && /[a-zA-Z0-9.]$/.test(inputUntilCursor)) {
- this._autocompleteCache = message.matches;
- this._autocompleteQuery = inputUntilCursor;
- }
-
- let matches = message.matches;
- let lastPart = message.matchProp;
- if (!matches.length) {
- this.clearCompletion();
- callback && callback(this);
- this.emit("autocomplete-updated");
- return;
- }
-
- let items = matches.reverse().map(function(match) {
- return { preLabel: lastPart, label: match };
- });
-
- let popup = this.autocompletePopup;
- popup.setItems(items);
-
- let completionType = this.lastCompletion.completionType;
- this.lastCompletion = {
- value: inputValue,
- matchProp: lastPart,
- };
- if (items.length > 1 && !popup.isOpen) {
- let str = this.getInputValue().substr(0, this.inputNode.selectionStart);
- let offset = str.length - (str.lastIndexOf("\n") + 1) - lastPart.length;
- let x = offset * this._inputCharWidth;
- popup.openPopup(inputNode, x + this._chevronWidth);
- this._autocompletePopupNavigated = false;
- } else if (items.length < 2 && popup.isOpen) {
- popup.hidePopup();
- this._autocompletePopupNavigated = false;
- }
- if (items.length == 1) {
- popup.selectedIndex = 0;
- }
-
- this.onAutocompleteSelect();
-
- if (completionType != this.COMPLETE_HINT_ONLY && popup.itemCount == 1) {
- this.acceptProposedCompletion();
- } else if (completionType == this.COMPLETE_BACKWARD) {
- popup.selectPreviousItem();
- } else if (completionType == this.COMPLETE_FORWARD) {
- popup.selectNextItem();
- }
-
- callback && callback(this);
- this.emit("autocomplete-updated");
- },
-
- onAutocompleteSelect: function() {
- // Render the suggestion only if the cursor is at the end of the input.
- if (this.inputNode.selectionStart != this.getInputValue().length) {
- return;
- }
-
- let currentItem = this.autocompletePopup.selectedItem;
- if (currentItem && this.lastCompletion.value) {
- let suffix =
- currentItem.label.substring(this.lastCompletion.matchProp.length);
- this.updateCompleteNode(suffix);
- } else {
- this.updateCompleteNode("");
- }
- },
-
- /**
- * Clear the current completion information and close the autocomplete popup,
- * if needed.
- */
- clearCompletion: function() {
- this.autocompletePopup.clearItems();
- this.lastCompletion = { value: null };
- this.updateCompleteNode("");
- if (this.autocompletePopup.isOpen) {
- // Trigger a blur/focus of the JSTerm input to force screen readers to read the
- // value again.
- this.inputNode.blur();
- this.autocompletePopup.once("popup-closed", () => {
- this.inputNode.focus();
- });
- this.autocompletePopup.hidePopup();
- this._autocompletePopupNavigated = false;
- }
- },
-
- /**
- * Accept the proposed input completion.
- *
- * @return boolean
- * True if there was a selected completion item and the input value
- * was updated, false otherwise.
- */
- acceptProposedCompletion: function() {
- let updated = false;
-
- let currentItem = this.autocompletePopup.selectedItem;
- if (currentItem && this.lastCompletion.value) {
- let suffix =
- currentItem.label.substring(this.lastCompletion.matchProp.length);
- let cursor = this.inputNode.selectionStart;
- let value = this.getInputValue();
- this.setInputValue(value.substr(0, cursor) +
- suffix + value.substr(cursor));
- let newCursor = cursor + suffix.length;
- this.inputNode.selectionStart = this.inputNode.selectionEnd = newCursor;
- updated = true;
- }
-
- this.clearCompletion();
-
- return updated;
- },
-
- /**
- * Update the node that displays the currently selected autocomplete proposal.
- *
- * @param string suffix
- * The proposed suffix for the inputNode value.
- */
- updateCompleteNode: function(suffix) {
- // completion prefix = input, with non-control chars replaced by spaces
- let prefix = suffix ? this.getInputValue().replace(/[\S]/g, " ") : "";
- this.completeNode.value = prefix + suffix;
- },
- /**
- * Calculates the width and height of a single character of the input box.
- * This will be used in opening the popup at the correct offset.
- *
- * @private
- */
- _updateCharSize: function() {
- let doc = this.hud.document;
- let tempLabel = doc.createElementNS(XHTML_NS, "span");
- let style = tempLabel.style;
- style.position = "fixed";
- style.padding = "0";
- style.margin = "0";
- style.width = "auto";
- style.color = "transparent";
- WebConsoleUtils.copyTextStyles(this.inputNode, tempLabel);
- tempLabel.textContent = "x";
- doc.documentElement.appendChild(tempLabel);
- this._inputCharWidth = tempLabel.offsetWidth;
- tempLabel.remove();
- // Calculate the width of the chevron placed at the beginning of the input
- // box. Remove 4 more pixels to accomodate the padding of the popup.
- this._chevronWidth = +doc.defaultView.getComputedStyle(this.inputNode)
- .paddingLeft.replace(/[^0-9.]/g, "") - 4;
- },
-
- /**
- * Build the notification box as soon as needed.
- */
- getNotificationBox: function() {
- if (this._notificationBox) {
- return this._notificationBox;
- }
-
- let box = this.hud.document.getElementById("webconsole-notificationbox");
- if (box.tagName === "notificationbox") {
- // Here we are in the old console frontend (e.g. browser console), so we
- // can directly return the notificationbox.
- return box;
- }
-
- let toolbox = gDevTools.getToolbox(this.hud.owner.target);
-
- // Render NotificationBox and assign priority levels to it.
- this._notificationBox = Object.assign(
- toolbox.ReactDOM.render(toolbox.React.createElement(NotificationBox), box),
- PriorityLevels);
- return this._notificationBox;
- },
-
- /**
- * Destroy the sidebar.
- * @private
- */
- _sidebarDestroy: function() {
- if (this._variablesView) {
- this._variablesView.controller.releaseActors();
- this._variablesView = null;
- }
-
- if (this.sidebar) {
- this.sidebar.hide();
- this.sidebar.destroy();
- this.sidebar = null;
- }
-
- this.emit("sidebar-closed");
- },
-
- /**
- * Destroy the JSTerm object. Call this method to avoid memory leaks.
- */
- destroy: function() {
- this._sidebarDestroy();
-
- this.clearCompletion();
-
- if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) {
- this.webConsoleClient.clearNetworkRequests();
- this.hud.outputNode.innerHTML = "";
- } else {
- this.clearOutput();
- }
-
- this.autocompletePopup.destroy();
- this.autocompletePopup = null;
-
- if (this._onPaste) {
- this.inputNode.removeEventListener("paste", this._onPaste);
- this.inputNode.removeEventListener("drop", this._onPaste);
- this._onPaste = null;
- }
-
- this.inputNode.removeEventListener("keypress", this._keyPress);
- this.inputNode.removeEventListener("input", this._inputEventHandler);
- this.inputNode.removeEventListener("keyup", this._inputEventHandler);
- this.inputNode.removeEventListener("focus", this._focusEventHandler);
- this.hud.window.removeEventListener("blur", this._blurEventHandler);
-
- this.hud = null;
- },
-};
-
-function gSequenceId() {
- return gSequenceId.n++;
-}
-gSequenceId.n = 0;
-exports.gSequenceId = gSequenceId;
-
-/**
- * @see VariablesView.simpleValueEvalMacro
- */
-function simpleValueEvalMacro(item, currentString) {
- return VariablesView.simpleValueEvalMacro(item, currentString, "_self");
-}
-
-/**
- * @see VariablesView.overrideValueEvalMacro
- */
-function overrideValueEvalMacro(item, currentString) {
- return VariablesView.overrideValueEvalMacro(item, currentString, "_self");
-}
-
-/**
- * @see VariablesView.getterOrSetterEvalMacro
- */
-function getterOrSetterEvalMacro(item, currentString) {
- return VariablesView.getterOrSetterEvalMacro(item, currentString, "_self");
-}
-
-exports.JSTerm = JSTerm;
deleted file mode 100644
--- a/devtools/client/webconsole/old/moz.build
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
-
-DIRS += [
- 'net',
-]
-DevToolsModules(
- 'console-output.js',
- 'jsterm.js',
- 'webconsole.js',
-)
-with Files('**'):
- BUG_COMPONENT = ('Firefox', 'Developer Tools: Console')
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/.eslintrc.js
+++ /dev/null
@@ -1,20 +0,0 @@
-"use strict";
-
-module.exports = {
- "globals": {
- "Locale": true,
- "Document": true,
- "document": true,
- "Node": true,
- "Element": true,
- "MessageEvent": true,
- "BrowserLoader": true,
- "addEventListener": true,
- "DOMParser": true,
- "dispatchEvent": true,
- "setTimeout": true
- },
- "rules": {
- "no-unused-vars": ["error", {"args": "none"}],
- }
-};
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/cookies-tab.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const NetInfoGroupList = createFactory(require("./net-info-group-list"));
-
-/**
- * This template represents 'Cookies' tab displayed when the user
- * expands network log in the Console panel. It's responsible for rendering
- * sent and received cookies.
- */
-class CookiesTab extends Component {
- static get propTypes() {
- return {
- actions: PropTypes.shape({
- requestData: PropTypes.func.isRequired
- }),
- data: PropTypes.object.isRequired,
- };
- }
-
- componentDidMount() {
- let { actions, data } = this.props;
- let requestCookies = data.request.cookies;
- let responseCookies = data.response.cookies;
-
- // TODO: use async action objects as soon as Redux is in place
- if (!requestCookies || !requestCookies.length) {
- actions.requestData("requestCookies");
- }
-
- if (!responseCookies || !responseCookies.length) {
- actions.requestData("responseCookies");
- }
- }
-
- render() {
- let { data: file } = this.props;
- let requestCookies = file.request.cookies;
- let responseCookies = file.response.cookies;
-
- // The cookie panel displays two groups of cookies:
- // 1) Response Cookies
- // 2) Request Cookies
- let groups = [{
- key: "responseCookies",
- name: Locale.$STR("responseCookies"),
- params: responseCookies
- }, {
- key: "requestCookies",
- name: Locale.$STR("requestCookies"),
- params: requestCookies
- }];
-
- return (
- dom.div({className: "cookiesTabBox"},
- dom.div({className: "panelContent"},
- NetInfoGroupList({
- groups: groups
- })
- )
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = CookiesTab;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/headers-tab.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const NetInfoGroupList = createFactory(require("./net-info-group-list"));
-const Spinner = createFactory(require("./spinner"));
-
-/**
- * This template represents 'Headers' tab displayed when the user
- * expands network log in the Console panel. It's responsible for rendering
- * request and response HTTP headers.
- */
-class HeadersTab extends Component {
- static get propTypes() {
- return {
- actions: PropTypes.shape({
- requestData: PropTypes.func.isRequired
- }),
- data: PropTypes.object.isRequired,
- };
- }
-
- componentDidMount() {
- let { actions, data } = this.props;
- let requestHeaders = data.request.headers;
- let responseHeaders = data.response.headers;
-
- // Request headers if they are not available yet.
- // TODO: use async action objects as soon as Redux is in place
- if (!requestHeaders) {
- actions.requestData("requestHeaders");
- }
-
- if (!responseHeaders) {
- actions.requestData("responseHeaders");
- }
- }
-
- render() {
- let { data } = this.props;
- let requestHeaders = data.request.headers;
- let responseHeaders = data.response.headers;
-
- // TODO: Another groups to implement:
- // 1) Cached Headers
- // 2) Headers from upload stream
- let groups = [{
- key: "responseHeaders",
- name: Locale.$STR("responseHeaders"),
- params: responseHeaders
- }, {
- key: "requestHeaders",
- name: Locale.$STR("requestHeaders"),
- params: requestHeaders
- }];
-
- // If response headers are not available yet, display a spinner
- if (!responseHeaders || !responseHeaders.length) {
- groups[0].content = Spinner();
- }
-
- return (
- dom.div({className: "headersTabBox"},
- dom.div({className: "panelContent"},
- NetInfoGroupList({groups: groups})
- )
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = HeadersTab;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/moz.build
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DevToolsModules(
- 'cookies-tab.js',
- 'headers-tab.js',
- 'net-info-body.css',
- 'net-info-body.js',
- 'net-info-group-list.js',
- 'net-info-group.css',
- 'net-info-group.js',
- 'net-info-params.css',
- 'net-info-params.js',
- 'params-tab.js',
- 'post-tab.js',
- 'response-tab.css',
- 'response-tab.js',
- 'size-limit.css',
- 'size-limit.js',
- 'spinner.js',
- 'stacktrace-tab.js',
-)
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-body.css
+++ /dev/null
@@ -1,93 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/******************************************************************************/
-/* Network Info Body */
-
-.netInfoBody {
- margin: 10px 0 0 0;
- width: 100%;
- cursor: default;
- display: block;
-}
-
-.netInfoBody *:focus {
- outline: 0 !important;
-}
-
-.netInfoBody .panelContent {
- word-break: break-all;
-}
-
-/******************************************************************************/
-/* Network Info Body Tabs */
-
-.netInfoBody > .tabs {
- background-color: transparent;
- background-image: none;
- height: 100%;
-}
-
-.netInfoBody > .tabs .tabs-navigation {
- border-bottom-color: var(--net-border);
- background-color: transparent;
- text-decoration: none;
- padding-top: 3px;
- padding-left: 7px;
- padding-bottom: 1px;
- border-bottom: 1px solid var(--net-border);
-}
-
-.netInfoBody > .tabs .tabs-menu {
- display: table;
- list-style: none;
- padding: 0;
- margin: 0;
-}
-
-/* This is the trick that makes the tab bottom border invisible */
-.netInfoBody > .tabs .tabs-menu-item {
- position: relative;
- bottom: -2px;
- float: left;
-}
-
-.netInfoBody > .tabs .tabs-menu-item a {
- display: block;
- border: 1px solid transparent;
- text-decoration: none;
- padding: 5px 8px 4px 8px;;
- font-weight: bold;
- color: var(--theme-body-color);
- border-radius: 4px 4px 0 0;
-}
-
-.netInfoBody > .tabs .tab-panel {
- background-color: var(--theme-body-background);
- border: 1px solid transparent;
- border-top: none;
- padding: 10px;
- overflow: auto;
- height: calc(100% - 31px); /* minus the height of the tab bar */
-}
-
-.netInfoBody > .tabs .tab-panel > div,
-.netInfoBody > .tabs .tab-panel > div > div {
- height: 100%;
-}
-
-.netInfoBody > .tabs .tabs-menu-item.is-active a,
-.netInfoBody > .tabs .tabs-menu-item.is-active a:focus,
-.netInfoBody > .tabs .tabs-menu-item.is-active:hover a {
- background-color: var(--theme-body-background);
- border: 1px solid transparent;
- border-bottom-color: var(--theme-highlight-bluegrey);
- color: var(--theme-highlight-bluegrey);
-}
-
-.netInfoBody > .tabs .tabs-menu-item:hover a {
- border: 1px solid transparent;
- border-bottom: 1px solid var(--net-border);
- background-color: var(--theme-body-background);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-body.js
+++ /dev/null
@@ -1,196 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const { createFactories } = require("devtools/client/shared/react-utils");
-const { Tabs, TabPanel } = createFactories(require("devtools/client/shared/components/tabs/Tabs"));
-
-// Network
-const HeadersTab = createFactory(require("./headers-tab"));
-const ResponseTab = createFactory(require("./response-tab"));
-const ParamsTab = createFactory(require("./params-tab"));
-const CookiesTab = createFactory(require("./cookies-tab"));
-const PostTab = createFactory(require("./post-tab"));
-const StackTraceTab = createFactory(require("./stacktrace-tab"));
-const NetUtils = require("../utils/net");
-
-
-/**
- * This template renders the basic Network log info body. It's not
- * visible by default, the user needs to expand the network log
- * to see it.
- *
- * This is the set of tabs displaying details about network events:
- * 1) Headers - request and response headers
- * 2) Params - URL parameters
- * 3) Response - response body
- * 4) Cookies - request and response cookies
- * 5) Post - posted data
- */
-class NetInfoBody extends Component {
- static get propTypes() {
- return {
- tabActive: PropTypes.number.isRequired,
- actions: PropTypes.object.isRequired,
- data: PropTypes.shape({
- request: PropTypes.object.isRequired,
- response: PropTypes.object.isRequired
- }),
- // Service to enable the source map feature.
- sourceMapService: PropTypes.object,
- };
- }
-
- static get defaultProps() {
- return {
- tabActive: 0
- };
- }
-
- constructor(props) {
- super(props);
-
- this.state = {
- data: {
- request: {},
- response: {}
- },
- tabActive: props.tabActive,
- };
-
- this.onTabChanged = this.onTabChanged.bind(this);
- this.hasCookies = this.hasCookies.bind(this);
- this.hasStackTrace = this.hasStackTrace.bind(this);
- this.getTabPanels = this.getTabPanels.bind(this);
- }
-
- onTabChanged(index) {
- this.setState({tabActive: index});
- }
-
- hasCookies() {
- let {request, response} = this.state.data;
- return this.state.hasCookies ||
- NetUtils.getHeaderValue(request.headers, "Cookie") ||
- NetUtils.getHeaderValue(response.headers, "Set-Cookie");
- }
-
- hasStackTrace() {
- let {cause} = this.state.data;
- return cause && cause.stacktrace && cause.stacktrace.length > 0;
- }
-
- getTabPanels() {
- let { actions, sourceMapService } = this.props;
- let data = this.state.data;
- let {request} = data;
-
- // Flags for optional tabs. Some tabs are visible only if there
- // are data to display.
- let hasParams = request.queryString && request.queryString.length;
- let hasPostData = request.bodySize > 0;
-
- let panels = [];
-
- // Headers tab
- panels.push(
- TabPanel({
- id: "headers",
- className: "headers",
- key: "headers",
- title: Locale.$STR("netRequest.headers")},
- HeadersTab({data: data, actions: actions})
- )
- );
-
- // URL parameters tab
- if (hasParams) {
- panels.push(
- TabPanel({
- id: "params",
- className: "params",
- key: "params",
- title: Locale.$STR("netRequest.params")},
- ParamsTab({data: data, actions: actions})
- )
- );
- }
-
- // Posted data tab
- if (hasPostData) {
- panels.push(
- TabPanel({
- id: "post",
- className: "post",
- key: "post",
- title: Locale.$STR("netRequest.post")},
- PostTab({data: data, actions: actions})
- )
- );
- }
-
- // Response tab
- panels.push(
- TabPanel({
- id: "response",
- className: "response",
- key: "response",
- title: Locale.$STR("netRequest.response")},
- ResponseTab({data: data, actions: actions})
- )
- );
-
- // Cookies tab
- if (this.hasCookies()) {
- panels.push(
- TabPanel({
- id: "cookies",
- className: "cookies",
- key: "cookies",
- title: Locale.$STR("netRequest.cookies")},
- CookiesTab({
- data: data,
- actions: actions
- })
- )
- );
- }
-
- // Stacktrace tab
- if (this.hasStackTrace()) {
- panels.push(
- TabPanel({
- id: "stacktrace-tab",
- className: "stacktrace-tab",
- key: "stacktrace",
- title: Locale.$STR("netRequest.callstack")},
- StackTraceTab({
- data: data,
- actions: actions,
- sourceMapService: sourceMapService,
- })
- )
- );
- }
-
- return panels;
- }
-
- render() {
- let tabActive = this.state.tabActive;
- let tabPanels = this.getTabPanels();
- return (
- Tabs({
- tabActive: tabActive,
- onAfterChange: this.onTabChanged},
- tabPanels
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = NetInfoBody;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-group-list.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const NetInfoGroup = createFactory(require("./net-info-group"));
-
-/**
- * This template is responsible for rendering sections/groups inside tabs.
- * It's used e.g to display Response and Request headers as separate groups.
- */
-class NetInfoGroupList extends Component {
- static get propTypes() {
- return {
- groups: PropTypes.array.isRequired,
- };
- }
-
- render() {
- let groups = this.props.groups;
-
- // Filter out empty groups.
- groups = groups.filter(group => {
- return group && ((group.params && group.params.length) || group.content);
- });
-
- // Render groups
- groups = groups.map(group => {
- group.type = group.key;
- return NetInfoGroup(group);
- });
-
- return (
- dom.div({className: "netInfoGroupList"},
- groups
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = NetInfoGroupList;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-group.css
+++ /dev/null
@@ -1,68 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/******************************************************************************/
-/* Net Info Group */
-
-.netInfoBody .netInfoGroup {
- padding-bottom: 6px;
-}
-
-/* Last group doesn't need bottom padding */
-.netInfoBody .netInfoGroup:last-child {
- padding-bottom: 0;
-}
-
-.netInfoBody .netInfoGroup:last-child .netInfoGroupContent {
- padding-bottom: 0;
-}
-
-.netInfoBody .netInfoGroupTitle {
- cursor: pointer;
- font-weight: bold;
- -moz-user-select: none;
- cursor: pointer;
- padding-left: 3px;
-}
-
-.netInfoBody .netInfoGroupTwisty {
- background-image: url("chrome://devtools/skin/images/controls.png");
- background-size: 56px 28px;
- background-position: 0 -14px;
- background-repeat: no-repeat;
- width: 14px;
- height: 14px;
- cursor: pointer;
- display: inline-block;
- vertical-align: middle;
-}
-
-.netInfoBody .netInfoGroup.opened .netInfoGroupTwisty {
- background-position: -14px -14px;
-}
-
-/* Group content is expandable/collapsible by clicking on the title */
-.netInfoBody .netInfoGroupContent {
- padding-top: 7px;
- margin-top: 3px;
- padding-bottom: 14px;
- border-top: 1px solid var(--net-border);
- display: none;
-}
-
-/* Toggle group visibility */
-.netInfoBody .netInfoGroup.opened .netInfoGroupContent {
- display: block;
-}
-
-/******************************************************************************/
-/* Themes */
-
-.theme-dark .netInfoBody .netInfoGroup {
- color: var(--theme-body-color);
-}
-
-.theme-dark .netInfoBody .netInfoGroup .netInfoGroupTwisty {
- filter: invert(1);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-group.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const NetInfoParams = createFactory(require("./net-info-params"));
-
-/**
- * This template represents a group of data within a tab. For example,
- * Headers tab has two groups 'Request Headers' and 'Response Headers'
- * The Response tab can also have two groups 'Raw Data' and 'JSON'
- */
-class NetInfoGroup extends Component {
- static get propTypes() {
- return {
- type: PropTypes.string.isRequired,
- name: PropTypes.string.isRequired,
- params: PropTypes.array,
- content: PropTypes.element,
- open: PropTypes.bool
- };
- }
-
- static get defaultProps() {
- return {
- open: true,
- };
- }
-
- constructor(props) {
- super(props);
-
- this.state = {
- open: props.open,
- };
-
- this.onToggle = this.onToggle.bind(this);
- }
-
- onToggle(event) {
- this.setState({
- open: !this.state.open
- });
- }
-
- render() {
- let content = this.props.content;
-
- if (!content && this.props.params) {
- content = NetInfoParams({
- params: this.props.params
- });
- }
-
- let open = this.state.open;
- let className = open ? "opened" : "";
-
- return (
- dom.div({className: "netInfoGroup" + " " + className + " " +
- this.props.type},
- dom.span({
- className: "netInfoGroupTwisty",
- onClick: this.onToggle
- }),
- dom.span({
- className: "netInfoGroupTitle",
- onClick: this.onToggle},
- this.props.name
- ),
- dom.div({className: "netInfoGroupContent"},
- content
- )
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = NetInfoGroup;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-params.css
+++ /dev/null
@@ -1,23 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/******************************************************************************/
-/* Net Info Params */
-
-.netInfoBody .netInfoParamName {
- padding: 0 10px 0 0;
- font-weight: bold;
- vertical-align: top;
- text-align: right;
- white-space: nowrap;
-}
-
-.netInfoBody .netInfoParamValue {
- width: 100%;
- word-wrap: break-word;
-}
-
-.netInfoBody .netInfoParamValue > code {
- font-family: var(--monospace-font-family);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/net-info-params.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component } = require("devtools/client/shared/vendor/react");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-/**
- * This template renders list of parameters within a group.
- * It's essentially a list of name + value pairs.
- */
-class NetInfoParams extends Component {
- static get propTypes() {
- return {
- params: PropTypes.arrayOf(PropTypes.shape({
- name: PropTypes.string.isRequired,
- value: PropTypes.string.isRequired
- })).isRequired,
- };
- }
-
- render() {
- let params = this.props.params || [];
-
- params.sort(function (a, b) {
- return a.name > b.name ? 1 : -1;
- });
-
- let rows = [];
- params.forEach((param, index) => {
- rows.push(
- dom.tr({key: index},
- dom.td({className: "netInfoParamName"},
- dom.span({title: param.name}, param.name)
- ),
- dom.td({className: "netInfoParamValue"},
- dom.code({}, param.value)
- )
- )
- );
- });
-
- return (
- dom.table({cellPadding: 0, cellSpacing: 0},
- dom.tbody({},
- rows
- )
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = NetInfoParams;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/params-tab.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const NetInfoParams = createFactory(require("./net-info-params"));
-
-/**
- * This template represents 'Params' tab displayed when the user
- * expands network log in the Console panel. It's responsible for
- * displaying URL parameters (query string).
- */
-class ParamsTab extends Component {
- static get propTypes() {
- return {
- data: PropTypes.shape({
- request: PropTypes.object.isRequired
- })
- };
- }
-
- render() {
- let data = this.props.data;
-
- return (
- dom.div({className: "paramsTabBox"},
- dom.div({className: "panelContent"},
- NetInfoParams({params: data.request.queryString})
- )
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = ParamsTab;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/post-tab.js
+++ /dev/null
@@ -1,290 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-
-const TreeView =
- createFactory(require("devtools/client/shared/components/tree/TreeView"));
-
-const { REPS, MODE, parseURLEncodedText } =
- require("devtools/client/shared/components/reps/reps");
-const { Rep } = REPS;
-
-// Network
-const NetInfoParams = createFactory(require("./net-info-params"));
-const NetInfoGroupList = createFactory(require("./net-info-group-list"));
-const Spinner = createFactory(require("./spinner"));
-const SizeLimit = createFactory(require("./size-limit"));
-const NetUtils = require("../utils/net");
-const Json = require("../utils/json");
-
-/**
- * This template represents 'Post' tab displayed when the user
- * expands network log in the Console panel. It's responsible for
- * displaying posted data (HTTP post body).
- */
-class PostTab extends Component {
- static get propTypes() {
- return {
- data: PropTypes.shape({
- request: PropTypes.object.isRequired
- }),
- actions: PropTypes.object.isRequired
- };
- }
-
- constructor(props) {
- super(props);
- this.isJson = this.isJson.bind(this);
- this.parseJson = this.parseJson.bind(this);
- this.renderJson = this.renderJson.bind(this);
- this.parseXml = this.parseXml.bind(this);
- this.isXml = this.isXml.bind(this);
- this.renderXml = this.renderXml.bind(this);
- this.renderMultiPart = this.renderMultiPart.bind(this);
- this.renderUrlEncoded = this.renderUrlEncoded.bind(this);
- this.renderRawData = this.renderRawData.bind(this);
- }
-
- componentDidMount() {
- let { actions, data: file } = this.props;
-
- if (!file.request.postData) {
- // TODO: use async action objects as soon as Redux is in place
- actions.requestData("requestPostData");
- }
- }
-
- isJson(file) {
- let text = file.request.postData.text;
- let value = NetUtils.getHeaderValue(file.request.headers, "content-type");
- return Json.isJSON(value, text);
- }
-
- parseJson(file) {
- let postData = file.request.postData;
- if (!postData) {
- return null;
- }
-
- let jsonString = new String(postData.text);
- return Json.parseJSONString(jsonString);
- }
-
- /**
- * Render JSON post data as an expandable tree.
- */
- renderJson(file) {
- let text = file.request.postData.text;
- if (!text || isLongString(text)) {
- return null;
- }
-
- if (!this.isJson(file)) {
- return null;
- }
-
- let json = this.parseJson(file);
- if (!json) {
- return null;
- }
-
- return {
- key: "json",
- content: TreeView({
- columns: [{id: "value"}],
- object: json,
- mode: MODE.TINY,
- renderValue: props => Rep(Object.assign({}, props, {
- cropLimit: 50,
- })),
- }),
- name: Locale.$STR("jsonScopeName")
- };
- }
-
- parseXml(file) {
- let text = file.request.postData.text;
- if (isLongString(text)) {
- return null;
- }
-
- return NetUtils.parseXml({
- mimeType: NetUtils.getHeaderValue(file.request.headers, "content-type"),
- text: text,
- });
- }
-
- isXml(file) {
- if (isLongString(file.request.postData.text)) {
- return false;
- }
-
- let value = NetUtils.getHeaderValue(file.request.headers, "content-type");
- if (!value) {
- return false;
- }
-
- return NetUtils.isHTML(value);
- }
-
- renderXml(file) {
- let text = file.request.postData.text;
- if (!text || isLongString(text)) {
- return null;
- }
-
- if (!this.isXml(file)) {
- return null;
- }
-
- let doc = this.parseXml(file);
- if (!doc) {
- return null;
- }
-
- // Proper component for rendering XML should be used (see bug 1247392)
- return null;
- }
-
- /**
- * Multipart post data are parsed and nicely rendered
- * as an expandable tree of individual parts.
- */
- renderMultiPart(file) {
- let text = file.request.postData.text;
- if (!text || isLongString(text)) {
- return;
- }
-
- if (NetUtils.isMultiPartRequest(file)) {
- // TODO: render multi part request (bug: 1247423)
- }
- }
-
- /**
- * URL encoded post data are nicely rendered as a list
- * of parameters.
- */
- renderUrlEncoded(file) {
- let text = file.request.postData.text;
- if (!text || isLongString(text)) {
- return null;
- }
-
- if (!NetUtils.isURLEncodedRequest(file)) {
- return null;
- }
-
- let lines = text.split("\n");
- let params = parseURLEncodedText(lines[lines.length - 1]);
-
- return {
- key: "url-encoded",
- content: NetInfoParams({params: params}),
- name: Locale.$STR("netRequest.params")
- };
- }
-
- renderRawData(file) {
- let text = file.request.postData.text;
-
- let group;
-
- // The post body might reached the limit, so check if we are
- // dealing with a long string.
- if (typeof text == "object") {
- group = {
- key: "raw-longstring",
- name: Locale.$STR("netRequest.rawData"),
- content: dom.div({className: "netInfoResponseContent"},
- sanitize(text.initial),
- SizeLimit({
- actions: this.props.actions,
- data: file.request.postData,
- message: Locale.$STR("netRequest.sizeLimitMessage"),
- link: Locale.$STR("netRequest.sizeLimitMessageLink")
- })
- )
- };
- } else {
- group = {
- key: "raw",
- name: Locale.$STR("netRequest.rawData"),
- content: dom.div({className: "netInfoResponseContent"},
- sanitize(text)
- )
- };
- }
-
- return group;
- }
-
- render() {
- let { data: file } = this.props;
-
- if (file.discardRequestBody) {
- return dom.span({className: "netInfoBodiesDiscarded"},
- Locale.$STR("netRequest.requestBodyDiscarded")
- );
- }
-
- if (!file.request.postData) {
- return (
- Spinner()
- );
- }
-
- // Render post body data. The right representation of the data
- // is picked according to the content type.
- let groups = [];
- groups.push(this.renderUrlEncoded(file));
- // TODO: render multi part request (bug: 1247423)
- // groups.push(this.renderMultiPart(file));
- groups.push(this.renderJson(file));
- groups.push(this.renderXml(file));
- groups.push(this.renderRawData(file));
-
- // Filter out empty groups.
- groups = groups.filter(group => group);
-
- // The raw response is collapsed by default if a nice formatted
- // version is available.
- if (groups.length > 1) {
- groups[groups.length - 1].open = false;
- }
-
- return (
- dom.div({className: "postTabBox"},
- dom.div({className: "panelContent"},
- NetInfoGroupList({
- groups: groups
- })
- )
- )
- );
- }
-}
-
-// Helpers
-
-/**
- * Workaround for a "not well-formed" error that react
- * reports when there's multipart data passed to render.
- */
-function sanitize(text) {
- text = JSON.stringify(text);
- text = text.replace(/\\r\\n/g, "\r\n").replace(/\\"/g, "\"");
- return text.slice(1, text.length - 1);
-}
-
-function isLongString(text) {
- return typeof text == "object";
-}
-
-// Exports from this module
-module.exports = PostTab;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/response-tab.css
+++ /dev/null
@@ -1,21 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/******************************************************************************/
-/* Response Tab */
-
-.netInfoBody .netInfoBodiesDiscarded {
- font-style: italic;
- color: gray;
-}
-
-.netInfoBody .netInfoResponseContent {
- font-family: var(--monospace-font-family);
- word-wrap: break-word;
-}
-
-.netInfoBody .responseTabBox img {
- max-width: 300px;
- max-height: 300px;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/response-tab.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-
-// Reps
-const TreeView = createFactory(require("devtools/client/shared/components/tree/TreeView"));
-const { REPS, MODE } = require("devtools/client/shared/components/reps/reps");
-const { Rep } = REPS;
-
-// Network
-const SizeLimit = createFactory(require("./size-limit"));
-const NetInfoGroupList = createFactory(require("./net-info-group-list"));
-const Spinner = createFactory(require("./spinner"));
-const Json = require("../utils/json");
-const NetUtils = require("../utils/net");
-
-/**
- * This template represents 'Response' tab displayed when the user
- * expands network log in the Console panel. It's responsible for
- * rendering HTTP response body.
- *
- * In case of supported response mime-type (e.g. application/json,
- * text/xml, etc.), the response is parsed using appropriate parser
- * and rendered accordingly.
- */
-class ResponseTab extends Component {
- static get propTypes() {
- return {
- data: PropTypes.shape({
- request: PropTypes.object.isRequired,
- response: PropTypes.object.isRequired
- }),
- actions: PropTypes.object.isRequired
- };
- }
-
- constructor(props) {
- super(props);
- this.isJson = this.isJson.bind(this);
- this.parseJson = this.parseJson.bind(this);
- this.isImage = this.isImage.bind(this);
- this.isXml = this.isXml.bind(this);
- this.parseXml = this.parseXml.bind(this);
- this.renderJson = this.renderJson.bind(this);
- this.renderImage = this.renderImage.bind(this);
- this.renderXml = this.renderXml.bind(this);
- this.renderFormattedResponse = this.renderFormattedResponse.bind(this);
- this.renderRawResponse = this.renderRawResponse.bind(this);
- }
-
- componentDidMount() {
- let { actions, data: file } = this.props;
- let content = file.response.content;
-
- if (!content || typeof (content.text) == "undefined") {
- // TODO: use async action objects as soon as Redux is in place
- actions.requestData("responseContent");
- }
- }
-
- // Response Types
-
- isJson(content) {
- if (isLongString(content.text)) {
- return false;
- }
-
- return Json.isJSON(content.mimeType, content.text);
- }
-
- parseJson(file) {
- let content = file.response.content;
- if (isLongString(content.text)) {
- return null;
- }
-
- let jsonString = new String(content.text);
- return Json.parseJSONString(jsonString);
- }
-
- isImage(content) {
- if (isLongString(content.text)) {
- return false;
- }
-
- return NetUtils.isImage(content.mimeType);
- }
-
- isXml(content) {
- if (isLongString(content.text)) {
- return false;
- }
-
- return NetUtils.isHTML(content.mimeType);
- }
-
- parseXml(file) {
- let content = file.response.content;
- if (isLongString(content.text)) {
- return null;
- }
-
- return NetUtils.parseXml(content);
- }
-
- // Rendering
-
- renderJson(file) {
- let content = file.response.content;
- if (!this.isJson(content)) {
- return null;
- }
-
- let json = this.parseJson(file);
- if (!json) {
- return null;
- }
-
- return {
- key: "json",
- content: TreeView({
- columns: [{id: "value"}],
- object: json,
- mode: MODE.TINY,
- renderValue: props => Rep(Object.assign({}, props, {
- cropLimit: 50,
- })),
- }),
- name: Locale.$STR("jsonScopeName")
- };
- }
-
- renderImage(file) {
- let content = file.response.content;
- if (!this.isImage(content)) {
- return null;
- }
-
- let dataUri = "data:" + content.mimeType + ";base64," + content.text;
- return {
- key: "image",
- content: dom.img({src: dataUri}),
- name: Locale.$STR("netRequest.image")
- };
- }
-
- renderXml(file) {
- let content = file.response.content;
- if (!this.isXml(content)) {
- return null;
- }
-
- let doc = this.parseXml(file);
- if (!doc) {
- return null;
- }
-
- // Proper component for rendering XML should be used (see bug 1247392)
- return null;
- }
-
- /**
- * If full response text is available, let's try to parse and
- * present nicely according to the underlying format.
- */
- renderFormattedResponse(file) {
- let content = file.response.content;
- if (typeof content.text == "object") {
- return null;
- }
-
- let group = this.renderJson(file);
- if (group) {
- return group;
- }
-
- group = this.renderImage(file);
- if (group) {
- return group;
- }
-
- group = this.renderXml(file);
- if (group) {
- return group;
- }
-
- return null;
- }
-
- renderRawResponse(file) {
- let group;
- let content = file.response.content;
-
- // The response might reached the limit, so check if we are
- // dealing with a long string.
- if (typeof content.text == "object") {
- group = {
- key: "raw-longstring",
- name: Locale.$STR("netRequest.rawData"),
- content: dom.div({className: "netInfoResponseContent"},
- content.text.initial,
- SizeLimit({
- actions: this.props.actions,
- data: content,
- message: Locale.$STR("netRequest.sizeLimitMessage"),
- link: Locale.$STR("netRequest.sizeLimitMessageLink")
- })
- )
- };
- } else {
- group = {
- key: "raw",
- name: Locale.$STR("netRequest.rawData"),
- content: dom.div({className: "netInfoResponseContent"},
- content.text
- )
- };
- }
-
- return group;
- }
-
- /**
- * The response panel displays two groups:
- *
- * 1) Formatted response (in case of supported format, e.g. JSON, XML, etc.)
- * 2) Raw response data (always displayed if not discarded)
- */
- render() {
- let { data: file } = this.props;
-
- // If response bodies are discarded (not collected) let's just
- // display a info message indicating what to do to collect even
- // response bodies.
- if (file.discardResponseBody) {
- return dom.span({className: "netInfoBodiesDiscarded"},
- Locale.$STR("netRequest.responseBodyDiscarded")
- );
- }
-
- // Request for the response content is done only if the response
- // is not fetched yet - i.e. the `content.text` is undefined.
- // Empty content.text` can also be a valid response either
- // empty or not available yet.
- let content = file.response.content;
- if (!content || typeof (content.text) == "undefined") {
- return (
- Spinner()
- );
- }
-
- // Render response body data. The right representation of the data
- // is picked according to the content type.
- let groups = [];
- groups.push(this.renderFormattedResponse(file));
- groups.push(this.renderRawResponse(file));
-
- // Filter out empty groups.
- groups = groups.filter(group => group);
-
- // The raw response is collapsed by default if a nice formatted
- // version is available.
- if (groups.length > 1) {
- groups[1].open = false;
- }
-
- return (
- dom.div({className: "responseTabBox"},
- dom.div({className: "panelContent"},
- NetInfoGroupList({
- groups: groups
- })
- )
- )
- );
- }
-}
-
-// Helpers
-
-function isLongString(text) {
- return typeof text == "object";
-}
-
-// Exports from this module
-module.exports = ResponseTab;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/size-limit.css
+++ /dev/null
@@ -1,15 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/******************************************************************************/
-/* Response Size Limit */
-
-.netInfoBody .netInfoSizeLimit {
- font-weight: bold;
- padding-top: 10px;
-}
-
-.netInfoBody .netInfoSizeLimit .objectLink {
- color: var(--theme-highlight-blue);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/size-limit.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component } = require("devtools/client/shared/vendor/react");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-
-/**
- * This template represents a size limit notification message
- * used e.g. in the Response tab when response body exceeds
- * size limit. The message contains a link allowing the user
- * to fetch the rest of the data from the backend (debugger server).
- */
-class SizeLimit extends Component {
- static get propTypes() {
- return {
- data: PropTypes.object.isRequired,
- message: PropTypes.string.isRequired,
- link: PropTypes.string.isRequired,
- actions: PropTypes.shape({
- resolveString: PropTypes.func.isRequired
- }),
- };
- }
-
- constructor(props) {
- super(props);
- this.onClickLimit = this.onClickLimit.bind(this);
- }
-
- // Event Handlers
-
- onClickLimit(event) {
- let actions = this.props.actions;
- let content = this.props.data;
-
- actions.resolveString(content, "text");
- }
-
- // Rendering
-
- render() {
- let message = this.props.message;
- let link = this.props.link;
- let reLink = /^(.*)\{\{link\}\}(.*$)/;
- let m = message.match(reLink);
-
- return (
- dom.div({className: "netInfoSizeLimit"},
- dom.span({}, m[1]),
- dom.a({
- className: "objectLink",
- onClick: this.onClickLimit},
- link
- ),
- dom.span({}, m[2])
- )
- );
- }
-}
-
-// Exports from this module
-module.exports = SizeLimit;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/spinner.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component } = require("devtools/client/shared/vendor/react");
-const dom = require("devtools/client/shared/vendor/react-dom-factories");
-
-/**
- * This template represents a throbber displayed when the UI
- * is waiting for data coming from the backend (debugging server).
- */
-class Spinner extends Component {
- render() {
- return (
- dom.div({className: "devtools-throbber"})
- );
- }
-}
-
-// Exports from this module
-module.exports = Spinner;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/components/stacktrace-tab.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { Component, createFactory } = require("devtools/client/shared/vendor/react");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-const StackTrace =
- createFactory(require("devtools/client/shared/components/StackTrace"));
-
-class StackTraceTab extends Component {
- static get propTypes() {
- return {
- data: PropTypes.object.isRequired,
- actions: PropTypes.shape({
- onViewSourceInDebugger: PropTypes.func.isRequired
- }),
- // Service to enable the source map feature.
- sourceMapService: PropTypes.object,
- };
- }
-
- render() {
- let { stacktrace } = this.props.data.cause;
- let { actions, sourceMapService } = this.props;
- let onViewSourceInDebugger = actions.onViewSourceInDebugger.bind(actions);
-
- return StackTrace({ stacktrace, onViewSourceInDebugger, sourceMapService });
- }
-}
-
-// Exports from this module
-module.exports = StackTraceTab;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/data-provider.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const promise = require("promise");
-const defer = require("devtools/shared/defer");
-
-/**
- * Map of pending requests. Used mainly by tests to wait
- * till things are ready.
- */
-var promises = new Map();
-
-/**
- * This object is used to fetch network data from the backend.
- * Communication with the chrome scope is based on message
- * exchange.
- */
-var DataProvider = {
- hasPendingRequests: function () {
- return promises.size > 0;
- },
-
- requestData: function (client, actor, method) {
- let key = actor + ":" + method;
- let p = promises.get(key);
- if (p) {
- return p;
- }
-
- let deferred = defer();
- let realMethodName = "get" + method.charAt(0).toUpperCase() +
- method.slice(1);
-
- if (!client[realMethodName]) {
- return null;
- }
-
- client[realMethodName](actor, response => {
- promises.delete(key);
- deferred.resolve(response);
- });
-
- promises.set(key, deferred.promise);
- return deferred.promise;
- },
-
- resolveString: function (client, stringGrip) {
- let key = stringGrip.actor + ":getString";
- let p = promises.get(key);
- if (p) {
- return p;
- }
-
- p = client.getString(stringGrip).then(result => {
- promises.delete(key);
- return result;
- });
-
- promises.set(key, p);
- return p;
- },
-};
-
-// Exports from this module
-module.exports = DataProvider;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/main.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-/* global BrowserLoader */
-
-// Initialize module loader and load all modules of the new inline
-// preview feature. The entire code-base doesn't need any extra
-// privileges and runs entirely in content scope.
-const rootUrl = "resource://devtools/client/webconsole/old/net/";
-const require = BrowserLoader({
- baseURI: rootUrl,
- window}).require;
-
-const NetRequest = require("./net-request");
-const { loadSheet } = require("devtools/shared/layout/utils");
-
-// Localization
-const {LocalizationHelper} = require("devtools/shared/l10n");
-const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties");
-
-// Stylesheets
-var styleSheets = [
- "resource://devtools/client/jsonview/css/toolbar.css",
- "resource://devtools/client/shared/components/tree/TreeView.css",
- "resource://devtools/client/shared/components/reps.css",
- "resource://devtools/client/webconsole/old/net/net-request.css",
- "resource://devtools/client/webconsole/old/net/components/size-limit.css",
- "resource://devtools/client/webconsole/old/net/components/net-info-body.css",
- "resource://devtools/client/webconsole/old/net/components/net-info-group.css",
- "resource://devtools/client/webconsole/old/net/components/net-info-params.css",
- "resource://devtools/client/webconsole/old/net/components/response-tab.css"
-];
-
-// Load theme stylesheets into the Console frame. This should be
-// done automatically by UI Components as soon as we have consensus
-// on the right CSS strategy FIXME.
-// It would also be nice to include them using @import.
-styleSheets.forEach(url => {
- loadSheet(window, url, "author");
-});
-
-// Localization API used by React components
-// accessing strings from *.properties file.
-// Example:
-// let localizedString = Locale.$STR('string-key');
-//
-// Resources:
-// http://l20n.org/
-// https://github.com/yahoo/react-intl
-this.Locale = {
- $STR: key => {
- try {
- return L10N.getStr(key);
- } catch (err) {
- console.error(key + ": " + err);
- }
- return key;
- }
-};
-
-// List of NetRequest instances represents the state.
-// As soon as Redux is in place it should be maintained using a reducer.
-var netRequests = new Map();
-
-/**
- * This function handles network events received from the backend. It's
- * executed from within the webconsole.js
- */
-function onNetworkEvent(log) {
- // The 'from' field is set only in case of a 'networkEventUpdate' packet.
- // The initial 'networkEvent' packet uses 'actor'.
- // Check if NetRequest object is already created for this event actor and
- // if there is none make sure to create one.
- let response = log.response;
- let netRequest = response.from ? netRequests.get(response.from) : null;
- if (!netRequest && !log.update) {
- netRequest = new NetRequest(log);
- netRequests.set(response.actor, netRequest);
- }
-
- if (!netRequest) {
- return;
- }
-
- if (log.update) {
- netRequest.updateBody(response);
- }
-}
-
-// Make the 'onNetworkEvent' accessible from chrome (see webconsole.js)
-this.NetRequest = {
- onNetworkEvent: onNetworkEvent
-};
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/moz.build
+++ /dev/null
@@ -1,19 +0,0 @@
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DIRS += [
- 'components',
- 'utils'
-]
-
-DevToolsModules(
- 'data-provider.js',
- 'main.js',
- 'net-request.css',
- 'net-request.js',
-)
-
-XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
-BROWSER_CHROME_MANIFESTS += ['test/mochitest/browser.ini']
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/net-request.css
+++ /dev/null
@@ -1,31 +0,0 @@
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/******************************************************************************/
-/* General */
-
-:root {
- --net-border: #d7d7d7;
-}
-
-:root.theme-dark {
- --net-border: #5f7387;
-}
-
-/******************************************************************************/
-/* Network log */
-
-/* No background if a Net log is opened */
-.netRequest.message.opened,
-.netRequest.message.opened:hover {
- background: transparent !important;
-}
-
-/******************************************************************************/
-/* Themes */
-
-.theme-dark .netRequest.opened:hover,
-.theme-dark .netRequest.opened {
- background: transparent;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/net-request.js
+++ /dev/null
@@ -1,324 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-// React
-const React = require("devtools/client/shared/vendor/react");
-const ReactDOM = require("devtools/client/shared/vendor/react-dom");
-
-// Reps
-const { parseURLParams } = require("devtools/client/shared/components/reps/reps");
-
-// Network
-const { cancelEvent, isLeftClick } = require("./utils/events");
-const NetInfoBody = React.createFactory(require("./components/net-info-body"));
-const DataProvider = require("./data-provider");
-
-// Constants
-const XHTML_NS = "http://www.w3.org/1999/xhtml";
-
-/**
- * This object represents a network log in the Console panel (and in the
- * Network panel in the future).
- * It's associated with an existing log and so, also with an existing
- * element in the DOM.
- *
- * The object neither render no request for more data by default. It only
- * reqisters a click listener to the associated log entry (a network event)
- * and changes the class attribute of the log entry, so a twisty icon
- * appears to indicates that there are more details displayed if the
- * log entry is expanded.
- *
- * When the user expands the log, data are requested from the backend
- * and rendered directly within the Console iframe.
- */
-function NetRequest(log) {
- this.initialize(log);
-}
-
-NetRequest.prototype = {
- initialize: function (log) {
- this.client = log.consoleFrame.webConsoleClient;
- this.owner = log.consoleFrame.owner;
-
- // 'this.file' field is following HAR spec.
- // http://www.softwareishard.com/blog/har-12-spec/
- this.file = log.response;
- this.parentNode = log.node;
- this.file.request.queryString = parseURLParams(this.file.request.url);
- this.hasCookies = false;
-
- // Map of fetched responses (to avoid unnecessary RDP round trip).
- this.cachedResponses = new Map();
-
- let doc = this.parentNode.ownerDocument;
- let twisty = doc.createElementNS(XHTML_NS, "a");
- twisty.className = "theme-twisty";
- twisty.href = "#";
-
- let messageBody = this.parentNode.querySelector(".message-body-wrapper");
- this.parentNode.insertBefore(twisty, messageBody);
- this.parentNode.setAttribute("collapsible", true);
-
- this.parentNode.classList.add("netRequest");
-
- // Register a click listener.
- this.addClickListener();
- },
-
- addClickListener: function () {
- // Add an event listener to toggle the expanded state when clicked.
- // The event bubbling is canceled if the user clicks on the log
- // itself (not on the expanded body), so opening of the default
- // modal dialog is avoided.
- this.parentNode.addEventListener("click", (event) => {
- if (!isLeftClick(event)) {
- return;
- }
-
- // Clicking on the toggle button or the method expands/collapses
- // the body with HTTP details.
- let classList = event.originalTarget.classList;
- if (!(classList.contains("theme-twisty") ||
- classList.contains("method"))) {
- return;
- }
-
- // Alright, the user is clicking fine, let's open HTTP details!
- this.onToggleBody(event);
-
- // Avoid the default modal dialog
- cancelEvent(event);
- }, true);
- },
-
- onToggleBody: function (event) {
- let target = event.currentTarget;
- let logRow = target.closest(".netRequest");
- logRow.classList.toggle("opened");
-
- let twisty = this.parentNode.querySelector(".theme-twisty");
- if (logRow.classList.contains("opened")) {
- twisty.setAttribute("open", true);
- } else {
- twisty.removeAttribute("open");
- }
-
- let isOpen = logRow.classList.contains("opened");
- if (isOpen) {
- this.renderBody();
- } else {
- this.closeBody();
- }
- },
-
- updateCookies: function(method, response) {
- // TODO: This code will be part of a reducer.
- let result;
- if (response.cookies > 0 &&
- ["requestCookies", "responseCookies"].includes(method)) {
- this.hasCookies = true;
- this.refresh();
- }
- },
-
- /**
- * Executed when 'networkEventUpdate' is received from the backend.
- */
- updateBody: function (response) {
- // 'networkEventUpdate' event indicates that there are new data
- // available on the backend. The following logic checks the response
- // cache and if this data has been already requested before they
- // need to be updated now (re-requested).
- let method = response.updateType;
- this.updateCookies(method, response);
- if (this.cachedResponses.get(method)) {
- this.cachedResponses.delete(method);
- this.requestData(method);
- }
- },
-
- /**
- * Close network inline preview body.
- */
- closeBody: function () {
- this.netInfoBodyBox.remove();
- },
-
- /**
- * Render network inline preview body.
- */
- renderBody: function () {
- let messageBody = this.parentNode.querySelector(".message-body-wrapper");
-
- // Create box for all markup rendered by ReactJS. Since we are
- // rendering within webconsole.xul (i.e. XUL document) we need
- // to explicitly specify XHTML namespace.
- let doc = messageBody.ownerDocument;
- this.netInfoBodyBox = doc.createElementNS(XHTML_NS, "div");
- this.netInfoBodyBox.classList.add("netInfoBody");
- messageBody.appendChild(this.netInfoBodyBox);
-
- // As soon as Redux is in place state and actions will come from
- // separate modules.
- let body = NetInfoBody({
- actions: this,
- sourceMapService: this.owner.sourceMapURLService,
- });
-
- // Render net info body!
- this.body = ReactDOM.render(body, this.netInfoBodyBox);
-
- this.refresh();
- },
-
- /**
- * Render top level ReactJS component.
- */
- refresh: function () {
- if (!this.netInfoBodyBox) {
- return;
- }
-
- // TODO: As soon as Redux is in place there will be reducer
- // computing a new state.
- let newState = Object.assign({}, this.body.state, {
- data: this.file,
- hasCookies: this.hasCookies
- });
-
- this.body.setState(newState);
- },
-
- // Communication with the backend
-
- requestData: function (method) {
- // If the response has already been received bail out.
- let response = this.cachedResponses.get(method);
- if (response) {
- return;
- }
-
- // Set an attribute indicating that this net log is waiting for
- // data coming from the backend. Intended mainly for tests.
- this.parentNode.setAttribute("loading", "true");
-
- let actor = this.file.actor;
- DataProvider.requestData(this.client, actor, method).then(args => {
- this.cachedResponses.set(method, args);
- this.onRequestData(method, args);
-
- if (!DataProvider.hasPendingRequests()) {
- this.parentNode.removeAttribute("loading");
-
- // Fire an event indicating that all pending requests for
- // data from the backend has finished. Intended for tests.
- // Do it asynchronously so, it's done after all handlers
- // for the current promise are executed.
- setTimeout(() => {
- let event = document.createEvent("Event");
- event.initEvent("netlog-no-pending-requests", true, true);
- this.parentNode.dispatchEvent(event);
- });
- }
- });
- },
-
- onRequestData: function (method, response) {
- // TODO: This code will be part of a reducer.
- let result;
- switch (method) {
- case "requestHeaders":
- result = this.onRequestHeaders(response);
- break;
- case "responseHeaders":
- result = this.onResponseHeaders(response);
- break;
- case "requestCookies":
- result = this.onRequestCookies(response);
- break;
- case "responseCookies":
- result = this.onResponseCookies(response);
- break;
- case "responseContent":
- result = this.onResponseContent(response);
- break;
- case "requestPostData":
- result = this.onRequestPostData(response);
- break;
- }
-
- result.then(() => {
- this.refresh();
- });
- },
-
- onRequestHeaders: function (response) {
- this.file.request.headers = response.headers;
-
- return this.resolveHeaders(this.file.request.headers);
- },
-
- onResponseHeaders: function (response) {
- this.file.response.headers = response.headers;
-
- return this.resolveHeaders(this.file.response.headers);
- },
-
- onResponseContent: function (response) {
- let content = response.content;
-
- for (let p in content) {
- this.file.response.content[p] = content[p];
- }
-
- return Promise.resolve();
- },
-
- onRequestPostData: function (response) {
- this.file.request.postData = response.postData;
- return Promise.resolve();
- },
-
- onRequestCookies: function (response) {
- this.file.request.cookies = response.cookies;
- return this.resolveHeaders(this.file.request.cookies);
- },
-
- onResponseCookies: function (response) {
- this.file.response.cookies = response.cookies;
- return this.resolveHeaders(this.file.response.cookies);
- },
-
- onViewSourceInDebugger: function (frame) {
- this.owner.viewSourceInDebugger(frame.source, frame.line);
- },
-
- resolveHeaders: function (headers) {
- let promises = [];
-
- for (let header of headers) {
- if (typeof header.value == "object") {
- promises.push(this.resolveString(header.value).then(value => {
- header.value = value;
- }));
- }
- }
-
- return Promise.all(promises);
- },
-
- resolveString: function (object, propName) {
- let stringGrip = object[propName];
- if (typeof stringGrip == "object") {
- DataProvider.resolveString(this.client, stringGrip).then(args => {
- object[propName] = args;
- this.refresh();
- });
- }
- }
-};
-
-// Exports from this module
-module.exports = NetRequest;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/.eslintrc.js
+++ /dev/null
@@ -1,6 +0,0 @@
-"use strict";
-
-module.exports = {
- // Extend from the shared list of defined globals for mochitests.
- "extends": "../../../../../../.eslintrc.mochitests.js",
-};
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser.ini
+++ /dev/null
@@ -1,23 +0,0 @@
-[DEFAULT]
-tags = devtools
-subsuite = devtools
-support-files =
- head.js
- page_basic.html
- test.json
- test.json^headers^
- test-cookies.json
- test-cookies.json^headers^
- test.txt
- test.xml
- test.xml^headers^
- !/devtools/client/shared/test/frame-script-utils.js
- !/devtools/client/shared/test/shared-head.js
- !/devtools/client/webconsole/old/test/head.js
-
-[browser_net_basic.js]
-[browser_net_cookies.js]
-[browser_net_headers.js]
-[browser_net_params.js]
-[browser_net_post.js]
-[browser_net_response.js]
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser_net_basic.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
-const JSON_XHR_URL = URL_ROOT + "test.json";
-
-/**
- * Basic test that generates XHR in the content and
- * checks the related log in the Console panel can
- * be expanded.
- */
-add_task(async function () {
- info("Test XHR Spy basic started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: JSON_XHR_URL
- });
-
- ok(netInfoBody, "The network details must be available");
-
- // There should be at least two tabs: Headers and Response
- ok(netInfoBody.querySelector(".tabs .tabs-menu-item.headers"),
- "Headers tab must be available");
- ok(netInfoBody.querySelector(".tabs .tabs-menu-item.response"),
- "Response tab must be available");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser_net_cookies.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
-const JSON_XHR_URL = URL_ROOT + "test-cookies.json";
-
-/**
- * This test generates XHR requests in the page, expands
- * networks details in the Console panel and checks that
- * Cookies are properly displayed.
- */
-add_task(async function () {
- info("Test XHR Spy cookies started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: JSON_XHR_URL
- });
-
- // Select "Cookies" tab
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "cookies");
-
- let requestCookieName = tabBody.querySelector(
- ".netInfoGroup.requestCookies .netInfoParamName > span[title='bar']");
-
- // Verify request cookies (name and value)
- ok(requestCookieName, "Request Cookie name must exist");
- is(requestCookieName.textContent, "bar",
- "The cookie name must have proper value");
-
- let requestCookieValue = requestCookieName.parentNode.nextSibling;
- ok(requestCookieValue, "Request Cookie value must exist");
- is(requestCookieValue.textContent, "foo",
- "The cookie value must have proper value");
-
- let responseCookieName = tabBody.querySelector(
- ".netInfoGroup.responseCookies .netInfoParamName > span[title='test']");
-
- // Verify response cookies (name and value)
- ok(responseCookieName, "Response Cookie name must exist");
- is(responseCookieName.textContent, "test",
- "The cookie name must have proper value");
-
- let responseCookieValue = responseCookieName.parentNode.nextSibling;
- ok(responseCookieValue, "Response Cookie value must exist");
- is(responseCookieValue.textContent, "abc",
- "The cookie value must have proper value");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser_net_headers.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
-const JSON_XHR_URL = URL_ROOT + "test.json";
-
-/**
- * This test generates XHR requests in the page, expands
- * networks details in the Console panel and checks that
- * HTTP headers are there.
- */
-add_task(async function () {
- // Disable rcwn to make cache behavior deterministic.
- await pushPref("network.http.rcwn.enabled", false);
-
- info("Test XHR Spy headers started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: JSON_XHR_URL
- });
-
- // Select "Headers" tab
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "headers");
- let paramName = tabBody.querySelector(
- ".netInfoParamName > span[title='content-type']");
-
- // Verify "Content-Type" header (name and value)
- ok(paramName, "Header name must exist");
- is(paramName.textContent, "content-type",
- "The header name must have proper value");
-
- let paramValue = paramName.parentNode.nextSibling;
- ok(paramValue, "Header value must exist");
- is(paramValue.textContent, "application/json; charset=utf-8",
- "The header value must have proper value");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser_net_params.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
-const JSON_XHR_URL = URL_ROOT + "test.json";
-
-/**
- * This test generates XHR requests in the page, expands
- * networks details in the Console panel and checks that
- * HTTP parameters (query string) are there.
- */
-add_task(async function () {
- info("Test XHR Spy params started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: JSON_XHR_URL,
- queryString: "?foo=bar"
- });
-
- // Check headers
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "params");
-
- let paramName = tabBody.querySelector(
- ".netInfoParamName > span[title='foo']");
-
- // Verify "Content-Type" header (name and value)
- ok(paramName, "Header name must exist");
- is(paramName.textContent, "foo",
- "The param name must have proper value");
-
- let paramValue = paramName.parentNode.nextSibling;
- ok(paramValue, "param value must exist");
- is(paramValue.textContent, "bar",
- "The param value must have proper value");
-});
-
-/**
- * Test URL parameters with the same name.
- */
-add_task(async function () {
- info("Test XHR Spy params started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: JSON_XHR_URL,
- queryString: "?box[]=123&box[]=456"
- });
-
- // Check headers
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "params");
-
- let params = tabBody.querySelectorAll(
- ".netInfoParamName > span[title='box[]']");
- is(params.length, 2, "Two URI parameters must exist");
-
- let values = tabBody.querySelectorAll(
- ".netInfoParamValue > code");
- is(values[0].textContent, 123, "First value must match");
- is(values[1].textContent, 456, "Second value must match");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser_net_post.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
-const JSON_XHR_URL = URL_ROOT + "test.json";
-
-const plainPostBody = "test-data";
-const jsonData = "{\"bar\": \"baz\"}";
-const jsonRendered = "bar\"baz\"";
-const xmlPostBody = "<xml><name>John</name></xml>";
-
-/**
- * This test generates XHR requests in the page, expands
- * networks details in the Console panel and checks that
- * Post data are properly rendered.
- */
-add_task(async function () {
- info("Test XHR Spy post plain body started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "POST",
- url: JSON_XHR_URL,
- body: plainPostBody
- });
-
- // Check post body data
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "post");
- let postContent = tabBody.querySelector(
- ".netInfoGroup.raw.opened .netInfoGroupContent");
- is(postContent.textContent, plainPostBody,
- "Post body must be properly rendered");
-});
-
-add_task(async function () {
- info("Test XHR Spy post JSON body started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "POST",
- url: JSON_XHR_URL,
- body: jsonData,
- requestHeaders: [{
- name: "Content-Type",
- value: "application/json"
- }]
- });
-
- // Check post body data
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "post");
- let postContent = tabBody.querySelector(
- ".netInfoGroup.json.opened .netInfoGroupContent");
- is(postContent.textContent, jsonRendered,
- "Post body must be properly rendered");
-
- let rawPostContent = tabBody.querySelector(
- ".netInfoGroup.raw.opened .netInfoGroupContent");
- ok(!rawPostContent, "Raw response group must be collapsed");
-});
-
-add_task(async function () {
- info("Test XHR Spy post XML body started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "POST",
- url: JSON_XHR_URL,
- body: xmlPostBody,
- requestHeaders: [{
- name: "Content-Type",
- value: "application/xml"
- }]
- });
-
- // Check post body data
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "post");
- let rawPostContent = tabBody.querySelector(
- ".netInfoGroup.raw.opened .netInfoGroupContent");
- is(rawPostContent.textContent, xmlPostBody,
- "Raw response group must not be collapsed");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/browser_net_response.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
-const TEXT_XHR_URL = URL_ROOT + "test.txt";
-const JSON_XHR_URL = URL_ROOT + "test.json";
-const XML_XHR_URL = URL_ROOT + "test.xml";
-
-const textResponseBody = "this is a response";
-const jsonResponseBody = "name\"John\"";
-
-// Individual tests below generate XHR request in the page, expand
-// network details in the Console panel and checks various types
-// of response bodies.
-
-/**
- * Validate plain text response
- */
-add_task(async function () {
- info("Test XHR Spy respone plain body started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: TEXT_XHR_URL,
- });
-
- // Check response body data
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "response");
- let responseContent = tabBody.querySelector(
- ".netInfoGroup.raw.opened .netInfoGroupContent");
-
- ok(responseContent.textContent.indexOf(textResponseBody) > -1,
- "Response body must be properly rendered");
-});
-
-/**
- * Validate XML response
- */
-add_task(async function () {
- info("Test XHR Spy response XML body started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: XML_XHR_URL,
- });
-
- // Check response body data
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "response");
- let rawResponseContent = tabBody.querySelector(
- ".netInfoGroup.raw.opened .netInfoGroupContent");
- ok(rawResponseContent, "Raw response group must not be collapsed");
-});
-
-/**
- * Validate JSON response
- */
-add_task(async function () {
- info("Test XHR Spy response JSON body started");
-
- let {hud} = await addTestTab(TEST_PAGE_URL);
-
- let netInfoBody = await executeAndInspectXhr(hud, {
- method: "GET",
- url: JSON_XHR_URL,
- });
-
- // Check response body data
- let tabBody = await selectNetInfoTab(hud, netInfoBody, "response");
- let responseContent = tabBody.querySelector(
- ".netInfoGroup.json .netInfoGroupContent");
-
- is(responseContent.textContent, jsonResponseBody,
- "Response body must be properly rendered");
-
- let rawResponseContent = tabBody.querySelector(
- ".netInfoGroup.raw.opened .netInfoGroupContent");
- ok(!rawResponseContent, "Raw response group must be collapsed");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/head.js
+++ /dev/null
@@ -1,201 +0,0 @@
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-/* eslint no-unused-vars: [2, {"vars": "local", "args": "none"}] */
-/* import-globals-from ../../../test/head.js */
-
-"use strict";
-
-// Load Web Console head.js, it implements helper console test API
-Services.scriptloader.loadSubScript(
- "chrome://mochitests/content/browser/devtools/client/webconsole/old/test/head.js", this);
-
-const NET_INFO_PREF = "devtools.webconsole.filter.networkinfo";
-const NET_XHR_PREF = "devtools.webconsole.filter.netxhr";
-
-// Enable XHR logging for the test
-Services.prefs.setBoolPref(NET_INFO_PREF, true);
-Services.prefs.setBoolPref(NET_XHR_PREF, true);
-
-registerCleanupFunction(() => {
- Services.prefs.clearUserPref(NET_INFO_PREF);
- Services.prefs.clearUserPref(NET_XHR_PREF);
-});
-
-// Use the old webconsole since the new one doesn't yet support
-// XHR spy. See Bug 1304794.
-Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", false);
-registerCleanupFunction(function() {
- Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
-});
-
-/**
- * Add a new test tab in the browser and load the given url.
- * @param {String} url The url to be loaded in the new tab
- * @return a promise that resolves to the tab object when the url is loaded
- */
-function addTestTab(url) {
- info("Adding a new JSON tab with URL: '" + url + "'");
-
- return (async function () {
- let tab = await addTab(url);
-
- // Load devtools/shared/test/frame-script-utils.js
- loadFrameScriptUtils(tab.linkedBrowser);
-
- // Open the Console panel
- let hud = await openConsole();
-
- return {
- tab: tab,
- browser: tab.linkedBrowser,
- hud: hud
- };
- })();
-}
-
-/**
- *
- * @param hud
- * @param options
- */
-function executeAndInspectXhr(hud, options) {
- hud.jsterm.clearOutput();
-
- options.queryString = options.queryString || "";
-
- // Execute XHR in the content scope.
- performRequestsInContent({
- method: options.method,
- url: options.url + options.queryString,
- body: options.body,
- nocache: options.nocache,
- requestHeaders: options.requestHeaders
- });
-
- return (async function () {
- // Wait till the appropriate Net log appears in the Console panel.
- let rules = await waitForMessages({
- webconsole: hud,
- messages: [{
- text: options.url,
- category: CATEGORY_NETWORK,
- severity: SEVERITY_INFO,
- isXhr: true,
- }]
- });
-
- // The log is here, get its parent element (className: 'message').
- let msg = [...rules[0].matched][0];
- let body = msg.querySelector(".message-body");
-
- // Open XHR HTTP details body and wait till the UI fetches
- // all necessary data from the backend. All RPD requests
- // needs to be finished before we can continue testing.
- await synthesizeMouseClickSoon(hud, body);
- await waitForBackend(msg);
- let netInfoBody = body.querySelector(".netInfoBody");
- ok(netInfoBody, "Net info body must exist");
- return netInfoBody;
- })();
-}
-
-/**
- * Wait till XHR data are fetched from the backend (i.e. there are
- * no pending RDP requests.
- */
-function waitForBackend(element) {
- if (!element.hasAttribute("loading")) {
- return;
- }
- return once(element, "netlog-no-pending-requests", true);
-}
-
-/**
- * Select specific tab in XHR info body.
- *
- * @param netInfoBody The main XHR info body
- * @param tabId Tab ID (possible values: 'headers', 'cookies', 'params',
- * 'post', 'response');
- *
- * @returns Tab body element.
- */
-function selectNetInfoTab(hud, netInfoBody, tabId) {
- let tab = netInfoBody.querySelector(".tabs-menu-item." + tabId);
- ok(tab, "Tab must exist " + tabId);
-
- // Click to select specified tab and wait till its
- // UI is populated with data from the backend.
- // There must be no pending RDP requests before we can
- // continue testing the UI.
- return (async function () {
- await synthesizeMouseClickSoon(hud, tab);
- let msg = getAncestorByClass(netInfoBody, "message");
- await waitForBackend(msg);
- let tabBody = netInfoBody.querySelector("." + tabId + "TabBox");
- ok(tabBody, "Tab body must exist");
- return tabBody;
- })();
-}
-
-/**
- * Return parent node with specified class.
- *
- * @param node A child element
- * @param className Specified class name.
- *
- * @returns A parent element.
- */
-function getAncestorByClass(node, className) {
- for (let parent = node; parent; parent = parent.parentNode) {
- if (parent.classList && parent.classList.contains(className)) {
- return parent;
- }
- }
- return null;
-}
-
-/**
- * Synthesize asynchronous click event (with clean stack trace).
- */
-function synthesizeMouseClickSoon(hud, element) {
- return new Promise((resolve) => {
- executeSoon(() => {
- EventUtils.synthesizeMouse(element, 2, 2, {}, hud.iframeWindow);
- resolve();
- });
- });
-}
-
-/**
- * Execute XHR in the content scope.
- */
-function performRequestsInContent(requests) {
- info("Performing requests in the context of the content.");
- return executeInContent("devtools:test:xhr", requests);
-}
-
-function executeInContent(name, data = {}, objects = {},
- expectResponse = true) {
- let mm = gBrowser.selectedBrowser.messageManager;
-
- mm.sendAsyncMessage(name, data, objects);
- if (expectResponse) {
- return waitForContentMessage(name);
- }
-
- return Promise.resolve();
-}
-
-function waitForContentMessage(name) {
- info("Expecting message " + name + " from content");
-
- let mm = gBrowser.selectedBrowser.messageManager;
-
- return new Promise((resolve) => {
- mm.addMessageListener(name, function onMessage(msg) {
- mm.removeMessageListener(name, onMessage);
- resolve(msg.data);
- });
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/page_basic.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<!doctype html>
-<html>
- <head>
- <meta charset="utf-8"/>
- <title>XHR Spy test page</title>
- </head>
- <body>
- <script type="text/javascript">
- document.cookie = "bar=foo";
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test-cookies.json
+++ /dev/null
@@ -1,1 +0,0 @@
-{"name":"Cookies Test"}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test-cookies.json^headers^
+++ /dev/null
@@ -1,2 +0,0 @@
-Content-Type: application/json; charset=utf-8
-Set-Cookie: test=abc
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test.json
+++ /dev/null
@@ -1,1 +0,0 @@
-{"name":"John"}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test.json^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: application/json; charset=utf-8
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-this is a response
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test.xml
+++ /dev/null
@@ -1,1 +0,0 @@
-<xml><name>John</name></xml>
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/mochitest/test.xml^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: application/xml; charset=utf-8
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/unit/.eslintrc.js
+++ /dev/null
@@ -1,6 +0,0 @@
-"use strict";
-
-module.exports = {
- // Extend from the common devtools xpcshell eslintrc config.
- "extends": "../../../../../../.eslintrc.xpcshell.js"
-};
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/unit/test_json-utils.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-const { parseJSONString, isJSON } = require("devtools/client/webconsole/old/net/utils/json");
-
-// Test data
-const simpleJson = '{"name":"John"}';
-const jsonInFunc = 'someFunc({"name":"John"})';
-
-const json1 = "{'a': 1}";
-const json2 = " {'a': 1}";
-const json3 = "\t {'a': 1}";
-const json4 = "\n\n\t {'a': 1}";
-const json5 = "\n\n\t ";
-
-const textMimeType = "text/plain";
-const jsonMimeType = "text/javascript";
-const unknownMimeType = "text/unknown";
-
-/**
- * Testing API provided by webconsole/old/net/utils/json.js
- */
-function run_test() {
- // parseJSONString
- equal(parseJSONString(simpleJson).name, "John");
- equal(parseJSONString(jsonInFunc).name, "John");
-
- // isJSON
- equal(isJSON(textMimeType, json1), true);
- equal(isJSON(textMimeType, json2), true);
- equal(isJSON(jsonMimeType, json3), true);
- equal(isJSON(jsonMimeType, json4), true);
-
- equal(isJSON(unknownMimeType, json1), true);
- equal(isJSON(textMimeType, json1), true);
-
- equal(isJSON(unknownMimeType), false);
- equal(isJSON(unknownMimeType, json5), false);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/unit/test_net-utils.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-const {
- isImage,
- isHTML,
- getHeaderValue,
- isURLEncodedRequest,
- isMultiPartRequest
-} = require("devtools/client/webconsole/old/net/utils/net");
-
-// Test data
-const imageMimeTypes = ["image/jpeg", "image/jpg", "image/gif",
- "image/png", "image/bmp"];
-
-const htmlMimeTypes = ["text/html", "text/xml", "application/xml",
- "application/rss+xml", "application/atom+xml", "application/xhtml+xml",
- "application/mathml+xml", "application/rdf+xml"];
-
-const headers = [{name: "headerName", value: "value1"}];
-
-const har1 = {
- request: {
- postData: {
- text: "content-type: application/x-www-form-urlencoded"
- }
- }
-};
-
-const har2 = {
- request: {
- headers: [{
- name: "content-type",
- value: "application/x-www-form-urlencoded"
- }]
- }
-};
-
-const har3 = {
- request: {
- headers: [{
- name: "content-type",
- value: "multipart/form-data"
- }]
- }
-};
-
-/**
- * Testing API provided by webconsole/old/net/utils/net.js
- */
-function run_test() {
- // isImage
- imageMimeTypes.forEach(mimeType => {
- ok(isImage(mimeType));
- });
-
- // isHTML
- htmlMimeTypes.forEach(mimeType => {
- ok(isHTML(mimeType));
- });
-
- // getHeaderValue
- equal(getHeaderValue(headers, "headerName"), "value1");
-
- // isURLEncodedRequest
- ok(isURLEncodedRequest(har1));
- ok(isURLEncodedRequest(har2));
-
- // isMultiPartRequest
- ok(isMultiPartRequest(har3));
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/test/unit/xpcshell.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[DEFAULT]
-tags = devtools
-head =
-firefox-appdir = browser
-skip-if = toolkit == 'android'
-
-[test_json-utils.js]
-[test_net-utils.js]
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/utils/events.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-function isLeftClick(event, allowKeyModifiers) {
- return event.button === 0 && (allowKeyModifiers || noKeyModifiers(event));
-}
-
-function noKeyModifiers(event) {
- return !event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey;
-}
-
-function cancelEvent(event) {
- event.stopPropagation();
- event.preventDefault();
-}
-
-// Exports from this module
-exports.isLeftClick = isLeftClick;
-exports.cancelEvent = cancelEvent;
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/utils/json.js
+++ /dev/null
@@ -1,234 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-// List of JSON content types.
-const contentTypes = {
- "text/plain": 1,
- "text/javascript": 1,
- "text/x-javascript": 1,
- "text/json": 1,
- "text/x-json": 1,
- "application/json": 1,
- "application/x-json": 1,
- "application/javascript": 1,
- "application/x-javascript": 1,
- "application/json-rpc": 1
-};
-
-// Implementation
-var Json = {};
-
-/**
- * Parsing JSON
- */
-Json.parseJSONString = function (jsonString) {
- if (!jsonString.length) {
- return null;
- }
-
- let regex, matches;
-
- let first = firstNonWs(jsonString);
- if (first !== "[" && first !== "{") {
- // This (probably) isn't pure JSON. Let's try to strip various sorts
- // of XSSI protection/wrapping and see if that works better.
-
- // Prototype-style secure requests
- regex = /^\s*\/\*-secure-([\s\S]*)\*\/\s*$/;
- matches = regex.exec(jsonString);
- if (matches) {
- jsonString = matches[1];
-
- if (jsonString[0] === "\\" && jsonString[1] === "n") {
- jsonString = jsonString.substr(2);
- }
-
- if (jsonString[jsonString.length - 2] === "\\" &&
- jsonString[jsonString.length - 1] === "n") {
- jsonString = jsonString.substr(0, jsonString.length - 2);
- }
- }
-
- // Google-style (?) delimiters
- if (jsonString.includes("&&&START&&&")) {
- regex = /&&&START&&&([\s\S]*)&&&END&&&/;
- matches = regex.exec(jsonString);
- if (matches) {
- jsonString = matches[1];
- }
- }
-
- // while(1);, for(;;);, and )]}'
- regex = /^\s*(\)\]\}[^\n]*\n|while\s*\(1\);|for\s*\(;;\);)([\s\S]*)/;
- matches = regex.exec(jsonString);
- if (matches) {
- jsonString = matches[2];
- }
-
- // JSONP
- regex = /^\s*([A-Za-z0-9_$.]+\s*(?:\[.*\]|))\s*\(([\s\S]*)\)/;
- matches = regex.exec(jsonString);
- if (matches) {
- jsonString = matches[2];
- }
- }
-
- try {
- return JSON.parse(jsonString);
- } catch (err) {
- // eslint-disable-line no-empty
- }
-
- // Give up if we don't have valid start, to avoid some unnecessary overhead.
- first = firstNonWs(jsonString);
- if (first !== "[" && first !== "{" && isNaN(first) && first !== '"') {
- return null;
- }
-
- // Remove JavaScript comments, quote non-quoted identifiers, and merge
- // multi-line structures like |{"a": 1} \n {"b": 2}| into a single JSON
- // object [{"a": 1}, {"b": 2}].
- jsonString = pseudoJsonToJson(jsonString);
-
- try {
- return JSON.parse(jsonString);
- } catch (err) {
- // eslint-disable-line no-empty
- }
-
- return null;
-};
-
-function firstNonWs(str) {
- for (let i = 0, len = str.length; i < len; i++) {
- let ch = str[i];
- if (ch !== " " && ch !== "\n" && ch !== "\t" && ch !== "\r") {
- return ch;
- }
- }
- return "";
-}
-
-function pseudoJsonToJson(json) {
- let ret = "";
- let at = 0, lasti = 0, lastch = "", hasMultipleParts = false;
- for (let i = 0, len = json.length; i < len; ++i) {
- let ch = json[i];
- if (/\s/.test(ch)) {
- continue;
- }
-
- if (ch === '"') {
- // Consume a string.
- ++i;
- while (i < len) {
- if (json[i] === "\\") {
- ++i;
- } else if (json[i] === '"') {
- break;
- }
- ++i;
- }
- } else if (ch === "'") {
- // Convert an invalid string into a valid one.
- ret += json.slice(at, i) + "\"";
- at = i + 1;
- ++i;
-
- while (i < len) {
- if (json[i] === "\\") {
- ++i;
- } else if (json[i] === "'") {
- break;
- }
- ++i;
- }
-
- if (i < len) {
- ret += json.slice(at, i) + "\"";
- at = i + 1;
- }
- } else if ((ch === "[" || ch === "{") &&
- (lastch === "]" || lastch === "}")) {
- // Multiple JSON messages in one... Make it into a single array by
- // inserting a comma and setting the "multiple parts" flag.
- ret += json.slice(at, i) + ",";
- hasMultipleParts = true;
- at = i;
- } else if (lastch === "," && (ch === "]" || ch === "}")) {
- // Trailing commas in arrays/objects.
- ret += json.slice(at, lasti);
- at = i;
- } else if (lastch === "/" && lasti === i - 1) {
- // Some kind of comment; remove it.
- if (ch === "/") {
- ret += json.slice(at, i - 1);
- at = i + json.slice(i).search(/\n|\r|$/);
- i = at - 1;
- } else if (ch === "*") {
- ret += json.slice(at, i - 1);
- at = json.indexOf("*/", i + 1) + 2;
- if (at === 1) {
- at = len;
- }
- i = at - 1;
- }
- ch = "\0";
- } else if (/[a-zA-Z$_]/.test(ch) && lastch !== ":") {
- // Non-quoted identifier. Quote it.
- ret += json.slice(at, i) + "\"";
- at = i;
- i = i + json.slice(i).search(/[^a-zA-Z0-9$_]|$/);
- ret += json.slice(at, i) + "\"";
- at = i;
- }
-
- lastch = ch;
- lasti = i;
- }
-
- ret += json.slice(at);
- if (hasMultipleParts) {
- ret = "[" + ret + "]";
- }
-
- return ret;
-}
-
-Json.isJSON = function (contentType, data) {
- // Workaround for JSON responses without proper content type
- // Let's consider all responses starting with "{" as JSON. In the worst
- // case there will be an exception when parsing. This means that no-JSON
- // responses (and post data) (with "{") can be parsed unnecessarily,
- // which represents a little overhead, but this happens only if the request
- // is actually expanded by the user in the UI (Net & Console panels).
- // Do a manual string search instead of checking (data.strip()[0] === "{")
- // to improve performance/memory usage.
- let len = data ? data.length : 0;
- for (let i = 0; i < len; i++) {
- let ch = data.charAt(i);
- if (ch === "{") {
- return true;
- }
-
- if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
- continue;
- }
-
- break;
- }
-
- if (!contentType) {
- return false;
- }
-
- contentType = contentType.split(";")[0];
- contentType = contentType.trim();
- return !!contentTypes[contentType];
-};
-
-// Exports from this module
-module.exports = Json;
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/utils/moz.build
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DevToolsModules(
- 'events.js',
- 'json.js',
- 'net.js',
-)
deleted file mode 100644
--- a/devtools/client/webconsole/old/net/utils/net.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const mimeCategoryMap = {
- "text/plain": "txt",
- "application/octet-stream": "bin",
- "text/html": "html",
- "text/xml": "html",
- "application/xml": "html",
- "application/rss+xml": "html",
- "application/atom+xml": "html",
- "application/xhtml+xml": "html",
- "application/mathml+xml": "html",
- "application/rdf+xml": "html",
- "text/css": "css",
- "application/x-javascript": "js",
- "text/javascript": "js",
- "application/javascript": "js",
- "text/ecmascript": "js",
- "application/ecmascript": "js",
- "image/jpeg": "image",
- "image/jpg": "image",
- "image/gif": "image",
- "image/png": "image",
- "image/bmp": "image",
- "application/x-shockwave-flash": "plugin",
- "application/x-silverlight-app": "plugin",
- "video/x-flv": "media",
- "audio/mpeg3": "media",
- "audio/x-mpeg-3": "media",
- "video/mpeg": "media",
- "video/x-mpeg": "media",
- "video/webm": "media",
- "video/mp4": "media",
- "video/ogg": "media",
- "audio/ogg": "media",
- "application/ogg": "media",
- "application/x-ogg": "media",
- "application/x-midi": "media",
- "audio/midi": "media",
- "audio/x-mid": "media",
- "audio/x-midi": "media",
- "music/crescendo": "media",
- "audio/wav": "media",
- "audio/x-wav": "media",
- "application/x-woff": "font",
- "application/font-woff": "font",
- "application/x-font-woff": "font",
- "application/x-ttf": "font",
- "application/x-font-ttf": "font",
- "font/ttf": "font",
- "font/woff": "font",
- "application/x-otf": "font",
- "application/x-font-otf": "font"
-};
-
-var NetUtils = {};
-
-NetUtils.isImage = function (contentType) {
- if (!contentType) {
- return false;
- }
-
- contentType = contentType.split(";")[0];
- contentType = contentType.trim();
- return mimeCategoryMap[contentType] == "image";
-};
-
-NetUtils.isHTML = function (contentType) {
- if (!contentType) {
- return false;
- }
-
- contentType = contentType.split(";")[0];
- contentType = contentType.trim();
- return mimeCategoryMap[contentType] == "html";
-};
-
-NetUtils.getHeaderValue = function (headers, name) {
- if (!headers) {
- return null;
- }
-
- name = name.toLowerCase();
- for (let i = 0; i < headers.length; ++i) {
- let headerName = headers[i].name.toLowerCase();
- if (headerName == name) {
- return headers[i].value;
- }
- }
-};
-
-NetUtils.parseXml = function (content) {
- let contentType = content.mimeType.split(";")[0];
- contentType = contentType.trim();
-
- let parser = new DOMParser();
- let doc = parser.parseFromString(content.text, contentType);
- let root = doc.documentElement;
-
- // Error handling
- let nsURI = "http://www.mozilla.org/newlayout/xml/parsererror.xml";
- if (root.namespaceURI == nsURI && root.nodeName == "parsererror") {
- return null;
- }
-
- return doc;
-};
-
-NetUtils.isURLEncodedRequest = function (file) {
- let mimeType = "application/x-www-form-urlencoded";
-
- let postData = file.request.postData;
- if (postData && postData.text) {
- let text = postData.text.toLowerCase();
- if (text.startsWith("content-type: " + mimeType)) {
- return true;
- }
- }
-
- let value = NetUtils.getHeaderValue(file.request.headers, "content-type");
- return value && value.startsWith(mimeType);
-};
-
-NetUtils.isMultiPartRequest = function (file) {
- let mimeType = "multipart/form-data";
- let value = NetUtils.getHeaderValue(file.request.headers, "content-type");
- return value && value.startsWith(mimeType);
-};
-
-// Exports from this module
-module.exports = NetUtils;
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/.eslintrc.js
+++ /dev/null
@@ -1,6 +0,0 @@
-"use strict";
-
-module.exports = {
- // Extend from the shared list of defined globals for mochitests.
- "extends": "../../../../.eslintrc.mochitests.js"
-};
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser.ini
+++ /dev/null
@@ -1,409 +0,0 @@
-[DEFAULT]
-tags = devtools
-subsuite = devtools
-support-files =
- head.js
- test-bug-585956-console-trace.html
- test-bug-593003-iframe-wrong-hud-iframe.html
- test-bug-593003-iframe-wrong-hud.html
- test-bug-595934-canvas-css.html
- test-bug-595934-canvas-css.js
- test-bug-595934-css-loader.css
- test-bug-595934-css-loader.css^headers^
- test-bug-595934-css-loader.html
- test-bug-595934-css-parser.css
- test-bug-595934-css-parser.html
- test-bug-595934-empty-getelementbyid.html
- test-bug-595934-empty-getelementbyid.js
- test-bug-595934-html.html
- test-bug-595934-image.html
- test-bug-595934-image.jpg
- test-bug-595934-imagemap.html
- test-bug-595934-malformedxml-external.html
- test-bug-595934-malformedxml-external.xml
- test-bug-595934-malformedxml.xhtml
- test-bug-595934-svg.xhtml
- test-bug-595934-workers.html
- test-bug-595934-workers.js
- test-bug-597136-external-script-errors.html
- test-bug-597136-external-script-errors.js
- test-bug-597756-reopen-closed-tab.html
- test-bug-599725-response-headers.sjs
- test-bug-600183-charset.html
- test-bug-600183-charset.html^headers^
- test-bug-601177-log-levels.html
- test-bug-601177-log-levels.js
- test-bug-603750-websocket.html
- test-bug-603750-websocket.js
- test-bug-613013-console-api-iframe.html
- test-bug-618078-network-exceptions.html
- test-bug-621644-jsterm-dollar.html
- test-bug-630733-response-redirect-headers.sjs
- test-bug-632275-getters.html
- test-bug-632347-iterators-generators.html
- test-bug-644419-log-limits.html
- test-bug-646025-console-file-location.html
- test-bug-658368-time-methods.html
- test-bug-737873-mixedcontent.html
- test-bug-752559-ineffective-iframe-sandbox-warning0.html
- test-bug-752559-ineffective-iframe-sandbox-warning1.html
- test-bug-752559-ineffective-iframe-sandbox-warning2.html
- test-bug-752559-ineffective-iframe-sandbox-warning3.html
- test-bug-752559-ineffective-iframe-sandbox-warning4.html
- test-bug-752559-ineffective-iframe-sandbox-warning5.html
- test-bug-752559-ineffective-iframe-sandbox-warning-inner.html
- test-bug-752559-ineffective-iframe-sandbox-warning-nested1.html
- test-bug-752559-ineffective-iframe-sandbox-warning-nested2.html
- test-bug-762593-insecure-passwords-about-blank-web-console-warning.html
- test-bug-762593-insecure-passwords-web-console-warning.html
- test-bug-766001-console-log.js
- test-bug-766001-js-console-links.html
- test-bug-766001-js-errors.js
- test-bug-782653-css-errors-1.css
- test-bug-782653-css-errors-2.css
- test-bug-782653-css-errors.html
- test-bug-837351-security-errors.html
- test-bug-859170-longstring-hang.html
- test-bug-869003-iframe.html
- test-bug-869003-top-window.html
- test-closure-optimized-out.html
- test-closures.html
- test-console-assert.html
- test-console-clear.html
- test-console-count.html
- test-console-count-external-file.js
- test-console-extras.html
- test-console-replaced-api.html
- test-console-server-logging.sjs
- test-console-server-logging-array.sjs
- test-console-server-logging-backtrace.sjs
- test-console.html
- test-console-workers.html
- test-console-table.html
- test-console-output-02.html
- test-console-output-03.html
- test-console-output-04.html
- test-console-output-dom-elements.html
- test-console-output-events.html
- test-console-column.html
- test-consoleiframes.html
- test-console-trace-async.html
- test-certificate-messages.html
- test-cu-reporterror.js
- test-data.json
- test-data.json^headers^
- test-duplicate-error.html
- test-encoding-ISO-8859-1.html
- test-error.html
- test-eval-in-stackframe.html
- test-file-location.js
- test-filter.html
- test-for-of.html
- test_hpkp-invalid-headers.sjs
- test_hsts-invalid-headers.sjs
- test-iframe-762593-insecure-form-action.html
- test-iframe-762593-insecure-frame.html
- test-iframe1.html
- test-iframe2.html
- test-iframe3.html
- test-image.png
- test-mixedcontent-securityerrors.html
- test-mutation.html
- test-network-request.html
- test-network.html
- test-observe-http-ajax.html
- test-own-console.html
- test-property-provider.html
- test-repeated-messages.html
- test-result-format-as-string.html
- test-trackingprotection-securityerrors.html
- test-webconsole-error-observer.html
- test_bug_770099_violation.html
- test_bug_770099_violation.html^headers^
- test-autocomplete-in-stackframe.html
- testscript.js
- test-bug_923281_console_log_filter.html
- test-bug_923281_test1.js
- test-bug_923281_test2.js
- test-bug_939783_console_trace_duplicates.html
- test-bug-952277-highlight-nodes-in-vview.html
- test-bug-609872-cd-iframe-parent.html
- test-bug-609872-cd-iframe-child.html
- test-bug-989025-iframe-parent.html
- test-bug_1050691_click_function_to_source.html
- test-bug_1050691_click_function_to_source.js
- test-console-api-stackframe.html
- test-exception-stackframe.html
- test_bug_1010953_cspro.html^headers^
- test_bug_1010953_cspro.html
- test_bug1045902_console_csp_ignore_reflected_xss_message.html^headers^
- test_bug1045902_console_csp_ignore_reflected_xss_message.html
- test_bug1092055_shouldwarn.js^headers^
- test_bug1092055_shouldwarn.js
- test_bug1092055_shouldwarn.html
- test_bug_1247459_violation.html
- !/devtools/client/netmonitor/test/sjs_cors-test-server.sjs
- !/devtools/client/shared/test/shared-head.js
- !/image/test/mochitest/blue.png
-
-[browser_bug1045902_console_csp_ignore_reflected_xss_message.js]
-skip-if = (e10s && debug) || (e10s && os == 'win') # Bug 1221499 enabled these on windows
-[browser_bug664688_sandbox_update_after_navigation.js]
-[browser_bug_638949_copy_link_location.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_bug_862916_console_dir_and_filter_off.js]
-skip-if = (e10s && (os == 'win' || os == 'mac')) # Bug 1243976
-[browser_bug_865288_repeat_different_objects.js]
-[browser_bug_865871_variables_view_close_on_esc_key.js]
-[browser_bug_869003_inspect_cross_domain_object.js]
-[browser_bug_871156_ctrlw_close_tab.js]
-[browser_cached_messages.js]
-[browser_console.js]
-[browser_console_certificate_imminent_distrust.js]
-[browser_console_clear_method.js]
-[browser_console_clear_on_reload.js]
-[browser_console_click_focus.js]
-[browser_console_consolejsm_output.js]
-[browser_console_copy_command.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_console_dead_objects.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_console_copy_entire_message_context_menu.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_console_devtools_loader_exception.js]
-[browser_console_error_source_click.js]
-[browser_console_filters.js]
-[browser_console_iframe_messages.js]
-[browser_console_keyboard_accessibility.js]
-[browser_console_log_inspectable_object.js]
-[browser_console_native_getters.js]
-[browser_console_navigation_marker.js]
-[browser_console_netlogging.js]
-[browser_console_nsiconsolemessage.js]
-[browser_console_optimized_out_vars.js]
-[browser_console_private_browsing.js]
-skip-if = e10s # Bug 1042253 - webconsole e10s tests
-[browser_console_restore.js]
-[browser_console_server_logging.js]
-[browser_console_variables_view.js]
-[browser_console_variables_view_filter.js]
-[browser_console_variables_view_dom_nodes.js]
-[browser_console_variables_view_dont_sort_non_sortable_classes_properties.js]
-[browser_console_variables_view_special_names.js]
-[browser_console_variables_view_while_debugging.js]
-[browser_console_variables_view_while_debugging_and_inspecting.js]
-[browser_eval_in_debugger_stackframe.js]
-[browser_eval_in_debugger_stackframe2.js]
-[browser_jsterm_inspect.js]
-skip-if = e10s && debug && (os == 'win' || os == 'mac') # Bug 1243966
-[browser_longstring_hang.js]
-[browser_output_breaks_after_console_dir_uninspectable.js]
-[browser_output_longstring_expand.js]
-[browser_repeated_messages_accuracy.js]
-[browser_result_format_as_string.js]
-[browser_warn_user_about_replaced_api.js]
-[browser_webconsole_allow_mixedcontent_securityerrors.js]
-tags = mcb
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_script_errordoc_urls.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_webconsole_assert.js]
-[browser_webconsole_block_mixedcontent_securityerrors.js]
-tags = mcb
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_bug_579412_input_focus.js]
-[browser_webconsole_bug_580001_closing_after_completion.js]
-[browser_webconsole_bug_580030_errors_after_page_reload.js]
-[browser_webconsole_bug_582201_duplicate_errors.js]
-[browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js]
-[browser_webconsole_bug_585237_line_limit.js]
-[browser_webconsole_bug_585956_console_trace.js]
-[browser_webconsole_bug_585991_autocomplete_keys.js]
-[browser_webconsole_bug_585991_autocomplete_popup.js]
-[browser_webconsole_bug_586388_select_all.js]
-[browser_webconsole_bug_587617_output_copy.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_webconsole_bug_588342_document_focus.js]
-[browser_webconsole_bug_588730_text_node_insertion.js]
-[browser_webconsole_bug_588967_input_expansion.js]
-[browser_webconsole_bug_589162_css_filter.js]
-[browser_webconsole_bug_592442_closing_brackets.js]
-[browser_webconsole_bug_593003_iframe_wrong_hud.js]
-[browser_webconsole_bug_594497_history_arrow_keys.js]
-[browser_webconsole_bug_595223_file_uri.js]
-[browser_webconsole_bug_595350_multiple_windows_and_tabs.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_webconsole_bug_595934_message_categories.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_webconsole_bug_597103_deactivateHUDForContext_unfocused_window.js]
-[browser_webconsole_bug_597136_external_script_errors.js]
-[browser_webconsole_bug_597136_network_requests_from_chrome.js]
-[browser_webconsole_bug_597460_filter_scroll.js]
-[browser_webconsole_bug_597756_reopen_closed_tab.js]
-[browser_webconsole_bug_599725_response_headers.js]
-[browser_webconsole_bug_600183_charset.js]
-[browser_webconsole_bug_601177_log_levels.js]
-[browser_webconsole_bug_601352_scroll.js]
-[browser_webconsole_bug_601667_filter_buttons.js]
-[browser_webconsole_bug_603750_websocket.js]
-[browser_webconsole_bug_611795.js]
-[browser_webconsole_bug_613013_console_api_iframe.js]
-[browser_webconsole_bug_613280_jsterm_copy.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_webconsole_bug_613642_maintain_scroll.js]
-[browser_webconsole_bug_613642_prune_scroll.js]
-[browser_webconsole_bug_614793_jsterm_scroll.js]
-[browser_webconsole_bug_618078_network_exceptions.js]
-[browser_webconsole_bug_621644_jsterm_dollar.js]
-[browser_webconsole_bug_622303_persistent_filters.js]
-[browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js]
-skip-if = os != "win"
-[browser_webconsole_bug_630733_response_redirect_headers.js]
-[browser_webconsole_bug_632275_getters_document_width.js]
-[browser_webconsole_bug_632347_iterators_generators.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_webconsole_bug_632817.js]
-skip-if = true # Bug 1244707
-[browser_webconsole_bug_642108_pruneTest.js]
-[browser_webconsole_autocomplete_and_selfxss.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_webconsole_bug_644419_log_limits.js]
-[browser_webconsole_bug_646025_console_file_location.js]
-[browser_webconsole_bug_651501_document_body_autocomplete.js]
-[browser_webconsole_bug_653531_highlighter_console_helper.js]
-skip-if = true # Requires direct access to content nodes
-[browser_webconsole_bug_658368_time_methods.js]
-[browser_webconsole_bug_659907_console_dir.js]
-[browser_webconsole_bug_660806_history_nav.js]
-[browser_webconsole_bug_664131_console_group.js]
-[browser_webconsole_bug_686937_autocomplete_JSTerm_helpers.js]
-[browser_webconsole_bug_704295.js]
-[browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js]
-[browser_webconsole_bug_737873_mixedcontent.js]
-tags = mcb
-[browser_webconsole_bug_752559_ineffective_iframe_sandbox_warning.js]
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_bug_762593_insecure_passwords_about_blank_web_console_warning.js]
-[browser_webconsole_bug_762593_insecure_passwords_web_console_warning.js]
-skip-if = true # Bug 1110500 - mouse event failure in test
-[browser_webconsole_bug_764572_output_open_url.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_webconsole_bug_766001_JS_Console_in_Debugger.js]
-[browser_webconsole_bug_770099_violation.js]
-skip-if = e10s && (os == 'win' || os == 'mac') # Bug 1243978
-[browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js]
-[browser_webconsole_bug_804845_ctrl_key_nav.js]
-skip-if = os != "mac"
-[browser_webconsole_bug_817834_add_edited_input_to_history.js]
-[browser_webconsole_bug_837351_securityerrors.js]
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_filter_buttons_contextmenu.js]
-[browser_webconsole_bug_1006027_message_timestamps_incorrect.js]
-skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug intermittent)
-[browser_webconsole_bug_1010953_cspro.js]
-skip-if = e10s && (os == 'win' || os == 'mac') # Bug 1243967
-[browser_webconsole_bug_1247459_violation.js]
-skip-if = e10s && (os == 'win') # Bug 1264955
-[browser_webconsole_certificate_messages.js]
-skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
-[browser_webconsole_show_subresource_security_errors.js]
-skip-if = e10s && (os == 'win' || os == 'mac') # Bug 1243987
-[browser_webconsole_cached_autocomplete.js]
-[browser_webconsole_chrome.js]
-[browser_webconsole_clear_method.js]
-[browser_webconsole_clickable_urls.js]
-[browser_webconsole_closure_inspection.js]
-[browser_webconsole_completion.js]
-[browser_webconsole_console_extras.js]
-[browser_webconsole_console_logging_api.js]
-[browser_webconsole_console_logging_workers_api.js]
-[browser_webconsole_console_trace_async.js]
-[browser_webconsole_count.js]
-[browser_webconsole_dont_navigate_on_doubleclick.js]
-[browser_webconsole_execution_scope.js]
-[browser_webconsole_for_of.js]
-[browser_webconsole_history.js]
-[browser_webconsole_hpkp_invalid-headers.js]
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_hsts_invalid-headers.js]
-skip-if = e10s # Bug 1042253 - webconsole e10s tests
-[browser_webconsole_input_field_focus_on_panel_select.js]
-[browser_webconsole_inspect-parsed-documents.js]
-[browser_webconsole_js_input_expansion.js]
-[browser_webconsole_jsterm.js]
-skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
-[browser_webconsole_live_filtering_of_message_types.js]
-[browser_webconsole_live_filtering_on_search_strings.js]
-[browser_webconsole_message_node_id.js]
-[browser_webconsole_multiline_input.js]
-[browser_webconsole_netlogging.js]
-skip-if = true # Bug 1298364
-[browser_webconsole_netlogging_basic.js]
-[browser_webconsole_netlogging_panel.js]
-[browser_webconsole_netlogging_reset_filter.js]
-[browser_webconsole_notifications.js]
-[browser_webconsole_open-links-without-callback.js]
-[browser_webconsole_promise.js]
-[browser_webconsole_output_copy_newlines.js]
-subsuite = clipboard
-skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
-[browser_webconsole_output_order.js]
-[browser_webconsole_scratchpad_panel_link.js]
-[browser_webconsole_split.js]
-[browser_webconsole_split_escape_key.js]
-[browser_webconsole_split_focus.js]
-[browser_webconsole_split_persist.js]
-[browser_webconsole_trackingprotection_errors.js]
-tags = trackingprotection
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_view_source.js]
-skip-if = (os == 'win' && bits == 64) # Bug 1390001
-[browser_webconsole_reflow.js]
-[browser_webconsole_log_file_filter.js]
-[browser_webconsole_expandable_timestamps.js]
-[browser_webconsole_autocomplete_accessibility.js]
-[browser_webconsole_autocomplete_in_debugger_stackframe.js]
-[browser_webconsole_autocomplete_popup_close_on_tab_switch.js]
-[browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js]
-[browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js]
-[browser_console_history_persist.js]
-[browser_webconsole_output_01.js]
-[browser_webconsole_output_02.js]
-[browser_webconsole_output_03.js]
-[browser_webconsole_output_04.js]
-[browser_webconsole_output_05.js]
-[browser_webconsole_output_06.js]
-[browser_webconsole_output_dom_elements_01.js]
-[browser_webconsole_output_dom_elements_02.js]
-skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
-[browser_webconsole_output_dom_elements_03.js]
-skip-if = e10s # Bug 1241019
-[browser_webconsole_output_dom_elements_04.js]
-skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
-[browser_webconsole_output_dom_elements_05.js]
-[browser_webconsole_output_events.js]
-[browser_webconsole_output_regexp.js]
-[browser_webconsole_output_table.js]
-[browser_console_variables_view_highlighter.js]
-[browser_webconsole_start_netmon_first.js]
-[browser_webconsole_console_trace_duplicates.js]
-[browser_webconsole_cd_iframe.js]
-[browser_webconsole_autocomplete_crossdomain_iframe.js]
-[browser_webconsole_console_custom_styles.js]
-[browser_webconsole_console_api_stackframe.js]
-[browser_webconsole_exception_stackframe.js]
-[browser_webconsole_column_numbers.js]
-[browser_console_open_or_focus.js]
-[browser_webconsole_bug_922212_console_dirxml.js]
-[browser_webconsole_shows_reqs_in_netmonitor.js]
-[browser_netmonitor_shows_reqs_in_webconsole.js]
-[browser_webconsole_bug_1050691_click_function_to_source.js]
-[browser_webconsole_context_menu_open_in_var_view.js]
-[browser_webconsole_context_menu_store_as_global.js]
-[browser_webconsole_strict_mode_errors.js]
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug1045902_console_csp_ignore_reflected_xss_message.js
+++ /dev/null
@@ -1,52 +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/ */
-
-// Tests that a file with an unsupported CSP directive ('reflected-xss filter')
-// displays the appropriate message to the console.
-
-"use strict";
-
-const EXPECTED_RESULT = "Not supporting directive \u2018reflected-xss\u2019. " +
- "Directive and values will be ignored.";
-const TEST_FILE = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test_bug1045902_console_csp_ignore_reflected_xss_" +
- "message.html";
-
-var hud = undefined;
-
-var TEST_URI = "data:text/html;charset=utf8,Web Console CSP ignoring " +
- "reflected XSS (bug 1045902)";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- hud = yield openConsole();
-
- yield loadDocument(browser);
- yield testViolationMessage();
-
- hud = null;
-});
-
-function loadDocument(browser) {
- hud.jsterm.clearOutput();
- browser.loadURI(TEST_FILE);
- return BrowserTestUtils.browserLoaded(browser);
-}
-
-function testViolationMessage() {
- let aOutputNode = hud.outputNode;
-
- return waitForSuccess({
- name: "Confirming that CSP logs messages to the console when " +
- "\u2018reflected-xss\u2019 directive is used!",
- validator: function () {
- console.log(aOutputNode.textContent);
- let success = false;
- success = aOutputNode.textContent.indexOf(EXPECTED_RESULT) > -1;
- return success;
- }
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug664688_sandbox_update_after_navigation.js
+++ /dev/null
@@ -1,92 +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/ */
-
-// Tests if the JSTerm sandbox is updated when the user navigates from one
-// domain to another, in order to avoid permission denied errors with a sandbox
-// created for a different origin.
-
-"use strict";
-
-add_task(function* () {
- const TEST_URI1 = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
- const TEST_URI2 = "http://example.org/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
- yield loadTab(TEST_URI1);
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
- hud.jsterm.execute("window.location.href");
-
- info("wait for window.location.href");
-
- let msgForLocation1 = {
- webconsole: hud,
- messages: [
- {
- name: "window.location.href jsterm input",
- text: "window.location.href",
- category: CATEGORY_INPUT,
- },
- {
- name: "window.location.href result is displayed",
- text: TEST_URI1,
- category: CATEGORY_OUTPUT,
- },
- ],
- };
-
- yield waitForMessages(msgForLocation1);
-
- // load second url
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);
- yield loadBrowser(gBrowser.selectedBrowser);
-
- is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
- "no permission denied errors");
-
- hud.jsterm.clearOutput();
- hud.jsterm.execute("window.location.href");
-
- info("wait for window.location.href after page navigation");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "window.location.href jsterm input",
- text: "window.location.href",
- category: CATEGORY_INPUT,
- },
- {
- name: "window.location.href result is displayed",
- text: TEST_URI2,
- category: CATEGORY_OUTPUT,
- },
- ],
- });
-
- is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
- "no permission denied errors");
-
- // Navigation clears messages. Wait for that clear to happen before
- // continuing the test or it might destroy messages we wait later on (Bug
- // 1270234).
- let cleared = hud.jsterm.once("messages-cleared");
-
- gBrowser.goBack();
-
- info("Waiting for messages to be cleared due to navigation");
- yield cleared;
-
- info("Messages cleared after navigation; checking location");
- hud.jsterm.execute("window.location.href");
-
- info("wait for window.location.href after goBack()");
- yield waitForMessages(msgForLocation1);
- is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
- "no permission denied errors");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug_638949_copy_link_location.js
+++ /dev/null
@@ -1,109 +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.
-
-"use strict";
-
-add_task(function* () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "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();
- yield ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- 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
- gBrowser.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);
- }
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug_862916_console_dir_and_filter_off.js
+++ /dev/null
@@ -1,31 +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/ */
-
-// Check that the output for console.dir() works even if Logging filter is off.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test for bug 862916";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- ok(hud, "web console opened");
-
- hud.setFilterState("log", false);
- registerCleanupFunction(() => hud.setFilterState("log", true));
-
- hud.jsterm.execute("window.fooBarz = 'bug862916'; " +
- "console.dir(window)");
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
- ok(varView, "variables view object");
-
- yield findVariableViewProperties(varView, [
- { name: "fooBarz", value: "bug862916" },
- ], { webconsole: hud });
-});
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug_865288_repeat_different_objects.js
+++ /dev/null
@@ -1,63 +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 that makes sure messages are not considered repeated when console.log()
-// is invoked with different objects, see bug 865288.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-repeated-messages.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- info("waiting for 3 console.log objects");
-
- hud.jsterm.clearOutput(true);
- hud.jsterm.execute("window.testConsoleObjects()");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "3 console.log messages",
- text: "abba",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- count: 3,
- repeats: 1,
- objects: true,
- }],
- });
-
- let msgs = [...result.matched];
- is(msgs.length, 3, "3 message elements");
-
- for (let i = 0; i < msgs.length; i++) {
- info("test message element #" + i);
-
- let msg = msgs[i];
- let clickable = msg.querySelector(".message-body a");
- ok(clickable, "clickable object #" + i);
-
- msg.scrollIntoView(false);
- yield clickObject(clickable, i);
- }
-
- function* clickObject(obj, i) {
- executeSoon(() => {
- EventUtils.synthesizeMouse(obj, 2, 2, {}, hud.iframeWindow);
- });
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
- ok(varView, "variables view fetched #" + i);
-
- yield findVariableViewProperties(varView, [
- { name: "id", value: "abba" + i },
- ], { webconsole: hud });
- }
-});
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug_865871_variables_view_close_on_esc_key.js
+++ /dev/null
@@ -1,75 +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/ */
-
-// Check that the variables view sidebar can be closed by pressing Escape in the
-// web console.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-eval-in-stackframe.html";
-
-function test() {
- let hud;
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- let {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
- let jsterm = hud.jsterm;
- let result;
- let vview;
- let msg;
-
- yield openSidebar("fooObj",
- 'testProp: "testValue"',
- { name: "testProp", value: "testValue" });
-
- let prop = result.matchedProp;
- ok(prop, "matched the |testProp| property in the variables view");
-
- vview.window.focus();
-
- let sidebarClosed = jsterm.once("sidebar-closed");
- EventUtils.synthesizeKey("KEY_Escape");
- yield sidebarClosed;
-
- jsterm.clearOutput();
-
- yield openSidebar("window.location",
- "Location \u2192 http://example.com/browser/",
- { name: "host", value: "example.com" });
-
- vview.window.focus();
-
- msg.scrollIntoView();
- sidebarClosed = jsterm.once("sidebar-closed");
- EventUtils.synthesizeKey("KEY_Escape");
- yield sidebarClosed;
-
- function* openSidebar(objName, expectedText, expectedObj) {
- msg = yield jsterm.execute(objName);
- ok(msg, "output message found");
-
- let anchor = msg.querySelector("a");
- let body = msg.querySelector(".message-body");
- ok(anchor, "object anchor");
- ok(body, "message body");
- ok(body.textContent.includes(expectedText), "message text check");
-
- msg.scrollIntoView();
- yield EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow);
-
- let vviewVar = yield jsterm.once("variablesview-fetched");
- vview = vviewVar._variablesView;
- ok(vview, "variables view object exists");
-
- [result] = yield findVariableViewProperties(vviewVar, [
- expectedObj,
- ], { webconsole: hud });
- }
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug_869003_inspect_cross_domain_object.js
+++ /dev/null
@@ -1,83 +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/ */
-
-// Check that users can inspect objects logged from cross-domain iframes -
-// bug 869003.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-869003-top-window.html";
-
-add_task(function* () {
- // This test is slightly more involved: it opens the web console, then the
- // variables view for a given object, it updates a property in the view and
- // checks the result. We can get a timeout with debug builds on slower
- // machines.
- requestLongerTimeout(2);
-
- yield loadTab("data:text/html;charset=utf8,<p>hello");
- let hud = yield openConsole();
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log message",
- text: "foobar",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- objects: true,
- }],
- });
-
- let msg = [...result.matched][0];
- ok(msg, "message element");
-
- let body = msg.querySelector(".message-body");
- ok(body, "message body");
- ok(body.textContent.includes('{ hello: "world!",'), "message text check");
- ok(body.textContent.includes('function func()'), "message text check");
-
- yield testClickable(result.clickableElements[0], [
- { name: "hello", value: "world!" },
- { name: "bug", value: 869003 },
- ], hud);
- yield testClickable(result.clickableElements[1], [
- { name: "hello", value: "world!" },
- { name: "name", value: "func" },
- { name: "length", value: 1 },
- ], hud);
-});
-
-function* testClickable(clickable, props, hud) {
- ok(clickable, "clickable object found");
-
- executeSoon(() => {
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
- });
-
- let aVar = yield hud.jsterm.once("variablesview-fetched");
- ok(aVar, "variables view fetched");
- ok(aVar._variablesView, "variables view object");
-
- let [result] = yield findVariableViewProperties(aVar, props, { webconsole: hud });
- let prop = result.matchedProp;
- ok(prop, "matched the |" + props[0].name + "| property in the variables view");
-
- // Check that property value updates work.
- aVar = yield updateVariablesViewProperty({
- property: prop,
- field: "value",
- string: "'omgtest'",
- webconsole: hud,
- });
-
- info("onFetchAfterUpdate");
-
- props[0].value = "omgtest";
- yield findVariableViewProperties(aVar, props, { webconsole: hud });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_bug_871156_ctrlw_close_tab.js
+++ /dev/null
@@ -1,76 +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/ */
-
-// Check that Ctrl-W closes the Browser Console and that Ctrl-W closes the
-// current tab when using the Web Console - bug 871156.
-
-"use strict";
-
-add_task(function* () {
- const TEST_URI = "data:text/html;charset=utf8,<title>bug871156</title>\n" +
- "<p>hello world";
- let firstTab = gBrowser.selectedTab;
-
- Services.prefs.setBoolPref("toolkit.cosmeticAnimations.enabled", false);
- registerCleanupFunction(() => {
- Services.prefs.clearUserPref("toolkit.cosmeticAnimations.enabled");
- });
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- ok(hud, "Web Console opened");
-
- let tabClosed = defer();
- let toolboxDestroyed = defer();
- let tabSelected = defer();
-
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
-
- gBrowser.tabContainer.addEventListener("TabClose", function () {
- info("tab closed");
- tabClosed.resolve(null);
- }, {once: true});
-
- gBrowser.tabContainer.addEventListener("TabSelect", function () {
- if (gBrowser.selectedTab == firstTab) {
- info("tab selected");
- tabSelected.resolve(null);
- }
- }, {once: true});
-
- toolbox.once("destroyed", () => {
- info("toolbox destroyed");
- toolboxDestroyed.resolve(null);
- });
-
- // Get out of the web console initialization.
- executeSoon(() => {
- EventUtils.synthesizeKey("w", { accelKey: true });
- });
-
- yield promise.all([tabClosed.promise, toolboxDestroyed.promise,
- tabSelected.promise]);
- info("promise.all resolved. start testing the Browser Console");
-
- hud = yield HUDService.toggleBrowserConsole();
- ok(hud, "Browser Console opened");
-
- let deferred = defer();
-
- Services.obs.addObserver(function onDestroy() {
- Services.obs.removeObserver(onDestroy, "web-console-destroyed");
- ok(true, "the Browser Console closed");
-
- deferred.resolve(null);
- }, "web-console-destroyed");
-
- waitForFocus(() => {
- EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
- }, hud.iframeWindow);
-
- yield deferred.promise;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_cached_messages.js
+++ /dev/null
@@ -1,59 +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 to see if the cached messages are displayed when the console UI is
-// opened.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-webconsole-error-observer.html";
-
-// On e10s, the exception is triggered in child process
-// and is ignored by test harness
-if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
-}
-
-function test() {
- waitForExplicitFinish();
-
- loadTab(TEST_URI).then(testOpenUI);
-}
-
-function testOpenUI(aTestReopen) {
- openConsole().then((hud) => {
- waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "log Bazzle",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "error Bazzle",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- },
- {
- text: "bazBug611032",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- text: "cssColorBug611032",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- },
- ],
- }).then(() => {
- closeConsole(gBrowser.selectedTab).then(() => {
- aTestReopen && info("will reopen the Web Console");
- executeSoon(aTestReopen ? testOpenUI : finishTest);
- });
- });
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console.js
+++ /dev/null
@@ -1,246 +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 the basic features of the Browser Console, bug 587757.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html?" + Date.now();
-const TEST_FILE = "chrome://mochitests/content/browser/devtools/client/" +
- "webconsole/old/test/test-cu-reporterror.js";
-
-const TEST_XHR_ERROR_URI = `http://example.com/404.html?${Date.now()}`;
-
-const TEST_IMAGE = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-image.png";
-
-const ObjectClient = require("devtools/shared/client/object-client");
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let opened = waitForBrowserConsole();
-
- let hud = HUDService.getBrowserConsole();
- ok(!hud, "browser console is not open");
- info("wait for the browser console to open with ctrl-shift-j");
- EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window);
-
- hud = yield opened;
- ok(hud, "browser console opened");
- yield testMessages(hud);
- yield testCPOWInspection(hud);
-});
-
-function testMessages(hud) {
- hud.jsterm.clearOutput(true);
-
- expectUncaughtException();
- executeSoon(() => {
- foobarExceptionBug587757();
- });
-
- // Add a message from a chrome window.
- hud.iframeWindow.console.log("bug587757a");
-
- // Check Cu.reportError stack.
- // Use another js script to not depend on the test file line numbers.
- Services.scriptloader.loadSubScript(TEST_FILE, hud.iframeWindow);
-
- // Bug 1348885: test that error from nuked globals do not throw
- let sandbox = new Cu.Sandbox(null, {
- wantComponents: false,
- wantGlobalProperties: ["URL", "URLSearchParams"],
- });
- let error = Cu.evalInSandbox(`
- new Error("1348885");
- `, sandbox);
- Cu.reportError(error);
- Cu.nukeSandbox(sandbox);
-
- // Add a message from a content window.
- gBrowser.contentWindowAsCPOW.console.log("bug587757b");
-
- // Test eval.
- hud.jsterm.execute("document.location.href");
-
- // Test eval frame script
- hud.jsterm.execute(`
- gBrowser.selectedBrowser.messageManager.loadFrameScript('data:application/javascript,console.log("framescript-message")', false);
- "framescript-eval";
- `);
-
- // Check for network requests.
- let xhr = new XMLHttpRequest();
- xhr.onload = () => console.log("xhr loaded, status is: " + xhr.status);
- xhr.open("get", TEST_URI, true);
- xhr.send();
-
- // Check for xhr error.
- let xhrErr = new XMLHttpRequest();
- xhrErr.onload = () => {
- console.log("xhr error loaded, status is: " + xhrErr.status);
- };
- xhrErr.open("get", TEST_XHR_ERROR_URI, true);
- xhrErr.send();
-
- // Check that Fetch requests are categorized as "XHR".
- fetch(TEST_IMAGE).then(() => { console.log("fetch loaded"); });
-
- return waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "chrome window console.log() is displayed",
- text: "bug587757a",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "Cu.reportError is displayed",
- text: "bug1141222",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- stacktrace: [{
- file: TEST_FILE,
- line: 2,
- }, {
- file: TEST_FILE,
- line: 4,
- },
- // Ignore the rest of the stack,
- // just assert Cu.reportError call site
- // and consoleOpened call
- ]
- },
- {
- name: "Error from nuked global works",
- text: "1348885",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- name: "content window console.log() is displayed",
- text: "bug587757b",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "jsterm eval result",
- text: "browser.xul",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_LOG,
- },
- {
- name: "jsterm eval result 2",
- text: "framescript-eval",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_LOG,
- },
- {
- name: "frame script message",
- text: "framescript-message",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "exception message",
- text: "foobarExceptionBug587757",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- name: "network message",
- text: "test-console.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_INFO,
- isXhr: true,
- },
- {
- name: "xhr error message",
- text: "404.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_ERROR,
- isXhr: true,
- },
- {
- name: "network message",
- text: "test-image.png",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_INFO,
- isXhr: true,
- },
- ],
- });
-}
-
-function* testCPOWInspection(hud) {
- // Directly request evaluation to get an actor for the selected browser.
- // Note that this doesn't actually render a message, and instead allows us
- // us to assert that inspecting an object doesn't throw in the server.
- // This would be done in a mochitest-chrome suite, but that doesn't run in
- // e10s, so it's harder to get ahold of a CPOW.
- let cpowEval = yield hud.jsterm.requestEvaluation("gBrowser.selectedBrowser");
- info("Creating an ObjectClient with: " + cpowEval.result.actor);
-
- let objectClient = new ObjectClient(hud.jsterm.hud.proxy.client, {
- actor: cpowEval.result.actor,
- });
-
- // Before the fix for Bug 1382833, this wouldn't resolve due to a CPOW error
- // in the ObjectActor.
- let prototypeAndProperties = yield objectClient.getPrototypeAndProperties();
-
- // Just a sanity check to make sure a valid packet came back
- is(prototypeAndProperties.prototype.class, "XBL prototype JSClass",
- "Looks like a valid response");
-
- // The CPOW is in the _contentWindow property.
- let cpow = prototypeAndProperties.ownProperties._contentWindow.value;
-
- // But it's only a CPOW in e10s.
- let e10sCheck = yield hud.jsterm.requestEvaluation(
- "Cu.isCrossProcessWrapper(gBrowser.selectedBrowser._contentWindow)");
- if (!e10sCheck.result) {
- is(cpow.class, "Window", "The object is not a CPOW.");
- return;
- }
-
- is(cpow.class, "CPOW: Window", "The CPOW grip has the right class.");
-
- // Check that various protocol request methods work for the CPOW.
- let response, slice;
- let objClient = new ObjectClient(hud.jsterm.hud.proxy.client, cpow);
-
- response = yield objClient.getPrototypeAndProperties();
- is(Reflect.ownKeys(response.ownProperties).length, 0, "No property was retrieved.");
- is(response.ownSymbols.length, 0, "No symbol property was retrieved.");
- is(response.prototype.type, "null", "The prototype is null.");
-
- response = yield objClient.enumProperties({ignoreIndexedProperties: true});
- slice = yield response.iterator.slice(0, response.iterator.count);
- is(Reflect.ownKeys(slice.ownProperties).length, 0, "No property was retrieved.");
-
- response = yield objClient.enumProperties({});
- slice = yield response.iterator.slice(0, response.iterator.count);
- is(Reflect.ownKeys(slice.ownProperties).length, 0, "No property was retrieved.");
-
- response = yield objClient.getOwnPropertyNames();
- is(response.ownPropertyNames.length, 0, "No property was retrieved.");
-
- response = yield objClient.getProperty("x");
- is(response.descriptor, undefined, "The property does not exist.");
-
- response = yield objClient.enumSymbols();
- slice = yield response.iterator.slice(0, response.iterator.count);
- is(slice.ownSymbols.length, 0, "No symbol property was retrieved.");
-
- response = yield objClient.getPrototype();
- is(response.prototype.type, "null", "The prototype is null.");
-
- response = yield objClient.getDisplayString();
- is(response.displayString, "<cpow>", "The CPOW stringifies to <cpow>");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_certificate_imminent_distrust.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-// Tests handling of certificates that will be imminently distrusted, and thus
-// should emit a warning to the console.
-//
-// This test requires a cert to be created in build/pgo/certs.
-//
-// Change directories to build/pgo/certs:
-// cd build/pgo/certs
-//
-// certutil -S -d . -n "imminently_distrusted" -s "CN=Imminently Distrusted End Entity" -c "pgo temporary ca" -t "P,," -k rsa -g 2048 -Z SHA256 -m 1519140221 -v 120 -8 "imminently-distrusted.example.com"
-//
-
-
-const TEST_URI = "data:text/html;charset=utf8,Browser Console imminent " +
- "distrust warnings test";
-const TEST_URI_PATH = "/browser/devtools/client/webconsole/old/test/" +
- "test-certificate-messages.html";
-
-var gWebconsoleTests = [
- {url: "https://sha256ee.example.com" + TEST_URI_PATH,
- name: "Imminent distrust warnings appropriately not present",
- warning: [], nowarning: ["Upcoming_Distrust_Actions"]},
- {url: "https://imminently-distrusted.example.com" +
- TEST_URI_PATH,
- name: "Imminent distrust warning displayed successfully",
- warning: ["Upcoming_Distrust_Actions"], nowarning: []},
-];
-const TRIGGER_MSG = "If you haven't seen ssl warnings yet, you won't";
-
-var gHud = undefined, gContentBrowser;
-var gCurrentTest;
-
-function test() {
- registerCleanupFunction(function () {
- gHud = gContentBrowser = null;
- });
-
- loadTab(TEST_URI).then(({browser}) => {
- gContentBrowser = browser;
-
- let opened = waitForBrowserConsole();
-
- let hud = HUDService.getBrowserConsole();
- ok(!hud, "browser console is not open");
-
- HUDService.toggleBrowserConsole();
-
- opened.then(function (hud) {
- ok(hud, "browser console opened");
- runTestLoop(hud);
- });
- });
-}
-
-function runTestLoop(theHud) {
- gCurrentTest = gWebconsoleTests.shift();
- if (!gCurrentTest) {
- finishTest();
- return;
- }
- if (!gHud) {
- gHud = theHud;
- }
- gHud.jsterm.clearOutput();
- BrowserTestUtils.browserLoaded(gContentBrowser).then(onLoad);
- if (gCurrentTest.pref) {
- SpecialPowers.pushPrefEnv({"set": gCurrentTest.pref},
- function () {
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.url);
- });
- } else {
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.url);
- }
-}
-
-function onLoad() {
- waitForSuccess({
- name: gCurrentTest.name,
- validator: function () {
- if (gHud.outputNode.textContent.includes(TRIGGER_MSG)) {
- for (let warning of gCurrentTest.warning) {
- if (!gHud.outputNode.textContent.includes(warning)) {
- return false;
- }
- }
- for (let nowarning of gCurrentTest.nowarning) {
- if (gHud.outputNode.textContent.includes(nowarning)) {
- return false;
- }
- }
- return true;
- }
- }
- }).then(runTestLoop);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_clear_method.js
+++ /dev/null
@@ -1,41 +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/ */
-
-// Check that console.clear() does not clear the output of the browser console.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>Bug 1296870";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield HUDService.toggleBrowserConsole();
-
- info("Log a new message from the content page");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.console.log("msg");
- });
- yield waitForMessage("msg", hud);
-
- info("Send a console.clear() from the content page");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.console.clear();
- });
- yield waitForMessage("Console was cleared", hud);
-
- info("Check that the messages logged after the first clear are still displayed");
- isnot(hud.outputNode.textContent.indexOf("msg"), -1, "msg is in the output");
-});
-
-function waitForMessage(message, webconsole) {
- return waitForMessages({
- webconsole,
- messages: [{
- text: message,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_clear_on_reload.js
+++ /dev/null
@@ -1,86 +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/ */
-
-// Check that clear output on page reload works - bug 705921.
-// Check that clear output and page reload remove the sidebar - bug 971967.
-
-"use strict";
-
-add_task(function* () {
- const PREF = "devtools.webconsole.persistlog";
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
- Services.prefs.setBoolPref(PREF, false);
- registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- ok(hud, "Web Console opened");
-
- yield openSidebar("fooObj", { name: "testProp", value: "testValue" });
-
- let sidebarClosed = hud.jsterm.once("sidebar-closed");
- hud.jsterm.clearOutput();
- yield sidebarClosed;
-
- hud.jsterm.execute("console.log('foobarz1')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarz1",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- yield openSidebar("fooObj", { name: "testProp", value: "testValue" });
-
- BrowserReload();
-
- sidebarClosed = hud.jsterm.once("sidebar-closed");
- loadBrowser(gBrowser.selectedBrowser);
- yield sidebarClosed;
-
- hud.jsterm.execute("console.log('foobarz2')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test-console.html",
- category: CATEGORY_NETWORK,
- },
- {
- text: "foobarz2",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- is(hud.outputNode.textContent.indexOf("foobarz1"), -1,
- "foobarz1 has been removed from output");
-
- function* openSidebar(objName, expectedObj) {
- let msg = yield hud.jsterm.execute(objName);
- ok(msg, "output message found");
-
- let anchor = msg.querySelector("a");
- let body = msg.querySelector(".message-body");
- ok(anchor, "object anchor");
- ok(body, "message body");
-
- yield EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow);
-
- let vviewVar = yield hud.jsterm.once("variablesview-fetched");
- let vview = vviewVar._variablesView;
- ok(vview, "variables view object exists");
-
- yield findVariableViewProperties(vviewVar, [
- expectedObj,
- ], { webconsole: hud });
- }
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_click_focus.js
+++ /dev/null
@@ -1,59 +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/ */
-
-// Tests that the input field is focused when the console is opened.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Dolske Digs Bacon",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let msg = [...result.matched][0];
- let outputItem = msg.querySelector(".message-body");
- ok(outputItem, "found a logged message");
-
- let inputNode = hud.jsterm.inputNode;
- ok(inputNode.getAttribute("focused"), "input node is focused, first");
-
- yield waitForBlurredInput(inputNode);
-
- EventUtils.sendMouseEvent({type: "click"}, hud.outputNode);
- ok(inputNode.getAttribute("focused"), "input node is focused, second time");
-
- yield waitForBlurredInput(inputNode);
-
- info("Setting a text selection and making sure a click does not re-focus");
- let selection = hud.iframeWindow.getSelection();
- selection.selectAllChildren(outputItem);
-
- EventUtils.sendMouseEvent({type: "click"}, hud.outputNode);
- ok(!inputNode.getAttribute("focused"),
- "input node is not focused after drag");
-});
-
-function waitForBlurredInput(inputNode) {
- return new Promise(resolve => {
- let lostFocus = () => {
- inputNode.removeEventListener("blur", lostFocus);
- ok(!inputNode.getAttribute("focused"), "input node is not focused");
- resolve();
- };
- inputNode.addEventListener("blur", lostFocus);
- document.getElementById("urlbar").click();
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_consolejsm_output.js
+++ /dev/null
@@ -1,322 +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 that Console.jsm outputs messages to the Browser Console, bug 851231.
-
-"use strict";
-
-function onNewMessage(aNewMessages) {
- for (let msg of aNewMessages) {
- // Messages that shouldn't be output contain the substring FAIL_TEST
- if (msg.node.textContent.includes("FAIL_TEST")) {
- ok(false, "Message shouldn't have been output: " + msg.node.textContent);
- }
- }
-}
-
-add_task(function* () {
- let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
- let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
- storage.clearEvents();
-
- let {console} = ChromeUtils.import("resource://gre/modules/Console.jsm", {});
- console.log("bug861338-log-cached");
-
- let hud = yield HUDService.toggleBrowserConsole();
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "cached console.log message",
- text: "bug861338-log-cached",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- hud.jsterm.clearOutput(true);
-
- function testTrace() {
- console.trace();
- }
-
- console.time("foobarTimer");
- let foobar = { bug851231prop: "bug851231value" };
-
- console.log("bug851231-log");
- console.info("bug851231-info");
- console.warn("bug851231-warn");
- console.error("bug851231-error", foobar);
- console.debug("bug851231-debug");
- console.dir(document);
- testTrace();
- console.timeEnd("foobarTimer");
-
- info("wait for the Console.jsm messages");
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "console.log output",
- text: "bug851231-log",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "console.info output",
- text: "bug851231-info",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_INFO,
- },
- {
- name: "console.warn output",
- text: "bug851231-warn",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_WARNING,
- },
- {
- name: "console.error output",
- text: /\bbug851231-error\b.+\{\s*bug851231prop:\s"bug851231value"\s*\}/,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- objects: true,
- },
- {
- name: "console.debug output",
- text: "bug851231-debug",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "console.trace output",
- consoleTrace: {
- file: "browser_console_consolejsm_output.js",
- fn: "testTrace",
- },
- },
- {
- name: "console.dir output",
- consoleDir: /XULDocument\s+.+\s+chrome:\/\/.+\/browser\.xul/,
- },
- {
- name: "console.time output",
- consoleTime: "foobarTimer",
- },
- {
- name: "console.timeEnd output",
- consoleTimeEnd: "foobarTimer",
- },
- ],
- });
-
- let consoleErrorMsg = results[3];
- ok(consoleErrorMsg, "console.error message element found");
- let clickable = consoleErrorMsg.clickableElements[0];
- ok(clickable, "clickable object found for console.error");
-
- let deferred = defer();
-
- let onFetch = (aVar) => {
- // Skip the notification from console.dir variablesview-fetched.
- if (aVar._variablesView != hud.jsterm._variablesView) {
- return;
- }
- hud.jsterm.off("variablesview-fetched", onFetch);
-
- deferred.resolve(aVar);
- };
-
- hud.jsterm.on("variablesview-fetched", onFetch);
-
- clickable.scrollIntoView(false);
-
- info("wait for variablesview-fetched");
- executeSoon(() =>
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow));
-
- let varView = yield deferred.promise;
- ok(varView, "object inspector opened on click");
-
- yield findVariableViewProperties(varView, [{
- name: "bug851231prop",
- value: "bug851231value",
- }], { webconsole: hud });
-
- yield HUDService.toggleBrowserConsole();
-});
-
-add_task(function* testPrefix() {
- let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
- let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
- storage.clearEvents();
-
- let {ConsoleAPI} = ChromeUtils.import("resource://gre/modules/Console.jsm", {});
- let consoleOptions = {
- maxLogLevel: "error",
- prefix: "Log Prefix",
- };
- let console2 = new ConsoleAPI(consoleOptions);
- console2.error("Testing a prefix");
- console2.log("FAIL_TEST: Below the maxLogLevel");
-
- let hud = yield HUDService.toggleBrowserConsole();
- hud.ui.on("new-messages", onNewMessage);
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "cached console.error message",
- prefix: "Log Prefix:",
- severity: SEVERITY_ERROR,
- text: "Testing a prefix",
- }],
- });
-
- hud.jsterm.clearOutput(true);
- hud.ui.off("new-messages", onNewMessage);
- yield HUDService.toggleBrowserConsole();
-});
-
-add_task(function* testMaxLogLevelPrefMissing() {
- let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
- let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
- storage.clearEvents();
-
- let {ConsoleAPI} = ChromeUtils.import("resource://gre/modules/Console.jsm", {});
- let consoleOptions = {
- maxLogLevel: "error",
- maxLogLevelPref: "testing.maxLogLevel",
- };
- let console = new ConsoleAPI(consoleOptions);
-
- is(Services.prefs.getPrefType(consoleOptions.maxLogLevelPref),
- Services.prefs.PREF_INVALID,
- "Check log level pref is missing");
-
- // Since the maxLogLevelPref doesn't exist, we should fallback to the passed
- // maxLogLevel of "error".
- console.warn("FAIL_TEST: Below the maxLogLevel");
- console.error("Error should be shown");
-
- let hud = yield HUDService.toggleBrowserConsole();
-
- hud.ui.on("new-messages", onNewMessage);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "defaulting to error level",
- severity: SEVERITY_ERROR,
- text: "Error should be shown",
- }],
- });
-
- hud.jsterm.clearOutput(true);
- hud.ui.off("new-messages", onNewMessage);
- yield HUDService.toggleBrowserConsole();
-});
-
-add_task(function* testMaxLogLevelPref() {
- let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
- let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
- storage.clearEvents();
-
- let {ConsoleAPI} = ChromeUtils.import("resource://gre/modules/Console.jsm", {});
- let consoleOptions = {
- maxLogLevel: "error",
- maxLogLevelPref: "testing.maxLogLevel",
- };
-
- info("Setting the pref to warn");
- Services.prefs.setCharPref(consoleOptions.maxLogLevelPref, "Warn");
-
- let console = new ConsoleAPI(consoleOptions);
-
- is(console.maxLogLevel, "warn", "Check pref was read at initialization");
-
- console.info("FAIL_TEST: info is below the maxLogLevel");
- console.error("Error should be shown");
- console.warn("Warn should be shown due to the initial pref value");
-
- info("Setting the pref to info");
- Services.prefs.setCharPref(consoleOptions.maxLogLevelPref, "INFO");
- is(console.maxLogLevel, "info", "Check pref was lowercased");
-
- console.info("info should be shown due to the pref change being observed");
-
- info("Clearing the pref");
- Services.prefs.clearUserPref(consoleOptions.maxLogLevelPref);
-
- console.warn("FAIL_TEST: Shouldn't be shown due to defaulting to error");
- console.error("Should be shown due to defaulting to error");
-
- let hud = yield HUDService.toggleBrowserConsole();
- hud.ui.on("new-messages", onNewMessage);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "error > warn",
- severity: SEVERITY_ERROR,
- text: "Error should be shown",
- },
- {
- name: "warn is the inital pref value",
- severity: SEVERITY_WARNING,
- text: "Warn should be shown due to the initial pref value",
- },
- {
- name: "pref changed to info",
- severity: SEVERITY_INFO,
- text: "info should be shown due to the pref change being observed",
- },
- {
- name: "default to intial maxLogLevel if pref is removed",
- severity: SEVERITY_ERROR,
- text: "Should be shown due to defaulting to error",
- }],
- });
-
- hud.jsterm.clearOutput(true);
- hud.ui.off("new-messages", onNewMessage);
- yield HUDService.toggleBrowserConsole();
-});
-
-// Test that console.profile/profileEnd trigger the right events
-add_task(function* testProfile() {
- let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
- let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
- let { console } = ChromeUtils.import("resource://gre/modules/Console.jsm", {});
-
- storage.clearEvents();
-
- let profilerEvents = [];
-
- function observer(subject, topic) {
- is(topic, "console-api-profiler", "The topic is 'console-api-profiler'");
- const subjectObj = subject.wrappedJSObject;
- const event = { action: subjectObj.action, name: subjectObj.arguments[0] };
- info(`Profiler event: action=${event.action}, name=${event.name}`);
- profilerEvents.push(event);
- }
-
- Services.obs.addObserver(observer, "console-api-profiler");
-
- console.profile("test");
- console.profileEnd("test");
-
- Services.obs.removeObserver(observer, "console-api-profiler");
-
- // Test that no messages were logged to the storage
- let consoleEvents = storage.getEvents();
- is(consoleEvents.length, 0, "There are zero logged messages");
-
- // Test that two profiler events were fired
- is(profilerEvents.length, 2, "Got two profiler events");
- is(profilerEvents[0].action, "profile", "First event has the right action");
- is(profilerEvents[0].name, "test", "First event has the right name");
- is(profilerEvents[1].action, "profileEnd", "Second event has the right action");
- is(profilerEvents[1].name, "test", "Second event has the right name");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_copy_command.js
+++ /dev/null
@@ -1,78 +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/ */
-
-// Tests that the `copy` console helper works as intended.
-
-"use strict";
-
-var gWebConsole, gJSTerm;
-
-var TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
- "elit, sed do eiusmod tempor incididunt ut labore et dolore magna " +
- "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
- "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
- "dolor in reprehenderit in voluptate velit esse cillum dolore eu " +
- "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " +
- "proident, sunt in culpa qui officia deserunt mollit anim id est laborum." +
- new Date();
-
-var ID = "select-me";
-
-add_task(function* init() {
- yield loadTab("data:text/html;charset=utf-8," +
- "<body>" +
- " <div>" +
- " <h1>Testing copy command</h1>" +
- " <p>This is some example text</p>" +
- " <p id='select-me'>" + TEXT + "</p>" +
- " </div>" +
- " <div><p></p></div>" +
- "</body>");
-
- gWebConsole = yield openConsole();
- gJSTerm = gWebConsole.jsterm;
-});
-
-add_task(function* testCopy() {
- let RANDOM = Math.random();
- let string = "Text: " + RANDOM;
- let obj = {a: 1, b: "foo", c: RANDOM};
-
- let samples = [
- [RANDOM, RANDOM],
- [JSON.stringify(string), string],
- [obj.toSource(), JSON.stringify(obj, null, " ")],
- [
- "$('#" + ID + "')",
- yield ContentTask.spawn(gBrowser.selectedBrowser, ID, function(id) {
- return content.document.getElementById(id).outerHTML;
- })
- ]
- ];
- for (let [source, reference] of samples) {
- let deferredResult = defer();
-
- SimpleTest.waitForClipboard(
- "" + reference,
- () => {
- let command = "copy(" + source + ")";
- info("Attempting to copy: " + source);
- info("Executing command: " + command);
- gJSTerm.execute(command, msg => {
- is(msg, undefined, "Command success: " + command);
- });
- },
- deferredResult.resolve,
- deferredResult.reject);
-
- yield deferredResult.promise;
- }
-});
-
-add_task(function* cleanup() {
- gWebConsole = gJSTerm = null;
- gBrowser.removeTab(gBrowser.selectedTab);
- finishTest();
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_copy_entire_message_context_menu.js
+++ /dev/null
@@ -1,97 +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/ */
-
-/* globals goDoCommand */
-
-"use strict";
-
-// Test copying of the entire console message when right-clicked
-// with no other text selected. See Bug 1100562.
-
-add_task(function* () {
- let hud;
- let outputNode;
- let contextMenu;
-
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/test/test-console.html";
-
- const { tab, browser } = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
- outputNode = hud.outputNode;
- contextMenu = hud.iframeWindow.document.getElementById("output-contextmenu");
-
- registerCleanupFunction(() => {
- hud = outputNode = contextMenu = null;
- });
-
- hud.jsterm.clearOutput();
-
- yield ContentTask.spawn(browser, {}, function* () {
- let button = content.document.getElementById("testTrace");
- button.click();
- });
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "bug 1100562",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- lines: 1,
- },
- {
- name: "console.trace output",
- consoleTrace: true,
- lines: 3,
- },
- ]
- });
-
- outputNode.focus();
-
- for (let result of results) {
- let message = [...result.matched][0];
-
- yield waitForContextMenu(contextMenu, message, () => {
- let copyItem = contextMenu.querySelector("#cMenu_copy");
- copyItem.doCommand();
-
- let controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
- });
-
- let clipboardText;
-
- yield waitForClipboardPromise(
- () => goDoCommand("cmd_copy"),
- (str) => {
- clipboardText = str;
- return message.textContent == clipboardText;
- }
- );
-
- ok(clipboardText, "Clipboard text was found and saved");
-
- let lines = clipboardText.split("\n");
- ok(lines.length > 0, "There is at least one newline in the message");
- is(lines.pop(), "", "There is a newline at the end");
- is(lines.length, result.lines, `There are ${result.lines} lines in the message`);
-
- // Test the first line for "timestamp message repeat file:line"
- let firstLine = lines.shift();
- ok(/^[\d:.]+ .+ \d+ .+:\d+$/.test(firstLine),
- "The message's first line has the right format");
-
- // Test the remaining lines (stack trace) for "TABfunctionName sourceURL:line:col"
- for (let line of lines) {
- ok(/^\t.+ .+:\d+:\d+$/.test(line), "The stack trace line has the right format");
- }
- }
-
- yield closeConsole(tab);
- yield finishTest();
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_dead_objects.js
+++ /dev/null
@@ -1,95 +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/ */
-
-// Check that Dead Objects do not break the Web/Browser Consoles.
-// See bug 883649.
-// This test does:
-// - opens a new tab,
-// - opens the Browser Console,
-// - stores a reference to the content document of the tab on the chrome
-// window object,
-// - closes the tab,
-// - tries to use the object that was pointing to the now-defunct content
-// document. This is the dead object.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>dead objects!";
-
-function test() {
- let hud = null;
-
- registerCleanupFunction(() => {
- Services.prefs.clearUserPref("devtools.chrome.enabled");
- });
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- Services.prefs.setBoolPref("devtools.chrome.enabled", true);
- yield loadTab(TEST_URI);
- let browser = gBrowser.selectedBrowser;
- let winID = browser.outerWindowID;
-
- info("open the browser console");
-
- hud = yield HUDService.toggleBrowserConsole();
- ok(hud, "browser console opened");
-
- let jsterm = hud.jsterm;
-
- jsterm.clearOutput();
-
- // Add the reference to the content document.
- yield jsterm.execute("Cu = Components.utils;" +
- "Cu.import('resource://gre/modules/Services.jsm');" +
- "chromeWindow = Services.wm.getMostRecentWindow('" +
- "navigator:browser');" +
- "foobarzTezt = chromeWindow.content.document;" +
- "delete chromeWindow");
-
- gBrowser.removeCurrentTab();
-
- yield TestUtils.topicObserved("outer-window-nuked", (subject, data) => {
- let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
- return id == winID;
- });
-
- let msg = yield jsterm.execute("foobarzTezt");
-
- isnot(hud.outputNode.textContent.indexOf("DeadObject"), -1,
- "dead object found");
-
- jsterm.setInputValue("foobarzTezt");
-
- for (let c of ".hello") {
- EventUtils.synthesizeKey(c, {}, hud.iframeWindow);
- }
-
- yield jsterm.execute();
-
- isnot(hud.outputNode.textContent.indexOf("can't access dead object"), -1,
- "'cannot access dead object' message found");
-
- // Click the second execute output.
- let clickable = msg.querySelector("a");
- ok(clickable, "clickable object found");
- isnot(clickable.textContent.indexOf("DeadObject"), -1,
- "message text check");
-
- msg.scrollIntoView();
-
- executeSoon(() => {
- EventUtils.synthesizeMouseAtCenter(clickable, {}, hud.iframeWindow);
- });
-
- yield jsterm.once("variablesview-fetched");
- ok(true, "variables view fetched");
-
- msg = yield jsterm.execute("delete window.foobarzTezt; 2013-26");
-
- isnot(msg.textContent.indexOf("1987"), -1, "result message found");
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_devtools_loader_exception.js
+++ /dev/null
@@ -1,92 +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/ */
-
-// Check that exceptions from scripts loaded with the DevTools loader are
-// opened correctly in View Source from the Browser Console.
-// See bug 866950.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
-
-function test() {
- requestLongerTimeout(2);
-
- let webconsole, browserconsole;
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- let {tab} = yield loadTab(TEST_URI);
- webconsole = yield openConsole(tab);
- ok(webconsole, "web console opened");
-
- browserconsole = yield HUDService.toggleBrowserConsole();
- ok(browserconsole, "browser console opened");
-
- // Cause an exception in a script loaded with the DevTools loader.
- let toolbox = gDevTools.getToolbox(webconsole.target);
- let oldPanels = toolbox._toolPanels;
- // non-iterable
- toolbox._toolPanels = {};
-
- function fixToolbox() {
- toolbox._toolPanels = oldPanels;
- }
-
- info("generate exception and wait for message");
-
- executeSoon(() => {
- executeSoon(fixToolbox);
- expectUncaughtException();
- toolbox.getToolPanels();
- });
-
- let [result] = yield waitForMessages({
- webconsole: browserconsole,
- messages: [{
- text: "TypeError: this._toolPanels is not iterable",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
-
- fixToolbox();
-
- let msg = [...result.matched][0];
- ok(msg, "message element found");
- let locationNode = msg
- .querySelector(".message .message-location > .frame-link");
- ok(locationNode, "message location element found");
-
- let url = locationNode.getAttribute("data-url");
- info("location node url: " + url);
- ok(url.indexOf("resource://") === 0, "error comes from a subscript");
-
- let viewSource = browserconsole.viewSource;
- let URL = null;
- let clickPromise = defer();
- browserconsole.viewSourceInDebugger = (sourceURL) => {
- info("browserconsole.viewSourceInDebugger() was invoked: " + sourceURL);
- URL = sourceURL;
- clickPromise.resolve(null);
- };
-
- msg.scrollIntoView();
- EventUtils.synthesizeMouse(locationNode, 2, 2, {},
- browserconsole.iframeWindow);
-
- info("wait for click on locationNode");
- yield clickPromise.promise;
-
- info("view-source url: " + URL);
- ok(URL, "we have some source URL after the click");
- isnot(URL.indexOf("toolbox.js"), -1,
- "we have the expected view source URL");
- is(URL.indexOf("->"), -1, "no -> in the URL given to view-source");
-
- browserconsole.viewSourceInDebugger = viewSource;
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_error_source_click.js
+++ /dev/null
@@ -1,79 +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/ */
-
-// Check that JS errors and CSS warnings open view source when their source link
-// is clicked in the Browser Console. See bug 877778.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 877778 " +
- "<button onclick='foobar.explode()' " +
- "style='test-color: green-please'>click!</button>";
-
-add_task(function* () {
- yield new Promise(resolve => {
- SpecialPowers.pushPrefEnv({"set": [
- ["devtools.browserconsole.filter.cssparser", true]
- ]}, resolve);
- });
-
- yield loadTab(TEST_URI);
- let hud = yield HUDService.toggleBrowserConsole();
- ok(hud, "browser console opened");
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- info("generate exception and wait for the message");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let button = content.document.querySelector("button");
- button.click();
- });
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "ReferenceError: foobar is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- text: "Unknown property \u2018test-color\u2019",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- },
- ],
- });
-
- let viewSourceCalled = false;
-
- let viewSource = hud.viewSource;
- hud.viewSource = () => {
- viewSourceCalled = true;
- };
-
- for (let result of results) {
- viewSourceCalled = false;
-
- let msg = [...result.matched][0];
- ok(msg, "message element found for: " + result.text);
- ok(!msg.classList.contains("filtered-by-type"), "message element is not filtered");
- let selector = ".message .message-location .frame-link-source";
- let locationNode = msg.querySelector(selector);
- ok(locationNode, "message location element found");
-
- locationNode.click();
-
- ok(viewSourceCalled, "view source opened");
- }
-
- hud.viewSource = viewSource;
-
- yield finishTest();
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_filters.js
+++ /dev/null
@@ -1,60 +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/ */
-
-// Check that the Browser Console does not use the same filter prefs as the Web
-// Console. See bug 878186.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>browser console filters";
-const WEB_CONSOLE_PREFIX = "devtools.webconsole.filter.";
-const BROWSER_CONSOLE_PREFIX = "devtools.browserconsole.filter.";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- info("open the web console");
- let hud = yield openConsole();
- ok(hud, "web console opened");
-
- is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
- "'exception' filter is enabled (browser console)");
- is(Services.prefs.getBoolPref(WEB_CONSOLE_PREFIX + "exception"), true,
- "'exception' filter is enabled (web console)");
-
- info("toggle 'exception' filter");
- hud.setFilterState("exception", false);
-
- is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
- "'exception' filter is enabled (browser console)");
- is(Services.prefs.getBoolPref(WEB_CONSOLE_PREFIX + "exception"), false,
- "'exception' filter is disabled (web console)");
-
- hud.setFilterState("exception", true);
-
- // We need to let the console opening event loop to finish.
- let deferred = defer();
- executeSoon(() => closeConsole().then(() => deferred.resolve(null)));
- yield deferred.promise;
-
- info("web console closed");
- hud = yield HUDService.toggleBrowserConsole();
- ok(hud, "browser console opened");
-
- is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), true,
- "'exception' filter is enabled (browser console)");
- is(Services.prefs.getBoolPref(WEB_CONSOLE_PREFIX + "exception"), true,
- "'exception' filter is enabled (web console)");
-
- info("toggle 'exception' filter");
- hud.setFilterState("exception", false);
-
- is(Services.prefs.getBoolPref(BROWSER_CONSOLE_PREFIX + "exception"), false,
- "'exception' filter is disabled (browser console)");
- is(Services.prefs.getBoolPref(WEB_CONSOLE_PREFIX + "exception"), true,
- "'exception' filter is enabled (web console)");
-
- hud.setFilterState("exception", true);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js
+++ /dev/null
@@ -1,114 +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/ */
-
-/*
- * Bug 922161 - Hide Browser Console JS input field if devtools.chrome.enabled
- * is false.
- * when devtools.chrome.enabled then
- * -browser console jsterm should be enabled
- * -browser console object inspector properties should be set.
- * -webconsole jsterm should be enabled
- * -webconsole object inspector properties should be set.
- *
- * when devtools.chrome.enabled == false then
- * -browser console jsterm should be disabled
- * -browser console object inspector properties should not be set.
- * -webconsole jsterm should be enabled
- * -webconsole object inspector properties should be set.
- */
-
-"use strict";
-
-function testObjectInspectorPropertiesAreNotSet(variablesView) {
- is(variablesView.eval, null, "vview.eval is null");
- is(variablesView.switch, null, "vview.switch is null");
- is(variablesView.delete, null, "vview.delete is null");
-}
-
-function* getVariablesView(hud) {
- function openVariablesView(vview) {
- deferred.resolve(vview._variablesView);
- }
-
- let deferred = defer();
-
- // Filter out other messages to ensure ours stays visible.
- hud.ui.filterBox.value = "browser_console_hide_jsterm_test";
-
- hud.jsterm.clearOutput();
- hud.jsterm.execute("new Object({ browser_console_hide_jsterm_test: true })");
-
- let [message] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Object { browser_console_hide_jsterm_test: true }",
- category: CATEGORY_OUTPUT,
- }],
- });
-
- hud.jsterm.once("variablesview-fetched", openVariablesView);
-
- let anchor = [...message.matched][0].querySelector("a");
-
- executeSoon(() =>
- EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow)
- );
-
- return deferred.promise;
-}
-
-function testJSTermIsVisible(hud) {
- let inputContainer = hud.ui.window.document
- .querySelector(".jsterm-input-container");
- isnot(inputContainer.style.display, "none", "input is visible");
-}
-
-function testObjectInspectorPropertiesAreSet(variablesView) {
- isnot(variablesView.eval, null, "vview.eval is set");
- isnot(variablesView.switch, null, "vview.switch is set");
- isnot(variablesView.delete, null, "vview.delete is set");
-}
-
-function testJSTermIsNotVisible(hud) {
- let inputContainer = hud.ui.window.document
- .querySelector(".jsterm-input-container");
- is(inputContainer.style.display, "none", "input is not visible");
-}
-
-function* testRunner() {
- let browserConsole, webConsole, variablesView;
-
- Services.prefs.setBoolPref("devtools.chrome.enabled", true);
-
- browserConsole = yield HUDService.toggleBrowserConsole();
- variablesView = yield getVariablesView(browserConsole);
- testJSTermIsVisible(browserConsole);
- testObjectInspectorPropertiesAreSet(variablesView);
-
- let {tab: browserTab} = yield loadTab("data:text/html;charset=utf8,hello world");
- webConsole = yield openConsole(browserTab);
- variablesView = yield getVariablesView(webConsole);
- testJSTermIsVisible(webConsole);
- testObjectInspectorPropertiesAreSet(variablesView);
- yield closeConsole(browserTab);
-
- yield HUDService.toggleBrowserConsole();
- Services.prefs.setBoolPref("devtools.chrome.enabled", false);
-
- browserConsole = yield HUDService.toggleBrowserConsole();
- variablesView = yield getVariablesView(browserConsole);
- testJSTermIsNotVisible(browserConsole);
- testObjectInspectorPropertiesAreNotSet(variablesView);
-
- webConsole = yield openConsole(browserTab);
- variablesView = yield getVariablesView(webConsole);
- testJSTermIsVisible(webConsole);
- testObjectInspectorPropertiesAreSet(variablesView);
- yield closeConsole(browserTab);
-}
-
-function test() {
- Task.spawn(testRunner).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_history_persist.js
+++ /dev/null
@@ -1,119 +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 that console command input is persisted across toolbox loads.
-// See Bug 943306.
-
-"use strict";
-
-requestLongerTimeout(2);
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "persisting history - bug 943306";
-const INPUT_HISTORY_COUNT = 10;
-
-add_task(function* () {
- info("Setting custom input history pref to " + INPUT_HISTORY_COUNT);
- Services.prefs.setIntPref("devtools.webconsole.inputHistoryCount",
- INPUT_HISTORY_COUNT);
-
- // First tab: run a bunch of commands and then make sure that you can
- // navigate through their history.
- yield loadTab(TEST_URI);
- let hud1 = yield openConsole();
- is(JSON.stringify(hud1.jsterm.history), "[]",
- "No history on first tab initially");
- yield populateInputHistory(hud1);
- is(JSON.stringify(hud1.jsterm.history),
- '["0","1","2","3","4","5","6","7","8","9"]',
- "First tab has populated history");
-
- // Second tab: Just make sure that you can navigate through the history
- // generated by the first tab.
- yield loadTab(TEST_URI);
- let hud2 = yield openConsole();
- is(JSON.stringify(hud2.jsterm.history),
- '["0","1","2","3","4","5","6","7","8","9"]',
- "Second tab has populated history");
- yield testNaviatingHistoryInUI(hud2);
- is(JSON.stringify(hud2.jsterm.history),
- '["0","1","2","3","4","5","6","7","8","9",""]',
- "An empty entry has been added in the second tab due to history perusal");
-
- // Third tab: Should have the same history as first tab, but if we run a
- // command, then the history of the first and second shouldn't be affected
- yield loadTab(TEST_URI);
- let hud3 = yield openConsole();
- is(JSON.stringify(hud3.jsterm.history),
- '["0","1","2","3","4","5","6","7","8","9"]',
- "Third tab has populated history");
-
- // Set input value separately from execute so UP arrow accurately navigates
- // history.
- hud3.jsterm.setInputValue('"hello from third tab"');
- yield hud3.jsterm.execute();
-
- is(JSON.stringify(hud1.jsterm.history),
- '["0","1","2","3","4","5","6","7","8","9"]',
- "First tab history hasn't changed due to command in third tab");
- is(JSON.stringify(hud2.jsterm.history),
- '["0","1","2","3","4","5","6","7","8","9",""]',
- "Second tab history hasn't changed due to command in third tab");
- is(JSON.stringify(hud3.jsterm.history),
- '["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
- "Third tab has updated history (and purged the first result) after " +
- "running a command");
-
- // Fourth tab: Should have the latest command from the third tab, followed
- // by the rest of the history from the first tab.
- yield loadTab(TEST_URI);
- let hud4 = yield openConsole();
- is(JSON.stringify(hud4.jsterm.history),
- '["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
- "Fourth tab has most recent history");
-
- yield hud4.jsterm.clearHistory();
- is(JSON.stringify(hud4.jsterm.history), "[]",
- "Clearing history for a tab works");
-
- yield loadTab(TEST_URI);
- let hud5 = yield openConsole();
- is(JSON.stringify(hud5.jsterm.history), "[]",
- "Clearing history carries over to a new tab");
-
- info("Clearing custom input history pref");
- Services.prefs.clearUserPref("devtools.webconsole.inputHistoryCount");
-});
-
-/**
- * Populate the history by running the following commands:
- * [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- */
-function* populateInputHistory(hud) {
- let jsterm = hud.jsterm;
-
- for (let i = 0; i < INPUT_HISTORY_COUNT; i++) {
- // Set input value separately from execute so UP arrow accurately navigates
- // history.
- jsterm.setInputValue(i);
- yield jsterm.execute();
- }
-}
-
-/**
- * Check pressing up results in history traversal like:
- * [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
- */
-function* testNaviatingHistoryInUI(hud) {
- let jsterm = hud.jsterm;
- jsterm.focus();
-
- // Count backwards from original input and make sure that pressing up
- // restores this.
- for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) {
- EventUtils.synthesizeKey("KEY_ArrowUp");
- is(jsterm.getInputValue(), i, "Pressing up restores last input");
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_iframe_messages.js
+++ /dev/null
@@ -1,114 +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/ */
-
-// Check that cached messages from nested iframes are displayed in the
-// Web/Browser Console.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-consoleiframes.html";
-
-const expectedMessages = [
- {
- text: "main file",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "blah",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR
- },
- {
- text: "iframe 2",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG
- },
- {
- text: "iframe 3",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG
- }
-];
-
-// "iframe 1" console messages can be coalesced into one if they follow each
-// other in the sequence of messages (depending on timing). If they do not, then
-// they will be displayed in the console output independently, as separate
-// messages. This is why we need to match any of the following two rules.
-const expectedMessagesAny = [
- {
- name: "iframe 1 (count: 2)",
- text: "iframe 1",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- count: 2
- },
- {
- name: "iframe 1 (repeats: 2)",
- text: "iframe 1",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 2
- },
-];
-
-add_task(function* () {
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- ok(hud, "web console opened");
-
- yield testWebConsole(hud);
- yield closeConsole();
- info("web console closed");
-
- hud = yield HUDService.toggleBrowserConsole();
- yield testBrowserConsole(hud);
- yield closeConsole();
-});
-
-function* testWebConsole(hud) {
- yield waitForMessages({
- webconsole: hud,
- messages: expectedMessages,
- });
-
- info("first messages matched");
-
- yield waitForMessages({
- webconsole: hud,
- messages: expectedMessagesAny,
- matchCondition: "any",
- });
-}
-
-function* testBrowserConsole(hud) {
- ok(hud, "browser console opened");
-
- // TODO: The browser console doesn't show page's console.log statements
- // in e10s windows. See Bug 1241289.
- if (Services.appinfo.browserTabsRemoteAutostart) {
- todo(false, "Bug 1241289");
- return;
- }
-
- yield waitForMessages({
- webconsole: hud,
- messages: expectedMessages,
- });
-
- info("first messages matched");
- yield waitForMessages({
- webconsole: hud,
- messages: expectedMessagesAny,
- matchCondition: "any",
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_keyboard_accessibility.js
+++ /dev/null
@@ -1,80 +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/ */
-
-// Check that basic keyboard shortcuts work in the web console.
-
-"use strict";
-
-add_task(async function () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
- await loadTab(TEST_URI);
-
- let hud = await openConsole();
- ok(hud, "Web Console opened");
-
- info("dump some spew into the console for scrolling");
- hud.jsterm.execute("(function() { for (var i = 0; i < 100; i++) { " +
- "console.log('foobarz' + i);" +
- "}})();");
-
- await waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarz99",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let currentPosition = hud.ui.outputWrapper.scrollTop;
- let bottom = currentPosition;
-
- EventUtils.synthesizeKey("KEY_PageUp");
- isnot(hud.ui.outputWrapper.scrollTop, currentPosition,
- "scroll position changed after page up");
-
- currentPosition = hud.ui.outputWrapper.scrollTop;
- EventUtils.synthesizeKey("KEY_PageDown");
- ok(hud.ui.outputWrapper.scrollTop > currentPosition,
- "scroll position now at bottom");
-
- EventUtils.synthesizeKey("KEY_Home");
- is(hud.ui.outputWrapper.scrollTop, 0, "scroll position now at top");
-
- EventUtils.synthesizeKey("KEY_End");
-
- let scrollTop = hud.ui.outputWrapper.scrollTop;
- ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5,
- "scroll position now at bottom");
-
- info("try ctrl-l to clear output");
- executeSoon(() => {
- let clearShortcut;
- if (Services.appinfo.OS === "Darwin") {
- clearShortcut = WCUL10n.getStr("webconsole.clear.keyOSX");
- } else {
- clearShortcut = WCUL10n.getStr("webconsole.clear.key");
- }
- synthesizeKeyShortcut(clearShortcut);
- });
- await hud.jsterm.once("messages-cleared");
-
- // Wait for the next event tick to make sure keyup for the shortcut above
- // finishes. Otherwise the 2 shortcuts are mixed.
- await new Promise(executeSoon);
-
- is(hud.outputNode.textContent.indexOf("foobarz1"), -1, "output cleared");
- is(hud.jsterm.inputNode.getAttribute("focused"), "true",
- "jsterm input is focused");
-
- info("try ctrl-f to focus filter");
- synthesizeKeyShortcut(WCUL10n.getStr("webconsole.find.key"));
- ok(!hud.jsterm.inputNode.getAttribute("focused"),
- "jsterm input is not focused");
- is(hud.ui.filterBox.getAttribute("focused"), "true",
- "filter input is focused");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_log_inspectable_object.js
+++ /dev/null
@@ -1,52 +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 that objects given to console.log() are inspectable.
-
-"use strict";
-
-add_task(function* () {
- yield loadTab("data:text/html;charset=utf8,test for bug 676722 - " +
- "inspectable objects for window.console");
-
- let hud = yield openConsole();
- hud.jsterm.clearOutput(true);
-
- yield hud.jsterm.execute("myObj = {abba: 'omgBug676722'}");
- hud.jsterm.execute("console.log('fooBug676722', myObj)");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "fooBug676722",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- objects: true,
- }],
- });
-
- let msg = [...result.matched][0];
- ok(msg, "message element");
-
- let body = msg.querySelector(".message-body");
- ok(body, "message body");
-
- let clickable = result.clickableElements[0];
- ok(clickable, "the console.log() object anchor was found");
- ok(body.textContent.includes('{ abba: "omgBug676722" }'),
- "clickable node content is correct");
-
- executeSoon(() => {
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
- });
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
- ok(varView, "object inspector opened on click");
-
- yield findVariableViewProperties(varView, [{
- name: "abba",
- value: "omgBug676722",
- }], { webconsole: hud });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_native_getters.js
+++ /dev/null
@@ -1,101 +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/ */
-
-// Check that native getters and setters for DOM elements work as expected in
-// variables view - bug 870220.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<title>bug870220</title>\n" +
- "<p>hello world\n<p>native getters!";
-
-requestLongerTimeout(2);
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- let jsterm = hud.jsterm;
-
- jsterm.execute("document");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "HTMLDocument \u2192 data:text/html;charset=utf8",
- category: CATEGORY_OUTPUT,
- objects: true,
- }],
- });
-
- let clickable = result.clickableElements[0];
- ok(clickable, "clickable object found");
-
- executeSoon(() => {
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
- });
-
- let fetchedVar = yield jsterm.once("variablesview-fetched");
-
- let variablesView = fetchedVar._variablesView;
- ok(variablesView, "variables view object");
-
- let results = yield findVariableViewProperties(fetchedVar, [
- { name: "title", value: "bug870220" },
- { name: "bgColor" },
- ], { webconsole: hud });
-
- let prop = results[1].matchedProp;
- ok(prop, "matched the |bgColor| property in the variables view");
-
- // Check that property value updates work.
- let updatedVar = yield updateVariablesViewProperty({
- property: prop,
- field: "value",
- string: "'red'",
- webconsole: hud,
- });
-
- info("on fetch after background update");
-
- jsterm.clearOutput(true);
- jsterm.execute("document.bgColor");
-
- [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "red",
- category: CATEGORY_OUTPUT,
- }],
- });
-
- yield findVariableViewProperties(updatedVar, [
- { name: "bgColor", value: "red" },
- ], { webconsole: hud });
-
- jsterm.execute("$$('p')");
-
- [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Array [",
- category: CATEGORY_OUTPUT,
- objects: true,
- }],
- });
-
- clickable = result.clickableElements[0];
- ok(clickable, "clickable object found");
-
- executeSoon(() => {
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
- });
-
- fetchedVar = yield jsterm.once("variablesview-fetched");
-
- yield findVariableViewProperties(fetchedVar, [
- { name: "0.textContent", value: /hello world/ },
- { name: "1.textContent", value: /native getters/ },
- ], { webconsole: hud });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_navigation_marker.js
+++ /dev/null
@@ -1,81 +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/ */
-
-// Check that the navigation marker shows on page reload - bug 793996.
-
-"use strict";
-
-const PREF = "devtools.webconsole.persistlog";
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-var hud;
-
-add_task(function* () {
- Services.prefs.setBoolPref(PREF, true);
-
- let { browser } = yield loadTab(TEST_URI);
- hud = yield openConsole();
-
- yield consoleOpened();
-
- let loaded = loadBrowser(browser);
- BrowserReload();
- yield loaded;
-
- yield onReload();
-
- isnot(hud.outputNode.textContent.indexOf("foobarz1"), -1,
- "foobarz1 is still in the output");
-
- Services.prefs.clearUserPref(PREF);
-
- hud = null;
-});
-
-function consoleOpened() {
- ok(hud, "Web Console opened");
-
- hud.jsterm.clearOutput();
-
- ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
- content.console.log("foobarz1");
- });
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarz1",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-function onReload() {
- ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
- content.console.log("foobarz2");
- });
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- name: "page reload",
- text: "test-console.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "foobarz2",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "navigation marker",
- text: "test-console.html",
- type: Messages.NavigationMarker,
- }],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_netlogging.js
+++ /dev/null
@@ -1,37 +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/ */
-
-// Tests that network log messages bring up the network panel.
-
-"use strict";
-
-const TEST_NETWORK_REQUEST_URI =
- "http://example.com/browser/devtools/client/webconsole/old/test/" +
- "test-network-request.html";
-
-add_task(function* () {
- let finishedRequest = waitForFinishedRequest(({ request }) => {
- return request.url === TEST_NETWORK_REQUEST_URI;
- });
-
- const hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI,
- "browserConsole");
- let request = yield finishedRequest;
-
- ok(request, "Page load was logged");
-
- let client = hud.ui.webConsoleClient;
- const postData = yield client.getRequestPostData(request.actor);
- const responseContent = yield client.getResponseContent(request.actor);
-
- is(request.request.url, TEST_NETWORK_REQUEST_URI,
- "Logged network entry is page load");
- is(request.request.method, "GET", "Method is correct");
- ok(!postData.postData.text, "No request body was stored");
- ok(postData.postDataDiscarded, "Request body was discarded");
- ok(!responseContent.content.text, "No response body was stored");
- ok(responseContent.contentDiscarded || request.fromCache,
- "Response body was discarded or response came from the cache");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_nsiconsolemessage.js
+++ /dev/null
@@ -1,85 +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/ */
-
-// Check that nsIConsoleMessages are displayed in the Browser Console.
-// See bug 859756.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<title>bug859756</title>\n" +
- "<p>hello world\n<p>nsIConsoleMessages ftw!";
-
-function test() {
- const FILTER_PREF = "devtools.browserconsole.filter.jslog";
- Services.prefs.setBoolPref(FILTER_PREF, true);
-
- registerCleanupFunction(() => {
- Services.prefs.clearUserPref(FILTER_PREF);
- });
-
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
-
- // Test for cached nsIConsoleMessages.
- Services.console.logStringMessage("test1 for bug859756");
-
- info("open web console");
- let hud = yield openConsole(tab);
-
- ok(hud, "web console opened");
- Services.console.logStringMessage("do-not-show-me");
-
- ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
- content.console.log("foobarz");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarz",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let text = hud.outputNode.textContent;
- is(text.indexOf("do-not-show-me"), -1,
- "nsIConsoleMessages are not displayed");
- is(text.indexOf("test1 for bug859756"), -1,
- "nsIConsoleMessages are not displayed (confirmed)");
-
- yield closeConsole(tab);
-
- info("web console closed");
- hud = yield HUDService.toggleBrowserConsole();
- ok(hud, "browser console opened");
-
- Services.console.logStringMessage("test2 for bug859756");
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test1 for bug859756",
- category: CATEGORY_JS,
- }, {
- text: "test2 for bug859756",
- category: CATEGORY_JS,
- }, {
- text: "do-not-show-me",
- category: CATEGORY_JS,
- }],
- });
-
- let msg = [...results[2].matched][0];
- ok(msg, "message element for do-not-show-me (nsIConsoleMessage)");
- isnot(msg.textContent.indexOf("do-not-show"), -1,
- "element content is correct");
- ok(!msg.classList.contains("filtered-by-type"), "element is not filtered");
-
- hud.setFilterState("jslog", false);
-
- ok(msg.classList.contains("filtered-by-type"), "element is filtered");
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_open_or_focus.js
+++ /dev/null
@@ -1,40 +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 that the "browser console" menu item opens or focuses (if already open)
-// the console window instead of toggling it open/close.
-
-"use strict";
-
-var {Tools} = require("devtools/client/definitions");
-
-add_task(function* () {
- let currWindow, hud, mainWindow;
-
- mainWindow = Services.wm.getMostRecentWindow(null);
-
- yield HUDService.openBrowserConsoleOrFocus();
-
- hud = HUDService.getBrowserConsole();
-
- console.log("testmessage");
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "testmessage"
- }],
- });
- currWindow = Services.wm.getMostRecentWindow(null);
- is(currWindow.document.documentURI, Tools.webConsole.oldWebConsoleURL,
- "The Browser Console is open and has focus");
- mainWindow.focus();
- yield HUDService.openBrowserConsoleOrFocus();
- currWindow = Services.wm.getMostRecentWindow(null);
- is(currWindow.document.documentURI, Tools.webConsole.oldWebConsoleURL,
- "The Browser Console is open and has focus");
- yield HUDService.toggleBrowserConsole();
- hud = HUDService.getBrowserConsole();
- ok(!hud, "Browser Console has been closed");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_optimized_out_vars.js
+++ /dev/null
@@ -1,91 +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/ */
-
-// Check that inspecting an optimized out variable works when execution is
-// paused.
-
-"use strict";
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-function test() {
- Task.spawn(function* () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-closure-optimized-out.html";
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- let { toolbox, panel, panelWin } = yield openDebugger();
-
- let sources = panelWin.DebuggerView.Sources;
- yield panel.addBreakpoint({ actor: sources.values[0], line: 18 });
- yield ensureThreadClientState(panel, "resumed");
-
- let fetchedScopes = panelWin.once(panelWin.EVENTS.FETCHED_SCOPES);
-
- // Cause the debuggee to pause
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let button = content.document.querySelector("button");
- button.click();
- });
-
- yield fetchedScopes;
- ok(true, "Scopes were fetched");
-
- yield toolbox.selectTool("webconsole");
-
- // This is the meat of the test: evaluate the optimized out variable.
- yield hud.jsterm.execute("upvar");
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "optimized out",
- category: CATEGORY_OUTPUT,
- }]
- });
-
- finishTest();
- }).catch(aError => {
- ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
- });
-}
-
-// Debugger helper functions stolen from devtools/client/debugger/test/head.js.
-
-function ensureThreadClientState(aPanel, aState) {
- let thread = aPanel.panelWin.gThreadClient;
- let state = thread.state;
-
- info("Thread is: '" + state + "'.");
-
- if (state == aState) {
- return promise.resolve(null);
- }
- return waitForThreadEvents(aPanel, aState);
-}
-
-function waitForThreadEvents(aPanel, aEventName, aEventRepeat = 1) {
- info("Waiting for thread event: '" + aEventName + "' to fire: " +
- aEventRepeat + " time(s).");
-
- let deferred = defer();
- let thread = aPanel.panelWin.gThreadClient;
- let count = 0;
-
- thread.addListener(aEventName, function onEvent(eventName, ...args) {
- info("Thread event '" + eventName + "' fired: " + (++count) + " time(s).");
-
- if (count == aEventRepeat) {
- ok(true, "Enough '" + eventName + "' thread events have been fired.");
- thread.removeListener(eventName, onEvent);
- deferred.resolve.apply(deferred, args);
- }
- });
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_private_browsing.js
+++ /dev/null
@@ -1,192 +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/ */
-
-// Bug 874061: test for how the browser and web consoles display messages coming
-// from private windows. See bug for description of expected behavior.
-
-"use strict";
-
-function test() {
- const TEST_URI = "data:text/html;charset=utf8,<p>hello world! bug 874061" +
- "<button onclick='console.log(\"foobar bug 874061\");" +
- "fooBazBaz.yummy()'>click</button>";
- let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
- .getService(Ci.nsIConsoleAPIStorage);
- let privateWindow, privateBrowser, privateTab, privateContent;
- let hud, expectedMessages, nonPrivateMessage;
-
- // This test is slightly more involved: it opens the web console twice,
- // a new private window once, and the browser console twice. We can get
- // a timeout with debug builds on slower machines.
- requestLongerTimeout(2);
- start();
-
- function start() {
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "data:text/html;charset=utf8," +
- "<p>hello world! I am not private!");
- gBrowser.selectedBrowser.addEventListener("load", onLoadTab, true);
- }
-
- function onLoadTab() {
- gBrowser.selectedBrowser.removeEventListener("load", onLoadTab, true);
- info("onLoadTab()");
-
- // Make sure we have a clean state to start with.
- Services.console.reset();
- ConsoleAPIStorage.clearEvents();
-
- // Add a non-private message to the browser console.
- ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
- content.console.log("bug874061-not-private");
- });
-
- nonPrivateMessage = {
- name: "console message from a non-private window",
- text: "bug874061-not-private",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- };
-
- privateWindow = OpenBrowserWindow({ private: true });
- ok(privateWindow, "new private window");
- ok(PrivateBrowsingUtils.isWindowPrivate(privateWindow), "window's private");
-
- whenDelayedStartupFinished(privateWindow, onPrivateWindowReady);
- }
-
- function onPrivateWindowReady() {
- info("private browser window opened");
- privateBrowser = privateWindow.gBrowser;
-
- privateTab = privateBrowser.selectedTab = privateBrowser.addTab(TEST_URI);
- privateBrowser.selectedBrowser.addEventListener("load", function onLoad() {
- info("private tab opened");
- privateBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
- privateContent = privateBrowser.selectedBrowser.contentWindow;
- ok(PrivateBrowsingUtils.isBrowserPrivate(privateBrowser.selectedBrowser),
- "tab window is private");
- openConsole(privateTab).then(consoleOpened);
- }, true);
- }
-
- function addMessages() {
- let button = privateContent.document.querySelector("button");
- ok(button, "button in page");
- EventUtils.synthesizeMouse(button, 2, 2, {}, privateContent);
- }
-
- function consoleOpened(injectedHud) {
- hud = injectedHud;
- ok(hud, "web console opened");
-
- addMessages();
- expectedMessages = [
- {
- name: "script error",
- text: "fooBazBaz is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- name: "console message",
- text: "foobar bug 874061",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- ];
-
- // Make sure messages are displayed in the web console as they happen, even
- // if this is a private tab.
- waitForMessages({
- webconsole: hud,
- messages: expectedMessages,
- }).then(testCachedMessages);
- }
-
- function testCachedMessages() {
- info("testCachedMessages()");
- closeConsole(privateTab).then(() => {
- info("web console closed");
- openConsole(privateTab).then(consoleReopened);
- });
- }
-
- function consoleReopened(injectedHud) {
- hud = injectedHud;
- ok(hud, "web console reopened");
-
- // Make sure that cached messages are displayed in the web console, even
- // if this is a private tab.
- waitForMessages({
- webconsole: hud,
- messages: expectedMessages,
- }).then(testBrowserConsole);
- }
-
- function testBrowserConsole() {
- info("testBrowserConsole()");
- closeConsole(privateTab).then(() => {
- info("web console closed");
- HUDService.toggleBrowserConsole().then(onBrowserConsoleOpen);
- });
- }
-
- // Make sure that the cached messages from private tabs are not displayed in
- // the browser console.
- function checkNoPrivateMessages() {
- let text = hud.outputNode.textContent;
- is(text.indexOf("fooBazBaz"), -1, "no exception displayed");
- is(text.indexOf("bug 874061"), -1, "no console message displayed");
- }
-
- function onBrowserConsoleOpen(injectedHud) {
- hud = injectedHud;
- ok(hud, "browser console opened");
-
- checkNoPrivateMessages();
- addMessages();
- expectedMessages.push(nonPrivateMessage);
-
- // Make sure that live messages are displayed in the browser console, even
- // from private tabs.
- waitForMessages({
- webconsole: hud,
- messages: expectedMessages,
- }).then(testPrivateWindowClose);
- }
-
- function testPrivateWindowClose() {
- info("close the private window and check if private messages are removed");
- hud.jsterm.once("private-messages-cleared", () => {
- isnot(hud.outputNode.textContent.indexOf("bug874061-not-private"), -1,
- "non-private messages are still shown after private window closed");
- checkNoPrivateMessages();
-
- info("close the browser console");
- HUDService.toggleBrowserConsole().then(() => {
- info("reopen the browser console");
- executeSoon(() =>
- HUDService.toggleBrowserConsole().then(onBrowserConsoleReopen));
- });
- });
- privateWindow.BrowserTryToCloseWindow();
- }
-
- function onBrowserConsoleReopen(injectedHud) {
- hud = injectedHud;
- ok(hud, "browser console reopened");
-
- // Make sure that the non-private message is still shown after reopen.
- waitForMessages({
- webconsole: hud,
- messages: [nonPrivateMessage],
- }).then(() => {
- // Make sure that no private message is displayed after closing the
- // private window and reopening the Browser Console.
- checkNoPrivateMessages();
- executeSoon(finishTest);
- });
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_restore.js
+++ /dev/null
@@ -1,32 +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/ */
-
-// Check that the browser console gets session state is set correctly, and that
-// it re-opens when restore is requested.
-
-"use strict";
-
-add_task(async function() {
- is(HUDService.getBrowserConsoleSessionState(), false, "Session state false by default");
- HUDService.storeBrowserConsoleSessionState();
- is(HUDService.getBrowserConsoleSessionState(), false,
- "Session state still not true even after setting (since Browser Console is closed)");
-
- await HUDService.toggleBrowserConsole();
- HUDService.storeBrowserConsoleSessionState();
- is(HUDService.getBrowserConsoleSessionState(), true,
- "Session state true (since Browser Console is opened)");
-
- info("Closing the browser console and waiting for the session restore to reopen it")
- await HUDService.toggleBrowserConsole();
-
- let opened = waitForBrowserConsole();
- gDevTools.restoreDevToolsSession({
- browserConsole: true
- });
-
- info("Waiting for the console to open after session restore")
- await opened;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_server_logging.js
+++ /dev/null
@@ -1,117 +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/ */
-
-"use strict";
-
-// Check that server log appears in the console panel - bug 1168872
-add_task(function* () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/test/test-console-server-logging.sjs";
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- // Set logging filter and wait till it's set on the backend
- hud.setFilterState("serverlog", true);
- yield updateServerLoggingListener(hud);
-
- BrowserReloadSkipCache();
-
- // Note that the test is also checking out the (printf like)
- // formatters and encoding of UTF8 characters (see the one at the end).
- let text = "values: string Object { a: 10 } 123 1.12 \u2713";
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: text,
- category: CATEGORY_SERVER,
- severity: SEVERITY_LOG,
- }],
- });
- // Clean up filter
- hud.setFilterState("serverlog", false);
- yield updateServerLoggingListener(hud);
-});
-
-add_task(function* () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/test/test-console-server-logging-array.sjs";
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- // Set logging filter and wait till it's set on the backend
- hud.setFilterState("serverlog", true);
- yield updateServerLoggingListener(hud);
-
- BrowserReloadSkipCache();
- // Note that the test is also checking out the (printf like)
- // formatters and encoding of UTF8 characters (see the one at the end).
- let text = "Object { best: \"Firefox\", reckless: \"Chrome\", " +
- "new_ie: \"Safari\", new_new_ie: \"Edge\" }";
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: text,
- category: CATEGORY_SERVER,
- severity: SEVERITY_LOG,
- }],
- });
- // Clean up filter
- hud.setFilterState("serverlog", false);
- yield updateServerLoggingListener(hud);
-});
-
-add_task(function* () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/test/test-console-server-logging-backtrace.sjs";
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- // Set logging filter and wait till it's set on the backend
- hud.setFilterState("serverlog", true);
- yield updateServerLoggingListener(hud);
-
- BrowserReloadSkipCache();
- // Note that the test is also checking out the (printf like)
- // formatters and encoding of UTF8 characters (see the one at the end).
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "correct 1",
- category: CATEGORY_SERVER,
- severity: SEVERITY_ERROR,
- source: {url: "/some/path/to/file.py", line: 33}
- }, {
- text: "correct 2",
- category: CATEGORY_SERVER,
- severity: SEVERITY_ERROR,
- source: {url: "/some/path/to/file.py", line: 33}
- }, {
- text: "wrong 1",
- category: CATEGORY_SERVER,
- severity: SEVERITY_ERROR,
- source: {url: "/some/path/to/file.py:33wrong"}
- }, {
- text: "wrong 2",
- category: CATEGORY_SERVER,
- severity: SEVERITY_ERROR,
- source: {url: "/some/path/to/file.py"}
- }],
- });
- // Clean up filter
- hud.setFilterState("serverlog", false);
- yield updateServerLoggingListener(hud);
-});
-
-function updateServerLoggingListener(hud) {
- let deferred = defer();
- hud.ui._updateServerLoggingListener(response => {
- deferred.resolve(response);
- });
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view.js
+++ /dev/null
@@ -1,238 +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/ */
-
-// Check that variables view works as expected in the web console.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-eval-in-stackframe.html";
-
-var hud, gVariablesView;
-
-registerCleanupFunction(function () {
- hud = gVariablesView = null;
-});
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
-
- let msg = yield hud.jsterm.execute("(function foo(){})");
-
- ok(msg, "output message found");
- ok(msg.textContent.includes("function foo()"),
- "message text check");
-
- executeSoon(() => {
- EventUtils.synthesizeMouse(msg.querySelector("a"), 2, 2, {}, hud.iframeWindow);
- });
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
- ok(varView, "object inspector opened on click");
-
- yield findVariableViewProperties(varView, [{
- name: "name",
- value: "foo",
- }], { webconsole: hud });
-});
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
-
- let msg = yield hud.jsterm.execute("Function.prototype");
-
- ok(msg, "output message found");
- ok(msg.textContent.includes("function ()"),
- "message text check");
-
- executeSoon(() => {
- EventUtils.synthesizeMouse(msg.querySelector("a"), 2, 2, {}, hud.iframeWindow);
- });
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
- ok(varView, "object inspector opened on click");
-
- yield findVariableViewProperties(varView, [{
- name: "constructor",
- value: "Function()",
- }], { webconsole: hud });
-});
-
-add_task(function* () {
- let msg = yield hud.jsterm.execute("fooObj");
-
- ok(msg, "output message found");
- ok(msg.textContent.includes('{ testProp: "testValue" }'),
- "message text check");
-
- let anchor = msg.querySelector("a");
- ok(anchor, "object link found");
-
- let fetched = hud.jsterm.once("variablesview-fetched");
-
- // executeSoon
- EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow);
-
- let view = yield fetched;
-
- let results = yield onFooObjFetch(view);
-
- let vView = yield onTestPropFound(results);
- let results2 = yield onFooObjFetchAfterUpdate(vView);
-
- let vView2 = yield onUpdatedTestPropFound(results2);
- let results3 = yield onFooObjFetchAfterPropRename(vView2);
-
- let vView3 = yield onRenamedTestPropFound(results3);
- let results4 = yield onPropUpdateError(vView3);
-
- yield onRenamedTestPropFoundAgain(results4);
-
- let prop = results4[0].matchedProp;
- yield testPropDelete(prop);
-});
-
-function onFooObjFetch(aVar) {
- gVariablesView = aVar._variablesView;
- ok(gVariablesView, "variables view object");
-
- return findVariableViewProperties(aVar, [
- { name: "testProp", value: "testValue" },
- ], { webconsole: hud });
-}
-
-function onTestPropFound(aResults) {
- let prop = aResults[0].matchedProp;
- ok(prop, "matched the |testProp| property in the variables view");
-
- is("testValue", aResults[0].value,
- "|fooObj.testProp| value is correct");
-
- // Check that property value updates work and that jsterm functions can be
- // used.
- return updateVariablesViewProperty({
- property: prop,
- field: "value",
- string: "document.title + window.location + $('p')",
- webconsole: hud
- });
-}
-
-function onFooObjFetchAfterUpdate(aVar) {
- info("onFooObjFetchAfterUpdate");
- let expectedValue = gBrowser.contentTitle + gBrowser.currentURI.spec +
- "[object HTMLParagraphElement]";
-
- return findVariableViewProperties(aVar, [
- { name: "testProp", value: expectedValue },
- ], { webconsole: hud });
-}
-
-async function onUpdatedTestPropFound(aResults) {
- let prop = aResults[0].matchedProp;
- ok(prop, "matched the updated |testProp| property value");
-
- await ContentTask.spawn(gBrowser.selectedBrowser, aResults[0].value, function(value) {
- is(content.wrappedJSObject.fooObj.testProp, value,
- "|fooObj.testProp| value has been updated");
- });
-
- // Check that property name updates work.
- return updateVariablesViewProperty({
- property: prop,
- field: "name",
- string: "testUpdatedProp",
- webconsole: hud
- });
-}
-
-function* onFooObjFetchAfterPropRename(aVar) {
- info("onFooObjFetchAfterPropRename");
-
- let expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let para = content.wrappedJSObject.document.querySelector("p");
- return content.document.title + content.location + para;
- });
-
- // Check that the new value is in the variables view.
- return findVariableViewProperties(aVar, [
- { name: "testUpdatedProp", value: expectedValue },
- ], { webconsole: hud });
-}
-
-async function onRenamedTestPropFound(aResults) {
- let prop = aResults[0].matchedProp;
- ok(prop, "matched the renamed |testProp| property");
-
- await ContentTask.spawn(gBrowser.selectedBrowser, aResults[0].value, function(value) {
- ok(!content.wrappedJSObject.fooObj.testProp,
- "|fooObj.testProp| has been deleted");
- is(content.wrappedJSObject.fooObj.testUpdatedProp, value,
- "|fooObj.testUpdatedProp| is correct");
- });
-
- // Check that property value updates that cause exceptions are reported in
- // the web console output.
- return updateVariablesViewProperty({
- property: prop,
- field: "value",
- string: "foobarzFailure()",
- webconsole: hud
- });
-}
-
-function* onPropUpdateError(aVar) {
- info("onPropUpdateError");
-
- let expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let para = content.wrappedJSObject.document.querySelector("p");
- return content.document.title + content.location + para;
- });
-
- // Make sure the property did not change.
- return findVariableViewProperties(aVar, [
- { name: "testUpdatedProp", value: expectedValue },
- ], { webconsole: hud });
-}
-
-function onRenamedTestPropFoundAgain(aResults) {
- let prop = aResults[0].matchedProp;
- ok(prop, "matched the renamed |testProp| property again");
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- name: "exception in property update reported in the web console output",
- text: "foobarzFailure",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_ERROR,
- }],
- });
-}
-
-function testPropDelete(aProp) {
- gVariablesView.window.focus();
- aProp.focus();
-
- executeSoon(() => {
- EventUtils.synthesizeKey("VK_DELETE", {}, gVariablesView.window);
- });
-
- let success = false;
- return waitForSuccess({
- name: "property deleted",
- timeout: 60000,
- validator: function() {
- ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- return !("testUpdatedProp" in content.wrappedJSObject.fooObj);
- }).then((result) => success = result);
- return success;
- }
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_dom_nodes.js
+++ /dev/null
@@ -1,59 +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 that ensures DOM nodes are rendered correctly in VariablesView.
-
-"use strict";
-
-function test() {
- const TEST_URI = `
- data:text/html;charset=utf-8,
- <html>
- <head>
- <title>Test for DOM nodes in variables view</title>
- </head>
- <body>
- <div></div>
- <div id="testID"></div>
- <div class="single-class"></div>
- <div class="multiple-classes another-class"></div>
- <div class="class-and-id" id="class-and-id"></div>
- <div class="multiple-classes-and-id another-class"
- id="multiple-classes-and-id"></div>
- <div class=" whitespace-start"></div>
- <div class="whitespace-end "></div>
- <div class="multiple spaces"></div>
- </body>
- </html>
-`;
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
- const jsterm = hud.jsterm;
-
- let deferred = defer();
- jsterm.once("variablesview-fetched", (val) => deferred.resolve(val));
- jsterm.execute("inspect(document.querySelectorAll('div'))");
-
- let variableScope = yield deferred.promise;
- ok(variableScope, "Variables view opened");
-
- yield findVariableViewProperties(variableScope, [
- { name: "0", value: "<div>"},
- { name: "1", value: "<div#testID>"},
- { name: "2", value: "<div.single-class>"},
- { name: "3", value: "<div.multiple-classes.another-class>"},
- { name: "4", value: "<div#class-and-id.class-and-id>"},
- { name: "5", value: "<div#multiple-classes-and-id." +
- "multiple-classes-and-id.another-class>"},
- { name: "6", value: "<div.whitespace-start>"},
- { name: "7", value: "<div.whitespace-end>"},
- { name: "8", value: "<div.multiple.spaces>"},
- ], { webconsole: hud});
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
+++ /dev/null
@@ -1,135 +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/ */
-
-"use strict";
-
-/* Test case that ensures Array and other list types are not sorted in variables
- * view.
- *
- * The tested types are:
- * - Array
- * - Int8Array
- * - Int16Array
- * - Int32Array
- * - Uint8Array
- * - Uint16Array
- * - Uint32Array
- * - Uint8ClampedArray
- * - Float32Array
- * - Float64Array
- * - NodeList
- */
-
-function test() {
- const TEST_URI = "data:text/html;charset=utf-8, \
- <html> \
- <head> \
- <title>Test document for bug 977500</title> \
- </head> \
- <body> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- <div></div> \
- </body> \
- </html>";
-
- let jsterm;
-
- function* runner() {
- const typedArrayTypes = ["Int8Array", "Int16Array", "Int32Array",
- "Uint8Array", "Uint16Array", "Uint32Array",
- "Uint8ClampedArray", "Float32Array",
- "Float64Array"];
-
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
- jsterm = hud.jsterm;
-
- // Create an ArrayBuffer of 80 bytes to test TypedArrays. 80 bytes is
- // enough to get 10 items in all different TypedArrays.
- yield jsterm.execute("let buf = new ArrayBuffer(80);");
-
- // Array
- yield testNotSorted("Array(0,1,2,3,4,5,6,7,8,9,10)");
- // NodeList
- yield testNotSorted("document.querySelectorAll('div')");
- // Object
- yield testSorted("Object({'hello':1,1:5,10:2,4:2,'abc':1})");
-
- // Typed arrays.
- for (let type of typedArrayTypes) {
- yield testNotSorted("new " + type + "(buf)");
- }
- }
-
- /**
- * A helper that ensures the properties are not sorted when an object
- * specified by aObject is inspected.
- *
- * @param string aObject
- * A string that, once executed, creates and returns the object to
- * inspect.
- */
- function* testNotSorted(aObject) {
- info("Testing " + aObject);
- let deferred = defer();
- jsterm.once("variablesview-fetched", (aVar) => deferred.resolve(aVar));
- jsterm.execute("inspect(" + aObject + ")");
-
- let variableScope = yield deferred.promise;
- ok(variableScope, "Variables view opened");
-
- // If the properties are sorted: keys = ["0", "1", "10",...] <- incorrect
- // If the properties are not sorted: keys = ["0", "1", "2",...] <- correct
- let keyIterator = variableScope._store.keys();
- is(keyIterator.next().value, "0", "First key is 0");
- is(keyIterator.next().value, "1", "Second key is 1");
-
- // If the properties are sorted, the next one will be 10.
- is(keyIterator.next().value, "2", "Third key is 2, not 10");
- }
- /**
- * A helper that ensures the properties are sorted when an object
- * specified by aObject is inspected.
- *
- * @param string aObject
- * A string that, once executed, creates and returns the object to
- * inspect.
- */
- function* testSorted(aObject) {
- info("Testing " + aObject);
- let deferred = defer();
- jsterm.once("variablesview-fetched", (aVar) => deferred.resolve(aVar));
- jsterm.execute("inspect(" + aObject + ")");
-
- let variableScope = yield deferred.promise;
- ok(variableScope, "Variables view opened");
-
- // If the properties are sorted:
- // keys = ["1", "4", "10",..., "abc", "hello"] <- correct
- // If the properties are not sorted:
- // keys = ["1", "10", "4",...] <- incorrect
- let keyIterator = variableScope._store.keys();
- is(keyIterator.next().value, "1", "First key should be 1");
- is(keyIterator.next().value, "4", "Second key should be 4");
-
- // If the properties are sorted, the next one will be 10.
- is(keyIterator.next().value, "10", "Third key is 10");
- // If sorted next properties should be "abc" then "hello"
- is(keyIterator.next().value, "abc", "Fourth key is abc");
- is(keyIterator.next().value, "hello", "Fifth key is hello");
- }
-
- Task.spawn(runner).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_filter.js
+++ /dev/null
@@ -1,80 +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/ */
-
-// Check that variables view filter feature works fine in the console.
-
-function props(view, prefix = "") {
- // First match only the visible one, not hidden by a search
- let visible = [...view].filter(([id, prop]) => prop._isMatch);
- // Then flatten the list into a list of strings
- // being the jsonpath of each attribute being visible in the view
- return visible.reduce((list, [id, prop]) => {
- list.push(prefix + id);
- return list.concat(props(prop, prefix + id + "."));
- }, []);
-}
-
-function assertAttrs(view, expected, message) {
- is(props(view).join(","), expected, message);
-}
-
-add_task(function* () {
- yield loadTab("data:text/html;charset=utf-8,webconsole-filter");
-
- let hud = yield openConsole();
-
- let jsterm = hud.jsterm;
-
- let fetched = jsterm.once("variablesview-fetched");
-
- yield jsterm.execute("inspect({ foo: { bar : \"baz\" } })");
-
- let view = yield fetched;
- let variablesView = view._variablesView;
- let searchbox = variablesView._searchboxNode;
-
- assertAttrs(view, "foo,__proto__",
- "To start with, we just see the top level foo attr");
-
- fetched = jsterm.once("variablesview-fetched");
- searchbox.value = "bar";
- searchbox.doCommand();
- view = yield fetched;
-
- assertAttrs(view, "",
- "If we don't manually expand nested attr, we don't see them");
-
- fetched = jsterm.once("variablesview-fetched");
- searchbox.value = "";
- searchbox.doCommand();
- view = yield fetched;
-
- assertAttrs(view, "foo",
- "If we reset the search, we get back to original state");
-
- yield [...view][0][1].expand();
-
- fetched = jsterm.once("variablesview-fetched");
- searchbox.value = "bar";
- searchbox.doCommand();
- view = yield fetched;
-
- assertAttrs(view, "foo,foo.bar", "Now if we expand, we see the nested attr");
-
- fetched = jsterm.once("variablesview-fetched");
- searchbox.value = "baz";
- searchbox.doCommand();
- view = yield fetched;
-
- assertAttrs(view, "foo,foo.bar", "We can also search for attr values");
-
- fetched = jsterm.once("variablesview-fetched");
- searchbox.value = "";
- searchbox.doCommand();
- view = yield fetched;
-
- assertAttrs(view, "foo",
- "If we reset again, we get back to original state again");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_highlighter.js
+++ /dev/null
@@ -1,97 +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/ */
-
-// Check that variables view is linked to the inspector for highlighting and
-// selecting DOM nodes
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-952277-highlight-nodes-in-vview.html";
-
-var gWebConsole, gJSTerm, gVariablesView, gToolbox;
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then(hud => {
- consoleOpened(hud);
- });
- });
-}
-
-function consoleOpened(hud) {
- gWebConsole = hud;
- gJSTerm = hud.jsterm;
- gToolbox = gDevTools.getToolbox(hud.target);
- gJSTerm.execute("document.querySelectorAll('p')").then(onQSAexecuted);
-}
-
-function onQSAexecuted(msg) {
- ok(msg, "output message found");
- let anchor = msg.querySelector("a");
- ok(anchor, "object link found");
-
- gJSTerm.once("variablesview-fetched", onNodeListViewFetched);
-
- executeSoon(() =>
- EventUtils.synthesizeMouse(anchor, 2, 2, {}, gWebConsole.iframeWindow)
- );
-}
-
-function onNodeListViewFetched(variable) {
- gVariablesView = variable._variablesView;
- ok(gVariablesView, "variables view object");
-
- // Transform the vview into an array we can filter properties from
- let props = [...variable].map(([id, prop]) => [id, prop]);
-
- // These properties are the DOM nodes ones
- props = props.filter(v => v[0].match(/[0-9]+/));
-
- function hoverOverDomNodeVariableAndAssertHighlighter(index) {
- if (props[index]) {
- let prop = props[index][1];
-
- gToolbox.once("node-highlight", () => {
- ok(true, "The highlighter was shown on hover of the DOMNode");
- gToolbox.highlighterUtils.unhighlight().then(() => {
- clickOnDomNodeVariableAndAssertInspectorSelected(index);
- });
- });
-
- // Rather than trying to emulate a mouseenter event, let's call the
- // variable's highlightDomNode and see if it has the desired effect
- prop.highlightDomNode();
- } else {
- finishUp();
- }
- }
-
- function clickOnDomNodeVariableAndAssertInspectorSelected(index) {
- let prop = props[index][1];
-
- // Make sure the inspector is initialized so we can listen to its events
- gToolbox.initInspector().then(() => {
- // Rather than trying to click on the value here, let's just call the
- // variable's openNodeInInspector function and see if it has the
- // desired effect
- prop.openNodeInInspector().then(() => {
- is(gToolbox.currentToolId, "inspector",
- "The toolbox switched over the inspector on DOMNode click");
- gToolbox.selectTool("webconsole").then(() => {
- hoverOverDomNodeVariableAndAssertHighlighter(index + 1);
- });
- });
- });
- }
-
- hoverOverDomNodeVariableAndAssertHighlighter(0);
-}
-
-function finishUp() {
- gWebConsole = gJSTerm = gVariablesView = gToolbox = null;
-
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_special_names.js
+++ /dev/null
@@ -1,38 +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/ */
-
-// Check that variables view handles special names like "<return>"
-// properly for ordinary displays.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test for bug 1084430";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- ok(hud, "web console opened");
-
- hud.setFilterState("log", false);
- registerCleanupFunction(() => hud.setFilterState("log", true));
-
- hud.jsterm.execute("inspect({ '<return>': 47, '<exception>': 91 })");
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
- ok(varView, "variables view object");
-
- let props = yield findVariableViewProperties(varView, [
- { name: "<return>", value: 47 },
- { name: "<exception>", value: 91 },
- ], { webconsole: hud });
-
- for (let prop of props) {
- ok(!prop.matchedProp._internalItem, prop.name + " is not marked internal");
- let target = prop.matchedProp._target;
- ok(!target.hasAttribute("pseudo-item"),
- prop.name + " is not a pseudo-item");
- }
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_while_debugging.js
+++ /dev/null
@@ -1,109 +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 that makes sure web console eval happens in the user-selected stackframe
-// from the js debugger, when changing the value of a property in the variables
-// view.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-eval-in-stackframe.html";
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let dbgPanel = yield openDebugger();
- yield waitForFrameAdded();
- yield openConsole();
- yield testVariablesView(hud);
-});
-
-function* waitForFrameAdded() {
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
- let thread = toolbox.threadClient;
-
- info("Waiting for framesadded");
- yield new Promise(resolve => {
- thread.addOneTimeListener("framesadded", resolve);
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.firstCall();
- });
- });
-}
-
-function* testVariablesView(hud) {
- let jsterm = hud.jsterm;
- let msg = yield jsterm.execute("fooObj");
- ok(msg, "output message found");
- ok(msg.textContent.includes('{ testProp2: "testValue2" }'),
- "message text check");
-
- let anchor = msg.querySelector("a");
- ok(anchor, "object link found");
-
- info("Waiting for variable view to appear");
- let variable = yield new Promise(resolve => {
- jsterm.once("variablesview-fetched", (variable) => {
- resolve(variable);
- });
- executeSoon(() => EventUtils.synthesizeMouse(anchor, 2, 2, {},
- hud.iframeWindow));
- });
-
- info("Waiting for findVariableViewProperties");
- let results = yield findVariableViewProperties(variable, [
- { name: "testProp2", value: "testValue2" },
- { name: "testProp", value: "testValue", dontMatch: true },
- ], { webconsole: hud });
-
- let prop = results[0].matchedProp;
- ok(prop, "matched the |testProp2| property in the variables view");
-
- // Check that property value updates work and that jsterm functions can be
- // used.
- variable = yield updateVariablesViewProperty({
- property: prop,
- field: "value",
- string: "document.title + foo2 + $('p')",
- webconsole: hud
- });
-
- info("onFooObjFetchAfterUpdate");
- let expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let para = content.wrappedJSObject.document.querySelector("p");
- return content.document.title + "foo2SecondCall" + para;
- });
-
- results = yield findVariableViewProperties(variable, [
- { name: "testProp2", value: expectedValue },
- ], { webconsole: hud });
-
- prop = results[0].matchedProp;
- ok(prop, "matched the updated |testProp2| property value");
-
- // Check that testProp2 was updated.
- yield new Promise(resolve => {
- executeSoon(() => {
- jsterm.execute("fooObj.testProp2").then(resolve);
- });
- });
-
- expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let para = content.wrappedJSObject.document.querySelector("p");
- return content.document.title + "foo2SecondCall" + para;
- });
-
- isnot(hud.outputNode.textContent.indexOf(expectedValue), -1,
- "fooObj.testProp2 is correct");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_console_variables_view_while_debugging_and_inspecting.js
+++ /dev/null
@@ -1,112 +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 that makes sure web console eval works while the js debugger paused the
-// page, and while the inspector is active. See bug 886137.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-eval-in-stackframe.html";
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let dbgPanel = yield openDebugger();
- yield openInspector();
- yield waitForFrameAdded();
-
- yield openConsole();
- yield testVariablesView(hud);
-});
-
-function* waitForFrameAdded() {
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
- let thread = toolbox.threadClient;
-
- info("Waiting for framesadded");
- yield new Promise(resolve => {
- thread.addOneTimeListener("framesadded", resolve);
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.firstCall();
- });
- });
-}
-
-function* testVariablesView(hud) {
- info("testVariablesView");
- let jsterm = hud.jsterm;
-
- let msg = yield jsterm.execute("fooObj");
- ok(msg, "output message found");
- ok(msg.textContent.includes('{ testProp2: "testValue2" }'),
- "message text check");
-
- let anchor = msg.querySelector("a");
- ok(anchor, "object link found");
-
- info("Waiting for variable view to appear");
- let variable = yield new Promise(resolve => {
- jsterm.once("variablesview-fetched", (variable) => {
- resolve(variable);
- });
- executeSoon(() => EventUtils.synthesizeMouse(anchor, 2, 2, {},
- hud.iframeWindow));
- });
-
- info("Waiting for findVariableViewProperties");
- let results = yield findVariableViewProperties(variable, [
- { name: "testProp2", value: "testValue2" },
- { name: "testProp", value: "testValue", dontMatch: true },
- ], { webconsole: hud });
-
- let prop = results[0].matchedProp;
- ok(prop, "matched the |testProp2| property in the variables view");
-
- // Check that property value updates work and that jsterm functions can be
- // used.
- variable = yield updateVariablesViewProperty({
- property: prop,
- field: "value",
- string: "document.title + foo2 + $('p')",
- webconsole: hud
- });
-
- info("onFooObjFetchAfterUpdate");
- let expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let para = content.wrappedJSObject.document.querySelector("p");
- return content.document.title + "foo2SecondCall" + para;
- });
-
- results = yield findVariableViewProperties(variable, [
- { name: "testProp2", value: expectedValue },
- ], { webconsole: hud });
-
- prop = results[0].matchedProp;
- ok(prop, "matched the updated |testProp2| property value");
-
- // Check that testProp2 was updated.
- yield new Promise(resolve => {
- executeSoon(() => {
- jsterm.execute("fooObj.testProp2").then(resolve);
- });
- });
-
- expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let para = content.wrappedJSObject.document.querySelector("p");
- return content.document.title + "foo2SecondCall" + para;
- });
-
- isnot(hud.outputNode.textContent.indexOf(expectedValue), -1,
- "fooObj.testProp2 is correct");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_eval_in_debugger_stackframe.js
+++ /dev/null
@@ -1,157 +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 that makes sure web console eval happens in the user-selected stackframe
-// from the js debugger.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-eval-in-stackframe.html";
-
-var gWebConsole, gJSTerm, gDebuggerWin, gThread, gDebuggerController;
-var gStackframes;
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
-
-function consoleOpened(hud) {
- gWebConsole = hud;
- gJSTerm = hud.jsterm;
- gJSTerm.execute("foo").then(onExecuteFoo);
-}
-
-function onExecuteFoo() {
- isnot(gWebConsole.outputNode.textContent.indexOf("globalFooBug783499"), -1,
- "|foo| value is correct");
-
- gJSTerm.clearOutput();
-
- // Test for Bug 690529 - Web Console and Scratchpad should evaluate
- // expressions in the scope of the content window, not in a sandbox.
- executeSoon(() => {
- gJSTerm.execute("foo2 = 'newFoo'; window.foo2").then(onNewFoo2);
- });
-}
-
-function onNewFoo2(msg) {
- is(gWebConsole.outputNode.textContent.indexOf("undefined"), -1,
- "|undefined| is not displayed after adding |foo2|");
-
- ok(msg, "output result found");
-
- isnot(msg.textContent.indexOf("newFoo"), -1,
- "'newFoo' is displayed after adding |foo2|");
-
- gJSTerm.clearOutput();
-
- info("openDebugger");
- executeSoon(() => openDebugger().then(debuggerOpened));
-}
-
-function debuggerOpened(aResult) {
- gDebuggerWin = aResult.panelWin;
- gDebuggerController = gDebuggerWin.DebuggerController;
- gThread = gDebuggerController.activeThread;
- gStackframes = gDebuggerController.StackFrames;
-
- info("openConsole");
- executeSoon(() =>
- openConsole().then(() =>
- gJSTerm.execute("foo + foo2").then(onExecuteFooAndFoo2)
- )
- );
-}
-
-function onExecuteFooAndFoo2() {
- let expected = "globalFooBug783499newFoo";
- isnot(gWebConsole.outputNode.textContent.indexOf(expected), -1,
- "|foo + foo2| is displayed after starting the debugger");
-
- executeSoon(() => {
- gJSTerm.clearOutput();
-
- info("openDebugger");
- openDebugger().then(() => {
- gThread.addOneTimeListener("framesadded", onFramesAdded);
-
- info("firstCall()");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.firstCall();
- });
- });
- });
-}
-
-function onFramesAdded() {
- info("onFramesAdded, openConsole() now");
- executeSoon(() =>
- openConsole().then(() =>
- gJSTerm.execute("foo + foo2").then(onExecuteFooAndFoo2InSecondCall)
- )
- );
-}
-
-function onExecuteFooAndFoo2InSecondCall() {
- let expected = "globalFooBug783499foo2SecondCall";
- isnot(gWebConsole.outputNode.textContent.indexOf(expected), -1,
- "|foo + foo2| from |secondCall()|");
-
- function runOpenConsole() {
- openConsole().then(() => {
- gJSTerm.execute("foo + foo2 + foo3").then(onExecuteFoo23InFirstCall);
- });
- }
-
- executeSoon(() => {
- gJSTerm.clearOutput();
-
- info("openDebugger and selectFrame(1)");
-
- openDebugger().then(() => {
- gStackframes.selectFrame(1);
-
- info("openConsole");
- executeSoon(() => runOpenConsole());
- });
- });
-}
-
-function onExecuteFoo23InFirstCall() {
- let expected = "fooFirstCallnewFoofoo3FirstCall";
- isnot(gWebConsole.outputNode.textContent.indexOf(expected), -1,
- "|foo + foo2 + foo3| from |firstCall()|");
-
- executeSoon(() =>
- gJSTerm.execute("foo = 'abba'; foo3 = 'bug783499'; foo + foo3").then(
- onExecuteFooAndFoo3ChangesInFirstCall));
-}
-
-var onExecuteFooAndFoo3ChangesInFirstCall = Task.async(function*() {
- let expected = "abbabug783499";
- isnot(gWebConsole.outputNode.textContent.indexOf(expected), -1,
- "|foo + foo3| updated in |firstCall()|");
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
- is(content.wrappedJSObject.foo, "globalFooBug783499",
- "|foo| in content window");
- is(content.wrappedJSObject.foo2, "newFoo", "|foo2| in content window");
- ok(!content.wrappedJSObject.foo3,
- "|foo3| was not added to the content window");
- });
-
- gWebConsole = gJSTerm = gDebuggerWin = gThread = gDebuggerController =
- gStackframes = null;
- executeSoon(finishTest);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_eval_in_debugger_stackframe2.js
+++ /dev/null
@@ -1,71 +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 to make sure that web console commands can fire while paused at a
-// breakpoint that was triggered from a JS call. Relies on asynchronous js
-// evaluation over the protocol - see Bug 1088861.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-eval-in-stackframe.html";
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- info("open the web console");
- let hud = yield openConsole();
- let {jsterm} = hud;
-
- info("open the debugger");
- let {panelWin} = yield openDebugger();
- let {DebuggerController} = panelWin;
- let {activeThread} = DebuggerController;
-
- let firstCall = defer();
- let frameAdded = defer();
- executeSoon(() => {
- info("Executing firstCall");
- activeThread.addOneTimeListener("framesadded", () => {
- executeSoon(frameAdded.resolve);
- });
- jsterm.execute("firstCall()").then(firstCall.resolve);
- });
-
- info("Waiting for a frame to be added");
- yield frameAdded.promise;
-
- info("Executing basic command while paused");
- yield executeAndConfirm(jsterm, "1 + 2", "3");
-
- info("Executing command using scoped variables while paused");
- yield executeAndConfirm(jsterm, "foo + foo2",
- '"globalFooBug783499foo2SecondCall"');
-
- info("Resuming the thread");
- activeThread.resume();
-
- info("Checking the first command, which is the last to resolve since it " +
- "paused");
- let node = yield firstCall.promise;
- is(node.querySelector(".message-body").textContent,
- "undefined",
- "firstCall() returned correct value");
-});
-
-function* executeAndConfirm(jsterm, input, output) {
- info("Executing command `" + input + "`");
-
- let node = yield jsterm.execute(input);
-
- is(node.querySelector(".message-body").textContent, output,
- "Expected result from call to " + input);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_jsterm_inspect.js
+++ /dev/null
@@ -1,47 +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/ */
-
-// Check that the inspect() jsterm helper function works.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>hello bug 869981";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- let jsterm = hud.jsterm;
-
- /* Check that the window object is inspected */
- jsterm.execute("testProp = 'testValue'");
-
- let updated = jsterm.once("variablesview-updated");
- jsterm.execute("inspect(window)");
- let view = yield updated;
- ok(view, "variables view object");
-
- // The single variable view contains a scope with the variable name
- // and unnamed subitem that contains the properties
- let variable = view.getScopeAtIndex(0).get(undefined);
- ok(variable, "variable object");
-
- yield findVariableViewProperties(variable, [
- { name: "testProp", value: "testValue" },
- { name: "document", value: /HTMLDocument \u2192 data:/ },
- ], { webconsole: hud });
-
- /* Check that a primitive value can be inspected, too */
- let updated2 = jsterm.once("variablesview-updated");
- jsterm.execute("inspect(1)");
- let view2 = yield updated2;
- ok(view2, "variables view object");
-
- // Check the label of the scope - it should contain the value
- let scope = view.getScopeAtIndex(0);
- ok(scope, "variable object");
-
- is(scope.name, "1", "The value of the primitive var is correct");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_longstring_hang.js
+++ /dev/null
@@ -1,57 +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 that very long strings do not hang the browser.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-859170-longstring-hang.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- info("wait for the initial long string");
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "find 'foobar', no 'foobaz', in long string output",
- text: "foobar",
- noText: "foobaz",
- category: CATEGORY_WEBDEV,
- longString: true,
- },
- ],
- });
-
- let clickable = results[0].longStrings[0];
- ok(clickable, "long string ellipsis is shown");
- clickable.scrollIntoView(false);
-
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
-
- info("wait for long string expansion");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "find 'foobaz' after expand, but no 'boom!' at the end",
- text: "foobaz",
- noText: "boom!",
- category: CATEGORY_WEBDEV,
- longString: false,
- },
- {
- text: "too long to be displayed",
- longString: false,
- },
- ],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_netmonitor_shows_reqs_in_webconsole.js
+++ /dev/null
@@ -1,81 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Test that the netmonitor " +
- "displays requests that have been recorded in the " +
- "web console, even if the netmonitor hadn't opened yet.";
-
-const TEST_FILE = "test-network-request.html";
-const TEST_PATH = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/" + TEST_FILE;
-
-const NET_PREF = "devtools.webconsole.filter.networkinfo";
-Services.prefs.setBoolPref(NET_PREF, true);
-registerCleanupFunction(() => {
- Services.prefs.clearUserPref(NET_PREF);
-});
-
-add_task(function* () {
- let { tab, browser } = yield loadTab(TEST_URI);
-
- // Test that the request appears in the console.
- let hud = yield openConsole();
- info("Web console is open");
-
- yield loadDocument(browser);
- info("Document loaded.");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "network message",
- text: TEST_FILE,
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG
- }
- ]
- });
-
- // Test that the request appears in the network panel.
- let target = TargetFactory.forTab(tab);
- let toolbox = yield gDevTools.showToolbox(target, "netmonitor");
- info("Network panel is open.");
-
- yield testNetmonitor(toolbox);
-});
-
-function loadDocument(browser) {
- let deferred = defer();
-
- BrowserTestUtils.browserLoaded(browser).then(function () {
- deferred.resolve();
- });
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_PATH);
-
- return deferred.promise;
-}
-
-function* testNetmonitor(toolbox) {
- let monitor = toolbox.getCurrentPanel();
-
- let { store, windowRequire } = monitor.panelWin;
- let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
- let { getSortedRequests } =
- windowRequire("devtools/client/netmonitor/src/selectors/index");
-
- store.dispatch(Actions.batchEnable(false));
-
- yield waitUntil(() => store.getState().requests.requests.size > 0);
-
- is(store.getState().requests.requests.size, 1,
- "Network request appears in the network panel");
-
- let item = getSortedRequests(store.getState()).get(0);
- is(item.method, "GET", "The attached method is correct.");
- is(item.url, TEST_PATH, "The attached url is correct.");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_output_breaks_after_console_dir_uninspectable.js
+++ /dev/null
@@ -1,49 +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/ */
-
-// Make sure that the Web Console output does not break after we try to call
-// console.dir() for objects that are not inspectable.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,test for bug 773466";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput(true);
-
- hud.jsterm.execute("console.log('fooBug773466a')");
- hud.jsterm.execute("myObj = Object.create(null)");
- hud.jsterm.execute("console.dir(myObj)");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "fooBug773466a",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- name: "console.dir output",
- consoleDir: "[object Object]",
- }],
- });
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("bug fooBug773466b");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "fooBug773466b",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_output_longstring_expand.js
+++ /dev/null
@@ -1,85 +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 that long strings can be expanded in the console output.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,test for bug 787981 - check " +
- "that long strings can be expanded in the output.";
-
-add_task(function* () {
- let { DebuggerServer } = require("devtools/server/main");
-
- let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4))
- .join("a") + "foobar";
- let initialString =
- longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput(true);
- hud.jsterm.execute("console.log('bazbaz', '" + longString + "', 'boom')");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log output",
- text: ["bazbaz", "boom", initialString],
- noText: "foobar",
- longString: true,
- }],
- });
-
- let clickable = result.longStrings[0];
- ok(clickable, "long string ellipsis is shown");
-
- clickable.scrollIntoView(false);
-
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "full string",
- text: ["bazbaz", "boom", longString],
- category: CATEGORY_WEBDEV,
- longString: false,
- }],
- });
-
- hud.jsterm.clearOutput(true);
- let msg = yield execute(hud, "'" + longString + "'");
-
- isnot(msg.textContent.indexOf(initialString), -1,
- "initial string is shown");
- is(msg.textContent.indexOf(longString), -1,
- "full string is not shown");
-
- clickable = msg.querySelector(".longStringEllipsis");
- ok(clickable, "long string ellipsis is shown");
-
- clickable.scrollIntoView(false);
-
- EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "full string",
- text: longString,
- category: CATEGORY_OUTPUT,
- longString: false,
- }],
- });
-});
-
-function execute(hud, str) {
- let deferred = defer();
- hud.jsterm.execute(str, deferred.resolve);
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_repeated_messages_accuracy.js
+++ /dev/null
@@ -1,178 +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 that makes sure messages are not considered repeated when coming from
-// different lines of code, or from different severities, etc.
-// See bugs 720180 and 800510.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-repeated-messages.html";
-const PREF = "devtools.webconsole.persistlog";
-
-add_task(function* () {
- Services.prefs.setBoolPref(PREF, true);
-
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield consoleOpened(hud);
-
- let loaded = loadBrowser(browser);
- BrowserReload();
- yield loaded;
-
- yield testCSSRepeats(hud);
- yield testCSSRepeatsAfterReload(hud);
- yield testConsoleRepeats(hud);
- yield testConsoleFalsyValues(hud);
-
- Services.prefs.clearUserPref(PREF);
-});
-
-function consoleOpened(hud) {
- // Check that css warnings are not coalesced if they come from different
- // lines.
- info("waiting for 2 css warnings");
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- name: "two css warnings",
- category: CATEGORY_CSS,
- count: 2,
- repeats: 1,
- }],
- });
-}
-
-function testCSSRepeats(hud) {
- info("wait for repeats after page reload");
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- name: "two css warnings, repeated twice",
- category: CATEGORY_CSS,
- repeats: 2,
- count: 2,
- }],
- });
-}
-
-function testCSSRepeatsAfterReload(hud) {
- hud.jsterm.clearOutput(true);
- hud.jsterm.execute("testConsole()");
-
- info("wait for repeats with the console API");
-
- return waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "console.log 'foo repeat' repeated twice",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 2,
- },
- {
- name: "console.log 'foo repeat' repeated once",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 1,
- },
- {
- name: "console.error 'foo repeat' repeated once",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- repeats: 1,
- },
- ],
- });
-}
-
-function testConsoleRepeats(hud) {
- hud.jsterm.clearOutput(true);
- hud.jsterm.execute("undefined");
-
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.console.log("undefined");
- });
-
- info("make sure console API messages are not coalesced with jsterm output");
-
- return waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "'undefined' jsterm input message",
- text: "undefined",
- category: CATEGORY_INPUT,
- },
- {
- name: "'undefined' jsterm output message",
- text: "undefined",
- category: CATEGORY_OUTPUT,
- },
- {
- name: "'undefined' console.log message",
- text: "undefined",
- category: CATEGORY_WEBDEV,
- repeats: 1,
- },
- ],
- });
-}
-
-function testConsoleFalsyValues(hud) {
- hud.jsterm.clearOutput(true);
- hud.jsterm.execute("testConsoleFalsyValues()");
-
- info("wait for repeats of falsy values with the console API");
-
- return waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "console.log 'NaN' repeated once",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 1,
- },
- {
- name: "console.log 'undefined' repeated once",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 1,
- },
- {
- name: "console.log 'null' repeated once",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 1,
- },
- {
- name: "console.log 'NaN' repeated twice",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 2,
- },
- {
- name: "console.log 'undefined' repeated twice",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 2,
- },
- {
- name: "console.log 'null' repeated twice",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 2,
- },
- ],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_result_format_as_string.js
+++ /dev/null
@@ -1,40 +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/ */
-
-// Make sure that JS eval result are properly formatted as strings.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-result-format-as-string.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput(true);
-
- let msg = yield execute(hud, "document.querySelector('p')");
-
- is(hud.outputNode.textContent.indexOf("bug772506_content"), -1,
- "no content element found");
- ok(!hud.outputNode.querySelector("#foobar"), "no #foobar element found");
-
- ok(msg, "eval output node found");
- is(msg.textContent.indexOf("<div>"), -1,
- "<div> string is not displayed");
- isnot(msg.textContent.indexOf("<p>"), -1,
- "<p> string is displayed");
-
- EventUtils.synthesizeMouseAtCenter(msg, {type: "mousemove"});
- ok(!gBrowser._bug772506, "no content variable");
-});
-
-function execute(hud, str) {
- let deferred = defer();
- hud.jsterm.execute(str, deferred.resolve);
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_warn_user_about_replaced_api.js
+++ /dev/null
@@ -1,86 +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/ */
-
-"use strict";
-
-const TEST_REPLACED_API_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-console-replaced-api.html";
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/testscript.js";
-const PREF = "devtools.webconsole.persistlog";
-
-add_task(function* () {
- Services.prefs.setBoolPref(PREF, true);
-
- let { browser } = yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- yield testWarningNotPresent(hud);
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_REPLACED_API_URI);
- yield loaded;
-
- let hud2 = yield openConsole();
-
- yield testWarningPresent(hud2);
-
- Services.prefs.clearUserPref(PREF);
-});
-
-function testWarningNotPresent(hud) {
- let deferred = defer();
-
- is(hud.outputNode.textContent.indexOf("logging API"), -1,
- "no warning displayed");
-
- // Bug 862024: make sure the warning doesn't show after page reload.
- info("reload " + TEST_URI);
- executeSoon(function () {
- let browser = gBrowser.selectedBrowser;
- ContentTask.spawn(browser, null, "() => content.location.reload()");
- });
-
- waitForMessages({
- webconsole: hud,
- messages: [{
- text: "testscript.js",
- category: CATEGORY_NETWORK,
- }],
- }).then(() => executeSoon(() => {
- is(hud.outputNode.textContent.indexOf("logging API"), -1,
- "no warning displayed");
- closeConsole().then(deferred.resolve);
- }));
-
- return deferred.promise;
-}
-
-function testWarningPresent(hud) {
- info("wait for the warning to show");
- let deferred = defer();
-
- let warning = {
- webconsole: hud,
- messages: [{
- text: /logging API .+ disabled by a script/,
- category: CATEGORY_JS,
- severity: SEVERITY_WARNING,
- }],
- };
-
- waitForMessages(warning).then(() => {
- hud.jsterm.clearOutput();
-
- executeSoon(() => {
- info("reload the test page and wait for the warning to show");
- waitForMessages(warning).then(deferred.resolve);
- let browser = gBrowser.selectedBrowser;
- ContentTask.spawn(browser, null, "() => content.location.reload()");
- });
- });
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_allow_mixedcontent_securityerrors.js
+++ /dev/null
@@ -1,70 +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/ */
-
-// The test loads a web page with mixed active and display content
-// on it while the "block mixed content" settings are _off_.
-// It then checks that the loading mixed content warning messages
-// are logged to the console and have the correct "Learn More"
-// url appended to them.
-// Bug 875456 - Log mixed content messages from the Mixed Content
-// Blocker to the Security Pane in the Web Console
-
-"use strict";
-
-const TEST_URI = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-mixedcontent-securityerrors.html";
-const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Web/Security/" +
- "Mixed_content" + DOCS_GA_PARAMS;
-
-add_task(function* () {
- yield pushPrefEnv();
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Logged mixed active content",
- text: "Loading mixed (insecure) active content " +
- "\u201chttp://example.com/\u201d on a secure page",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- {
- name: "Logged mixed passive content - image",
- text: "Loading mixed (insecure) display content " +
- "\u201chttp://example.com/tests/image/test/mochitest/blue.png\u201d " +
- "on a secure page",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- ],
- });
-
- yield testClickOpenNewTab(hud, results);
-});
-
-function pushPrefEnv() {
- let deferred = defer();
- let options = {"set":
- [["security.mixed_content.block_active_content", false],
- ["security.mixed_content.upgrade_display_content", false],
- ["security.mixed_content.block_display_content", false]
- ]};
- SpecialPowers.pushPrefEnv(options, deferred.resolve);
- return deferred.promise;
-}
-
-function testClickOpenNewTab(hud, results) {
- let warningNode = results[0].clickableElements[0];
- ok(warningNode, "link element");
- ok(warningNode.classList.contains("learn-more-link"), "link class name");
- return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_assert.js
+++ /dev/null
@@ -1,56 +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 that console.assert() works as expected (i.e. outputs only on falsy
-// asserts). See bug 760193.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-assert.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- yield consoleOpened(hud);
-});
-
-function consoleOpened(hud) {
- hud.jsterm.execute("test()");
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "undefined",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_LOG,
- },
- {
- text: "start",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "false assert",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- },
- {
- text: "falsy assert",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- },
- {
- text: "end",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- }).then(() => {
- let nodes = hud.outputNode.querySelectorAll(".message");
- is(nodes.length, 6,
- "only six messages are displayed, no output from the true assert");
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js
+++ /dev/null
@@ -1,47 +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/ */
-
-"use strict";
-
-// Test that properties starting with underscores or dollars can be
-// autocompleted (bug 967468).
-
-add_task(function* () {
- const TEST_URI = "data:text/html;charset=utf8,test autocompletion with " +
- "$ or _";
- yield loadTab(TEST_URI);
-
- function* autocomplete(term) {
- let deferred = defer();
-
- jsterm.setInputValue(term);
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, deferred.resolve);
-
- yield deferred.promise;
-
- ok(popup.itemCount > 0,
- "There's " + popup.itemCount + " suggestions for '" + term + "'");
- }
-
- let { jsterm } = yield openConsole();
- let popup = jsterm.autocompletePopup;
-
- yield jsterm.execute("var testObject = {$$aaab: '', $$aaac: ''}");
-
- // Should work with bug 967468.
- yield autocomplete("Object.__d");
- yield autocomplete("testObject.$$a");
-
- // Here's when things go wrong in bug 967468.
- yield autocomplete("Object.__de");
- yield autocomplete("testObject.$$aa");
-
- // Should work with bug 1207868.
- yield jsterm.execute("let foobar = {a: ''}; const blargh = {a: 1};");
- yield autocomplete("foobar");
- yield autocomplete("blargh");
- yield autocomplete("foobar.a");
- yield autocomplete("blargh.a");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_autocomplete_accessibility.js
+++ /dev/null
@@ -1,60 +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/ */
-
-// Tests that the autocomplete input is being blurred and focused when selecting a value.
-// This will help screen-readers notify users of the value that was set in the input.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test code completion";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let jsterm = hud.jsterm;
- let input = jsterm.inputNode;
-
- info("Type 'd' to open the autocomplete popup");
- yield autocomplete(jsterm, "d");
-
- // Add listeners for focus and blur events.
- let wasBlurred = false;
- input.addEventListener("blur", () => {
- wasBlurred = true;
- }, {
- once: true
- });
-
- let wasFocused = false;
- input.addEventListener("blur", () => {
- ok(wasBlurred, "jsterm input received a blur event before received back the focus");
- wasFocused = true;
- }, {
- once: true
- });
-
- info("Close the autocomplete popup by simulating a TAB key event");
- let onPopupClosed = jsterm.autocompletePopup.once("popup-closed");
- EventUtils.synthesizeKey("KEY_Tab");
-
- info("Wait for the autocomplete popup to be closed");
- yield onPopupClosed;
-
- ok(wasFocused, "jsterm input received a focus event");
-});
-
-function* autocomplete(jsterm, value) {
- let popup = jsterm.autocompletePopup;
-
- yield new Promise(resolve => {
- jsterm.setInputValue(value);
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- ok(popup.isOpen && popup.itemCount > 0,
- "Autocomplete popup is open and contains suggestions");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_autocomplete_and_selfxss.js
+++ /dev/null
@@ -1,130 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642615";
-
-XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
- "@mozilla.org/widget/clipboardhelper;1",
- "nsIClipboardHelper");
-var WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield consoleOpened(hud);
-});
-
-function consoleOpened(HUD) {
- let deferred = defer();
-
- let jsterm = HUD.jsterm;
- let stringToCopy = "foobazbarBug642615";
-
- jsterm.clearOutput();
-
- ok(!jsterm.completeNode.value, "no completeNode.value");
-
- jsterm.setInputValue("doc");
-
- let completionValue;
-
- // wait for key "u"
- function onCompletionValue() {
- completionValue = jsterm.completeNode.value;
-
- // Arguments: expected, setup, success, failure.
- waitForClipboard(
- stringToCopy,
- function () {
- clipboardHelper.copyString(stringToCopy);
- },
- onClipboardCopy,
- finishTest);
- }
-
- function onClipboardCopy() {
- testSelfXss();
-
- jsterm.setInputValue("docu");
- info("wait for completion update after clipboard paste");
- updateEditUIVisibility();
- jsterm.once("autocomplete-updated", onClipboardPaste);
- goDoCommand("cmd_paste");
- }
-
- // Self xss prevention tests (bug 994134)
- function testSelfXss() {
- info("Self-xss paste tests");
- WebConsoleUtils.usageCount = 0;
- is(WebConsoleUtils.usageCount, 0, "Test for usage count getter");
- // Input some commands to check if usage counting is working
- for (let i = 0; i <= 3; i++) {
- jsterm.setInputValue(i);
- jsterm.execute();
- }
- is(WebConsoleUtils.usageCount, 4, "Usage count incremented");
- WebConsoleUtils.usageCount = 0;
- updateEditUIVisibility();
-
- let oldVal = jsterm.getInputValue();
- goDoCommand("cmd_paste");
- let notificationbox = jsterm.hud.document.getElementById("webconsole-notificationbox");
- let notification = notificationbox.getNotificationWithValue("selfxss-notification");
- ok(notification, "Self-xss notification shown");
- is(oldVal, jsterm.getInputValue(), "Paste blocked by self-xss prevention");
-
- // Allow pasting
- jsterm.setInputValue("allow pasting");
- let evt = document.createEvent("KeyboardEvent");
- evt.initKeyEvent("keyup", true, true, window,
- 0, 0, 0, 0,
- 0, " ".charCodeAt(0));
- jsterm.inputNode.dispatchEvent(evt);
- jsterm.setInputValue("");
- goDoCommand("cmd_paste");
- isnot("", jsterm.getInputValue(), "Paste works");
- }
- function onClipboardPaste() {
- ok(!jsterm.completeNode.value, "no completion value after paste");
-
- info("wait for completion update after undo");
- jsterm.once("autocomplete-updated", onCompletionValueAfterUndo);
-
- // Get out of the webconsole event loop.
- executeSoon(() => {
- goDoCommand("cmd_undo");
- });
- }
-
- function onCompletionValueAfterUndo() {
- is(jsterm.completeNode.value, completionValue,
- "same completeNode.value after undo");
-
- info("wait for completion update after clipboard paste (ctrl-v)");
- jsterm.once("autocomplete-updated", () => {
- ok(!jsterm.completeNode.value,
- "no completion value after paste (ctrl-v)");
-
- // using executeSoon() to get out of the webconsole event loop.
- executeSoon(deferred.resolve);
- });
-
- // Get out of the webconsole event loop.
- executeSoon(() => {
- EventUtils.synthesizeKey("v", {accelKey: true});
- });
- }
-
- info("wait for completion value after typing 'docu'");
- jsterm.once("autocomplete-updated", onCompletionValue);
-
- EventUtils.sendString("u");
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_autocomplete_crossdomain_iframe.js
+++ /dev/null
@@ -1,64 +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 that autocomplete doesn't break when trying to reach into objects from
-// a different domain, bug 989025.
-
-"use strict";
-
-function test() {
- let hud;
-
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-989025-iframe-parent.html";
-
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
-
- hud.jsterm.execute("document.title");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "989025 - iframe parent",
- category: CATEGORY_OUTPUT,
- }],
- });
-
- let autocompleteUpdated = hud.jsterm.once("autocomplete-updated");
-
- hud.jsterm.setInputValue("window[0].document");
- executeSoon(() => {
- EventUtils.sendString(".");
- });
-
- yield autocompleteUpdated;
-
- hud.jsterm.setInputValue("window[0].document.title");
- EventUtils.synthesizeKey("KEY_Enter");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Permission denied",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_ERROR,
- }],
- });
-
- hud.jsterm.execute("window.location");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test-bug-989025-iframe-parent.html",
- category: CATEGORY_OUTPUT,
- }],
- });
-
- yield closeConsole(tab);
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_autocomplete_in_debugger_stackframe.js
+++ /dev/null
@@ -1,245 +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 that makes sure web console autocomplete happens in the user-selected
-// stackframe from the js debugger.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-autocomplete-in-stackframe.html";
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-var gStackframes;
-registerCleanupFunction(function () {
- gStackframes = null;
-});
-
-requestLongerTimeout(2);
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- yield testCompletion(hud);
-});
-
-function* testCompletion(hud) {
- let jsterm = hud.jsterm;
- let input = jsterm.inputNode;
- let popup = jsterm.autocompletePopup;
-
- // Test that document.title gives string methods. Native getters must execute.
- input.value = "document.title.";
- input.setSelectionRange(input.value.length, input.value.length);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- let newItems = popup.getItems();
- ok(newItems.length > 0, "'document.title.' gave a list of suggestions");
- ok(newItems.some(function (item) {
- return item.label == "substr";
- }), "autocomplete results do contain substr");
- ok(newItems.some(function (item) {
- return item.label == "toLowerCase";
- }), "autocomplete results do contain toLowerCase");
- ok(newItems.some(function (item) {
- return item.label == "strike";
- }), "autocomplete results do contain strike");
-
- // Test if 'f' gives 'foo1' but not 'foo2' or 'foo3'
- input.value = "f";
- input.setSelectionRange(1, 1);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(newItems.length > 0, "'f' gave a list of suggestions");
- ok(!newItems.every(function (item) {
- return item.label != "foo1";
- }), "autocomplete results do contain foo1");
- ok(!newItems.every(function (item) {
- return item.label != "foo1Obj";
- }), "autocomplete results do contain foo1Obj");
- ok(newItems.every(function (item) {
- return item.label != "foo2";
- }), "autocomplete results do not contain foo2");
- ok(newItems.every(function (item) {
- return item.label != "foo2Obj";
- }), "autocomplete results do not contain foo2Obj");
- ok(newItems.every(function (item) {
- return item.label != "foo3";
- }), "autocomplete results do not contain foo3");
- ok(newItems.every(function (item) {
- return item.label != "foo3Obj";
- }), "autocomplete results do not contain foo3Obj");
-
- // Test if 'foo1Obj.' gives 'prop1' and 'prop2'
- input.value = "foo1Obj.";
- input.setSelectionRange(8, 8);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(!newItems.every(function (item) {
- return item.label != "prop1";
- }), "autocomplete results do contain prop1");
- ok(!newItems.every(function (item) {
- return item.label != "prop2";
- }), "autocomplete results do contain prop2");
-
- // Test if 'foo1Obj.prop2.' gives 'prop21'
- input.value = "foo1Obj.prop2.";
- input.setSelectionRange(14, 14);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(!newItems.every(function (item) {
- return item.label != "prop21";
- }), "autocomplete results do contain prop21");
-
- info("Opening Debugger");
- let dbg = yield openDebugger();
-
- info("Waiting for pause");
- yield pauseDebugger(dbg);
-
- info("Opening Console again");
- yield openConsole();
-
- // From this point on the
- // Test if 'f' gives 'foo3' and 'foo1' but not 'foo2'
- input.value = "f";
- input.setSelectionRange(1, 1);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(newItems.length > 0, "'f' gave a list of suggestions");
- ok(!newItems.every(function (item) {
- return item.label != "foo3";
- }), "autocomplete results do contain foo3");
- ok(!newItems.every(function (item) {
- return item.label != "foo3Obj";
- }), "autocomplete results do contain foo3Obj");
- ok(!newItems.every(function (item) {
- return item.label != "foo1";
- }), "autocomplete results do contain foo1");
- ok(!newItems.every(function (item) {
- return item.label != "foo1Obj";
- }), "autocomplete results do contain foo1Obj");
- ok(newItems.every(function (item) {
- return item.label != "foo2";
- }), "autocomplete results do not contain foo2");
- ok(newItems.every(function (item) {
- return item.label != "foo2Obj";
- }), "autocomplete results do not contain foo2Obj");
-
- yield openDebugger();
-
- gStackframes.selectFrame(1);
-
- info("openConsole");
- yield openConsole();
-
- // Test if 'f' gives 'foo2' and 'foo1' but not 'foo3'
- input.value = "f";
- input.setSelectionRange(1, 1);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(newItems.length > 0, "'f' gave a list of suggestions");
- ok(!newItems.every(function (item) {
- return item.label != "foo2";
- }), "autocomplete results do contain foo2");
- ok(!newItems.every(function (item) {
- return item.label != "foo2Obj";
- }), "autocomplete results do contain foo2Obj");
- ok(!newItems.every(function (item) {
- return item.label != "foo1";
- }), "autocomplete results do contain foo1");
- ok(!newItems.every(function (item) {
- return item.label != "foo1Obj";
- }), "autocomplete results do contain foo1Obj");
- ok(newItems.every(function (item) {
- return item.label != "foo3";
- }), "autocomplete results do not contain foo3");
- ok(newItems.every(function (item) {
- return item.label != "foo3Obj";
- }), "autocomplete results do not contain foo3Obj");
-
- // Test if 'foo2Obj.' gives 'prop1'
- input.value = "foo2Obj.";
- input.setSelectionRange(8, 8);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(!newItems.every(function (item) {
- return item.label != "prop1";
- }), "autocomplete results do contain prop1");
-
- // Test if 'foo2Obj.prop1.' gives 'prop11'
- input.value = "foo2Obj.prop1.";
- input.setSelectionRange(14, 14);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(!newItems.every(function (item) {
- return item.label != "prop11";
- }), "autocomplete results do contain prop11");
-
- // Test if 'foo2Obj.prop1.prop11.' gives suggestions for a string
- // i.e. 'length'
- input.value = "foo2Obj.prop1.prop11.";
- input.setSelectionRange(21, 21);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- ok(!newItems.every(function (item) {
- return item.label != "length";
- }), "autocomplete results do contain length");
-
- // Test if 'foo1Obj[0].' throws no errors.
- input.value = "foo2Obj[0].";
- input.setSelectionRange(11, 11);
- yield new Promise(resolve => {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);
- });
-
- newItems = popup.getItems();
- is(newItems.length, 0, "no items for foo2Obj[0]");
-}
-
-function pauseDebugger(aResult) {
- let debuggerWin = aResult.panelWin;
- let debuggerController = debuggerWin.DebuggerController;
- let thread = debuggerController.activeThread;
- gStackframes = debuggerController.StackFrames;
- return new Promise(resolve => {
- thread.addOneTimeListener("framesadded", resolve);
-
- info("firstCall()");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.firstCall();
- });
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js
+++ /dev/null
@@ -1,27 +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 that the autocomplete popup closes on switching tabs. See bug 900448.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>bug 900448 - autocomplete " +
- "popup closes on tab switch";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- let popup = hud.jsterm.autocompletePopup;
- let popupShown = once(popup, "popup-opened");
-
- hud.jsterm.setInputValue("sc");
- EventUtils.sendString("r");
-
- yield popupShown;
-
- yield loadTab("data:text/html;charset=utf-8,<p>testing autocomplete closes");
-
- ok(!popup.isOpen, "Popup closes on tab switch");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_block_mixedcontent_securityerrors.js
+++ /dev/null
@@ -1,109 +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/ */
-
-// The test loads a web page with mixed active and display content
-// on it while the "block mixed content" settings are _on_.
-// It then checks that the blocked mixed content warning messages
-// are logged to the console and have the correct "Learn More"
-// url appended to them. After the first test finishes, it invokes
-// a second test that overrides the mixed content blocker settings
-// by clicking on the doorhanger shield and validates that the
-// appropriate messages are logged to console.
-// Bug 875456 - Log mixed content messages from the Mixed Content
-// Blocker to the Security Pane in the Web Console
-
-"use strict";
-
-const TEST_URI = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-mixedcontent-securityerrors.html";
-const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Web/Security/" +
- "Mixed_content" + DOCS_GA_PARAMS;
-
-add_task(function* () {
- yield pushPrefEnv();
-
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Logged blocking mixed active content",
- text: "Blocked loading mixed active content \u201chttp://example.com/\u201d",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_ERROR,
- objects: true,
- },
- {
- name: "Logged blocking mixed passive content - image",
- text: "Blocked loading mixed active content \u201chttp://example.com/\u201d",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_ERROR,
- objects: true,
- },
- ],
- });
-
- yield testClickOpenNewTab(hud, results[0]);
-
- let results2 = yield mixedContentOverrideTest2(hud, browser);
-
- yield testClickOpenNewTab(hud, results2[0]);
-});
-
-function pushPrefEnv() {
- let deferred = defer();
- let options = {
- "set": [
- ["security.mixed_content.block_active_content", true],
- ["security.mixed_content.block_display_content", true],
- ["security.mixed_content.upgrade_display_content", false],
- ]
- };
- SpecialPowers.pushPrefEnv(options, deferred.resolve);
- return deferred.promise;
-}
-
-function mixedContentOverrideTest2(hud, browser) {
- let deferred = defer();
- let {gIdentityHandler} = browser.ownerGlobal;
- ok(gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
- "Mixed Active Content state appeared on identity box");
- gIdentityHandler.disableMixedContentProtection();
-
- waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Logged blocking mixed active content",
- text: "Loading mixed (insecure) active content " +
- "\u201chttp://example.com/\u201d on a secure page",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- {
- name: "Logged blocking mixed passive content - image",
- text: "Loading mixed (insecure) display content" +
- " \u201chttp://example.com/tests/image/test/mochitest/blue.png\u201d" +
- " on a secure page",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- ],
- }).then(msgs => deferred.resolve(msgs), console.error);
-
- return deferred.promise;
-}
-
-function testClickOpenNewTab(hud, match) {
- let warningNode = match.clickableElements[0];
- ok(warningNode, "link element");
- ok(warningNode.classList.contains("learn-more-link"), "link class name");
- return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_1006027_message_timestamps_incorrect.js
+++ /dev/null
@@ -1,45 +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/ */
-
-"use strict";
-
-function test() {
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab("data:text/html;charset=utf8,<title>Test for " +
- "Bug 1006027");
-
- const hud = yield openConsole(tab);
-
- hud.jsterm.execute("console.log('bug1006027')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log",
- text: "bug1006027",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- info("hud.outputNode.textContent:\n" + hud.outputNode.textContent);
- let timestampNodes = hud.outputNode.querySelectorAll("span.timestamp");
- let aTimestampMilliseconds = Array.prototype.map.call(timestampNodes,
- function (value) {
- // We are parsing timestamps as local time, relative to the begin of
- // the epoch.
- // This is not the correct value of the timestamp, but good enough for
- // comparison.
- return Date.parse("T" + String(value.textContent).trim());
- });
-
- let minTimestamp = Math.min.apply(null, aTimestampMilliseconds);
- let maxTimestamp = Math.max.apply(null, aTimestampMilliseconds);
- ok(Math.abs(maxTimestamp - minTimestamp) < 2000,
- "console.log message timestamp spread < 2000ms confirmed");
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_1010953_cspro.js
+++ /dev/null
@@ -1,55 +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/ */
-
-/* We are loading:
-a script that is allowed by the CSP header but not by the CSPRO header
-an image which is allowed by the CSPRO header but not by the CSP header.
-
-So we expect a warning (image has been blocked) and a report
- (script should not load and was reported)
-
-The expected console messages in the constants CSP_VIOLATION_MSG and
-CSP_REPORT_MSG are confirmed to be found in the console messages.
-*/
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Web Console CSP report only " +
- "test (bug 1010953)";
-const TEST_VIOLATION = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test_bug_1010953_cspro.html";
-const CSP_VIOLATION_MSG = "Content Security Policy: The page\u2019s settings " +
- "blocked the loading of a resource at " +
- "http://some.example.com/test.png " +
- "(\u201cimg-src\u201d).";
-const CSP_REPORT_MSG = "Content Security Policy: The page\u2019s settings " +
- "observed the loading of a resource at " +
- "http://some.example.com/test_bug_1010953_cspro.js " +
- "(\u201cscript-src\u201d). A CSP report is " +
- "being sent.";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_VIOLATION);
- yield loaded;
-
- yield waitForSuccess({
- name: "Confirmed that CSP and CSP-Report-Only log different messages to " +
- "the console.",
- validator: function () {
- console.log(hud.outputNode.textContent);
- let success = false;
- success = hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1 &&
- hud.outputNode.textContent.indexOf(CSP_REPORT_MSG) > -1;
- return success;
- }
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_1050691_click_function_to_source.js
+++ /dev/null
@@ -1,60 +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/ */
-
-// Tests that clicking on a function displays its source in the debugger.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug_1050691_click_function_to_source.html";
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- // Open the Debugger panel.
- let debuggerPanel = yield openDebugger();
- // And right after come back to the Console panel.
- yield openConsole();
- yield testWithDebuggerOpen(hud, debuggerPanel);
-});
-
-function* testWithDebuggerOpen(hud, debuggerPanel) {
- let clickable = yield printFunction(hud);
- let panelWin = debuggerPanel.panelWin;
- let onEditorLocationSet = panelWin.once(panelWin.EVENTS.EDITOR_LOCATION_SET);
- synthesizeClick(clickable, hud);
- yield onEditorLocationSet;
- ok(isDebuggerCaretPos(debuggerPanel, 7),
- "Clicking on a function should go to its source in the debugger view");
-}
-
-function synthesizeClick(clickable, hud) {
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
-}
-
-var printFunction = Task.async(function* (hud) {
- hud.jsterm.clearOutput();
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.foo();
- });
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
- let msg = [...result.matched][0];
- let clickable = msg.querySelector("a");
- ok(clickable, "clickable item for object should exist");
- return clickable;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_1247459_violation.js
+++ /dev/null
@@ -1,39 +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/ */
-
-// Tests that the Web Console CSP messages for two META policies
-// are correctly displayed.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Web Console CSP violation test";
-const TEST_VIOLATION = "https://example.com/browser/devtools/client/" +
- "webconsole/old/test/test_bug_1247459_violation.html";
-const CSP_VIOLATION_MSG = "Content Security Policy: The page\u2019s settings " +
- "blocked the loading of a resource at " +
- "http://some.example.com/test.png (\u201cimg-src\u201d).";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_VIOLATION);
- yield loaded;
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "CSP policy URI warning displayed successfully",
- text: CSP_VIOLATION_MSG,
- repeats: 2
- }
- ]
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_578437_page_reload.js
+++ /dev/null
@@ -1,41 +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/ */
-
-// Tests that the console object still exists after a page reload.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-var browser;
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then((tab) => {
- browser = tab.browser;
-
- browser.addEventListener("DOMContentLoaded", testPageReload);
- content.location.reload();
- });
- });
- browser.addEventListener("DOMContentLoaded", onLoad);
-}
-
-function testPageReload() {
- browser.removeEventListener("DOMContentLoaded", testPageReload);
-
- let console = browser.contentWindow.wrappedJSObject.console;
-
- is(typeof console, "object", "window.console is an object, after page reload");
- is(typeof console.log, "function", "console.log is a function");
- is(typeof console.info, "function", "console.info is a function");
- is(typeof console.warn, "function", "console.warn is a function");
- is(typeof console.error, "function", "console.error is a function");
- is(typeof console.exception, "function", "console.exception is a function");
-
- browser = null;
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_579412_input_focus.js
+++ /dev/null
@@ -1,20 +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/ */
-
-// Tests that the input field is focused when the console is opened.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- let inputNode = hud.jsterm.inputNode;
- ok(inputNode.getAttribute("focused"), "input node is focused");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_580001_closing_after_completion.js
+++ /dev/null
@@ -1,47 +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/ */
-
-// Tests to ensure that errors don't appear when the console is closed while a
-// completion is being performed.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- yield testClosingAfterCompletion(hud, browser);
-});
-
-function testClosingAfterCompletion(hud, browser) {
- let deferred = defer();
-
- let errorWhileClosing = false;
- function errorListener() {
- errorWhileClosing = true;
- }
-
- browser.addEventListener("error", errorListener);
-
- // Focus the jsterm and perform the keycombo to close the WebConsole.
- hud.jsterm.focus();
-
- gDevTools.once("toolbox-destroyed", function () {
- browser.removeEventListener("error", errorListener);
- is(errorWhileClosing, false, "no error while closing the WebConsole");
- deferred.resolve();
- });
-
- if (Services.appinfo.OS == "Darwin") {
- EventUtils.synthesizeKey("i", { accelKey: true, altKey: true });
- } else {
- EventUtils.synthesizeKey("i", { accelKey: true, shiftKey: true });
- }
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_580030_errors_after_page_reload.js
+++ /dev/null
@@ -1,51 +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/ */
-
-// Tests that errors still show up in the Web Console after a page reload.
-// See bug 580030: the error handler fails silently after page reload.
-// https://bugzilla.mozilla.org/show_bug.cgi?id=580030
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-error.html";
-
-function test() {
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
- info("console opened");
-
- executeSoon(() => {
- hud.jsterm.clearOutput();
- info("wait for reload");
- gBrowser.reload();
- });
-
- yield hud.target.once("navigate");
- info("target navigated");
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- let button = content.document.querySelector("button");
- ok(button, "button found");
- button.click();
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "fooBazBaz is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_582201_duplicate_errors.js
+++ /dev/null
@@ -1,49 +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/ */
-
-// Tests that exceptions thrown by content don't show up twice in the Web
-// Console.
-
-"use strict";
-
-const INIT_URI = "data:text/html;charset=utf8,hello world";
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-duplicate-error.html";
-
-add_task(function* () {
- yield loadTab(INIT_URI);
-
- let hud = yield openConsole();
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "fooDuplicateError1",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- text: "test-duplicate-error.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-
- let text = hud.outputNode.textContent;
- let error1pos = text.indexOf("fooDuplicateError1");
- ok(error1pos > -1, "found fooDuplicateError1");
- if (error1pos > -1) {
- ok(!text.includes("fooDuplicateError1", error1pos + 1),
- "no duplicate for fooDuplicateError1");
- }
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js
+++ /dev/null
@@ -1,35 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/browser/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- testCompletion(hud);
-});
-
-function testCompletion(hud) {
- let jsterm = hud.jsterm;
- let input = jsterm.inputNode;
-
- jsterm.setInputValue("");
- EventUtils.synthesizeKey("KEY_Tab");
- is(jsterm.completeNode.value, "<- no result", "<- no result - matched");
- is(input.value, "", "inputnode is empty - matched");
- is(input.getAttribute("focused"), "true", "input is still focused");
-
- // Any thing which is not in property autocompleter
- jsterm.setInputValue("window.Bug583816");
- EventUtils.synthesizeKey("KEY_Tab");
- is(jsterm.completeNode.value, " <- no result",
- "completenode content - matched");
- is(input.value, "window.Bug583816", "inputnode content - matched");
- is(input.getAttribute("focused"), "true", "input is still focused");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_585237_line_limit.js
+++ /dev/null
@@ -1,89 +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/ */
-
-// Tests that the Web Console limits the number of lines displayed according to
-// the user's preferences.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,test for bug 585237";
-
-var outputNode;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- outputNode = hud.outputNode;
-
- hud.jsterm.clearOutput();
-
- let prefBranch = Services.prefs.getBranch("devtools.hud.loglimit.");
- prefBranch.setIntPref("console", 20);
-
- for (let i = 0; i < 30; i++) {
- yield ContentTask.spawn(gBrowser.selectedBrowser, i, function (i) {
- // must change message to prevent repeats
- content.console.log("foo #" + i);
- });
- }
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foo #29",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- is(countMessageNodes(), 20, "there are 20 message nodes in the output " +
- "when the log limit is set to 20");
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
- content.console.log("bar bug585237");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bar bug585237",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- is(countMessageNodes(), 20, "there are still 20 message nodes in the " +
- "output when adding one more");
-
- prefBranch.setIntPref("console", 30);
- for (let i = 0; i < 20; i++) {
- yield ContentTask.spawn(gBrowser.selectedBrowser, i, function (i) {
- // must change message to prevent repeats
- content.console.log("boo #" + i);
- });
- }
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "boo #19",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- is(countMessageNodes(), 30, "there are 30 message nodes in the output " +
- "when the log limit is set to 30");
-
- prefBranch.clearUserPref("console");
-
- outputNode = null;
-});
-
-function countMessageNodes() {
- return outputNode.querySelectorAll(".message").length;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_585956_console_trace.js
+++ /dev/null
@@ -1,66 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-bug-585956-console-trace.html";
-
-add_task(function* () {
- let {tab} = yield loadTab("data:text/html;charset=utf8,<p>hello");
- let hud = yield openConsole(tab);
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.trace output",
- consoleTrace: {
- file: "test-bug-585956-console-trace.html",
- fn: "window.foobar585956c",
- },
- }],
- });
-
- let node = [...result.matched][0];
- ok(node, "found trace log node");
-
- let obj = node._messageObject;
- ok(obj, "console.trace message object");
-
- // The expected stack trace object.
- let stacktrace = [
- {
- columnNumber: 3,
- filename: TEST_URI,
- functionName: "window.foobar585956c",
- lineNumber: 9
- },
- {
- columnNumber: 10,
- filename: TEST_URI,
- functionName: "foobar585956b",
- lineNumber: 14
- },
- {
- columnNumber: 10,
- filename: TEST_URI,
- functionName: "foobar585956a",
- lineNumber: 18
- },
- {
- columnNumber: 1,
- filename: TEST_URI,
- functionName: "",
- lineNumber: 21
- }
- ];
-
- ok(obj._stacktrace, "found stacktrace object");
- is(obj._stacktrace.toSource(), stacktrace.toSource(),
- "stacktrace is correct");
- isnot(node.textContent.indexOf("bug-585956"), -1, "found file name");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_585991_autocomplete_keys.js
+++ /dev/null
@@ -1,364 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>bug 585991 - autocomplete " +
- "popup keyboard usage test";
-
-// We should turn off auto-multiline editing during these tests
-const PREF_AUTO_MULTILINE = "devtools.webconsole.autoMultiline";
-var HUD, popup, jsterm, inputNode, completeNode;
-
-add_task(function* () {
- Services.prefs.setBoolPref(PREF_AUTO_MULTILINE, false);
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- yield consoleOpened(hud);
- yield popupHideAfterTab();
- yield testReturnKey();
- yield dontShowArrayNumbers();
- yield testReturnWithNoSelection();
- yield popupHideAfterReturnWithNoSelection();
- yield testCompletionInText();
- yield popupHideAfterCompletionInText();
-
- HUD = popup = jsterm = inputNode = completeNode = null;
- Services.prefs.setBoolPref(PREF_AUTO_MULTILINE, true);
-});
-
-var consoleOpened = Task.async(function* (hud) {
- let deferred = defer();
- HUD = hud;
- info("web console opened");
-
- jsterm = HUD.jsterm;
-
- yield jsterm.execute("window.foobarBug585991={" +
- "'item0': 'value0'," +
- "'item1': 'value1'," +
- "'item2': 'value2'," +
- "'item3': 'value3'" +
- "}");
- yield jsterm.execute("window.testBug873250a = 'hello world';"
- + "window.testBug873250b = 'hello world 2';");
- popup = jsterm.autocompletePopup;
- completeNode = jsterm.completeNode;
- inputNode = jsterm.inputNode;
-
- ok(!popup.isOpen, "popup is not open");
-
- popup.once("popup-opened", () => {
- ok(popup.isOpen, "popup is open");
-
- // 4 values, and the following properties:
- // __defineGetter__ __defineSetter__ __lookupGetter__ __lookupSetter__
- // __proto__ hasOwnProperty isPrototypeOf propertyIsEnumerable
- // toLocaleString toString toSource valueOfconstructor.
- is(popup.itemCount, 17, "popup.itemCount is correct");
-
- let sameItems = popup.getItems().reverse().map(function (e) {
- return e.label;
- });
-
- ok(sameItems.every(function (prop, index) {
- return [
- "__defineGetter__",
- "__defineSetter__",
- "__lookupGetter__",
- "__lookupSetter__",
- "__proto__",
- "constructor",
- "hasOwnProperty",
- "isPrototypeOf",
- "item0",
- "item1",
- "item2",
- "item3",
- "propertyIsEnumerable",
- "toLocaleString",
- "toSource",
- "toString",
- "valueOf",
- ][index] === prop;
- }), "getItems returns the items we expect");
-
- is(popup.selectedIndex, 16,
- "Index of the first item from bottom is selected.");
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
-
- is(popup.selectedIndex, 0, "index 0 is selected");
- is(popup.selectedItem.label, "valueOf", "valueOf is selected");
- is(completeNode.value, prefix + "valueOf",
- "completeNode.value holds valueOf");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(popup.selectedIndex, 1, "index 1 is selected");
- is(popup.selectedItem.label, "toString", "toString is selected");
- is(completeNode.value, prefix + "toString",
- "completeNode.value holds toString");
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(popup.selectedIndex, 0, "index 0 is selected");
- is(popup.selectedItem.label, "valueOf", "valueOf is selected");
- is(completeNode.value, prefix + "valueOf",
- "completeNode.value holds valueOf");
-
- let currentSelectionIndex = popup.selectedIndex;
-
- EventUtils.synthesizeKey("KEY_PageDown");
-
- ok(popup.selectedIndex > currentSelectionIndex,
- "Index is greater after PGDN");
-
- currentSelectionIndex = popup.selectedIndex;
- EventUtils.synthesizeKey("KEY_PageUp");
-
- ok(popup.selectedIndex < currentSelectionIndex,
- "Index is less after Page UP");
-
- EventUtils.synthesizeKey("KEY_End");
- is(popup.selectedIndex, 16, "index is last after End");
-
- EventUtils.synthesizeKey("KEY_Home");
- is(popup.selectedIndex, 0, "index is first after Home");
-
- info("press Tab and wait for popup to hide");
- popup.once("popup-closed", () => {
- deferred.resolve();
- });
- EventUtils.synthesizeKey("KEY_Tab");
- });
-
- jsterm.setInputValue("window.foobarBug585991");
- EventUtils.sendString(".");
-
- return deferred.promise;
-});
-
-function popupHideAfterTab() {
- let deferred = defer();
-
- // At this point the completion suggestion should be accepted.
- ok(!popup.isOpen, "popup is not open");
-
- is(jsterm.getInputValue(), "window.foobarBug585991.valueOf",
- "completion was successful after KEY_Tab");
-
- ok(!completeNode.value, "completeNode is empty");
-
- popup.once("popup-opened", function onShown() {
- ok(popup.isOpen, "popup is open");
-
- is(popup.itemCount, 17, "popup.itemCount is correct");
-
- is(popup.selectedIndex, 16, "First index from bottom is selected");
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
-
- is(popup.selectedIndex, 0, "index 0 is selected");
- is(popup.selectedItem.label, "valueOf", "valueOf is selected");
- is(completeNode.value, prefix + "valueOf",
- "completeNode.value holds valueOf");
-
- popup.once("popup-closed", function onHidden() {
- ok(!popup.isOpen, "popup is not open after KEY_Escape");
-
- is(jsterm.getInputValue(), "window.foobarBug585991.",
- "completion was cancelled");
-
- ok(!completeNode.value, "completeNode is empty");
-
- deferred.resolve();
- }, false);
-
- info("press Escape to close the popup");
- executeSoon(function () {
- EventUtils.synthesizeKey("KEY_Escape");
- });
- }, false);
-
- info("wait for completion: window.foobarBug585991.");
- executeSoon(function () {
- jsterm.setInputValue("window.foobarBug585991");
- EventUtils.sendString(".");
- });
-
- return deferred.promise;
-}
-
-function testReturnKey() {
- let deferred = defer();
-
- popup.once("popup-opened", function onShown() {
- ok(popup.isOpen, "popup is open");
-
- is(popup.itemCount, 17, "popup.itemCount is correct");
-
- is(popup.selectedIndex, 16, "First index from bottom is selected");
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
-
- is(popup.selectedIndex, 0, "index 0 is selected");
- is(popup.selectedItem.label, "valueOf", "valueOf is selected");
- is(completeNode.value, prefix + "valueOf",
- "completeNode.value holds valueOf");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(popup.selectedIndex, 1, "index 1 is selected");
- is(popup.selectedItem.label, "toString", "toString is selected");
- is(completeNode.value, prefix + "toString",
- "completeNode.value holds toString");
-
- popup.once("popup-closed", function onHidden() {
- ok(!popup.isOpen, "popup is not open after KEY_Enter");
-
- is(jsterm.getInputValue(), "window.foobarBug585991.toString",
- "completion was successful after KEY_Enter");
-
- ok(!completeNode.value, "completeNode is empty");
-
- deferred.resolve();
- }, false);
-
- info("press Return to accept suggestion. wait for popup to hide");
-
- executeSoon(() => EventUtils.synthesizeKey("KEY_Enter"));
- }, false);
-
- info("wait for completion suggestions: window.foobarBug585991.");
-
- executeSoon(function () {
- jsterm.setInputValue("window.foobarBug58599");
- EventUtils.sendString("1.");
- });
-
- return deferred.promise;
-}
-
-function* dontShowArrayNumbers() {
- let deferred = defer();
-
- info("dontShowArrayNumbers");
- yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.foobarBug585991 = ["Sherlock Holmes"];
- });
-
- jsterm = HUD.jsterm;
- popup = jsterm.autocompletePopup;
-
- popup.once("popup-opened", function onShown() {
- let sameItems = popup.getItems().map(function (e) {
- return e.label;
- });
- ok(!sameItems.some(function (prop) {
- prop === "0";
- }), "Completing on an array doesn't show numbers.");
-
- popup.once("popup-closed", function popupHidden() {
- deferred.resolve();
- }, false);
-
- info("wait for popup to hide");
- executeSoon(() => EventUtils.synthesizeKey("KEY_Escape"));
- }, false);
-
- info("wait for popup to show");
- executeSoon(() => {
- jsterm.setInputValue("window.foobarBug585991");
- EventUtils.sendString(".");
- });
-
- return deferred.promise;
-}
-
-function testReturnWithNoSelection() {
- let deferred = defer();
-
- info("test pressing return with open popup, but no selection, see bug 873250");
-
- popup.once("popup-opened", function onShown() {
- ok(popup.isOpen, "popup is open");
- is(popup.itemCount, 2, "popup.itemCount is correct");
- isnot(popup.selectedIndex, -1, "popup.selectedIndex is correct");
-
- info("press Return and wait for popup to hide");
- popup.once("popup-closed", function popupHidden() {
- deferred.resolve();
- });
- executeSoon(() => EventUtils.synthesizeKey("KEY_Enter"));
- });
-
- executeSoon(() => {
- info("wait for popup to show");
- jsterm.setInputValue("window.testBu");
- EventUtils.sendString("g");
- });
-
- return deferred.promise;
-}
-
-function popupHideAfterReturnWithNoSelection() {
- ok(!popup.isOpen, "popup is not open after KEY_Enter");
-
- is(jsterm.getInputValue(), "", "inputNode is empty after KEY_Enter");
- is(completeNode.value, "", "completeNode is empty");
- is(jsterm.history[jsterm.history.length - 1], "window.testBug",
- "jsterm history is correct");
-
- return promise.resolve();
-}
-
-function testCompletionInText() {
- info("test that completion works inside text, see bug 812618");
-
- let deferred = defer();
-
- popup.once("popup-opened", function onShown() {
- ok(popup.isOpen, "popup is open");
- is(popup.itemCount, 2, "popup.itemCount is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(popup.selectedIndex, 0, "popup.selectedIndex is correct");
- ok(!completeNode.value, "completeNode.value is empty");
-
- let items = popup.getItems().reverse().map(e => e.label);
- let sameItems = items.every((prop, index) =>
- ["testBug873250a", "testBug873250b"][index] === prop);
- ok(sameItems, "getItems returns the items we expect");
-
- info("press Tab and wait for popup to hide");
- popup.once("popup-closed", function popupHidden() {
- deferred.resolve();
- });
- EventUtils.synthesizeKey("KEY_Tab");
- });
-
- jsterm.setInputValue("dump(window.testBu)");
- inputNode.selectionStart = inputNode.selectionEnd = 18;
- EventUtils.sendString("g");
- return deferred.promise;
-}
-
-function popupHideAfterCompletionInText() {
- // At this point the completion suggestion should be accepted.
- ok(!popup.isOpen, "popup is not open");
- is(jsterm.getInputValue(), "dump(window.testBug873250b)",
- "completion was successful after KEY_Tab");
- is(inputNode.selectionStart, 26, "cursor location is correct");
- is(inputNode.selectionStart, inputNode.selectionEnd,
- "cursor location (confirmed)");
- ok(!completeNode.value, "completeNode is empty");
-
- return promise.resolve();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_585991_autocomplete_popup.js
+++ /dev/null
@@ -1,123 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>bug 585991 - autocomplete " +
- "popup test";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- yield consoleOpened(hud);
-});
-
-function consoleOpened(HUD) {
- let deferred = defer();
-
- let items = [
- {label: "item0", value: "value0"},
- {label: "item1", value: "value1"},
- {label: "item2", value: "value2"},
- ];
-
- let popup = HUD.jsterm.autocompletePopup;
- let input = HUD.jsterm.inputNode;
-
- ok(!popup.isOpen, "popup is not open");
- ok(!input.hasAttribute("aria-activedescendant"), "no aria-activedescendant");
-
- popup.once("popup-opened", () => {
- ok(popup.isOpen, "popup is open");
-
- is(popup.itemCount, 0, "no items");
- ok(!input.hasAttribute("aria-activedescendant"), "no aria-activedescendant");
-
- popup.setItems(items);
-
- is(popup.itemCount, items.length, "items added");
-
- let sameItems = popup.getItems();
- is(sameItems.every(function (item, index) {
- return item === items[index];
- }), true, "getItems returns back the same items");
-
- is(popup.selectedIndex, 2, "Index of the first item from bottom is selected.");
- is(popup.selectedItem, items[2], "First item from bottom is selected");
- checkActiveDescendant(popup, input);
-
- popup.selectedIndex = 1;
-
- is(popup.selectedIndex, 1, "index 1 is selected");
- is(popup.selectedItem, items[1], "item1 is selected");
- checkActiveDescendant(popup, input);
-
- popup.selectedItem = items[2];
-
- is(popup.selectedIndex, 2, "index 2 is selected");
- is(popup.selectedItem, items[2], "item2 is selected");
- checkActiveDescendant(popup, input);
-
- is(popup.selectPreviousItem(), items[1], "selectPreviousItem() works");
-
- is(popup.selectedIndex, 1, "index 1 is selected");
- is(popup.selectedItem, items[1], "item1 is selected");
- checkActiveDescendant(popup, input);
-
- is(popup.selectNextItem(), items[2], "selectNextItem() works");
-
- is(popup.selectedIndex, 2, "index 2 is selected");
- is(popup.selectedItem, items[2], "item2 is selected");
- checkActiveDescendant(popup, input);
-
- ok(popup.selectNextItem(), "selectNextItem() works");
-
- is(popup.selectedIndex, 0, "index 0 is selected");
- is(popup.selectedItem, items[0], "item0 is selected");
- checkActiveDescendant(popup, input);
-
- items.push({label: "label3", value: "value3"});
- popup.appendItem(items[3]);
-
- is(popup.itemCount, items.length, "item3 appended");
-
- popup.selectedIndex = 3;
- is(popup.selectedItem, items[3], "item3 is selected");
- checkActiveDescendant(popup, input);
-
- popup.removeItem(items[2]);
-
- is(popup.selectedIndex, 2, "index2 is selected");
- is(popup.selectedItem, items[3], "item3 is still selected");
- checkActiveDescendant(popup, input);
- is(popup.itemCount, items.length - 1, "item2 removed");
-
- popup.clearItems();
- is(popup.itemCount, 0, "items cleared");
- ok(!input.hasAttribute("aria-activedescendant"), "no aria-activedescendant");
-
- popup.once("popup-closed", () => {
- deferred.resolve();
- });
- popup.hidePopup();
- });
-
- popup.openPopup(input);
-
- return deferred.promise;
-}
-
-function checkActiveDescendant(popup, input) {
- let activeElement = input.ownerDocument.activeElement;
- let descendantId = activeElement.getAttribute("aria-activedescendant");
- let popupItem = popup._tooltip.panel.querySelector("#" + descendantId);
- let cloneItem = input.ownerDocument.querySelector("#" + descendantId);
-
- ok(popupItem, "Active descendant is found in the popup list");
- ok(cloneItem, "Active descendant is found in the list clone");
- is(popupItem.innerHTML, cloneItem.innerHTML,
- "Cloned item has the same HTML as the original element");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_586388_select_all.js
+++ /dev/null
@@ -1,84 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- yield testSelectionWhenMovingBetweenBoxes(hud);
- performTestsAfterOutput(hud);
-});
-
-var testSelectionWhenMovingBetweenBoxes = Task.async(function* (hud) {
- let jsterm = hud.jsterm;
-
- // Fill the console with some output.
- jsterm.clearOutput();
- yield jsterm.execute("1 + 2");
- yield jsterm.execute("3 + 4");
- yield jsterm.execute("5 + 6");
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "3",
- category: CATEGORY_OUTPUT,
- },
- {
- text: "7",
- category: CATEGORY_OUTPUT,
- },
- {
- text: "11",
- category: CATEGORY_OUTPUT,
- }],
- });
-});
-
-function performTestsAfterOutput(hud) {
- let outputNode = hud.outputNode;
-
- ok(outputNode.childNodes.length >= 3, "the output node has children after " +
- "executing some JavaScript");
-
- // Test that the global Firefox "Select All" functionality (e.g. Edit >
- // Select All) works properly in the Web Console.
- let commandController = hud.ui._commandController;
- ok(commandController != null, "the window has a command controller object");
-
- commandController.selectAll();
-
- let selectedCount = hud.ui.output.getSelectedMessages().length;
- is(selectedCount, outputNode.childNodes.length,
- "all console messages are selected after performing a regular browser " +
- "select-all operation");
-
- hud.iframeWindow.getSelection().removeAllRanges();
-
- // Test the context menu "Select All" (which has a different code path) works
- // properly as well.
- let contextMenuId = hud.ui.outputWrapper.getAttribute("context");
- let contextMenu = hud.ui.document.getElementById(contextMenuId);
- ok(contextMenu != null, "the output node has a context menu");
-
- let selectAllItem = contextMenu.querySelector("*[command='cmd_selectAll']");
- ok(selectAllItem != null,
- "the context menu on the output node has a \"Select All\" item");
-
- outputNode.focus();
-
- selectAllItem.doCommand();
-
- selectedCount = hud.ui.output.getSelectedMessages().length;
- is(selectedCount, outputNode.childNodes.length,
- "all console messages are selected after performing a select-all " +
- "operation from the context menu");
-
- hud.iframeWindow.getSelection().removeAllRanges();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_587617_output_copy.js
+++ /dev/null
@@ -1,106 +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/ */
-/* globals goUpdateCommand goDoCommand */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-var HUD, outputNode;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- yield consoleOpened(hud);
- yield testContextMenuCopy();
-
- HUD = outputNode = null;
-});
-
-function consoleOpened(hud) {
- HUD = hud;
-
- let deferred = defer();
-
- // See bugs 574036, 586386 and 587617.
- outputNode = HUD.outputNode;
-
- HUD.jsterm.clearOutput();
-
- let controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
-
- ContentTask.spawn(gBrowser.selectedBrowser, null,
- "() => content.console.log('Hello world! bug587617')");
-
- waitForMessages({
- webconsole: HUD,
- messages: [{
- text: "bug587617",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- }).then(([result]) => {
- let msg = [...result.matched][0];
- HUD.ui.output.selectMessage(msg);
-
- outputNode.focus();
-
- goUpdateCommand("cmd_copy");
- controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
-
- // Remove new lines and whitespace since getSelection() includes
- // a new line between message and line number, but the clipboard doesn't
- // @see bug 1119503
- let selection = (HUD.iframeWindow.getSelection() + "")
- .replace(/\r?\n|\r| /g, "");
- isnot(selection.indexOf("bug587617"), -1,
- "selection text includes 'bug587617'");
-
- waitForClipboard((str) => {
- // Strip out spaces for comparison ease
- return selection.trim() == str.trim().replace(/ /g, "");
- }, () => {
- goDoCommand("cmd_copy");
- }, deferred.resolve, deferred.resolve);
- });
- return deferred.promise;
-}
-
-// Test that the context menu "Copy" (which has a different code path) works
-// properly as well.
-function testContextMenuCopy() {
- let deferred = defer();
-
- let contextMenuId = HUD.ui.outputWrapper.getAttribute("context");
- let contextMenu = HUD.ui.document.getElementById(contextMenuId);
- ok(contextMenu, "the output node has a context menu");
-
- let copyItem = contextMenu.querySelector("*[command='cmd_copy']");
- ok(copyItem, "the context menu on the output node has a \"Copy\" item");
-
- // Remove new lines and whitespace since getSelection() includes
- // a new line between message and line number, but the clipboard doesn't
- // @see bug 1119503
- let selection = (HUD.iframeWindow.getSelection() + "")
- .replace(/\r?\n|\r| /g, "");
-
- copyItem.doCommand();
-
- waitForClipboard((str) => {
- // Strip out spaces for comparison ease
- return selection.trim() == str.trim().replace(/ /g, "");
- }, () => {
- goDoCommand("cmd_copy");
- }, deferred.resolve, deferred.resolve);
- HUD = outputNode = null;
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_588342_document_focus.js
+++ /dev/null
@@ -1,35 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 588342";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- yield checkConsoleFocus(hud);
-
- let isFocused = yield ContentTask.spawn(browser, { }, function* () {
- var fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
- return fm.focusedWindow == content;
- });
-
- ok(isFocused, "content document has focus");
-});
-
-function* checkConsoleFocus(hud) {
- let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
-
- yield new Promise(resolve => {
- waitForFocus(resolve);
- });
-
- is(hud.jsterm.inputNode.getAttribute("focused"), "true",
- "jsterm input is focused on web console open");
- is(fm.focusedWindow, hud.iframeWindow, "hud window is focused");
- yield closeConsole(null);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_588730_text_node_insertion.js
+++ /dev/null
@@ -1,53 +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/ */
-
-// Tests that adding text to one of the output labels doesn't cause errors.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield testTextNodeInsertion(hud);
-});
-
-// Test for bug 588730: Adding a text node to an existing label element causes
-// warnings
-function testTextNodeInsertion(hud) {
- let deferred = defer();
- let outputNode = hud.outputNode;
-
- let label = document.createElementNS(
- "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "label");
- outputNode.appendChild(label);
-
- let error = false;
- let listener = {
- observe: function (aMessage) {
- let messageText = aMessage.message;
- if (messageText.includes("JavaScript Warning")) {
- error = true;
- }
- }
- };
-
- Services.console.registerListener(listener);
-
- // This shouldn't fail.
- label.appendChild(document.createTextNode("foo"));
-
- executeSoon(function () {
- Services.console.unregisterListener(listener);
- ok(!error, "no error when adding text nodes as children of labels");
-
- return deferred.resolve();
- });
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_588967_input_expansion.js
+++ /dev/null
@@ -1,44 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- testInputExpansion(hud);
-});
-
-function testInputExpansion(hud) {
- let input = hud.jsterm.inputNode;
-
- input.focus();
-
- is(input.getAttribute("multiline"), "true", "multiline is enabled");
-
- let ordinaryHeight = input.clientHeight;
-
- // Tests if the inputNode expands.
- input.value = "hello\nworld\n";
- let length = input.value.length;
- input.selectionEnd = length;
- input.selectionStart = length;
- // Performs an "d". This will trigger/test for the input event that should
- // change the height of the inputNode.
- EventUtils.sendString("d");
- ok(input.clientHeight > ordinaryHeight, "the input expanded");
-
- // Test if the inputNode shrinks again.
- input.value = "";
- EventUtils.sendString("d");
- is(input.clientHeight, ordinaryHeight, "the input's height is normal again");
-
- input = length = null;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_589162_css_filter.js
+++ /dev/null
@@ -1,39 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<div style='font-size:3em;" +
- "foobarCssParser:baz'>test CSS parser filter</div>";
-
-/**
- * Unit test for bug 589162:
- * CSS filtering on the console does not work
- */
-add_task(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
-
- // CSS warnings are disabled by default.
- hud.setFilterState("cssparser", true);
- hud.jsterm.clearOutput();
-
- BrowserReload();
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarCssParser",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- }],
- });
-
- hud.setFilterState("cssparser", false);
-
- let msg = "the unknown CSS property warning is not displayed, " +
- "after filtering";
- testLogEntry(hud.outputNode, "foobarCssParser", msg, true, true);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_592442_closing_brackets.js
+++ /dev/null
@@ -1,29 +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/ */
-
-// Tests that, when the user types an extraneous closing bracket, no error
-// appears.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,test for bug 592442";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
- let jsterm = hud.jsterm;
-
- jsterm.setInputValue("document.getElementById)");
-
- let error = false;
- try {
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY);
- } catch (ex) {
- error = true;
- }
-
- ok(!error, "no error was thrown when an extraneous bracket was inserted");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_593003_iframe_wrong_hud.js
+++ /dev/null
@@ -1,68 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-593003-iframe-wrong-hud.html";
-
-const TEST_IFRAME_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-bug-593003-iframe-wrong-" +
- "hud-iframe.html";
-
-const TEST_DUMMY_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-console.html";
-
-add_task(function* () {
-
- let tab1 = (yield loadTab(TEST_URI)).tab;
- yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.console.log("FOO");
- });
- yield openConsole();
-
- let tab2 = (yield loadTab(TEST_DUMMY_URI)).tab;
- yield openConsole(gBrowser.selectedTab);
-
- info("Reloading tab 1");
- yield reloadTab(tab1);
-
- info("Checking for messages");
- yield checkMessages(tab1, tab2);
-
- info("Cleaning up");
- yield closeConsole(tab1);
- yield closeConsole(tab2);
-});
-
-function* reloadTab(tab) {
- let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
- tab.linkedBrowser.reload();
- yield loaded;
-}
-
-function* checkMessages(tab1, tab2) {
- let hud1 = yield openConsole(tab1);
- let outputNode1 = hud1.outputNode;
-
- info("Waiting for messages");
- yield waitForMessages({
- webconsole: hud1,
- messages: [{
- text: TEST_IFRAME_URI,
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }]
- });
-
- let hud2 = yield openConsole(tab2);
- let outputNode2 = hud2.outputNode;
-
- isnot(outputNode1, outputNode2,
- "the two HUD outputNodes must be different");
-
- let msg = "Didn't find the iframe network request in tab2";
- testLogEntry(outputNode2, TEST_IFRAME_URI, msg, true, true);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_594497_history_arrow_keys.js
+++ /dev/null
@@ -1,155 +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/ */
-
-"use strict";
-
-var jsterm, inputNode, values;
-
-var TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 594497 and bug 619598";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield setup(hud);
- performTests();
-
- jsterm = inputNode = values = null;
-});
-
-function* setup(HUD) {
- jsterm = HUD.jsterm;
- inputNode = jsterm.inputNode;
-
- jsterm.focus();
-
- ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
-
- values = ["document", "window", "document.body"];
- values.push(values.join(";\n"), "document.location");
-
- // Execute each of the values;
- for (let i = 0; i < values.length; i++) {
- jsterm.setInputValue(values[i]);
- yield jsterm.execute();
- }
-}
-
-function performTests() {
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
-
- is(jsterm.getInputValue(), values[4],
- "KEY_ArrowUp: jsterm.getInputValue() #4 is correct");
-
- ok(inputNode.selectionStart == values[4].length &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.getInputValue(), values[3],
- "KEY_ArrowUp: jsterm.getInputValue() #3 is correct");
-
- ok(inputNode.selectionStart == values[3].length &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- inputNode.setSelectionRange(values[3].length - 2, values[3].length - 2);
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.getInputValue(), values[3],
- "KEY_ArrowUp two times: jsterm.getInputValue() #3 is correct");
-
- ok(inputNode.selectionStart == jsterm.getInputValue().indexOf("\n") &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.getInputValue(), values[3],
- "KEY_ArrowUp again: jsterm.getInputValue() #3 is correct");
-
- ok(inputNode.selectionStart == 0 &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.getInputValue(), values[2],
- "KEY_ArrowUp: jsterm.getInputValue() #2 is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.getInputValue(), values[1],
- "KEY_ArrowUp: jsterm.getInputValue() #1 is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.getInputValue(), values[0],
- "KEY_ArrowUp: jsterm.getInputValue() #0 is correct");
-
- ok(inputNode.selectionStart == values[0].length &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(jsterm.getInputValue(), values[1],
- "KEY_ArrowDown: jsterm.getInputValue() #1 is correct");
-
- ok(inputNode.selectionStart == values[1].length &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(jsterm.getInputValue(), values[2],
- "KEY_ArrowDown: jsterm.getInputValue() #2 is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(jsterm.getInputValue(), values[3],
- "KEY_ArrowDown: jsterm.getInputValue() #3 is correct");
-
- ok(inputNode.selectionStart == values[3].length &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- inputNode.setSelectionRange(2, 2);
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(jsterm.getInputValue(), values[3],
- "KEY_ArrowDown two times: jsterm.getInputValue() #3 is correct");
-
- ok(inputNode.selectionStart > jsterm.getInputValue().lastIndexOf("\n") &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(jsterm.getInputValue(), values[3],
- "KEY_ArrowDown again: jsterm.getInputValue() #3 is correct");
-
- ok(inputNode.selectionStart == values[3].length &&
- inputNode.selectionStart == inputNode.selectionEnd,
- "caret location is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- is(jsterm.getInputValue(), values[4],
- "KEY_ArrowDown: jsterm.getInputValue() #4 is correct");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
-
- ok(!jsterm.getInputValue(),
- "KEY_ArrowDown: jsterm.getInputValue() is empty");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_595223_file_uri.js
+++ /dev/null
@@ -1,67 +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/ */
-
-"use strict";
-
-const PREF = "devtools.webconsole.persistlog";
-const TEST_FILE = "test-network.html";
-
-var hud;
-
-add_task(function* () {
- Services.prefs.setBoolPref(PREF, true);
-
- let jar = getJar(getRootDirectory(gTestPath));
- let dir = jar ?
- extractJarToTmp(jar) :
- getChromeDir(getResolvedURI(gTestPath));
-
- dir.append(TEST_FILE);
- let uri = Services.io.newFileURI(dir);
-
- // Open tab with correct remote type so we don't switch processes when we load
- // the file:// URI, otherwise we won't get the same web console.
- let remoteType = E10SUtils.getRemoteTypeForURI(uri.spec,
- gMultiProcessBrowser);
- let { browser } = yield loadTab("about:blank", remoteType);
-
- hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, uri.spec);
- yield loaded;
-
- yield testMessages();
-
- Services.prefs.clearUserPref(PREF);
- hud = null;
-});
-
-function testMessages() {
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "running network console logging tests",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-network.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-image.png",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "testscript.js",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_595350_multiple_windows_and_tabs.js
+++ /dev/null
@@ -1,100 +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/ */
-
-// Tests that the Web Console doesn't leak when multiple tabs and windows are
-// opened and then closed.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 595350";
-
-var win1 = window, win2;
-var openTabs = [];
-var loadedTabCount = 0;
-
-function test() {
- requestLongerTimeout(3);
-
- // Add two tabs in the main window.
- addTabs(win1);
-
- // Open a new window.
- win2 = OpenBrowserWindow();
- win2.addEventListener("load", onWindowLoad, true);
-}
-
-function onWindowLoad(aEvent) {
- win2.removeEventListener(aEvent.type, onWindowLoad, true);
-
- // Add two tabs in the new window.
- addTabs(win2);
-}
-
-function addTabs(aWindow) {
- for (let i = 0; i < 2; i++) {
- let tab = aWindow.gBrowser.addTab(TEST_URI);
- openTabs.push(tab);
-
- tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) {
- tab.linkedBrowser.removeEventListener(aEvent.type, onLoad, true);
-
- loadedTabCount++;
- info("tabs loaded: " + loadedTabCount);
- if (loadedTabCount >= 4) {
- executeSoon(openConsoles);
- }
- }, true);
- }
-}
-
-function openConsoles() {
- function open(i) {
- let tab = openTabs[i];
- openConsole(tab).then(function (hud) {
- ok(hud, "HUD is open for tab " + i);
- let window = hud.target.tab.linkedBrowser.contentWindow;
- window.console.log("message for tab " + i);
-
- if (i >= openTabs.length - 1) {
- // Use executeSoon() to allow the promise to resolve.
- executeSoon(closeConsoles);
- }
- else {
- executeSoon(() => open(i + 1));
- }
- });
- }
-
- // open the Web Console for each of the four tabs and log a message.
- open(0);
-}
-
-function closeConsoles() {
- let consolesClosed = 0;
-
- function onWebConsoleClose(aSubject, aTopic) {
- if (aTopic == "web-console-destroyed") {
- consolesClosed++;
- info("consoles destroyed: " + consolesClosed);
- if (consolesClosed == 4) {
- // Use executeSoon() to allow all the observers to execute.
- executeSoon(finishTest);
- }
- }
- }
-
- Services.obs.addObserver(onWebConsoleClose, "web-console-destroyed");
-
- registerCleanupFunction(() => {
- Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
- });
-
- win2.close();
-
- win1.gBrowser.removeTab(openTabs[0]);
- win1.gBrowser.removeTab(openTabs[1]);
-
- openTabs = win1 = win2 = null;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_595934_message_categories.js
+++ /dev/null
@@ -1,210 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 595934 - message categories coverage.";
-const TESTS_PATH = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/";
-const TESTS = [
- {
- // #0
- file: "test-bug-595934-css-loader.html",
- category: "CSS Loader",
- matchString: "text/css",
- },
- {
- // #1
- file: "test-bug-595934-imagemap.html",
- category: "Layout: ImageMap",
- matchString: "shape=\"rect\"",
- },
- {
- // #2
- file: "test-bug-595934-html.html",
- category: "HTML",
- matchString: "multipart/form-data",
- onload: function () {
- let form = content.document.querySelector("form");
- form.submit();
- },
- },
- {
- // #3
- file: "test-bug-595934-workers.html",
- category: "Web Worker",
- matchString: "fooBarWorker",
- },
- {
- // #4
- file: "test-bug-595934-malformedxml.xhtml",
- category: "malformed-xml",
- matchString: "no root element found",
- },
- {
- // #5
- file: "test-bug-595934-svg.xhtml",
- category: "SVG",
- matchString: "fooBarSVG",
- },
- {
- // #6
- file: "test-bug-595934-css-parser.html",
- category: "CSS Parser",
- matchString: "foobarCssParser",
- },
- {
- // #7
- file: "test-bug-595934-malformedxml-external.html",
- category: "malformed-xml",
- matchString: "</html>",
- },
- {
- // #8
- file: "test-bug-595934-empty-getelementbyid.html",
- category: "DOM",
- matchString: "getElementById",
- },
- {
- // #9
- file: "test-bug-595934-canvas-css.html",
- category: "CSS Parser",
- matchString: "foobarCanvasCssParser",
- },
- {
- // #10
- file: "test-bug-595934-image.html",
- category: "Image",
- matchString: "corrupt",
- },
-];
-
-var pos = -1;
-
-var foundCategory = false;
-var foundText = false;
-var pageLoaded = false;
-var pageError = false;
-var output = null;
-var jsterm = null;
-var hud = null;
-var testEnded = false;
-
-var TestObserver = {
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
-
- observe: function testObserve(subject) {
- if (testEnded || !(subject instanceof Ci.nsIScriptError)) {
- return;
- }
-
- let expectedCategory = TESTS[pos].category;
-
- info("test #" + pos + " console observer got " + subject.category +
- ", is expecting " + expectedCategory);
-
- if (subject.category == expectedCategory) {
- foundCategory = true;
- startNextTest();
- } else {
- info("unexpected message was: " + subject.sourceName + ":" +
- subject.lineNumber + "; " + subject.errorMessage);
- }
- }
-};
-
-function consoleOpened(hudConsole) {
- hud = hudConsole;
- output = hud.outputNode;
- jsterm = hud.jsterm;
-
- Services.console.registerListener(TestObserver);
-
- registerCleanupFunction(testEnd);
-
- testNext();
-}
-
-function testNext() {
- jsterm.clearOutput();
- foundCategory = false;
- foundText = false;
- pageLoaded = false;
- pageError = false;
-
- pos++;
- info("testNext: #" + pos);
- if (pos < TESTS.length) {
- test = TESTS[pos];
-
- waitForMessages({
- webconsole: hud,
- messages: [{
- name: "message for test #" + pos + ": '" + test.matchString + "'",
- text: test.matchString,
- }],
- }).then(() => {
- foundText = true;
- startNextTest();
- });
-
- let testLocation = TESTS_PATH + test.file;
- gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
- if (content.location.href != testLocation) {
- return;
- }
- gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
-
- pageLoaded = true;
- test.onload && test.onload(evt);
-
- if (test.expectError) {
- content.addEventListener("error", function () {
- pageError = true;
- startNextTest();
- }, {once: true});
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- } else {
- pageError = true;
- }
-
- startNextTest();
- }, true);
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, testLocation);
- } else {
- testEnded = true;
- finishTest();
- }
-}
-
-function testEnd() {
- if (!testEnded) {
- info("foundCategory " + foundCategory + " foundText " + foundText +
- " pageLoaded " + pageLoaded + " pageError " + pageError);
- }
-
- Services.console.unregisterListener(TestObserver);
- hud = TestObserver = output = jsterm = null;
-}
-
-function startNextTest() {
- if (!testEnded && foundCategory && foundText && pageLoaded && pageError) {
- testNext();
- }
-}
-
-function test() {
- requestLongerTimeout(2);
-
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_597103_deactivateHUDForContext_unfocused_window.js
+++ /dev/null
@@ -1,95 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-var tab1, tab2, win1, win2;
-var noErrors = true;
-
-function tab1Loaded() {
- win2 = OpenBrowserWindow();
- whenDelayedStartupFinished(win2, win2Loaded);
-}
-
-function win2Loaded() {
- tab2 = win2.gBrowser.addTab(TEST_URI);
- win2.gBrowser.selectedTab = tab2;
- BrowserTestUtils.browserLoaded(tab2.linkedBrowser).then(tab2Loaded);
-}
-
-function tab2Loaded(aEvent) {
- let consolesOpened = 0;
- function onWebConsoleOpen() {
- consolesOpened++;
- if (consolesOpened == 2) {
- executeSoon(closeConsoles);
- }
- }
-
- function openConsoles() {
- try {
- let target1 = TargetFactory.forTab(tab1);
- gDevTools.showToolbox(target1, "webconsole").then(onWebConsoleOpen);
- } catch (ex) {
- ok(false, "gDevTools.showToolbox(target1) exception: " + ex);
- noErrors = false;
- }
-
- try {
- let target2 = TargetFactory.forTab(tab2);
- gDevTools.showToolbox(target2, "webconsole").then(onWebConsoleOpen);
- } catch (ex) {
- ok(false, "gDevTools.showToolbox(target2) exception: " + ex);
- noErrors = false;
- }
- }
-
- function closeConsoles() {
- try {
- let target1 = TargetFactory.forTab(tab1);
- gDevTools.closeToolbox(target1).then(function () {
- try {
- let target2 = TargetFactory.forTab(tab2);
- gDevTools.closeToolbox(target2).then(testEnd);
- } catch (ex) {
- ok(false, "gDevTools.closeToolbox(target2) exception: " + ex);
- noErrors = false;
- }
- });
- } catch (ex) {
- ok(false, "gDevTools.closeToolbox(target1) exception: " + ex);
- noErrors = false;
- }
- }
-
- function testEnd() {
- ok(noErrors, "there were no errors");
-
- win1.gBrowser.removeTab(tab1);
-
- Array.forEach(win2.gBrowser.tabs, function (aTab) {
- win2.gBrowser.removeTab(aTab);
- });
-
- executeSoon(function () {
- win2.close();
- tab1 = tab2 = win1 = win2 = null;
- finishTest();
- });
- }
-
- openConsoles();
-}
-
-function test() {
- loadTab(TEST_URI).then(() => {
- tab1 = gBrowser.selectedTab;
- win1 = window;
- tab1Loaded();
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_597136_external_script_errors.js
+++ /dev/null
@@ -1,33 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-bug-597136-external-script-" +
- "errors.html";
-
-function test() {
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- BrowserTestUtils.synthesizeMouseAtCenter("button", {}, gBrowser.selectedBrowser);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bogus is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_597136_network_requests_from_chrome.js
+++ /dev/null
@@ -1,52 +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/ */
-
-// Tests that network requests from chrome don't cause the Web Console to
-// throw exceptions.
-
-"use strict";
-
-const TEST_URI = "http://example.com/";
-
-var good = true;
-var listener = {
- QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver ]),
- observe: function (subject) {
- if (subject instanceof Ci.nsIScriptError &&
- subject.category === "XPConnect JavaScript" &&
- subject.sourceName.includes("webconsole")) {
- good = false;
- }
- }
-};
-
-var xhr;
-
-function test() {
- Services.console.registerListener(listener);
-
- // trigger a lazy-load of the HUD Service
- HUDService;
-
- xhr = new XMLHttpRequest();
- xhr.addEventListener("load", xhrComplete);
- xhr.open("GET", TEST_URI, true);
- xhr.send(null);
-}
-
-function xhrComplete() {
- xhr.removeEventListener("load", xhrComplete);
- window.setTimeout(checkForException, 0);
-}
-
-function checkForException() {
- ok(good, "no exception was thrown when sending a network request from a " +
- "chrome window");
-
- Services.console.unregisterListener(listener);
- listener = xhr = null;
-
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_597460_filter_scroll.js
+++ /dev/null
@@ -1,77 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-network.html";
-const PREF = "devtools.webconsole.persistlog";
-
-add_task(function* () {
- Services.prefs.setBoolPref(PREF, true);
-
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let results = yield consoleOpened(hud);
-
- testScroll(results, hud);
-
- Services.prefs.clearUserPref(PREF);
-});
-
-async function consoleOpened(hud) {
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- for (let i = 0; i < 200; i++) {
- content.console.log("test message " + i);
- }
- });
-
- hud.setFilterState("network", false);
- hud.setFilterState("networkinfo", false);
-
- hud.ui.filterBox.value = "test message";
- hud.ui.adjustVisibilityOnSearchStringChange();
-
- await waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console messages displayed",
- text: "test message 199",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
- let promise = waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test-network.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
- gBrowser.reload();
- return promise;
-}
-
-function testScroll([result], hud) {
- let scrollNode = hud.ui.outputWrapper;
- let msgNode = [...result.matched][0];
- ok(msgNode.classList.contains("filtered-by-type"),
- "network message is filtered by type");
- ok(msgNode.classList.contains("filtered-by-string"),
- "network message is filtered by string");
-
- ok(scrollNode.scrollTop > 0, "scroll location is not at the top");
-
- // Make sure the Web Console output is scrolled as near as possible to the
- // bottom.
- let nodeHeight = msgNode.clientHeight;
- ok(scrollNode.scrollTop >= scrollNode.scrollHeight - scrollNode.clientHeight -
- nodeHeight * 2, "scroll location is correct");
-
- hud.setFilterState("network", true);
- hud.setFilterState("networkinfo", true);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_597756_reopen_closed_tab.js
+++ /dev/null
@@ -1,70 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-597756-reopen-closed-tab.html";
-
-var HUD;
-
-add_task(function* () {
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- let { browser } = yield loadTab(TEST_URI);
- HUD = yield openConsole();
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- yield reload(browser);
-
- yield testMessages();
-
- yield closeConsole();
-
- // Close and reopen
- gBrowser.removeCurrentTab();
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- let tab = yield loadTab(TEST_URI);
- HUD = yield openConsole();
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- yield reload(tab.browser);
-
- yield testMessages();
-
- HUD = null;
-});
-
-function reload(browser) {
- let loaded = loadBrowser(browser);
- browser.reload();
- return loaded;
-}
-
-function testMessages() {
- return waitForMessages({
- webconsole: HUD,
- messages: [{
- name: "error message displayed",
- text: "fooBug597756_error",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_599725_response_headers.js
+++ /dev/null
@@ -1,70 +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/ */
-
-"use strict";
-
-const INIT_URI = "data:text/plain;charset=utf8,hello world";
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-599725-response-headers.sjs";
-
-function performTest(request, hud) {
- let deferred = defer();
-
- let headers = null;
-
- function readHeader(name) {
- for (let header of headers) {
- if (header.name == name) {
- return header.value;
- }
- }
- return null;
- }
-
- hud.ui.proxy.webConsoleClient.getResponseHeaders(request.actor,
- function (response) {
- headers = response.headers;
- ok(headers, "we have the response headers for reload");
-
- let contentType = readHeader("Content-Type");
- let contentLength = readHeader("Content-Length");
-
- ok(!contentType, "we do not have the Content-Type header");
- isnot(contentLength, 60, "Content-Length != 60");
-
- executeSoon(deferred.resolve);
- });
-
- return deferred.promise;
-}
-
-let waitForRequest = Task.async(function*(hud) {
- let request = yield waitForFinishedRequest(req=> {
- return req.response.status === "304";
- });
-
- yield performTest(request, hud);
-});
-
-add_task(function* () {
- // Disable rcwn to make sure we will send a conditional request.
- yield pushPref("network.http.rcwn.enabled", false);
-
- let { browser } = yield loadTab(INIT_URI);
-
- let hud = yield openConsole();
-
- let gotLastRequest = waitForRequest(hud);
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_URI);
- yield loaded;
-
- let reloaded = loadBrowser(browser);
- ContentTask.spawn(browser, null, "() => content.location.reload()");
- yield reloaded;
-
- yield gotLastRequest;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_600183_charset.js
+++ /dev/null
@@ -1,59 +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/ */
-
-"use strict";
-
-const INIT_URI = "data:text/html;charset=utf-8,Web Console - bug 600183 test";
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-600183-charset.html";
-
-function performTest(lastFinishedRequest, console) {
- let deferred = defer();
-
- ok(lastFinishedRequest, "charset test page was loaded and logged");
- HUDService.lastFinishedRequest.callback = null;
-
- executeSoon(() => {
- console.webConsoleClient.getResponseContent(lastFinishedRequest.actor,
- (response) => {
- ok(!response.contentDiscarded, "response body was not discarded");
-
- let body = response.content.text;
- ok(body, "we have the response body");
-
- // 的问候!
- let chars = "\u7684\u95ee\u5019!";
- isnot(body.indexOf("<p>" + chars + "</p>"), -1,
- "found the chinese simplified string");
-
- HUDService.lastFinishedRequest.callback = null;
- executeSoon(deferred.resolve);
- });
- });
-
- return deferred.promise;
-}
-
-function waitForRequest() {
- let deferred = defer();
- HUDService.lastFinishedRequest.callback = (req, console) => {
- performTest(req, console).then(deferred.resolve);
- };
- return deferred.promise;
-}
-
-add_task(function* () {
- let { browser } = yield loadTab(INIT_URI);
-
- yield openConsole();
-
- let gotLastRequest = waitForRequest();
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_URI);
- yield loaded;
-
- yield gotLastRequest;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_601177_log_levels.js
+++ /dev/null
@@ -1,76 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 601177: log levels";
-const TEST_URI2 = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-601177-log-levels.html";
-
-add_task(function* () {
- Services.prefs.setBoolPref("javascript.options.strict", true);
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- yield testLogLevels(hud);
-
- Services.prefs.clearUserPref("javascript.options.strict");
-});
-
-function testLogLevels(hud) {
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);
-
- info("waiting for messages");
-
- return waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "test-bug-601177-log-levels.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-bug-601177-log-levels.js",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-image.png",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "foobar-known-to-fail.png",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_ERROR,
- },
- {
- text: "foobarBug601177exception",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- text: "undefinedPropertyBug601177",
- category: CATEGORY_JS,
- severity: SEVERITY_WARNING,
- },
- {
- text: "foobarBug601177strictError",
- category: CATEGORY_JS,
- severity: SEVERITY_WARNING,
- },
- ],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_601352_scroll.js
+++ /dev/null
@@ -1,84 +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 that the console output scrolls to JS eval results when there are many
-// messages displayed. See bug 601352.
-
-"use strict";
-
-add_task(function* () {
- let {tab} = yield loadTab("data:text/html;charset=utf-8,Web Console test " +
- "for bug 601352");
- let hud = yield openConsole(tab);
- hud.jsterm.clearOutput();
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let longMessage = "";
- for (let i = 0; i < 50; i++) {
- longMessage += "LongNonwrappingMessage";
- }
-
- for (let i = 0; i < 50; i++) {
- content.console.log("test1 message " + i);
- }
-
- content.console.log(longMessage);
-
- for (let i = 0; i < 50; i++) {
- content.console.log("test2 message " + i);
- }
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test1 message 0",
- }, {
- text: "test1 message 49",
- }, {
- text: "LongNonwrappingMessage",
- }, {
- text: "test2 message 0",
- }, {
- text: "test2 message 49",
- }],
- });
-
- let node = yield hud.jsterm.execute("1+1");
-
- let scrollNode = hud.ui.outputWrapper;
- let rectNode = node.getBoundingClientRect();
- let rectOutput = scrollNode.getBoundingClientRect();
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, {
- rectNode,
- rectOutput,
- scrollHeight: scrollNode.scrollHeight,
- scrollTop: scrollNode.scrollTop,
- clientHeight: scrollNode.clientHeight,
- }, function* (args) {
- console.debug("rectNode", args.rectNode, "rectOutput", args.rectOutput);
- console.log("scrollNode scrollHeight", args.scrollHeight,
- "scrollTop", args.scrollTop, "clientHeight",
- args.clientHeight);
- });
-
- isnot(scrollNode.scrollTop, 0, "scroll location is not at the top");
-
- // The bounding client rect .top/left coordinates are relative to the
- // console iframe.
-
- // Visible scroll viewport.
- let height = rectOutput.height;
-
- // Top and bottom coordinates of the last message node, relative to the
- // outputNode.
- let top = rectNode.top - rectOutput.top;
- let bottom = top + rectNode.height;
- info("node top " + top + " node bottom " + bottom + " node clientHeight " +
- node.clientHeight);
-
- ok(top >= 0 && bottom <= height, "last message is visible");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_601667_filter_buttons.js
+++ /dev/null
@@ -1,263 +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/ */
-
-// Tests that the filter button UI logic works correctly.
-
-"use strict";
-
-const TEST_URI = "http://example.com/";
-const FILTER_PREF_DOMAIN = "devtools.webconsole.filter.";
-
-var hud, hudId, hudBox;
-var prefs = {};
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
- hudId = hud.hudId;
- hudBox = hud.ui.rootElement;
-
- savePrefs();
-
- testFilterButtons();
-
- restorePrefs();
-
- hud = hudId = hudBox = null;
-});
-
-function savePrefs() {
- let branch = Services.prefs.getBranch(FILTER_PREF_DOMAIN);
- let children = branch.getChildList("");
- for (let child of children) {
- prefs[child] = branch.getBoolPref(child);
- }
-}
-
-function restorePrefs() {
- let branch = Services.prefs.getBranch(FILTER_PREF_DOMAIN);
- for (let p in prefs) {
- branch.setBoolPref(p, prefs[p]);
- }
-}
-
-function testFilterButtons() {
- testMenuFilterButton("net");
- testMenuFilterButton("css");
- testMenuFilterButton("js");
- testMenuFilterButton("logging");
- testMenuFilterButton("security");
- testMenuFilterButton("server");
-
- testIsolateFilterButton("net");
- testIsolateFilterButton("css");
- testIsolateFilterButton("js");
- testIsolateFilterButton("logging");
- testIsolateFilterButton("security");
- testIsolateFilterButton("server");
-}
-
-function testMenuFilterButton(category) {
- let selector = ".webconsole-filter-button[category=\"" + category + "\"]";
- let button = hudBox.querySelector(selector);
- ok(button, "we have the \"" + category + "\" button");
-
- let firstMenuItem = button.querySelector("menuitem");
- ok(firstMenuItem, "we have the first menu item for the \"" + category +
- "\" button");
-
- // Turn all the filters off, if they were on.
- let menuItem = firstMenuItem;
- while (menuItem != null) {
- if (menuItem.hasAttribute("prefKey") && isChecked(menuItem)) {
- chooseMenuItem(menuItem);
- }
- menuItem = menuItem.nextSibling;
- }
-
- // Turn all the filters on; make sure the button gets checked.
- menuItem = firstMenuItem;
- let prefKey;
- while (menuItem) {
- if (menuItem.hasAttribute("prefKey")) {
- prefKey = menuItem.getAttribute("prefKey");
- chooseMenuItem(menuItem);
- ok(isChecked(menuItem), "menu item " + prefKey + " for category " +
- category + " is checked after clicking it");
- ok(hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "on after clicking the appropriate menu item");
- }
- menuItem = menuItem.nextSibling;
- }
- ok(isChecked(button), "the button for category " + category + " is " +
- "checked after turning on all its menu items");
-
- // Turn one filter off; make sure the button is still checked.
- prefKey = firstMenuItem.getAttribute("prefKey");
- chooseMenuItem(firstMenuItem);
- ok(!isChecked(firstMenuItem), "the first menu item for category " +
- category + " is no longer checked after clicking it");
- ok(!hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "turned off after clicking the appropriate menu item");
- ok(isChecked(button), "the button for category " + category + " is still " +
- "checked after turning off its first menu item");
-
- // Turn all the filters off by shift clicking the button.
- shiftClickButton(button);
- ok(!isChecked(button), "the button for category " + category + " is " +
- "no longer checked after clicking its main part");
-
- menuItem = firstMenuItem;
- while (menuItem) {
- prefKey = menuItem.getAttribute("prefKey");
- if (prefKey) {
- ok(!isChecked(menuItem), "menu item " + prefKey + " for category " +
- category + " is no longer checked after clicking the button");
- ok(!hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "off after clicking the button");
- }
- menuItem = menuItem.nextSibling;
- }
-
- // Turn all the filters on by shift clicking the button.
- shiftClickButton(button);
-
- ok(isChecked(button), "the button for category " + category + " is " +
- "checked after clicking its main part");
-
- menuItem = firstMenuItem;
- while (menuItem) {
- if (menuItem.hasAttribute("prefKey")) {
- prefKey = menuItem.getAttribute("prefKey");
- // The CSS/Log menu item should not be checked. See bug 971798.
- if (category == "css" && prefKey == "csslog") {
- ok(!isChecked(menuItem), "menu item " + prefKey + " for category " +
- category + " should not be checked after clicking the button");
- ok(!hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "off after clicking the button");
- } else {
- ok(isChecked(menuItem), "menu item " + prefKey + " for category " +
- category + " is checked after clicking the button");
- ok(hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "on after clicking the button");
- }
- }
- menuItem = menuItem.nextSibling;
- }
-
- // Uncheck the main button by unchecking all the filters
- menuItem = firstMenuItem;
- while (menuItem) {
- // The csslog menu item is already unchecked at this point.
- // Make sure it is not selected. See bug 971798.
- prefKey = menuItem.getAttribute("prefKey");
- if (prefKey && prefKey != "csslog") {
- chooseMenuItem(menuItem);
- }
- menuItem = menuItem.nextSibling;
- }
-
- ok(!isChecked(button), "the button for category " + category + " is " +
- "unchecked after unchecking all its filters");
-
- // Turn all the filters on again by shift clicking the button.
- shiftClickButton(button);
-}
-
-function testIsolateFilterButton(category) {
- let selector = ".webconsole-filter-button[category=\"" + category + "\"]";
- let targetButton = hudBox.querySelector(selector);
- ok(targetButton, "we have the \"" + category + "\" button");
-
- // Turn on all the filters by alt clicking the button.
- altClickButton(targetButton);
- ok(isChecked(targetButton), "the button for category " + category +
- " is checked after isolating for filter");
-
- // Check if all the filters for the target button are on.
- let menuItems = targetButton.querySelectorAll("menuitem");
- Array.forEach(menuItems, (item) => {
- let prefKey = item.getAttribute("prefKey");
- // The CSS/Log filter should not be checked. See bug 971798.
- if (category == "css" && prefKey == "csslog") {
- ok(!isChecked(item), "menu item " + prefKey + " for category " +
- category + " should not be checked after isolating for " + category);
- ok(!hud.ui.filterPrefs[prefKey], prefKey + " messages should be " +
- "turned off after isolating for " + category);
- } else if (prefKey) {
- ok(isChecked(item), "menu item " + prefKey + " for category " +
- category + " is checked after isolating for " + category);
- ok(hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "turned on after isolating for " + category);
- }
- });
-
- // Ensure all other filter buttons are toggled off and their
- // associated filters are turned off
- let buttons = hudBox.querySelectorAll(".webconsole-filter-button[category]");
- Array.forEach(buttons, (filterButton) => {
- if (filterButton !== targetButton) {
- let categoryBtn = filterButton.getAttribute("category");
- ok(!isChecked(filterButton), "the button for category " +
- categoryBtn + " is unchecked after isolating for " + category);
-
- menuItems = filterButton.querySelectorAll("menuitem");
- Array.forEach(menuItems, (item) => {
- let prefKey = item.getAttribute("prefKey");
- if (prefKey) {
- ok(!isChecked(item), "menu item " + prefKey + " for category " +
- category + " is unchecked after isolating for " + category);
- ok(!hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
- "turned off after isolating for " + category);
- }
- });
-
- // Turn all the filters on again by shift clicking the button.
- shiftClickButton(targetButton);
- }
- });
-}
-
-/**
- * Return the main part of the target filter button.
- */
-function getMainButton(targetButton) {
- let anonymousNodes = hud.ui.document.getAnonymousNodes(targetButton);
- let subbutton;
-
- for (let i = 0; i < anonymousNodes.length; i++) {
- let node = anonymousNodes[i];
- if (node.classList.contains("toolbarbutton-menubutton-button")) {
- subbutton = node;
- break;
- }
- }
-
- return subbutton;
-}
-
-function clickButton(node) {
- EventUtils.sendMouseEvent({ type: "click" }, node);
-}
-
-function altClickButton(node) {
- EventUtils.sendMouseEvent({ type: "click", altKey: true }, node);
-}
-
-function shiftClickButton(node) {
- EventUtils.sendMouseEvent({ type: "click", shiftKey: true }, node);
-}
-
-function chooseMenuItem(node) {
- let event = document.createEvent("XULCommandEvent");
- event.initCommandEvent("command", true, true, window, 0, false, false, false,
- false, null, 0);
- node.dispatchEvent(event);
-}
-
-function isChecked(node) {
- return node.getAttribute("checked") === "true";
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_603750_websocket.js
+++ /dev/null
@@ -1,37 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-603750-websocket.html";
-const TEST_URI2 = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 603750: Web Socket errors";
-
-add_task(function* () {
- yield loadTab(TEST_URI2);
-
- let hud = yield openConsole();
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "ws://0.0.0.0:81",
- source: { url: "test-bug-603750-websocket.js" },
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- text: "ws://0.0.0.0:82",
- source: { url: "test-bug-603750-websocket.js" },
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- ]
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_611795.js
+++ /dev/null
@@ -1,67 +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/ */
-
-"use strict";
-
-const TEST_URI = 'data:text/html;charset=utf-8,<div style="-moz-opacity:0;">' +
- 'test repeated css warnings</div><p style="-moz-opacity:0">' +
- "hi</p>";
-var hud;
-
-/**
- * Unit test for bug 611795:
- * Repeated CSS messages get collapsed into one.
- */
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
- hud.jsterm.clearOutput(true);
-
- BrowserReload();
- yield loadBrowser(gBrowser.selectedBrowser);
-
- yield onContentLoaded();
- yield testConsoleLogRepeats();
-
- hud = null;
-});
-
-function onContentLoaded() {
- let cssWarning = "Unknown property \u2018-moz-opacity\u2019. Declaration dropped.";
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: cssWarning,
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- repeats: 2,
- }],
- });
-}
-
-function testConsoleLogRepeats() {
- let jsterm = hud.jsterm;
-
- jsterm.clearOutput();
-
- jsterm.setInputValue("for (let i = 0; i < 10; ++i) console.log('this is a " +
- "line of reasonably long text that I will use to " +
- "verify that the repeated text node is of an " +
- "appropriate size.');");
- jsterm.execute();
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "this is a line of reasonably long text",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- repeats: 10,
- }],
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_613013_console_api_iframe.js
+++ /dev/null
@@ -1,26 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-613013-console-api-iframe.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- BrowserReload();
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarBug613013",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_613280_jsterm_copy.js
+++ /dev/null
@@ -1,64 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 613280";
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then((HUD) => {
- ContentTask.spawn(gBrowser.selectedBrowser, null, function*(){
- content.console.log("foobarBazBug613280");
- });
- waitForMessages({
- webconsole: HUD,
- messages: [{
- text: "foobarBazBug613280",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- }).then(performTest.bind(null, HUD));
- });
- });
-}
-
-function performTest(HUD, [result]) {
- let msg = [...result.matched][0];
- let input = HUD.jsterm.inputNode;
-
- let clipboardSetup = function () {
- goDoCommand("cmd_copy");
- };
-
- let clipboardCopyDone = function () {
- finishTest();
- };
-
- let controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
-
- HUD.ui.output.selectMessage(msg);
- HUD.outputNode.focus();
-
- goUpdateCommand("cmd_copy");
-
- controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
-
- // Remove new lines and whitespace since getSelection() includes
- // a new line between message and line number, but the clipboard doesn't
- // @see bug 1119503
- let selectionText = (HUD.iframeWindow.getSelection() + "")
- .replace(/\r?\n|\r| /g, "");
- isnot(selectionText.indexOf("foobarBazBug613280"), -1,
- "selection text includes 'foobarBazBug613280'");
-
- waitForClipboard((str) => {
- return selectionText.trim() === str.trim().replace(/ /g, "");
- }, clipboardSetup, clipboardCopyDone, clipboardCopyDone);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_613642_maintain_scroll.js
+++ /dev/null
@@ -1,119 +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/ */
-
-"use strict";
-
-var TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 613642: remember scroll location";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
- let outputNode = hud.outputNode;
- let scrollBox = hud.ui.outputWrapper;
-
- for (let i = 0; i < 150; i++) {
- ContentTask.spawn(gBrowser.selectedBrowser, i, function* (num) {
- content.console.log("test message " + num);
- });
- }
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test message 149",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- ok(scrollBox.scrollTop > 0, "scroll location is not at the top");
-
- // scroll to the first node
- outputNode.focus();
-
- let scrolled = defer();
-
- scrollBox.onscroll = () => {
- info("onscroll top " + scrollBox.scrollTop);
- if (scrollBox.scrollTop != 0) {
- // Wait for scroll to 0.
- return;
- }
- scrollBox.onscroll = null;
- is(scrollBox.scrollTop, 0, "scroll location updated (moved to top)");
- scrolled.resolve();
- };
- EventUtils.synthesizeKey("KEY_Home", {}, hud.iframeWindow);
-
- yield scrolled.promise;
-
- // add a message and make sure scroll doesn't change
- ContentTask.spawn(gBrowser.selectedBrowser, null,
- "() => content.console.log('test message 150')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test message 150",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- scrolled = defer();
- scrollBox.onscroll = () => {
- if (scrollBox.scrollTop != 0) {
- // Wait for scroll to stabilize at the top.
- return;
- }
- scrollBox.onscroll = null;
- is(scrollBox.scrollTop, 0, "scroll location is still at the top");
- scrolled.resolve();
- };
-
- // Make sure that scroll stabilizes at the top. executeSoon() is needed for
- // the yield to work.
- executeSoon(scrollBox.onscroll);
-
- yield scrolled.promise;
-
- // scroll back to the bottom
- outputNode.lastChild.focus();
-
- scrolled = defer();
- scrollBox.onscroll = () => {
- if (scrollBox.scrollTop == 0) {
- // Wait for scroll to bottom.
- return;
- }
- scrollBox.onscroll = null;
- isnot(scrollBox.scrollTop, 0, "scroll location updated (moved to bottom)");
- scrolled.resolve();
- };
- EventUtils.synthesizeKey("KEY_End");
- yield scrolled.promise;
-
- let oldScrollTop = scrollBox.scrollTop;
-
- ContentTask.spawn(gBrowser.selectedBrowser, null,
- "() => content.console.log('test message 151')");
-
- scrolled = defer();
- scrollBox.onscroll = () => {
- if (scrollBox.scrollTop == oldScrollTop) {
- // Wait for scroll to change.
- return;
- }
- scrollBox.onscroll = null;
- isnot(scrollBox.scrollTop, oldScrollTop,
- "scroll location updated (moved to bottom again)");
- scrolled.resolve();
- };
- yield scrolled.promise;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_613642_prune_scroll.js
+++ /dev/null
@@ -1,82 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 613642: maintain scroll with pruning of old messages";
-
-var hud;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
-
- hud.jsterm.clearOutput();
-
- let outputNode = hud.outputNode;
-
- Services.prefs.setIntPref("devtools.hud.loglimit.console", 140);
- let scrollBoxElement = hud.ui.outputWrapper;
-
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- for (let i = 0; i < 150; i++) {
- content.console.log("test message " + i);
- }
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test message 149",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let oldScrollTop = scrollBoxElement.scrollTop;
- isnot(oldScrollTop, 0, "scroll location is not at the top");
-
- let firstNode = outputNode.firstChild;
- ok(firstNode, "found the first message");
-
- let msgNode = outputNode.children[80];
- ok(msgNode, "found the 80th message");
-
- // scroll to the middle message node
- msgNode.scrollIntoView(false);
-
- isnot(scrollBoxElement.scrollTop, oldScrollTop,
- "scroll location updated (scrolled to message)");
-
- oldScrollTop = scrollBoxElement.scrollTop;
-
- // add a message
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.console.log("hello world");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "hello world",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- // Scroll location needs to change, because one message is also removed, and
- // we need to scroll a bit towards the top, to keep the current view in sync.
- isnot(scrollBoxElement.scrollTop, oldScrollTop,
- "scroll location updated (added a message)");
-
- isnot(outputNode.firstChild, firstNode,
- "first message removed");
-
- Services.prefs.clearUserPref("devtools.hud.loglimit.console");
-
- hud = null;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_614793_jsterm_scroll.js
+++ /dev/null
@@ -1,54 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 614793: jsterm result scroll";
-
-requestLongerTimeout(2);
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- yield testScrollPosition(hud);
-});
-
-function* testScrollPosition(hud) {
- hud.jsterm.clearOutput();
-
- let scrollNode = hud.ui.outputWrapper;
-
- for (let i = 0; i < 150; i++) {
- yield ContentTask.spawn(gBrowser.selectedBrowser, i, function* (i) {
- content.console.log("test message " + i);
- });
- }
-
- let oldScrollTop = -1;
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test message 149",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- oldScrollTop = scrollNode.scrollTop;
- isnot(oldScrollTop, 0, "scroll location is not at the top");
-
- let msg = yield hud.jsterm.execute("'hello world'");
-
- isnot(scrollNode.scrollTop, oldScrollTop, "scroll location updated");
-
- oldScrollTop = scrollNode.scrollTop;
-
- msg.scrollIntoView(false);
-
- is(scrollNode.scrollTop, oldScrollTop, "scroll location is the same");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_618078_network_exceptions.js
+++ /dev/null
@@ -1,36 +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/ */
-
-// Tests that we report JS exceptions in event handlers coming from
-// network requests, like onreadystate for XHR. See bug 618078.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 618078";
-const TEST_URI2 = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-618078-network-exceptions.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bug618078exception",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_621644_jsterm_dollar.js
+++ /dev/null
@@ -1,47 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-621644-jsterm-dollar.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield test$(hud);
- yield test$$(hud);
-});
-
-function* test$(HUD) {
- let deferred = defer();
-
- HUD.jsterm.clearOutput();
-
- HUD.jsterm.execute("$(document.body)", (msg) => {
- ok(msg.textContent.indexOf("<p>") > -1,
- "jsterm output is correct for $()");
- deferred.resolve();
- });
-
- return deferred.promise;
-}
-
-function test$$(HUD) {
- let deferred = defer();
-
- HUD.jsterm.clearOutput();
-
- HUD.jsterm.setInputValue();
- HUD.jsterm.execute("$$(document)", (msg) => {
- ok(msg.textContent.indexOf("621644") > -1,
- "jsterm output is correct for $$()");
- deferred.resolve();
- });
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_622303_persistent_filters.js
+++ /dev/null
@@ -1,149 +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/ */
-
-"use strict";
-
-const prefs = {
- "net": [
- "network",
- "netwarn",
- "netxhr",
- "networkinfo"
- ],
- "css": [
- "csserror",
- "cssparser",
- "csslog"
- ],
- "js": [
- "exception",
- "jswarn",
- "jslog",
- ],
- "logging": [
- "error",
- "warn",
- "info",
- "log",
- "serviceworkers",
- "sharedworkers",
- "windowlessworkers"
- ]
-};
-
-add_task(function* () {
- // Set all prefs to true
- for (let category in prefs) {
- prefs[category].forEach(function (pref) {
- Services.prefs.setBoolPref("devtools.webconsole.filter." + pref, true);
- });
- }
-
- yield loadTab("about:blank");
-
- let hud = yield openConsole();
-
- let hud2 = yield onConsoleOpen(hud);
- let hud3 = yield onConsoleReopen1(hud2);
- yield onConsoleReopen2(hud3);
-
- // Clear prefs
- for (let category in prefs) {
- prefs[category].forEach(function (pref) {
- Services.prefs.clearUserPref("devtools.webconsole.filter." + pref);
- });
- }
-});
-
-function onConsoleOpen(hud) {
- let deferred = defer();
-
- let hudBox = hud.ui.rootElement;
-
- // Check if the filters menuitems exists and are checked
- for (let category in prefs) {
- let button = hudBox.querySelector(".webconsole-filter-button[category=\""
- + category + "\"]");
- ok(isChecked(button), "main button for " + category +
- " category is checked");
-
- prefs[category].forEach(function (pref) {
- let menuitem = hudBox.querySelector("menuitem[prefKey=" + pref + "]");
- ok(isChecked(menuitem), "menuitem for " + pref + " is checked");
- });
- }
-
- // Set all prefs to false
- for (let category in prefs) {
- prefs[category].forEach(function (pref) {
- hud.setFilterState(pref, false);
- });
- }
-
- // Re-init the console
- closeConsole().then(() => {
- openConsole().then(deferred.resolve);
- });
-
- return deferred.promise;
-}
-
-function onConsoleReopen1(hud) {
- info("testing after reopening once");
- let deferred = defer();
-
- let hudBox = hud.ui.rootElement;
-
- // Check if the filter button and menuitems are unchecked
- for (let category in prefs) {
- let button = hudBox.querySelector(".webconsole-filter-button[category=\""
- + category + "\"]");
- ok(isUnchecked(button), "main button for " + category +
- " category is not checked");
-
- prefs[category].forEach(function (pref) {
- let menuitem = hudBox.querySelector("menuitem[prefKey=" + pref + "]");
- ok(isUnchecked(menuitem), "menuitem for " + pref + " is not checked");
- });
- }
-
- // Set first pref in each category to true
- for (let category in prefs) {
- hud.setFilterState(prefs[category][0], true);
- }
-
- // Re-init the console
- closeConsole().then(() => {
- openConsole().then(deferred.resolve);
- });
-
- return deferred.promise;
-}
-
-function onConsoleReopen2(hud) {
- info("testing after reopening again");
-
- let hudBox = hud.ui.rootElement;
-
- // Check the main category button is checked and first menuitem is checked
- for (let category in prefs) {
- let button = hudBox.querySelector(".webconsole-filter-button[category=\"" +
- category + "\"]");
- ok(isChecked(button), category +
- " button is checked when first pref is true");
-
- let pref = prefs[category][0];
- let menuitem = hudBox.querySelector("menuitem[prefKey=" + pref + "]");
- ok(isChecked(menuitem), "first " + category + " menuitem is checked");
- }
-}
-
-function isChecked(aNode) {
- return aNode.getAttribute("checked") === "true";
-}
-
-function isUnchecked(aNode) {
- return aNode.getAttribute("checked") === "false";
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js
+++ /dev/null
@@ -1,32 +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 https://bugzilla.mozilla.org/show_bug.cgi?id=623749
-// Map Control + A to Select All, In the web console input, on Windows
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Test console for bug 623749";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let jsterm = hud.jsterm;
- jsterm.setInputValue("Ignore These Four Words");
- let inputNode = jsterm.inputNode;
-
- // Test select all with Control + A.
- EventUtils.synthesizeKey("a", { ctrlKey: true });
- let inputLength = inputNode.selectionEnd - inputNode.selectionStart;
- is(inputLength, jsterm.getInputValue().length, "Select all of input");
-
- // Test do nothing on Control + E.
- jsterm.setInputValue("Ignore These Four Words");
- inputNode.selectionStart = 0;
- EventUtils.synthesizeKey("e", { ctrlKey: true });
- is(inputNode.selectionStart, 0, "Control + E does not move to end of input");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_630733_response_redirect_headers.js
+++ /dev/null
@@ -1,120 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for " +
- "bug 630733";
-const TEST_URI2 = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-630733-response-redirect-headers.sjs";
-
-var lastFinishedRequests = {};
-var webConsoleClient;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield consoleOpened(hud);
- yield getHeaders();
- yield getContent();
-
- performTest();
-});
-
-function consoleOpened(hud) {
- let deferred = defer();
-
- webConsoleClient = hud.ui.webConsoleClient;
- HUDService.lastFinishedRequest.callback = (aHttpRequest) => {
- let status = aHttpRequest.response.status;
- lastFinishedRequests[status] = aHttpRequest;
- if ("301" in lastFinishedRequests &&
- "404" in lastFinishedRequests) {
- deferred.resolve();
- }
- };
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);
-
- return deferred.promise;
-}
-
-function getHeaders() {
- let deferred = defer();
-
- HUDService.lastFinishedRequest.callback = null;
-
- ok("301" in lastFinishedRequests, "request 1: 301 Moved Permanently");
- ok("404" in lastFinishedRequests, "request 2: 404 Not found");
-
- webConsoleClient.getResponseHeaders(lastFinishedRequests["301"].actor,
- function (response) {
- lastFinishedRequests["301"].response.headers = response.headers;
-
- webConsoleClient.getResponseHeaders(lastFinishedRequests["404"].actor,
- function (resp) {
- lastFinishedRequests["404"].response.headers = resp.headers;
- executeSoon(deferred.resolve);
- });
- });
- return deferred.promise;
-}
-
-function getContent() {
- let deferred = defer();
-
- webConsoleClient.getResponseContent(lastFinishedRequests["301"].actor,
- function (response) {
- lastFinishedRequests["301"].response.content = response.content;
- lastFinishedRequests["301"].discardResponseBody = response.contentDiscarded;
-
- webConsoleClient.getResponseContent(lastFinishedRequests["404"].actor,
- function (resp) {
- lastFinishedRequests["404"].response.content = resp.content;
- lastFinishedRequests["404"].discardResponseBody =
- resp.contentDiscarded;
-
- webConsoleClient = null;
- executeSoon(deferred.resolve);
- });
- });
- return deferred.promise;
-}
-
-function performTest() {
- function readHeader(name) {
- for (let header of headers) {
- if (header.name.toLowerCase() == name.toLowerCase()) {
- return header.value;
- }
- }
- return null;
- }
-
- let headers = lastFinishedRequests["301"].response.headers;
- is(readHeader("Content-Type"), "text/html",
- "we do have the Content-Type header");
- is(readHeader("Content-Length"), 71, "Content-Length is correct");
- is(readHeader("Location"), "/redirect-from-bug-630733",
- "Content-Length is correct");
- is(readHeader("x-foobar-bug630733"), "bazbaz",
- "X-Foobar-bug630733 is correct");
-
- let body = lastFinishedRequests["301"].response.content;
- ok(!body.text, "body discarded for request 1");
- ok(lastFinishedRequests["301"].discardResponseBody,
- "body discarded for request 1 (confirmed)");
-
- headers = lastFinishedRequests["404"].response.headers;
- ok(!readHeader("Location"), "no Location header");
- ok(!readHeader("x-foobar-bug630733"), "no X-Foobar-bug630733 header");
-
- body = lastFinishedRequests["404"].response.content.text;
- isnot(body.indexOf("404"), -1,
- "body is correct for request 2");
-
- lastFinishedRequests = webConsoleClient = null;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_632275_getters_document_width.js
+++ /dev/null
@@ -1,49 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-632275-getters.html";
-
-var getterValue = null;
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
-
-async function consoleOpened(hud) {
- getterValue = await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- return content.wrappedJSObject.document.foobar._val;
- });
- hud.jsterm.execute("console.dir(document)");
-
- let onOpen = onViewOpened.bind(null, hud);
- hud.jsterm.once("variablesview-fetched", onOpen);
-}
-
-async function onViewOpened(hud, view) {
- await findVariableViewProperties(view, [
- { name: /^(width|height)$/, dontMatch: 1 },
- { name: "foobar._val", value: getterValue },
- { name: "foobar.val", isGetter: true },
- ], { webconsole: hud });
-
- await ContentTask.spawn(gBrowser.selectedBrowser, getterValue, function(value) {
- let doc = content.wrappedJSObject.document;
- is(doc.foobar._val, value, "getter did not execute");
- is(doc.foobar.val, value + 1, "getter executed");
- is(doc.foobar._val, value + 1, "getter executed (recheck)");
- });
-
- let textContent = hud.outputNode.textContent;
- is(textContent.indexOf("document.body.client"), -1,
- "no document.width/height warning displayed");
-
- getterValue = null;
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_632347_iterators_generators.js
+++ /dev/null
@@ -1,67 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-632347-iterators-generators.html";
-
-function test() {
- requestLongerTimeout(6);
-
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
-
-function consoleOpened(HUD) {
- let {JSPropertyProvider} = require("devtools/shared/webconsole/js-property-provider");
-
- let tmp = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm", {});
- tmp.addDebuggerToGlobal(tmp);
- let dbg = new tmp.Debugger();
-
- let jsterm = HUD.jsterm;
- let win = content.wrappedJSObject;
- let dbgWindow = dbg.addDebuggee(content);
- let container = win._container;
-
- // Make sure autocomplete does not walk through generators.
- let result = container.gen1.next().value;
- let completion = JSPropertyProvider(dbgWindow, null, "_container.gen1.");
- isnot(completion.matches.length, 0, "Got matches for gen1");
-
- is(result + 1, container.gen1.next().value, "gen1.next() did not execute");
-
- result = container.gen2.next().value;
-
- completion = JSPropertyProvider(dbgWindow, null, "_container.gen2.");
- isnot(completion.matches.length, 0, "Got matches for gen2");
-
- is((result / 2 + 1) * 2, container.gen2.next().value,
- "gen2.next() did not execute");
-
- completion = JSPropertyProvider(dbgWindow, null, "window._container.");
- ok(completion, "matches available for window._container");
- ok(completion.matches.length, "matches available for window (length)");
-
- dbg.removeDebuggee(content);
- jsterm.clearOutput();
-
- jsterm.execute("window._container", (msg) => {
- jsterm.once("variablesview-fetched", testVariablesView.bind(null, HUD));
- let anchor = msg.querySelector(".message-body a");
- EventUtils.synthesizeMouse(anchor, 2, 2, {}, HUD.iframeWindow);
- });
-}
-
-function testVariablesView(aWebconsole, aView) {
- findVariableViewProperties(aView, [
- { name: "gen1", isGenerator: true },
- { name: "gen2", isGenerator: true },
- ], { webconsole: aWebconsole }).then(function () {
- executeSoon(finishTest);
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_632817.js
+++ /dev/null
@@ -1,213 +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/ */
-
-// Tests that Web console messages can be filtered for NET events.
-
-"use strict";
-
-const TEST_NETWORK_REQUEST_URI =
- "https://example.com/browser/devtools/client/webconsole/old/test/" +
- "test-network-request.html";
-
-const TEST_IMG = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-image.png";
-
-const TEST_DATA_JSON_CONTENT =
- '{ id: "test JSON data", myArray: [ "foo", "bar", "baz", "biff" ] }';
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console network logging " +
- "tests";
-
-const PAGE_REQUEST_PREDICATE =
- ({ request }) => request.url.endsWith("test-network-request.html");
-
-const TEST_DATA_REQUEST_PREDICATE =
- ({ request }) => request.url.endsWith("test-data.json");
-
-const XHR_WARN_REQUEST_PREDICATE =
- ({ request }) => request.url.endsWith("sjs_cors-test-server.sjs");
-
-let hud;
-
-add_task(function*() {
- const PREF = "devtools.webconsole.persistlog";
- const NET_PREF = "devtools.webconsole.filter.networkinfo";
- const NETXHR_PREF = "devtools.webconsole.filter.netxhr";
- const MIXED_AC_PREF = "security.mixed_content.block_active_content";
- let original = Services.prefs.getBoolPref(NET_PREF);
- let originalXhr = Services.prefs.getBoolPref(NETXHR_PREF);
- let originalMixedActive = Services.prefs.getBoolPref(MIXED_AC_PREF);
- Services.prefs.setBoolPref(NET_PREF, true);
- Services.prefs.setBoolPref(NETXHR_PREF, true);
- Services.prefs.setBoolPref(MIXED_AC_PREF, false);
- Services.prefs.setBoolPref(PREF, true);
- registerCleanupFunction(() => {
- Services.prefs.setBoolPref(NET_PREF, original);
- Services.prefs.setBoolPref(NETXHR_PREF, originalXhr);
- Services.prefs.setBoolPref(MIXED_AC_PREF, originalMixedActive);
- Services.prefs.clearUserPref(PREF);
- hud = null;
- });
-
- yield loadTab(TEST_URI);
- hud = yield openConsole();
-
- yield testPageLoad();
- yield testXhrGet();
- yield testXhrWarn();
- yield testXhrPost();
- yield testFormSubmission();
- yield testLiveFilteringOnSearchStrings();
-});
-
-function testPageLoad() {
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_NETWORK_REQUEST_URI);
- let lastRequest = yield waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
-
- // Check if page load was logged correctly.
- ok(lastRequest, "Page load was logged");
- is(lastRequest.request.url, TEST_NETWORK_REQUEST_URI,
- "Logged network entry is page load");
- is(lastRequest.request.method, "GET", "Method is correct");
-}
-
-function testXhrGet() {
- // Start the XMLHttpRequest() GET test.
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
- content.wrappedJSObject.testXhrGet();
- });
-
- let lastRequest = yield waitForFinishedRequest(TEST_DATA_REQUEST_PREDICATE);
-
- ok(lastRequest, "testXhrGet() was logged");
- is(lastRequest.request.method, "GET", "Method is correct");
- ok(lastRequest.isXHR, "It's an XHR request");
-}
-
-function testXhrWarn() {
- // Start the XMLHttpRequest() warn test.
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
- content.wrappedJSObject.testXhrWarn();
- });
-
- let lastRequest = yield waitForFinishedRequest(XHR_WARN_REQUEST_PREDICATE);
- if (lastRequest.request.method == "HEAD") {
- lastRequest = yield waitForFinishedRequest(XHR_WARN_REQUEST_PREDICATE);
- }
-
- ok(lastRequest, "testXhrWarn() was logged");
- is(lastRequest.request.method, "GET", "Method is correct");
- ok(lastRequest.isXHR, "It's an XHR request");
- is(lastRequest.securityInfo, "insecure", "It's an insecure request");
-}
-
-function testXhrPost() {
- // Start the XMLHttpRequest() POST test.
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
- content.wrappedJSObject.testXhrPost();
- });
-
- let lastRequest = yield waitForFinishedRequest(TEST_DATA_REQUEST_PREDICATE);
-
- ok(lastRequest, "testXhrPost() was logged");
- is(lastRequest.request.method, "POST", "Method is correct");
- ok(lastRequest.isXHR, "It's an XHR request");
-}
-
-function testFormSubmission() {
- // Start the form submission test. As the form is submitted, the page is
- // loaded again. Bind to the load event to catch when this is done.
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
- let form = content.document.querySelector("form");
- ok(form, "we have the HTML form");
- form.submit();
- });
-
- // The form POSTs to the page URL but over https (page over http).
- let lastRequest = yield waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
-
- ok(lastRequest, "testFormSubmission() was logged");
- is(lastRequest.request.method, "POST", "Method is correct");
-
- // There should be 3 network requests pointing to the HTML file.
- waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "test-network-request.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- count: 3,
- },
- {
- text: "test-data.json",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_INFO,
- isXhr: true,
- count: 2,
- },
- {
- text: "http://example.com/",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_WARNING,
- isXhr: true,
- count: 1,
- },
- ],
- });
-}
-
-function testLiveFilteringOnSearchStrings() {
- setStringFilter("http");
- isnot(countMessageNodes(), 0, "the log nodes are not hidden when the " +
- "search string is set to \"http\"");
-
- setStringFilter("HTTP");
- isnot(countMessageNodes(), 0, "the log nodes are not hidden when the " +
- "search string is set to \"HTTP\"");
-
- setStringFilter("hxxp");
- is(countMessageNodes(), 0, "the log nodes are hidden when the search " +
- "string is set to \"hxxp\"");
-
- setStringFilter("ht tp");
- isnot(countMessageNodes(), 0, "the log nodes are not hidden when the " +
- "search string is set to \"ht tp\"");
-
- setStringFilter("");
- isnot(countMessageNodes(), 0, "the log nodes are not hidden when the " +
- "search string is removed");
-
- setStringFilter("json");
- is(countMessageNodes(), 2, "the log nodes show only the nodes with \"json\"");
-
- setStringFilter("'foo'");
- is(countMessageNodes(), 0, "the log nodes are hidden when searching for " +
- "the string 'foo'");
-
- setStringFilter("foo\"bar'baz\"boo'");
- is(countMessageNodes(), 0, "the log nodes are hidden when searching for " +
- "the string \"foo\"bar'baz\"boo'\"");
-}
-
-function countMessageNodes() {
- let messageNodes = hud.outputNode.querySelectorAll(".message");
- let displayedMessageNodes = 0;
- let view = hud.iframeWindow;
- for (let i = 0; i < messageNodes.length; i++) {
- let computedStyle = view.getComputedStyle(messageNodes[i]);
- if (computedStyle.display !== "none") {
- displayedMessageNodes++;
- }
- }
-
- return displayedMessageNodes;
-}
-
-function setStringFilter(value) {
- hud.ui.filterBox.value = value;
- hud.ui.adjustVisibilityOnSearchStringChange();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_642108_pruneTest.js
+++ /dev/null
@@ -1,81 +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/ */
-
-// Tests that the Web Console limits the number of lines displayed according to
-// the user's preferences.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108.";
-const LOG_LIMIT = 20;
-
-function test() {
- let hud;
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- let {tab} = yield loadTab(TEST_URI);
-
- Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT);
- Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true);
-
- registerCleanupFunction(function () {
- Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser");
- Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser");
- });
-
- hud = yield openConsole(tab);
-
- for (let i = 0; i < 5; i++) {
- logCSSMessage("css log x");
- }
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "css log x",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- repeats: 5,
- }],
- });
-
- for (let i = 0; i < LOG_LIMIT + 5; i++) {
- logCSSMessage("css log " + i);
- }
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "css log 5",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- },
- {
- // LOG_LIMIT + 5
- text: "css log 24",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- }],
- });
-
- is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT,
- "number of messages");
-
- is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT,
- "repeated nodes pruned from repeatNodes");
-
- let msg = [...result.matched][0];
- let repeats = msg.querySelector(".message-repeats");
- is(repeats.getAttribute("value"), 1,
- "repeated nodes pruned from repeatNodes (confirmed)");
- }
-
- function logCSSMessage(msg) {
- let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg);
- hud.ui.outputMessage(CATEGORY_CSS, node);
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_644419_log_limits.js
+++ /dev/null
@@ -1,250 +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/ */
-
-// Tests that the Web Console limits the number of lines displayed according to
-// the limit set for each category.
-
-"use strict";
-
-const INIT_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 644419: Console should " +
- "have user-settable log limits for each message category";
-
-const TEST_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-bug-644419-log-limits.html";
-
-var hud, outputNode;
-
-add_task(function* () {
- let { browser } = yield loadTab(INIT_URI);
-
- hud = yield openConsole();
-
- hud.jsterm.clearOutput();
- outputNode = hud.outputNode;
-
- let loaded = loadBrowser(browser);
-
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
- yield loaded;
-
- yield testWebDevLimits();
- yield testWebDevLimits2();
- yield testJsLimits();
- yield testJsLimits2();
-
- yield testNetLimits();
- yield loadImage();
- yield testCssLimits();
- yield testCssLimits2();
-
- hud = outputNode = null;
-});
-
-function testWebDevLimits() {
- Services.prefs.setIntPref("devtools.hud.loglimit.console", 10);
-
- // Find the sentinel entry.
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bar is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
-}
-
-async function testWebDevLimits2() {
- // Fill the log with Web Developer errors.
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- for (let i = 0; i < 11; i++) {
- content.console.log("test message " + i);
- }
- });
-
- await waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test message 10",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- testLogEntry(outputNode, "test message 0", "first message is pruned",
- false, true);
- findLogEntry("test message 1");
- // Check if the sentinel entry is still there.
- findLogEntry("bar is not defined");
-
- Services.prefs.clearUserPref("devtools.hud.loglimit.console");
-}
-
-async function testJsLimits() {
- Services.prefs.setIntPref("devtools.hud.loglimit.exception", 10);
-
- hud.jsterm.clearOutput();
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("testing JS limits");
- });
-
- // Find the sentinel entry.
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "testing JS limits",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-async function testJsLimits2() {
- // Fill the log with JS errors.
- for (let i = 0; i < 11; i++) {
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- await ContentTask.spawn(gBrowser.selectedBrowser, i, function(idx) {
- let head = content.document.getElementsByTagName("head")[0];
- let script = content.document.createElement("script");
- script.text = "fubar" + idx + ".bogus(6);";
- head.insertBefore(script, head.firstChild);
- });
- }
-
- await waitForMessages({
- webconsole: hud,
- messages: [{
- text: "fubar10 is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- }],
- });
-
- testLogEntry(outputNode, "fubar0 is not defined", "first message is pruned",
- false, true);
- findLogEntry("fubar1 is not defined");
- // Check if the sentinel entry is still there.
- findLogEntry("testing JS limits");
-
- Services.prefs.clearUserPref("devtools.hud.loglimit.exception");
-}
-
-var gCounter;
-
-async function testNetLimits() {
- Services.prefs.setIntPref("devtools.hud.loglimit.network", 10);
-
- hud.jsterm.clearOutput();
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("testing Net limits");
- });
-
- // Find the sentinel entry.
- await waitForMessages({
- webconsole: hud,
- messages: [{
- text: "testing Net limits",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- // Fill the log with network messages.
- gCounter = 0;
-}
-
-async function loadImage() {
- if (gCounter < 11) {
- await ContentTask.spawn(gBrowser.selectedBrowser, gCounter, function(counter) {
- let body = content.document.getElementsByTagName("body")[0];
- let gImage = content.document.createElement("img");
- gImage.src = "test-image.png?_fubar=" + counter;
- body.insertBefore(gImage, body.firstChild);
- return new Promise(function(resolve) {
- gImage.addEventListener("load", resolve, {once: true});
- });
- });
- gCounter++;
- loadImage();
- return true;
- }
-
- is(gCounter, 11, "loaded 11 files");
-
- await waitForMessages({
- webconsole: hud,
- messages: [{
- text: "test-image.png",
- url: "test-image.png?_fubar=10",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-
- let msgs = outputNode.querySelectorAll(".message[category=network]");
- is(msgs.length, 10, "number of network messages");
- isnot(msgs[0].url.indexOf("fubar=1"), -1, "first network message");
- isnot(msgs[1].url.indexOf("fubar=2"), -1, "second network message");
- findLogEntry("testing Net limits");
-
- Services.prefs.clearUserPref("devtools.hud.loglimit.network");
-}
-
-async function testCssLimits() {
- Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", 10);
-
- hud.jsterm.clearOutput();
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("testing CSS limits");
- });
-
- // Find the sentinel entry.
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "testing CSS limits",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-async function testCssLimits2() {
- // Fill the log with CSS errors.
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- let body = content.document.getElementsByTagName("body")[0];
- for (let i = 0; i < 11; i++) {
- let div = content.document.createElement("div");
- div.setAttribute("style", "-moz-foobar" + i + ": 42;");
- body.insertBefore(div, body.firstChild);
- }
- });
-
- await waitForMessages({
- webconsole: hud,
- messages: [{
- text: "-moz-foobar10",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- }],
- });
-
- testLogEntry(outputNode, "Unknown property \u2018-moz-foobar0\u2019",
- "first message is pruned", false, true);
- findLogEntry("Unknown property \u2018-moz-foobar1\u2019");
- // Check if the sentinel entry is still there.
- findLogEntry("testing CSS limits");
-
- Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_646025_console_file_location.js
+++ /dev/null
@@ -1,57 +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/ */
-
-// Tests that console logging methods display the method location along with
-// the output in the console.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console file location " +
- "display test";
-const TEST_URI2 = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/" +
- "test-bug-646025-console-file-location.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "message for level log",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- source: { url: "test-file-location.js", line: 8 },
- },
- {
- text: "message for level info",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_INFO,
- source: { url: "test-file-location.js", line: 9 },
- },
- {
- text: "message for level warn",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_WARNING,
- source: { url: "test-file-location.js", line: 10 },
- },
- {
- text: "message for level error",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- source: { url: "test-file-location.js", line: 11 },
- },
- {
- text: "message for level debug",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- source: { url: "test-file-location.js", line: 12 },
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_651501_document_body_autocomplete.js
+++ /dev/null
@@ -1,102 +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/ */
-
-// Tests that document.body autocompletes in the web console.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console autocompletion " +
- "bug in document.body";
-
-var gHUD;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- gHUD = yield openConsole();
-
- yield consoleOpened();
- yield autocompletePopupHidden();
- let view = yield testPropertyPanel();
- yield onVariablesViewReady(view);
-
- gHUD = null;
-});
-
-function consoleOpened() {
- let deferred = defer();
-
- let jsterm = gHUD.jsterm;
- let popup = jsterm.autocompletePopup;
-
- ok(!popup.isOpen, "popup is not open");
-
- popup.once("popup-opened", () => {
- ok(popup.isOpen, "popup is open");
-
- is(popup.itemCount, jsterm._autocompleteCache.length,
- "popup.itemCount is correct");
- isnot(jsterm._autocompleteCache.indexOf("addEventListener"), -1,
- "addEventListener is in the list of suggestions");
- isnot(jsterm._autocompleteCache.indexOf("bgColor"), -1,
- "bgColor is in the list of suggestions");
- isnot(jsterm._autocompleteCache.indexOf("ATTRIBUTE_NODE"), -1,
- "ATTRIBUTE_NODE is in the list of suggestions");
-
- popup.once("popup-closed", () => {
- deferred.resolve();
- });
- EventUtils.synthesizeKey("KEY_Escape");
- });
-
- jsterm.setInputValue("document.body");
- EventUtils.sendString(".");
-
- return deferred.promise;
-}
-
-function autocompletePopupHidden() {
- let deferred = defer();
-
- let jsterm = gHUD.jsterm;
- let popup = jsterm.autocompletePopup;
- let completeNode = jsterm.completeNode;
-
- ok(!popup.isOpen, "popup is not open");
-
- jsterm.once("autocomplete-updated", function () {
- is(completeNode.value, testStr + "dy", "autocomplete shows document.body");
- deferred.resolve();
- });
-
- let inputStr = "document.b";
- jsterm.setInputValue(inputStr);
- EventUtils.sendString("o");
- let testStr = inputStr.replace(/./g, " ") + " ";
-
- return deferred.promise;
-}
-
-function testPropertyPanel() {
- let deferred = defer();
-
- let jsterm = gHUD.jsterm;
- jsterm.clearOutput();
- jsterm.execute("document", (msg) => {
- jsterm.once("variablesview-fetched", (view) => {
- deferred.resolve(view);
- });
- let anchor = msg.querySelector(".message-body a");
- EventUtils.synthesizeMouse(anchor, 2, 2, {}, gHUD.iframeWindow);
- });
-
- return deferred.promise;
-}
-
-function onVariablesViewReady(view) {
- return findVariableViewProperties(view, [
- { name: "body", value: "<body>" },
- ], { webconsole: gHUD });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_653531_highlighter_console_helper.js
+++ /dev/null
@@ -1,108 +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/ */
-
-// Tests that the $0 console helper works as intended.
-
-"use strict";
-
-var inspector, h1, outputNode;
-
-function createDocument() {
- let doc = content.document;
- let div = doc.createElement("div");
- h1 = doc.createElement("h1");
- let p1 = doc.createElement("p");
- let p2 = doc.createElement("p");
- let div2 = doc.createElement("div");
- let p3 = doc.createElement("p");
- doc.title = "Inspector Tree Selection Test";
- h1.textContent = "Inspector Tree Selection Test";
- p1.textContent = "This is some example text";
- p2.textContent = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
- "elit, sed do eiusmod tempor incididunt ut labore et dolore magna " +
- "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
- "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
- "dolor in reprehenderit in voluptate velit esse cillum dolore eu " +
- "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " +
- "proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
- p3.textContent = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
- "elit, sed do eiusmod tempor incididunt ut labore et dolore magna " +
- "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
- "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
- "dolor in reprehenderit in voluptate velit esse cillum dolore eu " +
- "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " +
- "proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
- div.appendChild(h1);
- div.appendChild(p1);
- div.appendChild(p2);
- div2.appendChild(p3);
- doc.body.appendChild(div);
- doc.body.appendChild(div2);
- setupHighlighterTests();
-}
-
-function setupHighlighterTests() {
- ok(h1, "we have the header node");
- openInspector().then(runSelectionTests);
-}
-
-var runSelectionTests = Task.async(function* (aInspector) {
- inspector = aInspector;
-
- let onPickerStarted = inspector.toolbox.once("picker-started");
- inspector.toolbox.highlighterUtils.startPicker();
- yield onPickerStarted;
-
- info("Picker mode started, now clicking on H1 to select that node");
- h1.scrollIntoView();
- let onPickerStopped = inspector.toolbox.once("picker-stopped");
- let onInspectorUpdated = inspector.once("inspector-updated");
- EventUtils.synthesizeMouseAtCenter(h1, {}, content);
- yield onPickerStopped;
- yield onInspectorUpdated;
-
- info("Picker mode stopped, H1 selected, now switching to the console");
- let hud = yield openConsole(gBrowser.selectedTab);
-
- performWebConsoleTests(hud);
-});
-
-function performWebConsoleTests(hud) {
- let jsterm = hud.jsterm;
- outputNode = hud.outputNode;
-
- jsterm.clearOutput();
- jsterm.execute("$0", onNodeOutput);
-
- function onNodeOutput(node) {
- isnot(node.textContent.indexOf("<h1>"), -1, "correct output for $0");
-
- jsterm.clearOutput();
- jsterm.execute("$0.textContent = 'bug653531'", onNodeUpdate);
- }
-
- function onNodeUpdate(node) {
- isnot(node.textContent.indexOf("bug653531"), -1,
- "correct output for $0.textContent");
- is(inspector.selection.node.textContent, "bug653531",
- "node successfully updated");
-
- inspector = h1 = outputNode = null;
- gBrowser.removeCurrentTab();
- finishTest();
- }
-}
-
-function test() {
- waitForExplicitFinish();
-
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- gBrowser.selectedBrowser.addEventListener("load", function () {
- waitForFocus(createDocument, content);
- }, {capture: true, once: true});
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser,
- "data:text/html;charset=utf-8,test for highlighter helper in web console");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_658368_time_methods.js
+++ /dev/null
@@ -1,67 +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/ */
-
-// Tests that the Console API implements the time() and timeEnd() methods.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-658368-time-methods.html";
-
-const TEST_URI2 = "data:text/html;charset=utf-8,<script>" +
- "console.timeEnd('bTimer');</script>";
-
-const TEST_URI3 = "data:text/html;charset=utf-8,<script>" +
- "console.time('bTimer');</script>";
-
-const TEST_URI4 = "data:text/html;charset=utf-8," +
- "<script>console.timeEnd('bTimer');</script>";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud1 = yield openConsole();
-
- yield waitForMessages({
- webconsole: hud1,
- messages: [{
- name: "aTimer started",
- consoleTime: "aTimer",
- }, {
- name: "aTimer end",
- consoleTimeEnd: "aTimer",
- }],
- });
-
- // The next test makes sure that timers with the same name but in separate
- // tabs, do not contain the same value.
- let { browser } = yield loadTab(TEST_URI2);
- let hud2 = yield openConsole();
-
- testLogEntry(hud2.outputNode, "bTimer: timer started",
- "bTimer was not started", false, true);
-
- // The next test makes sure that timers with the same name but in separate
- // pages, do not contain the same value.
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI3);
-
- yield waitForMessages({
- webconsole: hud2,
- messages: [{
- name: "bTimer started",
- consoleTime: "bTimer",
- }],
- });
-
- hud2.jsterm.clearOutput();
-
- // Now the following console.timeEnd() call shouldn't display anything,
- // if the timers in different pages are not related.
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI4);
- yield loadBrowser(browser);
-
- testLogEntry(hud2.outputNode, "bTimer: timer started",
- "bTimer was not started", false, true);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_659907_console_dir.js
+++ /dev/null
@@ -1,36 +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/ */
-
-// Tests that console.dir works as intended.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 659907: Expand console object with a dir method";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- hud.jsterm.execute("console.dir(document)");
-
- let varView = yield hud.jsterm.once("variablesview-fetched");
-
- yield findVariableViewProperties(varView, [
- {
- name: "__proto__.__proto__.querySelectorAll",
- value: "querySelectorAll()"
- },
- {
- name: "location",
- value: /Location \u2192 data:Web/
- },
- {
- name: "__proto__.write",
- value: "write()"
- },
- ], { webconsole: hud });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_660806_history_nav.js
+++ /dev/null
@@ -1,54 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>bug 660806 - history " +
- "navigation must not show the autocomplete popup";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield consoleOpened(hud);
-});
-
-function consoleOpened(HUD) {
- let deferred = defer();
-
- let jsterm = HUD.jsterm;
- let popup = jsterm.autocompletePopup;
- let onShown = function () {
- ok(false, "popup shown");
- };
-
- jsterm.execute(`window.foobarBug660806 = {
- 'location': 'value0',
- 'locationbar': 'value1'
- }`);
-
- popup.on("popup-opened", onShown);
-
- ok(!popup.isOpen, "popup is not open");
-
- ok(!jsterm.lastInputValue, "no lastInputValue");
- jsterm.setInputValue("window.foobarBug660806.location");
- is(jsterm.lastInputValue, "window.foobarBug660806.location",
- "lastInputValue is correct");
-
- EventUtils.synthesizeKey("KEY_Enter");
- EventUtils.synthesizeKey("KEY_ArrowUp");
-
- is(jsterm.lastInputValue, "window.foobarBug660806.location",
- "lastInputValue is correct, again");
-
- executeSoon(function () {
- ok(!popup.isOpen, "popup is not open");
- popup.off("popup-opened", onShown);
- executeSoon(deferred.resolve);
- });
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_664131_console_group.js
+++ /dev/null
@@ -1,79 +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/ */
-
-// Tests that console.group/groupEnd works as intended.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 664131: Expand console object with group methods";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- let jsterm = hud.jsterm;
-
- hud.jsterm.clearOutput();
-
- yield jsterm.execute("console.group('bug664131a')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bug664131a",
- consoleGroup: 1,
- }],
- });
-
- yield jsterm.execute("console.log('bug664131a-inside')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bug664131a-inside",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- groupDepth: 1,
- }],
- });
-
- yield jsterm.execute('console.groupEnd()');
- yield jsterm.execute('console.log("bug664131-outside")');
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bug664131-outside",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- groupDepth: 0,
- }],
- });
-
- yield jsterm.execute('console.groupCollapsed("bug664131b")');
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bug664131b",
- consoleGroup: 1,
- }],
- });
-
- // Test that clearing the console removes the indentation.
- hud.jsterm.clearOutput();
- yield jsterm.execute('console.log("bug664131-cleared")');
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "bug664131-cleared",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- groupDepth: 0,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_686937_autocomplete_JSTerm_helpers.js
+++ /dev/null
@@ -1,75 +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/ */
-
-// Tests that the autocompletion results contain the names of JSTerm helpers.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test JSTerm Helpers " +
- "autocomplete";
-
-var jsterm;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- jsterm = hud.jsterm;
- let input = jsterm.inputNode;
- let popup = jsterm.autocompletePopup;
-
- // Test if 'i' gives 'inspect'
- input.value = "i";
- input.setSelectionRange(1, 1);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- let newItems = popup.getItems().map(function (e) {
- return e.label;
- });
- ok(newItems.indexOf("inspect") > -1,
- "autocomplete results contain helper 'inspect'");
-
- // Test if 'window.' does not give 'inspect'.
- input.value = "window.";
- input.setSelectionRange(7, 7);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- newItems = popup.getItems().map(function (e) {
- return e.label;
- });
- is(newItems.indexOf("inspect"), -1,
- "autocomplete results do not contain helper 'inspect'");
-
- // Test if 'dump(i' gives 'inspect'
- input.value = "dump(i";
- input.setSelectionRange(6, 6);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- newItems = popup.getItems().map(function (e) {
- return e.label;
- });
- ok(newItems.indexOf("inspect") > -1,
- "autocomplete results contain helper 'inspect'");
-
- // Test if 'window.dump(i' gives 'inspect'
- input.value = "window.dump(i";
- input.setSelectionRange(13, 13);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- newItems = popup.getItems().map(function (e) {
- return e.label;
- });
- ok(newItems.indexOf("inspect") > -1,
- "autocomplete results contain helper 'inspect'");
-
- jsterm = null;
-});
-
-function complete(type) {
- let updated = jsterm.once("autocomplete-updated");
- jsterm.complete(type);
- return updated;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_704295.js
+++ /dev/null
@@ -1,40 +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/ */
-
-// Tests for bug 704295
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- testCompletion(hud);
-});
-
-function testCompletion(hud) {
- let jsterm = hud.jsterm;
- let input = jsterm.inputNode;
-
- // Test typing 'var d = 5;' and press RETURN
- jsterm.setInputValue("var d = ");
- EventUtils.sendString("5;");
- is(input.value, "var d = 5;", "var d = 5;");
- is(jsterm.completeNode.value, "", "no completion");
- EventUtils.synthesizeKey("KEY_Enter");
- is(jsterm.completeNode.value, "", "clear completion on execute()");
-
- // Test typing 'var a = d' and press RETURN
- jsterm.setInputValue("var a = ");
- EventUtils.sendString("d");
- is(input.value, "var a = d", "var a = d");
- is(jsterm.completeNode.value, "", "no completion");
- EventUtils.synthesizeKey("KEY_Enter");
- is(jsterm.completeNode.value, "", "clear completion on execute()");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js
+++ /dev/null
@@ -1,35 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/browser/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let jsterm = hud.jsterm;
- let input = jsterm.inputNode;
-
- is(input.getAttribute("focused"), "true", "input has focus");
- EventUtils.synthesizeKey("KEY_Tab");
- is(input.getAttribute("focused"), "", "focus moved away");
-
- // Test user changed something
- input.focus();
- EventUtils.sendString("a");
- EventUtils.synthesizeKey("KEY_Tab");
- is(input.getAttribute("focused"), "true", "input is still focused");
-
- // Test non empty input but not changed since last focus
- input.blur();
- input.focus();
- EventUtils.synthesizeKey("KEY_ArrowRight");
- EventUtils.synthesizeKey("KEY_Tab");
- is(input.getAttribute("focused"), "", "input moved away");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_737873_mixedcontent.js
+++ /dev/null
@@ -1,63 +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/ */
-
-// Tests that the Web Console Mixed Content messages are displayed
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Web Console mixed content test";
-const TEST_HTTPS_URI = "https://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-bug-737873-mixedcontent.html";
-const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Web/Security/" +
- "Mixed_content";
-
-registerCleanupFunction(function*() {
- Services.prefs.clearUserPref("security.mixed_content.block_display_content");
- Services.prefs.clearUserPref("security.mixed_content.block_active_content");
-});
-
-add_task(function* () {
- Services.prefs.setBoolPref("security.mixed_content.block_display_content",
- false);
- Services.prefs.setBoolPref("security.mixed_content.block_active_content",
- false);
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield testMixedContent(hud);
-});
-
-var testMixedContent = Task.async(function* (hud) {
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_HTTPS_URI);
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "example.com",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_WARNING,
- }],
- });
-
- let msg = [...results[0].matched][0];
- ok(msg, "page load logged");
- ok(msg.classList.contains("mixed-content"), ".mixed-content element");
-
- let link = msg.querySelector(".learn-more-link");
- ok(link, "mixed content link element");
- is(link.textContent, "[Mixed Content]", "link text is accurate");
-
- yield simulateMessageLinkClick(link, LEARN_MORE_URI);
-
- ok(!msg.classList.contains("filtered-by-type"), "message is not filtered");
-
- hud.setFilterState("netwarn", false);
-
- ok(msg.classList.contains("filtered-by-type"), "message is filtered");
-
- hud.setFilterState("netwarn", true);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_752559_ineffective_iframe_sandbox_warning.js
+++ /dev/null
@@ -1,83 +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/ */
-
-// Tests that warnings about ineffective iframe sandboxing are logged to the
-// web console when necessary (and not otherwise).
-
-"use strict";
-
-requestLongerTimeout(2);
-
-const TEST_URI_WARNING = "http://example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning0.html";
-const TEST_URI_NOWARNING = [
- "http://example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning1.html",
- "http://example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning2.html",
- "http://example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning3.html",
- "http://example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning4.html",
- "http://example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning5.html"
-];
-
-const INEFFECTIVE_IFRAME_SANDBOXING_MSG = "An iframe which has both " +
- "allow-scripts and allow-same-origin for its sandbox attribute can remove " +
- "its sandboxing.";
-const SENTINEL_MSG = "testing ineffective sandboxing message";
-
-add_task(function* () {
- yield testYesWarning();
-
- for (let id = 0; id < TEST_URI_NOWARNING.length; id++) {
- yield testNoWarning(id);
- }
-});
-
-function* testYesWarning() {
- yield loadTab(TEST_URI_WARNING);
- let hud = yield openConsole();
-
- ContentTask.spawn(gBrowser.selectedBrowser, SENTINEL_MSG, function* (msg) {
- content.console.log(msg);
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Ineffective iframe sandboxing warning displayed successfully",
- text: INEFFECTIVE_IFRAME_SANDBOXING_MSG,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING
- },
- {
- text: SENTINEL_MSG,
- severity: SEVERITY_LOG
- }
- ]
- });
-
- let msgs = hud.outputNode.querySelectorAll(".message[category=security]");
- is(msgs.length, 1, "one security message");
-}
-
-function* testNoWarning(id) {
- yield loadTab(TEST_URI_NOWARNING[id]);
- let hud = yield openConsole();
-
- ContentTask.spawn(gBrowser.selectedBrowser, SENTINEL_MSG, function* (msg) {
- content.console.log(msg);
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: SENTINEL_MSG,
- severity: SEVERITY_LOG
- }
- ]
- });
-
- let msgs = hud.outputNode.querySelectorAll(".message[category=security]");
- is(msgs.length, 0, "no security messages (case " + id + ")");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_762593_insecure_passwords_about_blank_web_console_warning.js
+++ /dev/null
@@ -1,32 +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/ */
-
-// Tests that errors about insecure passwords are logged to the web console.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-762593-insecure-passwords-about-blank-web-console-warning.html";
-const INSECURE_PASSWORD_MSG = "Password fields present on an insecure " +
- "(http://) iframe. This is a security risk that allows user login " +
- "credentials to be stolen.";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Insecure password error displayed successfully",
- text: INSECURE_PASSWORD_MSG,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING
- },
- ],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_762593_insecure_passwords_web_console_warning.js
+++ /dev/null
@@ -1,62 +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/ */
-
- // Tests that errors about insecure passwords are logged to the web console.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-762593-insecure-passwords-web-" +
- "console-warning.html";
-const INSECURE_PASSWORD_MSG = "Password fields present on an insecure " +
- "(http://) page. This is a security risk that allows user " +
- "login credentials to be stolen.";
-const INSECURE_FORM_ACTION_MSG = "Password fields present in a form with an " +
- "insecure (http://) form action. This is a security risk " +
- "that allows user login credentials to be stolen.";
-const INSECURE_IFRAME_MSG = "Password fields present on an insecure " +
- "(http://) iframe. This is a security risk that allows " +
- "user login credentials to be stolen.";
-const INSECURE_PASSWORDS_URI = "https://developer.mozilla.org/docs/Web/" +
- "Security/Insecure_passwords" + DOCS_GA_PARAMS;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let result = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Insecure password error displayed successfully",
- text: INSECURE_PASSWORD_MSG,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING
- },
- {
- name: "Insecure iframe error displayed successfully",
- text: INSECURE_IFRAME_MSG,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING
- },
- {
- name: "Insecure form action error displayed successfully",
- text: INSECURE_FORM_ACTION_MSG,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING
- },
- ],
- });
-
- yield testClickOpenNewTab(hud, result);
-});
-
-function testClickOpenNewTab(hud, [result]) {
- let msg = [...result.matched][0];
- let warningNode = msg.querySelector(".learn-more-link");
- ok(warningNode, "learn more link");
- return simulateMessageLinkClick(warningNode, INSECURE_PASSWORDS_URI);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_764572_output_open_url.js
+++ /dev/null
@@ -1,141 +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/ */
-
-// This is a test for the Open URL context menu item
-// that is shown for network requests
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-const COMMAND_NAME = "consoleCmd_openURL";
-const CONTEXT_MENU_ID = "#menu_openURL";
-
-var HUD = null, outputNode = null, contextMenu = null;
-
-add_task(function* () {
- Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", true);
-
- yield loadTab(TEST_URI);
- HUD = yield openConsole();
-
- let results = yield consoleOpened();
- yield onConsoleMessage(results);
-
- let results2 = yield testOnNetActivity();
- let msg = yield onNetworkMessage(results2);
-
- yield testOnNetActivityContextMenu(msg);
-
- Services.prefs.clearUserPref("devtools.webconsole.filter.networkinfo");
-
- HUD = null;
- outputNode = null;
- contextMenu = null;
-});
-
-function consoleOpened() {
- outputNode = HUD.outputNode;
- contextMenu = HUD.iframeWindow.document.getElementById("output-contextmenu");
-
- HUD.jsterm.clearOutput();
-
- content.console.log("bug 764572");
-
- return waitForMessages({
- webconsole: HUD,
- messages: [{
- text: "bug 764572",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-function onConsoleMessage(results) {
- outputNode.focus();
- outputNode.selectedItem = [...results[0].matched][0];
-
- // Check if the command is disabled non-network messages.
- goUpdateCommand(COMMAND_NAME);
- let controller = top.document.commandDispatcher
- .getControllerForCommand(COMMAND_NAME);
-
- let isDisabled = !controller || !controller.isCommandEnabled(COMMAND_NAME);
- ok(isDisabled, COMMAND_NAME + " should be disabled.");
-
- return waitForContextMenu(contextMenu, outputNode.selectedItem, () => {
- let isHidden = contextMenu.querySelector(CONTEXT_MENU_ID).hidden;
- ok(isHidden, CONTEXT_MENU_ID + " should be hidden.");
- });
-}
-
-function testOnNetActivity() {
- HUD.jsterm.clearOutput();
-
- // Reload the url to show net activity in console.
- content.location.reload();
-
- return waitForMessages({
- webconsole: HUD,
- messages: [{
- text: "test-console.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-function onNetworkMessage(results) {
- let deferred = defer();
-
- outputNode.focus();
- let msg = [...results[0].matched][0];
- ok(msg, "network message");
- HUD.ui.output.selectMessage(msg);
-
- let currentTab = gBrowser.selectedTab;
- let newTab = null;
-
- gBrowser.tabContainer.addEventListener("TabOpen", function (evt) {
- newTab = evt.target;
- newTab.linkedBrowser.addEventListener("load", onTabLoaded, true);
- }, {capture: true, once: true});
-
- function onTabLoaded() {
- newTab.linkedBrowser.removeEventListener("load", onTabLoaded, true);
- gBrowser.removeTab(newTab);
- gBrowser.selectedTab = currentTab;
- executeSoon(deferred.resolve.bind(null, msg));
- }
-
- // Check if the command is enabled for a network message.
- goUpdateCommand(COMMAND_NAME);
- let controller = top.document.commandDispatcher
- .getControllerForCommand(COMMAND_NAME);
- ok(controller.isCommandEnabled(COMMAND_NAME),
- COMMAND_NAME + " should be enabled.");
-
- // Try to open the URL.
- goDoCommand(COMMAND_NAME);
-
- return deferred.promise;
-}
-
-function testOnNetActivityContextMenu(msg) {
- let deferred = defer();
-
- outputNode.focus();
- HUD.ui.output.selectMessage(msg);
-
- info("net activity context menu");
-
- waitForContextMenu(contextMenu, msg, () => {
- let isShown = !contextMenu.querySelector(CONTEXT_MENU_ID).hidden;
- ok(isShown, CONTEXT_MENU_ID + " should be shown.");
- }).then(deferred.resolve);
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_766001_JS_Console_in_Debugger.js
+++ /dev/null
@@ -1,93 +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 that message source links for js errors and console API calls open in
-// the jsdebugger when clicked.
-
-"use strict";
-
-// There are shutdown issues for which multiple rejections are left uncaught.
-// See bug 1018184 for resolving these issues.
-const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
-PromiseTestUtils.whitelistRejectionsGlobally(/this\.worker is null/);
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/test" +
- "/test-bug-766001-js-console-links.html";
-
-// Force the new debugger UI, in case this gets uplifted with the old
-// debugger still turned on
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", true);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-function test() {
- let hud;
-
- requestLongerTimeout(2);
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
-
- let {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
-
- let [exceptionRule, consoleRule] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "document.bar",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- {
- text: "Blah Blah",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let exceptionMsg = [...exceptionRule.matched][0];
- let consoleMsg = [...consoleRule.matched][0];
- let nodes = [exceptionMsg.querySelector(".message-location > .frame-link"),
- consoleMsg.querySelector(".message-location > .frame-link")];
- ok(nodes[0], ".location node for the exception message");
- ok(nodes[1], ".location node for the console message");
-
- for (let i = 0; i < nodes.length; i++) {
- yield checkClickOnNode(i, nodes[i]);
- yield gDevTools.showToolbox(hud.target, "webconsole");
- }
-
- // check again the first node.
- yield checkClickOnNode(0, nodes[0]);
- }
-
- function* checkClickOnNode(index, node) {
- info("checking click on node index " + index);
-
- let url = node.getAttribute("data-url");
- ok(url, "source url found for index " + index);
-
- let line = node.getAttribute("data-line");
- ok(line, "found source line for index " + index);
-
- executeSoon(() => {
- EventUtils.sendMouseEvent({ type: "click" }, node.querySelector(".frame-link-filename"));
- });
-
- yield hud.ui.once("source-in-debugger-opened");
-
- let toolbox = yield gDevTools.getToolbox(hud.target);
- let dbg = toolbox.getPanel("jsdebugger");
- is(dbg._selectors.getSelectedSource(dbg._getState()).get("url"),
- url,
- "expected source url");
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_770099_violation.js
+++ /dev/null
@@ -1,34 +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/ */
-
-// Tests that the Web Console CSP messages are displayed
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Web Console CSP violation test";
-const TEST_VIOLATION = "https://example.com/browser/devtools/client/" +
- "webconsole/old/test/test_bug_770099_violation.html";
-const CSP_VIOLATION_MSG = "Content Security Policy: The page\u2019s settings " +
- "blocked the loading of a resource at " +
- "http://some.example.com/test.png (\u201cdefault-src\u201d).";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_VIOLATION);
- yield loaded;
-
- yield waitForSuccess({
- name: "CSP policy URI warning displayed successfully",
- validator: function () {
- return hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1;
- }
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
+++ /dev/null
@@ -1,138 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/test" +
- "/test-bug-782653-css-errors.html";
-
-var nodes, hud, StyleEditorUI;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
-
- let styleEditor = yield testViewSource();
- yield onStyleEditorReady(styleEditor);
-
- nodes = hud = StyleEditorUI = null;
-});
-
-function testViewSource() {
- let deferred = defer();
-
- waitForMessages({
- webconsole: hud,
- messages: [{
- text: "\u2018font-weight\u2019",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- },
- {
- text: "\u2018color\u2019",
- category: CATEGORY_CSS,
- severity: SEVERITY_WARNING,
- }],
- }).then(([error1Rule, error2Rule]) => {
- let error1Msg = [...error1Rule.matched][0];
- let error2Msg = [...error2Rule.matched][0];
- nodes = [error1Msg.querySelector(".message-location .frame-link"),
- error2Msg.querySelector(".message-location .frame-link")];
- ok(nodes[0], ".frame-link node for the first error");
- ok(nodes[1], ".frame-link node for the second error");
-
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
- toolbox.once("styleeditor-selected", panel => {
- StyleEditorUI = panel.UI;
- deferred.resolve(panel);
- });
-
- EventUtils.sendMouseEvent({ type: "click" }, nodes[0].querySelector(".frame-link-filename"));
- });
-
- return deferred.promise;
-}
-
-function onStyleEditorReady(panel) {
- let deferred = defer();
-
- let win = panel.panelWindow;
- ok(win, "Style Editor Window is defined");
- ok(StyleEditorUI, "Style Editor UI is defined");
-
- function fireEvent(toolbox, href, line) {
- toolbox.once("styleeditor-selected", function () {
- checkStyleEditorForSheetAndLine(href, line - 1).then(deferred.resolve);
- });
-
- EventUtils.sendMouseEvent({ type: "click" }, nodes[1].querySelector(".frame-link-filename"));
- }
-
- waitForFocus(function () {
- info("style editor window focused");
-
- let href = nodes[0].getAttribute("data-url");
- let line = nodes[0].getAttribute("data-line");
- ok(line, "found source line");
-
- checkStyleEditorForSheetAndLine(href, line - 1).then(function () {
- info("first check done");
-
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
-
- href = nodes[1].getAttribute("data-url");
- line = nodes[1].getAttribute("data-line");
- ok(line, "found source line");
-
- toolbox.selectTool("webconsole").then(function () {
- info("webconsole selected");
- fireEvent(toolbox, href, line);
- });
- });
- }, win);
-
- return deferred.promise;
-}
-
-function checkStyleEditorForSheetAndLine(href, line) {
- let foundEditor = null;
- for (let editor of StyleEditorUI.editors) {
- if (editor.styleSheet.href == href) {
- foundEditor = editor;
- break;
- }
- }
-
- ok(foundEditor, "found style editor for " + href);
- return performLineCheck(foundEditor, line);
-}
-
-function performLineCheck(editor, line) {
- let deferred = defer();
-
- function checkForCorrectState() {
- is(editor.sourceEditor.getCursor().line, line,
- "correct line is selected");
- is(StyleEditorUI.selectedStyleSheetIndex, editor.styleSheet.styleSheetIndex,
- "correct stylesheet is selected in the editor");
-
- executeSoon(deferred.resolve);
- }
-
- info("wait for source editor to load");
-
- // Get out of the styleeditor-selected event loop.
- executeSoon(() => {
- editor.getSourceEditor().then(() => {
- // Get out of the editor's source-editor-load event loop.
- executeSoon(checkForCorrectState);
- });
- });
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_804845_ctrl_key_nav.js
+++ /dev/null
@@ -1,227 +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 navigation of webconsole contents via ctrl-a, ctrl-e, ctrl-p, ctrl-n
-// see https://bugzilla.mozilla.org/show_bug.cgi?id=804845
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 804845 and bug 619598";
-
-var jsterm, inputNode;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield doTests(hud);
-
- jsterm = inputNode = null;
-});
-
-function* doTests(HUD) {
- jsterm = HUD.jsterm;
- inputNode = jsterm.inputNode;
- ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
- is(jsterm.inputNode.selectionStart, 0);
- is(jsterm.inputNode.selectionEnd, 0);
-
- testSingleLineInputNavNoHistory();
- testMultiLineInputNavNoHistory();
- yield testNavWithHistory();
-}
-
-function testSingleLineInputNavNoHistory() {
- // Single char input
- EventUtils.sendString("1");
- is(inputNode.selectionStart, 1, "caret location after single char input");
-
- // nav to start/end with ctrl-a and ctrl-e;
- EventUtils.synthesizeKey("a", {ctrlKey: true});
- is(inputNode.selectionStart, 0,
- "caret location after single char input and ctrl-a");
-
- EventUtils.synthesizeKey("e", {ctrlKey: true});
- is(inputNode.selectionStart, 1,
- "caret location after single char input and ctrl-e");
-
- // Second char input
- EventUtils.sendString("2");
- // nav to start/end with up/down keys; verify behaviour using ctrl-p/ctrl-n
- EventUtils.synthesizeKey("KEY_ArrowUp");
- is(inputNode.selectionStart, 0,
- "caret location after two char input and KEY_ArrowUp");
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(inputNode.selectionStart, 2,
- "caret location after two char input and KEY_ArrowDown");
-
- EventUtils.synthesizeKey("a", {ctrlKey: true});
- is(inputNode.selectionStart, 0,
- "move caret to beginning of 2 char input with ctrl-a");
- EventUtils.synthesizeKey("a", {ctrlKey: true});
- is(inputNode.selectionStart, 0,
- "no change of caret location on repeat ctrl-a");
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(inputNode.selectionStart, 0,
- "no change of caret location on ctrl-p from beginning of line");
-
- EventUtils.synthesizeKey("e", {ctrlKey: true});
- is(inputNode.selectionStart, 2,
- "move caret to end of 2 char input with ctrl-e");
- EventUtils.synthesizeKey("e", {ctrlKey: true});
- is(inputNode.selectionStart, 2,
- "no change of caret location on repeat ctrl-e");
- EventUtils.synthesizeKey("n", {ctrlKey: true});
- is(inputNode.selectionStart, 2,
- "no change of caret location on ctrl-n from end of line");
-
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(inputNode.selectionStart, 0, "ctrl-p moves to start of line");
-
- EventUtils.synthesizeKey("n", {ctrlKey: true});
- is(inputNode.selectionStart, 2, "ctrl-n moves to end of line");
-}
-
-function testMultiLineInputNavNoHistory() {
- let lineValues = ["one", "2", "something longer", "", "", "three!"];
- jsterm.setInputValue("");
- // simulate shift-return
- for (let i = 0; i < lineValues.length; i++) {
- jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]);
- EventUtils.synthesizeKey("KEY_Enter", {shiftKey: true});
- }
- let inputValue = jsterm.getInputValue();
- is(inputNode.selectionStart, inputNode.selectionEnd);
- is(inputNode.selectionStart, inputValue.length,
- "caret at end of multiline input");
-
- // possibility newline is represented by one ('\r', '\n') or two
- // ('\r\n') chars
- let newlineString = inputValue.match(/(\r\n?|\n\r?)$/)[0];
-
- // Ok, test navigating within the multi-line string!
- EventUtils.synthesizeKey("KEY_ArrowUp");
- let expectedStringAfterCarat = lineValues[5] + newlineString;
- is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
- "up arrow from end of multiline");
-
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(jsterm.getInputValue().slice(inputNode.selectionStart), "",
- "down arrow from within multiline");
-
- // navigate up through input lines
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
- "ctrl-p from end of multiline");
-
- for (let i = 4; i >= 0; i--) {
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- expectedStringAfterCarat = lineValues[i] + newlineString +
- expectedStringAfterCarat;
- is(jsterm.getInputValue().slice(inputNode.selectionStart),
- expectedStringAfterCarat, "ctrl-p from within line " + i +
- " of multiline input");
- }
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(inputNode.selectionStart, 0, "reached start of input");
- is(jsterm.getInputValue(), inputValue,
- "no change to multiline input on ctrl-p from beginning of multiline");
-
- // navigate to end of first line
- EventUtils.synthesizeKey("e", {ctrlKey: true});
- let caretPos = inputNode.selectionStart;
- let expectedStringBeforeCarat = lineValues[0];
- is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
- "ctrl-e into multiline input");
- EventUtils.synthesizeKey("e", {ctrlKey: true});
- is(inputNode.selectionStart, caretPos,
- "repeat ctrl-e doesn't change caret position in multiline input");
-
- // navigate down one line; ctrl-a to the beginning; ctrl-e to end
- for (let i = 1; i < lineValues.length; i++) {
- EventUtils.synthesizeKey("n", {ctrlKey: true});
- EventUtils.synthesizeKey("a", {ctrlKey: true});
- caretPos = inputNode.selectionStart;
- expectedStringBeforeCarat += newlineString;
- is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
- "ctrl-a to beginning of line " + (i + 1) + " in multiline input");
-
- EventUtils.synthesizeKey("e", {ctrlKey: true});
- caretPos = inputNode.selectionStart;
- expectedStringBeforeCarat += lineValues[i];
- is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
- "ctrl-e to end of line " + (i + 1) + "in multiline input");
- }
-}
-
-function* testNavWithHistory() {
- // NOTE: Tests does NOT currently define behaviour for ctrl-p/ctrl-n with
- // caret placed _within_ single line input
- let values = ['"single line input"',
- '"a longer single-line input to check caret repositioning"',
- ['"multi-line"', '"input"', '"here!"'].join("\n"),
- ];
- // submit to history
- for (let i = 0; i < values.length; i++) {
- jsterm.setInputValue(values[i]);
- yield jsterm.execute();
- }
- is(inputNode.selectionStart, 0, "caret location at start of empty line");
-
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(inputNode.selectionStart, values[values.length - 1].length,
- "caret location correct at end of last history input");
-
- // Navigate backwards history with ctrl-p
- for (let i = values.length - 1; i > 0; i--) {
- let match = values[i].match(/(\n)/g);
- if (match) {
- // multi-line inputs won't update from history unless caret at beginning
- EventUtils.synthesizeKey("a", {ctrlKey: true});
- for (let j = 0; j < match.length; j++) {
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- }
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- } else {
- // single-line inputs will update from history from end of line
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- }
- is(jsterm.getInputValue(), values[i - 1],
- "ctrl-p updates inputNode from backwards history values[" + i - 1 + "]");
- }
- let inputValue = jsterm.getInputValue();
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(inputNode.selectionStart, 0,
- "ctrl-p at beginning of history moves caret location to beginning " +
- "of line");
- is(jsterm.getInputValue(), inputValue,
- "no change to input value on ctrl-p from beginning of line");
-
- // Navigate forwards history with ctrl-n
- for (let i = 1; i < values.length; i++) {
- EventUtils.synthesizeKey("n", {ctrlKey: true});
- is(jsterm.getInputValue(), values[i],
- "ctrl-n updates inputNode from forwards history values[" + i + "]");
- is(inputNode.selectionStart, values[i].length,
- "caret location correct at end of history input for values[" + i + "]");
- }
- EventUtils.synthesizeKey("n", {ctrlKey: true});
- ok(!jsterm.getInputValue(), "ctrl-n at end of history updates to empty input");
-
- // Simulate editing multi-line
- inputValue = "one\nlinebreak";
- jsterm.setInputValue(inputValue);
-
- // Attempt nav within input
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(jsterm.getInputValue(), inputValue,
- "ctrl-p from end of multi-line does not trigger history");
-
- EventUtils.synthesizeKey("a", {ctrlKey: true});
- EventUtils.synthesizeKey("p", {ctrlKey: true});
- is(jsterm.getInputValue(), values[values.length - 1],
- "ctrl-p from start of multi-line triggers history");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_817834_add_edited_input_to_history.js
+++ /dev/null
@@ -1,57 +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 that user input that is not submitted in the command line input is not
-// lost after navigating in history.
-// See https://bugzilla.mozilla.org/show_bug.cgi?id=817834
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 817834";
-
-add_task(async function () {
- await loadTab(TEST_URI);
-
- let hud = await openConsole();
-
- await testEditedInputHistory(hud);
-});
-
-async function testEditedInputHistory(HUD) {
- let jsterm = HUD.jsterm;
- let inputNode = jsterm.inputNode;
- ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
- is(inputNode.selectionStart, 0);
- is(inputNode.selectionEnd, 0);
-
- jsterm.setInputValue('"first item"');
- EventUtils.synthesizeKey("KEY_ArrowUp");
- is(jsterm.getInputValue(), '"first item"', "null test history up");
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(jsterm.getInputValue(), '"first item"', "null test history down");
-
- await jsterm.execute();
- is(jsterm.getInputValue(), "", "cleared input line after submit");
-
- jsterm.setInputValue('"editing input 1"');
- EventUtils.synthesizeKey("KEY_ArrowUp");
- is(jsterm.getInputValue(), '"first item"', "test history up");
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(jsterm.getInputValue(), '"editing input 1"',
- "test history down restores in-progress input");
-
- jsterm.setInputValue('"second item"');
- await jsterm.execute();
- jsterm.setInputValue('"editing input 2"');
- EventUtils.synthesizeKey("KEY_ArrowUp");
- is(jsterm.getInputValue(), '"second item"', "test history up");
- EventUtils.synthesizeKey("KEY_ArrowUp");
- is(jsterm.getInputValue(), '"first item"', "test history up");
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(jsterm.getInputValue(), '"second item"', "test history down");
- EventUtils.synthesizeKey("KEY_ArrowDown");
- is(jsterm.getInputValue(), '"editing input 2"',
- "test history down restores new in-progress input again");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_837351_securityerrors.js
+++ /dev/null
@@ -1,42 +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/ */
-
-"use strict";
-
-const TEST_URI = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-837351-security-errors.html";
-
-add_task(function* () {
- yield pushPrefEnv();
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let button = hud.ui.rootElement.querySelector(".webconsole-filter-button[category=\"security\"]");
- ok(button, "Found security button in the web console");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Logged blocking mixed active content",
- text: "Blocked loading mixed active content \u201chttp://example.com/\u201d",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_ERROR
- },
- ],
- });
-});
-
-function pushPrefEnv() {
- let deferred = defer();
- let options = {
- set: [["security.mixed_content.block_active_content", true]]
- };
- SpecialPowers.pushPrefEnv(options, deferred.resolve);
- return deferred.promise;
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_bug_922212_console_dirxml.js
+++ /dev/null
@@ -1,48 +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/ */
-
-// Tests that console.dirxml works as intended.
-
-"use strict";
-
-const TEST_URI = `data:text/html;charset=utf-8,Web Console test for bug 922212:
- Add console.dirxml`;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- // Should work like console.log(window)
- hud.jsterm.execute("console.dirxml(window)");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.dirxml(window) output:",
- text: /Window \u2192/,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- hud.jsterm.clearOutput();
-
- hud.jsterm.execute("console.dirxml(document.body)");
-
- // Should work like console.log(document.body);
- [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.dirxml(document.body) output:",
- text: "<body>",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
- let msg = [...result.matched][0];
- yield checkLinkToInspector(true, msg);
-});
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_cached_autocomplete.js
+++ /dev/null
@@ -1,114 +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/ */
-
-// Tests that the cached autocomplete results are used when the new
-// user input is a subset of the existing completion results.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test cached autocompletion " +
- "results";
-
-var jsterm;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- jsterm = hud.jsterm;
- let input = jsterm.inputNode;
- let popup = jsterm.autocompletePopup;
-
- // Test if 'doc' gives 'document'
- input.value = "doc";
- input.setSelectionRange(3, 3);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- is(input.value, "doc", "'docu' completion (input.value)");
- is(jsterm.completeNode.value, " ument", "'docu' completion (completeNode)");
-
- // Test typing 'window.'.
- input.value = "window.";
- input.setSelectionRange(7, 7);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- ok(popup.getItems().length > 0, "'window.' gave a list of suggestions");
-
- yield jsterm.execute("window.docfoobar = true");
-
- // Test typing 'window.doc'.
- input.value = "window.doc";
- input.setSelectionRange(10, 10);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- let newItems = popup.getItems();
- ok(newItems.every(function (item) {
- return item.label != "docfoobar";
- }), "autocomplete cached results do not contain docfoobar. list has not " +
- "been updated");
-
- // Test that backspace does not cause a request to the server
- input.value = "window.do";
- input.setSelectionRange(9, 9);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- newItems = popup.getItems();
- ok(newItems.every(function (item) {
- return item.label != "docfoobar";
- }), "autocomplete cached results do not contain docfoobar. list has not " +
- "been updated");
-
- yield jsterm.execute("delete window.docfoobar");
-
- // Test if 'window.getC' gives 'getComputedStyle'
- input.value = "window.";
- input.setSelectionRange(7, 7);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- input.value = "window.getC";
- input.setSelectionRange(11, 11);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- newItems = popup.getItems();
- ok(!newItems.every(function (item) {
- return item.label != "getComputedStyle";
- }), "autocomplete results do contain getComputedStyle");
-
- // Test if 'dump(d' gives non-zero results
- input.value = "dump(d";
- input.setSelectionRange(6, 6);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- ok(popup.getItems().length > 0, "'dump(d' gives non-zero results");
-
- // Test that 'dump(window.)' works.
- input.value = "dump(window.)";
- input.setSelectionRange(12, 12);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- yield jsterm.execute("window.docfoobar = true");
-
- // Make sure 'dump(window.doc)' does not contain 'docfoobar'.
- input.value = "dump(window.doc)";
- input.setSelectionRange(15, 15);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- newItems = popup.getItems();
- ok(newItems.every(function (item) {
- return item.label != "docfoobar";
- }), "autocomplete cached results do not contain docfoobar. list has not " +
- "been updated");
-
- yield jsterm.execute("delete window.docfoobar");
-
- jsterm = null;
-});
-
-function complete(type) {
- let updated = jsterm.once("autocomplete-updated");
- jsterm.complete(type);
- return updated;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_cd_iframe.js
+++ /dev/null
@@ -1,115 +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 that the cd() jsterm helper function works as expected. See bug 609872.
-
-"use strict";
-
-function test() {
- let hud;
-
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug-609872-cd-iframe-parent.html";
-
- const parentMessages = [{
- name: "document.title in parent iframe",
- text: "bug 609872 - iframe parent",
- category: CATEGORY_OUTPUT,
- }, {
- name: "paragraph content",
- text: "p: test for bug 609872 - iframe parent",
- category: CATEGORY_OUTPUT,
- }, {
- name: "object content",
- text: "obj: parent!",
- category: CATEGORY_OUTPUT,
- }];
-
- const childMessages = [{
- name: "document.title in child iframe",
- text: "bug 609872 - iframe child",
- category: CATEGORY_OUTPUT,
- }, {
- name: "paragraph content",
- text: "p: test for bug 609872 - iframe child",
- category: CATEGORY_OUTPUT,
- }, {
- name: "object content",
- text: "obj: child!",
- category: CATEGORY_OUTPUT,
- }];
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
-
- yield executeWindowTest();
-
- yield waitForMessages({ webconsole: hud, messages: parentMessages });
-
- info("cd() into the iframe using a selector");
- hud.jsterm.clearOutput();
- yield hud.jsterm.execute("cd('iframe')");
- yield executeWindowTest();
-
- yield waitForMessages({ webconsole: hud, messages: childMessages });
-
- info("cd() out of the iframe, reset to default window");
- hud.jsterm.clearOutput();
- yield hud.jsterm.execute("cd()");
- yield executeWindowTest();
-
- yield waitForMessages({ webconsole: hud, messages: parentMessages });
-
- info("call cd() with unexpected arguments");
- hud.jsterm.clearOutput();
- yield hud.jsterm.execute("cd(document)");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Cannot cd()",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_ERROR,
- }],
- });
-
- hud.jsterm.clearOutput();
- yield hud.jsterm.execute("cd('p')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Cannot cd()",
- category: CATEGORY_OUTPUT,
- severity: SEVERITY_ERROR,
- }],
- });
-
- info("cd() into the iframe using an iframe DOM element");
- hud.jsterm.clearOutput();
- yield hud.jsterm.execute("cd($('iframe'))");
- yield executeWindowTest();
-
- yield waitForMessages({ webconsole: hud, messages: childMessages });
-
- info("cd(window.parent)");
- hud.jsterm.clearOutput();
- yield hud.jsterm.execute("cd(window.parent)");
- yield executeWindowTest();
-
- yield waitForMessages({ webconsole: hud, messages: parentMessages });
-
- yield closeConsole(tab);
- }
-
- function* executeWindowTest() {
- yield hud.jsterm.execute("document.title");
- yield hud.jsterm.execute("'p: ' + document.querySelector('p').textContent");
- yield hud.jsterm.execute("'obj: ' + window.foobarBug609872");
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_certificate_messages.js
+++ /dev/null
@@ -1,81 +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/ */
-
-// Tests that the Web Console shows weak crypto warnings (SHA-1 Certificate)
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Web Console weak crypto " +
- "warnings test";
-const TEST_URI_PATH = "/browser/devtools/client/webconsole/old/test/" +
- "test-certificate-messages.html";
-
-var gWebconsoleTests = [
- {url: "https://sha1ee.example.com" + TEST_URI_PATH,
- name: "SHA1 warning displayed successfully",
- warning: ["SHA-1"], nowarning: ["SSL 3.0", "RC4"]},
- {url: "https://sha256ee.example.com" + TEST_URI_PATH,
- name: "SSL warnings appropriately not present",
- warning: [], nowarning: ["SHA-1", "SSL 3.0", "RC4"]},
-];
-const TRIGGER_MSG = "If you haven't seen ssl warnings yet, you won't";
-
-var gHud = undefined, gContentBrowser;
-var gCurrentTest;
-
-function test() {
- registerCleanupFunction(function () {
- gHud = gContentBrowser = null;
- });
-
- loadTab(TEST_URI).then(({browser}) => {
- gContentBrowser = browser;
- openConsole().then(runTestLoop);
- });
-}
-
-function runTestLoop(theHud) {
- gCurrentTest = gWebconsoleTests.shift();
- if (!gCurrentTest) {
- finishTest();
- return;
- }
- if (!gHud) {
- gHud = theHud;
- }
- gHud.jsterm.clearOutput();
- gContentBrowser.addEventListener("load", onLoad, true);
- if (gCurrentTest.pref) {
- SpecialPowers.pushPrefEnv({"set": gCurrentTest.pref},
- function () {
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.url);
- });
- } else {
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.url);
- }
-}
-
-function onLoad() {
- gContentBrowser.removeEventListener("load", onLoad, true);
-
- waitForSuccess({
- name: gCurrentTest.name,
- validator: function () {
- if (gHud.outputNode.textContent.includes(TRIGGER_MSG)) {
- for (let warning of gCurrentTest.warning) {
- if (!gHud.outputNode.textContent.includes(warning)) {
- return false;
- }
- }
- for (let nowarning of gCurrentTest.nowarning) {
- if (gHud.outputNode.textContent.includes(nowarning)) {
- return false;
- }
- }
- return true;
- }
- }
- }).then(runTestLoop);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_chrome.js
+++ /dev/null
@@ -1,38 +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/ */
-
-// Tests that code completion works properly in chrome tabs, like about:credits.
-
-"use strict";
-
-function test() {
- Task.spawn(function* () {
- const {tab} = yield loadTab("about:config");
- ok(tab, "tab loaded");
-
- const hud = yield openConsole(tab);
- ok(hud, "we have a console");
- ok(hud.iframeWindow, "we have the console UI window");
-
- let jsterm = hud.jsterm;
- ok(jsterm, "we have a jsterm");
-
- let input = jsterm.inputNode;
- ok(hud.outputNode, "we have an output node");
-
- // Test typing 'docu'.
- input.value = "docu";
- input.setSelectionRange(4, 4);
-
- let deferred = defer();
-
- jsterm.complete(jsterm.COMPLETE_HINT_ONLY, function () {
- is(jsterm.completeNode.value, " ment", "'docu' completion");
- deferred.resolve(null);
- });
-
- yield deferred.promise;
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_clear_method.js
+++ /dev/null
@@ -1,135 +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/ */
-
-// Check that calls to console.clear from a script delete the messages
-// previously logged.
-
-"use strict";
-
-add_task(async function () {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-clear.html";
-
- await loadTab(TEST_URI);
- let hud = await openConsole();
- ok(hud, "Web Console opened");
-
- info("Check the console.clear() done on page load has been processed.");
- await waitForLog("Console was cleared", hud);
- ok(hud.outputNode.textContent.includes("Console was cleared"),
- "console.clear() message is displayed");
- ok(!hud.outputNode.textContent.includes("log1"), "log1 not displayed");
- ok(!hud.outputNode.textContent.includes("log2"), "log2 not displayed");
-
- info("Logging two messages log3, log4");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.console.log("log3");
- content.wrappedJSObject.console.log("log4");
- });
-
- await waitForLog("log3", hud);
- await waitForLog("log4", hud);
-
- ok(hud.outputNode.textContent.includes("Console was cleared"),
- "console.clear() message is still displayed");
- ok(hud.outputNode.textContent.includes("log3"), "log3 is displayed");
- ok(hud.outputNode.textContent.includes("log4"), "log4 is displayed");
-
- info("Open the variables view sidebar for 'objFromPage'");
- await openSidebar("objFromPage", { a: 1 }, hud);
- let sidebarClosed = hud.jsterm.once("sidebar-closed");
-
- info("Call console.clear from the page");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.console.clear();
- });
-
- // Cannot wait for "Console was cleared" here because such a message is
- // already present and would resolve immediately.
- info("Wait for variables view sidebar to be closed after console.clear()");
- await sidebarClosed;
-
- // Wait for the next event tick to make sure the remaining part of the
- // test is not executed before the message is actually flushed.
- await new Promise(executeSoon);
-
- ok(!hud.outputNode.textContent.includes("log3"), "log3 not displayed");
- ok(!hud.outputNode.textContent.includes("log4"), "log4 not displayed");
- ok(hud.outputNode.textContent.includes("Console was cleared"),
- "console.clear() message is still displayed");
- is(hud.outputNode.textContent.split("Console was cleared").length, 2,
- "console.clear() message is only displayed once");
-
- info("Logging one messages log5");
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- content.wrappedJSObject.console.log("log5");
- });
- await waitForLog("log5", hud);
-
- info("Close and reopen the webconsole.");
- await closeConsole(gBrowser.selectedTab);
- hud = await openConsole();
- await waitForLog("Console was cleared", hud);
-
- ok(hud.outputNode.textContent.includes("Console was cleared"),
- "console.clear() message is still displayed");
- ok(!hud.outputNode.textContent.includes("log1"), "log1 not displayed");
- ok(!hud.outputNode.textContent.includes("log2"), "log1 not displayed");
- ok(!hud.outputNode.textContent.includes("log3"), "log3 not displayed");
- ok(!hud.outputNode.textContent.includes("log4"), "log4 not displayed");
- ok(hud.outputNode.textContent.includes("log5"), "log5 still displayed");
-});
-
-/**
- * Wait for a single message to be logged in the provided webconsole instance
- * with the category CATEGORY_WEBDEV and the SEVERITY_LOG severity.
- *
- * @param {String} message
- * The expected messaged.
- * @param {WebConsole} webconsole
- * WebConsole instance in which the message should be logged.
- */
-function waitForLog(message, webconsole, options) {
- return waitForMessages({
- webconsole: webconsole,
- messages: [{
- text: message,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-/**
- * Open the variables view sidebar for the object with the provided name objName
- * and wait for the expected object is displayed in the variables view.
- *
- * @param {String} objName
- * The name of the object to open in the sidebar.
- * @param {Object} expectedObj
- * The properties that should be displayed in the variables view.
- * @param {WebConsole} webconsole
- * WebConsole instance in which the message should be logged.
- *
- */
-async function openSidebar(objName, expectedObj, webconsole) {
- let msg = await webconsole.jsterm.execute(objName);
- ok(msg, "output message found");
-
- let anchor = msg.querySelector("a");
- let body = msg.querySelector(".message-body");
- ok(anchor, "object anchor");
- ok(body, "message body");
-
- await EventUtils.synthesizeMouse(anchor, 2, 2, {}, webconsole.iframeWindow);
-
- let vviewVar = await webconsole.jsterm.once("variablesview-fetched");
- let vview = vviewVar._variablesView;
- ok(vview, "variables view object exists");
-
- await findVariableViewProperties(vviewVar, [
- expectedObj,
- ], { webconsole: webconsole });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_clickable_urls.js
+++ /dev/null
@@ -1,103 +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/ */
-
-// When strings containing URLs are entered into the webconsole, check
-// its output and ensure that the output can be clicked to open those URLs.
-
-"use strict";
-
-const inputTests = [
-
- // 0: URL opens page when clicked.
- {
- input: "'http://example.com'",
- output: "http://example.com",
- expectedTab: "http://example.com/",
- },
-
- // 1: URL opens page using https when clicked.
- {
- input: "'https://example.com'",
- output: "https://example.com",
- expectedTab: "https://example.com/",
- },
-
- // 2: URL with port opens page when clicked.
- {
- input: "'https://example.com:443'",
- output: "https://example.com:443",
- expectedTab: "https://example.com/",
- },
-
- // 3: URL containing non-empty path opens page when clicked.
- {
- input: "'http://example.com/foo'",
- output: "http://example.com/foo",
- expectedTab: "http://example.com/foo",
- },
-
- // 4: URL opens page when clicked, even when surrounded by non-URL tokens.
- {
- input: "'foo http://example.com bar'",
- output: "foo http://example.com bar",
- expectedTab: "http://example.com/",
- },
-
- // 5: URL opens page when clicked, and whitespace is be preserved.
- {
- input: "'foo\\nhttp://example.com\\nbar'",
- output: "foo\nhttp://example.com\nbar",
- expectedTab: "http://example.com/",
- },
-
- // 6: URL opens page when clicked when multiple links are present.
- {
- input: "'http://example.com http://example.com'",
- output: "http://example.com http://example.com",
- expectedTab: "http://example.com/",
- },
-
- // 7: URL without scheme does not open page when clicked.
- {
- input: "'example.com'",
- output: "example.com",
- },
-
- // 8: URL with invalid scheme does not open page when clicked.
- {
- input: "'foo://example.com'",
- output: "foo://example.com",
- },
-
- // 9: Shortened URL in an array
- {
- input: "['http://example.com/abcdefghijabcdefghij some other text']",
- output: "Array [ \"http://example.com/abcdefghijabcdef\u2026\" ]",
- printOutput: "http://example.com/abcdefghijabcdefghij some other text",
- expectedTab: "http://example.com/abcdefghijabcdefghij",
- getClickableNode: (msg) => msg.querySelectorAll("a")[1],
- },
-
- // 10: Shortened URL in an object
- {
- input: "{test: 'http://example.com/abcdefghijabcdefghij some other text'}",
- output: "Object { test: \"http://example.com/abcdefghijabcdef\u2026\" }",
- printOutput: "[object Object]",
- evalOutput: "http://example.com/abcdefghijabcdefghij some other text",
- noClick: true,
- consoleLogClick: true,
- expectedTab: "http://example.com/abcdefghijabcdefghij",
- getClickableNode: (msg) => msg.querySelectorAll("a")[1],
- },
-
-];
-
-const url = "data:text/html;charset=utf8,Bug 1005909 - Clickable URLS";
-
-add_task(function* () {
- yield BrowserTestUtils.openNewForegroundTab(gBrowser, url);
- let hud = yield openConsole();
- yield checkOutputForInputs(hud, inputTests);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_closure_inspection.js
+++ /dev/null
@@ -1,100 +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/ */
-
-// Check that inspecting a closure in the variables view sidebar works when
-// execution is paused.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-closures.html";
-
-var gWebConsole, gJSTerm, gVariablesView;
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-function test() {
- registerCleanupFunction(() => {
- gWebConsole = gJSTerm = gVariablesView = null;
- });
-
- function fetchScopes(hud, toolbox, panelWin, deferred) {
- panelWin.once(panelWin.EVENTS.FETCHED_SCOPES, () => {
- ok(true, "Scopes were fetched");
- toolbox.selectTool("webconsole").then(() => consoleOpened(hud));
- deferred.resolve();
- });
- }
-
- loadTab(TEST_URI).then(() => {
- openConsole().then((hud) => {
- openDebugger().then(({ toolbox, panelWin }) => {
- let deferred = defer();
- fetchScopes(hud, toolbox, panelWin, deferred);
-
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- let button = content.document.querySelector("button");
- ok(button, "button element found");
- button.click();
- });
-
- return deferred.promise;
- });
- });
- });
-}
-
-function consoleOpened(hud) {
- gWebConsole = hud;
- gJSTerm = hud.jsterm;
- gJSTerm.execute("window.george.getName");
-
- waitForMessages({
- webconsole: gWebConsole,
- messages: [{
- text: "getName()",
- category: CATEGORY_OUTPUT,
- objects: true,
- }],
- }).then(onExecuteGetName);
-}
-
-function onExecuteGetName(results) {
- let clickable = results[0].clickableElements[0];
- ok(clickable, "clickable object found");
-
- gJSTerm.once("variablesview-fetched", onGetNameFetch);
- let contextMenu =
- gWebConsole.iframeWindow.document.getElementById("output-contextmenu");
- waitForContextMenu(contextMenu, clickable, () => {
- let openInVarView = contextMenu.querySelector("#menu_openInVarView");
- ok(openInVarView.disabled === false,
- "the \"Open In Variables View\" context menu item should be clickable");
- // EventUtils.synthesizeMouseAtCenter seems to fail here in Mac OSX
- openInVarView.click();
- });
-}
-
-function onGetNameFetch(view) {
- gVariablesView = view._variablesView;
- ok(gVariablesView, "variables view object");
-
- findVariableViewProperties(view, [
- { name: /_pfactory/, value: "" },
- ], { webconsole: gWebConsole }).then(onExpandClosure);
-}
-
-function onExpandClosure(results) {
- let prop = results[0].matchedProp;
- ok(prop, "matched the name property in the variables view");
-
- gVariablesView.window.focus();
- gJSTerm.once("sidebar-closed", finishTest);
- EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_column_numbers.js
+++ /dev/null
@@ -1,46 +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/ */
-
- // Check if console provides the right column number alongside line number
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-column.html";
-
-var hud;
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
-
-function consoleOpened(aHud) {
- hud = aHud;
-
- waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Error Message",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR
- }]
- }).then(testLocationColumn);
-}
-
-function testLocationColumn() {
- let messages = hud.outputNode.children;
- let expected = ["11:7", "11:39", "12:9", "13:11", "14:9", "15:7"];
-
- for (let i = 0, len = messages.length; i < len; i++) {
- let msg = messages[i].textContent;
-
- is(msg.includes(expected[i]), true, "Found expected line:column of " +
- expected[i]);
- }
-
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_completion.js
+++ /dev/null
@@ -1,106 +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/ */
-
-// Tests that code completion works properly.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test code completion";
-
-var jsterm;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- jsterm = hud.jsterm;
- let input = jsterm.inputNode;
-
- // Test typing 'docu'.
- input.value = "docu";
- input.setSelectionRange(4, 4);
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- is(input.value, "docu", "'docu' completion (input.value)");
- is(jsterm.completeNode.value, " ment", "'docu' completion (completeNode)");
-
- // Test typing 'docu' and press tab.
- input.value = "docu";
- input.setSelectionRange(4, 4);
- yield complete(jsterm.COMPLETE_FORWARD);
-
- is(input.value, "document", "'docu' tab completion");
- is(input.selectionStart, 8, "start selection is alright");
- is(input.selectionEnd, 8, "end selection is alright");
- is(jsterm.completeNode.value.replace(/ /g, ""), "", "'docu' completed");
-
- // Test typing 'window.Ob' and press tab. Just 'window.O' is
- // ambiguous: could be window.Object, window.Option, etc.
- input.value = "window.Ob";
- input.setSelectionRange(9, 9);
- yield complete(jsterm.COMPLETE_FORWARD);
-
- is(input.value, "window.Object", "'window.Ob' tab completion");
-
- // Test typing 'document.getElem'.
- input.value = "document.getElem";
- input.setSelectionRange(16, 16);
- yield complete(jsterm.COMPLETE_FORWARD);
-
- is(input.value, "document.getElem", "'document.getElem' completion");
- is(jsterm.completeNode.value, " entsByTagNameNS",
- "'document.getElem' completion");
-
- // Test pressing tab another time.
- yield jsterm.complete(jsterm.COMPLETE_FORWARD);
-
- is(input.value, "document.getElem", "'document.getElem' completion");
- is(jsterm.completeNode.value, " entsByTagName",
- "'document.getElem' another tab completion");
-
- // Test pressing shift_tab.
- complete(jsterm.COMPLETE_BACKWARD);
-
- is(input.value, "document.getElem", "'document.getElem' untab completion");
- is(jsterm.completeNode.value, " entsByTagNameNS",
- "'document.getElem' completion");
-
- jsterm.clearOutput();
-
- input.value = "docu";
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- is(jsterm.completeNode.value, " ment", "'docu' completion");
- yield jsterm.execute();
- is(jsterm.completeNode.value, "", "clear completion on execute()");
-
- // Test multi-line completion works
- input.value = "console.log('one');\nconsol";
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- is(jsterm.completeNode.value, " \n e",
- "multi-line completion");
-
- // Test non-object autocompletion.
- input.value = "Object.name.sl";
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- is(jsterm.completeNode.value, " ice", "non-object completion");
-
- // Test string literal autocompletion.
- input.value = "'Asimov'.sl";
- yield complete(jsterm.COMPLETE_HINT_ONLY);
-
- is(jsterm.completeNode.value, " ice", "string literal completion");
-
- jsterm = null;
-});
-
-function complete(type) {
- let updated = jsterm.once("autocomplete-updated");
- jsterm.complete(type);
- return updated;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_api_stackframe.js
+++ /dev/null
@@ -1,85 +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/ */
-
-"use strict";
-
-// Test that the console API messages for console.error()/exception()/assert()
-// include a stackframe. See bug 920116.
-
-function test() {
- let hud;
-
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-api-stackframe.html";
- const TEST_FILE = TEST_URI.substr(TEST_URI.lastIndexOf("/"));
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
-
- const stack = [{
- file: TEST_FILE,
- fn: "thirdCall",
- // 21,22,23
- line: /\b2[123]\b/,
- }, {
- file: TEST_FILE,
- fn: "secondCall",
- line: 16,
- }, {
- file: TEST_FILE,
- fn: "firstCall",
- line: 12,
- }];
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foo-log",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- collapsible: false,
- }, {
- text: "foo-error",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- collapsible: true,
- stacktrace: stack,
- }, {
- text: "foo-exception",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- collapsible: true,
- stacktrace: stack,
- }, {
- text: "foo-assert",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_ERROR,
- collapsible: true,
- stacktrace: stack,
- }],
- });
-
- let elem = [...results[1].matched][0];
- ok(elem, "message element");
-
- let msg = elem._messageObject;
- ok(msg, "message object");
-
- ok(msg.collapsed, "message is collapsed");
-
- msg.toggleDetails();
-
- ok(!msg.collapsed, "message is not collapsed");
-
- msg.toggleDetails();
-
- ok(msg.collapsed, "message is collapsed");
-
- yield closeConsole(tab);
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_custom_styles.js
+++ /dev/null
@@ -1,81 +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/ */
-
-"use strict";
-
-// Test that the '%c' modifier works with the console API. See bug 823097.
-
-function test() {
- let hud;
-
- const TEST_URI = "data:text/html;charset=utf8,<p>test for " +
- "console.log('%ccustom styles', 'color:red')";
-
- const checks = [{
- // check the basics work
- style: "color:red;font-size:1.3em",
- props: { color: true, fontSize: true },
- sameStyleExpected: true,
- }, {
- // check that the url() is not allowed
- style: "color:blue;background-image:url('http://example.com/test')",
- props: { color: true, fontSize: false, background: false,
- backgroundImage: false },
- sameStyleExpected: false,
- }, {
- // check that some properties are not allowed
- style: "color:pink;position:absolute;top:10px",
- props: { color: true, position: false, top: false },
- sameStyleExpected: false,
- }];
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
-
- for (let check of checks) {
- yield checkStyle(check);
- }
-
- yield closeConsole(tab);
- }
-
- function* checkStyle(check) {
- hud.jsterm.clearOutput();
-
- info("checkStyle " + check.style);
- hud.jsterm.execute("console.log('%cfoobar', \"" + check.style + "\")");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobar",
- category: CATEGORY_WEBDEV,
- }],
- });
-
- let msg = [...result.matched][0];
- ok(msg, "message element");
-
- let span = msg.querySelector(".message-body span[style]");
- ok(span, "span element");
-
- info("span textContent is: " + span.textContent);
- isnot(span.textContent.indexOf("foobar"), -1, "span textContent check");
-
- let outputStyle = span.getAttribute("style").replace(/\s+|;+$/g, "");
- if (check.sameStyleExpected) {
- is(outputStyle, check.style, "span style is correct");
- } else {
- isnot(outputStyle, check.style, "span style is not the same");
- }
-
- for (let prop of Object.keys(check.props)) {
- is(!!span.style[prop], check.props[prop], "property check for " + prop);
- }
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_extras.js
+++ /dev/null
@@ -1,45 +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 that window.console functions that are not implemented yet do not
-// output anything in the web console and they do not throw any exceptions.
-// See bug 614350.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-extras.html";
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
-
-function consoleOpened(hud) {
- waitForMessages({
- webconsole: hud,
- messages: [{
- text: "start",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "end",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- }).then(() => {
- let nodes = hud.outputNode.querySelectorAll(".message");
- is(nodes.length, 2, "only two messages are displayed");
- finishTest();
- });
-
- ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- let button = content.document.querySelector("button");
- ok(button, "we have the button");
- button.click();
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_logging_api.js
+++ /dev/null
@@ -1,106 +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/ */
-
-// Tests that the basic console.log()-style APIs and filtering work.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- let outputNode = hud.outputNode;
-
- let methods = ["log", "info", "warn", "error", "exception", "debug"];
- for (let method of methods) {
- yield testMethod(method, hud, outputNode);
- }
-});
-
-function* testMethod(method, hud, outputNode) {
- hud.jsterm.clearOutput();
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, method, function(method) {
- content.console[method]("foo-bar-baz");
- content.console[method]("baar-baz");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foo-bar-baz",
- }, {
- text: "baar-baz",
- }],
- });
-
- setStringFilter("foo", hud);
-
- is(outputNode.querySelectorAll(".filtered-by-string").length, 1,
- "1 hidden " + method + " node via string filtering");
-
- hud.jsterm.clearOutput();
-
- // now toggle the current method off - make sure no visible message
- // TODO: move all filtering tests into a separate test file: see bug 608135
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, method, function(method) {
- content.console[method]("foo-bar-baz");
- });
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foo-bar-baz",
- }],
- });
-
- setStringFilter("", hud);
- let filter;
- switch (method) {
- case "debug":
- filter = "log";
- break;
- case "exception":
- filter = "error";
- break;
- default:
- filter = method;
- break;
- }
-
- hud.setFilterState(filter, false);
-
- is(outputNode.querySelectorAll(".filtered-by-type").length, 1,
- "1 message hidden for " + method + " (logging turned off)");
-
- hud.setFilterState(filter, true);
-
- is(outputNode.querySelectorAll(".message:not(.filtered-by-type)").length, 1,
- "1 message shown for " + method + " (logging turned on)");
-
- hud.jsterm.clearOutput();
-
- // test for multiple arguments.
- yield ContentTask.spawn(gBrowser.selectedBrowser, method, function(method) {
- content.console[method]("foo", "bar");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foo bar",
- category: CATEGORY_WEBDEV,
- }],
- });
-}
-
-function setStringFilter(value, hud) {
- hud.ui.filterBox.value = value;
- hud.ui.adjustVisibilityOnSearchStringChange();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_logging_workers_api.js
+++ /dev/null
@@ -1,39 +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/ */
-
-// Tests that the basic console.log()-style APIs and filtering work for
-// sharedWorkers
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-workers.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foo-bar-shared-worker"
- }],
- });
-
- hud.setFilterState("sharedworkers", false);
-
- is(hud.outputNode.querySelectorAll(".filtered-by-type").length, 1,
- "1 message hidden for sharedworkers (logging turned off)");
-
- hud.setFilterState("sharedworkers", true);
-
- is(hud.outputNode.querySelectorAll(".filtered-by-type").length, 0,
- "1 message shown for sharedworkers (logging turned on)");
-
- hud.setFilterState("sharedworkers", false);
-
- hud.jsterm.clearOutput(true);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_trace_async.js
+++ /dev/null
@@ -1,72 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-console-trace-async.html";
-
-add_task(function* runTest() {
- // Async stacks aren't on by default in all builds
- yield new Promise(resolve => {
- SpecialPowers.pushPrefEnv({"set": [
- ["javascript.options.asyncstack", true]
- ]}, resolve);
- });
-
- let {tab} = yield loadTab("data:text/html;charset=utf8,<p>hello");
- let hud = yield openConsole(tab);
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.trace output",
- consoleTrace: {
- file: "test-console-trace-async.html",
- fn: "inner",
- },
- }],
- });
-
- let node = [...result.matched][0];
- ok(node, "found trace log node");
- ok(node.textContent.includes("console.trace()"),
- "trace log node includes console.trace()");
- ok(node.textContent.includes("promise callback"),
- "trace log node includes promise callback");
- ok(node.textContent.includes("setTimeout handler"),
- "trace log node includes setTimeout handler");
-
- // The expected stack trace object.
- let stacktrace = [
- {
- columnNumber: 3,
- filename: TEST_URI,
- functionName: "inner",
- lineNumber: 9
- },
- {
- asyncCause: "promise callback",
- columnNumber: 3,
- filename: TEST_URI,
- functionName: "time1",
- lineNumber: 13,
- },
- {
- asyncCause: "setTimeout handler",
- columnNumber: 1,
- filename: TEST_URI,
- functionName: "",
- lineNumber: 18,
- }
- ];
-
- let obj = node._messageObject;
- ok(obj, "console.trace message object");
- ok(obj._stacktrace, "found stacktrace object");
- is(obj._stacktrace.toSource(), stacktrace.toSource(),
- "stacktrace is correct");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_console_trace_duplicates.js
+++ /dev/null
@@ -1,50 +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/ */
-
-"use strict";
-
-function test() {
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug_939783_console_trace_duplicates.html";
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab("data:text/html;charset=utf8,<p>hello");
- const hud = yield openConsole(tab);
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
-
- // NB: Now that stack frames include a column number multiple invocations
- // on the same line are considered unique. ie:
- // |foo(); foo();|
- // will generate two distinct trace entries.
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.trace output for foo1()",
- text: "foo1",
- consoleTrace: {
- file: "test-bug_939783_console_trace_duplicates.html",
- fn: "foo3",
- },
- }, {
- name: "console.trace output for foo1()",
- text: "foo1",
- consoleTrace: {
- file: "test-bug_939783_console_trace_duplicates.html",
- fn: "foo3",
- },
- }, {
- name: "console.trace output for foo1b()",
- text: "foo1b",
- consoleTrace: {
- file: "test-bug_939783_console_trace_duplicates.html",
- fn: "foo3",
- },
- }],
- });
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_context_menu_open_in_var_view.js
+++ /dev/null
@@ -1,51 +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/ */
-
-// Tests that the "Open in Variables View" context menu item is enabled
-// only for objects.
-
-"use strict";
-
-const TEST_URI = `data:text/html,<script>
- console.log("foo");
- console.log("foo", window);
-</script>`;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- count: 2,
- text: /foo/
- }],
- });
-
- let [msgWithText, msgWithObj] = [...result.matched];
- ok(msgWithText && msgWithObj, "Two messages should have appeared");
-
- let contextMenu = hud.iframeWindow.document
- .getElementById("output-contextmenu");
- let openInVarViewItem = contextMenu.querySelector("#menu_openInVarView");
- let obj = msgWithObj.querySelector(".cm-variable");
- let text = msgWithText.querySelector(".console-string");
-
- yield waitForContextMenu(contextMenu, obj, () => {
- ok(openInVarViewItem.disabled === false, "The \"Open In Variables View\" " +
- "context menu item should be available for objects");
- }, () => {
- ok(openInVarViewItem.disabled === true, "The \"Open In Variables View\" " +
- "context menu item should be disabled on popup hiding");
- });
-
- yield waitForContextMenu(contextMenu, text, () => {
- ok(openInVarViewItem.disabled === true, "The \"Open In Variables View\" " +
- "context menu item should be disabled for texts");
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_context_menu_store_as_global.js
+++ /dev/null
@@ -1,66 +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/ */
-
-// Tests the "Store as global variable" context menu item feature.
-// It should be work, and be enabled only for objects
-
-"use strict";
-
-const TEST_URI = `data:text/html,<script>
- window.bar = { baz: 1 };
- console.log("foo");
- console.log("foo", window.bar);
-</script>`;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- count: 2,
- text: /foo/
- }],
- });
-
- let [msgWithText, msgWithObj] = [...result.matched];
- ok(msgWithText && msgWithObj, "Two messages should have appeared");
-
- let contextMenu = hud.iframeWindow.document
- .getElementById("output-contextmenu");
- let storeAsGlobalItem = contextMenu.querySelector("#menu_storeAsGlobal");
- let obj = msgWithObj.querySelector(".cm-variable");
- let text = msgWithText.querySelector(".console-string");
- let onceInputSet = hud.jsterm.once("set-input-value");
-
- info("Waiting for context menu on the object");
- yield waitForContextMenu(contextMenu, obj, () => {
- ok(storeAsGlobalItem.disabled === false, "The \"Store as global\" " +
- "context menu item should be available for objects");
- storeAsGlobalItem.click();
- }, () => {
- ok(storeAsGlobalItem.disabled === true, "The \"Store as global\" " +
- "context menu item should be disabled on popup hiding");
- });
-
- info("Waiting for context menu on the text node");
- yield waitForContextMenu(contextMenu, text, () => {
- ok(storeAsGlobalItem.disabled === true, "The \"Store as global\" " +
- "context menu item should be disabled for texts");
- });
-
- info("Waiting for input to be set");
- yield onceInputSet;
-
- is(hud.jsterm.getInputValue(), "temp0", "Input was set");
- let executedResult = yield hud.jsterm.execute();
-
- ok(executedResult.textContent.includes("{ baz: 1 }"),
- "Correct variable assigned into console");
-
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_count.js
+++ /dev/null
@@ -1,66 +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 that console.count() counts as expected. See bug 922208.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-count.html";
-
-function test() {
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
-
- BrowserTestUtils.synthesizeMouseAtCenter("#local", {}, gBrowser.selectedBrowser);
- let messages = [];
- [
- "start",
- "default: 1",
- "default: 2",
- "console.count() testcounter: 1",
- "console.count() testcounter: 2",
- "console.count() testcounter: 3",
- "console.count() testcounter: 4",
- "end"
- ].forEach(function (msg) {
- messages.push({
- text: msg,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG
- });
- });
- yield waitForMessages({
- webconsole: hud,
- messages: messages
- });
-
- hud.jsterm.clearOutput();
-
- BrowserTestUtils.synthesizeMouseAtCenter("#external", {}, gBrowser.selectedBrowser);
- messages = [];
- [
- "start",
- "console.count() testcounter: 5",
- "console.count() testcounter: 6",
- "default: 3",
- "default: 4",
- "end"
- ].forEach(function (msg) {
- messages.push({
- text: msg,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG
- });
- });
- yield waitForMessages({
- webconsole: hud,
- messages: messages
- });
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_dont_navigate_on_doubleclick.js
+++ /dev/null
@@ -1,55 +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/ */
-
-// Tests that if a link in console is double clicked, the console frame doesn't
-// navigate to that destination (bug 975707).
-
-"use strict";
-
-function test() {
- let originalNetPref = Services.prefs
- .getBoolPref("devtools.webconsole.filter.networkinfo");
- registerCleanupFunction(() => {
- Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo",
- originalNetPref);
- });
- Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", true);
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const TEST_PAGE_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-console.html" + "?_uniq=" +
- Date.now();
-
- const {tab} = yield loadTab("data:text/html;charset=utf8,<p>hello</p>");
- const hud = yield openConsole(tab);
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_PAGE_URI);
-
- let messages = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "Network request message",
- url: TEST_PAGE_URI,
- category: CATEGORY_NETWORK
- }]
- });
-
- let networkEventMessage = messages[0].matched.values().next().value;
- let urlNode = networkEventMessage.querySelector(".url");
-
- let deferred = defer();
- urlNode.addEventListener("click", function (event) {
- ok(event.defaultPrevented, "The default action was prevented.");
-
- deferred.resolve();
- }, {once: true});
-
- EventUtils.synthesizeMouseAtCenter(urlNode, {clickCount: 2},
- hud.iframeWindow);
-
- yield deferred.promise;
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_exception_stackframe.js
+++ /dev/null
@@ -1,104 +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/ */
-
-"use strict";
-
-// Test that the console receive exceptions include a stackframe.
-// See bug 1184172.
-
-// On e10s, the exception is triggered in child process
-// and is ignored by test harness
-if (!Services.appinfo.browserTabsRemoteAutostart) {
- SimpleTest.ignoreAllUncaughtExceptions();
-}
-
-function test() {
- let hud;
-
- const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-exception-stackframe.html";
- const TEST_FILE = TEST_URI.substr(TEST_URI.lastIndexOf("/"));
-
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab(TEST_URI);
- hud = yield openConsole(tab);
-
- const stack = [{
- file: TEST_FILE,
- fn: "thirdCall",
- line: 21,
- }, {
- file: TEST_FILE,
- fn: "secondCall",
- line: 17,
- }, {
- file: TEST_FILE,
- fn: "firstCall",
- line: 12,
- }];
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "nonExistingMethodCall is not defined",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- collapsible: true,
- stacktrace: stack,
- }, {
- text: "SyntaxError: 'buggy;selector' is not a valid selector",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- collapsible: true,
- stacktrace: [{
- file: TEST_FILE,
- fn: "domAPI",
- line: 25,
- }, {
- file: TEST_FILE,
- fn: "onLoadDomAPI",
- line: 33,
- }
- ]
- }, {
- text: "DOMException",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- collapsible: true,
- stacktrace: [{
- file: TEST_FILE,
- fn: "domException",
- line: 29,
- }, {
- file: TEST_FILE,
- fn: "onLoadDomException",
- line: 36,
- },
-
- ]
- }],
- });
-
- let elem = [...results[0].matched][0];
- ok(elem, "message element");
-
- let msg = elem._messageObject;
- ok(msg, "message object");
-
- ok(msg.collapsed, "message is collapsed");
-
- msg.toggleDetails();
-
- ok(!msg.collapsed, "message is not collapsed");
-
- msg.toggleDetails();
-
- ok(msg.collapsed, "message is collapsed");
-
- yield closeConsole(tab);
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_execution_scope.js
+++ /dev/null
@@ -1,37 +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/ */
-
-// Tests that commands run by the user are executed in content space.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
- hud.jsterm.execute("window.location.href;");
-
- let [input, output] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "window.location.href;",
- category: CATEGORY_INPUT,
- },
- {
- text: TEST_URI,
- category: CATEGORY_OUTPUT,
- }],
- });
-
- let inputNode = [...input.matched][0];
- let outputNode = [...output.matched][0];
- is(inputNode.getAttribute("category"), "input",
- "input node category is correct");
- is(outputNode.getAttribute("category"), "output",
- "output node category is correct");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_expandable_timestamps.js
+++ /dev/null
@@ -1,61 +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 message timestamps option: check if the preference toggles the
-// display of messages in the console output. See bug 722267.
-
-"use strict";
-
-const {PrefObserver} = require("devtools/client/shared/prefs");
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "bug 722267 - preference for toggling timestamps in messages";
-const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
-var hud;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
- let panel = yield consoleOpened();
-
- let observer = new PrefObserver("");
- yield onOptionsPanelSelected(panel, observer);
- onPrefChanged();
- observer.destroy();
-
- Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP);
- hud = null;
-});
-
-function consoleOpened() {
- info("console opened");
- let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
- ok(!prefValue, "messages have no timestamp by default (pref check)");
- ok(hud.outputNode.classList.contains("hideTimestamps"),
- "messages have no timestamp (class name check)");
-
- let toolbox = gDevTools.getToolbox(hud.target);
- return toolbox.selectTool("options");
-}
-
-function onOptionsPanelSelected(panel, observer) {
- info("options panel opened");
-
- let prefChanged = observer.once(PREF_MESSAGE_TIMESTAMP, () => {});
-
- let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages");
- checkbox.click();
-
- return prefChanged;
-}
-
-function onPrefChanged() {
- info("pref changed");
- let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
- ok(prefValue, "messages have timestamps (pref check)");
- ok(!hud.outputNode.classList.contains("hideTimestamps"),
- "messages have timestamps (class name check)");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_filter_buttons_contextmenu.js
+++ /dev/null
@@ -1,79 +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/ */
-
-// Tests that the filter button context menu logic works correctly.
-
-"use strict";
-
-const TEST_URI = "http://example.com/";
-
-function test() {
- loadTab(TEST_URI).then(() => {
- openConsole().then(testFilterButtons);
- });
-}
-
-function testFilterButtons(aHud) {
- let hudBox = aHud.ui.rootElement;
-
- testRightClick("net", hudBox, aHud)
- .then(() => testRightClick("css", hudBox, aHud))
- .then(() => testRightClick("js", hudBox, aHud))
- .then(() => testRightClick("logging", hudBox, aHud))
- .then(() => testRightClick("security", hudBox, aHud))
- .then(finishTest);
-}
-
-function testRightClick(aCategory, hudBox, aHud) {
- let deferred = defer();
- let selector = ".webconsole-filter-button[category=\"" + aCategory + "\"]";
- let button = hudBox.querySelector(selector);
- let origCheckedState = button.getAttribute("aria-pressed");
- let contextMenu = aHud.iframeWindow.document.getElementById(aCategory + "-contextmenu");
-
- function verifyContextMenuIsClosed() {
- info("verify the context menu is closed");
- is(button.getAttribute("open"), false, "The context menu for the \"" +
- aCategory + "\" button is closed");
- }
-
- function verifyOriginalCheckedState() {
- info("verify the button has the original checked state");
- is(button.getAttribute("aria-pressed"), origCheckedState,
- "The button state should not have changed");
- }
-
- function verifyNewCheckedState() {
- info("verify the button's checked state has changed");
- isnot(button.getAttribute("aria-pressed"), origCheckedState,
- "The button state should have changed");
- }
-
- function leftClickToClose() {
- info("left click the button to close the contextMenu");
- EventUtils.sendMouseEvent({type: "click"}, button);
- executeSoon(() => {
- verifyContextMenuIsClosed();
- verifyOriginalCheckedState();
- leftClickToChangeCheckedState();
- });
- }
-
- function leftClickToChangeCheckedState() {
- info("shift click the button to change checked state");
- EventUtils.sendMouseEvent({type: "click", shiftKey: true}, button);
- executeSoon(() => {
- verifyContextMenuIsClosed();
- verifyNewCheckedState();
- deferred.resolve();
- });
- }
-
- verifyContextMenuIsClosed();
- info("right click the button to open the context menu");
- waitForContextMenu(contextMenu, button, verifyOriginalCheckedState,
- leftClickToClose);
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_for_of.js
+++ /dev/null
@@ -1,32 +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/ */
-
-// A for-of loop in Web Console code can loop over a content NodeList.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-for-of.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
- yield testForOf(hud);
-});
-
-function testForOf(hud) {
- let deferred = defer();
-
- let jsterm = hud.jsterm;
- jsterm.execute("{ let _nodes = []; for (let x of document.body.childNodes) { if (x.nodeType === 1) { _nodes.push(x.tagName); } } _nodes.join(' '); }",
- (node) => {
- ok(/H1 DIV H2 P/.test(node.textContent),
- "for-of loop should find all top-level nodes");
- deferred.resolve();
- });
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_history.js
+++ /dev/null
@@ -1,62 +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/ */
-
-// Tests the console history feature accessed via the up and down arrow keys.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-// Constants used for defining the direction of JSTerm input history navigation.
-const HISTORY_BACK = -1;
-const HISTORY_FORWARD = 1;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- let jsterm = hud.jsterm;
- let input = jsterm.inputNode;
-
- let executeList = ["document", "window", "window.location"];
-
- for (let item of executeList) {
- input.value = item;
- yield jsterm.execute();
- }
-
- for (let x = executeList.length - 1; x != -1; x--) {
- jsterm.historyPeruse(HISTORY_BACK);
- is(input.value, executeList[x], "check history previous idx:" + x);
- }
-
- jsterm.historyPeruse(HISTORY_BACK);
- is(input.value, executeList[0], "test that item is still index 0");
-
- jsterm.historyPeruse(HISTORY_BACK);
- is(input.value, executeList[0], "test that item is still still index 0");
-
- for (let i = 1; i < executeList.length; i++) {
- jsterm.historyPeruse(HISTORY_FORWARD);
- is(input.value, executeList[i], "check history next idx:" + i);
- }
-
- jsterm.historyPeruse(HISTORY_FORWARD);
- is(input.value, "", "check input is empty again");
-
- // Simulate pressing Arrow_Down a few times and then if Arrow_Up shows
- // the previous item from history again.
- jsterm.historyPeruse(HISTORY_FORWARD);
- jsterm.historyPeruse(HISTORY_FORWARD);
- jsterm.historyPeruse(HISTORY_FORWARD);
-
- is(input.value, "", "check input is still empty");
-
- let idxLast = executeList.length - 1;
- jsterm.historyPeruse(HISTORY_BACK);
- is(input.value, executeList[idxLast], "check history next idx:" + idxLast);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_hpkp_invalid-headers.js
+++ /dev/null
@@ -1,126 +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/ */
-
-// Tests that errors about invalid HPKP security headers are logged to the web
-// console.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console HPKP invalid " +
- "header test";
-const SJS_URL = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test_hpkp-invalid-headers.sjs";
-const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Web/HTTP/" +
- "Public_Key_Pinning" + DOCS_GA_PARAMS;
-const NON_BUILTIN_ROOT_PREF = "security.cert_pinning.process_headers_from_" +
- "non_builtin_roots";
-
-add_task(function* () {
- registerCleanupFunction(() => {
- Services.prefs.clearUserPref(NON_BUILTIN_ROOT_PREF);
- });
-
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield* checkForMessage({
- url: SJS_URL + "?badSyntax",
- name: "Could not parse header error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that could not be " +
- "parsed successfully."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?noMaxAge",
- name: "No max-age error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that did not include " +
- "a \u2018max-age\u2019 directive."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?invalidIncludeSubDomains",
- name: "Invalid includeSubDomains error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that included an " +
- "invalid \u2018includeSubDomains\u2019 directive."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?invalidMaxAge",
- name: "Invalid max-age error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that included an " +
- "invalid \u2018max-age\u2019 directive."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?multipleIncludeSubDomains",
- name: "Multiple includeSubDomains error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that included " +
- "multiple \u2018includeSubDomains\u2019 directives."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?multipleMaxAge",
- name: "Multiple max-age error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that included " +
- "multiple \u2018max-age\u2019 directives."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?multipleReportURIs",
- name: "Multiple report-uri error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that included " +
- "multiple \u2018report-uri\u2019 directives."
- }, hud);
-
- // The root used for mochitests is not built-in, so set the relevant pref to
- // true to have the PKP implementation return more specific errors.
- Services.prefs.setBoolPref(NON_BUILTIN_ROOT_PREF, true);
-
- yield* checkForMessage({
- url: SJS_URL + "?pinsetDoesNotMatch",
- name: "Non-matching pinset error displayed successfully",
- text: "Public-Key-Pins: The site specified a header that did not include " +
- "a matching pin."
- }, hud);
-
- Services.prefs.setBoolPref(NON_BUILTIN_ROOT_PREF, false);
-
- yield* checkForMessage({
- url: SJS_URL + "?pinsetDoesNotMatch",
- name: "Non-built-in root error displayed successfully",
- text: "Public-Key-Pins: The certificate used by the site was not issued " +
- "by a certificate in the default root certificate store. To " +
- "prevent accidental breakage, the specified header was ignored."
- }, hud);
-});
-
-function* checkForMessage(curTest, hud) {
- hud.jsterm.clearOutput();
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, curTest.url);
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: curTest.name,
- text: curTest.text,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- ],
- });
-
- yield testClickOpenNewTab(hud, results);
-}
-
-function testClickOpenNewTab(hud, results) {
- let warningNode = results[0].clickableElements[0];
- ok(warningNode, "link element");
- ok(warningNode.classList.contains("learn-more-link"), "link class name");
- return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_hsts_invalid-headers.js
+++ /dev/null
@@ -1,92 +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/ */
-
-// Tests that errors about invalid HSTS security headers are logged
-// to the web console.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console HSTS invalid " +
- "header test";
-const SJS_URL = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test_hsts-invalid-headers.sjs";
-const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Web/HTTP/Headers/" +
- "Strict-Transport-Security" + DOCS_GA_PARAMS;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- yield* checkForMessage({
- url: SJS_URL + "?badSyntax",
- name: "Could not parse header error displayed successfully",
- text: "Strict-Transport-Security: The site specified a header that could " +
- "not be parsed successfully."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?noMaxAge",
- name: "No max-age error displayed successfully",
- text: "Strict-Transport-Security: The site specified a header that did " +
- "not include a \u2018max-age\u2019 directive."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?invalidIncludeSubDomains",
- name: "Invalid includeSubDomains error displayed successfully",
- text: "Strict-Transport-Security: The site specified a header that " +
- "included an invalid \u2018includeSubDomains\u2019 directive."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?invalidMaxAge",
- name: "Invalid max-age error displayed successfully",
- text: "Strict-Transport-Security: The site specified a header that " +
- "included an invalid \u2018max-age\u2019 directive."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?multipleIncludeSubDomains",
- name: "Multiple includeSubDomains error displayed successfully",
- text: "Strict-Transport-Security: The site specified a header that " +
- "included multiple \u2018includeSubDomains\u2019 directives."
- }, hud);
-
- yield* checkForMessage({
- url: SJS_URL + "?multipleMaxAge",
- name: "Multiple max-age error displayed successfully",
- text: "Strict-Transport-Security: The site specified a header that " +
- "included multiple \u2018max-age\u2019 directives."
- }, hud);
-});
-
-function* checkForMessage(curTest, hud) {
- hud.jsterm.clearOutput();
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, curTest.url);
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: curTest.name,
- text: curTest.text,
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- ],
- });
-
- yield testClickOpenNewTab(hud, results);
-}
-
-function testClickOpenNewTab(hud, results) {
- let warningNode = results[0].clickableElements[0];
- ok(warningNode, "link element");
- ok(warningNode.classList.contains("learn-more-link"), "link class name");
- return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_input_field_focus_on_panel_select.js
+++ /dev/null
@@ -1,34 +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 that the JS input field is focused when the user switches back to the
-// web console from other tools, see bug 891581.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>hello";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- is(hud.jsterm.inputNode.hasAttribute("focused"), true,
- "inputNode should be focused");
-
- hud.ui.filterBox.focus();
-
- is(hud.ui.filterBox.hasAttribute("focused"), true,
- "filterBox should be focused");
-
- is(hud.jsterm.inputNode.hasAttribute("focused"), false,
- "inputNode shouldn't be focused");
-
- yield openInspector();
- hud = yield openConsole();
-
- is(hud.jsterm.inputNode.hasAttribute("focused"), true,
- "inputNode should be focused");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_inspect-parsed-documents.js
+++ /dev/null
@@ -1,35 +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 that dynamically created (HTML|XML|SVG)Documents can be inspected by
-// clicking on the object in console (bug 1035198).
-
-"use strict";
-
-const TEST_CASES = [
- {
- input: '(new DOMParser()).parseFromString("<a />", "text/html")',
- output: "HTMLDocument",
- inspectable: true,
- },
- {
- input: '(new DOMParser()).parseFromString("<a />", "application/xml")',
- output: "XMLDocument",
- inspectable: true,
- },
- {
- input: '(new DOMParser()).parseFromString("<svg></svg>", "image/svg+xml")',
- output: "XMLDocument",
- inspectable: true,
- },
-];
-
-const TEST_URI = "data:text/html;charset=utf8," +
- "browser_webconsole_inspect-parsed-documents.js";
-add_task(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- yield checkOutputForInputs(hud, TEST_CASES);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_js_input_expansion.js
+++ /dev/null
@@ -1,55 +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/ */
-
-// Tests that the input box expands as the user types long lines.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- let input = hud.jsterm.inputNode;
- input.focus();
-
- is(input.getAttribute("multiline"), "true", "multiline is enabled");
- // Tests if the inputNode expands.
- input.value = "hello\nworld\n";
- let length = input.value.length;
- input.selectionEnd = length;
- input.selectionStart = length;
- function getHeight() {
- return input.clientHeight;
- }
- let initialHeight = getHeight();
- // Performs an "d". This will trigger/test for the input event that should
- // change the "row" attribute of the inputNode.
- EventUtils.sendString("d");
- let newHeight = getHeight();
- ok(initialHeight < newHeight, "Height changed: " + newHeight);
-
- // Add some more rows. Tests for the 8 row limit.
- input.value = "row1\nrow2\nrow3\nrow4\nrow5\nrow6\nrow7\nrow8\nrow9\nrow10\n";
- length = input.value.length;
- input.selectionEnd = length;
- input.selectionStart = length;
- EventUtils.sendString("d");
- let newerHeight = getHeight();
-
- ok(newerHeight > newHeight, "height changed: " + newerHeight);
-
- // Test if the inputNode shrinks again.
- input.value = "";
- EventUtils.sendString("d");
- let height = getHeight();
- info("height: " + height);
- info("initialHeight: " + initialHeight);
- let finalHeightDifference = Math.abs(initialHeight - height);
- ok(finalHeightDifference <= 1, "height shrank to original size within 1px");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_jsterm.js
+++ /dev/null
@@ -1,194 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-var jsterm;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- jsterm = hud.jsterm;
- yield testJSTerm(hud);
- jsterm = null;
-});
-
-function checkResult(msg, desc) {
- let def = defer();
- waitForMessages({
- webconsole: jsterm.hud.owner,
- messages: [{
- name: desc,
- category: CATEGORY_OUTPUT,
- }],
- }).then(([result]) => {
- let node = [...result.matched][0].querySelector(".message-body");
- if (typeof msg == "string") {
- is(node.textContent.trim(), msg,
- "correct message shown for " + desc);
- } else if (typeof msg == "function") {
- ok(msg(node), "correct message shown for " + desc);
- }
-
- def.resolve();
- });
- return def.promise;
-}
-
-function* testJSTerm(hud) {
- const HELP_URL = "https://developer.mozilla.org/docs/Tools/" +
- "Web_Console/Helpers";
-
- jsterm.clearOutput();
- yield jsterm.execute("$('#header').getAttribute('id')");
- yield checkResult('"header"', "$() worked");
-
- jsterm.clearOutput();
- yield jsterm.execute("$$('h1').length");
- yield checkResult("1", "$$() worked");
-
- jsterm.clearOutput();
- yield jsterm.execute("$x('.//*', document.body)[0] == $$('h1')[0]");
- yield checkResult("true", "$x() worked");
-
- // no jsterm.clearOutput() here as we clear the output using the clear() fn.
- yield jsterm.execute("clear()");
-
- yield waitForSuccess({
- name: "clear() worked",
- validator: function () {
- return jsterm.outputNode.childNodes.length == 0;
- }
- });
-
- jsterm.clearOutput();
- yield jsterm.execute("keys({b:1})[0] == 'b'");
- yield checkResult("true", "keys() worked", 1);
-
- jsterm.clearOutput();
- yield jsterm.execute("values({b:1})[0] == 1");
- yield checkResult("true", "values() worked", 1);
-
- jsterm.clearOutput();
-
- let openedLinks = 0;
- let oldOpenLink = hud.openLink;
- hud.openLink = (url) => {
- if (url == HELP_URL) {
- openedLinks++;
- }
- };
-
- yield jsterm.execute("help()");
- yield jsterm.execute("help");
- yield jsterm.execute("?");
-
- let output = jsterm.outputNode.querySelector(".message[category='output']");
- ok(!output, "no output for help() calls");
- is(openedLinks, 3, "correct number of pages opened by the help calls");
- hud.openLink = oldOpenLink;
-
- jsterm.clearOutput();
- yield jsterm.execute("pprint({b:2, a:1})");
- yield checkResult("\" b: 2\n a: 1\"", "pprint()");
-
- // check instanceof correctness, bug 599940
- jsterm.clearOutput();
- yield jsterm.execute("[] instanceof Array");
- yield checkResult("true", "[] instanceof Array == true");
-
- jsterm.clearOutput();
- yield jsterm.execute("({}) instanceof Object");
- yield checkResult("true", "({}) instanceof Object == true");
-
- // check for occurrences of Object XRayWrapper, bug 604430
- jsterm.clearOutput();
- yield jsterm.execute("document");
- yield checkResult(function (node) {
- return node.textContent.search(/\[object xraywrapper/i) == -1;
- }, "document - no XrayWrapper");
-
- // check that pprint(window) and keys(window) don't throw, bug 608358
- jsterm.clearOutput();
- yield jsterm.execute("pprint(window)");
- yield checkResult(null, "pprint(window)");
-
- jsterm.clearOutput();
- yield jsterm.execute("keys(window)");
- yield checkResult(null, "keys(window)");
-
- // bug 614561
- jsterm.clearOutput();
- yield jsterm.execute("pprint('hi')");
- yield checkResult("\" 0: \"h\"\n 1: \"i\"\"", "pprint('hi')");
-
- // check that pprint(function) shows function source, bug 618344
- jsterm.clearOutput();
- yield jsterm.execute("pprint(function() { var someCanaryValue = 42; })");
- yield checkResult(function (node) {
- return node.textContent.indexOf("someCanaryValue") > -1;
- }, "pprint(function) shows source");
-
- // check that an evaluated null produces "null", bug 650780
- jsterm.clearOutput();
- yield jsterm.execute("null");
- yield checkResult("null", "null is null");
-
- jsterm.clearOutput();
- yield jsterm.execute("undefined");
- yield checkResult("undefined", "undefined is printed");
-
- // check that thrown strings produce error messages,
- // and the message text matches that of a stringified error object
- // bug 1099071
- jsterm.clearOutput();
- yield jsterm.execute("throw '';");
- yield checkResult((node) => {
- return node.closest(".message").getAttribute("severity") === "error" &&
- node.textContent === new Error("").toString();
- }, "thrown empty string generates error message");
-
- jsterm.clearOutput();
- yield jsterm.execute("throw 'tomatoes';");
- yield checkResult((node) => {
- return node.closest(".message").getAttribute("severity") === "error" &&
- node.textContent === new Error("tomatoes").toString();
- }, "thrown non-empty string generates error message");
-
- jsterm.clearOutput();
- yield jsterm.execute("throw { foo: 'bar' };");
- yield checkResult((node) => {
- return node.closest(".message").getAttribute("severity") === "error" &&
- node.textContent === Object.prototype.toString();
- }, "thrown object generates error message");
-
- // check that errors with entires in errordocs.js display links
- // alongside their messages.
- const ErrorDocs = require("devtools/server/actors/errordocs");
-
- const ErrorDocStatements = {
- "JSMSG_BAD_RADIX": "(42).toString(0);",
- "JSMSG_BAD_ARRAY_LENGTH": "([]).length = -1",
- "JSMSG_NEGATIVE_REPETITION_COUNT": "'abc'.repeat(-1);",
- "JSMSG_PRECISION_RANGE": "77.1234.toExponential(-1);",
- };
-
- for (let errorMessageName of Object.keys(ErrorDocStatements)) {
- let title = ErrorDocs.GetURL({ errorMessageName }).split("?")[0];
-
- jsterm.clearOutput();
- yield jsterm.execute(ErrorDocStatements[errorMessageName]);
- yield checkResult((node) => {
- return node.parentNode.getElementsByTagName("a")[0].title == title;
- }, `error links to ${title}`);
- }
-
- // Ensure that dom errors, with error numbers outside of the range
- // of valid js.msg errors, don't cause crashes (bug 1270721).
- yield jsterm.execute("new Request('',{redirect:'foo'})");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_live_filtering_of_message_types.js
+++ /dev/null
@@ -1,56 +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/ */
-
-// Tests that the message type filter checkboxes work.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- for (let i = 0; i < 50; i++) {
- content.console.log("foobarz #" + i);
- }
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "foobarz #49",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- is(hud.outputNode.children.length, 50, "number of messages");
-
- hud.setFilterState("log", false);
- is(countMessageNodes(hud), 0, "the log nodes are hidden when the " +
- "corresponding filter is switched off");
-
- hud.setFilterState("log", true);
- is(countMessageNodes(hud), 50, "the log nodes reappear when the " +
- "corresponding filter is switched on");
-});
-
-function countMessageNodes(hud) {
- let messageNodes = hud.outputNode.querySelectorAll(".message");
- let displayedMessageNodes = 0;
- let view = hud.iframeWindow;
- for (let i = 0; i < messageNodes.length; i++) {
- let computedStyle = view.getComputedStyle(messageNodes[i]);
- if (computedStyle.display !== "none") {
- displayedMessageNodes++;
- }
- }
-
- return displayedMessageNodes;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_live_filtering_on_search_strings.js
+++ /dev/null
@@ -1,96 +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/ */
-
-// Tests that the text filter box works.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
- for (let i = 0; i < 50; i++) {
- content.console.log("http://www.example.com/ " + i);
- }
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "http://www.example.com/ 49",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- is(hud.outputNode.children.length, 50, "number of messages");
-
- setStringFilter(hud, "http");
- isnot(countMessageNodes(hud), 0, "the log nodes are not hidden when the " +
- "search string is set to \"http\"");
-
- setStringFilter(hud, "hxxp");
- is(countMessageNodes(hud), 0, "the log nodes are hidden when the search " +
- "string is set to \"hxxp\"");
-
- setStringFilter(hud, "ht tp");
- isnot(countMessageNodes(hud), 0, "the log nodes are not hidden when the " +
- "search string is set to \"ht tp\"");
-
- setStringFilter(hud, " zzzz zzzz ");
- is(countMessageNodes(hud), 0, "the log nodes are hidden when the search " +
- "string is set to \" zzzz zzzz \"");
-
- setStringFilter(hud, "");
- isnot(countMessageNodes(hud), 0, "the log nodes are not hidden when the " +
- "search string is removed");
-
- setStringFilter(hud, "\u9f2c");
- is(countMessageNodes(hud), 0, "the log nodes are hidden when searching " +
- "for weasels");
-
- setStringFilter(hud, "\u0007");
- is(countMessageNodes(hud), 0, "the log nodes are hidden when searching for " +
- "the bell character");
-
- setStringFilter(hud, '"foo"');
- is(countMessageNodes(hud), 0, "the log nodes are hidden when searching for " +
- 'the string "foo"');
-
- setStringFilter(hud, "'foo'");
- is(countMessageNodes(hud), 0, "the log nodes are hidden when searching for " +
- "the string 'foo'");
-
- setStringFilter(hud, "foo\"bar'baz\"boo'");
- is(countMessageNodes(hud), 0, "the log nodes are hidden when searching for " +
- "the string \"foo\"bar'baz\"boo'\"");
-});
-
-function countMessageNodes(hud) {
- let outputNode = hud.outputNode;
-
- let messageNodes = outputNode.querySelectorAll(".message");
- let displayedMessageNodes = 0;
- let view = hud.iframeWindow;
- for (let i = 0; i < messageNodes.length; i++) {
- let computedStyle = view.getComputedStyle(messageNodes[i]);
- if (computedStyle.display !== "none") {
- displayedMessageNodes++;
- }
- }
-
- return displayedMessageNodes;
-}
-
-function setStringFilter(hud, value) {
- hud.ui.filterBox.value = value;
- hud.ui.adjustVisibilityOnSearchStringChange();
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_log_file_filter.js
+++ /dev/null
@@ -1,83 +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/ */
-
-// Tests that the text filter box works to filter based on filenames
-// where the logs were generated.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-bug_923281_console_log_filter.html";
-
-var hud;
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- hud = yield openConsole();
- yield consoleOpened();
-
- testLiveFilteringOnSearchStrings();
-
- hud = null;
-});
-
-async function consoleOpened() {
- await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("sentinel log");
- });
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "sentinel log",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG
- }],
- });
-}
-
-function testLiveFilteringOnSearchStrings() {
- is(hud.outputNode.children.length, 4, "number of messages");
-
- setStringFilter("random");
- is(countMessageNodes(), 1, "the log nodes not containing string " +
- "\"random\" are hidden");
-
- setStringFilter("test2.js");
- is(countMessageNodes(), 2, "show only log nodes containing string " +
- "\"test2.js\" or log nodes created from files with filename " +
- "containing \"test2.js\" as substring.");
-
- setStringFilter("test1");
- is(countMessageNodes(), 2, "show only log nodes containing string " +
- "\"test1\" or log nodes created from files with filename " +
- "containing \"test1\" as substring.");
-
- setStringFilter("");
- is(countMessageNodes(), 4, "show all log nodes on setting filter string " +
- "as \"\".");
-}
-
-function countMessageNodes() {
- let outputNode = hud.outputNode;
-
- let messageNodes = outputNode.querySelectorAll(".message");
- let displayedMessageNodes = 0;
- let view = hud.iframeWindow;
- for (let i = 0; i < messageNodes.length; i++) {
- let computedStyle = view.getComputedStyle(messageNodes[i]);
- if (computedStyle.display !== "none") {
- displayedMessageNodes++;
- }
- }
-
- return displayedMessageNodes;
-}
-
-function setStringFilter(value) {
- hud.ui.filterBox.value = value;
- hud.ui.adjustVisibilityOnSearchStringChange();
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_message_node_id.js
+++ /dev/null
@@ -1,28 +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/ */
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- hud.jsterm.execute("console.log('a log message')");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "a log message",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let msg = [...result.matched][0];
- ok(msg.getAttribute("id"), "log message has an ID");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_multiline_input.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Tests that the console waits for more input instead of evaluating
-// when valid, but incomplete, statements are present upon pressing enter
-// -or- when the user ends a line with shift + enter.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-let SHOULD_ENTER_MULTILINE = [
- {input: "function foo() {" },
- {input: "var a = 1," },
- {input: "var a = 1;", shiftKey: true },
- {input: "function foo() { }", shiftKey: true },
- {input: "function" },
- {input: "(x) =>" },
- {input: "let b = {" },
- {input: "let a = [" },
- {input: "{" },
- {input: "{ bob: 3343," },
- {input: "function x(y=" },
- {input: "Array.from(" },
- // shift + enter creates a new line despite parse errors
- {input: "{2,}", shiftKey: true },
-];
-let SHOULD_EXECUTE = [
- {input: "function foo() { }" },
- {input: "var a = 1;" },
- {input: "function foo() { var a = 1; }" },
- {input: '"asdf"' },
- {input: "99 + 3" },
- {input: "1, 2, 3" },
- // errors
- {input: "function f(x) { let y = 1, }" },
- {input: "function f(x=,) {" },
- {input: "{2,}" },
-];
-
-add_task(function* () {
- let { tab, browser } = yield loadTab(TEST_URI);
- let hud = yield openConsole();
- let inputNode = hud.jsterm.inputNode;
-
- for (let test of SHOULD_ENTER_MULTILINE) {
- hud.jsterm.setInputValue(test.input);
- EventUtils.synthesizeKey("VK_RETURN", { shiftKey: test.shiftKey });
- let inputValue = hud.jsterm.getInputValue();
- is(inputNode.selectionStart, inputNode.selectionEnd,
- "selection is collapsed");
- is(inputNode.selectionStart, inputValue.length,
- "caret at end of multiline input");
- let inputWithNewline = test.input + "\n";
- is(inputValue, inputWithNewline, "Input value is correct");
- }
-
- for (let test of SHOULD_EXECUTE) {
- hud.jsterm.setInputValue(test.input);
- EventUtils.synthesizeKey("VK_RETURN", { shiftKey: test.shiftKey });
-
- yield waitFor(() => !hud.jsterm.getInputValue());
-
- let inputValue = hud.jsterm.getInputValue();
- is(inputNode.selectionStart, 0, "selection starts/ends at 0");
- is(inputNode.selectionEnd, 0, "selection starts/ends at 0");
- is(inputValue, "", "Input value is cleared");
- }
-
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_netlogging.js
+++ /dev/null
@@ -1,140 +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/ */
-
-// Tests response logging for different request types.
-
-"use strict";
-
-// This test runs very slowly on linux32 debug - bug 1269977
-requestLongerTimeout(2);
-
-const TEST_NETWORK_REQUEST_URI =
- "http://example.com/browser/devtools/client/webconsole/old/test/" +
- "test-network-request.html";
-
-const TEST_DATA_JSON_CONTENT =
- '{ id: "test JSON data", myArray: [ "foo", "bar", "baz", "biff" ] }';
-
-const PAGE_REQUEST_PREDICATE =
- ({ request }) => request.url.endsWith("test-network-request.html");
-
-const TEST_DATA_REQUEST_PREDICATE =
- ({ request }) => request.url.endsWith("test-data.json");
-
-add_task(function* testPageLoad() {
- // Enable logging in the UI. Not needed to pass test but makes it easier
- // to debug interactively.
- yield new Promise(resolve => {
- SpecialPowers.pushPrefEnv({"set":
- [["devtools.webconsole.filter.networkinfo", true]
- ]}, resolve);
- });
-
- let finishedRequest = waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
- let hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI);
- let request = yield finishedRequest;
-
- ok(request, "Page load was logged");
-
- let client = hud.ui.webConsoleClient;
- const postData = yield client.getRequestPostData(request.actor);
- const responseContent = yield client.getResponseContent(request.actor);
-
- is(request.request.url, TEST_NETWORK_REQUEST_URI,
- "Logged network entry is page load");
- is(request.request.method, "GET", "Method is correct");
- ok(!postData.postData.text, "No request body was stored");
- ok(!postData.postDataDiscarded,
- "Request body was not discarded");
- is(responseContent.content.text.indexOf("<!DOCTYPE HTML>"), 0,
- "Response body's beginning is okay");
-
- yield closeTabAndToolbox();
-});
-
-add_task(function* testXhrGet() {
- let hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI);
-
- let finishedRequest = waitForFinishedRequest(TEST_DATA_REQUEST_PREDICATE);
- content.wrappedJSObject.testXhrGet();
- let request = yield finishedRequest;
-
- ok(request, "testXhrGet() was logged");
-
- let client = hud.ui.webConsoleClient;
- const postData = yield client.getRequestPostData(request.actor);
- const responseContent = yield client.getResponseContent(request.actor);
-
- is(request.request.method, "GET", "Method is correct");
- ok(!postData.postData.text, "No request body was sent");
- ok(!postData.postDataDiscarded,
- "Request body was not discarded");
- is(responseContent.content.text, TEST_DATA_JSON_CONTENT,
- "Response is correct");
-
- yield closeTabAndToolbox();
-});
-
-add_task(function* testXhrPost() {
- let hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI);
-
- let finishedRequest = waitForFinishedRequest(TEST_DATA_REQUEST_PREDICATE);
- content.wrappedJSObject.testXhrPost();
- let request = yield finishedRequest;
-
- ok(request, "testXhrPost() was logged");
-
- let client = hud.ui.webConsoleClient;
- const postData = yield client.getRequestPostData(request.actor);
- const responseContent = yield client.getResponseContent(request.actor);
-
- is(request.request.method, "POST", "Method is correct");
- is(postData.postData.text, "Hello world!", "Request body was logged");
- is(responseContent.content.text, TEST_DATA_JSON_CONTENT,
- "Response is correct");
-
- yield closeTabAndToolbox();
-});
-
-add_task(function* testFormSubmission() {
- let pageLoadRequestFinished = waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
- let hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI);
-
- info("Waiting for the page load to be finished.");
- yield pageLoadRequestFinished;
-
- // The form POSTs to the page URL but over https (page over http).
- let finishedRequest = waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
- ContentTask.spawn(gBrowser.selectedBrowser, { }, `function()
- {
- let form = content.document.querySelector("form");
- form.submit();
- }`);
- let request = yield finishedRequest;
-
- ok(request, "testFormSubmission() was logged");
-
- let client = hud.ui.webConsoleClient;
- const postData = yield client.getRequestPostData(request.actor);
- const requestHeaders = yield client.getRequestHeaders(request.actor);
- const responseContent = yield client.getResponseContent(request.actor);
-
- let getHeader = name => {
- let header = requestHeaders.headers.find(h => h.name == name);
- return header && header.value;
- };
-
- is(request.request.method, "POST", "Method is correct");
- is(getHeader("Content-Type"), "application/x-www-form-urlencoded",
- "Content-Type is correct");
- is(getHeader("Content-Length"), "20",
- "Content-length is correct");
- isnot(postData.postData.text
- .indexOf("name=foo+bar&age=144"), -1, "Form data is correct");
- is(responseContent.content.text.indexOf("<!DOCTYPE HTML>"), 0,
- "Response body's beginning is okay");
-
- yield closeTabAndToolbox();
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_netlogging_basic.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Tests that the page's resources are displayed in the console as they're
-// loaded
-
-"use strict";
-
-const TEST_NETWORK_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-network.html" + "?_date=" +
- Date.now();
-
-add_task(function* () {
- yield loadTab("data:text/html;charset=utf-8,Web Console basic network " +
- "logging test");
- let hud = yield openConsole();
-
- yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_NETWORK_URI);
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "running network console",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-network.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "testscript.js",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-image.png",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_netlogging_panel.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Tests that network log messages bring up the network panel.
-
-"use strict";
-
-const TEST_NETWORK_REQUEST_URI =
- "http://example.com/browser/devtools/client/webconsole/old/test/" +
- "test-network-request.html";
-
-add_task(function* () {
- let finishedRequest = waitForFinishedRequest(({ request }) => {
- return request.url.endsWith("test-network-request.html");
- });
-
- const hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI);
- let request = yield finishedRequest;
-
- yield hud.ui.openNetworkPanel(request.actor);
- let toolbox = gDevTools.getToolbox(hud.target);
- is(toolbox.currentToolId, "netmonitor", "Network panel was opened");
- let monitor = toolbox.getCurrentPanel();
-
- let { store, windowRequire } = monitor.panelWin;
- let { getSelectedRequest } =
- windowRequire("devtools/client/netmonitor/src/selectors/index");
-
- let selected = getSelectedRequest(store.getState());
- is(selected.method, request.request.method,
- "The correct request is selected");
- is(selected.url, request.request.url,
- "The correct request is definitely selected");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_netlogging_reset_filter.js
+++ /dev/null
@@ -1,97 +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/ */
-
-// Tests that network log messages bring up the network panel and select the
-// right request even if it was previously filtered off.
-
-"use strict";
-
-const TEST_FILE_URI =
- "http://example.com/browser/devtools/client/webconsole/old/test/" +
- "test-network.html";
-const TEST_URI = "data:text/html;charset=utf8,<p>test file URI";
-
-var hud;
-
-add_task(function* () {
- let requests = [];
- let { browser } = yield loadTab(TEST_URI);
-
- yield pushPrefEnv();
- hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- HUDService.lastFinishedRequest.callback = request => requests.push(request);
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_FILE_URI);
- yield loaded;
-
- yield testMessages();
- let htmlRequest = requests.find(e => e.request.url.endsWith("html"));
- ok(htmlRequest, "htmlRequest was a html");
-
- yield hud.ui.openNetworkPanel(htmlRequest.actor);
- let toolbox = gDevTools.getToolbox(hud.target);
- is(toolbox.currentToolId, "netmonitor", "Network panel was opened");
-
- let monitor = toolbox.getCurrentPanel();
- let { store, windowRequire } = monitor.panelWin;
- let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
- let { getSelectedRequest } = windowRequire("devtools/client/netmonitor/src/selectors/index");
-
- let selected = getSelectedRequest(store.getState());
- is(selected.method, htmlRequest.request.method,
- "The correct request is selected");
- is(selected.url, htmlRequest.request.url,
- "The correct request is definitely selected");
-
- // Filter out the HTML request.
- store.dispatch(Actions.toggleRequestFilterType("js"));
-
- yield toolbox.selectTool("webconsole");
- is(toolbox.currentToolId, "webconsole", "Web console was selected");
- yield hud.ui.openNetworkPanel(htmlRequest.actor);
-
- selected = getSelectedRequest(store.getState());
- is(selected.method, htmlRequest.request.method,
- "The correct request is selected");
- is(selected.url, htmlRequest.request.url,
- "The correct request is definitely selected");
-
- // All tests are done. Shutdown.
- HUDService.lastFinishedRequest.callback = null;
- htmlRequest = browser = requests = hud = null;
-});
-
-function testMessages() {
- return waitForMessages({
- webconsole: hud,
- messages: [{
- text: "running network console logging tests",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "test-network.html",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- },
- {
- text: "testscript.js",
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-}
-
-function pushPrefEnv() {
- let deferred = defer();
- let options = {
- set: [["devtools.webconsole.filter.networkinfo", true]]
- };
- SpecialPowers.pushPrefEnv(options, deferred.resolve);
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_notifications.js
+++ /dev/null
@@ -1,79 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for " +
- "notifications";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let consoleOpened = defer();
- let gotEvents = waitForEvents(consoleOpened.promise);
- yield openConsole().then(() => {
- consoleOpened.resolve();
- });
-
- yield gotEvents;
-});
-
-function waitForEvents(onConsoleOpened) {
- let deferred = defer();
-
- function webConsoleCreated(id) {
- Services.obs.removeObserver(observer, "web-console-created");
- ok(HUDService.getHudReferenceById(id), "We have a hud reference");
- ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("adding a log message");
- });
- }
-
- function webConsoleDestroyed(id) {
- Services.obs.removeObserver(observer, "web-console-destroyed");
- ok(!HUDService.getHudReferenceById(id), "We do not have a hud reference");
- executeSoon(deferred.resolve);
- }
-
- function webConsoleMessage(id, nodeID) {
- Services.obs.removeObserver(observer, "web-console-message-created");
- ok(id, "we have a console ID");
- is(typeof nodeID, "string", "message node id is a string");
- onConsoleOpened.then(closeConsole);
- }
-
- let observer = {
-
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
-
- observe: function observe(subject, topic, data) {
- subject = subject.QueryInterface(Ci.nsISupportsString);
-
- switch (topic) {
- case "web-console-created":
- webConsoleCreated(subject.data);
- break;
- case "web-console-destroyed":
- webConsoleDestroyed(subject.data);
- break;
- case "web-console-message-created":
- webConsoleMessage(subject, data);
- break;
- default:
- break;
- }
- },
-
- init: function init() {
- Services.obs.addObserver(this, "web-console-created");
- Services.obs.addObserver(this, "web-console-destroyed");
- Services.obs.addObserver(this, "web-console-message-created");
- }
- };
-
- observer.init();
-
- return deferred.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_open-links-without-callback.js
+++ /dev/null
@@ -1,54 +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/ */
-
-// Tests that if a link without an onclick callback is clicked the link is
-// opened in a new tab and no exception occurs (bug 999236).
-
-"use strict";
-
-function test() {
- function* runner() {
- const TEST_EVAL_STRING = "document";
- const TEST_PAGE_URI = "http://example.com/browser/devtools/client/" +
- "webconsole/old/test/test-console.html";
- const {tab} = yield loadTab(TEST_PAGE_URI);
- const hud = yield openConsole(tab);
-
- hud.jsterm.execute(TEST_EVAL_STRING);
-
- const EXPECTED_OUTPUT = new RegExp("HTMLDocument \.+");
-
- let messages = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "JS eval output",
- text: EXPECTED_OUTPUT,
- category: CATEGORY_OUTPUT,
- }],
- });
-
- let messageNode = messages[0].matched.values().next().value;
-
- // The correct anchor is second in the message node; the first anchor has
- // class .cm-variable. Ignore the first one by not matching anchors that
- // have the class .cm-variable.
- let urlNode = messageNode.querySelector("a:not(.cm-variable)");
-
- let linkOpened = false;
- let oldOpenWebLinkIn = window.openWebLinkIn;
- window.openWebLinkIn = function (aLink) {
- if (aLink == TEST_PAGE_URI) {
- linkOpened = true;
- }
- };
-
- EventUtils.synthesizeMouseAtCenter(urlNode, {}, hud.iframeWindow);
-
- ok(linkOpened, "Clicking the URL opens the desired page");
- window.openWebLinkIn = oldOpenWebLinkIn;
- }
-
- Task.spawn(runner).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_01.js
+++ /dev/null
@@ -1,120 +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/ */
-
-// Whitelisting this test.
-// As part of bug 1077403, the leaking uncaught rejection should be fixed.
-//
-
-"use strict";
-
-// Test the webconsole output for various types of objects.
-
-const TEST_URI = "data:text/html;charset=utf8,test for console output - 01";
-
-var {DebuggerServer} = require("devtools/server/main");
-
-var longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
-var initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
-
-var inputTests = [
- // 0
- {
- input: "'hello \\nfrom \\rthe \\\"string world!'",
- output: "\"hello \nfrom \rthe \"string world!\"",
- consoleOutput: "hello \nfrom \rthe \"string world!",
- },
-
- // 1
- {
- // unicode test
- input: "'\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165'",
- output: "\"\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165\"",
- consoleOutput: "\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165",
- },
-
- // 2
- {
- input: "'" + longString + "'",
- output: '"' + initialString + "\"[\u2026]",
- consoleOutput: initialString + "[\u2026]",
- printOutput: initialString,
- },
-
- // 3
- {
- input: "''",
- output: '""',
- consoleOutput: "",
- printOutput: '""',
- },
-
- // 4
- {
- input: "0",
- output: "0",
- },
-
- // 5
- {
- input: "'0'",
- output: '"0"',
- consoleOutput: "0",
- },
-
- // 6
- {
- input: "42",
- output: "42",
- },
-
- // 7
- {
- input: "'42'",
- output: '"42"',
- consoleOutput: "42",
- },
-
- // 8
- {
- input: "/foobar/",
- output: "/foobar/",
- inspectable: true,
- },
-
- // 9
- {
- input: "Symbol()",
- output: "Symbol()"
- },
-
- // 10
- {
- input: "Symbol('foo')",
- output: "Symbol(foo)"
- },
-
- // 11
- {
- input: "Symbol.iterator",
- output: "Symbol(Symbol.iterator)"
- },
-];
-
-longString = initialString = null;
-
-function test() {
- requestLongerTimeout(2);
-
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- return checkOutputForInputs(hud, inputTests);
- }).then(finishUp);
-}
-
-function finishUp() {
- longString = initialString = inputTests = null;
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_02.js
+++ /dev/null
@@ -1,183 +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 the webconsole output for various types of objects.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-02.html";
-
-var inputTests = [
- // 0 - native named function
- {
- input: "document.getElementById",
- output: "function getElementById()",
- printOutput: "function getElementById() {\n [native code]\n}",
- inspectable: true,
- variablesViewLabel: "getElementById()",
- },
-
- // 1 - anonymous function
- {
- input: "(function() { return 42; })",
- output: "function ()",
- printOutput: "function() { return 42; }",
- suppressClick: true
- },
-
- // 2 - named function
- {
- input: "window.testfn1",
- output: "function testfn1()",
- printOutput: "function testfn1() { return 42; }",
- suppressClick: true
- },
-
- // 3 - anonymous function, but gets name.
- {
- input: "testobj1.testfn2",
- output: "function testfn2()",
- printOutput: "function() { return 42; }",
- suppressClick: true
- },
-
- // 4 - named function with custom display name
- {
- input: "window.testfn3",
- output: "function testfn3DisplayName()",
- printOutput: "function testfn3() { return 42; }",
- suppressClick: true
- },
-
- // 5 - basic array
- {
- input: "window.array1",
- output: 'Array [ 1, 2, 3, "a", "b", "c", "4", "5" ]',
- printOutput: "1,2,3,a,b,c,4,5",
- inspectable: true,
- variablesViewLabel: "Array[8]",
- },
-
- // 6 - array with objects
- {
- input: "window.array2",
- output: 'Array [ "a", HTMLDocument \u2192 test-console-output-02.html, ' +
- "<body>, DOMStringMap[0], DOMTokenList[0] ]",
- printOutput: '"a,[object HTMLDocument],[object HTMLBodyElement],' +
- '[object DOMStringMap],"',
- inspectable: true,
- variablesViewLabel: "Array[5]",
- },
-
- // 7 - array with more than 10 elements
- {
- input: "window.array3",
- output: "Array [ 1, Window \u2192 test-console-output-02.html, null, " +
- '"a", "b", undefined, false, "", -Infinity, ' +
- "testfn3DisplayName(), 3 more\u2026 ]",
- printOutput: '"1,[object Window],,a,b,,false,,-Infinity,' +
- 'function testfn3() { return 42; },[object Object],foo,bar"',
- inspectable: true,
- variablesViewLabel: "Array[13]",
- },
-
- // 8 - array with holes and a cyclic reference
- {
- input: "window.array4",
- output: 'Array [ <5 empty slots>, "test", Array[7] ]',
- printOutput: '",,,,,test,"',
- inspectable: true,
- variablesViewLabel: "Array[7]",
- },
-
- // 9
- {
- input: "window.typedarray1",
- output: "Int32Array [ 1, 287, 8651, 40983, 8754 ]",
- printOutput: "1,287,8651,40983,8754",
- inspectable: true,
- variablesViewLabel: "Int32Array[5]",
- },
-
- // 10 - Set with cyclic reference
- {
- input: "window.set1",
- output: 'Set [ 1, 2, null, Array[13], "a", "b", undefined, <head>, ' +
- "Set[9] ]",
- printOutput: "[object Set]",
- inspectable: true,
- variablesViewLabel: "Set[9]",
- },
-
- // 11 - Object with cyclic reference and a getter
- {
- input: "window.testobj2",
- output: 'Object { a: "b", c: "d", e: 1, f: "2", foo: Object, ' +
- "bar: Object, getterTest: Getter }",
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 12 - Object with more than 10 properties
- {
- input: "window.testobj3",
- output: 'Object { a: "b", c: "d", e: 1, f: "2", g: true, h: null, ' +
- 'i: undefined, j: "", k: StyleSheetList[0], l: NodeList[5], ' +
- "2 more\u2026 }",
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 13 - Object with a non-enumerable property that we do not show
- {
- input: "window.testobj4",
- output: 'Object { a: "b", c: "d", 1 more\u2026 }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 14 - Map with cyclic references
- {
- input: "window.map1",
- output: 'Map { a: "b", HTMLCollection[2]: Object, Map[3]: Set[9] }',
- printOutput: "[object Map]",
- inspectable: true,
- variablesViewLabel: "Map[3]",
- },
-
- // 15 - WeakSet
- {
- input: "window.weakset",
- // Need a regexp because the order may vary.
- output: new RegExp("WeakSet \\[ (String, <head>|<head>, String) \\]"),
- printOutput: "[object WeakSet]",
- inspectable: true,
- variablesViewLabel: "WeakSet[2]",
- },
-
- // 16 - WeakMap
- {
- input: "window.weakmap",
- // Need a regexp because the order may vary.
- output: new RegExp("WeakMap { (String: 23, HTMLCollection\\[2\\]: Object|HTMLCollection\\[2\\]: Object, String: 23) }"),
- printOutput: "[object WeakMap]",
- inspectable: true,
- variablesViewLabel: "WeakMap[2]",
- },
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
- yield checkOutputForInputs(hud, inputTests);
- inputTests = null;
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_03.js
+++ /dev/null
@@ -1,168 +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 the webconsole output for various types of objects.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-03.html";
-
-var inputTests = [
-
- // 0
- {
- input: "document",
- output: "HTMLDocument \u2192 " + TEST_URI,
- printOutput: "[object HTMLDocument]",
- inspectable: true,
- noClick: true,
- },
-
- // 1
- {
- input: "window",
- output: "Window \u2192 " + TEST_URI,
- printOutput: "[object Window",
- inspectable: true,
- noClick: true,
- },
-
- // 2
- {
- input: "document.body",
- output: "<body>",
- printOutput: "[object HTMLBodyElement]",
- inspectable: true,
- noClick: true,
- },
-
- // 3
- {
- input: "document.body.dataset",
- output: "DOMStringMap { }",
- printOutput: "[object DOMStringMap]",
- inspectable: true,
- variablesViewLabel: "DOMStringMap[0]",
- },
-
- // 4
- {
- input: "document.body.classList",
- output: "DOMTokenList [ ]",
- printOutput: '""',
- inspectable: true,
- variablesViewLabel: "DOMTokenList[0]",
- },
-
- // 5
- {
- input: "window.location.href",
- output: '"' + TEST_URI + '"',
- noClick: true,
- },
-
- // 6
- {
- input: "window.location",
- output: "Location \u2192 " + TEST_URI,
- printOutput: TEST_URI,
- inspectable: true,
- variablesViewLabel: "Location \u2192 test-console-output-03.html",
- },
-
- // 7
- {
- input: "document.body.attributes",
- output: "NamedNodeMap [ ]",
- printOutput: "[object NamedNodeMap]",
- inspectable: true,
- variablesViewLabel: "NamedNodeMap[0]",
- },
-
- // 8
- {
- input: "document.styleSheets",
- output: "StyleSheetList [ ]",
- printOutput: "[object StyleSheetList",
- inspectable: true,
- variablesViewLabel: "StyleSheetList[0]",
- },
-
- // 9
- {
- input: "testBodyClassName()",
- output: '<body class="test1 tezt2">',
- printOutput: "[object HTMLBodyElement]",
- inspectable: true,
- noClick: true,
- },
-
- // 10
- {
- input: "testBodyID()",
- output: '<body class="test1 tezt2" id="foobarid">',
- printOutput: "[object HTMLBodyElement]",
- inspectable: true,
- noClick: true,
- },
-
- // 11
- {
- input: "document.body.classList",
- output: 'DOMTokenList [ "test1", "tezt2" ]',
- printOutput: '"test1 tezt2"',
- inspectable: true,
- variablesViewLabel: "DOMTokenList[2]",
- },
-
- // 12
- {
- input: "testBodyDataset()",
- output: '<body class="test1 tezt2" id="foobarid"' +
- ' data-preview="zuzu"<a>foo">',
- printOutput: "[object HTMLBodyElement]",
- inspectable: true,
- noClick: true,
- },
-
- // 13
- {
- input: "document.body.dataset",
- output: 'DOMStringMap { preview: "zuzu"<a>foo" }',
- printOutput: "[object DOMStringMap]",
- inspectable: true,
- variablesViewLabel: "DOMStringMap[1]",
- },
-
- // 14
- {
- input: "document.body.attributes",
- output: 'NamedNodeMap [ class="test1 tezt2", id="foobarid", ' +
- 'data-preview="zuzu"<a>foo" ]',
- printOutput: "[object NamedNodeMap]",
- inspectable: true,
- variablesViewLabel: "NamedNodeMap[3]",
- },
-
- // 15
- {
- input: "document.body.attributes[0]",
- output: 'class="test1 tezt2"',
- printOutput: "[object Attr]",
- inspectable: true,
- variablesViewLabel: 'class="test1 tezt2"',
- },
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
- yield checkOutputForInputs(hud, inputTests);
- inputTests = null;
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_04.js
+++ /dev/null
@@ -1,127 +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/ */
-
-// Whitelisting this test.
-// As part of bug 1077403, the leaking uncaught rejection should be fixed.
-//
-
-"use strict";
-
-// Test the webconsole output for various types of objects.
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-04.html";
-
-var inputTests = [
- // 0
- {
- input: "testTextNode()",
- output: '#text "hello world!"',
- printOutput: "[object Text]",
- inspectable: true,
- noClick: true,
- },
-
- // 1
- {
- input: "testCommentNode()",
- output: /<!--\s+- Any copyright /,
- printOutput: "[object Comment]",
- inspectable: true,
- noClick: true,
- },
-
- // 2
- {
- input: "testDocumentFragment()",
- output: "DocumentFragment [ <div#foo1.bar>, <div#foo3> ]",
- printOutput: "[object DocumentFragment]",
- inspectable: true,
- variablesViewLabel: "DocumentFragment[2]",
- },
-
- // 3
- {
- input: "testError()",
- output: "TypeError: window.foobar is not a function\n" +
- "Stack trace:\n" +
- "testError@" + TEST_URI + ":44",
- printOutput: '"TypeError: window.foobar is not a function"',
- inspectable: true,
- variablesViewLabel: "TypeError",
- },
-
- // 4
- {
- input: "testDOMException()",
- output: `DOMException [SyntaxError: "'foo;()bar!' is not a valid selector"`,
- printOutput: `"SyntaxError: 'foo;()bar!' is not a valid selector"`,
- inspectable: true,
- variablesViewLabel: "SyntaxError",
- },
-
- // 5
- {
- input: "testCSSStyleDeclaration()",
- output: 'CSS2Properties { color: "green", font-size: "2em" }',
- printOutput: "[object CSS2Properties]",
- inspectable: true,
- noClick: true,
- },
-
- // 6
- {
- input: "testStyleSheetList()",
- output: "StyleSheetList [ CSSStyleSheet ]",
- printOutput: "[object StyleSheetList",
- inspectable: true,
- variablesViewLabel: "StyleSheetList[1]",
- },
-
- // 7
- {
- input: "document.styleSheets[0]",
- output: "CSSStyleSheet",
- printOutput: "[object CSSStyleSheet]",
- inspectable: true,
- },
-
- // 8
- {
- input: "document.styleSheets[0].cssRules",
- output: "CSSRuleList [ CSSStyleRule, CSSMediaRule ]",
- printOutput: "[object CSSRuleList",
- inspectable: true,
- variablesViewLabel: "CSSRuleList[2]",
- },
-
- // 9
- {
- input: "document.styleSheets[0].cssRules[0]",
- output: 'CSSStyleRule "p, div"',
- printOutput: "[object CSSStyleRule",
- inspectable: true,
- variablesViewLabel: "CSSStyleRule",
- },
-
- // 10
- {
- input: "document.styleSheets[0].cssRules[1]",
- output: 'CSSMediaRule "print"',
- printOutput: "[object CSSMediaRule",
- inspectable: true,
- variablesViewLabel: "CSSMediaRule",
- },
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- const {tab} = yield loadTab(TEST_URI);
- const hud = yield openConsole(tab);
- yield checkOutputForInputs(hud, inputTests);
- inputTests = null;
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_05.js
+++ /dev/null
@@ -1,168 +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 the webconsole output for various types of objects.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,test for console output - 05";
-const {ELLIPSIS} = require("devtools/shared/l10n");
-
-// March, 1960: The first implementation of Lisp. From Wikipedia:
-//
-// > Lisp was first implemented by Steve Russell on an IBM 704 computer. Russell
-// > had read McCarthy's paper, and realized (to McCarthy's surprise) that the
-// > Lisp eval function could be implemented in machine code. The result was a
-// > working Lisp interpreter which could be used to run Lisp programs, or more
-// > properly, 'evaluate Lisp expressions.'
-var testDate = -310435200000;
-
-var inputTests = [
- // 0
- {
- input: "/foo?b*\\s\"ar/igym",
- output: "/foo?b*\\s\"ar/gimy",
- printOutput: "/foo?b*\\s\"ar/gimy",
- inspectable: true,
- },
-
- // 1
- {
- input: "null",
- output: "null",
- },
-
- // 2
- {
- input: "undefined",
- output: "undefined",
- },
-
- // 3
- {
- input: "true",
- output: "true",
- },
-
- // 4
- {
- input: "new Boolean(false)",
- output: "Boolean { false }",
- printOutput: "false",
- inspectable: true,
- variablesViewLabel: "Boolean { false }"
- },
-
- // 5
- {
- input: "new Date(" + testDate + ")",
- output: "Date " + (new Date(testDate)).toISOString(),
- printOutput: (new Date(testDate)).toString(),
- inspectable: true,
- },
-
- // 6
- {
- input: "new Date('test')",
- output: "Invalid Date",
- printOutput: "Invalid Date",
- inspectable: true,
- variablesViewLabel: "Invalid Date",
- },
-
- // 7
- {
- input: "new Number(43)",
- output: "Number { 43 }",
- printOutput: "43",
- inspectable: true,
- variablesViewLabel: "Number { 43 }"
- },
-
- // 8
- {
- input: "new String('hello')",
- output: /String { "hello", 6 more.* }/,
- printOutput: "hello",
- inspectable: true,
- variablesViewLabel: "String"
- },
-
- // 9
- {
- input: "(function () { var s = new String('hello'); s.whatever = 23; " +
- " return s;})()",
- output: /String { "hello", whatever: 23, 6 more.* }/,
- printOutput: "hello",
- inspectable: true,
- variablesViewLabel: "String"
- },
-
- // 10
- {
- input: "(function () { var s = new String('hello'); s[8] = 'x'; " +
- " return s;})()",
- output: /String { "hello", 8: "x", 6 more.* }/,
- printOutput: "hello",
- inspectable: true,
- variablesViewLabel: "String"
- },
-
- // 11
- {
- // XXX: Can't test fulfilled and rejected promises, because promises get
- // settled on the next tick of the event loop.
- input: "new Promise(function () {})",
- output: 'Promise { <state>: "pending" }',
- printOutput: "[object Promise]",
- inspectable: true,
- variablesViewLabel: "Promise"
- },
-
- // 12
- {
- input: "(function () { var p = new Promise(function () {}); " +
- "p.foo = 1; return p; }())",
- output: 'Promise { <state>: "pending", foo: 1 }',
- printOutput: "[object Promise]",
- inspectable: true,
- variablesViewLabel: "Promise"
- },
-
- // 13
- {
- input: "new Object({0: 'this\\nis\\nsupposed\\nto\\nbe\\na\\nvery" +
- "\\nlong\\nstring\\n,shown\\non\\na\\nsingle\\nline', " +
- "1: 'a shorter string', 2: 100})",
- output: '[ "this is supposed to be a very long ' + ELLIPSIS +
- '", "a shorter string", 100 ]',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object[3]"
- },
-
- // 14
- {
- input: "new Proxy({a:1},[1,2,3])",
- output: 'Proxy { <target>: Object, <handler>: Array[3] }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Proxy"
- }
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- return checkOutputForInputs(hud, inputTests);
- }).then(finishUp);
-}
-
-function finishUp() {
- inputTests = testDate = null;
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_06.js
+++ /dev/null
@@ -1,229 +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/ */
-
-"use strict";
-
-// Test the webconsole output for various arrays.
-
-const TEST_URI = "data:text/html;charset=utf8,test for console output - 06";
-const {ELLIPSIS} = require("devtools/shared/l10n");
-
-const testStrIn = "SHOW\\nALL\\nOF\\nTHIS\\nON\\nA\\nSINGLE" +
- "\\nLINE ONLY. ESCAPE ALL NEWLINE";
-const testStrOut = "SHOW ALL OF THIS ON A SINGLE LINE O" + ELLIPSIS;
-
-var inputTests = [
- // 1 - array with empty slots only
- {
- input: "Array(5)",
- output: "Array [ <5 empty slots> ]",
- printOutput: ",,,,",
- inspectable: true,
- variablesViewLabel: "Array[5]",
- },
- // 2 - array with one empty slot at the beginning
- {
- input: "[,1,2,3]",
- output: "Array [ <1 empty slot>, 1, 2, 3 ]",
- printOutput: ",1,2,3",
- inspectable: true,
- variablesViewLabel: "Array[4]",
- },
- // 3 - array with multiple consecutive empty slots at the beginning
- {
- input: "[,,,3,4,5]",
- output: "Array [ <3 empty slots>, 3, 4, 5 ]",
- printOutput: ",,,3,4,5",
- inspectable: true,
- variablesViewLabel: "Array[6]",
- },
- // 4 - array with one empty slot at the middle
- {
- input: "[0,1,,3,4,5]",
- output: "Array [ 0, 1, <1 empty slot>, 3, 4, 5 ]",
- printOutput: "0,1,,3,4,5",
- inspectable: true,
- variablesViewLabel: "Array[6]",
- },
- // 5 - array with multiple successive empty slots at the middle
- {
- input: "[0,1,,,,5]",
- output: "Array [ 0, 1, <3 empty slots>, 5 ]",
- printOutput: "0,1,,,,5",
- inspectable: true,
- variablesViewLabel: "Array[6]",
- },
- // 6 - array with multiple non successive single empty slots
- {
- input: "[0,,2,,4,5]",
- output: "Array [ 0, <1 empty slot>, 2, <1 empty slot>, 4, 5 ]",
- printOutput: "0,,2,,4,5",
- inspectable: true,
- variablesViewLabel: "Array[6]",
- },
- // 7 - array with multiple multi-slot holes
- {
- input: "[0,,,3,,,,7,8]",
- output: "Array [ 0, <2 empty slots>, 3, <3 empty slots>, 7, 8 ]",
- printOutput: "0,,,3,,,,7,8",
- inspectable: true,
- variablesViewLabel: "Array[9]",
- },
- // 8 - array with a single slot hole at the end
- {
- input: "[0,1,2,3,4,,]",
- output: "Array [ 0, 1, 2, 3, 4, <1 empty slot> ]",
- printOutput: "0,1,2,3,4,",
- inspectable: true,
- variablesViewLabel: "Array[6]",
- },
- // 9 - array with multiple consecutive empty slots at the end
- {
- input: "[0,1,2,,,,]",
- output: "Array [ 0, 1, 2, <3 empty slots> ]",
- printOutput: "0,1,2,,,",
- inspectable: true,
- variablesViewLabel: "Array[6]",
- },
-
- // 10 - array with members explicitly set to null
- {
- input: "[0,null,null,3,4,5]",
- output: "Array [ 0, null, null, 3, 4, 5 ]",
- printOutput: "0,,,3,4,5",
- inspectable: true,
- variablesViewLabel: "Array[6]"
- },
-
- // 11 - array with members explicitly set to undefined
- {
- input: "[0,undefined,undefined,3,4,5]",
- output: "Array [ 0, undefined, undefined, 3, 4, 5 ]",
- printOutput: "0,,,3,4,5",
- inspectable: true,
- variablesViewLabel: "Array[6]"
- },
-
- // 12 - array with long strings as elements
- {
- input: '["' + testStrIn + '", "' + testStrIn + '", "' + testStrIn + '"]',
- output: 'Array [ "' + testStrOut + '", "' + testStrOut + '", "' +
- testStrOut + '" ]',
- inspectable: true,
- printOutput: "SHOW\nALL\nOF\nTHIS\nON\nA\nSINGLE\nLINE ONLY. ESCAPE " +
- "ALL NEWLINE,SHOW\nALL\nOF\nTHIS\nON\nA\nSINGLE\nLINE ONLY. " +
- "ESCAPE ALL NEWLINE,SHOW\nALL\nOF\nTHIS\nON\nA\nSINGLE\n" +
- "LINE ONLY. ESCAPE ALL NEWLINE",
- variablesViewLabel: "Array[3]"
- },
-
- // 13
- {
- input: '({0: "a", 1: "b"})',
- output: 'Object [ "a", "b" ]',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object[2]",
- },
-
- // 14
- {
- input: '({0: "a", 1: "b", 2: "c", 3: "d", 4: "e", 5: "f", 6: "g", ' +
- '7: "h", 8: "i", 9: "j", 10: "k", 11: "l"})',
- output: 'Object [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ' +
- "2 more\u2026 ]",
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object[12]",
- },
-
- // 15
- {
- input: '({0: "a", 1: "b", 2: "c", 3: "d", 4: "e", 5: "f", 6: "g", ' +
- '7: "h", 8: "i", 9: "j", 10: "k", 11: "l", m: "n"})',
- output: 'Object { 0: "a", 1: "b", 2: "c", 3: "d", 4: "e", 5: "f", ' +
- '6: "g", 7: "h", 8: "i", 9: "j", 3 more\u2026 }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 16
- {
- input: '({" ": "a"})',
- output: 'Object { : "a" }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 17
- {
- input: '({})',
- output: 'Object { }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 18
- {
- input: '({0: "a", 1: "b", length: 2})',
- output: 'Object [ "a", "b" ]',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object[2]",
- },
-
- // 19
- {
- input: '({0: "a", 2: "b", length: 2})',
- output: 'Object { 0: "a", 2: "b", length: 2 }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 20
- {
- input: '({0: "a", b: "b", length: 1})',
- output: 'Object { 0: "a", b: "b", length: 1 }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 21
- {
- input: '({0: "a", b: "b", length: 2})',
- output: 'Object { 0: "a", b: "b", length: 2 }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-
- // 22
- {
- input: '({42: "a"})',
- output: 'Object { 42: "a" }',
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object",
- },
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- return checkOutputForInputs(hud, inputTests);
- }).then(finishUp);
-}
-
-function finishUp() {
- inputTests = null;
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_copy_newlines.js
+++ /dev/null
@@ -1,68 +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 that multiple messages are copied into the clipboard and that they are
-// separated by new lines. See bug 916997.
-
-"use strict";
-
-add_task(function* () {
- const TEST_URI = "data:text/html;charset=utf8,<p>hello world, bug 916997";
-
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
- hud.jsterm.clearOutput();
-
- let controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
-
- yield ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.console.log("Hello world! bug916997a");
- content.console.log("Hello world 2! bug916997b");
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Hello world! bug916997a",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }, {
- text: "Hello world 2! bug916997b",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- hud.ui.output.selectAllMessages();
- hud.outputNode.focus();
-
- goUpdateCommand("cmd_copy");
- controller = top.document.commandDispatcher
- .getControllerForCommand("cmd_copy");
- is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
-
- let selection = hud.iframeWindow.getSelection() + "";
- info("selection '" + selection + "'");
-
- let clipboardValue = yield SimpleTest.promiseClipboardChange(str => {
- return str.indexOf("bug916997a") > -1 && str.indexOf("bug916997b") > -1;
- },
- () => {
- goDoCommand("cmd_copy");
- }
- );
-
- let lines = clipboardValue.trim().split("\n");
- is(hud.outputNode.children.length, 2, "number of messages");
- is(lines.length, hud.outputNode.children.length, "number of lines");
- isnot(lines[0].indexOf("bug916997a"), -1,
- "first message text includes 'bug916997a'");
- isnot(lines[1].indexOf("bug916997b"), -1,
- "second message text includes 'bug916997b'");
- is(lines[0].indexOf("bug916997b"), -1,
- "first message text does not include 'bug916997b'");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_dom_elements_01.js
+++ /dev/null
@@ -1,123 +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/ */
-
-// Whitelisting this test.
-// As part of bug 1077403, the leaking uncaught rejections should be fixed.
-
-"use strict";
-
-// Test the webconsole output for various types of DOM Nodes.
-
-// There are shutdown issues for which multiple rejections are left uncaught.
-// See bug 1018184 for resolving these issues.
-const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
-PromiseTestUtils.whitelistRejectionsGlobally(/this\.toolbox is null/);
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-dom-elements.html";
-
-var inputTests = [
- {
- input: "testBodyNode()",
- output: '<body class="body-class" id="body-id">',
- printOutput: "[object HTMLBodyElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: true
- },
-
- {
- input: "testDocumentElement()",
- output: '<html dir="ltr" lang="en-US">',
- printOutput: "[object HTMLHtmlElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: true
- },
-
- {
- input: "testDocument()",
- output: "HTMLDocument \u2192 " + TEST_URI,
- printOutput: "[object HTMLDocument]",
- inspectable: true,
- noClick: true,
- inspectorIcon: false
- },
-
- {
- input: "testNode()",
- output: '<p some-attribute="some-value">',
- printOutput: "[object HTMLParagraphElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: true
- },
-
- {
- input: "testNodeList()",
- output: "NodeList [ <p>, <p#lots-of-attributes>, <iframe>, " +
- "<div.some.classname.here.with.more.classnames.here>, " +
- "<svg>, <clipPath>, <rect>, <script> ]",
- printOutput: "[object NodeList]",
- inspectable: true,
- noClick: true,
- inspectorIcon: true
- },
-
- {
- input: "testNodeInIframe()",
- output: "<p>",
- printOutput: "[object HTMLParagraphElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: true
- },
-
- {
- input: "testLotsOfAttributes()",
- output: '<p id="lots-of-attributes" a="" b="" c="" d="" e="" f="" g="" ' +
- 'h="" i="" j="" k="" l="" m="" n="">',
- printOutput: "[object HTMLParagraphElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: true
- },
-
- {
- input: "testDocumentFragment()",
- output: "DocumentFragment [ <span.foo>, <div#fragdiv> ]",
- printOutput: "[object DocumentFragment]",
- inspectable: true,
- noClick: true,
- inspectorIcon: false
- },
-
- {
- input: "testNodeInDocumentFragment()",
- output: '<span class="foo" data-lolz="hehe">',
- printOutput: "[object HTMLSpanElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: false
- },
-
- {
- input: "testUnattachedNode()",
- output: '<p class="such-class" data-data="such-data">',
- printOutput: "[object HTMLParagraphElement]",
- inspectable: true,
- noClick: true,
- inspectorIcon: false
- },
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- yield checkOutputForInputs(hud, inputTests);
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_dom_elements_02.js
+++ /dev/null
@@ -1,66 +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 the inspector links in the webconsole output for DOM Nodes actually
-// open the inspector and select the right node.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-dom-elements.html";
-
-const TEST_DATA = [
- {
- // The first test shouldn't be returning the body element as this is the
- // default selected node, so re-selecting it won't fire the
- // inspector-updated event
- input: "testNode()",
- output: '<p some-attribute="some-value">',
- displayName: "p",
- attrs: [{name: "some-attribute", value: "some-value"}]
- },
- {
- input: "testBodyNode()",
- output: '<body class="body-class" id="body-id">',
- displayName: "body",
- attrs: [
- {
- name: "class", value: "body-class"
- },
- {
- name: "id", value: "body-id"
- }
- ]
- },
- {
- input: "testNodeInIframe()",
- output: "<p>",
- displayName: "p",
- attrs: []
- },
- {
- input: "testDocumentElement()",
- output: '<html dir="ltr" lang="en-US">',
- displayName: "html",
- attrs: [
- {
- name: "dir",
- value: "ltr"
- },
- {
- name: "lang",
- value: "en-US"
- }
- ]
- }
-];
-
-function test() {
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- yield checkDomElementHighlightingForInputs(hud, TEST_DATA);
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_dom_elements_03.js
+++ /dev/null
@@ -1,70 +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 that inspector links in webconsole outputs for DOM Nodes highlight
-// the actual DOM Nodes on hover
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-dom-elements.html";
-
-function test() {
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- let toolbox = gDevTools.getToolbox(hud.target);
-
- // Loading the inspector panel at first, to make it possible to listen for
- // new node selections
- yield toolbox.loadTool("inspector");
- toolbox.getPanel("inspector");
-
- info("Executing 'testNode()' in the web console to output a DOM Node");
- let [result] = yield jsEval("testNode()", hud, {
- text: '<p some-attribute="some-value">'
- });
-
- let elementNodeWidget = yield getWidget(result);
-
- let nodeFront = yield hoverOverWidget(elementNodeWidget, toolbox);
- let attrs = nodeFront.attributes;
- is(nodeFront.tagName, "P", "The correct node was highlighted");
- is(attrs[0].name, "some-attribute", "The correct node was highlighted");
- is(attrs[0].value, "some-value", "The correct node was highlighted");
- }).then(finishTest);
-}
-
-function jsEval(input, hud, message) {
- hud.jsterm.execute(input);
- return waitForMessages({
- webconsole: hud,
- messages: [message]
- });
-}
-
-function* getWidget(result) {
- info("Getting the output ElementNode widget");
-
- let msg = [...result.matched][0];
- let elementNodeWidget = [...msg._messageObject.widgets][0];
- ok(elementNodeWidget, "ElementNode widget found in the output");
-
- info("Waiting for the ElementNode widget to be linked to the inspector");
- yield elementNodeWidget.linkToInspector();
-
- return elementNodeWidget;
-}
-
-function* hoverOverWidget(widget, toolbox) {
- info("Hovering over the output to highlight the node");
-
- let onHighlight = toolbox.once("node-highlight");
- EventUtils.sendMouseEvent({type: "mouseover"}, widget.element,
- widget.element.ownerDocument.defaultView);
- let nodeFront = yield onHighlight;
- ok(true, "The highlighter was shown on a node");
- return nodeFront;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_dom_elements_04.js
+++ /dev/null
@@ -1,112 +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 that inspector links in the webconsole output for DOM Nodes do not try
-// to highlight or select nodes once they have been detached
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-dom-elements.html";
-
-const TEST_DATA = [
- {
- // The first test shouldn't be returning the body element as this is the
- // default selected node, so re-selecting it won't fire the
- // inspector-updated event
- input: "testNode()",
- output: '<p some-attribute="some-value">'
- },
- {
- input: "testSvgNode()",
- output: '<clipPath>'
- },
- {
- input: "testBodyNode()",
- output: '<body class="body-class" id="body-id">'
- },
- {
- input: "testNodeInIframe()",
- output: "<p>"
- },
- {
- input: "testDocumentElement()",
- output: '<html dir="ltr" lang="en-US">'
- }
-];
-
-const PREF = "devtools.webconsole.persistlog";
-
-function test() {
- Services.prefs.setBoolPref(PREF, true);
- registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
-
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- let toolbox = gDevTools.getToolbox(hud.target);
-
- info("Executing the test data");
- let widgets = [];
- for (let data of TEST_DATA) {
- let [result] = yield jsEval(data.input, hud, {text: data.output});
- let {widget} = yield getWidgetAndMessage(result);
- widgets.push(widget);
- }
-
- info("Reloading the page");
- yield reloadPage();
-
- info("Iterating over the ElementNode widgets");
- for (let widget of widgets) {
- // Verify that openNodeInInspector rejects since the associated dom node
- // doesn't exist anymore
- yield widget.openNodeInInspector().then(() => {
- ok(false, "The openNodeInInspector promise resolved");
- }, () => {
- ok(true, "The openNodeInInspector promise rejected as expected");
- });
- yield toolbox.selectTool("webconsole");
-
- // Verify that highlightDomNode rejects too, for the same reason
- yield widget.highlightDomNode().then(() => {
- ok(false, "The highlightDomNode promise resolved");
- }, () => {
- ok(true, "The highlightDomNode promise rejected as expected");
- });
- }
- }).then(finishTest);
-}
-
-function jsEval(input, hud, message) {
- info("Executing '" + input + "' in the web console");
- hud.jsterm.execute(input);
- return waitForMessages({
- webconsole: hud,
- messages: [message]
- });
-}
-
-function* getWidgetAndMessage(result) {
- info("Getting the output ElementNode widget");
-
- let msg = [...result.matched][0];
- let widget = [...msg._messageObject.widgets][0];
- ok(widget, "ElementNode widget found in the output");
-
- info("Waiting for the ElementNode widget to be linked to the inspector");
- yield widget.linkToInspector();
-
- return {widget: widget, msg: msg};
-}
-
-function reloadPage() {
- let def = defer();
- gBrowser.selectedBrowser.addEventListener("load", function () {
- def.resolve();
- }, {capture: true, once: true});
- content.location.reload();
- return def.promise;
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_dom_elements_05.js
+++ /dev/null
@@ -1,47 +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/ */
-
-"use strict";
-
-// Test the inspector links in the webconsole output for namespaced elements
-// actually open the inspector and select the right node.
-
-const XHTML = `
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:svg="http://www.w3.org/2000/svg">
- <body>
- <svg:svg width="100" height="100">
- <svg:clipPath id="clip">
- <svg:rect id="rectangle" x="0" y="0" width="10" height="5"></svg:rect>
- </svg:clipPath>
- <svg:circle cx="0" cy="0" r="5"></svg:circle>
- </svg:svg>
- </body>
- </html>
-`;
-
-const TEST_URI = "data:application/xhtml+xml;charset=utf-8," + encodeURI(XHTML);
-
-const TEST_DATA = [
- {
- input: 'document.querySelector("clipPath")',
- output: '<svg:clipPath id="clip">',
- displayName: "svg:clipPath"
- },
- {
- input: 'document.querySelector("circle")',
- output: '<svg:circle cx="0" cy="0" r="5">',
- displayName: "svg:circle"
- },
-];
-
-function test() {
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- yield checkDomElementHighlightingForInputs(hud, TEST_DATA);
- }).then(finishTest);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_events.js
+++ /dev/null
@@ -1,52 +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/ */
-
-// Whitelisting this test.
-// As part of bug 1077403, the leaking uncaught rejection should be fixed.
-
-"use strict";
-
-// Test the webconsole output for DOM events.
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-output-events.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
- hud.jsterm.execute("testDOMEvents()");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "testDOMEvents() output",
- text: "undefined",
- category: CATEGORY_OUTPUT,
- }],
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log() output for mousemove",
- text: /eventLogger mousemove { target: .+, buttons: 0, clientX: \d+, clientY: \d+, layerX: \d+, layerY: \d+ }/,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log() output for keypress",
- text: /eventLogger keypress Shift { target: .+, key: .+, charCode: \d+, keyCode: \d+ }/,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_order.js
+++ /dev/null
@@ -1,47 +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/ */
-
-// Tests that any output created from calls to the console API comes before the
-// echoed JavaScript.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- let jsterm = hud.jsterm;
-
- jsterm.clearOutput();
- jsterm.execute("console.log('foo', 'bar');");
-
- let [functionCall, consoleMessage, result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "console.log('foo', 'bar');",
- category: CATEGORY_INPUT,
- },
- {
- text: "foo bar",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- },
- {
- text: "undefined",
- category: CATEGORY_OUTPUT,
- }]
- });
-
- let fncallNode = [...functionCall.matched][0];
- let consoleMessageNode = [...consoleMessage.matched][0];
- let resultNode = [...result.matched][0];
- is(fncallNode.nextElementSibling, consoleMessageNode,
- "console.log() is followed by 'foo' 'bar'");
- is(consoleMessageNode.nextElementSibling, resultNode,
- "'foo' 'bar' is followed by undefined");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_regexp.js
+++ /dev/null
@@ -1,34 +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 the webconsole output for a regexp object.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test regexp output";
-
-var inputTests = [
- // 0
- {
- input: "/foo/igym",
- output: "/foo/gimy",
- printOutput: "/foo/gimy",
- inspectable: true,
- },
-];
-
-function test() {
- requestLongerTimeout(2);
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- return checkOutputForInputs(hud, inputTests);
- }).then(finishUp);
-}
-
-function finishUp() {
- inputTests = null;
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_output_table.js
+++ /dev/null
@@ -1,199 +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/ */
-
-// Tests that console.table() works as intended.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-console-table.html";
-
-const TEST_DATA = [
- {
- command: "console.table(languages1)",
- data: [
- { _index: 0, name: "\"JavaScript\"", fileExtension: "Array[1]" },
- { _index: 1, name: "Object", fileExtension: "\".ts\"" },
- { _index: 2, name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
- ],
- columns: { _index: "(index)", name: "name", fileExtension: "fileExtension" }
- },
- {
- command: "console.table(languages1, 'name')",
- data: [
- { _index: 0, name: "\"JavaScript\"", fileExtension: "Array[1]" },
- { _index: 1, name: "Object", fileExtension: "\".ts\"" },
- { _index: 2, name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
- ],
- columns: { _index: "(index)", name: "name" }
- },
- {
- command: "console.table(languages1, ['name'])",
- data: [
- { _index: 0, name: "\"JavaScript\"", fileExtension: "Array[1]" },
- { _index: 1, name: "Object", fileExtension: "\".ts\"" },
- { _index: 2, name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
- ],
- columns: { _index: "(index)", name: "name" }
- },
- {
- command: "console.table(languages2)",
- data: [
- { _index: "csharp", name: "\"C#\"", paradigm: "\"object-oriented\"" },
- { _index: "fsharp", name: "\"F#\"", paradigm: "\"functional\"" }
- ],
- columns: { _index: "(index)", name: "name", paradigm: "paradigm" }
- },
- {
- command: "console.table([[1, 2], [3, 4]])",
- data: [
- { _index: 0, 0: "1", 1: "2" },
- { _index: 1, 0: "3", 1: "4" }
- ],
- columns: { _index: "(index)", 0: "0", 1: "1" }
- },
- {
- command: "console.table({a: [1, 2], b: [3, 4]})",
- data: [
- { _index: "a", 0: "1", 1: "2" },
- { _index: "b", 0: "3", 1: "4" }
- ],
- columns: { _index: "(index)", 0: "0", 1: "1" }
- },
- {
- command: "console.table(family)",
- data: [
- { _index: "mother", firstName: "\"Susan\"", lastName: "\"Doyle\"",
- age: "32" },
- { _index: "father", firstName: "\"John\"", lastName: "\"Doyle\"",
- age: "33" },
- { _index: "daughter", firstName: "\"Lily\"", lastName: "\"Doyle\"",
- age: "5" },
- { _index: "son", firstName: "\"Mike\"", lastName: "\"Doyle\"", age: "8" },
- ],
- columns: { _index: "(index)", firstName: "firstName", lastName: "lastName",
- age: "age" }
- },
- {
- command: "console.table(family, [])",
- data: [
- { _index: "mother", firstName: "\"Susan\"", lastName: "\"Doyle\"",
- age: "32" },
- { _index: "father", firstName: "\"John\"", lastName: "\"Doyle\"",
- age: "33" },
- { _index: "daughter", firstName: "\"Lily\"", lastName: "\"Doyle\"",
- age: "5" },
- { _index: "son", firstName: "\"Mike\"", lastName: "\"Doyle\"", age: "8" },
- ],
- columns: { _index: "(index)" }
- },
- {
- command: "console.table(family, ['firstName', 'lastName'])",
- data: [
- { _index: "mother", firstName: "\"Susan\"", lastName: "\"Doyle\"",
- age: "32" },
- { _index: "father", firstName: "\"John\"", lastName: "\"Doyle\"",
- age: "33" },
- { _index: "daughter", firstName: "\"Lily\"", lastName: "\"Doyle\"",
- age: "5" },
- { _index: "son", firstName: "\"Mike\"", lastName: "\"Doyle\"", age: "8" },
- ],
- columns: { _index: "(index)", firstName: "firstName", lastName: "lastName" }
- },
- {
- command: "console.table(mySet)",
- data: [
- { _index: 0, _value: "1" },
- { _index: 1, _value: "5" },
- { _index: 2, _value: "\"some text\"" },
- { _index: 3, _value: "null" },
- { _index: 4, _value: "undefined" }
- ],
- columns: { _index: "(iteration index)", _value: "Values" }
- },
- {
- command: "console.table(myMap)",
- data: [
- { _index: 0, _key: "\"a string\"",
- _value: "\"value associated with 'a string'\"" },
- { _index: 1, _key: "5", _value: "\"value associated with 5\"" },
- ],
- columns: { _index: "(iteration index)", _key: "Key", _value: "Values" }
- },
- {
- command: "console.table(weakset)",
- data: [
- { _value: "String" },
- { _value: "String" },
- ],
- columns: { _index: "(iteration index)", _value: "Values" },
- couldBeOutOfOrder: true,
- },
- {
- command: "console.table(weakmap)",
- data: [
- { _key: "String", _value: "\"oh no\"" },
- { _key: "String", _value: "23" },
- ],
- columns: { _index: "(iteration index)", _key: "Key", _value: "Values" },
- couldBeOutOfOrder: true,
- },
-];
-
-add_task(function* () {
- const {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
-
- for (let testdata of TEST_DATA) {
- hud.jsterm.clearOutput();
-
- info("Executing " + testdata.command);
-
- let onTableRender = once(hud.ui, "messages-table-rendered");
- hud.jsterm.execute(testdata.command);
- yield onTableRender;
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: testdata.command + " output",
- consoleTable: true
- }],
- });
-
- let node = [...result.matched][0];
- ok(node, "found trace log node");
-
- let obj = node._messageObject;
- ok(obj, "console.trace message object");
-
- ok(obj._data, "found table data object");
-
- let data = obj._data.map(entries => {
- let entryResult = {};
-
- for (let key of Object.keys(entries)) {
- // If the results can be out of order, then ignore _index.
- if (!testdata.couldBeOutOfOrder || key !== "_index") {
- entryResult[key] = entries[key] instanceof HTMLElement ?
- entries[key].textContent : entries[key];
- }
- }
-
- return entryResult;
- });
-
- if (testdata.couldBeOutOfOrder) {
- data = data.map(e => e.toSource()).sort().join(",");
- let expected = testdata.data.map(e => e.toSource()).sort().join(",");
- is(data, expected, "table data is correct");
- } else {
- is(data.toSource(), testdata.data.toSource(), "table data is correct");
- }
- ok(obj._columns, "found table column object");
- is(obj._columns.toSource(), testdata.columns.toSource(),
- "table column is correct");
- }
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_promise.js
+++ /dev/null
@@ -1,35 +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/ */
-
-// Bug 1148759 - Test the webconsole can display promises inside objects.
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,test for console and promises";
-
-var inputTests = [
- // 0
- {
- input: "({ x: Promise.resolve() })",
- output: "Object { x: Promise }",
- printOutput: "[object Object]",
- inspectable: true,
- variablesViewLabel: "Object"
- },
-];
-
-function test() {
- requestLongerTimeout(2);
-
- Task.spawn(function* () {
- let {tab} = yield loadTab(TEST_URI);
- let hud = yield openConsole(tab);
- return checkOutputForInputs(hud, inputTests);
- }).then(finishUp);
-}
-
-function finishUp() {
- finishTest();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_reflow.js
+++ /dev/null
@@ -1,35 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
- "reflow activity";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- function onReflowListenersReady() {
- ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
- content.document.body.style.display = "none";
- content.document.body.clientTop;
- });
- }
-
- Services.prefs.setBoolPref("devtools.webconsole.filter.csslog", true);
- hud.ui._updateReflowActivityListener(onReflowListenersReady);
- Services.prefs.clearUserPref("devtools.webconsole.filter.csslog");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: /reflow: /,
- category: CATEGORY_CSS,
- severity: SEVERITY_LOG,
- }],
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_scratchpad_panel_link.js
+++ /dev/null
@@ -1,76 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,<p>test Scratchpad panel " +
- "linking</p>";
-
-var { Tools } = require("devtools/client/definitions");
-var { isTargetSupported } = Tools.scratchpad;
-
-function pushPrefEnv() {
- let deferred = defer();
- let options = {"set":
- [["devtools.scratchpad.enabled", true]
- ]};
- SpecialPowers.pushPrefEnv(options, deferred.resolve);
- return deferred.promise;
-}
-
-add_task(function* () {
- waitForExplicitFinish();
-
- yield pushPrefEnv();
-
- yield loadTab(TEST_URI);
-
- info("Opening toolbox with Scratchpad panel");
-
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = yield gDevTools.showToolbox(target, "scratchpad", "window");
-
- let scratchpadPanel = toolbox.getPanel("scratchpad");
- let { scratchpad } = scratchpadPanel;
- is(toolbox.getCurrentPanel(), scratchpadPanel,
- "Scratchpad is currently selected panel");
-
- info("Switching to webconsole panel");
-
- let webconsolePanel = yield toolbox.selectTool("webconsole");
- let { hud } = webconsolePanel;
- is(toolbox.getCurrentPanel(), webconsolePanel,
- "Webconsole is currently selected panel");
-
- info("console.log()ing from Scratchpad");
-
- scratchpad.setText("console.log('foobar-from-scratchpad')");
- scratchpad.run();
- let messages = yield waitForMessages({
- webconsole: hud,
- messages: [{ text: "foobar-from-scratchpad" }]
- });
-
- info("Clicking link to switch to and focus Scratchpad");
-
- let [matched] = [...messages[0].matched];
- ok(matched, "Found logged message from Scratchpad");
- let anchor = matched.querySelector(".message-location .frame-link-filename");
-
- toolbox.on("scratchpad-selected", function selected() {
- toolbox.off("scratchpad-selected", selected);
-
- is(toolbox.getCurrentPanel(), scratchpadPanel,
- "Clicking link switches to Scratchpad panel");
-
- is(Services.ww.activeWindow, toolbox.win.parent,
- "Scratchpad's toolbox is focused");
-
- Tools.scratchpad.isTargetSupported = isTargetSupported;
- finish();
- });
-
- EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_script_errordoc_urls.js
+++ /dev/null
@@ -1,67 +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/ */
-
-// Ensure that [Learn More] links appear alongside any errors listed
-// in "errordocs.js". Note: this only tests script execution.
-
-"use strict";
-
-const ErrorDocs = require("devtools/server/actors/errordocs");
-
-function makeURIData(script) {
- return `data:text/html;charset=utf8,<script>${script}</script>`;
-}
-
-const TestData = [
- {
- jsmsg: "JSMSG_READ_ONLY",
- script: "'use strict'; (Object.freeze({name: 'Elsa', score: 157})).score = 0;",
- isException: true,
- },
- {
- jsmsg: "JSMSG_STMT_AFTER_RETURN",
- script: "function a() { return; 1 + 1; };",
- isException: false,
- }
-];
-
-add_task(function* () {
- yield loadTab("data:text/html;charset=utf8,errordoc tests");
-
- let hud = yield openConsole();
-
- for (let i = 0; i < TestData.length; i++) {
- yield testScriptError(hud, TestData[i]);
- }
-});
-
-function* testScriptError(hud, testData) {
- if (testData.isException === true) {
- expectUncaughtException();
- }
-
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, makeURIData(testData.script));
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- category: CATEGORY_JS
- }
- ]
- });
-
- // grab the most current error doc URL
- let url = ErrorDocs.GetURL({ errorMessageName: testData.jsmsg });
-
- let hrefs = {};
- for (let link of hud.jsterm.outputNode.querySelectorAll("a")) {
- hrefs[link.href] = true;
- }
-
- ok(url in hrefs, `Expected a link to ${url}.`);
-
- hud.jsterm.clearOutput();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_show_subresource_security_errors.js
+++ /dev/null
@@ -1,33 +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/ */
-
-// Ensure non-toplevel security errors are displayed
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console subresource STS " +
- "warning test";
-const TEST_DOC = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test_bug1092055_shouldwarn.html";
-const SAMPLE_MSG = "specified a header that could not be parsed successfully.";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- hud.jsterm.clearOutput();
-
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_DOC);
- yield loaded;
-
- yield waitForSuccess({
- name: "Subresource STS warning displayed successfully",
- validator: function () {
- return hud.outputNode.textContent.indexOf(SAMPLE_MSG) > -1;
- }
- });
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_shows_reqs_in_netmonitor.js
+++ /dev/null
@@ -1,75 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf8,Test that the web console " +
- "displays requests that have been recorded in the " +
- "netmonitor, even if the console hadn't opened yet.";
-
-const TEST_FILE = "test-network-request.html";
-const TEST_PATH = "http://example.com/browser/devtools/client/webconsole/old/" +
- "test/" + TEST_FILE;
-
-const NET_PREF = "devtools.webconsole.filter.networkinfo";
-Services.prefs.setBoolPref(NET_PREF, true);
-registerCleanupFunction(() => {
- Services.prefs.clearUserPref(NET_PREF);
-});
-
-add_task(function* () {
- let { tab, browser } = yield loadTab(TEST_URI);
-
- let target = TargetFactory.forTab(tab);
- let toolbox = yield gDevTools.showToolbox(target, "netmonitor");
- info("Network panel is open.");
-
- yield loadDocument(browser);
- info("Document loaded.");
-
- // Test that the request appears in the network panel.
- yield testNetmonitor(toolbox);
-
- // Test that the request appears in the console.
- let hud = yield openConsole();
- info("Web console is open");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "network message",
- text: TEST_FILE,
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG
- }
- ]
- });
-});
-
-function loadDocument(browser) {
- let deferred = defer();
-
- BrowserTestUtils.browserLoaded(browser).then(function () {
- deferred.resolve();
- });
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_PATH);
-
- return deferred.promise;
-}
-
-function* testNetmonitor(toolbox) {
- let monitor = toolbox.getCurrentPanel();
- let { store, windowRequire } = monitor.panelWin;
- let { getSortedRequests } = windowRequire("devtools/client/netmonitor/src/selectors/index");
-
- yield waitUntil(() => store.getState().requests.requests.size > 0);
-
- is(store.getState().requests.requests.size, 1, "Network request appears in the network panel");
-
- let item = getSortedRequests(store.getState()).get(0);
- is(item.method, "GET", "The request method is correct.");
- is(item.url, TEST_PATH, "The request url is correct.");
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_split.js
+++ /dev/null
@@ -1,293 +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/ */
-
-"use strict";
-
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for splitting";
-
-function test() {
- waitForExplicitFinish();
- // Test is slow on Linux EC2 instances - Bug 962931
- requestLongerTimeout(2);
-
- let {Toolbox} = require("devtools/client/framework/toolbox");
- let {LocalizationHelper} = require("devtools/shared/l10n");
- let L10N =
- new LocalizationHelper("devtools/client/locales/toolbox.properties");
- let toolbox;
-
- loadTab(TEST_URI).then(testConsoleLoadOnDifferentPanel);
-
- function testConsoleLoadOnDifferentPanel() {
- info("About to check console loads even when non-webconsole panel is open");
-
- openPanel("inspector").then(() => {
- let initialOpenComplete;
-
- toolbox.on("webconsole-ready", () => {
- ok(true, "Webconsole has been triggered as loaded while another tool " +
- "is active");
- initialOpenComplete.then(() => {
- testKeyboardShortcuts();
- });
- });
-
- // Opens split console.
- initialOpenComplete = toolbox.toggleSplitConsole();
- });
- }
-
- function testKeyboardShortcuts() {
- info("About to check that panel responds to ESCAPE keyboard shortcut");
-
- toolbox.once("split-console", () => {
- ok(true, "Split console has been triggered via ESCAPE keypress");
- checkAllTools();
- });
-
- // Closes split console.
- EventUtils.sendKey("ESCAPE", toolbox.win);
- }
-
- function checkAllTools() {
- info("About to check split console with each panel individually.");
-
- Task.spawn(function* () {
- yield openAndCheckPanel("jsdebugger");
- yield openAndCheckPanel("inspector");
- yield openAndCheckPanel("styleeditor");
- yield openAndCheckPanel("performance");
- yield openAndCheckPanel("netmonitor");
-
- yield checkWebconsolePanelOpened();
- testBottomHost();
- });
- }
-
- async function getCurrentUIState() {
- let win = toolbox.win;
- let deck = toolbox.doc.querySelector("#toolbox-deck");
- let webconsolePanel = toolbox.webconsolePanel;
- let splitter = toolbox.doc.querySelector("#toolbox-console-splitter");
-
- let containerHeight = parseFloat(win.getComputedStyle(deck.parentNode)
- .getPropertyValue("height"));
- let deckHeight = parseFloat(win.getComputedStyle(deck)
- .getPropertyValue("height"));
- let webconsoleHeight = parseFloat(win.getComputedStyle(webconsolePanel)
- .getPropertyValue("height"));
- let splitterVisibility = !splitter.getAttribute("hidden");
- let openedConsolePanel = toolbox.currentToolId === "webconsole";
-
- return {
- deckHeight: deckHeight,
- containerHeight: containerHeight,
- webconsoleHeight: webconsoleHeight,
- splitterVisibility: splitterVisibility,
- openedConsolePanel: openedConsolePanel,
- menuLabel: await getMenuLabel(toolbox),
- };
- }
-
- function getMenuLabel(toolbox) {
- return new Promise(resolve => {
- const button = toolbox.doc.getElementById("toolbox-meatball-menu-button");
- EventUtils.sendMouseEvent({ type: "click" }, button);
-
- toolbox.doc.addEventListener("popupshown", () => {
- const menuItem =
- toolbox.doc.getElementById("toolbox-meatball-menu-splitconsole");
-
- // Return undefined if the menu item is not available
- let label;
- if (menuItem) {
- label =
- menuItem.label ===
- L10N.getStr("toolbox.meatballMenu.hideconsole.label")
- ? "hide"
- : "split";
- }
-
- // Wait for menu to close
- toolbox.doc.addEventListener("popuphidden", () => {
- resolve(label);
- }, { once: true });
- EventUtils.synthesizeKey("KEY_Escape");
- }, { once: true });
- });
- }
-
- const checkWebconsolePanelOpened = Task.async(function* () {
- info("About to check special cases when webconsole panel is open.");
-
- // Start with console split, so we can test for transition to main panel.
- yield toolbox.toggleSplitConsole();
-
- let currentUIState = yield getCurrentUIState();
-
- ok(currentUIState.splitterVisibility,
- "Splitter is visible when console is split");
- ok(currentUIState.deckHeight > 0,
- "Deck has a height > 0 when console is split");
- ok(currentUIState.webconsoleHeight > 0,
- "Web console has a height > 0 when console is split");
- ok(!currentUIState.openedConsolePanel,
- "The console panel is not the current tool");
- is(currentUIState.menuLabel, "hide",
- "The menu item indicates the console is split");
-
- yield openPanel("webconsole");
- currentUIState = yield getCurrentUIState();
-
- ok(!currentUIState.splitterVisibility,
- "Splitter is hidden when console is opened.");
- is(currentUIState.deckHeight, 0,
- "Deck has a height == 0 when console is opened.");
- is(currentUIState.webconsoleHeight, currentUIState.containerHeight,
- "Web console is full height.");
- ok(currentUIState.openedConsolePanel,
- "The console panel is the current tool");
- is(currentUIState.menuLabel, undefined,
- "The menu item is hidden when console is opened");
-
- // Make sure splitting console does nothing while webconsole is opened
- yield toolbox.toggleSplitConsole();
-
- currentUIState = yield getCurrentUIState();
-
- ok(!currentUIState.splitterVisibility,
- "Splitter is hidden when console is opened.");
- is(currentUIState.deckHeight, 0,
- "Deck has a height == 0 when console is opened.");
- is(currentUIState.webconsoleHeight, currentUIState.containerHeight,
- "Web console is full height.");
- ok(currentUIState.openedConsolePanel,
- "The console panel is the current tool");
- is(currentUIState.menuLabel, undefined,
- "The menu item is hidden when console is opened");
-
- // Make sure that split state is saved after opening another panel
- yield openPanel("inspector");
- currentUIState = yield getCurrentUIState();
- ok(currentUIState.splitterVisibility,
- "Splitter is visible when console is split");
- ok(currentUIState.deckHeight > 0,
- "Deck has a height > 0 when console is split");
- ok(currentUIState.webconsoleHeight > 0,
- "Web console has a height > 0 when console is split");
- ok(!currentUIState.openedConsolePanel,
- "The console panel is not the current tool");
- is(currentUIState.menuLabel, "hide",
- "The menu item still indicates the console is split");
-
- yield toolbox.toggleSplitConsole();
- });
-
- const checkToolboxUI = Task.async(function* () {
- let currentUIState = yield getCurrentUIState();
-
- ok(!currentUIState.splitterVisibility, "Splitter is hidden by default");
- is(currentUIState.deckHeight, currentUIState.containerHeight,
- "Deck has a height > 0 by default");
- is(currentUIState.webconsoleHeight, 0,
- "Web console is collapsed by default");
- ok(!currentUIState.openedConsolePanel,
- "The console panel is not the current tool");
- is(currentUIState.menuLabel, "split",
- "The menu item indicates the console is not split");
-
- yield toolbox.toggleSplitConsole();
-
- currentUIState = yield getCurrentUIState();
-
- ok(currentUIState.splitterVisibility,
- "Splitter is visible when console is split");
- ok(currentUIState.deckHeight > 0,
- "Deck has a height > 0 when console is split");
- ok(currentUIState.webconsoleHeight > 0,
- "Web console has a height > 0 when console is split");
- is(Math.round(currentUIState.deckHeight + currentUIState.webconsoleHeight),
- currentUIState.containerHeight,
- "Everything adds up to container height");
- ok(!currentUIState.openedConsolePanel,
- "The console panel is not the current tool");
- is(currentUIState.menuLabel, "hide",
- "The menu item indicates the console is split");
-
- yield toolbox.toggleSplitConsole();
-
- currentUIState = yield getCurrentUIState();
-
- ok(!currentUIState.splitterVisibility, "Splitter is hidden after toggling");
- is(currentUIState.deckHeight, currentUIState.containerHeight,
- "Deck has a height > 0 after toggling");
- is(currentUIState.webconsoleHeight, 0,
- "Web console is collapsed after toggling");
- ok(!currentUIState.openedConsolePanel,
- "The console panel is not the current tool");
- is(currentUIState.menuLabel, "split",
- "The menu item indicates the console is not split");
- });
-
- function openPanel(toolId) {
- let deferred = defer();
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- gDevTools.showToolbox(target, toolId).then(function (box) {
- toolbox = box;
- deferred.resolve();
- }).catch(console.error);
- return deferred.promise;
- }
-
- function openAndCheckPanel(toolId) {
- return openPanel(toolId).then(() => {
- info("Checking toolbox for " + toolId);
- return checkToolboxUI(toolbox.getCurrentPanel());
- });
- }
-
- function testBottomHost() {
- checkHostType(Toolbox.HostType.BOTTOM);
-
- checkToolboxUI();
-
- toolbox.switchHost(Toolbox.HostType.SIDE).then(testSidebarHost);
- }
-
- function testSidebarHost() {
- checkHostType(Toolbox.HostType.SIDE);
-
- checkToolboxUI();
-
- toolbox.switchHost(Toolbox.HostType.WINDOW).then(testWindowHost);
- }
-
- function testWindowHost() {
- checkHostType(Toolbox.HostType.WINDOW);
-
- checkToolboxUI();
-
- toolbox.switchHost(Toolbox.HostType.BOTTOM).then(testDestroy);
- }
-
- function checkHostType(hostType) {
- is(toolbox.hostType, hostType, "host type is " + hostType);
-
- let pref = Services.prefs.getCharPref("devtools.toolbox.host");
- is(pref, hostType, "host pref is " + hostType);
- }
-
- function testDestroy() {
- toolbox.destroy().then(function () {
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- gDevTools.showToolbox(target).then(finish);
- });
- }
-
- function finish() {
- toolbox = null;
- finishTest();
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_split_escape_key.js
+++ /dev/null
@@ -1,158 +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/ */
-
- "use strict";
-
- function test() {
- info("Test various cases where the escape key should hide the split console.");
-
- let toolbox;
- let hud;
- let jsterm;
- let hudMessages;
- let variablesView;
-
- Task.spawn(runner).then(finish);
-
- function* runner() {
- let {tab} = yield loadTab("data:text/html;charset=utf-8,<p>Web Console " +
- "test for splitting");
- let target = TargetFactory.forTab(tab);
- toolbox = yield gDevTools.showToolbox(target, "inspector");
-
- yield testCreateSplitConsoleAfterEscape();
-
- yield showAutoCompletePopoup();
-
- yield testHideAutoCompletePopupAfterEscape();
-
- yield executeJS();
- yield clickMessageAndShowVariablesView();
- jsterm.focus();
-
- yield testHideVariablesViewAfterEscape();
-
- yield clickMessageAndShowVariablesView();
- yield startPropertyEditor();
-
- yield testCancelPropertyEditorAfterEscape();
- yield testHideVariablesViewAfterEscape();
- yield testHideSplitConsoleAfterEscape();
- }
-
- function testCreateSplitConsoleAfterEscape() {
- let result = toolbox.once("webconsole-ready", () => {
- hud = toolbox.getPanel("webconsole").hud;
- jsterm = hud.jsterm;
- ok(toolbox.splitConsole, "Split console is created.");
- });
-
- let contentWindow = toolbox.win;
- contentWindow.focus();
- EventUtils.sendKey("ESCAPE", contentWindow);
-
- return result;
- }
-
- function testHideSplitConsoleAfterEscape() {
- let result = toolbox.once("split-console", () => {
- ok(!toolbox.splitConsole, "Split console is hidden.");
- });
- EventUtils.sendKey("ESCAPE", toolbox.win);
-
- return result;
- }
-
- function testHideVariablesViewAfterEscape() {
- let result = jsterm.once("sidebar-closed", () => {
- ok(!hud.ui.jsterm.sidebar,
- "Variables view is hidden.");
- ok(toolbox.splitConsole,
- "Split console is open after hiding the variables view.");
- });
- EventUtils.sendKey("ESCAPE", toolbox.win);
-
- return result;
- }
-
- function testHideAutoCompletePopupAfterEscape() {
- let deferred = defer();
- let popup = jsterm.autocompletePopup;
-
- popup.once("popup-closed", () => {
- ok(!popup.isOpen,
- "Auto complete popup is hidden.");
- ok(toolbox.splitConsole,
- "Split console is open after hiding the autocomplete popup.");
-
- deferred.resolve();
- });
-
- EventUtils.sendKey("ESCAPE", toolbox.win);
-
- return deferred.promise;
- }
-
- function testCancelPropertyEditorAfterEscape() {
- EventUtils.sendKey("ESCAPE", variablesView.window);
- ok(hud.ui.jsterm.sidebar,
- "Variables view is open after canceling property editor.");
- ok(toolbox.splitConsole,
- "Split console is open after editing.");
- }
-
- function* executeJS() {
- jsterm.execute("var foo = { bar: \"baz\" }; foo;");
- hudMessages = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Object { bar: \"baz\" }",
- category: CATEGORY_OUTPUT,
- objects: true
- }],
- });
- }
-
- function clickMessageAndShowVariablesView() {
- let result = jsterm.once("variablesview-fetched", (vview) => {
- variablesView = vview;
- });
-
- let clickable = hudMessages[0].clickableElements[0];
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
-
- return result;
- }
-
- function* startPropertyEditor() {
- let results = yield findVariableViewProperties(variablesView, [
- {name: "bar", value: "baz"}
- ], {webconsole: hud});
- results[0].matchedProp.focus();
- EventUtils.synthesizeKey("VK_RETURN", variablesView.window);
- }
-
- function showAutoCompletePopoup() {
- let onPopupShown = jsterm.autocompletePopup.once("popup-opened");
-
- jsterm.focus();
- jsterm.setInputValue("document.location.");
- EventUtils.sendKey("TAB", hud.iframeWindow);
-
- return onPopupShown;
- }
-
- function finish() {
- toolbox.destroy().then(() => {
- toolbox = null;
- hud = null;
- jsterm = null;
- hudMessages = null;
- variablesView = null;
-
- finishTest();
- });
- }
- }
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_split_focus.js
+++ /dev/null
@@ -1,64 +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/ */
-
- "use strict";
-
- function test() {
- info("Test that the split console state is persisted");
-
- let toolbox;
- let TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for " +
- "splitting</p>";
-
- Task.spawn(runner).then(finish);
-
- function* runner() {
- info("Opening a tab while there is no user setting on split console pref");
- let {tab} = yield loadTab(TEST_URI);
- let target = TargetFactory.forTab(tab);
- toolbox = yield gDevTools.showToolbox(target, "inspector");
-
- ok(!toolbox.splitConsole, "Split console is hidden by default");
-
- info("Focusing the search box before opening the split console");
- let inspector = toolbox.getPanel("inspector");
- inspector.searchBox.focus();
-
- let activeElement = getActiveElement(inspector.panelDoc);
- is(activeElement, inspector.searchBox, "Search box is focused");
-
- yield toolbox.openSplitConsole();
-
- ok(toolbox.splitConsole, "Split console is now visible");
-
- // Use the binding element since jsterm.inputNode is a XUL textarea element.
- activeElement = getActiveElement(toolbox.doc);
- activeElement = activeElement.ownerDocument.getBindingParent(activeElement);
- let inputNode = toolbox.getPanel("webconsole").hud.jsterm.inputNode;
- is(activeElement, inputNode, "Split console input is focused by default");
-
- yield toolbox.closeSplitConsole();
-
- info("Making sure that the search box is refocused after closing the " +
- "split console");
- activeElement = getActiveElement(inspector.panelDoc);
- is(activeElement, inspector.searchBox, "Search box is focused");
-
- yield toolbox.destroy();
- }
-
- function getActiveElement(doc) {
- let activeElement = doc.activeElement;
- while (activeElement && activeElement.contentDocument) {
- activeElement = activeElement.contentDocument.activeElement;
- }
- return activeElement;
- }
-
- function finish() {
- toolbox = TEST_URI = null;
- finishTest();
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_split_persist.js
+++ /dev/null
@@ -1,140 +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/ */
-
- "use strict";
-
- function test() {
- info("Test that the split console state is persisted");
-
- let {LocalizationHelper} = require("devtools/shared/l10n");
- let L10N =
- new LocalizationHelper("devtools/client/locales/toolbox.properties");
-
- let toolbox;
- let TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for " +
- "splitting</p>";
-
- Task.spawn(runner).then(finish);
-
- function* runner() {
- info("Opening a tab while there is no user setting on split console pref");
- let {tab} = yield loadTab(TEST_URI);
- let target = TargetFactory.forTab(tab);
- toolbox = yield gDevTools.showToolbox(target, "inspector");
-
- ok(!toolbox.splitConsole, "Split console is hidden by default.");
- ok(!(yield doesMenuSayHide()),
- "Split console menu item says split by default");
- yield toggleSplitConsoleWithEscape();
- ok(toolbox.splitConsole, "Split console is now visible.");
- ok(yield doesMenuSayHide(), "Split console menu item now says hide");
- ok(getVisiblePrefValue(), "Visibility pref is true");
-
- is(getHeightPrefValue(), toolbox.webconsolePanel.height,
- "Panel height matches the pref");
- toolbox.webconsolePanel.height = 200;
-
- yield toolbox.destroy();
-
- info("Opening a tab while there is a true user setting on split console " +
- "pref");
- ({tab} = yield loadTab(TEST_URI));
- target = TargetFactory.forTab(tab);
- toolbox = yield gDevTools.showToolbox(target, "inspector");
-
- ok(toolbox.splitConsole, "Split console is visible by default.");
- ok(yield doesMenuSayHide(), "Split console menu item initially says hide");
- is(getHeightPrefValue(), 200, "Height is set based on panel height after " +
- "closing");
-
- // Use the binding element since jsterm.inputNode is a XUL textarea element.
- let activeElement = getActiveElement(toolbox.doc);
- activeElement = activeElement.ownerDocument.getBindingParent(activeElement);
- let inputNode = toolbox.getPanel("webconsole").hud.jsterm.inputNode;
- is(activeElement, inputNode, "Split console input is focused by default");
-
- toolbox.webconsolePanel.height = 1;
- ok(toolbox.webconsolePanel.clientHeight > 1,
- "The actual height of the console is bound with a min height");
-
- toolbox.webconsolePanel.height = 10000;
- ok(toolbox.webconsolePanel.clientHeight < 10000,
- "The actual height of the console is bound with a max height");
-
- yield toggleSplitConsoleWithEscape();
- ok(!toolbox.splitConsole, "Split console is now hidden.");
- ok(!(yield doesMenuSayHide()), "Split console menu item now says split");
- ok(!getVisiblePrefValue(), "Visibility pref is false");
-
- yield toolbox.destroy();
-
- is(getHeightPrefValue(), 10000,
- "Height is set based on panel height after closing");
-
- info("Opening a tab while there is a false user setting on split " +
- "console pref");
- ({tab} = yield loadTab(TEST_URI));
- target = TargetFactory.forTab(tab);
- toolbox = yield gDevTools.showToolbox(target, "inspector");
-
- ok(!toolbox.splitConsole, "Split console is hidden by default.");
- ok(!getVisiblePrefValue(), "Visibility pref is false");
-
- yield toolbox.destroy();
- }
-
- function getActiveElement(doc) {
- let activeElement = doc.activeElement;
- while (activeElement && activeElement.contentDocument) {
- activeElement = activeElement.contentDocument.activeElement;
- }
- return activeElement;
- }
-
- function getVisiblePrefValue() {
- return Services.prefs.getBoolPref("devtools.toolbox.splitconsoleEnabled");
- }
-
- function getHeightPrefValue() {
- return Services.prefs.getIntPref("devtools.toolbox.splitconsoleHeight");
- }
-
- function doesMenuSayHide() {
- return new Promise(resolve => {
- const button = toolbox.doc.getElementById("toolbox-meatball-menu-button");
- EventUtils.sendMouseEvent({ type: "click" }, button);
-
- toolbox.doc.addEventListener("popupshown", () => {
- const menuItem =
- toolbox.doc.getElementById("toolbox-meatball-menu-splitconsole");
-
- const result =
- menuItem &&
- menuItem.label ===
- L10N.getStr("toolbox.meatballMenu.hideconsole.label");
-
- toolbox.doc.addEventListener("popuphidden", () => {
- resolve(result);
- },
- { once: true });
- EventUtils.synthesizeKey("KEY_Escape");
- },
- { once: true });
- });
- }
-
- function toggleSplitConsoleWithEscape() {
- let onceSplitConsole = toolbox.once("split-console");
- let contentWindow = toolbox.win;
- contentWindow.focus();
- EventUtils.synthesizeKey("KEY_Escape");
- return onceSplitConsole;
- }
-
- function finish() {
- toolbox = TEST_URI = null;
- finishTest();
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_start_netmon_first.js
+++ /dev/null
@@ -1,38 +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/ */
-
-// Check that the webconsole works if the network monitor is first opened, then
-// the user switches to the webconsole. See bug 970914.
-
-"use strict";
-
-function test() {
- Task.spawn(runner).then(finishTest);
-
- function* runner() {
- const {tab} = yield loadTab("data:text/html;charset=utf8,<p>hello");
-
- const hud = yield openConsole(tab);
-
- hud.jsterm.execute("console.log('foobar bug970914')");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log",
- text: "foobar bug970914",
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let text = hud.outputNode.textContent;
- isnot(text.indexOf("foobar bug970914"), -1,
- "console.log message confirmed");
- ok(!/logging API|disabled by a script/i.test(text),
- "no warning about disabled console API");
- }
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_strict_mode_errors.js
+++ /dev/null
@@ -1,83 +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/ */
-
-// Check that "use strict" JS errors generate errors, not warnings.
-
-"use strict";
-
-add_task(function* () {
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- yield loadTab("data:text/html;charset=utf8,<script>'use strict';var arguments;</script>");
-
- let hud = yield openConsole();
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "SyntaxError: 'arguments' can't be defined or assigned to in strict mode code",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- ],
- });
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "data:text/html;charset="
- + "utf8,<script>'use strict';function f(a, a) {};</script>");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "SyntaxError: duplicate formal argument a",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- ],
- });
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "data:text/html;charset="
- + "utf8,<script>'use strict';var o = {get p() {}};o.p = 1;</script>");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: 'TypeError: setting getter-only property "p"',
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- ],
- });
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser,
- "data:text/html;charset=utf8,<script>'use strict';v = 1;</script>");
-
- yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- text: "ReferenceError: assignment to undeclared variable v",
- category: CATEGORY_JS,
- severity: SEVERITY_ERROR,
- },
- ],
- });
-
- hud = null;
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_trackingprotection_errors.js
+++ /dev/null
@@ -1,54 +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/ */
-
-// Load a page with tracking elements that get blocked and make sure that a
-// 'learn more' link shows up in the webconsole.
-
-"use strict";
-
-const TEST_URI = "http://tracking.example.org/browser/devtools/client/" +
- "webconsole/old/test/test-trackingprotection-securityerrors.html";
-const LEARN_MORE_URI = "https://developer.mozilla.org/Firefox/Privacy/" +
- "Tracking_Protection" + DOCS_GA_PARAMS;
-const PREF = "privacy.trackingprotection.enabled";
-
-const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
-
-registerCleanupFunction(function () {
- Services.prefs.clearUserPref(PREF);
- UrlClassifierTestUtils.cleanupTestTrackers();
-});
-
-add_task(function* testMessagesAppear() {
- yield UrlClassifierTestUtils.addTestTrackers();
- Services.prefs.setBoolPref(PREF, true);
-
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
-
- let results = yield waitForMessages({
- webconsole: hud,
- messages: [
- {
- name: "Was blocked because tracking protection is enabled",
- text: "The resource at \u201chttp://tracking.example.com/\u201d was " +
- "blocked because tracking protection is enabled",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_WARNING,
- objects: true,
- },
- ],
- });
-
- yield testClickOpenNewTab(hud, results[0]);
-});
-
-function testClickOpenNewTab(hud, match) {
- let warningNode = match.clickableElements[0];
- ok(warningNode, "link element");
- ok(warningNode.classList.contains("learn-more-link"), "link class name");
- return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/browser_webconsole_view_source.js
+++ /dev/null
@@ -1,42 +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/ */
-
-// Tests that source URLs in the Web Console can be clicked to display the
-// standard View Source window. As JS exceptions and console.log() messages always
-// have their locations opened in Debugger, we need to test a security message in
-// order to have it opened in the standard View Source window.
-
-"use strict";
-
-const TEST_URI = "https://example.com/browser/devtools/client/webconsole/old/" +
- "test/test-mixedcontent-securityerrors.html";
-
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole(null);
- info("console opened");
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: "Blocked loading mixed active content",
- category: CATEGORY_SECURITY,
- severity: SEVERITY_ERROR,
- }],
- });
-
- let msg = [...result.matched][0];
- ok(msg, "error message");
- let locationNode = msg.querySelector(".message-location .frame-link-filename");
- ok(locationNode, "location node");
-
- let onTabOpen = waitForTab();
-
- EventUtils.sendMouseEvent({ type: "click" }, locationNode);
-
- let tab = yield onTabOpen;
- ok(true, "the view source tab was opened in response to clicking the location node");
- gBrowser.removeTab(tab);
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/head.js
+++ /dev/null
@@ -1,1847 +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/ */
-
-/* import-globals-from ../../../shared/test/shared-head.js */
-"use strict";
-
-// shared-head.js handles imports, constants, and utility functions
-Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js", this);
-
-var {Utils: WebConsoleUtils} = require("devtools/client/webconsole/utils");
-var {Messages} = require("devtools/client/webconsole/old/console-output");
-const asyncStorage = require("devtools/shared/async-storage");
-const {HUDService} = require("devtools/client/webconsole/hudservice");
-
-// Services.prefs.setBoolPref("devtools.debugger.log", true);
-
-var gPendingOutputTest = 0;
-
-// The various categories of messages.
-const CATEGORY_NETWORK = 0;
-const CATEGORY_CSS = 1;
-const CATEGORY_JS = 2;
-const CATEGORY_WEBDEV = 3;
-const CATEGORY_INPUT = 4;
-const CATEGORY_OUTPUT = 5;
-const CATEGORY_SECURITY = 6;
-const CATEGORY_SERVER = 7;
-
-// The possible message severities.
-const SEVERITY_ERROR = 0;
-const SEVERITY_WARNING = 1;
-const SEVERITY_INFO = 2;
-const SEVERITY_LOG = 3;
-
-// The indent of a console group in pixels.
-const GROUP_INDENT = 12;
-
-var WCUL10n = require("devtools/client/webconsole/webconsole-l10n");
-
-const DOCS_GA_PARAMS = "?utm_source=mozilla" +
- "&utm_medium=firefox-console-errors" +
- "&utm_campaign=default";
-
-Services.prefs.setBoolPref("devtools.browserconsole.new-frontend-enabled", false);
-registerCleanupFunction(async function () {
- Services.prefs.clearUserPref("devtools.browserconsole.new-frontend-enabled");
-});
-
-function loadTab(url, preferredRemoteType) {
- return addTab(url, { preferredRemoteType }).then( tab => {
- return { tab, browser: tab.linkedBrowser };
- });
-}
-
-function loadBrowser(browser) {
- return BrowserTestUtils.browserLoaded(browser);
-}
-
-function closeTab(tab) {
- return removeTab(tab);
-}
-
-/**
- * Load the page and return the associated HUD.
- *
- * @param string uri
- * The URI of the page to load.
- * @param string consoleType [optional]
- * The console type, either "browserConsole" or "webConsole". Defaults to
- * "webConsole".
- * @return object
- * The HUD associated with the console
- */
-function* loadPageAndGetHud(uri, consoleType) {
- let { browser } = yield loadTab("data:text/html;charset=utf-8,Loading tab for tests");
-
- let hud;
- if (consoleType === "browserConsole") {
- hud = yield HUDService.openBrowserConsoleOrFocus();
- } else {
- hud = yield openConsole();
- }
-
- ok(hud, "Console was opened");
-
- let loaded = loadBrowser(browser);
- yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, uri);
- yield loaded;
-
- yield waitForMessages({
- webconsole: hud,
- messages: [{
- text: uri,
- category: CATEGORY_NETWORK,
- severity: SEVERITY_LOG,
- }],
- });
-
- return hud;
-}
-
-function afterAllTabsLoaded(callback, win) {
- win = win || window;
-
- let stillToLoad = 0;
-
- function onLoad() {
- this.removeEventListener("load", onLoad, true);
- stillToLoad--;
- if (!stillToLoad) {
- callback();
- }
- }
-
- for (let a = 0; a < win.gBrowser.tabs.length; a++) {
- let browser = win.gBrowser.tabs[a].linkedBrowser;
- if (browser.webProgress.isLoadingDocument) {
- stillToLoad++;
- browser.addEventListener("load", onLoad, true);
- }
- }
-
- if (!stillToLoad) {
- callback();
- }
-}
-
-/**
- * Wait for a predicate to return a result.
- *
- * @param function condition
- * Invoked once in a while until it returns a truthy value. This should be an
- * idempotent function, since we have to run it a second time after it returns
- * true in order to return the value.
- * @param string message [optional]
- * A message to output if the condition fails.
- * @param number interval [optional]
- * How often the predicate is invoked, in milliseconds.
- * @return object
- * A promise that is resolved with the result of the condition.
- */
-async function waitFor(condition, message = "waitFor", interval = 10, maxTries = 500) {
- await BrowserTestUtils.waitForCondition(condition, message, interval, maxTries);
- return condition();
-}
-
-/**
- * Check if a log entry exists in the HUD output node.
- *
- * @param {Element} outputNode
- * the HUD output node.
- * @param {string} matchString
- * the string you want to check if it exists in the output node.
- * @param {string} msg
- * the message describing the test
- * @param {boolean} [onlyVisible=false]
- * find only messages that are visible, not hidden by the filter.
- * @param {boolean} [failIfFound=false]
- * fail the test if the string is found in the output node.
- * @param {string} cssClass [optional]
- * find only messages with the given CSS class.
- */
-function testLogEntry(outputNode, matchString, msg, onlyVisible,
- failIfFound, cssClass) {
- let selector = ".message";
- // Skip entries that are hidden by the filter.
- if (onlyVisible) {
- selector += ":not(.filtered-by-type):not(.filtered-by-string)";
- }
- if (cssClass) {
- selector += "." + aClass;
- }
-
- let msgs = outputNode.querySelectorAll(selector);
- let found = false;
- for (let i = 0, n = msgs.length; i < n; i++) {
- let message = msgs[i].textContent.indexOf(matchString);
- if (message > -1) {
- found = true;
- break;
- }
- }
-
- is(found, !failIfFound, msg);
-}
-
-/**
- * A convenience method to call testLogEntry().
- *
- * @param str string
- * The string to find.
- */
-function findLogEntry(str) {
- testLogEntry(outputNode, str, "found " + str);
-}
-
-/**
- * Open the Web Console for the given tab.
- *
- * @param nsIDOMElement [tab]
- * Optional tab element for which you want open the Web Console. The
- * default tab is taken from the global variable |tab|.
- * @param function [callback]
- * Optional function to invoke after the Web Console completes
- * initialization (web-console-created).
- * @return object
- * A promise that is resolved once the web console is open.
- */
-var openConsole = function (tab) {
- let webconsoleOpened = defer();
- let target = TargetFactory.forTab(tab || gBrowser.selectedTab);
- gDevTools.showToolbox(target, "webconsole").then(toolbox => {
- let hud = toolbox.getCurrentPanel().hud;
- hud.jsterm._lazyVariablesView = false;
- webconsoleOpened.resolve(hud);
- });
- return webconsoleOpened.promise;
-};
-
-/**
- * Close the Web Console for the given tab.
- *
- * @param nsIDOMElement [tab]
- * Optional tab element for which you want close the Web Console. The
- * default tab is taken from the global variable |tab|.
- * @param function [callback]
- * Optional function to invoke after the Web Console completes
- * closing (web-console-destroyed).
- * @return object
- * A promise that is resolved once the web console is closed.
- */
-var closeConsole = Task.async(function* (tab) {
- let target = TargetFactory.forTab(tab || gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
- if (toolbox) {
- yield toolbox.destroy();
- }
-});
-
-/**
- * Listen for a new tab to open and return a promise that resolves when one
- * does and completes the load event.
- * @return a promise that resolves to the tab object
- */
-var waitForTab = Task.async(function* () {
- info("Waiting for a tab to open");
- yield once(gBrowser.tabContainer, "TabOpen");
- let tab = gBrowser.selectedTab;
- let browser = tab.linkedBrowser;
- yield BrowserTestUtils.browserLoaded(browser);
- info("The tab load completed");
- return tab;
-});
-
-/**
- * Dump the output of all open Web Consoles - used only for debugging purposes.
- */
-function dumpConsoles() {
- if (gPendingOutputTest) {
- console.log("dumpConsoles start");
- for (let [, hud] of HUDService.consoles) {
- if (!hud.outputNode) {
- console.debug("no output content for", hud.hudId);
- continue;
- }
-
- console.debug("output content for", hud.hudId);
- for (let elem of hud.outputNode.childNodes) {
- dumpMessageElement(elem);
- }
- }
- console.log("dumpConsoles end");
-
- gPendingOutputTest = 0;
- }
-}
-
-/**
- * Dump to output debug information for the given webconsole message.
- *
- * @param nsIDOMNode message
- * The message element you want to display.
- */
-function dumpMessageElement(message) {
- let text = message.textContent;
- let repeats = message.querySelector(".message-repeats");
- if (repeats) {
- repeats = repeats.getAttribute("value");
- }
- console.debug("id", message.getAttribute("id"),
- "date", message.timestamp,
- "class", message.className,
- "category", message.category,
- "severity", message.severity,
- "repeats", repeats,
- "clipboardText", message.clipboardText,
- "text", text);
-}
-
-var finishTest = Task.async(function* () {
- dumpConsoles();
-
- let browserConsole = HUDService.getBrowserConsole();
- if (browserConsole) {
- if (browserConsole.jsterm) {
- browserConsole.jsterm.clearOutput(true);
- }
- yield HUDService.toggleBrowserConsole();
- }
-
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- yield gDevTools.closeToolbox(target);
-
- finish();
-});
-
-// Always use the 'old' frontend for tests that rely on it
-Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
-});
-
-registerCleanupFunction(function* () {
- // Remove stored console commands in between tests
- yield asyncStorage.removeItem("webConsoleHistory");
-
- dumpConsoles();
-
- let browserConsole = HUDService.getBrowserConsole();
- if (browserConsole) {
- if (browserConsole.jsterm) {
- browserConsole.jsterm.clearOutput(true);
- }
- yield HUDService.toggleBrowserConsole();
- }
-
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- yield gDevTools.closeToolbox(target);
-
- while (gBrowser.tabs.length > 1) {
- gBrowser.removeCurrentTab();
- }
-});
-
-waitForExplicitFinish();
-
-/**
- * Polls a given function waiting for it to become true.
- *
- * @param object options
- * Options object with the following properties:
- * - validator
- * A validator function that returns a boolean. This is called every few
- * milliseconds to check if the result is true. When it is true, the
- * promise is resolved and polling stops. If validator never returns
- * true, then polling timeouts after several tries and the promise is
- * rejected.
- * - name
- * Name of test. This is used to generate the success and failure
- * messages.
- * - timeout
- * Timeout for validator function, in milliseconds. Default is 5000.
- * @return object
- * A Promise object that is resolved based on the validator function.
- */
-function waitForSuccess(options) {
- let deferred = defer();
- let start = Date.now();
- let timeout = options.timeout || 5000;
- let {validator} = options;
-
- function wait() {
- if ((Date.now() - start) > timeout) {
- // Log the failure.
- ok(false, "Timed out while waiting for: " + options.name);
- deferred.reject(null);
- return;
- }
-
- if (validator(options)) {
- ok(true, options.name);
- deferred.resolve(null);
- } else {
- setTimeout(wait, 100);
- }
- }
-
- setTimeout(wait, 100);
-
- return deferred.promise;
-}
-
-var openInspector = Task.async(function* (tab = gBrowser.selectedTab) {
- let target = TargetFactory.forTab(tab);
- let toolbox = yield gDevTools.showToolbox(target, "inspector");
- return toolbox.getCurrentPanel();
-});
-
-/**
- * Find variables or properties in a VariablesView instance.
- *
- * @param object view
- * The VariablesView instance.
- * @param array rules
- * The array of rules you want to match. Each rule is an object with:
- * - name (string|regexp): property name to match.
- * - value (string|regexp): property value to match.
- * - isIterator (boolean): check if the property is an iterator.
- * - isGetter (boolean): check if the property is a getter.
- * - isGenerator (boolean): check if the property is a generator.
- * - dontMatch (boolean): make sure the rule doesn't match any property.
- * @param object options
- * Options for matching:
- * - webconsole: the WebConsole instance we work with.
- * @return object
- * A promise object that is resolved when all the rules complete
- * matching. The resolved callback is given an array of all the rules
- * you wanted to check. Each rule has a new property: |matchedProp|
- * which holds a reference to the Property object instance from the
- * VariablesView. If the rule did not match, then |matchedProp| is
- * undefined.
- */
-function findVariableViewProperties(view, rules, options) {
- // Initialize the search.
- function init() {
- // Separate out the rules that require expanding properties throughout the
- // view.
- let expandRules = [];
- let filterRules = rules.filter((rule) => {
- if (typeof rule.name == "string" && rule.name.indexOf(".") > -1) {
- expandRules.push(rule);
- return false;
- }
- return true;
- });
-
- // Search through the view those rules that do not require any properties to
- // be expanded. Build the array of matchers, outstanding promises to be
- // resolved.
- let outstanding = [];
- finder(filterRules, view, outstanding);
-
- // Process the rules that need to expand properties.
- let lastStep = processExpandRules.bind(null, expandRules);
-
- // Return the results - a promise resolved to hold the updated rules array.
- let returnResults = onAllRulesMatched.bind(null, rules);
-
- return promise.all(outstanding).then(lastStep).then(returnResults);
- }
-
- function onMatch(prop, rule, matched) {
- if (matched && !rule.matchedProp) {
- rule.matchedProp = prop;
- }
- }
-
- function finder(rules, vars, promises) {
- for (let [, prop] of vars) {
- for (let rule of rules) {
- let matcher = matchVariablesViewProperty(prop, rule, options);
- promises.push(matcher.then(onMatch.bind(null, prop, rule)));
- }
- }
- }
-
- function processExpandRules(rules) {
- let rule = rules.shift();
- if (!rule) {
- return promise.resolve(null);
- }
-
- let deferred = defer();
- let expandOptions = {
- rootVariable: view,
- expandTo: rule.name,
- webconsole: options.webconsole,
- };
-
- variablesViewExpandTo(expandOptions).then(function onSuccess(prop) {
- let name = rule.name;
- let lastName = name.split(".").pop();
- rule.name = lastName;
-
- let matched = matchVariablesViewProperty(prop, rule, options);
- return matched.then(onMatch.bind(null, prop, rule)).then(function () {
- rule.name = name;
- });
- }, function onFailure() {
- return promise.resolve(null);
- }).then(processExpandRules.bind(null, rules)).then(function () {
- deferred.resolve(null);
- });
-
- return deferred.promise;
- }
-
- function onAllRulesMatched(rules) {
- for (let rule of rules) {
- let matched = rule.matchedProp;
- if (matched && !rule.dontMatch) {
- ok(true, "rule " + rule.name + " matched for property " + matched.name);
- } else if (matched && rule.dontMatch) {
- ok(false, "rule " + rule.name + " should not match property " +
- matched.name);
- } else {
- ok(rule.dontMatch, "rule " + rule.name + " did not match any property");
- }
- }
- return rules;
- }
-
- return init();
-}
-
-/**
- * Check if a given Property object from the variables view matches the given
- * rule.
- *
- * @param object prop
- * The variable's view Property instance.
- * @param object rule
- * Rules for matching the property. See findVariableViewProperties() for
- * details.
- * @param object options
- * Options for matching. See findVariableViewProperties().
- * @return object
- * A promise that is resolved when all the checks complete. Resolution
- * result is a boolean that tells your promise callback the match
- * result: true or false.
- */
-function matchVariablesViewProperty(prop, rule, options) {
- function resolve(result) {
- return promise.resolve(result);
- }
-
- if (rule.name) {
- let match = rule.name instanceof RegExp ?
- rule.name.test(prop.name) :
- prop.name == rule.name;
- if (!match) {
- return resolve(false);
- }
- }
-
- if (rule.value) {
- let displayValue = prop.displayValue;
- if (prop.displayValueClassName == "token-string") {
- displayValue = displayValue.substring(1, displayValue.length - 1);
- }
-
- let match = rule.value instanceof RegExp ?
- rule.value.test(displayValue) :
- displayValue == rule.value;
- if (!match) {
- info("rule " + rule.name + " did not match value, expected '" +
- rule.value + "', found '" + displayValue + "'");
- return resolve(false);
- }
- }
-
- if ("isGetter" in rule) {
- let isGetter = !!(prop.getter && prop.get("get"));
- if (rule.isGetter != isGetter) {
- info("rule " + rule.name + " getter test failed");
- return resolve(false);
- }
- }
-
- if ("isGenerator" in rule) {
- let isGenerator = prop.displayValue == "Generator";
- if (rule.isGenerator != isGenerator) {
- info("rule " + rule.name + " generator test failed");
- return resolve(false);
- }
- }
-
- let outstanding = [];
-
- if ("isIterator" in rule) {
- let isIterator = isVariableViewPropertyIterator(prop, options.webconsole);
- outstanding.push(isIterator.then((result) => {
- if (result != rule.isIterator) {
- info("rule " + rule.name + " iterator test failed");
- }
- return result == rule.isIterator;
- }));
- }
-
- outstanding.push(promise.resolve(true));
-
- return promise.all(outstanding).then(function _onMatchDone(results) {
- let ruleMatched = !results.includes(false);
- return resolve(ruleMatched);
- });
-}
-
-/**
- * Check if the given variables view property is an iterator.
- *
- * @param object prop
- * The Property instance you want to check.
- * @param object webConsole
- * The WebConsole instance to work with.
- * @return object
- * A promise that is resolved when the check completes. The resolved
- * callback is given a boolean: true if the property is an iterator, or
- * false otherwise.
- */
-function isVariableViewPropertyIterator(prop, webConsole) {
- if (prop.displayValue == "Iterator") {
- return promise.resolve(true);
- }
-
- let deferred = defer();
-
- variablesViewExpandTo({
- rootVariable: prop,
- expandTo: "__proto__.__iterator__",
- webconsole: webConsole,
- }).then(function onSuccess() {
- deferred.resolve(true);
- }, function onFailure() {
- deferred.resolve(false);
- });
-
- return deferred.promise;
-}
-
-/**
- * Recursively expand the variables view up to a given property.
- *
- * @param options
- * Options for view expansion:
- * - rootVariable: start from the given scope/variable/property.
- * - expandTo: string made up of property names you want to expand.
- * For example: "body.firstChild.nextSibling" given |rootVariable:
- * document|.
- * - webconsole: a WebConsole instance. If this is not provided all
- * property expand() calls will be considered sync. Things may fail!
- * @return object
- * A promise that is resolved only when the last property in |expandTo|
- * is found, and rejected otherwise. Resolution reason is always the
- * last property - |nextSibling| in the example above. Rejection is
- * always the last property that was found.
- */
-function variablesViewExpandTo(options) {
- let root = options.rootVariable;
- let expandTo = options.expandTo.split(".");
- let jsterm = (options.webconsole || {}).jsterm;
- let lastDeferred = defer();
-
- function fetch(prop) {
- if (!prop.onexpand) {
- ok(false, "property " + prop.name + " cannot be expanded: !onexpand");
- return promise.reject(prop);
- }
-
- let deferred = defer();
-
- if (prop._fetched || !jsterm) {
- executeSoon(function () {
- deferred.resolve(prop);
- });
- } else {
- jsterm.once("variablesview-fetched", function _onFetchProp() {
- executeSoon(() => deferred.resolve(prop));
- });
- }
-
- prop.expand();
-
- return deferred.promise;
- }
-
- function getNext(prop) {
- let name = expandTo.shift();
- let newProp = prop.get(name);
-
- if (expandTo.length > 0) {
- ok(newProp, "found property " + name);
- if (newProp) {
- fetch(newProp).then(getNext, fetchError);
- } else {
- lastDeferred.reject(prop);
- }
- } else if (newProp) {
- lastDeferred.resolve(newProp);
- } else {
- lastDeferred.reject(prop);
- }
- }
-
- function fetchError(prop) {
- lastDeferred.reject(prop);
- }
-
- if (!root._fetched) {
- fetch(root).then(getNext, fetchError);
- } else {
- getNext(root);
- }
-
- return lastDeferred.promise;
-}
-
-/**
- * Update the content of a property in the variables view.
- *
- * @param object options
- * Options for the property update:
- * - property: the property you want to change.
- * - field: string that tells what you want to change:
- * - use "name" to change the property name,
- * - or "value" to change the property value.
- * - string: the new string to write into the field.
- * - webconsole: reference to the Web Console instance we work with.
- * @return object
- * A Promise object that is resolved once the property is updated.
- */
-var updateVariablesViewProperty = Task.async(function* (options) {
- let view = options.property._variablesView;
- view.window.focus();
- options.property.focus();
-
- switch (options.field) {
- case "name":
- EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, view.window);
- break;
- case "value":
- EventUtils.synthesizeKey("VK_RETURN", {}, view.window);
- break;
- default:
- throw new Error("options.field is incorrect");
- }
-
- let deferred = defer();
-
- executeSoon(() => {
- EventUtils.synthesizeKey("A", { accelKey: true }, view.window);
-
- for (let c of options.string) {
- EventUtils.synthesizeKey(c, {}, view.window);
- }
-
- if (options.webconsole) {
- options.webconsole.jsterm.once("variablesview-fetched")
- .then((varView) => deferred.resolve(varView));
- }
-
- EventUtils.synthesizeKey("VK_RETURN", {}, view.window);
-
- if (!options.webconsole) {
- executeSoon(() => {
- deferred.resolve(null);
- });
- }
- });
-
- return deferred.promise;
-});
-
-/**
- * Open the JavaScript debugger.
- *
- * @param object options
- * Options for opening the debugger:
- * - tab: the tab you want to open the debugger for.
- * @return object
- * A promise that is resolved once the debugger opens, or rejected if
- * the open fails. The resolution callback is given one argument, an
- * object that holds the following properties:
- * - target: the Target object for the Tab.
- * - toolbox: the Toolbox instance.
- * - panel: the jsdebugger panel instance.
- * - panelWin: the window object of the panel iframe.
- */
-function openDebugger(options = {}) {
- if (!options.tab) {
- options.tab = gBrowser.selectedTab;
- }
-
- let deferred = defer();
-
- let target = TargetFactory.forTab(options.tab);
- let toolbox = gDevTools.getToolbox(target);
- let dbgPanelAlreadyOpen = toolbox && toolbox.getPanel("jsdebugger");
-
- gDevTools.showToolbox(target, "jsdebugger").then(function onSuccess(tool) {
- let panel = tool.getCurrentPanel();
- let panelWin = panel.panelWin;
-
- panel._view.Variables.lazyEmpty = false;
-
- let resolveObject = {
- target: target,
- toolbox: tool,
- panel: panel,
- panelWin: panelWin,
- };
-
- if (dbgPanelAlreadyOpen) {
- deferred.resolve(resolveObject);
- } else {
- panelWin.DebuggerController.waitForSourcesLoaded().then(() => {
- deferred.resolve(resolveObject);
- });
- }
- }, function onFailure(reason) {
- console.debug("failed to open the toolbox for 'jsdebugger'", reason);
- deferred.reject(reason);
- });
-
- return deferred.promise;
-}
-
-/**
- * Returns true if the caret in the debugger editor is placed at the specified
- * position.
- * @param panel The debugger panel.
- * @param {number} line The line number.
- * @param {number} [col] The column number.
- * @returns {boolean}
- */
-function isDebuggerCaretPos(panel, line, col = 1) {
- let editor = panel.panelWin.DebuggerView.editor;
- let cursor = editor.getCursor();
-
- // Source editor starts counting line and column numbers from 0.
- info("Current editor caret position: " + (cursor.line + 1) + ", " +
- (cursor.ch + 1));
- return cursor.line == (line - 1) && cursor.ch == (col - 1);
-}
-
-/**
- * Wait for messages in the Web Console output.
- *
- * @param object options
- * Options for what you want to wait for:
- * - webconsole: the webconsole instance you work with.
- * - matchCondition: "any" or "all". Default: "all". The promise
- * returned by this function resolves when all of the messages are
- * matched, if the |matchCondition| is "all". If you set the condition to
- * "any" then the promise is resolved by any message rule that matches,
- * irrespective of order - waiting for messages stops whenever any rule
- * matches.
- * - messages: an array of objects that tells which messages to wait for.
- * Properties:
- * - text: string or RegExp to match the textContent of each new
- * message.
- * - noText: string or RegExp that must not match in the message
- * textContent.
- * - repeats: the number of message repeats, as displayed by the Web
- * Console.
- * - category: match message category. See CATEGORY_* constants at
- * the top of this file.
- * - severity: match message severity. See SEVERITY_* constants at
- * the top of this file.
- * - count: how many unique web console messages should be matched by
- * this rule.
- * - consoleTrace: boolean, set to |true| to match a console.trace()
- * message. Optionally this can be an object of the form
- * { file, fn, line } that can match the specified file, function
- * and/or line number in the trace message.
- * - consoleTime: string that matches a console.time() timer name.
- * Provide this if you want to match a console.time() message.
- * - consoleTimeEnd: same as above, but for console.timeEnd().
- * - consoleDir: boolean, set to |true| to match a console.dir()
- * message.
- * - consoleGroup: boolean, set to |true| to match a console.group()
- * message.
- * - consoleTable: boolean, set to |true| to match a console.table()
- * message.
- * - longString: boolean, set to |true} to match long strings in the
- * message.
- * - collapsible: boolean, set to |true| to match messages that can
- * be collapsed/expanded.
- * - type: match messages that are instances of the given object. For
- * example, you can point to Messages.NavigationMarker to match any
- * such message.
- * - objects: boolean, set to |true| if you expect inspectable
- * objects in the message.
- * - source: object of the shape { url, line }. This is used to
- * match the source URL and line number of the error message or
- * console API call.
- * - prefix: prefix text to check for in the prefix element.
- * - stacktrace: array of objects of the form { file, fn, line } that
- * can match frames in the stacktrace associated with the message.
- * - groupDepth: number used to check the depth of the message in
- * a group.
- * - url: URL to match for network requests.
- * @return object
- * A promise object is returned once the messages you want are found.
- * The promise is resolved with the array of rule objects you give in
- * the |messages| property. Each objects is the same as provided, with
- * additional properties:
- * - matched: a Set of web console messages that matched the rule.
- * - clickableElements: a list of inspectable objects. This is available
- * if any of the following properties are present in the rule:
- * |consoleTrace| or |objects|.
- * - longStrings: a list of long string ellipsis elements you can click
- * in the message element, to expand a long string. This is available
- * only if |longString| is present in the matching rule.
- */
-function waitForMessages(options) {
- info("Waiting for messages...");
-
- gPendingOutputTest++;
- let webconsole = options.webconsole;
- let rules = WebConsoleUtils.cloneObject(options.messages, true);
- let rulesMatched = 0;
- let listenerAdded = false;
- let deferred = defer();
- options.matchCondition = options.matchCondition || "all";
-
- function checkText(rule, text) {
- let result = false;
- if (Array.isArray(rule)) {
- result = rule.every((s) => checkText(s, text));
- } else if (typeof rule == "string") {
- result = text.indexOf(rule) > -1;
- } else if (rule instanceof RegExp) {
- result = rule.test(text);
- } else {
- result = rule == text;
- }
- return result;
- }
-
- function checkConsoleTable(rule, element) {
- let elemText = element.textContent;
-
- if (!checkText("console.table():", elemText)) {
- return false;
- }
-
- rule.category = CATEGORY_WEBDEV;
- rule.severity = SEVERITY_LOG;
- rule.type = Messages.ConsoleTable;
-
- return true;
- }
-
- function checkConsoleTrace(rule, element) {
- let elemText = element.textContent;
- let trace = rule.consoleTrace;
-
- if (!checkText("console.trace():", elemText)) {
- return false;
- }
-
- rule.category = CATEGORY_WEBDEV;
- rule.severity = SEVERITY_LOG;
- rule.type = Messages.ConsoleTrace;
-
- if (!rule.stacktrace && typeof trace == "object" && trace !== true) {
- if (Array.isArray(trace)) {
- rule.stacktrace = trace;
- } else {
- rule.stacktrace = [trace];
- }
- }
-
- return true;
- }
-
- function checkConsoleTime(rule, element) {
- let elemText = element.textContent;
- let time = rule.consoleTime;
-
- if (!checkText(time + ": timer started", elemText)) {
- return false;
- }
-
- rule.category = CATEGORY_WEBDEV;
- rule.severity = SEVERITY_LOG;
-
- return true;
- }
-
- function checkConsoleTimeEnd(rule, element) {
- let elemText = element.textContent;
- let time = rule.consoleTimeEnd;
- let regex = new RegExp(time + ": -?\\d+([,.]\\d+)?ms");
-
- if (!checkText(regex, elemText)) {
- return false;
- }
-
- rule.category = CATEGORY_WEBDEV;
- rule.severity = SEVERITY_LOG;
-
- return true;
- }
-
- function checkConsoleDir(rule, element) {
- if (!element.classList.contains("inlined-variables-view")) {
- return false;
- }
-
- let elemText = element.textContent;
- if (!checkText(rule.consoleDir, elemText)) {
- return false;
- }
-
- let iframe = element.querySelector("iframe");
- if (!iframe) {
- ok(false, "console.dir message has no iframe");
- return false;
- }
-
- return true;
- }
-
- function checkConsoleGroup(rule) {
- if (!isNaN(parseInt(rule.consoleGroup, 10))) {
- rule.groupDepth = rule.consoleGroup;
- }
- rule.category = CATEGORY_WEBDEV;
- rule.severity = SEVERITY_LOG;
-
- return true;
- }
-
- function checkSource(rule, element) {
- let location = getRenderedSource(element);
- if (!location) {
- return false;
- }
-
- if (!checkText(rule.source.url, location.url)) {
- return false;
- }
-
- if ("line" in rule.source && location.line != rule.source.line) {
- return false;
- }
-
- return true;
- }
-
- function checkCollapsible(rule, element) {
- let msg = element._messageObject;
- if (!msg || !!msg.collapsible != rule.collapsible) {
- return false;
- }
-
- return true;
- }
-
- function checkStacktrace(rule, element) {
- let stack = rule.stacktrace;
- let frames = element.querySelectorAll(".stacktrace > .stack-trace > .frame-link");
- if (!frames.length) {
- return false;
- }
-
- for (let i = 0; i < stack.length; i++) {
- let frame = frames[i];
- let expected = stack[i];
- if (!frame) {
- ok(false, "expected frame #" + i + " but didnt find it");
- return false;
- }
-
- if (expected.file) {
- let url = frame.getAttribute("data-url");
- if (!checkText(expected.file, url)) {
- ok(false, "frame #" + i + " does not match file name: " +
- expected.file + " != " + url);
- displayErrorContext(rule, element);
- return false;
- }
- }
-
- if (expected.fn) {
- let fn = frame.querySelector(".frame-link-function-display-name").textContent;
- if (!checkText(expected.fn, fn)) {
- ok(false, "frame #" + i + " does not match the function name: " +
- expected.fn + " != " + fn);
- displayErrorContext(rule, element);
- return false;
- }
- }
-
- if (expected.line) {
- let line = frame.getAttribute("data-line");
- if (!checkText(expected.line, line)) {
- ok(false, "frame #" + i + " does not match the line number: " +
- expected.line + " != " + line);
- displayErrorContext(rule, element);
- return false;
- }
- }
- }
-
- return true;
- }
-
- function hasXhrLabel(element) {
- let xhr = element.querySelector(".xhr");
- if (!xhr) {
- return false;
- }
- return true;
- }
-
- function checkMessage(rule, element) {
- let elemText = element.textContent;
-
- if (rule.text && !checkText(rule.text, elemText)) {
- return false;
- }
-
- if (rule.noText && checkText(rule.noText, elemText)) {
- return false;
- }
-
- if (rule.consoleTable && !checkConsoleTable(rule, element)) {
- return false;
- }
-
- if (rule.consoleTrace && !checkConsoleTrace(rule, element)) {
- return false;
- }
-
- if (rule.consoleTime && !checkConsoleTime(rule, element)) {
- return false;
- }
-
- if (rule.consoleTimeEnd && !checkConsoleTimeEnd(rule, element)) {
- return false;
- }
-
- if (rule.consoleDir && !checkConsoleDir(rule, element)) {
- return false;
- }
-
- if (rule.consoleGroup && !checkConsoleGroup(rule, element)) {
- return false;
- }
-
- if (rule.source && !checkSource(rule, element)) {
- return false;
- }
-
- if ("collapsible" in rule && !checkCollapsible(rule, element)) {
- return false;
- }
-
- if (rule.isXhr && !hasXhrLabel(element)) {
- return false;
- }
-
- if (!rule.isXhr && hasXhrLabel(element)) {
- return false;
- }
-
- let partialMatch = !!(rule.consoleTrace || rule.consoleTime ||
- rule.consoleTimeEnd);
-
- // The rule tries to match the newer types of messages, based on their
- // object constructor.
- if (rule.type) {
- if (!element._messageObject ||
- !(element._messageObject instanceof rule.type)) {
- if (partialMatch) {
- ok(false, "message type for rule: " + displayRule(rule));
- displayErrorContext(rule, element);
- }
- return false;
- }
- partialMatch = true;
- }
-
- if ("category" in rule && element.category != rule.category) {
- if (partialMatch) {
- is(element.category, rule.category,
- "message category for rule: " + displayRule(rule));
- displayErrorContext(rule, element);
- }
- return false;
- }
-
- if ("severity" in rule && element.severity != rule.severity) {
- if (partialMatch) {
- is(element.severity, rule.severity,
- "message severity for rule: " + displayRule(rule));
- displayErrorContext(rule, element);
- }
- return false;
- }
-
- if (rule.text) {
- partialMatch = true;
- }
-
- if (rule.stacktrace && !checkStacktrace(rule, element)) {
- if (partialMatch) {
- ok(false, "failed to match stacktrace for rule: " + displayRule(rule));
- displayErrorContext(rule, element);
- }
- return false;
- }
-
- if (rule.category == CATEGORY_NETWORK && "url" in rule &&
- !checkText(rule.url, element.url)) {
- return false;
- }
-
- if ("repeats" in rule) {
- let repeats = element.querySelector(".message-repeats");
- if (!repeats || repeats.getAttribute("value") != rule.repeats) {
- return false;
- }
- }
-
- if ("groupDepth" in rule) {
- let indentNode = element.querySelector(".indent");
- let indent = (GROUP_INDENT * rule.groupDepth) + "px";
- if (!indentNode || indentNode.style.width != indent) {
- is(indentNode.style.width, indent,
- "group depth check failed for message rule: " + displayRule(rule));
- return false;
- }
- }
-
- if ("longString" in rule) {
- let longStrings = element.querySelectorAll(".longStringEllipsis");
- if (rule.longString != !!longStrings[0]) {
- if (partialMatch) {
- is(!!longStrings[0], rule.longString,
- "long string existence check failed for message rule: " +
- displayRule(rule));
- displayErrorContext(rule, element);
- }
- return false;
- }
- rule.longStrings = longStrings;
- }
-
- if ("objects" in rule) {
- let clickables = element.querySelectorAll(".message-body a");
- if (rule.objects != !!clickables[0]) {
- if (partialMatch) {
- is(!!clickables[0], rule.objects,
- "objects existence check failed for message rule: " +
- displayRule(rule));
- displayErrorContext(rule, element);
- }
- return false;
- }
- rule.clickableElements = clickables;
- }
-
- if ("prefix" in rule) {
- let prefixNode = element.querySelector(".prefix");
- is(prefixNode && prefixNode.textContent, rule.prefix, "Check prefix");
- }
-
- let count = rule.count || 1;
- if (!rule.matched) {
- rule.matched = new Set();
- }
- rule.matched.add(element);
-
- return rule.matched.size == count;
- }
-
- function onMessagesAdded(newMessages) {
- for (let msg of newMessages) {
- let elem = msg.node;
- let location = getRenderedSource(elem);
- if (location && location.url) {
- let url = location.url;
- // Prevent recursion with the browser console and any potential
- // messages coming from head.js.
- if (url.includes("devtools/client/webconsole/old/test/head.js")) {
- continue;
- }
- }
-
- for (let rule of rules) {
- if (rule._ruleMatched) {
- continue;
- }
-
- let matched = checkMessage(rule, elem);
- if (matched) {
- rule._ruleMatched = true;
- rulesMatched++;
- ok(1, "matched rule: " + displayRule(rule));
- if (maybeDone()) {
- return;
- }
- }
- }
- }
- }
-
- function allRulesMatched() {
- return options.matchCondition == "all" && rulesMatched == rules.length ||
- options.matchCondition == "any" && rulesMatched > 0;
- }
-
- function maybeDone() {
- if (allRulesMatched()) {
- if (listenerAdded) {
- webconsole.ui.off("new-messages", onMessagesAdded);
- }
- gPendingOutputTest--;
- deferred.resolve(rules);
- return true;
- }
- return false;
- }
-
- function testCleanup() {
- if (allRulesMatched()) {
- return;
- }
-
- if (webconsole.ui) {
- webconsole.ui.off("new-messages", onMessagesAdded);
- }
-
- for (let rule of rules) {
- if (!rule._ruleMatched) {
- ok(false, "failed to match rule: " + displayRule(rule));
- }
- }
- }
-
- function displayRule(rule) {
- return rule.name || rule.text;
- }
-
- function displayErrorContext(rule, element) {
- console.log("error occured during rule " + displayRule(rule));
- console.log("while checking the following message");
- dumpMessageElement(element);
- }
-
- executeSoon(() => {
- let messages = [];
- for (let elem of webconsole.outputNode.childNodes) {
- messages.push({
- node: elem,
- update: false,
- });
- }
-
- onMessagesAdded(messages);
-
- if (!allRulesMatched()) {
- listenerAdded = true;
- registerCleanupFunction(testCleanup);
- webconsole.ui.on("new-messages", onMessagesAdded);
- }
- });
-
- return deferred.promise;
-}
-
-function whenDelayedStartupFinished(win, callback) {
- Services.obs.addObserver(function observer(subject, topic) {
- if (win == subject) {
- Services.obs.removeObserver(observer, topic);
- executeSoon(callback);
- }
- }, "browser-delayed-startup-finished");
-}
-
-/**
- * Check the web console output for the given inputs. Each input is checked for
- * the expected JS eval result, the result of calling print(), the result of
- * console.log(). The JS eval result is also checked if it opens the variables
- * view on click.
- *
- * @param object hud
- * The web console instance to work with.
- * @param array inputTests
- * An array of input tests. An input test element is an object. Each
- * object has the following properties:
- * - input: string, JS input value to execute.
- *
- * - output: string|RegExp, expected JS eval result.
- *
- * - inspectable: boolean, when true, the test runner expects the JS eval
- * result is an object that can be clicked for inspection.
- *
- * - noClick: boolean, when true, the test runner does not click the JS
- * eval result. Some objects, like |window|, have a lot of properties and
- * opening vview for them is very slow (they can cause timeouts in debug
- * builds).
- *
- * - consoleOutput: string|RegExp, optional, expected consoleOutput
- * If not provided consoleOuput = output;
- *
- * - printOutput: string|RegExp, optional, expected output for
- * |print(input)|. If this is not provided, printOutput = output.
- *
- * - variablesViewLabel: string|RegExp, optional, the expected variables
- * view label when the object is inspected. If this is not provided, then
- * |output| is used.
- *
- * - inspectorIcon: boolean, when true, the test runner expects the
- * result widget to contain an inspectorIcon element (className
- * open-inspector).
- *
- * - expectedTab: string, optional, the full URL of the new tab which
- * must open. If this is not provided, any new tabs that open will cause
- * a test failure.
- */
-function checkOutputForInputs(hud, inputTests) {
- let container = gBrowser.tabContainer;
-
- function* runner() {
- for (let [i, entry] of inputTests.entries()) {
- info("checkInput(" + i + "): " + entry.input);
- yield checkInput(entry);
- }
- container = null;
- }
-
- function* checkInput(entry) {
- yield checkConsoleLog(entry);
- yield checkPrintOutput(entry);
- yield checkJSEval(entry);
- }
-
- function* checkConsoleLog(entry) {
- info("Logging");
- hud.jsterm.clearOutput();
- hud.jsterm.execute("console.log(" + entry.input + ")");
-
- let consoleOutput = "consoleOutput" in entry ?
- entry.consoleOutput : entry.output;
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "console.log() output: " + consoleOutput,
- text: consoleOutput,
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
-
- let msg = [...result.matched][0];
-
- if (entry.consoleLogClick) {
- yield checkObjectClick(entry, msg);
- }
-
- if (typeof entry.inspectorIcon == "boolean") {
- info("Checking Inspector Link");
- yield checkLinkToInspector(entry.inspectorIcon, msg);
- }
- }
-
- function checkPrintOutput(entry) {
- info("Printing");
- hud.jsterm.clearOutput();
- hud.jsterm.execute("print(" + entry.input + ")");
-
- let printOutput = entry.printOutput || entry.output;
-
- return waitForMessages({
- webconsole: hud,
- messages: [{
- name: "print() output: " + printOutput,
- text: printOutput,
- category: CATEGORY_OUTPUT,
- }],
- });
- }
-
- function* checkJSEval(entry) {
- info("Evaluating");
- hud.jsterm.clearOutput();
- hud.jsterm.execute(entry.input);
-
- let evalOutput = entry.evalOutput || entry.output;
-
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- name: "JS eval output: " + entry.evalOutput,
- text: entry.evalOutput,
- category: CATEGORY_OUTPUT,
- }],
- });
-
- let msg = [...result.matched][0];
- if (!entry.noClick) {
- yield checkObjectClick(entry, msg);
- }
- if (typeof entry.inspectorIcon == "boolean") {
- info("Checking Inspector Link: " + entry.input);
- yield checkLinkToInspector(entry.inspectorIcon, msg);
- }
- }
-
- function* checkObjectClick(entry, msg) {
- info("Clicking");
- let body;
- if (entry.getClickableNode) {
- body = entry.getClickableNode(msg);
- } else {
- body = msg.querySelector(".message-body a") ||
- msg.querySelector(".message-body");
- }
- ok(body, "the message body");
-
- let deferredVariablesView = defer();
- entry._onVariablesViewOpen = onVariablesViewOpen.bind(null, entry,
- deferredVariablesView);
- hud.jsterm.on("variablesview-open", entry._onVariablesViewOpen);
-
- let deferredTab = defer();
- entry._onTabOpen = onTabOpen.bind(null, entry, deferredTab);
- container.addEventListener("TabOpen", entry._onTabOpen, true);
-
- body.scrollIntoView();
-
- if (!entry.suppressClick) {
- EventUtils.synthesizeMouse(body, 2, 2, {}, hud.iframeWindow);
- }
-
- if (entry.inspectable) {
- info("message body tagName '" + body.tagName + "' className '" +
- body.className + "'");
- yield deferredVariablesView.promise;
- } else {
- hud.jsterm.off("variablesview-open", entry._onVariablesView);
- entry._onVariablesView = null;
- }
-
- if (entry.expectedTab) {
- yield deferredTab.promise;
- } else {
- container.removeEventListener("TabOpen", entry._onTabOpen, true);
- entry._onTabOpen = null;
- }
-
- yield promise.resolve(null);
- }
-
- function onVariablesViewOpen(entry, {resolve, reject}, {view, options}) {
- info("Variables view opened");
- let label = entry.variablesViewLabel || entry.output;
- if (typeof label == "string" && options.label != label) {
- return;
- }
- if (label instanceof RegExp && !label.test(options.label)) {
- return;
- }
-
- hud.jsterm.off("variablesview-open", entry._onVariablesViewOpen);
- entry._onVariablesViewOpen = null;
- ok(entry.inspectable, "variables view was shown");
-
- resolve(null);
- }
-
- function onTabOpen(entry, {resolve, reject}, event) {
- container.removeEventListener("TabOpen", entry._onTabOpen, true);
- entry._onTabOpen = null;
- let tab = event.target;
- let browser = gBrowser.getBrowserForTab(tab);
-
- Task.spawn(function* () {
- yield loadBrowser(browser);
- let uri = yield ContentTask.spawn(browser, {}, function* () {
- return content.location.href;
- });
- ok(entry.expectedTab && entry.expectedTab == uri,
- "opened tab '" + uri + "', expected tab '" + entry.expectedTab + "'");
- yield closeTab(tab);
- }).then(resolve, reject);
- }
-
- return Task.spawn(runner);
-}
-
-/**
- * Check the web console DOM element output for the given inputs.
- * Each input is checked for the expected JS eval result. The JS eval result is
- * also checked if it opens the inspector with the correct node selected on
- * inspector icon click
- *
- * @param object hud
- * The web console instance to work with.
- * @param array inputTests
- * An array of input tests. An input test element is an object. Each
- * object has the following properties:
- * - input: string, JS input value to execute.
- *
- * - output: string, expected JS eval result.
- *
- * - displayName: string, expected NodeFront's displayName.
- *
- * - attr: Array, expected NodeFront's attributes
- */
-function checkDomElementHighlightingForInputs(hud, inputs) {
- function* runner() {
- let toolbox = gDevTools.getToolbox(hud.target);
-
- // Loading the inspector panel at first, to make it possible to listen for
- // new node selections
- yield toolbox.selectTool("inspector");
- let inspector = toolbox.getCurrentPanel();
- yield toolbox.selectTool("webconsole");
-
- info("Iterating over the test data");
- for (let data of inputs) {
- let [result] = yield jsEval(data.input, {text: data.output});
- let {msg} = yield checkWidgetAndMessage(result);
- yield checkNodeHighlight(toolbox, inspector, msg, data);
- }
- }
-
- function jsEval(input, message) {
- info("Executing '" + input + "' in the web console");
-
- hud.jsterm.clearOutput();
- hud.jsterm.execute(input);
-
- return waitForMessages({
- webconsole: hud,
- messages: [message]
- });
- }
-
- function* checkWidgetAndMessage(result) {
- info("Getting the output ElementNode widget");
-
- let msg = [...result.matched][0];
- let widget = [...msg._messageObject.widgets][0];
- ok(widget, "ElementNode widget found in the output");
-
- info("Waiting for the ElementNode widget to be linked to the inspector");
- yield widget.linkToInspector();
-
- return {widget, msg};
- }
-
- function* checkNodeHighlight(toolbox, inspector, msg, testData) {
- let inspectorIcon = msg.querySelector(".open-inspector");
- ok(inspectorIcon, "Inspector icon found in the ElementNode widget");
-
- info("Clicking on the inspector icon and waiting for the " +
- "inspector to be selected");
- let onInspectorSelected = toolbox.once("inspector-selected");
- let onInspectorUpdated = inspector.once("inspector-updated");
- let onNewNode = toolbox.selection.once("new-node-front");
- let onNodeHighlight = toolbox.once("node-highlight");
-
- EventUtils.synthesizeMouseAtCenter(inspectorIcon, {},
- inspectorIcon.ownerDocument.defaultView);
- yield onInspectorSelected;
- yield onInspectorUpdated;
- yield onNodeHighlight;
- let nodeFront = yield onNewNode;
-
- ok(true, "Inspector selected and new node got selected");
-
- is(nodeFront.displayName, testData.displayName,
- "The correct node was highlighted");
-
- if (testData.attrs) {
- let attrs = nodeFront.attributes;
- for (let i in testData.attrs) {
- is(attrs[i].name, testData.attrs[i].name,
- "Expected attribute's name is present");
- is(attrs[i].value, testData.attrs[i].value,
- "Expected attribute's value is present");
- }
- }
-
- info("Unhighlight the node by moving away from the markup view");
- let onNodeUnhighlight = toolbox.once("node-unhighlight");
- let btn =
- inspector.toolbox.doc.getElementById("toolbox-meatball-menu-button");
- EventUtils.synthesizeMouseAtCenter(btn, {type: "mousemove"},
- inspector.toolbox.win);
- yield onNodeUnhighlight;
-
- info("Switching back to the console");
- yield toolbox.selectTool("webconsole");
- }
-
- return Task.spawn(runner);
-}
-
-/**
- * Finish the request and resolve with the request object.
- *
- * @param {Function} predicate A predicate function that takes the request
- * object as an argument and returns true if the request was the expected one,
- * false otherwise. The returned promise is resolved ONLY if the predicate
- * matches a request. Defaults to accepting any request.
- * @return promise
- * @resolves The request object.
- */
-function waitForFinishedRequest(predicate = () => true) {
- registerCleanupFunction(function () {
- HUDService.lastFinishedRequest.callback = null;
- });
-
- return new Promise(resolve => {
- HUDService.lastFinishedRequest.callback = request => {
- // Check if this is the expected request
- if (predicate(request)) {
- // Match found. Clear the listener.
- HUDService.lastFinishedRequest.callback = null;
-
- resolve(request);
- } else {
- info(`Ignoring unexpected request ${JSON.stringify(request, null, 2)}`);
- }
- };
- });
-}
-
-/**
- * Wait for eventName on target.
- * @param {Object} target An observable object that either supports on/off or
- * addEventListener/removeEventListener
- * @param {String} eventName
- * @param {Boolean} useCapture Optional for addEventListener/removeEventListener
- * @return A promise that resolves when the event has been handled
- */
-function once(target, eventName, useCapture = false) {
- info("Waiting for event: '" + eventName + "' on " + target + ".");
-
- let deferred = defer();
-
- for (let [add, remove] of [
- ["addEventListener", "removeEventListener"],
- ["addListener", "removeListener"],
- ["on", "off"]
- ]) {
- if ((add in target) && (remove in target)) {
- target[add](eventName, function onEvent(...aArgs) {
- target[remove](eventName, onEvent, useCapture);
- deferred.resolve.apply(deferred, aArgs);
- }, useCapture);
- break;
- }
- }
-
- return deferred.promise;
-}
-
-/**
- * Checks a link to the inspector
- *
- * @param {boolean} hasLinkToInspector Set to true if the message should
- * link to the inspector panel.
- * @param {element} msg The message to test.
- */
-function checkLinkToInspector(hasLinkToInspector, msg) {
- let elementNodeWidget = [...msg._messageObject.widgets][0];
- if (!elementNodeWidget) {
- ok(!hasLinkToInspector, "The message has no ElementNode widget");
- return true;
- }
-
- return elementNodeWidget.linkToInspector().then(() => {
- // linkToInspector resolved, check for the .open-inspector element
- if (hasLinkToInspector) {
- ok(msg.querySelectorAll(".open-inspector").length,
- "The ElementNode widget is linked to the inspector");
- } else {
- ok(!msg.querySelectorAll(".open-inspector").length,
- "The ElementNode widget isn't linked to the inspector");
- }
- }, () => {
- // linkToInspector promise rejected, node not linked to inspector
- ok(!hasLinkToInspector,
- "The ElementNode widget isn't linked to the inspector");
- });
-}
-
-function getSourceActor(sources, URL) {
- let item = sources.getItemForAttachment(a => a.source.url === URL);
- return item && item.value;
-}
-
-/**
- * Verify that clicking on a link from a popup notification message tries to
- * open the expected URL.
- */
-function simulateMessageLinkClick(element, expectedLink) {
- let deferred = defer();
-
- // Invoke the click event and check if a new tab would
- // open to the correct page.
- let oldOpenWebLinkIn = window.openWebLinkIn;
- let oldOpenTrustedLinkIn = window.openTrustedLinkIn;
- window.openTrustedLinkIn = window.openWebLinkIn = function (link) {
- if (link == expectedLink) {
- ok(true, "Clicking the message link opens the desired page");
- window.openWebLinkIn = oldOpenWebLinkIn;
- window.openTrustedLinkIn = oldOpenTrustedLinkIn;
- deferred.resolve();
- }
- };
-
- let event = new MouseEvent("click", {
- detail: 1,
- button: 0,
- bubbles: true,
- cancelable: true
- });
- element.dispatchEvent(event);
-
- return deferred.promise;
-}
-
-function getRenderedSource(root) {
- let location = root.querySelector(".message-location .frame-link");
- return location ? {
- url: location.getAttribute("data-url"),
- line: location.getAttribute("data-line"),
- column: location.getAttribute("data-column"),
- } : null;
-}
-
-function waitForBrowserConsole() {
- return new Promise(resolve => {
- Services.obs.addObserver(function observer(subject) {
- Services.obs.removeObserver(observer, "web-console-created");
- subject.QueryInterface(Ci.nsISupportsString);
-
- let hud = HUDService.getBrowserConsole();
- ok(hud, "browser console is open");
- is(subject.data, hud.hudId, "notification hudId is correct");
-
- executeSoon(() => resolve(hud));
- }, "web-console-created");
- });
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-autocomplete-in-stackframe.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en">
- <head>
- <meta charset="utf8">
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <title>Test for bug 842682 - use the debugger API for web console autocomplete</title>
- <script>
- var foo1 = "globalFoo";
-
- var foo1Obj = {
- prop1: "111",
- prop2: {
- prop21: "212121"
- }
- };
-
- function firstCall()
- {
- var foo2 = "fooFirstCall";
-
- var foo2Obj = {
- prop1: {
- prop11: "111111"
- }
- };
-
- secondCall();
- }
-
- function secondCall()
- {
- var foo3 = "fooSecondCall";
-
- var foo3Obj = {
- prop1: {
- prop11: "313131"
- }
- };
-
- debugger;
- }
- </script>
- </head>
- <body>
- <p>Hello world!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-585956-console-trace.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head><meta charset="utf-8">
- <title>Web Console test for bug 585956 - console.trace()</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<script type="application/javascript">
-window.foobar585956c = function(a) {
- console.trace();
- return a+"c";
-};
-
-function foobar585956b(a) {
- return foobar585956c(a+"b");
-}
-
-function foobar585956a(omg) {
- return foobar585956b(omg + "a");
-}
-
-foobar585956a("omg");
-</script>
- </head>
- <body>
- <p>Web Console test for bug 585956 - console.trace().</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-593003-iframe-wrong-hud-iframe.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>WebConsole test: iframe associated to the wrong HUD</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>WebConsole test: iframe associated to the wrong HUD.</p>
- <p>This is the iframe!</p>
- </body>
- </html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-593003-iframe-wrong-hud.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>WebConsole test: iframe associated to the wrong HUD</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>WebConsole test: iframe associated to the wrong HUD.</p>
- <iframe
- src="http://example.com/browser/devtools/client/webconsole/old/test/test-bug-593003-iframe-wrong-hud-iframe.html"></iframe>
- </body>
- </html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-canvas-css.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: CSS Parser (with
- Canvas)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript"
- src="test-bug-595934-canvas-css.js"></script>
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "CSS Parser" (with
- Canvas).</p>
- <p><canvas width="200" height="200">Canvas support is required!</canvas></p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-canvas-css.js
+++ /dev/null
@@ -1,10 +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/ */
-
-window.addEventListener("DOMContentLoaded", function () {
- var canvas = document.querySelector("canvas");
- var context = canvas.getContext("2d");
- context.strokeStyle = "foobarCanvasCssParser";
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-css-loader.css
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-body {
- color: #0f0;
- font-weight: bold;
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-css-loader.css^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: image/png
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-css-loader.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: CSS Loader</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <link rel="stylesheet" href="test-bug-595934-css-loader.css">
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "CSS Loader".</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-css-parser.css
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-p {
- color: #0f0;
- foobarCssParser: failure;
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-css-parser.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: CSS Parser</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <link rel="stylesheet" type="text/css"
- href="test-bug-595934-css-parser.css">
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "CSS Parser".</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-empty-getelementbyid.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: DOM.
- (empty getElementById())</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript"
- src="test-bug-595934-empty-getelementbyid.js"></script>
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "DOM"
- (empty getElementById()).</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-empty-getelementbyid.js
+++ /dev/null
@@ -1,8 +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/ */
-
-window.addEventListener("load", function () {
- document.getElementById("");
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-html.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: HTML</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "HTML".</p>
- <form action="?" enctype="multipart/form-data">
- <p><label>Input <input type="text" value="test value"></label></p>
- </form>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-image.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: Image</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - category Image.</p>
- <p><img src="test-bug-595934-image.jpg" alt="corrupted image"></p>
- </body>
-</html>
-
-
deleted file mode 100644
index 947e5f11ba13b7a1728ef64fbdedfa5ee25379cf..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-imagemap.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: ImageMap</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "ImageMap".</p>
- <p><img src="test-image.png" usemap="#testMap" alt="Test image"></p>
- <map name="testMap">
- <area shape="rect" coords="0,0,10,10,5" href="#" alt="Test area" />
- </map>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-malformedxml-external.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: malformed-xml.
- (external file)</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript"><!--
- var req = new XMLHttpRequest();
- req.open("GET", "test-bug-595934-malformedxml-external.xml", true);
- req.send(null);
- // --></script>
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "malformed-xml"
- (external file).</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-malformedxml-external.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "malformed-xml".</p>
- </body>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-malformedxml.xhtml
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Web Console test for bug 595934 - category: malformed-xml</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "malformed-xml".</p>
- </body>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-svg.xhtml
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Web Console test for bug 595934 - category: SVG</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - category "SVG".</p>
- <svg version="1.1" width="120" height="fooBarSVG"
- xmlns="http://www.w3.org/2000/svg">
- <ellipse fill="#0f0" stroke="#000" cx="50%"
- cy="50%" rx="50%" ry="50%" />
- </svg>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-workers.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 595934 - category: DOM Worker
- javascript</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p id="foobar">Web Console test for bug 595934 - category "DOM Worker
- javascript".</p>
- <script type="text/javascript">
- var myWorker = new Worker("test-bug-595934-workers.js");
- myWorker.postMessage("hello world");
- </script>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-595934-workers.js
+++ /dev/null
@@ -1,14 +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/ */
-
-/* global fooBarWorker*/
-/* eslint-disable no-unused-vars*/
-
-"use strict";
-
-var onmessage = function () {
- fooBarWorker();
-};
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-597136-external-script-errors.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta charset="utf-8">
-<!--
- ***** BEGIN LICENSE BLOCK *****
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- *
- * Contributor(s):
- * Patrick Walton <pcwalton@mozilla.com>
- *
- * ***** END LICENSE BLOCK *****
- -->
- <title>Test for bug 597136: external script errors</title>
- </head>
- <body>
- <h1>Test for bug 597136: external script errors</h1>
- <p><button onclick="f()">Click me</button</p>
-
- <script type="text/javascript"
- src="test-bug-597136-external-script-errors.js"></script>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-597136-external-script-errors.js
+++ /dev/null
@@ -1,9 +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/ */
-
-function f() {
- bogus.g();
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-597756-reopen-closed-tab.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Bug 597756: test error logging after tab close and reopen</title>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <h1>Bug 597756: test error logging after tab close and reopen.</h1>
-
- <script type="text/javascript"><!--
- fooBug597756_error.bar();
- // --></script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-599725-response-headers.sjs
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function handleRequest(request, response)
-{
- var Etag = '"4c881ab-b03-435f0a0f9ef00"';
- var IfNoneMatch = request.hasHeader("If-None-Match")
- ? request.getHeader("If-None-Match")
- : "";
-
- var page = "<!DOCTYPE html><html><body><p>hello world!</p></body></html>";
-
- response.setHeader("Etag", Etag, false);
-
- if (IfNoneMatch == Etag) {
- response.setStatusLine(request.httpVersion, "304", "Not Modified");
- }
- else {
- response.setHeader("Content-Type", "text/html", false);
- response.setHeader("Content-Length", page.length + "", false);
- response.write(page);
- }
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-600183-charset.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="gb2312">
- <title>Console HTTP test page (chinese)</title>
- </head>
- <body>
- <p>µÄÎʺò!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-600183-charset.html^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: text/html; charset=gb2312
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-601177-log-levels.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 601177: log levels</title>
- <script src="test-bug-601177-log-levels.js" type="text/javascript"></script>
- <script type="text/javascript"><!--
- window.undefinedPropertyBug601177;
- // --></script>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <h1>Web Console test for bug 601177: log levels</h1>
- <img src="test-image.png?bug601177">
- <img src="foobar-known-to-fail.png?bug601177">
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-601177-log-levels.js
+++ /dev/null
@@ -1,8 +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/ */
-
-foobarBug601177strictError = "strict error";
-
-window.foobarBug601177exception();
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-603750-websocket.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 603750 - Web Socket errors</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 595934 - Web Socket errors.</p>
- <iframe srcdoc="hello world!"></iframe>
- <script type="text/javascript" src="test-bug-603750-websocket.js"></script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-603750-websocket.js
+++ /dev/null
@@ -1,20 +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/ */
-
-"use strict";
-
-window.addEventListener("load", function () {
- let ws1 = new WebSocket("ws://0.0.0.0:81");
- ws1.onopen = function () {
- ws1.send("test 1");
- ws1.close();
- };
-
- let ws2 = new window.frames[0].WebSocket("ws://0.0.0.0:82");
- ws2.onopen = function () {
- ws2.send("test 2");
- ws2.close();
- };
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-609872-cd-iframe-child.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>test for bug 609872 - iframe child</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>test for bug 609872 - iframe child</p>
- <script>window.foobarBug609872 = 'child!';</script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-609872-cd-iframe-parent.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>test for bug 609872 - iframe parent</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>test for bug 609872 - iframe parent</p>
- <script>window.foobarBug609872 = 'parent!';</script>
- <iframe src="test-bug-609872-cd-iframe-child.html"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-613013-console-api-iframe.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>test for bug 613013</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>test for bug 613013</p>
- <script type="text/javascript"><!--
- (function () {
- var iframe = document.createElement('iframe');
- iframe.src = 'data:text/html;charset=utf-8,little iframe';
- document.body.appendChild(iframe);
-
- console.log("foobarBug613013");
- })();
- // --></script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-618078-network-exceptions.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 618078 - exception in async network request
- callback</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript">
- var req = new XMLHttpRequest();
- req.open('GET', 'http://example.com', true);
- req.onreadystatechange = function() {
- if (req.readyState == 4) {
- bug618078exception();
- }
- };
- req.send(null);
- </script>
- </head>
- <body>
- <p>Web Console test for bug 618078 - exception in async network request
- callback.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-621644-jsterm-dollar.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 621644</title>
- <script>
- function $(elem) {
- return elem.innerHTML;
- }
- function $$(doc) {
- return doc.title;
- }
- </script>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <h1>Web Console test for bug 621644</h1>
- <p>hello world!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-630733-response-redirect-headers.sjs
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function handleRequest(request, response)
-{
- var page = "<!DOCTYPE html><html><body><p>hello world! bug 630733</p></body></html>";
-
- response.setStatusLine(request.httpVersion, "301", "Moved Permanently");
- response.setHeader("Content-Type", "text/html", false);
- response.setHeader("Content-Length", page.length + "", false);
- response.setHeader("x-foobar-bug630733", "bazbaz", false);
- response.setHeader("Location", "/redirect-from-bug-630733", false);
- response.write(page);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-632275-getters.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 632275 - getters</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-
-<script type="application/javascript">
- document.foobar = {
- _val: 5,
- get val() { return ++this._val; }
- };
-</script>
-
- </head>
- <body>
- <p>Web Console test for bug 632275 - getters.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-632347-iterators-generators.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 632347 - generators</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<script type="application/javascript">
-(function(){
-function* genFunc() {
- var a = 5;
- while (a < 10) {
- yield a++;
- }
-}
-
-window._container = {};
-
-_container.gen1 = genFunc();
-_container.gen1.next();
-
-_container.gen2 = (function* () { for (let i = 3; i <= 15; ++i) yield i * 2; })();
-})();
-</script>
- </head>
- <body>
- <p>Web Console test for bug 632347 - generators.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-644419-log-limits.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <head>
- <meta charset="utf-8">
- <title>Test for bug 644419: console log limits</title>
- </head>
- <body>
- <h1>Test for bug 644419: Console should have user-settable log limits for
- each message category</h1>
-
- <script type="text/javascript">
- function foo() {
- bar.baz();
- }
- foo();
- </script>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-646025-console-file-location.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console file location test</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script src="test-file-location.js"></script>
- </head>
- <body>
- <h1>Web Console File Location Test Page</h1>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-658368-time-methods.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <head>
- <meta charset="utf-8">
- <title>Test for bug 658368: Expand console object with time and timeEnd
- methods</title>
- </head>
- <body>
- <h1>Test for bug 658368: Expand console object with time and timeEnd
- methods</h1>
-
- <script type="text/javascript">
- function foo() {
- console.timeEnd("aTimer");
- }
- console.time("aTimer");
- foo();
- console.time("bTimer");
- </script>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-737873-mixedcontent.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf8">
- <title>Mixed Content test - http on https</title>
- <script src="testscript.js"></script>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <iframe src = "http://example.com"></iframe>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-inner.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>I am sandboxed and want to escape.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-nested1.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe
-src="http://www.example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-inner.html"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-nested2.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe
-src="http://www.example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-inner.html" sandbox="allow-scripts allow-same-origin"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning0.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively (allow-scripts, allow-same-origin)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe src="test-bug-752559-ineffective-iframe-sandbox-warning-inner.html" sandbox="allow-scripts allow-same-origin"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning1.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively (allow-scripts, no allow-same-origin)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe src="test-bug-752559-ineffective-iframe-sandbox-warning-inner.html" sandbox="allow-scripts"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning2.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively (no allow-scripts, allow-same-origin)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe src="test-bug-752559-ineffective-iframe-sandbox-warning-inner.html" sandbox="allow-same-origin"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning3.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively (allow-scripts, allow-same-origin)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe
-src="http://www.example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-inner.html" sandbox="allow-scripts allow-same-origin"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning4.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively (allow-scripts, allow-same-origin, nested)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe
-src="http://www.example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-nested1.html" sandbox="allow-scripts allow-same-origin"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning5.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 752559 - print warning to error console when iframe sandbox
- is being used ineffectively (nested, allow-scripts, allow-same-origin)</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <iframe
-src="http://www.example.com/browser/devtools/client/webconsole/old/test/test-bug-752559-ineffective-iframe-sandbox-warning-nested2.html"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-762593-insecure-passwords-about-blank-web-console-warning.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 762593 - Add warning/error Message to Web Console when the
- page includes Insecure Password fields</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-
- <!-- This test tests the scenario where a javascript adds password fields to
- an about:blank iframe inside an insecure web page. It ensures that
- insecure password fields like those are detected and a warning is sent to
- the web console. -->
- </head>
- <body>
- <p>This insecure page is served with an about:blank iframe. A script then adds a
- password field to it.</p>
- <iframe id = "myiframe" width = "300" height="300" >
- </iframe>
- <script>
- var doc = window.document;
- var myIframe = doc.getElementById("myiframe");
- myIframe.contentDocument.open();
- myIframe.contentDocument.write("<form><input type = 'password' name='pwd' value='test'> </form>");
- myIframe.contentDocument.close();
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-762593-insecure-passwords-web-console-warning.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf8">
- <title>Bug 762593 - Add warning/error Message to Web Console when the
- page includes Insecure Password fields</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>This page is served with an iframe with insecure password field.</p>
- <iframe src
- ="http://example.com/browser/devtools/client/webconsole/old/test/test-iframe-762593-insecure-frame.html">
- </iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-766001-console-log.js
+++ /dev/null
@@ -1,10 +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/ */
-
-function onLoad123() {
- console.log("Blah Blah");
-}
-
-window.addEventListener("load", onLoad123);
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-766001-js-console-links.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 766001 : Open JS/Console call Links in Debugger</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript" src="test-bug-766001-js-errors.js"></script>
- <script type="text/javascript" src="test-bug-766001-console-log.js"></script>
- </head>
- <body>
- <p>Web Console test for bug 766001 : Open JS/Console call Links in Debugger.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-766001-js-errors.js
+++ /dev/null
@@ -1,8 +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/ */
-
-window.addEventListener("load", function () {
- document.bar();
-});
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-782653-css-errors-1.css
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-body {
- color: #0f0;
- font-weight: green;
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-782653-css-errors-2.css
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-body {
- color: #0fl;
- font-weight: bold;
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-782653-css-errors.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 782653 : Open CSS Links in Style Editor</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <link rel="stylesheet" href="test-bug-782653-css-errors-1.css">
- <link rel="stylesheet" href="test-bug-782653-css-errors-2.css">
- </head>
- <body>
- <p>Web Console test for bug 782653 : Open CSS Links in Style Editor.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-837351-security-errors.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf8">
- <title>Mixed Content test - http on https</title>
- <script src="testscript.js"></script>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <iframe src = "http://example.com"></iframe>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-859170-longstring-hang.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head><meta charset="utf-8">
- <title>Web Console test for bug 859170 - very long strings hang the browser</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<script type="application/javascript">
-(function() {
-var longString = "abbababazomglolztest";
-for (var i = 0; i < 10; i++) {
- longString += longString + longString;
-}
-
-longString = "foobar" + (new Array(9000)).join("a") + "foobaz" +
- longString + "boom!";
-console.log(longString);
-})();
-</script>
- </head>
- <body>
- <p>Web Console test for bug 859170 - very long strings hang the browser.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-869003-iframe.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 869003</title>
- <!-- Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript"><!--
- window.onload = function testConsoleLogging()
- {
- var o = { hello: "world!", bug: 869003 };
- var f = Object.assign(function func(arg){}, o);
- console.log("foobar", o, f);
- };
- // --></script>
- </head>
- <body>
- <p>Make sure users can inspect objects from cross-domain iframes.</p>
- <p>Iframe window.</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-869003-top-window.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 869003</title>
- <!-- Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Make sure users can inspect objects from cross-domain iframes.</p>
- <p>Top window.</p>
- <iframe src="http://example.org/browser/devtools/client/webconsole/old/test/test-bug-869003-iframe.html"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-952277-highlight-nodes-in-vview.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 952277 - Highlighting and selecting nodes from the variablesview</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Web Console test for bug 952277 - Highlighting and selecting nodes from the variablesview</p>
- <p>Web Console test for bug 952277 - Highlighting and selecting nodes from the variablesview</p>
- <p>Web Console test for bug 952277 - Highlighting and selecting nodes from the variablesview</p>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug-989025-iframe-parent.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>test for bug 989025 - iframe parent</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>test for bug 989025 - iframe parent</p>
- <iframe src="http://mochi.test:8888/browser/devtools/client/webconsole/old/test/test-bug-609872-cd-iframe-child.html"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug_1050691_click_function_to_source.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Click on function should point to source</title>
- <!-- Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript" src="test-bug_1050691_click_function_to_source.js"></script>
- </head>
- <body></body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug_1050691_click_function_to_source.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * this
- * is
- * a
- * function
- */
-function foo() {
- console.log(foo);
-}
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug_923281_console_log_filter.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Console test</title>
- <!-- Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript" src="test-bug_923281_test1.js"></script>
- <script type="text/javascript" src="test-bug_923281_test2.js"></script>
- </head>
- <body></body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug_923281_test1.js
+++ /dev/null
@@ -1,7 +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/ */
-
-console.log("Sample log.");
-console.log("This log should be filtered when filtered for test2.js.");
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug_923281_test2.js
+++ /dev/null
@@ -1,8 +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/ */
-
-"use strict";
-
-console.log("This is a random text.");
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-bug_939783_console_trace_duplicates.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test for bug 939783 - different console.trace() calls
- wrongly filtered as duplicates</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<script type="application/javascript">
-function foo1() {
- foo2();
-}
-
-function foo1b() {
- foo2();
-}
-
-function foo2() {
- foo3();
-}
-
-function foo3() {
- console.trace();
-}
-
-foo1(); foo1();
-foo1b();
-
-</script>
- </head>
- <body>
- <p>Web Console test for bug 939783 - different console.trace() calls
- wrongly filtered as duplicates</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-certificate-messages.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- Bug 1068949 - Log crypto warnings to the security pane in the webconsole
--->
-
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf8">
- <title>Security warning test - no violations</title>
- <!-- ensure no subresource errors so window re-use doesn't cause failures -->
- <link rel="icon" href="data:;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC">
- <script>
- console.log("If you haven't seen ssl warnings yet, you won't");
- </script>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-closure-optimized-out.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <meta charset='utf-8'/>
- <title>Debugger Test for Inspecting Optimized-Out Variables</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript">
- window.addEventListener("load", function () {
- function clickHandler(event) {
- button.removeEventListener("click", clickHandler);
- function outer(arg) {
- var upvar = arg * 2;
- // The inner lambda only aliases arg, so the frontend alias analysis decides
- // that upvar is not aliased and is not in the CallObject.
- return function () {
- arg += 2;
- };
- }
-
- var f = outer(42);
- f();
- }
- var button = document.querySelector("button");
- button.addEventListener("click", clickHandler);
- }, {once: true});
- </script>
-
- </head>
- <body>
- <button>Click me!</button>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-closures.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <meta charset='utf-8'/>
- <title>Console Test for Closure Inspection</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript">
- function injectPerson() {
- var PersonFactory = function _pfactory(name) {
- var foo = 10;
- return {
- getName: function() { return name; },
- getFoo: function() { foo = Date.now(); return foo; }
- };
- };
- window.george = new PersonFactory("George");
- debugger;
- }
- </script>
-
- </head>
- <body>
- <button onclick="injectPerson()">Test</button>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-api-stackframe.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en">
- <head>
- <meta charset="utf8">
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <title>Test for bug 920116 - stacktraces for console API messages</title>
- <script>
- function firstCall() {
- secondCall();
- }
-
- function secondCall() {
- thirdCall();
- }
-
- function thirdCall() {
- console.log("foo-log");
- console.error("foo-error");
- console.exception("foo-exception");
- console.assert("red" == "blue", "foo-assert");
- }
-
- window.onload = firstCall;
- </script>
- </head>
- <body>
- <p>Hello world!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-assert.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <meta charset="utf-8">
- <title>console.assert() test</title>
- <script type="text/javascript">
- function test() {
- console.log("start");
- console.assert(false, "false assert");
- console.assert(0, "falsy assert");
- console.assert(true, "true assert");
- console.log("end");
- }
- </script>
- </head>
- <body>
- <p>test console.assert()</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-clear.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console.clear() tests</title>
- <script type="text/javascript">
- console.log("log1");
- console.log("log2");
- console.clear();
-
- window.objFromPage = { a: 1 };
- </script>
- </head>
- <body>
- <h1 id="header">Clear Demo</h1>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-column.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <meta charset="utf-8">
- <title>Console test</title>
-
- <script type="text/javascript">
- /* eslint-disable */
- console.info("INLINE SCRIPT:"); console.log('Further');
- console.warn("I'm warning you, he will eat up all yr bacon.");
- console.error("Error Message");
- console.log('Rainbooooww');
- console.log('NYAN CATZ');
- </script>
- </head>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-count-external-file.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/* eslint-disable no-unused-vars */
-
-"use strict";
-
-function counterExternalFile() {
- console.count("console.count() testcounter");
-}
-function externalCountersWithoutLabel() {
- console.count();
- console.count();
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-count.html
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <meta charset="utf-8">
- <title>console.count() test</title>
- <script src="test-console-count-external-file.js"></script>
- <script tyoe="text/javascript">
- function counterSeperateScriptTag() {
- console.count("console.count() testcounter");
- }
- </script>
- <script type="text/javascript">
- function counterNoLabel() {
- console.count();
- }
- function counterWithLabel() {
- console.count("console.count() testcounter");
- }
- function testLocal() {
- console.log("start");
- counterNoLabel();
- counterNoLabel();
- counterWithLabel();
- counterWithLabel();
- counterSeperateScriptTag();
- counterSeperateScriptTag();
- console.log("end");
- }
- function testExternal() {
- console.log("start");
- counterExternalFile();
- counterExternalFile();
- externalCountersWithoutLabel();
- console.log("end");
- }
- </script>
- </head>
- <body>
- <p>test console.count()</p>
- <button id="local" onclick="testLocal();">
- test local console.count() calls
- </button>
- <button id="external" onclick="testExternal();">
- test external console.count() calls
- </button>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-extras.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console extended API test</title>
- <script type="text/javascript">
- function test() {
- console.log("start");
- console.clear();
- console.log("end");
- }
- </script>
- </head>
- <body>
- <h1 id="header">Heads Up Display Demo</h1>
- <button onclick="test();">Test Extended API</button>
- <div id="myDiv"></div>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-output-02.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en-US">
-<head>
- <meta charset="utf-8">
- <title>Test the web console output - 02</title>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
-</head>
-<body>
- <p>hello world!</p>
- <script type="text/javascript">
-function testfn1() { return 42; }
-
-var testobj1 = {
- testfn2: function() { return 42; },
-};
-
-function testfn3() { return 42; }
-testfn3.displayName = "testfn3DisplayName";
-
-var array1 = [1, 2, 3, "a", "b", "c", "4", "5"];
-
-var array2 = ["a", document, document.body, document.body.dataset,
- document.body.classList];
-
-var array3 = [1, window, null, "a", "b", undefined, false, "", -Infinity, testfn3, testobj1, "foo", "bar"];
-
-var array4 = new Array(5);
-array4.push("test");
-array4.push(array4);
-
-var typedarray1 = new Int32Array([1, 287, 8651, 40983, 8754]);
-
-var set1 = new Set([1, 2, null, array3, "a", "b", undefined, document.head]);
-set1.add(set1);
-
-var bunnies = new String("bunnies")
-var weakset = new WeakSet([bunnies, document.head]);
-
-var testobj2 = {a: "b", c: "d", e: 1, f: "2"};
-testobj2.foo = testobj1;
-testobj2.bar = testobj2;
-Object.defineProperty(testobj2, "getterTest", {
- enumerable: true,
- get: function() {
- return 42;
- },
-});
-
-var testobj3 = {a: "b", c: "d", e: 1, f: "2", g: true, h: null, i: undefined,
- j: "", k: document.styleSheets, l: document.body.childNodes,
- o: new Array(125), m: document.head};
-
-var testobj4 = {a: "b", c: "d"};
-Object.defineProperty(testobj4, "nonEnumerable", { value: "hello world" });
-
-var map1 = new Map([["a", "b"], [document.body.children, testobj2]]);
-map1.set(map1, set1);
-
-var weakmap = new WeakMap([[bunnies, 23], [document.body.children, testobj2]]);
-
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-output-03.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en-US">
-<head>
- <meta charset="utf-8">
- <title>Test the web console output - 03</title>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
-</head>
-<body>
- <p>hello world!</p>
- <script type="text/javascript">
-function testBodyClassName() {
- document.body.className = "test1 tezt2";
- return document.body;
-}
-
-function testBodyID() {
- document.body.id = 'foobarid';
- return document.body;
-}
-
-function testBodyDataset() {
- document.body.dataset.preview = 'zuzu"<a>foo';
- return document.body;
-}
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-output-04.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en-US">
-<head>
- <meta charset="utf-8">
- <title>Test the web console output - 04</title>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
-</head>
-<body>
- <p>hello world!</p>
- <script type="text/javascript">
-function testTextNode() {
- return document.querySelector("p").childNodes[0];
-}
-
-function testCommentNode() {
- return document.head.childNodes[5];
-}
-
-function testDocumentFragment() {
- var frag = document.createDocumentFragment();
-
- var div = document.createElement("div");
- div.id = "foo1";
- div.className = "bar";
- frag.appendChild(div);
-
- var span = document.createElement("span");
- span.id = "foo2";
- span.textContent = "hello world";
- div.appendChild(span);
-
- var div2 = document.createElement("div");
- div2.id = "foo3";
- frag.appendChild(div2);
-
- return frag;
-}
-
-function testError() {
- try {
- window.foobar("a");
- } catch (ex) {
- return ex;
- }
- return null;
-}
-
-function testDOMException() {
- try {
- var foo = document.querySelector("foo;()bar!");
- } catch (ex) {
- return ex;
- }
- return null;
-}
-
-function testCSSStyleDeclaration() {
- document.body.style = 'color: green; font-size: 2em';
- return document.body.style;
-}
-
-function testStyleSheetList() {
- var style = document.querySelector("style");
- if (!style) {
- style = document.createElement("style");
- style.textContent = "p, div { color: blue; font-weight: bold }\n" +
- "@media print { p { background-color: yellow } }";
- document.head.appendChild(style);
- }
- return document.styleSheets;
-}
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-output-dom-elements.html
+++ /dev/null
@@ -1,91 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en-US">
-<head>
- <meta charset="utf-8">
- <title>Test the web console output - dom elements</title>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
-</head>
-<body class="body-class" id="body-id">
- <p some-attribute="some-value">hello world!</p>
- <p id="lots-of-attributes" a b c d e f g h i j k l m n></p>
- <!--
- Be sure we have a charset in our iframe's data URI, otherwise we get the following extra
- console output message:
- "The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it."
- This wouldn't be a big deal, but when we look for a "<p>" in our `waitForMessage` helper,
- this extra encoding warning line contains the data URI source, returning a message
- that was unexpected
- -->
- <iframe srcdoc="<p>hello from iframe</p>"></iframe>
- <div class="some classname here with more classnames here"></div>
- <svg>
- <clipPath>
- <rect x="0" y="0" width="10" height="5"></rect>
- </clipPath>
- </svg>
- <script type="text/javascript">
-function testBodyNode() {
- return document.body;
-}
-
-function testDocumentElement() {
- return document.documentElement;
-}
-
-function testLotsOfAttributes() {
- return document.querySelector("#lots-of-attributes");
-}
-
-function testDocument() {
- return document;
-}
-
-function testNode() {
- return document.querySelector("p");
-}
-
-function testSvgNode() {
- return document.querySelector("clipPath");
-}
-
-function testNodeList() {
- return document.querySelectorAll("body *");
-}
-
-function testNodeInIframe() {
- return document.querySelector("iframe").contentWindow.document.querySelector("p");
-}
-
-function testDocumentFragment() {
- var frag = document.createDocumentFragment();
-
- var span = document.createElement("span");
- span.className = 'foo';
- span.dataset.lolz = 'hehe';
-
- var div = document.createElement('div')
- div.id = 'fragdiv';
-
- frag.appendChild(span);
- frag.appendChild(div);
-
- return frag;
-}
-
-function testNodeInDocumentFragment() {
- var frag = testDocumentFragment();
- return frag.firstChild;
-}
-
-function testUnattachedNode() {
- var p = document.createElement("p");
- p.className = "such-class";
- p.dataset.data = "such-data";
- return p;
-}
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-output-events.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en-US">
-<head>
- <meta charset="utf-8">
- <title>Test the web console output for DOM events</title>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
-</head>
-<body>
- <p>hello world!</p>
-
- <script type="text/javascript">
-function testDOMEvents() {
- function eventLogger(ev) {
- console.log("eventLogger", ev);
- }
- document.addEventListener("mousemove", eventLogger);
- document.addEventListener("keypress", eventLogger);
-
- synthesizeMouseMove();
- synthesizeKeyPress("a", {shiftKey: true});
-}
-
-function synthesizeMouseMove(element) {
- var mouseEvent = document.createEvent("MouseEvent");
- mouseEvent.initMouseEvent("mousemove", true, true, window, 0, 0, 0, 0, 0,
- false, false, false, false, 0, null);
-
- document.dispatchEvent(mouseEvent);
-}
-
-function synthesizeKeyPress(key, options) {
- var keyboardEvent = document.createEvent("KeyboardEvent");
- keyboardEvent.initKeyEvent("keypress", true, true, window, false, false,
- options.shiftKey, false, key.charCodeAt(0), 0);
- document.dispatchEvent(keyboardEvent);
-}
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-replaced-api.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console test replaced API</title>
- </head>
- <body>
- <h1 id="header">Web Console Replace API Test</h1>
- <script type="text/javascript">
- window.console = {log: function (msg){}, info: function (msg){}, warn: function (msg){}, error: function (msg){}};
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-server-logging-array.sjs
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function handleRequest(request, response)
-{
- var page = "<!DOCTYPE html><html>" +
- "<head><meta charset='utf-8'></head>" +
- "<body><p>hello world!</p></body>" +
- "</html>";
-
- var data = {
- "version": "4.1.0",
- "columns": ["log", "backtrace", "type"],
- "rows":[[
- [{ "best": "Firefox", "reckless": "Chrome", "new_ie": "Safari", "new_new_ie": "Edge"}],
- "C:\\src\\www\\serverlogging\\test7.php:4:1",
- ""
- ]],
- };
-
- // Put log into headers.
- var value = b64EncodeUnicode(JSON.stringify(data));
- response.setHeader("X-ChromeLogger-Data", value, false);
-
- response.write(page);
-}
-
-function b64EncodeUnicode(str) {
- return btoa(unescape(encodeURIComponent(str)));
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-server-logging-backtrace.sjs
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function handleRequest(request, response)
-{
- var page = "<!DOCTYPE html><html>" +
- "<head><meta charset='utf-8'></head>" +
- "<body><p>hello world!</p></body>" +
- "</html>";
-
- var data = {
- "version": "4.1.0",
- "columns": ["log", "backtrace", "type"],
- "rows":[[
- ["correct 1"],
- "/some/path/to/file.py : 33",
- "error"
- ], [
- ["correct 2"],
- "/some/path/to/file.py:33",
- "error"
- ], [
- ["wrong 1"],
- "/some/path/to/file.py:33wrong",
- "error"
- ], [
- ["wrong 2"],
- "/some/path/to/file.py",
- "error"
- ]],
- };
-
- // Put log into headers.
- var value = b64EncodeUnicode(JSON.stringify(data));
- response.setHeader("X-ChromeLogger-Data", value, false);
-
- response.write(page);
-}
-
-function b64EncodeUnicode(str) {
- return btoa(unescape(encodeURIComponent(str)));
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-server-logging.sjs
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function handleRequest(request, response)
-{
- var page = "<!DOCTYPE html><html>" +
- "<head><meta charset='utf-8'></head>" +
- "<body><p>hello world!</p></body>" +
- "</html>";
-
- var data = {
- "version": "4.1.0",
- "columns": ["log", "backtrace", "type"],
- "rows": [[
- ["values: %s %o %i %f %s","string",{"a":10,"___class_name":"Object"},123,1.12, "\u2713"],
- "C:\\src\\www\\serverlogging\\test7.php:4:1",
- ""
- ]]
- };
-
- // Put log into headers.
- var value = b64EncodeUnicode(JSON.stringify(data));
- response.setHeader("X-ChromeLogger-Data", value, false);
-
- response.write(page);
-}
-
-function b64EncodeUnicode(str) {
- return btoa(unescape(encodeURIComponent(str)));
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-table.html
+++ /dev/null
@@ -1,63 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en">
- <head>
- <meta charset="utf8">
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <title>Test for Bug 899753 - console.table support</title>
- <script>
- var languages1 = [
- { name: "JavaScript", fileExtension: [".js"] },
- { name: { a: "TypeScript" }, fileExtension: ".ts" },
- { name: "CoffeeScript", fileExtension: ".coffee" }
- ];
-
- var languages2 = {
- csharp: { name: "C#", paradigm: "object-oriented" },
- fsharp: { name: "F#", paradigm: "functional" }
- };
-
- function Person(firstName, lastName, age)
- {
- this.firstName = firstName;
- this.lastName = lastName;
- this.age = age;
- }
-
- var family = {};
- family.mother = new Person("Susan", "Doyle", 32);
- family.father = new Person("John", "Doyle", 33);
- family.daughter = new Person("Lily", "Doyle", 5);
- family.son = new Person("Mike", "Doyle", 8);
-
- var myMap = new Map();
-
- myMap.set("a string", "value associated with 'a string'");
- myMap.set(5, "value associated with 5");
-
- var mySet = new Set();
-
- mySet.add(1);
- mySet.add(5);
- mySet.add("some text");
- mySet.add(null);
- mySet.add(undefined);
-
- // These are globals and so won't be reclaimed by the GC.
- var bunnies = new String("bunnies");
- var lizards = new String("lizards");
-
- var weakmap = new WeakMap();
- weakmap.set(bunnies, 23);
- weakmap.set(lizards, "oh no");
-
- var weakset = new WeakSet([bunnies, lizards]);
-
- </script>
- </head>
- <body>
- <p>Hello world!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-trace-async.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head><meta charset="utf-8">
- <title>Web Console test for bug 1200832 - console.trace() async stacks</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<script type="application/javascript">
-function inner() {
- console.trace();
-}
-
-function time1() {
- new Promise(function(resolve, reject) {
- setTimeout(resolve, 10);
- }).then(inner);
-}
-
-setTimeout(time1, 10);
-</script>
- </head>
- <body>
- <p>Web Console test for bug 1200832 - console.trace() async stacks</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console-workers.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console test</title>
- </head>
- <body>
- <script type="text/javascript">
-var sw = new SharedWorker('data:application/javascript,console.log("foo-bar-shared-worker");');
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-console.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console test</title>
- <script type="text/javascript">
- var fooObj = {
- testProp: "testValue"
- };
-
- function test() {
- var str = "Dolske Digs Bacon, Now and Forevermore."
- for (var i=0; i < 5; i++) {
- console.log(str);
- }
- }
-
- function testTrace() {
- console.log("bug 1100562");
- console.trace();
- }
-
- console.info("INLINE SCRIPT:");
- test();
- console.warn("I'm warning you, he will eat up all yr bacon.");
- console.error("Error Message");
- </script>
- </head>
- <body>
- <h1 id="header">Heads Up Display Demo</h1>
- <button onclick="test();">Log stuff about Dolske</button>
- <button id="testTrace" onclick="testTrace();">Log stuff with stacktrace</button>
- <div id="myDiv"></div>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-consoleiframes.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
-<head>
- <script>
- console.log("main file");
- </script>
-</head>
-<body>
-<h1>iframe console test</h1>
-<iframe src="test-iframe1.html"></iframe>
-<iframe src="test-iframe2.html"></iframe>
-<iframe src="test-iframe3.html"></iframe>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-cu-reporterror.js
+++ /dev/null
@@ -1,4 +0,0 @@
-function a() {
- Cu.reportError("bug1141222");
-}
-a();
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-data.json
+++ /dev/null
@@ -1,1 +0,0 @@
-{ id: "test JSON data", myArray: [ "foo", "bar", "baz", "biff" ] }
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-data.json^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: application/json
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-duplicate-error.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Console duplicate error test</title>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
-
- See https://bugzilla.mozilla.org/show_bug.cgi?id=582201
- -->
- </head>
- <body>
- <h1>Heads Up Display - duplicate error test</h1>
-
- <script type="text/javascript"><!--
- fooDuplicateError1.bar();
- // --></script>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-encoding-ISO-8859-1.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="ISO-8859-1">
-</head>
-<body>üöä</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-error.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Console error test</title>
- </head>
- <body>
- <h1>Heads Up Display - error test</h1>
- <p><button>generate error</button></p>
-
- <script type="text/javascript"><!--
- var button = document.getElementsByTagName("button")[0];
-
- button.addEventListener("click", function () {
- fooBazBaz.bar();
- }, {once: true});
- // --></script>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-eval-in-stackframe.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en">
- <head>
- <meta charset="utf8">
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <title>Test for bug 783499 - use the debugger API in the web console</title>
- <script>
- var foo = "globalFooBug783499";
- var fooObj = {
- testProp: "testValue",
- };
-
- function firstCall()
- {
- var foo = "fooFirstCall";
- var foo3 = "foo3FirstCall";
- secondCall();
- }
-
- function secondCall()
- {
- var foo2 = "foo2SecondCall";
- var fooObj = {
- testProp2: "testValue2",
- };
- var fooObj2 = {
- testProp22: "testValue22",
- };
- debugger;
- }
- </script>
- </head>
- <body>
- <p>Hello world!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-exception-stackframe.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" lang="en">
- <head>
- <meta charset="utf8">
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- <title>Test for bug 1184172 - stacktraces for exceptions</title>
- <script>
- function firstCall() {
- secondCall();
- }
-
- // Check anonymous functions
- var secondCall = function () {
- thirdCall();
- }
-
- function thirdCall() {
- nonExistingMethodCall();
- }
-
- function domAPI() {
- document.querySelector("buggy;selector");
- }
-
- function domException() {
- throw new DOMException("DOMException");
- }
- window.addEventListener("load", firstCall);
- window.addEventListener("load", function onLoadDomAPI() {
- domAPI();
- });
- window.addEventListener("load", function onLoadDomException() {
- domException();
- });
- </script>
- </head>
- <body>
- <p>Hello world!</p>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-file-location.js
+++ /dev/null
@@ -1,12 +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/ */
-
-"use strict";
-
-console.log("message for level log");
-console.info("message for level info");
-console.warn("message for level warn");
-console.error("message for level error");
-console.debug("message for level debug");
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-filter.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console test</title>
- <script type="text/javascript">
- </script>
- </head>
- <body>
- <h1>Heads Up Display Filter Test Page</h1>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-for-of.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<meta charset="utf-8">
-<body>
-<h1>a</h1>
-<div><p>b</p></div>
-<h2>c</h2>
-<p>d</p>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-iframe-762593-insecure-form-action.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <h1>iframe 2</h1>
- <p>This frame contains a password field inside a form with insecure action.</p>
- <form action="http://test">
- <input type="password" name="pwd">
- </form>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-iframe-762593-insecure-frame.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <h1>iframe 1</h1>
- <p>This frame is served with an insecure password field.</p>
- <iframe src=
- "http://example.com/browser/devtools/client/webconsole/old/test/test-iframe-762593-insecure-form-action.html">
- </iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-iframe1.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-<head>
- <script>
- console.log("iframe 1");
- </script>
-</head>
-<body>
-<h1>iframe 1</h1>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-iframe2.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<html>
-<head>
- <script>
- console.log("iframe 2");
- blah;
- </script>
-</head>
-<body>
-<h1>iframe 2</h1>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-iframe3.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<html>
-<head>
- <script>
- console.log("iframe 3");
- </script>
-</head>
-<body>
-<h1>iframe 3</h1>
-<iframe src="test-iframe1.html"></iframe>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
index 769c636340e11f9d2a0b7eb6a84d574dd9563f0c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-mixedcontent-securityerrors.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
- Bug 875456 - Log mixed content messages from the Mixed Content Blocker to the
- Security Pane in the Web Console
--->
-
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf8">
- <title>Mixed Content test - http on https</title>
- <script src="testscript.js"></script>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <iframe src="http://example.com"></iframe>
- <img src="http://example.com/tests/image/test/mochitest/blue.png"></img>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-mutation.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Console mutation test</title>
- <script>
- window.onload = function (){
- var node = document.createElement("div");
- document.body.appendChild(node);
- };
- </script>
- </head>
- <body>
- <h1>Heads Up Display DOM Mutation Test Page</h1>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-network-request.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>Console HTTP test page</title>
- <script type="text/javascript"><!--
- function makeXhr(aMethod, aUrl, aRequestBody, aCallback) {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.open(aMethod, aUrl, true);
- xmlhttp.onreadystatechange = function() {
- if (aCallback && xmlhttp.readyState == 4) {
- aCallback();
- }
- };
- xmlhttp.send(aRequestBody);
- }
-
- function testXhrGet(aCallback) {
- makeXhr('get', 'test-data.json', null, aCallback);
- }
-
- function testXhrWarn(aCallback) {
- makeXhr('get', 'http://example.com/browser/devtools/client/netmonitor/test/sjs_cors-test-server.sjs', null, aCallback);
- }
-
- function testXhrPost(aCallback) {
- makeXhr('post', 'test-data.json', "Hello world!", aCallback);
- }
- // --></script>
- </head>
- <body>
- <h1>Heads Up Display HTTP Logging Testpage</h1>
- <h2>This page is used to test the HTTP logging.</h2>
-
- <form action="https://example.com/browser/devtools/client/old/est/test-network-request.html" method="post">
- <input name="name" type="text" value="foo bar"><br>
- <input name="age" type="text" value="144"><br>
- </form>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-network.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console network test</title>
- <script src="testscript.js?foo"></script>
- </head>
- <body>
- <h1>Heads Up Display Network Test Page</h1>
- <img src="test-image.png"></img>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-observe-http-ajax.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Console HTTP test page</title>
- <script type="text/javascript">
- function test() {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.open('get', 'test-data.json', false);
- xmlhttp.send(null);
- }
- </script>
- </head>
- <body onload="test();">
- <h1>Heads Up Display HTTP & AJAX Test Page</h1>
- <h2>This page fires an ajax request so we can see the http logging of the console</h2>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-own-console.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
-<head>
-<meta charset="utf-8">
-<script>
- var _console = {
- foo: "bar"
- }
-
- window.console = _console;
-
- function loadIFrame() {
- var iframe = document.body.querySelector("iframe");
- iframe.addEventListener("load", function() {
- iframe.removeEventListener("load", arguments.callee, true);
- }, true);
-
- iframe.setAttribute("src", "test-console.html");
- }
-</script>
-</head>
-<body>
- <iframe></iframe>
-</body>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-property-provider.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
- <meta charset="utf-8">
- <title>Property provider test</title>
- <script>
- var testObj = {
- testProp: 'testValue'
- };
- </script>
- </head>
- <body>
- <h1>Heads Up Property Provider Test Page</h1>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-repeated-messages.html
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf8">
- <title>Test for bugs 720180, 800510, 865288 and 1218089</title>
- <script>
- function testConsole() {
- // same line and column number
- for(var i = 0; i < 2; i++) {
- console.log("foo repeat");
- }
- console.log("foo repeat");
- console.error("foo repeat");
- }
- function testConsoleObjects() {
- for (var i = 0; i < 3; i++) {
- var o = { id: "abba" + i };
- console.log("abba", o);
- }
- }
- function testConsoleFalsyValues(){
- [NaN, undefined, null].forEach(function(item, index){
- console.log(item);
- });
- [NaN, NaN].forEach(function(item, index){
- console.log(item);
- });
- [undefined, undefined].forEach(function(item, index){
- console.log(item);
- });
- [null, null].forEach(function(item, index){
- console.log(item);
- });
- }
- </script>
- <style>
- body {
- background-image: foobarz;
- }
- p {
- background-image: foobarz;
- }
- </style>
- <!--
- - Any copyright is dedicated to the Public Domain.
- - http://creativecommons.org/publicdomain/zero/1.0/
- -->
- </head>
- <body>
- <p>Hello world!</p>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-result-format-as-string.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Web Console test: jsterm eval format as a string</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- </head>
- <body>
- <p>Make sure js eval results are formatted as strings.</p>
- <script>
- document.querySelector("p").toSource = function() {
- var element = document.createElement("div");
- element.id = "foobar";
- element.textContent = "bug772506_content";
- element.setAttribute("onmousemove",
- "(function () {" +
- " gBrowser._bug772506 = 'foobar';" +
- "})();"
- );
- return element;
- };
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-trackingprotection-securityerrors.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this
- - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf8">
- </head>
- <body>
- <iframe src="http://tracking.example.com/"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test-webconsole-error-observer.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE HTML>
-<html dir="ltr" xml:lang="en-US" lang="en-US">
- <head>
- <meta charset="utf-8">
- <title>WebConsoleErrorObserver test - bug 611032</title>
- <!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript">
- console.log("log Bazzle");
- console.info("info Bazzle");
- console.warn("warn Bazzle");
- console.error("error Bazzle");
-
- var foo = {};
- foo.bazBug611032();
- </script>
- <style type="text/css">
- .foo { color: cssColorBug611032; }
- </style>
- </head>
- <body>
- <h1>WebConsoleErrorObserver test</h1>
- </body>
-</html>
-
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug1045902_console_csp_ignore_reflected_xss_message.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>Bug 1045902 - CSP: Log console message for ‘reflected-xss’</title>
-</head>
-<body>
-Bug 1045902 - CSP: Log console message for ‘reflected-xss’
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug1045902_console_csp_ignore_reflected_xss_message.html^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Security-Policy: reflected-xss filter;
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug1092055_shouldwarn.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>Bug 1092055 - Log console messages for non-top-level security errors</title>
- <script src="test_bug1092055_shouldwarn.js"></script>
- <!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- -->
-</head>
-<body>
-Bug 1092055 - Log console messages for non-top-level security errors
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug1092055_shouldwarn.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// It doesn't matter what this script does, but the broken HSTS header sent
-// with it should result in warnings in the webconsole
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug1092055_shouldwarn.js^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Strict-Transport-Security: some complete nonsense
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug_1010953_cspro.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>Test for Bug 1010953 - Verify that CSP and CSPRO log different console
-messages.</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1010953">Mozilla Bug 1010953</a>
-
-
-<!-- this script file allowed by the CSP header (but not by the report-only header) -->
-<script src="http://some.example.com/test_bug_1010953_cspro.js"></script>
-
-<!-- this image allowed only be the CSP report-only header. -->
-<img src="http://some.example.com/test.png">
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug_1010953_cspro.html^headers^
+++ /dev/null
@@ -1,2 +0,0 @@
-Content-Security-Policy: default-src 'self'; img-src 'self'; script-src some.example.com;
-Content-Security-Policy-Report-Only: default-src 'self'; img-src some.example.com; script-src 'self'; report-uri https://example.com/ignored/;
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug_1247459_violation.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta http-equiv="Content-Security-Policy" content="img-src https://example.com"></meta>
- <meta http-equiv="Content-Security-Policy" content="img-src https://example.com"></meta>
- <meta charset="UTF-8">
- <title>Test for Bug 1247459 - policy violations for header and META are displayed separately</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1247459">Mozilla Bug 1247459</a>
-<img src="http://some.example.com/test.png">
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug_770099_violation.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>Test for Bug 770099 - policy violation</title>
-<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=770099">Mozilla Bug 770099</a>
-<img src="http://some.example.com/test.png">
-</body>
-</html>
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_bug_770099_violation.html^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Security-Policy: default-src 'self'
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_hpkp-invalid-headers.sjs
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function handleRequest(request, response)
-{
- response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
-
- let issue;
- switch (request.queryString) {
- case "badSyntax":
- response.setHeader("Public-Key-Pins", "\"");
- issue = "is not syntactically correct.";
- break;
- case "noMaxAge":
- response.setHeader("Public-Key-Pins", "max-age444");
- issue = "does not include a max-age directive.";
- break;
- case "invalidIncludeSubDomains":
- response.setHeader("Public-Key-Pins", "includeSubDomains=abc");
- issue = "includes an invalid includeSubDomains directive.";
- break;
- case "invalidMaxAge":
- response.setHeader("Public-Key-Pins", "max-age=abc");
- issue = "includes an invalid max-age directive.";
- break;
- case "multipleIncludeSubDomains":
- response.setHeader("Public-Key-Pins",
- "includeSubDomains; includeSubDomains");
- issue = "includes multiple includeSubDomains directives.";
- break;
- case "multipleMaxAge":
- response.setHeader("Public-Key-Pins",
- "max-age=444; max-age=999");
- issue = "includes multiple max-age directives.";
- break;
- case "multipleReportURIs":
- response.setHeader("Public-Key-Pins",
- 'report-uri="http://example.com"; ' +
- 'report-uri="http://example.com"');
- issue = "includes multiple report-uri directives.";
- break;
- case "pinsetDoesNotMatch":
- response.setHeader(
- "Public-Key-Pins",
- 'max-age=999; ' +
- 'pin-sha256="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; ' +
- 'pin-sha256="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB="');
- issue = "does not include a matching pin.";
- break;
- }
-
- response.write("This page is served with a PKP header that " + issue);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/test_hsts-invalid-headers.sjs
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function handleRequest(request, response)
-{
- response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
-
- let issue;
- switch (request.queryString) {
- case "badSyntax":
- response.setHeader("Strict-Transport-Security", "\"");
- issue = "is not syntactically correct.";
- break;
- case "noMaxAge":
- response.setHeader("Strict-Transport-Security", "max-age444");
- issue = "does not include a max-age directive.";
- break;
- case "invalidIncludeSubDomains":
- response.setHeader("Strict-Transport-Security", "includeSubDomains=abc");
- issue = "includes an invalid includeSubDomains directive.";
- break;
- case "invalidMaxAge":
- response.setHeader("Strict-Transport-Security", "max-age=abc");
- issue = "includes an invalid max-age directive.";
- break;
- case "multipleIncludeSubDomains":
- response.setHeader("Strict-Transport-Security",
- "includeSubDomains; includeSubDomains");
- issue = "includes multiple includeSubDomains directives.";
- break;
- case "multipleMaxAge":
- response.setHeader("Strict-Transport-Security",
- "max-age=444; max-age=999");
- issue = "includes multiple max-age directives.";
- break;
- }
-
- response.write("This page is served with a STS header that " + issue);
-}
deleted file mode 100644
--- a/devtools/client/webconsole/old/test/testscript.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-console.log("running network console logging tests");
deleted file mode 100644
--- a/devtools/client/webconsole/old/webconsole.js
+++ /dev/null
@@ -1,3073 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const {Cc, Ci, Cu} = require("chrome");
-
-const {Utils: WebConsoleUtils, CONSOLE_WORKER_IDS} =
- require("devtools/client/webconsole/utils");
-const { getSourceNames } = require("devtools/client/shared/source-utils");
-const ChromeUtils = require("ChromeUtils");
-// browser-loader.js is a JSM without .jsm file extension, so it has to be loaded
-// via ChromeUtils.import and not require() which would consider it as a CommonJS module
-const { BrowserLoader } = ChromeUtils.import("resource://devtools/client/shared/browser-loader.js", {});
-
-const promise = require("promise");
-const defer = require("devtools/shared/defer");
-const Services = require("Services");
-const Telemetry = require("devtools/client/shared/telemetry");
-const {PrefObserver} = require("devtools/client/shared/prefs");
-
-loader.lazyServiceGetter(this, "clipboardHelper",
- "@mozilla.org/widget/clipboardhelper;1",
- "nsIClipboardHelper");
-loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
-loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
-loader.lazyRequireGetter(this, "ConsoleOutput", "devtools/client/webconsole/old/console-output", true);
-loader.lazyRequireGetter(this, "Messages", "devtools/client/webconsole/old/console-output", true);
-loader.lazyRequireGetter(this, "EnvironmentClient", "devtools/shared/client/environment-client");
-loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/object-client");
-loader.lazyRequireGetter(this, "JSTerm", "devtools/client/webconsole/old/jsterm", true);
-loader.lazyRequireGetter(this, "gSequenceId", "devtools/client/webconsole/old/jsterm", true);
-loader.lazyImporter(this, "VariablesView", "resource://devtools/client/shared/widgets/VariablesView.jsm");
-loader.lazyImporter(this, "VariablesViewController", "resource://devtools/client/shared/widgets/VariablesViewController.jsm");
-loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
-loader.lazyRequireGetter(this, "KeyShortcuts", "devtools/client/shared/key-shortcuts");
-loader.lazyRequireGetter(this, "ZoomKeys", "devtools/client/shared/zoom-keys");
-loader.lazyRequireGetter(this, "WebConsoleConnectionProxy", "devtools/client/webconsole/webconsole-connection-proxy", true);
-
-const {PluralForm} = require("devtools/shared/plural-form");
-const l10n = require("devtools/client/webconsole/webconsole-l10n");
-
-const XHTML_NS = "http://www.w3.org/1999/xhtml";
-
-const MIXED_CONTENT_LEARN_MORE = "https://developer.mozilla.org/docs/Web/Security/Mixed_content";
-
-const IGNORED_SOURCE_URLS = ["debugger eval code"];
-
-// The amount of time in milliseconds that we wait before performing a live
-// search.
-const SEARCH_DELAY = 200;
-
-// The number of lines that are displayed in the console output by default, for
-// each category. The user can change this number by adjusting the hidden
-// "devtools.hud.loglimit.{network,cssparser,exception,console}" preferences.
-const DEFAULT_LOG_LIMIT = 1000;
-
-// The various categories of messages. We start numbering at zero so we can
-// use these as indexes into the MESSAGE_PREFERENCE_KEYS matrix below.
-const CATEGORY_NETWORK = 0;
-const CATEGORY_CSS = 1;
-const CATEGORY_JS = 2;
-const CATEGORY_WEBDEV = 3;
-// always on
-const CATEGORY_INPUT = 4;
-// always on
-const CATEGORY_OUTPUT = 5;
-const CATEGORY_SECURITY = 6;
-const CATEGORY_SERVER = 7;
-
-// The possible message severities. As before, we start at zero so we can use
-// these as indexes into MESSAGE_PREFERENCE_KEYS.
-const SEVERITY_ERROR = 0;
-const SEVERITY_WARNING = 1;
-const SEVERITY_INFO = 2;
-const SEVERITY_LOG = 3;
-
-// The fragment of a CSS class name that identifies each category.
-const CATEGORY_CLASS_FRAGMENTS = [
- "network",
- "cssparser",
- "exception",
- "console",
- "input",
- "output",
- "security",
- "server",
-];
-
-// The fragment of a CSS class name that identifies each severity.
-const SEVERITY_CLASS_FRAGMENTS = [
- "error",
- "warn",
- "info",
- "log",
-];
-
-// The preference keys to use for each category/severity combination, indexed
-// first by category (rows) and then by severity (columns) in the following
-// order:
-//
-// [ Error, Warning, Info, Log ]
-//
-// Most of these rather idiosyncratic names are historical and predate the
-// division of message type into "category" and "severity".
-const MESSAGE_PREFERENCE_KEYS = [
- // Network
- [ "network", "netwarn", "netxhr", "networkinfo", ],
- // CSS
- [ "csserror", "cssparser", null, "csslog", ],
- // JS
- [ "exception", "jswarn", null, "jslog", ],
- // Web Developer
- [ "error", "warn", "info", "log", ],
- // Input
- [ null, null, null, null, ],
- // Output
- [ null, null, null, null, ],
- // Security
- [ "secerror", "secwarn", null, null, ],
- // Server Logging
- [ "servererror", "serverwarn", "serverinfo", "serverlog", ],
-];
-
-// A mapping from the console API log event levels to the Web Console
-// severities.
-const LEVELS = {
- error: SEVERITY_ERROR,
- exception: SEVERITY_ERROR,
- assert: SEVERITY_ERROR,
- warn: SEVERITY_WARNING,
- info: SEVERITY_INFO,
- log: SEVERITY_LOG,
- clear: SEVERITY_LOG,
- trace: SEVERITY_LOG,
- table: SEVERITY_LOG,
- debug: SEVERITY_LOG,
- dir: SEVERITY_LOG,
- dirxml: SEVERITY_LOG,
- group: SEVERITY_LOG,
- groupCollapsed: SEVERITY_LOG,
- groupEnd: SEVERITY_LOG,
- time: SEVERITY_LOG,
- timeEnd: SEVERITY_LOG,
- count: SEVERITY_LOG
-};
-
-// This array contains the prefKey for the workers and it must keep them in the
-// same order as CONSOLE_WORKER_IDS
-const WORKERTYPES_PREFKEYS =
- [ "sharedworkers", "serviceworkers", "windowlessworkers" ];
-
-// The lowest HTTP response code (inclusive) that is considered an error.
-const MIN_HTTP_ERROR_CODE = 400;
-// The highest HTTP response code (inclusive) that is considered an error.
-const MAX_HTTP_ERROR_CODE = 599;
-
-// The indent of a console group in pixels.
-const GROUP_INDENT = 12;
-
-// The number of messages to display in a single display update. If we display
-// too many messages at once we slow down the Firefox UI too much.
-const MESSAGES_IN_INTERVAL = DEFAULT_LOG_LIMIT;
-
-// The delay (in milliseconds) between display updates - tells how often we
-// should *try* to push new messages to screen. This value is optimistic,
-// updates won't always happen. Keep this low so the Web Console output feels
-// live.
-const OUTPUT_INTERVAL = 20;
-
-// The maximum amount of time (in milliseconds) that can be spent doing cleanup
-// inside of the flush output callback. If things don't get cleaned up in this
-// time, then it will start again the next time it is called.
-const MAX_CLEANUP_TIME = 10;
-
-// When the output queue has more than MESSAGES_IN_INTERVAL items we throttle
-// output updates to this number of milliseconds. So during a lot of output we
-// update every N milliseconds given here.
-const THROTTLE_UPDATES = 1000;
-
-// The preference prefix for all of the Web Console filters.
-const FILTER_PREFS_PREFIX = "devtools.webconsole.filter.";
-
-const PREF_PERSISTLOG = "devtools.webconsole.persistlog";
-const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
-const PREF_NEW_FRONTEND_ENABLED = "devtools.webconsole.new-frontend-enabled";
-
-/**
- * A WebConsoleFrame instance is an interactive console initialized *per target*
- * that displays console log data as well as provides an interactive terminal to
- * manipulate the target's document content.
- *
- * The WebConsoleFrame is responsible for the actual Web Console UI
- * implementation.
- *
- * @constructor
- * @param object webConsoleOwner
- * The WebConsole owner object.
- */
-function WebConsoleFrame(webConsoleOwner) {
- this.owner = webConsoleOwner;
- this.hudId = this.owner.hudId;
- this.isBrowserConsole = this.owner._browserConsole;
-
- this.window = this.owner.iframeWindow;
-
- this._repeatNodes = {};
- this._outputQueue = [];
- this._itemDestroyQueue = [];
- this._pruneCategoriesQueue = {};
- this.filterPrefs = {};
-
- this.output = new ConsoleOutput(this);
-
- this.unmountMessage = this.unmountMessage.bind(this);
- this._toggleFilter = this._toggleFilter.bind(this);
- this.resize = this.resize.bind(this);
- this._onPanelSelected = this._onPanelSelected.bind(this);
- this._flushMessageQueue = this._flushMessageQueue.bind(this);
- this._onToolboxPrefChanged = this._onToolboxPrefChanged.bind(this);
- this._onUpdateListeners = this._onUpdateListeners.bind(this);
-
- this._outputTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- this._outputTimerInitialized = false;
-
- let toolbox = gDevTools.getToolbox(this.owner.target);
- let {require} = BrowserLoader({
- window: this.window,
- useOnlyShared: true,
- // The toolbox isn't available for the browser console.
- commonLibRequire: toolbox ? toolbox.browserRequire : null,
- });
-
- this.React = require("devtools/client/shared/vendor/react");
- this.ReactDOM = require("devtools/client/shared/vendor/react-dom");
- this.FrameView = this.React.createFactory(require("devtools/client/shared/components/Frame"));
- this.StackTraceView = this.React.createFactory(require("devtools/client/shared/components/StackTrace"));
-
- this._telemetry = new Telemetry();
-
- EventEmitter.decorate(this);
-}
-exports.WebConsoleFrame = WebConsoleFrame;
-
-WebConsoleFrame.prototype = {
- /**
- * The WebConsole instance that owns this frame.
- * @see hudservice.js::WebConsole
- * @type object
- */
- owner: null,
-
- /**
- * Proxy between the Web Console and the remote Web Console instance. This
- * object holds methods used for connecting, listening and disconnecting from
- * the remote server, using the remote debugging protocol.
- *
- * @see WebConsoleConnectionProxy
- * @type object
- */
- proxy: null,
-
- /**
- * Getter for the xul:popupset that holds any popups we open.
- * @type nsIDOMElement
- */
- get popupset() {
- return this.owner.mainPopupSet;
- },
-
- /**
- * Holds the initialization promise object.
- * @private
- * @type object
- */
- _initDefer: null,
-
- /**
- * Last time when we displayed any message in the output.
- *
- * @private
- * @type number
- * Timestamp in milliseconds since the Unix epoch.
- */
- _lastOutputFlush: 0,
-
- /**
- * Message nodes are stored here in a queue for later display.
- *
- * @private
- * @type array
- */
- _outputQueue: null,
-
- /**
- * Keep track of the categories we need to prune from time to time.
- *
- * @private
- * @type array
- */
- _pruneCategoriesQueue: null,
-
- /**
- * Function invoked whenever the output queue is emptied. This is used by some
- * tests.
- *
- * @private
- * @type function
- */
- _flushCallback: null,
-
- /**
- * Timer used for flushing the messages output queue.
- *
- * @private
- * @type nsITimer
- */
- _outputTimer: null,
- _outputTimerInitialized: null,
-
- /**
- * Store for tracking repeated nodes.
- * @private
- * @type object
- */
- _repeatNodes: null,
-
- /**
- * Preferences for filtering messages by type.
- * @see this._initDefaultFilterPrefs()
- * @type object
- */
- filterPrefs: null,
-
- /**
- * Prefix used for filter preferences.
- * @private
- * @type string
- */
- _filterPrefsPrefix: FILTER_PREFS_PREFIX,
-
- /**
- * The nesting depth of the currently active console group.
- */
- groupDepth: 0,
-
- /**
- * The current target location.
- * @type string
- */
- contentLocation: "",
-
- /**
- * The JSTerm object that manage the console's input.
- * @see JSTerm
- * @type object
- */
- jsterm: null,
-
- /**
- * The element that holds all of the messages we display.
- * @type nsIDOMElement
- */
- outputNode: null,
-
- /**
- * The ConsoleOutput instance that manages all output.
- * @type object
- */
- output: null,
-
- /**
- * The input element that allows the user to filter messages by string.
- * @type nsIDOMElement
- */
- filterBox: null,
-
- /**
- * Getter for the debugger WebConsoleClient.
- * @type object
- */
- get webConsoleClient() {
- return this.proxy ? this.proxy.webConsoleClient : null;
- },
-
- _destroyer: null,
-
- _saveRequestAndResponseBodies: true,
- _throttleData: null,
-
- // Chevron width at the starting of Web Console's input box.
- _chevronWidth: 0,
- // Width of the monospace characters in Web Console's input box.
- _inputCharWidth: 0,
-
- /**
- * Setter for saving of network request and response bodies.
- *
- * @param boolean value
- * The new value you want to set.
- */
- setSaveRequestAndResponseBodies: function (value) {
- if (!this.webConsoleClient) {
- // Don't continue if the webconsole disconnected.
- return promise.resolve(null);
- }
-
- let deferred = defer();
- let newValue = !!value;
- let toSet = {
- "NetworkMonitor.saveRequestAndResponseBodies": newValue,
- };
-
- // Make sure the web console client connection is established first.
- this.webConsoleClient.setPreferences(toSet, response => {
- if (!response.error) {
- this._saveRequestAndResponseBodies = newValue;
- deferred.resolve(response);
- } else {
- deferred.reject(response.error);
- }
- });
-
- return deferred.promise;
- },
-
- /**
- * Setter for throttling data.
- *
- * @param boolean value
- * The new value you want to set; @see NetworkThrottleManager.
- */
- setThrottleData: function(value) {
- if (!this.webConsoleClient) {
- // Don't continue if the webconsole disconnected.
- return promise.resolve(null);
- }
-
- let deferred = defer();
- let toSet = {
- "NetworkMonitor.throttleData": value,
- };
-
- // Make sure the web console client connection is established first.
- this.webConsoleClient.setPreferences(toSet, response => {
- if (!response.error) {
- this._throttleData = value;
- deferred.resolve(response);
- } else {
- deferred.reject(response.error);
- }
- });
-
- return deferred.promise;
- },
-
- /**
- * Getter for the persistent logging preference.
- * @type boolean
- */
- get persistLog() {
- // For the browser console, we receive tab navigation
- // when the original top level window we attached to is closed,
- // but we don't want to reset console history and just switch to
- // the next available window.
- return this.isBrowserConsole ||
- Services.prefs.getBoolPref(PREF_PERSISTLOG);
- },
-
- /**
- * Initialize the WebConsoleFrame instance.
- * @return object
- * A promise object that resolves once the frame is ready to use.
- */
- init: function () {
- this._initUI();
- let connectionInited = this._initConnection();
-
- // Don't reject if the history fails to load for some reason.
- // This would be fine, the panel will just start with empty history.
- let allReady = this.jsterm.historyLoaded.catch(() => {}).then(() => {
- return connectionInited;
- });
-
- // This notification is only used in tests. Don't chain it onto
- // the returned promise because the console panel needs to be attached
- // to the toolbox before the web-console-created event is receieved.
- let notifyObservers = () => {
- let id = WebConsoleUtils.supportsString(this.hudId);
- Services.obs.notifyObservers(id, "web-console-created");
- };
- allReady.then(notifyObservers, notifyObservers);
- return allReady;
- },
- /**
- * Connect to the server using the remote debugging protocol.
- *
- * @private
- * @return object
- * A promise object that is resolved/reject based on the connection
- * result.
- */
- _initConnection: function () {
- if (this._initDefer) {
- return this._initDefer.promise;
- }
-
- this._initDefer = defer();
- this.proxy = new WebConsoleConnectionProxy(this, this.owner.target);
-
- this.proxy.connect().then(() => {
- // on success
- this._initDefer.resolve(this);
- }, (reason) => {
- // on failure
- let node = this.createMessageNode(CATEGORY_JS, SEVERITY_ERROR,
- reason.error + ": " + reason.message);
- this.outputMessage(CATEGORY_JS, node, [reason]);
- this._initDefer.reject(reason);
- });
-
- return this._initDefer.promise;
- },
- /**
- * Find the Web Console UI elements and setup event listeners as needed.
- * @private
- */
- _initUI: function () {
- this.document = this.window.document;
- this.rootElement = this.document.documentElement;
- this.outputNode = this.document.getElementById("output-container");
- this.outputWrapper = this.document.getElementById("output-wrapper");
- this.completeNode = this.document.querySelector(".jsterm-complete-node");
- this.inputNode = this.document.querySelector(".jsterm-input-node");
- // In the old frontend, the area that scrolls is outputWrapper, but in the new
- // frontend this will be reassigned.
- this.outputScroller = this.outputWrapper;
- this.jsterm = new JSTerm(this);
- this.jsterm.init();
- let toolbox = gDevTools.getToolbox(this.owner.target);
- // Register the controller to handle "select all" properly.
- this._commandController = new CommandController(this);
- this.window.controllers.insertControllerAt(0, this._commandController);
-
- this._contextMenuHandler = new ConsoleContextMenu(this);
-
- this._initDefaultFilterPrefs();
- this.filterBox = this.document.querySelector(".hud-filter-box");
- this._setFilterTextBoxEvents();
- this._initFilterButtons();
-
- let clearButton =
- this.document.getElementsByClassName("webconsole-clear-console-button")[0];
- clearButton.addEventListener("command", () => {
- this.owner._onClearButton();
- this.jsterm.clearOutput(true);
- });
- this.resize();
- this.window.addEventListener("resize", this.resize, true);
- this.jsterm.on("sidebar-opened", this.resize);
- this.jsterm.on("sidebar-closed", this.resize);
- if (toolbox) {
- toolbox.on("webconsole-selected", this._onPanelSelected);
- }
-
- /*
- * Focus the input line whenever the output area is clicked.
- */
- this.outputWrapper.addEventListener("click", (event) => {
- // Do not focus on middle/right-click or 2+ clicks.
- if (event.detail !== 1 || event.button !== 0) {
- return;
- }
-
- // Do not focus if something is selected
- let selection = this.window.getSelection();
- if (selection && !selection.isCollapsed) {
- return;
- }
- // Do not focus if a link was clicked
- if (event.target.nodeName.toLowerCase() === "a" ||
- event.target.parentNode.nodeName.toLowerCase() === "a") {
- return;
- }
- this.jsterm.focus();
- });
- // Toggle the timestamp on preference change
- this._prefObserver = new PrefObserver("");
- this._prefObserver.on(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged);
- this._onToolboxPrefChanged();
- this._initShortcuts();
-
- // focus input node
- this.jsterm.focus();
- },
- /**
- * Resizes the output node to fit the output wrapped.
- * We need this because it makes the layout a lot faster than
- * using -moz-box-flex and 100% width. See Bug 1237368.
- */
- resize: function () {
- this.outputNode.style.width = this.outputWrapper.clientWidth + "px";
- },
- /**
- * Sets the focus to JavaScript input field when the web console tab is
- * selected or when there is a split console present.
- * @private
- */
- _onPanelSelected: function () {
- this.jsterm.focus();
- },
-
- /**
- * Initialize the default filter preferences.
- * @private
- */
- _initDefaultFilterPrefs: function () {
- let prefs = ["network", "networkinfo", "csserror", "cssparser", "csslog",
- "exception", "jswarn", "jslog", "error", "info", "warn", "log",
- "secerror", "secwarn", "netwarn", "netxhr", "sharedworkers",
- "serviceworkers", "windowlessworkers", "servererror",
- "serverwarn", "serverinfo", "serverlog"];
-
- for (let pref of prefs) {
- this.filterPrefs[pref] = Services.prefs.getBoolPref(
- this._filterPrefsPrefix + pref);
- }
- },
-
- _initShortcuts: function() {
- var shortcuts = new KeyShortcuts({
- window: this.window
- });
-
- shortcuts.on(l10n.getStr("webconsole.find.key"),
- event => {
- this.filterBox.focus();
- event.preventDefault();
- });
-
- let clearShortcut;
- if (AppConstants.platform === "macosx") {
- clearShortcut = l10n.getStr("webconsole.clear.keyOSX");
- } else {
- clearShortcut = l10n.getStr("webconsole.clear.key");
- }
- shortcuts.on(clearShortcut,
- () => this.jsterm.clearOutput(true));
-
- if (this.isBrowserConsole) {
- shortcuts.on(l10n.getStr("webconsole.close.key"),
- this.window.close.bind(this.window));
-
- ZoomKeys.register(this.window);
- }
- },
-
- /**
- * Attach / detach reflow listeners depending on the checked status
- * of the `CSS > Log` menuitem.
- *
- * @param function [callback=null]
- * Optional function to invoke when the listener has been
- * added/removed.
- */
- _updateReflowActivityListener: function (callback) {
- if (this.webConsoleClient) {
- let pref = this._filterPrefsPrefix + "csslog";
- if (Services.prefs.getBoolPref(pref)) {
- this.webConsoleClient.startListeners(["ReflowActivity"], callback);
- } else {
- this.webConsoleClient.stopListeners(["ReflowActivity"], callback);
- }
- }
- },
-
- /**
- * Attach / detach server logging listener depending on the filter
- * preferences. If the user isn't interested in the server logs at
- * all the listener is not registered.
- *
- * @param function [callback=null]
- * Optional function to invoke when the listener has been
- * added/removed.
- */
- _updateServerLoggingListener: function (callback) {
- if (!this.webConsoleClient) {
- return null;
- }
-
- let startListener = false;
- let prefs = ["servererror", "serverwarn", "serverinfo", "serverlog"];
- for (let i = 0; i < prefs.length; i++) {
- if (this.filterPrefs[prefs[i]]) {
- startListener = true;
- break;
- }
- }
-
- if (startListener) {
- this.webConsoleClient.startListeners(["ServerLogging"], callback);
- } else {
- this.webConsoleClient.stopListeners(["ServerLogging"], callback);
- }
- },
-
- /**
- * Sets the events for the filter input field.
- * @private
- */
- _setFilterTextBoxEvents: function () {
- let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- let timerEvent = this.adjustVisibilityOnSearchStringChange.bind(this);
-
- let onChange = function _onChange() {
- // To improve responsiveness, we let the user finish typing before we
- // perform the search.
- timer.cancel();
- timer.initWithCallback(timerEvent, SEARCH_DELAY,
- Ci.nsITimer.TYPE_ONE_SHOT);
- };
-
- this.filterBox.addEventListener("command", onChange);
- this.filterBox.addEventListener("input", onChange);
- },
-
- /**
- * Creates one of the filter buttons on the toolbar.
- *
- * @private
- * @param nsIDOMNode aParent
- * The node to which the filter button should be appended.
- * @param object aDescriptor
- * A descriptor that contains info about the button. Contains "name",
- * "category", and "prefKey" properties, and optionally a "severities"
- * property.
- */
- _initFilterButtons: function () {
- let categories = this.document
- .querySelectorAll(".webconsole-filter-button[category]");
- Array.forEach(categories, function (button) {
- button.addEventListener("contextmenu", () => {
- button.open = true;
- });
- button.addEventListener("click", this._toggleFilter);
-
- let someChecked = false;
- let severities = button.querySelectorAll("menuitem[prefKey]");
- Array.forEach(severities, function (menuItem) {
- menuItem.addEventListener("command", this._toggleFilter);
-
- let prefKey = menuItem.getAttribute("prefKey");
- let checked = this.filterPrefs[prefKey];
- menuItem.setAttribute("checked", checked);
- someChecked = someChecked || checked;
- }, this);
-
- button.setAttribute("checked", someChecked);
- button.setAttribute("aria-pressed", someChecked);
- }, this);
-
- if (!this.isBrowserConsole) {
- // The Browser Console displays nsIConsoleMessages which are messages that
- // end up in the JS category, but they are not errors or warnings, they
- // are just log messages. The Web Console does not show such messages.
- let jslog = this.document.querySelector("menuitem[prefKey=jslog]");
- jslog.hidden = true;
- }
-
- if (Services.appinfo.OS == "Darwin") {
- let net = this.document.querySelector("toolbarbutton[category=net]");
- let accesskey = net.getAttribute("accesskeyMacOSX");
- net.setAttribute("accesskey", accesskey);
-
- let logging =
- this.document.querySelector("toolbarbutton[category=logging]");
- logging.removeAttribute("accesskey");
- let serverLogging =
- this.document.querySelector("toolbarbutton[category=server]");
- serverLogging.removeAttribute("accesskey");
- }
- },
- /**
- * The event handler that is called whenever a user switches a filter on or
- * off.
- *
- * @private
- * @param nsIDOMEvent event
- * The event that triggered the filter change.
- */
- _toggleFilter: function (event) {
- let target = event.target;
- let tagName = target.tagName;
- // Prevent toggle if generated from a contextmenu event (right click)
- let isRightClick = (event.button === 2);
- if (tagName != event.currentTarget.tagName || isRightClick) {
- return;
- }
-
- switch (tagName) {
- case "toolbarbutton": {
- let originalTarget = event.originalTarget;
- let classes = originalTarget.classList;
-
- if (originalTarget.localName !== "toolbarbutton") {
- // Oddly enough, the click event is sent to the menu button when
- // selecting a menu item with the mouse. Detect this case and bail
- // out.
- break;
- }
-
- if (!event.getModifierState("Alt") &&
- !event.getModifierState("Shift")) {
- // Do nothing unless the click is modified. (The menu will
- // automatically appear without our intervention.)
- break;
- }
-
- // Toggle on the targeted filter button, and if the user alt clicked,
- // toggle off all other filter buttons and their associated filters.
- let state = target.getAttribute("checked") !== "true";
- if (event.getModifierState("Alt")) {
- let buttons = this.document
- .querySelectorAll(".webconsole-filter-button");
- Array.forEach(buttons, (button) => {
- if (button !== target) {
- button.setAttribute("checked", false);
- button.setAttribute("aria-pressed", false);
- this._setMenuState(button, false);
- }
- });
- state = true;
- }
- target.setAttribute("checked", state);
- target.setAttribute("aria-pressed", state);
-
- // This is a filter button with a drop-down, and the user clicked the
- // main part of the button. Go through all the severities and toggle
- // their associated filters.
- this._setMenuState(target, state);
-
- // CSS reflow logging can decrease web page performance.
- // Make sure the option is always unchecked when the CSS filter button
- // is selected. See bug 971798.
- if (target.getAttribute("category") == "css" && state) {
- let csslogMenuItem = target.querySelector("menuitem[prefKey=csslog]");
- csslogMenuItem.setAttribute("checked", false);
- this.setFilterState("csslog", false);
- }
-
- break;
- }
-
- case "menuitem": {
- let state = target.getAttribute("checked") !== "true";
- target.setAttribute("checked", state);
-
- let prefKey = target.getAttribute("prefKey");
- this.setFilterState(prefKey, state);
-
- // Adjust the state of the button appropriately.
- let menuPopup = target.parentNode;
-
- let someChecked = false;
- let menuItem = menuPopup.firstChild;
- while (menuItem) {
- if (menuItem.hasAttribute("prefKey") &&
- menuItem.getAttribute("checked") === "true") {
- someChecked = true;
- break;
- }
- menuItem = menuItem.nextSibling;
- }
- let toolbarButton = menuPopup.parentNode;
- toolbarButton.setAttribute("checked", someChecked);
- toolbarButton.setAttribute("aria-pressed", someChecked);
- break;
- }
- }
- },
-
- /**
- * Set the menu attributes for a specific toggle button.
- *
- * @private
- * @param XULElement target
- * Button with drop down items to be toggled.
- * @param boolean state
- * True if the menu item is being toggled on, and false otherwise.
- */
- _setMenuState: function (target, state) {
- let menuItems = target.querySelectorAll("menuitem");
- Array.forEach(menuItems, (item) => {
- item.setAttribute("checked", state);
- let prefKey = item.getAttribute("prefKey");
- this.setFilterState(prefKey, state);
- });
- },
-
- /**
- * Set the filter state for a specific toggle button.
- *
- * @param string toggleType
- * @param boolean state
- * @returns void
- */
- setFilterState: function (toggleType, state) {
- this.filterPrefs[toggleType] = state;
- this.adjustVisibilityForMessageType(toggleType, state);
-
- Services.prefs.setBoolPref(this._filterPrefsPrefix + toggleType, state);
-
- if (this._updateListenersTimeout) {
- clearTimeout(this._updateListenersTimeout);
- }
-
- this._updateListenersTimeout = setTimeout(
- this._onUpdateListeners, 200);
- },
-
- /**
- * Get the filter state for a specific toggle button.
- *
- * @param string toggleType
- * @returns boolean
- */
- getFilterState: function (toggleType) {
- return this.filterPrefs[toggleType];
- },
-
- /**
- * Called when a logging filter changes. Allows to stop/start
- * listeners according to the current filter state.
- */
- _onUpdateListeners: function () {
- this._updateReflowActivityListener();
- this._updateServerLoggingListener();
- },
-
- /**
- * Check that the passed string matches the filter arguments.
- *
- * @param String str
- * to search for filter words in.
- * @param String filter
- * is a string containing all of the words to filter on.
- * @returns boolean
- */
- stringMatchesFilters: function (str, filter) {
- if (!filter || !str) {
- return true;
- }
-
- let searchStr = str.toLowerCase();
- let filterStrings = filter.toLowerCase().split(/\s+/);
- return !filterStrings.some(function (f) {
- return !searchStr.includes(f);
- });
- },
-
- /**
- * Turns the display of log nodes on and off appropriately to reflect the
- * adjustment of the message type filter named by @prefKey.
- *
- * @param string prefKey
- * The preference key for the message type being filtered: one of the
- * values in the MESSAGE_PREFERENCE_KEYS table.
- * @param boolean state
- * True if the filter named by @messageType is being turned on; false
- * otherwise.
- * @returns void
- */
- adjustVisibilityForMessageType: function (prefKey, state) {
- let outputNode = this.outputNode;
- let doc = this.document;
-
- // Look for message nodes (".message") with the given preference key
- // (filter="error", filter="cssparser", etc.) and add or remove the
- // "filtered-by-type" class, which turns on or off the display.
-
- let attribute = !WORKERTYPES_PREFKEYS.includes(prefKey)
- ? "filter" : "workerType";
-
- let selector = "[" + attribute + "='" + prefKey + "'].message";
- let result = outputNode.querySelectorAll(selector);
- for (let node of result) {
- if (state) {
- node.classList.remove("filtered-by-type");
- } else {
- node.classList.add("filtered-by-type");
- }
- }
- },
-
- /**
- * Turns the display of log nodes on and off appropriately to reflect the
- * adjustment of the search string.
- */
- adjustVisibilityOnSearchStringChange: function () {
- let nodes = this.outputNode.getElementsByClassName("message");
- let searchString = this.filterBox.value;
-
- for (let i = 0, n = nodes.length; i < n; ++i) {
- let node = nodes[i];
-
- // hide nodes that match the strings
- let text = node.textContent;
-
- // if the text matches the words in aSearchString...
- if (this.stringMatchesFilters(text, searchString)) {
- node.classList.remove("filtered-by-string");
- } else {
- node.classList.add("filtered-by-string");
- }
- }
-
- this.resize();
- },
-
- /**
- * Applies the user's filters to a newly-created message node via CSS
- * classes.
- *
- * @param nsIDOMNode node
- * The newly-created message node.
- * @return boolean
- * True if the message was filtered or false otherwise.
- */
- filterMessageNode: function (node) {
- let isFiltered = false;
-
- // Filter by the message type.
- let prefKey = MESSAGE_PREFERENCE_KEYS[node.category][node.severity];
- if (prefKey && !this.getFilterState(prefKey)) {
- // The node is filtered by type.
- node.classList.add("filtered-by-type");
- isFiltered = true;
- }
-
- // Filter by worker type
- if ("workerType" in node && !this.getFilterState(node.workerType)) {
- node.classList.add("filtered-by-type");
- isFiltered = true;
- }
-
- // Filter on the search string.
- let search = this.filterBox.value;
- let text = node.clipboardText;
-
- // if string matches the filter text
- if (!this.stringMatchesFilters(text, search)) {
- node.classList.add("filtered-by-string");
- isFiltered = true;
- }
-
- if (isFiltered && node.classList.contains("inlined-variables-view")) {
- node.classList.add("hidden-message");
- }
-
- return isFiltered;
- },
-
- /**
- * Merge the attributes of repeated nodes.
- *
- * @param nsIDOMNode original
- * The Original Node. The one being merged into.
- */
- mergeFilteredMessageNode: function (original) {
- let repeatNode = original.getElementsByClassName("message-repeats")[0];
- if (!repeatNode) {
- // no repeat node, return early.
- return;
- }
-
- let occurrences = parseInt(repeatNode.getAttribute("value"), 10) + 1;
- repeatNode.setAttribute("value", occurrences);
- repeatNode.textContent = occurrences;
- let str = l10n.getStr("messageRepeats.tooltip2");
- repeatNode.title = PluralForm.get(occurrences, str)
- .replace("#1", occurrences);
- },
-
- /**
- * Filter the message node from the output if it is a repeat.
- *
- * @private
- * @param nsIDOMNode node
- * The message node to be filtered or not.
- * @returns nsIDOMNode|null
- * Returns the duplicate node if the message was filtered, null
- * otherwise.
- */
- _filterRepeatedMessage: function (node) {
- let repeatNode = node.getElementsByClassName("message-repeats")[0];
- if (!repeatNode) {
- return null;
- }
-
- let uid = repeatNode._uid;
- let dupeNode = null;
-
- if (node.category == CATEGORY_CSS ||
- node.category == CATEGORY_SECURITY) {
- dupeNode = this._repeatNodes[uid];
- if (!dupeNode) {
- this._repeatNodes[uid] = node;
- }
- } else if ((node.category == CATEGORY_WEBDEV ||
- node.category == CATEGORY_JS) &&
- node.category != CATEGORY_NETWORK &&
- !node.classList.contains("inlined-variables-view")) {
- let lastMessage = this.outputNode.lastChild;
- if (!lastMessage) {
- return null;
- }
-
- let lastRepeatNode =
- lastMessage.getElementsByClassName("message-repeats")[0];
- if (lastRepeatNode && lastRepeatNode._uid == uid) {
- dupeNode = lastMessage;
- }
- }
-
- if (dupeNode) {
- this.mergeFilteredMessageNode(dupeNode);
- // Even though this node was never rendered, we create the location
- // nodes before rendering, so we still have to clean up any
- // React components
- this.unmountMessage(node);
- return dupeNode;
- }
-
- return null;
- },
-
- /**
- * Display cached messages that may have been collected before the UI is
- * displayed.
- *
- * @param array remoteMessages
- * Array of cached messages coming from the remote Web Console
- * content instance.
- */
- displayCachedMessages: function (remoteMessages) {
- if (!remoteMessages.length) {
- return;
- }
-
- remoteMessages.forEach(function (message) {
- switch (message._type) {
- case "PageError": {
- let category = Utils.categoryForScriptError(message);
- this.outputMessage(category, this.reportPageError,
- [category, message]);
- break;
- }
- case "LogMessage":
- this.handleLogMessage(message);
- break;
- case "ConsoleAPI":
- this.outputMessage(CATEGORY_WEBDEV, this.logConsoleAPIMessage,
- [message]);
- break;
- case "NetworkEvent":
- this.outputMessage(CATEGORY_NETWORK, this.logNetEvent, [message]);
- break;
- }
- }, this);
- },
-
- /**
- * Logs a message to the Web Console that originates from the Web Console
- * server.
- *
- * @param object message
- * The message received from the server.
- * @return nsIDOMElement|null
- * The message element to display in the Web Console output.
- */
- logConsoleAPIMessage: function (message) {
- let body = null;
- let clipboardText = null;
- let sourceURL = message.filename;
- let sourceLine = message.lineNumber;
- let level = message.level;
- let args = message.arguments;
- let objectActors = new Set();
- let node = null;
-
- // Gather the actor IDs.
- args.forEach((value) => {
- if (WebConsoleUtils.isActorGrip(value)) {
- objectActors.add(value.actor);
- }
- });
-
- switch (level) {
- case "log":
- case "info":
- case "warn":
- case "error":
- case "exception":
- case "assert":
- case "debug": {
- let msg = new Messages.ConsoleGeneric(message);
- node = msg.init(this.output).render().element;
- break;
- }
- case "table": {
- let msg = new Messages.ConsoleTable(message);
- node = msg.init(this.output).render().element;
- break;
- }
- case "trace": {
- let msg = new Messages.ConsoleTrace(message);
- node = msg.init(this.output).render().element;
- break;
- }
- case "clear": {
- body = l10n.getStr("consoleCleared");
- clipboardText = body;
- break;
- }
- case "dir": {
- body = { arguments: args };
- let clipboardArray = [];
- args.forEach((value) => {
- clipboardArray.push(VariablesView.getString(value));
- });
- clipboardText = clipboardArray.join(" ");
- break;
- }
- case "dirxml": {
- // We just alias console.dirxml() with console.log().
- message.level = "log";
- return this.logConsoleAPIMessage(message);
- }
- case "group":
- case "groupCollapsed":
- clipboardText = body = message.groupName;
- this.groupDepth++;
- break;
-
- case "groupEnd":
- if (this.groupDepth > 0) {
- this.groupDepth--;
- }
- break;
-
- case "time": {
- let timer = message.timer;
- if (!timer) {
- return null;
- }
- if (timer.error) {
- console.error(new Error(l10n.getFormatStr(timer.error,
- [timer.name])));
- return null;
- }
- body = l10n.getFormatStr("timerStarted", [timer.name]);
- clipboardText = body;
- break;
- }
-
- case "timeEnd": {
- let timer = message.timer;
- if (!timer) {
- return null;
- }
- if (timer.error) {
- console.error(new Error(l10n.getFormatStr(timer.error,
- [timer.name])));
- return null;
- }
- let duration = Math.round(timer.duration * 100) / 100;
- body = l10n.getFormatStr("timeEnd", [timer.name, duration]);
- clipboardText = body;
- break;
- }
-
- case "count": {
- let counter = message.counter;
- if (!counter) {
- return null;
- }
- if (counter.error) {
- console.error(l10n.getStr(counter.error));
- return null;
- }
- let msg = new Messages.ConsoleGeneric(message);
- node = msg.init(this.output).render().element;
- break;
- }
-
- case "timeStamp": {
- // console.timeStamp() doesn't need to display anything.
- return null;
- }
-
- default:
- console.error(new Error("Unknown Console API log level: " + level));
- return null;
- }
-
- // Release object actors for arguments coming from console API methods that
- // we ignore their arguments.
- switch (level) {
- case "group":
- case "groupCollapsed":
- case "groupEnd":
- case "time":
- case "timeEnd":
- case "count":
- for (let actor of objectActors) {
- this._releaseObject(actor);
- }
- objectActors.clear();
- }
-
- if (level == "groupEnd") {
- // no need to continue
- return null;
- }
-
- if (!node) {
- node = this.createMessageNode(CATEGORY_WEBDEV, LEVELS[level], body,
- sourceURL, sourceLine, clipboardText,
- level, message.timeStamp);
- if (message.private) {
- node.setAttribute("private", true);
- }
- }
-
- if (objectActors.size > 0) {
- node._objectActors = objectActors;
-
- if (!node._messageObject) {
- let repeatNode = node.getElementsByClassName("message-repeats")[0];
- repeatNode._uid += [...objectActors].join("-");
- }
- }
-
- let workerTypeID = CONSOLE_WORKER_IDS.indexOf(message.workerType);
- if (workerTypeID != -1) {
- node.workerType = WORKERTYPES_PREFKEYS[workerTypeID];
- node.setAttribute("workerType", WORKERTYPES_PREFKEYS[workerTypeID]);
- }
-
- return node;
- },
-
- /**
- * Handle ConsoleAPICall objects received from the server. This method outputs
- * the window.console API call.
- *
- * @param object message
- * The console API message received from the server.
- */
- handleConsoleAPICall: function (message) {
- this.outputMessage(CATEGORY_WEBDEV, this.logConsoleAPIMessage, [message]);
- },
-
- /**
- * Reports an error in the page source, either JavaScript or CSS.
- *
- * @param nsIScriptError scriptError
- * The error message to report.
- * @return nsIDOMElement|undefined
- * The message element to display in the Web Console output.
- */
- reportPageError: function (category, scriptError) {
- // Warnings and legacy strict errors become warnings; other types become
- // errors.
- let severity = "error";
- if (scriptError.warning || scriptError.strict) {
- severity = "warning";
- } else if (scriptError.info) {
- severity = "log";
- }
-
- switch (category) {
- case CATEGORY_CSS:
- category = "css";
- break;
- case CATEGORY_SECURITY:
- category = "security";
- break;
- default:
- category = "js";
- break;
- }
-
- let objectActors = new Set();
-
- // Gather the actor IDs.
- for (let prop of ["errorMessage", "lineText"]) {
- let grip = scriptError[prop];
- if (WebConsoleUtils.isActorGrip(grip)) {
- objectActors.add(grip.actor);
- }
- }
-
- let errorMessage = scriptError.errorMessage;
- if (errorMessage.type && errorMessage.type == "longString") {
- errorMessage = errorMessage.initial;
- }
-
- let displayOrigin = scriptError.sourceName;
-
- // TLS errors are related to the connection and not the resource; therefore
- // it makes sense to only display the protcol, host and port (prePath).
- // This also means messages are grouped for a single origin.
- if (scriptError.category && scriptError.category == "SHA-1 Signature") {
- let sourceURI = Services.io.newURI(scriptError.sourceName)
- .QueryInterface(Ci.nsIURL);
- displayOrigin = sourceURI.prePath;
- }
-
- // Create a new message
- let msg = new Messages.Simple(errorMessage, {
- location: {
- url: displayOrigin,
- line: scriptError.lineNumber,
- column: scriptError.columnNumber
- },
- stack: scriptError.stacktrace,
- category: category,
- severity: severity,
- timestamp: scriptError.timeStamp,
- private: scriptError.private,
- filterDuplicates: true
- });
-
- let node = msg.init(this.output).render().element;
-
- // Select the body of the message node that is displayed in the console
- let msgBody = node.getElementsByClassName("message-body")[0];
-
- // Add the more info link node to messages that belong to certain categories
- if (scriptError.exceptionDocURL) {
- this.addLearnMoreWarningNode(msgBody, scriptError.exceptionDocURL);
- }
-
- // Collect telemetry data regarding JavaScript errors
- this._telemetry.logKeyed("DEVTOOLS_JAVASCRIPT_ERROR_DISPLAYED",
- scriptError.errorMessageName || "Unknown",
- true);
-
- if (objectActors.size > 0) {
- node._objectActors = objectActors;
- }
-
- return node;
- },
-
- /**
- * Handle PageError objects received from the server. This method outputs the
- * given error.
- *
- * @param nsIScriptError pageError
- * The error received from the server.
- */
- handlePageError: function (pageError) {
- let category = Utils.categoryForScriptError(pageError);
- this.outputMessage(category, this.reportPageError, [category, pageError]);
- },
-
- /**
- * Handle log messages received from the server. This method outputs the given
- * message.
- *
- * @param object packet
- * The message packet received from the server.
- */
- handleLogMessage: function (packet) {
- if (packet.message) {
- this.outputMessage(CATEGORY_JS, this._reportLogMessage, [packet]);
- }
- },
-
- /**
- * Display log messages received from the server.
- *
- * @private
- * @param object packet
- * The message packet received from the server.
- * @return nsIDOMElement
- * The message element to render for the given log message.
- */
- _reportLogMessage: function (packet) {
- let msg = packet.message;
- if (msg.type && msg.type == "longString") {
- msg = msg.initial;
- }
- let node = this.createMessageNode(CATEGORY_JS, SEVERITY_LOG, msg, null,
- null, null, null, packet.timeStamp);
- if (WebConsoleUtils.isActorGrip(packet.message)) {
- node._objectActors = new Set([packet.message.actor]);
- }
- return node;
- },
-
- /**
- * Log network event.
- *
- * @param object networkInfo
- * The network request information to log.
- * @return nsIDOMElement|null
- * The message element to display in the Web Console output.
- */
- logNetEvent: function (networkInfo) {
- let actorId = networkInfo.actor;
- let request = networkInfo.request;
- let clipboardText = request.method + " " + request.url;
- let severity = SEVERITY_LOG;
- if (networkInfo.isXHR) {
- clipboardText = request.method + " XHR " + request.url;
- severity = SEVERITY_INFO;
- }
- let mixedRequest =
- WebConsoleUtils.isMixedHTTPSRequest(request.url, this.contentLocation);
- if (mixedRequest) {
- severity = SEVERITY_WARNING;
- }
-
- let methodNode = this.document.createElementNS(XHTML_NS, "span");
- methodNode.className = "method";
- methodNode.textContent = request.method + " ";
-
- let messageNode = this.createMessageNode(CATEGORY_NETWORK, severity,
- methodNode, null, null,
- clipboardText, null,
- networkInfo.timeStamp);
- if (networkInfo.private) {
- messageNode.setAttribute("private", true);
- }
- messageNode._connectionId = actorId;
- messageNode.url = request.url;
-
- let body = methodNode.parentNode;
- body.setAttribute("aria-haspopup", true);
-
- if (networkInfo.isXHR) {
- let xhrNode = this.document.createElementNS(XHTML_NS, "span");
- xhrNode.className = "xhr";
- xhrNode.textContent = l10n.getStr("webConsoleXhrIndicator");
- body.appendChild(xhrNode);
- body.appendChild(this.document.createTextNode(" "));
- }
-
- let displayUrl = request.url;
- let pos = displayUrl.indexOf("?");
- if (pos > -1) {
- displayUrl = displayUrl.substr(0, pos);
- }
-
- let urlNode = this.document.createElementNS(XHTML_NS, "a");
- urlNode.className = "url";
- urlNode.setAttribute("title", request.url);
- urlNode.href = request.url;
- urlNode.textContent = displayUrl;
- urlNode.draggable = false;
- body.appendChild(urlNode);
- body.appendChild(this.document.createTextNode(" "));
-
- if (mixedRequest) {
- messageNode.classList.add("mixed-content");
- this.makeMixedContentNode(body);
- }
-
- let statusNode = this.document.createElementNS(XHTML_NS, "a");
- statusNode.className = "status";
- body.appendChild(statusNode);
-
- let onClick = () => this.openNetworkPanel(networkInfo.actor);
-
- this._addMessageLinkCallback(urlNode, onClick);
- this._addMessageLinkCallback(statusNode, onClick);
-
- networkInfo.node = messageNode;
-
- this._updateNetMessage(actorId);
-
- if (this.window.NetRequest) {
- this.window.NetRequest.onNetworkEvent({
- consoleFrame: this,
- response: networkInfo,
- node: messageNode,
- update: false
- });
- }
-
- return messageNode;
- },
-
- /**
- * Create a mixed content warning Node.
- *
- * @param linkNode
- * Parent to the requested urlNode.
- */
- makeMixedContentNode: function (linkNode) {
- let mixedContentWarning =
- "[" + l10n.getStr("webConsoleMixedContentWarning") + "]";
-
- // Mixed content warning message links to a Learn More page
- let mixedContentWarningNode = this.document.createElementNS(XHTML_NS, "a");
- mixedContentWarningNode.title = MIXED_CONTENT_LEARN_MORE;
- mixedContentWarningNode.href = MIXED_CONTENT_LEARN_MORE;
- mixedContentWarningNode.className = "learn-more-link";
- mixedContentWarningNode.textContent = mixedContentWarning;
- mixedContentWarningNode.draggable = false;
-
- linkNode.appendChild(mixedContentWarningNode);
-
- this._addMessageLinkCallback(mixedContentWarningNode, (event) => {
- event.stopPropagation();
- this.owner.openLink(MIXED_CONTENT_LEARN_MORE);
- });
- },
-
- /*
- * Appends a clickable warning node to the node passed
- * as a parameter to the function. When a user clicks on the appended
- * warning node, the browser navigates to the provided url.
- *
- * @param node
- * The node to which we will be adding a clickable warning node.
- * @param url
- * The url which points to the page where the user can learn more
- * about security issues associated with the specific message that's
- * being logged.
- */
- addLearnMoreWarningNode: function (node, url) {
- let moreInfoLabel = "[" + l10n.getStr("webConsoleMoreInfoLabel") + "]";
-
- let warningNode = this.document.createElementNS(XHTML_NS, "a");
- warningNode.title = url.split("?")[0];
- warningNode.href = url;
- warningNode.draggable = false;
- warningNode.textContent = moreInfoLabel;
- warningNode.className = "learn-more-link";
-
- this._addMessageLinkCallback(warningNode, (event) => {
- event.stopPropagation();
- this.owner.openLink(url);
- });
-
- node.appendChild(warningNode);
- },
-
- /**
- * Log file activity.
- *
- * @param string fileURI
- * The file URI that was loaded.
- * @return nsIDOMElement|undefined
- * The message element to display in the Web Console output.
- */
- logFileActivity: function (fileURI) {
- let urlNode = this.document.createElementNS(XHTML_NS, "a");
- urlNode.setAttribute("title", fileURI);
- urlNode.className = "url";
- urlNode.textContent = fileURI;
- urlNode.draggable = false;
- urlNode.href = fileURI;
-
- let outputNode = this.createMessageNode(CATEGORY_NETWORK, SEVERITY_LOG,
- urlNode, null, null, fileURI);
-
- this._addMessageLinkCallback(urlNode, () => {
- this.owner.viewSource(fileURI);
- });
-
- return outputNode;
- },
-
- /**
- * Handle the file activity messages coming from the remote Web Console.
- *
- * @param string fileURI
- * The file URI that was requested.
- */
- handleFileActivity: function (fileURI) {
- this.outputMessage(CATEGORY_NETWORK, this.logFileActivity, [fileURI]);
- },
-
- /**
- * Handle the reflow activity messages coming from the remote Web Console.
- *
- * @param object msg
- * An object holding information about a reflow batch.
- */
- logReflowActivity: function (message) {
- let {start, end, sourceURL, sourceLine} = message;
- let duration = Math.round((end - start) * 100) / 100;
- let node = this.document.createElementNS(XHTML_NS, "span");
- if (sourceURL) {
- node.textContent =
- l10n.getFormatStr("reflow.messageWithLink", [duration]);
- let a = this.document.createElementNS(XHTML_NS, "a");
- a.href = "#";
- a.draggable = "false";
- let filename = getSourceNames(sourceURL).short;
- let functionName = message.functionName ||
- l10n.getStr("stacktrace.anonymousFunction");
- a.textContent = l10n.getFormatStr("reflow.messageLinkText",
- [functionName, filename, sourceLine]);
- this._addMessageLinkCallback(a, () => {
- this.owner.viewSourceInDebugger(sourceURL, sourceLine);
- });
- node.appendChild(a);
- } else {
- node.textContent =
- l10n.getFormatStr("reflow.messageWithNoLink", [duration]);
- }
- return this.createMessageNode(CATEGORY_CSS, SEVERITY_LOG, node);
- },
-
- handleReflowActivity: function (message) {
- this.outputMessage(CATEGORY_CSS, this.logReflowActivity, [message]);
- },
-
- /**
- * Inform user that the window.console API has been replaced by a script
- * in a content page.
- */
- logWarningAboutReplacedAPI: function () {
- let node = this.createMessageNode(CATEGORY_JS, SEVERITY_WARNING,
- l10n.getStr("ConsoleAPIDisabled"));
- this.outputMessage(CATEGORY_JS, node);
- },
-
- /**
- * Handle the network events coming from the remote Web Console.
- *
- * @param object networkInfo
- * The network request information.
- */
- handleNetworkEvent: function (networkInfo) {
- this.outputMessage(CATEGORY_NETWORK, this.logNetEvent, [networkInfo]);
- },
-
- /**
- * Handle network event updates coming from the server.
- *
- * @param object networkInfo
- * The network request information.
- * @param object packet
- * Update details.
- */
- handleNetworkEventUpdate: function (networkInfo, packet) {
- if (networkInfo.node && this._updateNetMessage(packet.from)) {
- if (this.window.NetRequest) {
- this.window.NetRequest.onNetworkEvent({
- client: this.webConsoleClient,
- response: packet,
- node: networkInfo.node,
- update: true
- });
- }
-
- this.emit("new-messages", new Set([{
- update: true,
- node: networkInfo.node,
- response: packet,
- }]));
- }
-
- // For unit tests we pass the HTTP activity object to the test callback,
- // once requests complete.
- if (this.owner.lastFinishedRequestCallback &&
- networkInfo.updates.indexOf("responseContent") > -1 &&
- networkInfo.updates.indexOf("eventTimings") > -1) {
- this.owner.lastFinishedRequestCallback(networkInfo, this);
- }
- },
-
- /**
- * Update an output message to reflect the latest state of a network request,
- * given a network event actor ID.
- *
- * @private
- * @param string actorId
- * The network event actor ID for which you want to update the message.
- * @return boolean
- * |true| if the message node was updated, or |false| otherwise.
- */
- _updateNetMessage: function (actorId) {
- let networkInfo = this.webConsoleClient.getNetworkRequest(actorId);
- if (!networkInfo || !networkInfo.node) {
- return false;
- }
-
- let messageNode = networkInfo.node;
- let updates = networkInfo.updates;
- let hasEventTimings = updates.indexOf("eventTimings") > -1;
- let hasResponseStart = updates.indexOf("responseStart") > -1;
- let request = networkInfo.request;
- let methodText = (networkInfo.isXHR) ?
- request.method + " XHR" : request.method;
- let response = networkInfo.response;
- let updated = false;
-
- if (hasEventTimings || hasResponseStart) {
- let status = [];
- if (response.httpVersion && response.status) {
- status = [response.httpVersion, response.status, response.statusText];
- }
- if (hasEventTimings) {
- status.push(l10n.getFormatStr("NetworkPanel.durationMS",
- [networkInfo.totalTime]));
- }
- let statusText = "[" + status.join(" ") + "]";
-
- let statusNode = messageNode.getElementsByClassName("status")[0];
- statusNode.textContent = statusText;
-
- messageNode.clipboardText = [methodText, request.url, statusText]
- .join(" ");
-
- if (hasResponseStart && response.status >= MIN_HTTP_ERROR_CODE &&
- response.status <= MAX_HTTP_ERROR_CODE) {
- this.setMessageType(messageNode, CATEGORY_NETWORK, SEVERITY_ERROR);
- }
-
- updated = true;
- }
-
- if (messageNode._netPanel) {
- messageNode._netPanel.update();
- }
-
- return updated;
- },
-
- /**
- * Opens the network monitor and highlights the specified request.
- *
- * @param string requestId
- * The actor ID of the network request.
- */
- openNetworkPanel: function (requestId) {
- let toolbox = gDevTools.getToolbox(this.owner.target);
- // The browser console doesn't have a toolbox.
- if (toolbox) {
- return toolbox.selectTool("netmonitor").then(panel => {
- return panel.panelWin.Netmonitor.inspectRequest(requestId);
- });
- }
- },
-
- /**
- * Handler for page location changes.
- *
- * @param string uri
- * New page location.
- * @param string title
- * New page title.
- */
- onLocationChange: function (uri, title) {
- this.contentLocation = uri;
- if (this.owner.onLocationChange) {
- this.owner.onLocationChange(uri, title);
- }
- },
-
- /**
- * Handler for the tabNavigated notification.
- *
- * @param object packet
- * Notification packet received from the server.
- */
- handleTabNavigated: function (packet) {
- if (packet.url) {
- this.onLocationChange(packet.url, packet.title);
- }
-
- if (!packet.nativeConsoleAPI) {
- this.logWarningAboutReplacedAPI();
- }
- },
-
- /**
- * Handler for the tabNavigated notification.
- *
- * @param object packet
- * Notification packet received from the server.
- */
- handleTabWillNavigate: function (packet) {
- if (this.persistLog) {
- let marker = new Messages.NavigationMarker(packet, Date.now());
- this.output.addMessage(marker);
- } else {
- this.jsterm.clearOutput();
- }
-
- if (packet.url) {
- this.onLocationChange(packet.url, packet.title);
- }
- },
-
- /**
- * Output a message node. This filters a node appropriately, then sends it to
- * the output, regrouping and pruning output as necessary.
- *
- * Note: this call is async - the given message node may not be displayed when
- * you call this method.
- *
- * @param integer category
- * The category of the message you want to output. See the CATEGORY_*
- * constants.
- * @param function|nsIDOMElement methodOrNode
- * The method that creates the message element to send to the output or
- * the actual element. If a method is given it will be bound to the HUD
- * object and the arguments will be |args|.
- * @param array [args]
- * If a method is given to output the message element then the method
- * will be invoked with the list of arguments given here. The last
- * object in this array should be the packet received from the
- * back end.
- */
- outputMessage: function (category, methodOrNode, args) {
- if (!this._outputQueue.length) {
- // If the queue is empty we consider that now was the last output flush.
- // This avoid an immediate output flush when the timer executes.
- this._lastOutputFlush = Date.now();
- }
-
- this._outputQueue.push([category, methodOrNode, args]);
-
- this._initOutputTimer();
- },
-
- /**
- * Try to flush the output message queue. This takes the messages in the
- * output queue and displays them. Outputting stops at MESSAGES_IN_INTERVAL.
- * Further output is queued to happen later - see OUTPUT_INTERVAL.
- *
- * @private
- */
- _flushMessageQueue: function () {
- this._outputTimerInitialized = false;
- if (!this._outputTimer) {
- return;
- }
-
- let startTime = Date.now();
- let timeSinceFlush = startTime - this._lastOutputFlush;
- let shouldThrottle = this._outputQueue.length > MESSAGES_IN_INTERVAL &&
- timeSinceFlush < THROTTLE_UPDATES;
-
- // Determine how many messages we can display now.
- let toDisplay = Math.min(this._outputQueue.length, MESSAGES_IN_INTERVAL);
-
- // If there aren't any messages to display (because of throttling or an
- // empty queue), then take care of some cleanup. Destroy items that were
- // pruned from the outputQueue before being displayed.
- if (shouldThrottle || toDisplay < 1) {
- while (this._itemDestroyQueue.length) {
- if ((Date.now() - startTime) > MAX_CLEANUP_TIME) {
- break;
- }
- this._destroyItem(this._itemDestroyQueue.pop());
- }
-
- this._initOutputTimer();
- return;
- }
-
- // Try to prune the message queue.
- let shouldPrune = false;
- if (this._outputQueue.length > toDisplay && this._pruneOutputQueue()) {
- toDisplay = Math.min(this._outputQueue.length, toDisplay);
- shouldPrune = true;
- }
-
- let batch = this._outputQueue.splice(0, toDisplay);
- let outputNode = this.outputNode;
- let lastVisibleNode = null;
- let scrollNode = this.outputWrapper;
- let hudIdSupportsString = WebConsoleUtils.supportsString(this.hudId);
-
- // We won't bother to try to restore scroll position if this is showing
- // a lot of messages at once (and there are still items in the queue).
- // It is going to purge whatever you were looking at anyway.
- let scrolledToBottom =
- shouldPrune || Utils.isOutputScrolledToBottom(outputNode, scrollNode);
-
- // Output the current batch of messages.
- let messages = new Set();
- for (let i = 0; i < batch.length; i++) {
- let item = batch[i];
- let result = this._outputMessageFromQueue(hudIdSupportsString, item);
- if (result) {
- messages.add({
- node: result.isRepeated ? result.isRepeated : result.node,
- response: result.message,
- update: !!result.isRepeated,
- });
-
- if (result.visible && result.node == this.outputNode.lastChild) {
- lastVisibleNode = result.node;
- }
- }
- }
-
- let oldScrollHeight = 0;
- let removedNodes = 0;
-
- // Prune messages from the DOM, but only if needed.
- if (shouldPrune || !this._outputQueue.length) {
- // Only bother measuring the scrollHeight if not scrolled to bottom,
- // since the oldScrollHeight will not be used if it is.
- if (!scrolledToBottom) {
- oldScrollHeight = scrollNode.scrollHeight;
- }
-
- let categories = Object.keys(this._pruneCategoriesQueue);
- categories.forEach(function _pruneOutput(category) {
- removedNodes += this.pruneOutputIfNecessary(category);
- }, this);
- this._pruneCategoriesQueue = {};
- }
-
- let isInputOutput = lastVisibleNode &&
- (lastVisibleNode.category == CATEGORY_INPUT ||
- lastVisibleNode.category == CATEGORY_OUTPUT);
-
- // Scroll to the new node if it is not filtered, and if the output node is
- // scrolled at the bottom or if the new node is a jsterm input/output
- // message.
- if (lastVisibleNode && (scrolledToBottom || isInputOutput)) {
- Utils.scrollToVisible(lastVisibleNode);
- } else if (!scrolledToBottom && removedNodes > 0 &&
- oldScrollHeight != scrollNode.scrollHeight) {
- // If there were pruned messages and if scroll is not at the bottom, then
- // we need to adjust the scroll location.
- scrollNode.scrollTop -= oldScrollHeight - scrollNode.scrollHeight;
- }
-
- if (messages.size) {
- this.emit("new-messages", messages);
- }
-
- // If the output queue is empty, then run _flushCallback.
- if (this._outputQueue.length === 0 && this._flushCallback) {
- if (this._flushCallback() === false) {
- this._flushCallback = null;
- }
- }
-
- this._initOutputTimer();
-
- // Resize the output area in case a vertical scrollbar has been added
- this.resize();
-
- this._lastOutputFlush = Date.now();
- },
-
- /**
- * Initialize the output timer.
- * @private
- */
- _initOutputTimer: function () {
- let panelIsDestroyed = !this._outputTimer;
- let alreadyScheduled = this._outputTimerInitialized;
- let nothingToDo = !this._itemDestroyQueue.length &&
- !this._outputQueue.length;
-
- // Don't schedule a callback in the following cases:
- if (panelIsDestroyed || alreadyScheduled || nothingToDo) {
- return;
- }
-
- this._outputTimerInitialized = true;
- this._outputTimer.initWithCallback(this._flushMessageQueue,
- OUTPUT_INTERVAL,
- Ci.nsITimer.TYPE_ONE_SHOT);
- },
-
- /**
- * Output a message from the queue.
- *
- * @private
- * @param nsISupportsString hudIdSupportsString
- * The HUD ID as an nsISupportsString.
- * @param array item
- * An item from the output queue - this item represents a message.
- * @return object
- * An object that holds the following properties:
- * - node: the DOM element of the message.
- * - isRepeated: the DOM element of the original message, if this is
- * a repeated message, otherwise null.
- * - visible: boolean that tells if the message is visible.
- */
- _outputMessageFromQueue: function (hudIdSupportsString, item) {
- let [, methodOrNode, args] = item;
-
- // The last object in the args array should be message
- // object or response packet received from the server.
- let message = (args && args.length) ? args[args.length - 1] : null;
-
- let node = typeof methodOrNode == "function" ?
- methodOrNode.apply(this, args || []) :
- methodOrNode;
- if (!node) {
- return null;
- }
-
- let isFiltered = this.filterMessageNode(node);
-
- let isRepeated = this._filterRepeatedMessage(node);
-
- // If a clear message is processed while the webconsole is opened, the UI
- // should be cleared.
- // Do not clear the output if the current frame is owned by a Browser Console.
- if (message && message.level == "clear" && !this.isBrowserConsole) {
- // Do not clear the consoleStorage here as it has been cleared already
- // by the clear method, only clear the UI.
- this.jsterm.clearOutput(false);
- }
-
- let visible = !isRepeated && !isFiltered;
- if (!isRepeated) {
- this.outputNode.appendChild(node);
- this._pruneCategoriesQueue[node.category] = true;
-
- let nodeID = node.getAttribute("id");
- Services.obs.notifyObservers(hudIdSupportsString,
- "web-console-message-created", nodeID);
- }
-
- if (node._onOutput) {
- node._onOutput();
- delete node._onOutput;
- }
-
- return {
- visible: visible,
- node: node,
- isRepeated: isRepeated,
- message: message
- };
- },
-
- /**
- * Prune the queue of messages to display. This avoids displaying messages
- * that will be removed at the end of the queue anyway.
- * @private
- */
- _pruneOutputQueue: function () {
- let nodes = {};
-
- // Group the messages per category.
- this._outputQueue.forEach(function (item, index) {
- let [category] = item;
- if (!(category in nodes)) {
- nodes[category] = [];
- }
- nodes[category].push(index);
- }, this);
-
- let pruned = 0;
-
- // Loop through the categories we found and prune if needed.
- for (let category in nodes) {
- let limit = Utils.logLimitForCategory(category);
- let indexes = nodes[category];
- if (indexes.length > limit) {
- let n = Math.max(0, indexes.length - limit);
- pruned += n;
- for (let i = n - 1; i >= 0; i--) {
- this._itemDestroyQueue.push(this._outputQueue[indexes[i]]);
- this._outputQueue.splice(indexes[i], 1);
- }
- }
- }
-
- return pruned;
- },
-
- /**
- * Destroy an item that was once in the outputQueue but isn't needed
- * after all.
- *
- * @private
- * @param array item
- * The item you want to destroy. Does not remove it from the output
- * queue.
- */
- _destroyItem: function (item) {
- // TODO: handle object releasing in a more elegant way once all console
- // messages use the new API - bug 778766.
- let [category, methodOrNode, args] = item;
- if (typeof methodOrNode != "function" && methodOrNode._objectActors) {
- for (let actor of methodOrNode._objectActors) {
- this._releaseObject(actor);
- }
- methodOrNode._objectActors.clear();
- }
-
- if (methodOrNode == this.output._flushMessageQueue &&
- args[0]._objectActors) {
- for (let arg of args) {
- if (!arg._objectActors) {
- continue;
- }
- for (let actor of arg._objectActors) {
- this._releaseObject(actor);
- }
- arg._objectActors.clear();
- }
- }
-
- if (category == CATEGORY_NETWORK) {
- let connectionId = null;
- if (methodOrNode == this.logNetEvent) {
- connectionId = args[0].actor;
- } else if (typeof methodOrNode != "function") {
- connectionId = methodOrNode._connectionId;
- }
- if (connectionId &&
- this.webConsoleClient.hasNetworkRequest(connectionId)) {
- this.webConsoleClient.removeNetworkRequest(connectionId);
- this._releaseObject(connectionId);
- }
- } else if (category == CATEGORY_WEBDEV &&
- methodOrNode == this.logConsoleAPIMessage) {
- args[0].arguments.forEach((value) => {
- if (WebConsoleUtils.isActorGrip(value)) {
- this._releaseObject(value.actor);
- }
- });
- } else if (category == CATEGORY_JS &&
- methodOrNode == this.reportPageError) {
- let pageError = args[1];
- for (let prop of ["errorMessage", "lineText"]) {
- let grip = pageError[prop];
- if (WebConsoleUtils.isActorGrip(grip)) {
- this._releaseObject(grip.actor);
- }
- }
- } else if (category == CATEGORY_JS &&
- methodOrNode == this._reportLogMessage) {
- if (WebConsoleUtils.isActorGrip(args[0].message)) {
- this._releaseObject(args[0].message.actor);
- }
- }
- },
-
- /**
- * Cleans up a message via a node that may or may not
- * have actually been rendered in the DOM. Currently, only
- * cleans up React components.
- *
- * @param nsIDOMNode node
- * The message node you want to clean up.
- */
- unmountMessage(node) {
- // Unmount the Frame component with the message location
- let locationNode = node.querySelector(".message-location");
- if (locationNode) {
- this.ReactDOM.unmountComponentAtNode(locationNode);
- }
-
- // Unmount the StackTrace component if present in the message
- let stacktraceNode = node.querySelector(".stacktrace");
- if (stacktraceNode) {
- this.ReactDOM.unmountComponentAtNode(stacktraceNode);
- }
- },
-
- /**
- * Ensures that the number of message nodes of type category don't exceed that
- * category's line limit by removing old messages as needed.
- *
- * @param integer category
- * The category of message nodes to prune if needed.
- * @return number
- * The number of removed nodes.
- */
- pruneOutputIfNecessary: function (category) {
- let logLimit = Utils.logLimitForCategory(category);
- let messageNodes = this.outputNode.querySelectorAll(".message[category=" +
- CATEGORY_CLASS_FRAGMENTS[category] + "]");
- let n = Math.max(0, messageNodes.length - logLimit);
- [...messageNodes].slice(0, n).forEach(this.removeOutputMessage, this);
- return n;
- },
-
- /**
- * Remove a given message from the output.
- *
- * @param nsIDOMNode node
- * The message node you want to remove.
- */
- removeOutputMessage: function (node) {
- if (node._messageObject) {
- node._messageObject.destroy();
- }
-
- if (node._objectActors) {
- for (let actor of node._objectActors) {
- this._releaseObject(actor);
- }
- node._objectActors.clear();
- }
-
- if (node.category == CATEGORY_CSS ||
- node.category == CATEGORY_SECURITY) {
- let repeatNode = node.getElementsByClassName("message-repeats")[0];
- if (repeatNode && repeatNode._uid) {
- delete this._repeatNodes[repeatNode._uid];
- }
- } else if (node._connectionId &&
- node.category == CATEGORY_NETWORK) {
- this.webConsoleClient.removeNetworkRequest(node._connectionId);
- this._releaseObject(node._connectionId);
- } else if (node.classList.contains("inlined-variables-view")) {
- let view = node._variablesView;
- if (view) {
- view.controller.releaseActors();
- }
- node._variablesView = null;
- }
-
- this.unmountMessage(node);
-
- node.remove();
- },
-
- /**
- * Given a category and message body, creates a DOM node to represent an
- * incoming message. The timestamp is automatically added.
- *
- * @param number category
- * The category of the message: one of the CATEGORY_* constants.
- * @param number severity
- * The severity of the message: one of the SEVERITY_* constants;
- * @param string|nsIDOMNode body
- * The body of the message, either a simple string or a DOM node.
- * @param string sourceURL [optional]
- * The URL of the source file that emitted the error.
- * @param number sourceLine [optional]
- * The line number on which the error occurred. If zero or omitted,
- * there is no line number associated with this message.
- * @param string clipboardText [optional]
- * The text that should be copied to the clipboard when this node is
- * copied. If omitted, defaults to the body text. If `body` is not
- * a string, then the clipboard text must be supplied.
- * @param number level [optional]
- * The level of the console API message.
- * @param number timestamp [optional]
- * The timestamp to use for this message node. If omitted, the current
- * date and time is used.
- * @return nsIDOMNode
- * The message node: a DIV ready to be inserted into the Web Console
- * output node.
- */
- createMessageNode: function (category, severity, body, sourceURL, sourceLine,
- clipboardText, level, timestamp) {
- if (typeof body != "string" && clipboardText == null && body.innerText) {
- clipboardText = body.innerText;
- }
-
- let indentNode = this.document.createElementNS(XHTML_NS, "span");
- indentNode.className = "indent";
-
- // Apply the current group by indenting appropriately.
- let indent = this.groupDepth * GROUP_INDENT;
- indentNode.style.width = indent + "px";
-
- // Make the icon container, which is a vertical box. Its purpose is to
- // ensure that the icon stays anchored at the top of the message even for
- // long multi-line messages.
- let iconContainer = this.document.createElementNS(XHTML_NS, "span");
- iconContainer.className = "icon";
-
- // Create the message body, which contains the actual text of the message.
- let bodyNode = this.document.createElementNS(XHTML_NS, "span");
- bodyNode.className = "message-body-wrapper message-body devtools-monospace";
-
- // Store the body text, since it is needed later for the variables view.
- let storedBody = body;
- // If a string was supplied for the body, turn it into a DOM node and an
- // associated clipboard string now.
- clipboardText = clipboardText ||
- (body + (sourceURL ? " @ " + sourceURL : "") +
- (sourceLine ? ":" + sourceLine : ""));
-
- timestamp = timestamp || Date.now();
-
- // Create the containing node and append all its elements to it.
- let node = this.document.createElementNS(XHTML_NS, "div");
- node.id = "console-msg-" + gSequenceId();
- node.className = "message";
- node.clipboardText = clipboardText;
- node.timestamp = timestamp;
- this.setMessageType(node, category, severity);
-
- if (body instanceof Ci.nsIDOMNode) {
- bodyNode.appendChild(body);
- } else {
- let str = undefined;
- if (level == "dir") {
- str = VariablesView.getString(body.arguments[0]);
- } else {
- str = body;
- }
-
- if (str !== undefined) {
- body = this.document.createTextNode(str);
- bodyNode.appendChild(body);
- }
- }
-
- // Add the message repeats node only when needed.
- let repeatNode = null;
- if (category != CATEGORY_INPUT &&
- category != CATEGORY_OUTPUT &&
- category != CATEGORY_NETWORK &&
- !(category == CATEGORY_CSS && severity == SEVERITY_LOG)) {
- repeatNode = this.document.createElementNS(XHTML_NS, "span");
- repeatNode.setAttribute("value", "1");
- repeatNode.className = "message-repeats";
- repeatNode.textContent = 1;
- repeatNode._uid = [bodyNode.textContent, category, severity, level,
- sourceURL, sourceLine].join(":");
- }
-
- // Create the timestamp.
- let timestampNode = this.document.createElementNS(XHTML_NS, "span");
- timestampNode.className = "timestamp devtools-monospace";
-
- let timestampString = l10n.timestampString(timestamp);
- timestampNode.textContent = timestampString + " ";
-
- // Create the source location (e.g. www.example.com:6) that sits on the
- // right side of the message, if applicable.
- let locationNode;
- if (sourceURL && !IGNORED_SOURCE_URLS.includes(sourceURL)) {
- locationNode = this.createLocationNode({url: sourceURL,
- line: sourceLine});
- }
-
- node.appendChild(timestampNode);
- node.appendChild(indentNode);
- node.appendChild(iconContainer);
-
- // Display the variables view after the message node.
- if (level == "dir") {
- let options = {
- objectActor: storedBody.arguments[0],
- targetElement: bodyNode,
- hideFilterInput: true,
- };
- this.jsterm.openVariablesView(options).then((view) => {
- node._variablesView = view;
- if (node.classList.contains("hidden-message")) {
- node.classList.remove("hidden-message");
- }
- });
-
- node.classList.add("inlined-variables-view");
- }
-
- node.appendChild(bodyNode);
- if (repeatNode) {
- node.appendChild(repeatNode);
- }
- if (locationNode) {
- node.appendChild(locationNode);
- }
- node.appendChild(this.document.createTextNode("\n"));
-
- return node;
- },
-
- /**
- * Creates the anchor that displays the textual location of an incoming
- * message.
- *
- * @param {Object} location
- * An object containing url, line and column number of the message source.
- * @return {Element}
- * The new anchor element, ready to be added to the message node.
- */
- createLocationNode: function (location) {
- let locationNode = this.document.createElementNS(XHTML_NS, "div");
- locationNode.className = "message-location devtools-monospace";
-
- // Make the location clickable.
- let onClick = ({ url, line }) => {
- let category = locationNode.closest(".message").category;
- let target = null;
-
- if (/^Scratchpad\/\d+$/.test(url)) {
- target = "scratchpad";
- } else if (category === CATEGORY_CSS) {
- target = "styleeditor";
- } else if (category === CATEGORY_JS || category === CATEGORY_WEBDEV) {
- target = "jsdebugger";
- } else if (/\.js$/.test(url)) {
- // If it ends in .js, let's attempt to open in debugger
- // anyway, as this falls back to normal view-source.
- target = "jsdebugger";
- } else {
- // Point everything else to debugger, if source not available,
- // it will fall back to view-source.
- target = "jsdebugger";
- }
-
- switch (target) {
- case "scratchpad":
- this.owner.viewSourceInScratchpad(url, line);
- return;
- case "jsdebugger":
- this.owner.viewSourceInDebugger(url, line);
- return;
- case "styleeditor":
- this.owner.viewSourceInStyleEditor(url, line);
- return;
- }
- // No matching tool found; use old school view-source
- this.owner.viewSource(url, line);
- };
-
- const toolbox = gDevTools.getToolbox(this.owner.target);
-
- let { url, line, column } = location;
- let source = url ? url.split(" -> ").pop() : "";
-
- this.ReactDOM.render(this.FrameView({
- frame: { source, line, column },
- showEmptyPathAsHost: true,
- onClick,
- sourceMapService: toolbox ? toolbox.sourceMapURLService : null,
- }), locationNode);
-
- return locationNode;
- },
-
- /**
- * Adjusts the category and severity of the given message.
- *
- * @param nsIDOMNode messageNode
- * The message node to alter.
- * @param number category
- * The category for the message; one of the CATEGORY_ constants.
- * @param number severity
- * The severity for the message; one of the SEVERITY_ constants.
- * @return void
- */
- setMessageType: function (messageNode, category, severity) {
- messageNode.category = category;
- messageNode.severity = severity;
- messageNode.setAttribute("category", CATEGORY_CLASS_FRAGMENTS[category]);
- messageNode.setAttribute("severity", SEVERITY_CLASS_FRAGMENTS[severity]);
- messageNode.setAttribute("filter",
- MESSAGE_PREFERENCE_KEYS[category][severity]);
- },
-
- /**
- * Add the mouse event handlers needed to make a link.
- *
- * @private
- * @param nsIDOMNode node
- * The node for which you want to add the event handlers.
- * @param function callback
- * The function you want to invoke on click.
- */
- _addMessageLinkCallback: function (node, callback) {
- node.addEventListener("mousedown", (event) => {
- this._mousedown = true;
- this._startX = event.clientX;
- this._startY = event.clientY;
- });
-
- node.addEventListener("click", (event) => {
- let mousedown = this._mousedown;
- this._mousedown = false;
-
- event.preventDefault();
-
- // Do not allow middle/right-click or 2+ clicks.
- if (event.detail != 1 || event.button != 0) {
- return;
- }
-
- // If this event started with a mousedown event and it ends at a different
- // location, we consider this text selection.
- if (mousedown &&
- (this._startX != event.clientX) &&
- (this._startY != event.clientY)) {
- this._startX = this._startY = undefined;
- return;
- }
-
- this._startX = this._startY = undefined;
-
- callback.call(this, event);
- });
- },
- /**
- * Called when the message timestamp pref changes.
- */
- _onToolboxPrefChanged: function () {
- let newValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
- if (newValue) {
- this.outputNode.classList.remove("hideTimestamps");
- } else {
- this.outputNode.classList.add("hideTimestamps");
- }
- },
- /**
- * Copies the selected items to the system clipboard.
- *
- * @param object options
- * - linkOnly:
- * An optional flag to copy only URL without other meta-information.
- * Default is false.
- * - contextmenu:
- * An optional flag to copy the last clicked item which brought
- * up the context menu if nothing is selected. Default is false.
- */
- copySelectedItems: function (options) {
- options = options || { linkOnly: false, contextmenu: false };
-
- // Gather up the selected items and concatenate their clipboard text.
- let strings = [];
-
- let children = this.output.getSelectedMessages();
- if (!children.length && options.contextmenu) {
- children = [this._contextMenuHandler.lastClickedMessage];
- }
-
- for (let item of children) {
- // Ensure the selected item hasn't been filtered by type or string.
- if (!item.classList.contains("filtered-by-type") &&
- !item.classList.contains("filtered-by-string")) {
- if (options.linkOnly) {
- strings.push(item.url);
- } else {
- strings.push(item.clipboardText);
- }
- }
- }
-
- clipboardHelper.copyString(strings.join("\n"));
- },
-
- /**
- * Object properties provider. This function gives you the properties of the
- * remote object you want.
- *
- * @param string actor
- * The object actor ID from which you want the properties.
- * @param function callback
- * Function you want invoked once the properties are received.
- */
- objectPropertiesProvider: function (actor, callback) {
- this.webConsoleClient.inspectObjectProperties(actor,
- function (response) {
- if (response.error) {
- console.error("Failed to retrieve the object properties from the " +
- "server. Error: " + response.error);
- return;
- }
- callback(response.properties);
- });
- },
-
- /**
- * Release an actor.
- *
- * @private
- * @param string actor
- * The actor ID you want to release.
- */
- _releaseObject: function (actor) {
- if (this.proxy) {
- this.proxy.releaseActor(actor);
- }
- },
-
- /**
- * Open the selected item's URL in a new tab.
- */
- openSelectedItemInTab: function () {
- let item = this.output.getSelectedMessages(1)[0] ||
- this._contextMenuHandler.lastClickedMessage;
-
- if (!item || !item.url) {
- return;
- }
-
- this.owner.openLink(item.url);
- },
-
- /**
- * Destroy the WebConsoleFrame object. Call this method to avoid memory leaks
- * when the Web Console is closed.
- *
- * @return object
- * A promise that is resolved when the WebConsoleFrame instance is
- * destroyed.
- */
- destroy: function () {
- if (this._destroyer) {
- return this._destroyer.promise;
- }
-
- this._destroyer = defer();
-
- let toolbox = gDevTools.getToolbox(this.owner.target);
- if (toolbox) {
- toolbox.off("webconsole-selected", this._onPanelSelected);
- }
-
- this._prefObserver.off(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged);
- this._prefObserver.destroy();
- this.window.removeEventListener("resize", this.resize, true);
-
- this._repeatNodes = {};
- this._outputQueue.forEach(this._destroyItem, this);
- this._outputQueue = [];
- this._itemDestroyQueue.forEach(this._destroyItem, this);
- this._itemDestroyQueue = [];
- this._pruneCategoriesQueue = {};
- this.webConsoleClient.clearNetworkRequests();
-
- // Unmount any currently living frame components in DOM, since
- // currently we only clean up messages in `this.removeOutputMessage`,
- // via `this.pruneOutputIfNecessary`.
- let liveMessages = this.outputNode.querySelectorAll(".message");
- Array.prototype.forEach.call(liveMessages, this.unmountMessage);
-
- if (this._outputTimerInitialized) {
- this._outputTimerInitialized = false;
- this._outputTimer.cancel();
- }
- this._outputTimer = null;
- if (this.jsterm) {
- this.jsterm.off("sidebar-opened", this.resize);
- this.jsterm.off("sidebar-closed", this.resize);
- this.jsterm.destroy();
- this.jsterm = null;
- }
- this.output.destroy();
- this.output = null;
-
- this.React = this.ReactDOM = this.FrameView = null;
-
- if (this._contextMenuHandler) {
- this._contextMenuHandler.destroy();
- this._contextMenuHandler = null;
- }
-
- this._commandController = null;
-
- let onDestroy = () => {
- this._destroyer.resolve(null);
- };
-
- if (this.proxy) {
- this.proxy.disconnect().then(onDestroy);
- this.proxy = null;
- } else {
- onDestroy();
- }
-
- return this._destroyer.promise;
- },
-};
-
-/**
- * Utils: a collection of globally used functions.
- */
-var Utils = {
- /**
- * Scrolls a node so that it's visible in its containing element.
- *
- * @param nsIDOMNode node
- * The node to make visible.
- * @returns void
- */
- scrollToVisible: function (node) {
- node.scrollIntoView(false);
- },
-
- /**
- * Check if the given output node is scrolled to the bottom.
- *
- * @param nsIDOMNode outputNode
- * @param nsIDOMNode scrollNode
- * @return boolean
- * True if the output node is scrolled to the bottom, or false
- * otherwise.
- */
- isOutputScrolledToBottom: function (outputNode, scrollNode) {
- let lastNodeHeight = outputNode.lastChild ?
- outputNode.lastChild.clientHeight : 0;
- return scrollNode.scrollTop + scrollNode.clientHeight >=
- scrollNode.scrollHeight - lastNodeHeight / 2;
- },
-
- /**
- * Determine the category of a given nsIScriptError.
- *
- * @param nsIScriptError scriptError
- * The script error you want to determine the category for.
- * @return CATEGORY_JS|CATEGORY_CSS|CATEGORY_SECURITY
- * Depending on the script error CATEGORY_JS, CATEGORY_CSS, or
- * CATEGORY_SECURITY can be returned.
- */
- categoryForScriptError: function (scriptError) {
- let category = scriptError.category;
-
- if (/^(?:CSS|Layout)\b/.test(category)) {
- return CATEGORY_CSS;
- }
-
- switch (category) {
- case "Mixed Content Blocker":
- case "Mixed Content Message":
- case "CSP":
- case "Invalid HSTS Headers":
- case "Invalid HPKP Headers":
- case "SHA-1 Signature":
- case "Insecure Password Field":
- case "SSL":
- case "CORS":
- case "Iframe Sandbox":
- case "Tracking Protection":
- case "Sub-resource Integrity":
- return CATEGORY_SECURITY;
-
- default:
- return CATEGORY_JS;
- }
- },
-
- /**
- * Retrieve the limit of messages for a specific category.
- *
- * @param number category
- * The category of messages you want to retrieve the limit for. See the
- * CATEGORY_* constants.
- * @return number
- * The number of messages allowed for the specific category.
- */
- logLimitForCategory: function (category) {
- let logLimit = DEFAULT_LOG_LIMIT;
-
- try {
- let prefName = CATEGORY_CLASS_FRAGMENTS[category];
- logLimit = Services.prefs.getIntPref("devtools.hud.loglimit." + prefName);
- logLimit = Math.max(logLimit, 1);
- } catch (e) {
- // Ignore any exceptions
- }
-
- return logLimit;
- },
-};
-
-// CommandController
-
-/**
- * A controller (an instance of nsIController) that makes editing actions
- * behave appropriately in the context of the Web Console.
- */
-function CommandController(webConsole) {
- this.owner = webConsole;
-}
-
-CommandController.prototype = {
- /**
- * Selects all the text in the HUD output.
- */
- selectAll: function () {
- this.owner.output.selectAllMessages();
- },
-
- /**
- * Open the URL of the selected message in a new tab.
- */
- openURL: function () {
- this.owner.openSelectedItemInTab();
- },
-
- copyURL: function () {
- this.owner.copySelectedItems({ linkOnly: true, contextmenu: true });
- },
-
- /**
- * Copies the last clicked message.
- */
- copyLastClicked: function () {
- this.owner.copySelectedItems({ linkOnly: false, contextmenu: true });
- },
-
- supportsCommand: function (command) {
- if (!this.owner || !this.owner.output) {
- return false;
- }
- return this.isCommandEnabled(command);
- },
-
- isCommandEnabled: function (command) {
- switch (command) {
- case "consoleCmd_openURL":
- case "consoleCmd_copyURL": {
- // Only enable URL-related actions if node is Net Activity.
- let selectedItem = this.owner.output.getSelectedMessages(1)[0] ||
- this.owner._contextMenuHandler.lastClickedMessage;
- return selectedItem && "url" in selectedItem;
- }
- case "cmd_copy": {
- // Only copy if we right-clicked the console and there's no selected
- // text. With text selected, we want to fall back onto the default
- // copy behavior.
- return this.owner._contextMenuHandler.lastClickedMessage &&
- !this.owner.output.getSelectedMessages(1)[0];
- }
- case "cmd_selectAll":
- return true;
- }
- return false;
- },
-
- doCommand: function (command) {
- switch (command) {
- case "consoleCmd_openURL":
- this.openURL();
- break;
- case "consoleCmd_copyURL":
- this.copyURL();
- break;
- case "cmd_copy":
- this.copyLastClicked();
- break;
- case "cmd_selectAll":
- this.selectAll();
- break;
- }
- }
-};
-
-// Context Menu
-
-/*
- * ConsoleContextMenu this used to handle the visibility of context menu items.
- *
- * @constructor
- * @param object owner
- * The WebConsoleFrame instance that owns this object.
- */
-function ConsoleContextMenu(owner) {
- this.owner = owner;
- this.popup = this.owner.document.getElementById("output-contextmenu");
- this.build = this.build.bind(this);
- this.popup.addEventListener("popupshowing", this.build);
-}
-
-ConsoleContextMenu.prototype = {
- lastClickedMessage: null,
-
- /*
- * Handle to show/hide context menu item.
- */
- build: function (event) {
- let metadata = this.getSelectionMetadata(event.rangeParent);
- for (let element of this.popup.children) {
- element.hidden = this.shouldHideMenuItem(element, metadata);
- }
- },
-
- /*
- * Get selection information from the view.
- *
- * @param nsIDOMElement clickElement
- * The DOM element the user clicked on.
- * @return object
- * Selection metadata.
- */
- getSelectionMetadata: function (clickElement) {
- let metadata = {
- selectionType: "",
- selection: new Set(),
- };
- let selectedItems = this.owner.output.getSelectedMessages();
- if (!selectedItems.length) {
- let clickedItem = this.owner.output.getMessageForElement(clickElement);
- if (clickedItem) {
- this.lastClickedMessage = clickedItem;
- selectedItems = [clickedItem];
- }
- }
-
- metadata.selectionType = selectedItems.length > 1 ? "multiple" : "single";
-
- let selection = metadata.selection;
- for (let item of selectedItems) {
- switch (item.category) {
- case CATEGORY_NETWORK:
- selection.add("network");
- break;
- case CATEGORY_CSS:
- selection.add("css");
- break;
- case CATEGORY_JS:
- selection.add("js");
- break;
- case CATEGORY_WEBDEV:
- selection.add("webdev");
- break;
- case CATEGORY_SERVER:
- selection.add("server");
- break;
- }
- }
-
- return metadata;
- },
-
- /*
- * Determine if an item should be hidden.
- *
- * @param nsIDOMElement menuItem
- * @param object metadata
- * @return boolean
- * Whether the given item should be hidden or not.
- */
- shouldHideMenuItem: function (menuItem, metadata) {
- let selectionType = menuItem.getAttribute("selectiontype");
- if (selectionType && !metadata.selectionType == selectionType) {
- return true;
- }
-
- let selection = menuItem.getAttribute("selection");
- if (!selection) {
- return false;
- }
-
- let shouldHide = true;
- let itemData = selection.split("|");
- for (let type of metadata.selection) {
- // check whether this menu item should show or not.
- if (itemData.includes(type)) {
- shouldHide = false;
- break;
- }
- }
-
- return shouldHide;
- },
-
- /**
- * Destroy the ConsoleContextMenu object instance.
- */
- destroy: function () {
- this.popup.removeEventListener("popupshowing", this.build);
- this.popup = null;
- this.owner = null;
- this.lastClickedMessage = null;
- },
-};
deleted file mode 100644
--- a/devtools/client/webconsole/old/webconsole.xul
+++ /dev/null
@@ -1,215 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this
- - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<!DOCTYPE window [
-<!ENTITY % webConsoleDTD SYSTEM "chrome://devtools/locale/webConsole.dtd">
-%webConsoleDTD;
-<!ENTITY % editMenuDTD SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
-%editMenuDTD;
-]>
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<?xml-stylesheet href="chrome://devtools/skin/widgets.css"
- type="text/css"?>
-<?xml-stylesheet href="chrome://devtools/skin/webconsole.css"
- type="text/css"?>
-<?xml-stylesheet href="chrome://devtools/skin/components-frame.css"
- type="text/css"?>
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- id="devtools-webconsole"
- macanimationtype="document"
- fullscreenbutton="true"
- title="&window.title;"
- windowtype="devtools:webconsole"
- width="900" height="350"
- persist="screenX screenY width height sizemode">
- <script type="application/javascript"
- src="chrome://devtools/content/shared/theme-switching.js"/>
- <script type="application/javascript"
- src="resource://devtools/client/webconsole/main.js"/>
- <script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
- <script type="text/javascript" src="resource://devtools/client/webconsole/old/net/main.js"/>
- <script type="text/javascript"><![CDATA[
-function goUpdateConsoleCommands() {
- goUpdateCommand("consoleCmd_openURL");
- goUpdateCommand("consoleCmd_copyURL");
-}
- // ]]></script>
-
-#include ../../../../toolkit/content/editMenuCommands.inc.xul
-
- <commandset id="consoleCommands"
- commandupdater="true"
- events="focus,select"
- oncommandupdate="goUpdateConsoleCommands();">
- <command id="consoleCmd_openURL"
- oncommand="goDoCommand('consoleCmd_openURL');"/>
- <command id="consoleCmd_copyURL"
- oncommand="goDoCommand('consoleCmd_copyURL');"/>
- </commandset>
- <keyset id="consoleKeys">
- </keyset>
-#include ../../../../toolkit/content/editMenuKeys.inc.xul
-
- <popupset id="mainPopupSet">
- <menupopup id="output-contextmenu" onpopupshowing="goUpdateGlobalEditMenuItems()">
- <menuitem id="menu_openURL" label="&openURL.label;"
- accesskey="&openURL.accesskey;" command="consoleCmd_openURL"
- selection="network" selectionType="single"/>
- <menuitem id="menu_copyURL" label="©URLCmd.label;"
- accesskey="©URLCmd.accesskey;" command="consoleCmd_copyURL"
- selection="network" selectionType="single"/>
- <menuitem id="menu_openInVarView" label="&openInVarViewCmd.label;"
- accesskey="&openInVarViewCmd.accesskey;" disabled="true"/>
- <menuitem id="menu_storeAsGlobal" label="&storeAsGlobalVar.label;"
- accesskey="&storeAsGlobalVar.accesskey;"/>
- <menuitem id="cMenu_copy" label="©Cmd.label;"
- accesskey="©Cmd.accesskey;" command="cmd_copy"/>
- <menuitem id="cMenu_selectAll" label="&selectAllCmd.label;"
- accesskey="&selectAllCmd.accesskey;" command="cmd_selectAll"/>
- </menupopup>
- </popupset>
-
- <tooltip id="aHTMLTooltip" page="true"/>
-
- <box class="hud-outer-wrapper devtools-responsive-container theme-body" flex="1">
- <vbox class="hud-console-wrapper devtools-main-content" flex="1">
- <toolbar class="hud-console-filter-toolbar devtools-toolbar" mode="full">
- <toolbarbutton class="webconsole-clear-console-button devtools-toolbarbutton devtools-clear-icon"
- tooltiptext="&btnClear.tooltip;"
- accesskey="&btnClear.accesskey;"
- tabindex="3"/>
- <hbox class="devtools-toolbarbutton-group">
- <toolbarbutton label="&btnPageNet.label;" type="menu"
- category="net" class="devtools-toolbarbutton webconsole-filter-button"
- tooltiptext="&btnPageNet.tooltip;"
- accesskeyMacOSX="&btnPageNet.accesskeyMacOSX;"
- accesskey="&btnPageNet.accesskey;"
- tabindex="4">
- <menupopup id="net-contextmenu">
- <menuitem label="&btnConsoleErrors;" type="checkbox" autocheck="false"
- prefKey="network"/>
- <menuitem label="&btnConsoleWarnings;" type="checkbox" autocheck="false"
- prefKey="netwarn"/>
- <menuitem label="&btnConsoleXhr;" type="checkbox" autocheck="false"
- prefKey="netxhr"/>
- <menuitem label="&btnConsoleLog;" type="checkbox" autocheck="false"
- prefKey="networkinfo"/>
- </menupopup>
- </toolbarbutton>
- <toolbarbutton label="&btnPageCSS.label;" type="menu"
- category="css" class="devtools-toolbarbutton webconsole-filter-button"
- tooltiptext="&btnPageCSS.tooltip2;"
- accesskey="&btnPageCSS.accesskey;"
- tabindex="5">
- <menupopup id="css-contextmenu">
- <menuitem label="&btnConsoleErrors;" type="checkbox" autocheck="false"
- prefKey="csserror"/>
- <menuitem label="&btnConsoleWarnings;" type="checkbox"
- autocheck="false" prefKey="cssparser"/>
- <menuitem label="&btnConsoleReflows;" type="checkbox"
- autocheck="false" prefKey="csslog"/>
- </menupopup>
- </toolbarbutton>
- <toolbarbutton label="&btnPageJS.label;" type="menu"
- category="js" class="devtools-toolbarbutton webconsole-filter-button"
- tooltiptext="&btnPageJS.tooltip;"
- accesskey="&btnPageJS.accesskey;"
- tabindex="6">
- <menupopup id="js-contextmenu">
- <menuitem label="&btnConsoleErrors;" type="checkbox"
- autocheck="false" prefKey="exception"/>
- <menuitem label="&btnConsoleWarnings;" type="checkbox"
- autocheck="false" prefKey="jswarn"/>
- <menuitem label="&btnConsoleLog;" type="checkbox"
- autocheck="false" prefKey="jslog"/>
- </menupopup>
- </toolbarbutton>
- <toolbarbutton label="&btnPageSecurity.label;" type="menu"
- category="security" class="devtools-toolbarbutton webconsole-filter-button"
- tooltiptext="&btnPageSecurity.tooltip;"
- accesskey="&btnPageSecurity.accesskey;"
- tabindex="7">
- <menupopup id="security-contextmenu">
- <menuitem label="&btnConsoleErrors;" type="checkbox"
- autocheck="false" prefKey="secerror"/>
- <menuitem label="&btnConsoleWarnings;" type="checkbox"
- autocheck="false" prefKey="secwarn"/>
- </menupopup>
- </toolbarbutton>
- <toolbarbutton label="&btnPageLogging.label;" type="menu"
- category="logging" class="devtools-toolbarbutton webconsole-filter-button"
- tooltiptext="&btnPageLogging.tooltip;"
- accesskey="&btnPageLogging.accesskey3;"
- tabindex="8">
- <menupopup id="logging-contextmenu">
- <menuitem label="&btnConsoleErrors;" type="checkbox"
- autocheck="false" prefKey="error"/>
- <menuitem label="&btnConsoleWarnings;" type="checkbox"
- autocheck="false" prefKey="warn"/>
- <menuitem label="&btnConsoleInfo;" type="checkbox" autocheck="false"
- prefKey="info"/>
- <menuitem label="&btnConsoleLog;" type="checkbox" autocheck="false"
- prefKey="log"/>
- <menuseparator />
- <menuitem label="&btnConsoleSharedWorkers;" type="checkbox"
- autocheck="false" prefKey="sharedworkers"/>
- <menuitem label="&btnConsoleServiceWorkers;" type="checkbox"
- autocheck="false" prefKey="serviceworkers"/>
- <menuitem label="&btnConsoleWindowlessWorkers;" type="checkbox"
- autocheck="false" prefKey="windowlessworkers"/>
- </menupopup>
- </toolbarbutton>
- <toolbarbutton label="&btnServerLogging.label;" type="menu"
- category="server" class="devtools-toolbarbutton webconsole-filter-button"
- tooltiptext="&btnServerLogging.tooltip;"
- accesskey="&btnServerLogging.accesskey;"
- tabindex="9">
- <menupopup id="server-logging-contextmenu">
- <menuitem label="&btnServerErrors;" type="checkbox"
- autocheck="false" prefKey="servererror"/>
- <menuitem label="&btnServerWarnings;" type="checkbox"
- autocheck="false" prefKey="serverwarn"/>
- <menuitem label="&btnServerInfo;" type="checkbox" autocheck="false"
- prefKey="serverinfo"/>
- <menuitem label="&btnServerLog;" type="checkbox" autocheck="false"
- prefKey="serverlog"/>
- </menupopup>
- </toolbarbutton>
- </hbox>
-
- <spacer flex="1"/>
-
- <textbox class="compact hud-filter-box devtools-filterinput" type="search"
- placeholder="&filterOutput.placeholder;" tabindex="2"/>
- </toolbar>
-
- <hbox id="output-wrapper" flex="1" context="output-contextmenu" tooltip="aHTMLTooltip">
- <!-- Wrapper element to make scrolling in output-container much faster.
- See Bug 1237368 -->
- <div xmlns="http://www.w3.org/1999/xhtml">
- <div xmlns="http://www.w3.org/1999/xhtml" id="output-container"
- tabindex="0" role="document" aria-live="polite" />
- </div>
- </hbox>
- <notificationbox id="webconsole-notificationbox">
- <hbox class="jsterm-input-container" style="direction:ltr">
- <stack class="jsterm-stack-node" flex="1">
- <textbox class="jsterm-complete-node devtools-monospace"
- multiline="true" rows="1" tabindex="-1"/>
- <textbox class="jsterm-input-node devtools-monospace"
- multiline="true" rows="1" tabindex="0"
- aria-autocomplete="list"/>
- </stack>
- </hbox>
- </notificationbox>
- </vbox>
-
- <splitter class="devtools-side-splitter"/>
-
- <tabbox id="webconsole-sidebar" class="devtools-sidebar-tabs" hidden="true" width="300">
- <tabs/>
- <tabpanels flex="1"/>
- </tabbox>
- </box>
-</window>
--- a/devtools/client/webconsole/test/fixtures/stub-generators/head.js
+++ b/devtools/client/webconsole/test/fixtures/stub-generators/head.js
@@ -9,20 +9,16 @@
"use strict";
// shared-head.js handles imports, constants, and utility functions
// Load the shared-head file first.
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
this);
-Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", true);
-registerCleanupFunction(() => {
- Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
-});
const { PREFS } = require("devtools/client/webconsole/constants");
const { prepareMessage } = require("devtools/client/webconsole/utils/messages");
const { stubPackets } = require("devtools/client/webconsole/test/fixtures/stubs/index.js");
const {
consoleApi,
cssMessage,
evaluationResult,
--- a/devtools/client/webconsole/test/mochitest/head.js
+++ b/devtools/client/webconsole/test/mochitest/head.js
@@ -29,19 +29,17 @@ const DOCS_GA_PARAMS = `?${new URLSearch
const STATUS_CODES_GA_PARAMS = `?${new URLSearchParams({
"utm_source": "mozilla",
"utm_medium": "devtools-webconsole",
"utm_campaign": "default"
})}`;
const wcActions = require("devtools/client/webconsole/actions/index");
-Services.prefs.setBoolPref("devtools.browserconsole.new-frontend-enabled", true);
registerCleanupFunction(async function() {
- Services.prefs.clearUserPref("devtools.browserconsole.new-frontend-enabled");
Services.prefs.clearUserPref("devtools.webconsole.ui.filterbar");
// Reset all filter prefs between tests. First flushPrefEnv in case one of the
// filter prefs has been pushed for the test
await SpecialPowers.flushPrefEnv();
Services.prefs.getChildList("devtools.webconsole.filter").forEach(pref => {
Services.prefs.clearUserPref(pref);
});