Attachment #8740502: bug659625.part2.v3.patch for bug #659625

View | Details | Raw Unified | Return to bug 659625
Collapse All | Expand All

(-)a/devtools/client/locales/en-US/webconsole.properties (+5 lines)
Line     Link Here 
 Lines 102-117   stacktrace.asyncStack=(Async: %S) Link Here 
102
# of the console.time() call. Parameters: %S is the name of the timer.
102
# of the console.time() call. Parameters: %S is the name of the timer.
103
timerStarted=%S: timer started
103
timerStarted=%S: timer started
104
104
105
# LOCALIZATION NOTE (timeEnd): this string is used to display the result of
105
# LOCALIZATION NOTE (timeEnd): this string is used to display the result of
106
# the console.timeEnd() call. Parameters: %1$S is the name of the timer, %2$S
106
# the console.timeEnd() call. Parameters: %1$S is the name of the timer, %2$S
107
# is the number of milliseconds.
107
# is the number of milliseconds.
108
timeEnd=%1$S: %2$Sms
108
timeEnd=%1$S: %2$Sms
109
109
110
# LOCALIZATION NOTE (consoleCleared): this string is displayed when receiving a
111
# call to console.clear() to let the user know the previous messages of the
112
# console have been removed programmatically.
113
consoleCleared=Console was cleared.
114
110
# LOCALIZATION NOTE (noCounterLabel): this string is used to display
115
# LOCALIZATION NOTE (noCounterLabel): this string is used to display
111
# count-messages with no label provided.
116
# count-messages with no label provided.
112
noCounterLabel=<no label>
117
noCounterLabel=<no label>
113
118
114
# LOCALIZATION NOTE (Autocomplete.blank): this string is used when inputnode
119
# LOCALIZATION NOTE (Autocomplete.blank): this string is used when inputnode
115
# string containing anchor doesn't matches to any property in the content.
120
# string containing anchor doesn't matches to any property in the content.
116
Autocomplete.blank=  <- no result
121
Autocomplete.blank=  <- no result
117
122
(-)a/devtools/client/webconsole/console-output.js (+1 lines)
Line     Link Here 
 Lines 88-103   const COMPAT = { Link Here 
88
// A map from the console API call levels to the Web Console severities.
88
// A map from the console API call levels to the Web Console severities.
89
const CONSOLE_API_LEVELS_TO_SEVERITIES = {
89
const CONSOLE_API_LEVELS_TO_SEVERITIES = {
90
  error: "error",
90
  error: "error",
91
  exception: "error",
91
  exception: "error",
92
  assert: "error",
92
  assert: "error",
93
  warn: "warning",
93
  warn: "warning",
94
  info: "info",
94
  info: "info",
95
  log: "log",
95
  log: "log",
96
  clear: "log",
96
  trace: "log",
97
  trace: "log",
97
  table: "log",
98
  table: "log",
98
  debug: "log",
99
  debug: "log",
99
  dir: "log",
100
  dir: "log",
100
  dirxml: "log",
101
  dirxml: "log",
101
  group: "log",
102
  group: "log",
102
  groupCollapsed: "log",
103
  groupCollapsed: "log",
103
  groupEnd: "log",
104
  groupEnd: "log",
(-)a/devtools/client/webconsole/test/browser.ini (+2 lines)
Line     Link Here 
 Lines 64-79   support-files = Link Here 
64
  test-bug-782653-css-errors.html
64
  test-bug-782653-css-errors.html
65
  test-bug-837351-security-errors.html
65
  test-bug-837351-security-errors.html
66
  test-bug-859170-longstring-hang.html
66
  test-bug-859170-longstring-hang.html
67
  test-bug-869003-iframe.html
67
  test-bug-869003-iframe.html
68
  test-bug-869003-top-window.html
68
  test-bug-869003-top-window.html
69
  test-closure-optimized-out.html
69
  test-closure-optimized-out.html
70
  test-closures.html
70
  test-closures.html
71
  test-console-assert.html
71
  test-console-assert.html
72
  test-console-clear.html
72
  test-console-count.html
73
  test-console-count.html
73
  test-console-count-external-file.js
74
  test-console-count-external-file.js
74
  test-console-extras.html
75
  test-console-extras.html
75
  test-console-replaced-api.html
76
  test-console-replaced-api.html
76
  test-console-server-logging.sjs
77
  test-console-server-logging.sjs
77
  test-console-server-logging-array.sjs
78
  test-console-server-logging-array.sjs
78
  test-console.html
79
  test-console.html
79
  test-console-workers.html
80
  test-console-workers.html
 Lines 152-167   skip-if = (e10s && debug) || (e10s && os Link Here 
152
skip-if = (e10s && (os == 'win' || os == 'mac')) # Bug 1243976
153
skip-if = (e10s && (os == 'win' || os == 'mac')) # Bug 1243976
153
[browser_bug_865288_repeat_different_objects.js]
154
[browser_bug_865288_repeat_different_objects.js]
154
[browser_bug_865871_variables_view_close_on_esc_key.js]
155
[browser_bug_865871_variables_view_close_on_esc_key.js]
155
[browser_bug_869003_inspect_cross_domain_object.js]
156
[browser_bug_869003_inspect_cross_domain_object.js]
156
[browser_bug_871156_ctrlw_close_tab.js]
157
[browser_bug_871156_ctrlw_close_tab.js]
157
[browser_cached_messages.js]
158
[browser_cached_messages.js]
158
[browser_console.js]
159
[browser_console.js]
159
[browser_console_addonsdk_loader_exception.js]
160
[browser_console_addonsdk_loader_exception.js]
161
[browser_console_clear_method.js]
160
[browser_console_clear_on_reload.js]
162
[browser_console_clear_on_reload.js]
161
[browser_console_click_focus.js]
163
[browser_console_click_focus.js]
162
[browser_console_consolejsm_output.js]
164
[browser_console_consolejsm_output.js]
163
[browser_console_copy_command.js]
165
[browser_console_copy_command.js]
164
[browser_console_dead_objects.js]
166
[browser_console_dead_objects.js]
165
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
167
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
166
[browser_console_copy_entire_message_context_menu.js]
168
[browser_console_copy_entire_message_context_menu.js]
167
[browser_console_error_source_click.js]
169
[browser_console_error_source_click.js]
(-)a/devtools/client/webconsole/test/browser_console_clear_method.js (+131 lines)
Line     Link Here 
Line 0    Link Here 
1
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
3
/* Any copyright is dedicated to the Public Domain.
4
 * http://creativecommons.org/publicdomain/zero/1.0/ */
5
6
// Check that calls to console.clear from a script delete the messages
7
// previously logged.
8
9
"use strict";
10
11
add_task(function* () {
12
  const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
13
                   "test/test-console-clear.html";
14
15
  yield loadTab(TEST_URI);
16
  let hud = yield openConsole();
17
  ok(hud, "Web Console opened");
18
19
  info("Check the console.clear() done on page load has been processed.");
20
  yield waitForLog("Console was cleared", hud);
21
  ok(hud.outputNode.textContent.includes("Console was cleared"),
22
    "console.clear() message is displayed");
23
  ok(!hud.outputNode.textContent.includes("log1"), "log1 not displayed");
24
  ok(!hud.outputNode.textContent.includes("log2"), "log2 not displayed");
25
26
  info("Logging two messages log3, log4");
27
  ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
28
    content.wrappedJSObject.console.log("log3");
29
    content.wrappedJSObject.console.log("log4");
30
  });
31
32
  yield waitForLog("log3", hud);
33
  yield waitForLog("log4", hud);
34
35
  ok(hud.outputNode.textContent.includes("Console was cleared"),
36
    "console.clear() message is still displayed");
37
  ok(hud.outputNode.textContent.includes("log3"), "log3 is displayed");
38
  ok(hud.outputNode.textContent.includes("log4"), "log4 is displayed");
39
40
  info("Open the variables view sidebar for 'objFromPage'");
41
  yield openSidebar("objFromPage", { a: 1 }, hud);
42
  let sidebarClosed = hud.jsterm.once("sidebar-closed");
43
44
  info("Call console.clear from the page");
45
  ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
46
    content.wrappedJSObject.console.clear();
47
  });
48
49
  // Cannot wait for "Console was cleared" here because such a message is
50
  // already present and would yield immediately.
51
  info("Wait for variables view sidebar to be closed after console.clear()");
52
  yield sidebarClosed;
53
54
  ok(!hud.outputNode.textContent.includes("log3"), "log3 not displayed");
55
  ok(!hud.outputNode.textContent.includes("log4"), "log4 not displayed");
56
  ok(hud.outputNode.textContent.includes("Console was cleared"),
57
    "console.clear() message is still displayed");
58
  is(hud.outputNode.textContent.split("Console was cleared"), 2,
59
    "console.clear() message is only displayed once");
60
61
  info("Logging one messages log5");
62
  ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
63
    content.wrappedJSObject.console.log("log5");
64
  });
65
  yield waitForLog("log5", hud);
66
67
  info("Close and reopen the webconsole.");
68
  yield closeConsole(gBrowser.selectedTab);
69
  hud = yield openConsole();
70
  yield waitForLog("Console was cleared", hud);
71
72
  ok(hud.outputNode.textContent.includes("Console was cleared"),
73
    "console.clear() message is still displayed");
74
  ok(!hud.outputNode.textContent.includes("log1"), "log1 not displayed");
75
  ok(!hud.outputNode.textContent.includes("log2"), "log1 not displayed");
76
  ok(!hud.outputNode.textContent.includes("log3"), "log3 not displayed");
77
  ok(!hud.outputNode.textContent.includes("log4"), "log4 not displayed");
78
  ok(hud.outputNode.textContent.includes("log5"), "log5 still displayed");
79
});
80
81
/**
82
 * Wait for a single message to be logged in the provided webconsole instance
83
 * with the category CATEGORY_WEBDEV and the SEVERITY_LOG severity.
84
 *
85
 * @param {String} message
86
 *        The expected messaged.
87
 * @param {WebConsole} webconsole
88
 *        WebConsole instance in which the message should be logged.
89
 */
90
function* waitForLog(message, webconsole, options) {
91
  yield waitForMessages({
92
    webconsole: webconsole,
93
    messages: [{
94
      text: message,
95
      category: CATEGORY_WEBDEV,
96
      severity: SEVERITY_LOG,
97
    }],
98
  });
99
}
100
101
/**
102
 * Open the variables view sidebar for the object with the provided name objName
103
 * and wait for the expected object is displayed in the variables view.
104
 *
105
 * @param {String} objName
106
 *        The name of the object to open in the sidebar.
107
 * @param {Object} expectedObj
108
 *        The properties that should be displayed in the variables view.
109
 * @param {WebConsole} webconsole
110
 *        WebConsole instance in which the message should be logged.
111
 *
112
 */
113
function* openSidebar(objName, expectedObj, webconsole) {
114
  let msg = yield webconsole.jsterm.execute(objName);
115
  ok(msg, "output message found");
116
117
  let anchor = msg.querySelector("a");
118
  let body = msg.querySelector(".message-body");
119
  ok(anchor, "object anchor");
120
  ok(body, "message body");
121
122
  yield EventUtils.synthesizeMouse(anchor, 2, 2, {}, webconsole.iframeWindow);
123
124
  let vviewVar = yield webconsole.jsterm.once("variablesview-fetched");
125
  let vview = vviewVar._variablesView;
126
  ok(vview, "variables view object exists");
127
128
  yield findVariableViewProperties(vviewVar, [
129
    expectedObj,
130
  ], { webconsole: webconsole });
131
}
(-)a/devtools/client/webconsole/test/test-console-clear.html (+16 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE HTML>
2
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
3
    <meta charset="utf-8">
4
    <title>Console.clear() tests</title>
5
    <script type="text/javascript">
6
      console.log("log1");
7
      console.log("log2");
8
      console.clear();
9
10
      window.objFromPage = { a: 1 };
11
    </script>
12
  </head>
13
  <body>
14
    <h1 id="header">Clear Demo</h1>
15
  </body>
16
</html>
(-)a/devtools/client/webconsole/webconsole.js (+14 lines)
Line     Link Here 
 Lines 137-152   const MESSAGE_PREFERENCE_KEYS = [ Link Here 
137
// severities.
137
// severities.
138
const LEVELS = {
138
const LEVELS = {
139
  error: SEVERITY_ERROR,
139
  error: SEVERITY_ERROR,
140
  exception: SEVERITY_ERROR,
140
  exception: SEVERITY_ERROR,
141
  assert: SEVERITY_ERROR,
141
  assert: SEVERITY_ERROR,
142
  warn: SEVERITY_WARNING,
142
  warn: SEVERITY_WARNING,
143
  info: SEVERITY_INFO,
143
  info: SEVERITY_INFO,
144
  log: SEVERITY_LOG,
144
  log: SEVERITY_LOG,
145
  clear: SEVERITY_LOG,
145
  trace: SEVERITY_LOG,
146
  trace: SEVERITY_LOG,
146
  table: SEVERITY_LOG,
147
  table: SEVERITY_LOG,
147
  debug: SEVERITY_LOG,
148
  debug: SEVERITY_LOG,
148
  dir: SEVERITY_LOG,
149
  dir: SEVERITY_LOG,
149
  dirxml: SEVERITY_LOG,
150
  dirxml: SEVERITY_LOG,
150
  group: SEVERITY_LOG,
151
  group: SEVERITY_LOG,
151
  groupCollapsed: SEVERITY_LOG,
152
  groupCollapsed: SEVERITY_LOG,
152
  groupEnd: SEVERITY_LOG,
153
  groupEnd: SEVERITY_LOG,
 Lines 1280-1295   WebConsoleFrame.prototype = { Link Here 
1280
        node = msg.init(this.output).render().element;
1281
        node = msg.init(this.output).render().element;
1281
        break;
1282
        break;
1282
      }
1283
      }
1283
      case "trace": {
1284
      case "trace": {
1284
        let msg = new Messages.ConsoleTrace(message);
1285
        let msg = new Messages.ConsoleTrace(message);
1285
        node = msg.init(this.output).render().element;
1286
        node = msg.init(this.output).render().element;
1286
        break;
1287
        break;
1287
      }
1288
      }
1289
      case "clear": {
1290
        body = l10n.getStr("consoleCleared");
1291
        clipboardText = body;
1292
        break;
1293
      }
1288
      case "dir": {
1294
      case "dir": {
1289
        body = { arguments: args };
1295
        body = { arguments: args };
1290
        let clipboardArray = [];
1296
        let clipboardArray = [];
1291
        args.forEach((value) => {
1297
        args.forEach((value) => {
1292
          clipboardArray.push(VariablesView.getString(value));
1298
          clipboardArray.push(VariablesView.getString(value));
1293
        });
1299
        });
1294
        clipboardText = clipboardArray.join(" ");
1300
        clipboardText = clipboardArray.join(" ");
1295
        break;
1301
        break;
 Lines 2198-2213   WebConsoleFrame.prototype = { Link Here 
2198
    if (!node) {
2204
    if (!node) {
2199
      return null;
2205
      return null;
2200
    }
2206
    }
2201
2207
2202
    let isFiltered = this.filterMessageNode(node);
2208
    let isFiltered = this.filterMessageNode(node);
2203
2209
2204
    let isRepeated = this._filterRepeatedMessage(node);
2210
    let isRepeated = this._filterRepeatedMessage(node);
2205
2211
2212
    // If a clear message is processed while the webconsole is opened, the UI
2213
    // should be cleared.
2214
    if (message && message.level == "clear") {
2215
      // Do not clear the consoleStorage here as it has been cleared already
2216
      // by the clear method, only clear the UI.
2217
      this.jsterm.clearOutput(false);
2218
    }
2219
2206
    let visible = !isRepeated && !isFiltered;
2220
    let visible = !isRepeated && !isFiltered;
2207
    if (!isRepeated) {
2221
    if (!isRepeated) {
2208
      this.outputNode.appendChild(node);
2222
      this.outputNode.appendChild(node);
2209
      this._pruneCategoriesQueue[node.category] = true;
2223
      this._pruneCategoriesQueue[node.category] = true;
2210
2224
2211
      let nodeID = node.getAttribute("id");
2225
      let nodeID = node.getAttribute("id");
2212
      Services.obs.notifyObservers(hudIdSupportsString,
2226
      Services.obs.notifyObservers(hudIdSupportsString,
2213
                                   "web-console-message-created", nodeID);
2227
                                   "web-console-message-created", nodeID);

Return to bug 659625