Bug 1141222 - Test Cu.reportError stack in browser console. r=vporof
--- a/devtools/client/webconsole/test/browser.ini
+++ b/devtools/client/webconsole/test/browser.ini
@@ -83,16 +83,17 @@ support-files =
test-console-output-04.html
test-console-output-dom-elements.html
test-console-output-events.html
test-console-output-regexp.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
--- a/devtools/client/webconsole/test/browser_console.js
+++ b/devtools/client/webconsole/test/browser_console.js
@@ -4,16 +4,18 @@
* 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/" +
"test/test-console.html?" + Date.now();
+const TEST_FILE = "chrome://mochitests/content/browser/devtools/client/" +
+ "webconsole/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/" +
"test/test-image.png";
"use strict";
@@ -39,16 +41,20 @@ function consoleOpened(hud) {
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);
+
// Add a message from a content window.
content.console.log("bug587757b");
// Test eval.
hud.jsterm.execute("document.location.href");
// Check for network requests.
let xhr = new XMLHttpRequest();
@@ -72,16 +78,33 @@ function consoleOpened(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: "content window console.log() is displayed",
text: "bug587757b",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "jsterm eval result",
text: "browser.xul",
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/test/test-cu-reporterror.js
@@ -0,0 +1,4 @@
+function a() {
+ Components.utils.reportError("bug1141222");
+}
+a();