From 4c8951359a9da5e4f2f722a5fb6f066bfeaa79d1 Mon Sep 17 00:00:00 2001 From: Dorel Luca Date: Sat, 9 May 2020 20:08:21 +0300 Subject: [PATCH] Backed out changeset d7df79387af7 (bug 1595046) for Talos tests failures in webconsole/complicated.js. CLOSED TREE --- .../packages/devtools-reps/src/reps/error.js | 22 +- .../reps/tests/__snapshots__/error.js.snap | 157 +-- .../devtools-reps/src/reps/tests/error.js | 4 +- devtools/client/fronts/webconsole.js | 25 +- .../client/shared/components/reps/reps.js | 27 +- .../Output/message-types/EvaluationResult.js | 32 +- .../Output/message-types/PageError.js | 36 +- .../webconsole/test/browser/_webconsole.ini | 3 +- .../test/browser/browser_console.js | 5 +- .../browser/browser_jsterm_await_error.js | 85 +- .../browser/browser_webconsole_async_stack.js | 17 +- ...onsole_context_menu_copy_entire_message.js | 9 +- ...sole_context_menu_export_console_output.js | 4 +- .../browser/browser_webconsole_eval_error.js | 81 +- .../browser_webconsole_eval_sources.js | 36 +- ...browser_webconsole_primitive_stacktrace.js | 19 + ...wser_webconsole_promise_rejected_object.js | 73 +- ...wser_webconsole_stubs_evaluation_result.js | 17 - .../browser_webconsole_stubs_page_error.js | 53 - .../browser_webconsole_uncaught_exception.js | 88 -- .../client/webconsole/test/browser/head.js | 25 +- .../test/browser/stub-generator-helpers.js | 73 +- .../browser/test-primitive-stacktrace.html | 22 + .../node/components/evaluation-result.test.js | 81 +- .../test/node/components/page-error.test.js | 160 +-- .../node/fixtures/stubs/evaluationResult.js | 307 ----- .../test/node/fixtures/stubs/pageError.js | 1000 +---------------- .../webconsole/test/node/mocha-test-setup.js | 3 +- devtools/client/webconsole/types.js | 1 - devtools/client/webconsole/utils/messages.js | 23 +- .../webconsole/utils/object-inspector.js | 1 - devtools/server/actors/webconsole.js | 18 +- devtools/shared/specs/webconsole.js | 1 - 33 files changed, 195 insertions(+), 2313 deletions(-) create mode 100644 devtools/client/webconsole/test/browser/browser_webconsole_primitive_stacktrace.js delete mode 100644 devtools/client/webconsole/test/browser/browser_webconsole_uncaught_exception.js create mode 100644 devtools/client/webconsole/test/browser/test-primitive-stacktrace.html diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/error.js b/devtools/client/debugger/packages/devtools-reps/src/reps/error.js index fec78de8779e..e9d644a31b19 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/error.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/error.js @@ -66,28 +66,18 @@ function ErrorRep(props) { name = "Error"; } - const errorTitle = mode === MODE.TINY ? name : `${name}: `; const content = []; - if (customFormat) { - content.push(errorTitle); + if (!customFormat) { + content.push(span({ className: "objectTitle" }, name)); + } else if (typeof preview.message !== "string") { + content.push(name); } else { - content.push(span({ className: "objectTitle", key: "title" }, errorTitle)); + content.push(`${name}: "${preview.message}"`); } - if (mode !== MODE.TINY) { - const { Rep } = require("./rep"); - content.push( - Rep({ - ...props, - key: "message", - object: preview.message, - mode: props.mode || MODE.TINY, - useQuotes: false, - }) - ); - } const renderStack = preview.stack && customFormat; + if (renderStack) { const stacktrace = props.renderStacktrace ? props.renderStacktrace(parseStackString(preview.stack)) diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/__snapshots__/error.js.snap b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/__snapshots__/error.js.snap index 2e63e6292352..4e880bb13d37 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/__snapshots__/error.js.snap +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/__snapshots__/error.js.snap @@ -5,12 +5,7 @@ exports[`Error - Error with V8-like stack renders with expected text 1`] = ` className="objectBox-stackTrace reps-custom-format" data-link-actor-id="server1.conn1.child1/obj1020" > - Error: - - BOOM - + Error: "BOOM" - Error: - - bad stack - + Error: "bad stack" - Error: - - undefined - + Error Error @@ -107,12 +91,7 @@ exports[`Error - Error with undefined-grip name renders with expected text 1`] = className="objectBox-stackTrace reps-custom-format" data-link-actor-id="server0.conn0.child1/obj88" > - Error: - - too much recursion - + Error: "too much recursion" Error @@ -156,12 +134,7 @@ exports[`Error - Error with undefined-grip stack renders with expected text 1`] className="objectBox-stackTrace reps-custom-format" data-link-actor-id="server0.conn0.child1/obj88" > - InternalError: - - too much recursion - + InternalError: "too much recursion" - EvalError: - - EvalError message - + EvalError: "EvalError message" - InternalError: - - InternalError message - + InternalError: "InternalError message" - Error: - - bar - + Error: "bar" - RangeError: - - RangeError message - + RangeError: "RangeError message" - ReferenceError: - - ReferenceError message - + ReferenceError: "ReferenceError message" - Error: - - bar - + Error: "bar" - Error: - - - bar + Error `; @@ -469,14 +406,8 @@ exports[`Error - Simple error renders with error type only when depth is > 0 1`] > - Error: - - - bar + Error `; @@ -486,12 +417,7 @@ exports[`Error - Simple error renders with expected text for simple error 1`] = className="objectBox-stackTrace reps-custom-format" data-link-actor-id="server1.conn1.child1/obj1020" > - Error: - - Error message - + Error: "Error message" - SyntaxError: - - SyntaxError message - + SyntaxError: "SyntaxError message" - TypeError: - - TypeError message - + TypeError: "TypeError message" - URIError: - - URIError message - + URIError: "URIError message" Error @@ -640,12 +550,7 @@ exports[`Error - base-loader.js renders as expected without mode 1`] = ` className="objectBox-stackTrace reps-custom-format" data-link-actor-id="server1.conn1.child1/obj1020" > - Error: - - Error message - + Error: "Error message" - InternalError: - - too much recursion - + InternalError: "too much recursion" - Error: - + Error: "" - Error: - - bar - + Error: "bar"
  • @@ -1063,12 +955,7 @@ exports[`Error - renderStacktrace prop uses renderStacktrace with longString err className="objectBox-stackTrace reps-custom-format" data-link-actor-id="server1.conn1.child1/obj33" > - InternalError: - - too much recursion - + InternalError: "too much recursion"
  • diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/error.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/error.js index 9200ecceb2e3..f966ad58eb58 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/error.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/error.js @@ -135,7 +135,7 @@ describe("Error - Error without stacktrace", () => { }) ); - expect(renderedComponent.text()).toEqual("Error: Error message"); + expect(renderedComponent.text()).toEqual('Error: "Error message"'); }); it("renders expected text for error without stacktrace in tiny mode", () => { @@ -383,7 +383,7 @@ describe("Error - DOMException", () => { ); expect(renderedComponent.text()).toEqual( - "DOMException: 'foo;()bar!' is not a valid selector" + "DOMException: \"'foo;()bar!' is not a valid selector\"" ); }); diff --git a/devtools/client/fronts/webconsole.js b/devtools/client/fronts/webconsole.js index b414bf9b0757..07335d275841 100644 --- a/devtools/client/fronts/webconsole.js +++ b/devtools/client/fronts/webconsole.js @@ -290,13 +290,6 @@ class WebConsoleFront extends FrontClassWithSpec(webconsoleSpec) { this ); } - - if (packet?.pageError?.exception) { - packet.pageError.exception = getAdHocFrontOrPrimitiveGrip( - packet.pageError.exception, - this - ); - } return packet; } @@ -304,20 +297,14 @@ class WebConsoleFront extends FrontClassWithSpec(webconsoleSpec) { const response = await super.getCachedMessages(messageTypes); if (Array.isArray(response.messages)) { response.messages = response.messages.map(message => { - if (Array.isArray(message?.arguments)) { - // We might need to create fronts for each of the message arguments. - message.arguments = message.arguments.map(arg => - getAdHocFrontOrPrimitiveGrip(arg, this) - ); - } - - if (message?.exception) { - message.exception = getAdHocFrontOrPrimitiveGrip( - message.exception, - this - ); + if (!message || !Array.isArray(message.arguments)) { + return message; } + // We might need to create fronts for each of the message arguments. + message.arguments = message.arguments.map(arg => + getAdHocFrontOrPrimitiveGrip(arg, this) + ); return message; }); } diff --git a/devtools/client/shared/components/reps/reps.js b/devtools/client/shared/components/reps/reps.js index e504fc3def67..455bc5ce951c 100644 --- a/devtools/client/shared/components/reps/reps.js +++ b/devtools/client/shared/components/reps/reps.js @@ -3142,29 +3142,16 @@ function ErrorRep(props) { name = "Error"; } - const errorTitle = mode === MODE.TINY ? name : `${name}: `; const content = []; - if (customFormat) { - content.push(errorTitle); - } else { + if (!customFormat) { content.push(span({ - className: "objectTitle", - key: "title" - }, errorTitle)); - } - - if (mode !== MODE.TINY) { - const { - Rep - } = __webpack_require__(24); - - content.push(Rep({ ...props, - key: "message", - object: preview.message, - mode: props.mode || MODE.TINY, - useQuotes: false - })); + className: "objectTitle" + }, name)); + } else if (typeof preview.message !== "string") { + content.push(name); + } else { + content.push(`${name}: "${preview.message}"`); } const renderStack = preview.stack && customFormat; diff --git a/devtools/client/webconsole/components/Output/message-types/EvaluationResult.js b/devtools/client/webconsole/components/Output/message-types/EvaluationResult.js index 1d6e6d27d4a8..fd128b269b36 100644 --- a/devtools/client/webconsole/components/Output/message-types/EvaluationResult.js +++ b/devtools/client/webconsole/components/Output/message-types/EvaluationResult.js @@ -44,7 +44,6 @@ function EvaluationResult(props) { level, id: messageId, indent, - hasException, exceptionDocURL, stacktrace, frame, @@ -70,25 +69,18 @@ function EvaluationResult(props) { messageBody = `${messageText.initial}…`; } } else { - messageBody = []; - if (hasException) { - messageBody.push("Uncaught "); - } - messageBody.push( - GripMessageBody({ - dispatch, - messageId, - grip: parameters[0], - key: "grip", - serviceContainer, - useQuotes: !hasException, - escapeWhitespace: false, - type, - helperType, - maybeScrollToBottom, - customFormat: true, - }) - ); + messageBody = GripMessageBody({ + dispatch, + messageId, + grip: parameters[0], + serviceContainer, + useQuotes: true, + escapeWhitespace: false, + type, + helperType, + maybeScrollToBottom, + customFormat: true, + }); } const topLevelClasses = ["cm-s-mozilla"]; diff --git a/devtools/client/webconsole/components/Output/message-types/PageError.js b/devtools/client/webconsole/components/Output/message-types/PageError.js index 08950749f2ae..9fc8a060a393 100644 --- a/devtools/client/webconsole/components/Output/message-types/PageError.js +++ b/devtools/client/webconsole/components/Output/message-types/PageError.js @@ -10,7 +10,7 @@ const PropTypes = require("devtools/client/shared/vendor/react-prop-types"); const Message = createFactory( require("devtools/client/webconsole/components/Output/Message") ); -const GripMessageBody = require("devtools/client/webconsole/components/Output/GripMessageBody"); + loader.lazyGetter(this, "REPS", function() { return require("devtools/client/shared/components/reps/reps").REPS; }); @@ -55,40 +55,16 @@ function PageError(props) { exceptionDocURL, timeStamp, notes, - parameters, - hasException, } = message; - const messageBody = []; - - const repsProps = { + const messageBody = REPS.StringRep.rep({ + object: messageText, + mode: MODE.LONG, useQuotes: false, escapeWhitespace: false, + urlCropLimit: 120, openLink: serviceContainer.openLink, - }; - - if (hasException) { - messageBody.push( - "Uncaught ", - GripMessageBody({ - dispatch, - messageId, - grip: parameters[0], - serviceContainer, - type, - customFormat: true, - ...repsProps, - }) - ); - } else { - messageBody.push( - REPS.StringRep.rep({ - object: messageText, - mode: MODE.LONG, - ...repsProps, - }) - ); - } + }); return Message({ dispatch, diff --git a/devtools/client/webconsole/test/browser/_webconsole.ini b/devtools/client/webconsole/test/browser/_webconsole.ini index dfc2de30201e..37853083b36a 100644 --- a/devtools/client/webconsole/test/browser/_webconsole.ini +++ b/devtools/client/webconsole/test/browser/_webconsole.ini @@ -136,6 +136,7 @@ support-files = test-non-javascript-mime.js test-non-javascript-mime.js^headers^ test-non-javascript-mime-worker.html + test-primitive-stacktrace.html test-reopen-closed-tab.html test-same-origin-required-load.html test-sourcemap-error-01.html @@ -312,6 +313,7 @@ skip-if = (os == "linux" && fission && !ccov) || (os == "win" && fission) #Bug 1 [browser_webconsole_output_order.js] [browser_webconsole_output_trimmed.js] [browser_webconsole_persist.js] +[browser_webconsole_primitive_stacktrace.js] [browser_webconsole_promise_rejected_object.js] [browser_webconsole_reopen_closed_tab.js] [browser_webconsole_repeat_different_objects.js] @@ -364,7 +366,6 @@ skip-if = verify [browser_webconsole_trackingprotection_errors.js] skip-if = fission #Bug 1535451 tags = trackingprotection -[browser_webconsole_uncaught_exception.js] [browser_webconsole_view_source.js] [browser_webconsole_visibility_messages.js] [browser_webconsole_warn_about_replaced_api.js] diff --git a/devtools/client/webconsole/test/browser/browser_console.js b/devtools/client/webconsole/test/browser/browser_console.js index 59b779f58d5e..22fa7d3648b5 100644 --- a/devtools/client/webconsole/test/browser/browser_console.js +++ b/devtools/client/webconsole/test/browser/browser_console.js @@ -126,9 +126,6 @@ async function testMessages(hud) { async function checkMessageExists(hud, msg) { info(`Checking "${msg}" was logged`); - const message = await waitFor( - () => findMessage(hud, msg), - `Couldn't find "${msg}"` - ); + const message = await waitFor(() => findMessage(hud, msg)); ok(message, `"${msg}" was logged`); } diff --git a/devtools/client/webconsole/test/browser/browser_jsterm_await_error.js b/devtools/client/webconsole/test/browser/browser_jsterm_await_error.js index 448a649831d8..a15f1d26f1b3 100644 --- a/devtools/client/webconsole/test/browser/browser_jsterm_await_error.js +++ b/devtools/client/webconsole/test/browser/browser_jsterm_await_error.js @@ -22,91 +22,16 @@ add_task(async function() { info("Check that awaiting for a rejecting promise displays an error"); let res = await executeAndWaitForErrorMessage( `await new Promise((resolve,reject) => setTimeout(() => reject("await-rej"), 250))`, - "Uncaught await-rej" + "uncaught exception: await-rej" ); ok(res.node, "awaiting for a rejecting promise displays an error message"); res = await executeAndWaitForErrorMessage( `await Promise.reject("await-rej-2")`, - `Uncaught await-rej-2` + `uncaught exception: await-rej-2` ); ok(res.node, "awaiting for Promise.reject displays an error"); - res = await executeAndWaitForErrorMessage( - `await Promise.reject("")`, - `Uncaught ` - ); - ok( - res.node, - "awaiting for Promise rejecting with empty string displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `await Promise.reject(null)`, - `Uncaught null` - ); - ok( - res.node, - "awaiting for Promise rejecting with null displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `await Promise.reject(undefined)`, - `Uncaught undefined` - ); - ok( - res.node, - "awaiting for Promise rejecting with undefined displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `await Promise.reject(false)`, - `Uncaught false` - ); - ok( - res.node, - "awaiting for Promise rejecting with false displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `await Promise.reject(0)`, - `Uncaught 0` - ); - ok( - res.node, - "awaiting for Promise rejecting with 0 displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `await Promise.reject({foo: "bar"})`, - `Uncaught Object { foo: "bar" }` - ); - ok( - res.node, - "awaiting for Promise rejecting with an object displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `await Promise.reject(new Error("foo"))`, - `Uncaught Error: foo` - ); - ok( - res.node, - "awaiting for Promise rejecting with an error object displays the expected error" - ); - - res = await executeAndWaitForErrorMessage( - `var err = new Error("foo"); - err.name = "CustomError"; - await Promise.reject(err); - `, - `Uncaught CustomError: foo` - ); - ok( - res.node, - "awaiting for Promise rejecting with an error object with a name property displays the expected error" - ); - res = await executeAndWaitForErrorMessage( `await new Promise(() => a.b.c)`, `ReferenceError: a is not defined` @@ -127,7 +52,7 @@ add_task(async function() { res = await executeAndWaitForErrorMessage( `await new Promise(res => { throw "instant throw"; })`, - `Uncaught instant throw` + `uncaught exception: instant throw` ); ok( res.node, @@ -145,7 +70,7 @@ add_task(async function() { res = await executeAndWaitForErrorMessage( `await new Promise(res => { setTimeout(() => { throw "throw in timeout"; }, 250) })`, - `Uncaught throw in timeout` + `uncaught exception: throw in timeout` ); ok( res.node, @@ -164,7 +89,7 @@ add_task(async function() { ); info("Check that we have the expected number of commands"); - const expectedInputsNumber = 16; + const expectedInputsNumber = 8; is( hud.ui.outputNode.querySelectorAll(".message.command").length, expectedInputsNumber, diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_async_stack.js b/devtools/client/webconsole/test/browser/browser_webconsole_async_stack.js index 44c7fbae5fac..0982116b1a9b 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_async_stack.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_async_stack.js @@ -43,14 +43,14 @@ add_task(async function() { ].join("\n"); const traceMsgNode = await waitFor( - () => findMessage(hud, "Trace message", ".console-api.trace"), + () => findMessage(hud, "Trace message"), "Wait for the trace message to be logged" ); let frames = await getSimplifiedStack(traceMsgNode); is(frames, expectedFrames, "console.trace has expected frames"); const consoleErrorMsgNode = await waitFor( - () => findMessage(hud, "console error message", ".console-api.error"), + () => findMessage(hud, "console error message"), "Wait for the console error message to be logged" ); consoleErrorMsgNode.querySelector(".arrow").click(); @@ -58,12 +58,7 @@ add_task(async function() { is(frames, expectedFrames, "console.error has expected frames"); const errorMsgNode = await waitFor( - () => - findMessage( - hud, - "Uncaught Error: Thrown error message", - ".javascript.error" - ), + () => findMessage(hud, "Thrown error message"), "Wait for the thrown error message to be logged" ); errorMsgNode.querySelector(".arrow").click(); @@ -73,11 +68,9 @@ add_task(async function() { async function getSimplifiedStack(messageEl) { const framesEl = await waitFor(() => { - const frames = messageEl.querySelectorAll( - ".message-body-wrapper > .stacktrace .frame" - ); + const frames = messageEl.querySelectorAll(".frame"); return frames.length > 0 ? frames : null; - }, "Couldn't find stacktrace"); + }); return Array.from(framesEl) .map(frameEl => diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_copy_entire_message.js b/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_copy_entire_message.js index 132acff8f588..f7bd52264958 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_copy_entire_message.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_copy_entire_message.js @@ -133,7 +133,7 @@ async function testMessagesCopy(hud, timestamp) { lines = clipboardText.split(newLineString); is( lines[0], - `${timestamp ? getTimestampText(message) + " " : ""}Error: error object`, + `${timestamp ? getTimestampText(message) + " " : ""}Error: "error object"`, "Error object first line has expected text" ); if (timestamp) { @@ -161,7 +161,7 @@ async function testMessagesCopy(hud, timestamp) { is( lines[0], (timestamp ? getTimestampText(message) + " " : "") + - "Uncaught ReferenceError: z is not defined", + "ReferenceError: z is not defined test.js:11:5", "ReferenceError first line has expected text" ); if (timestamp) { @@ -170,11 +170,6 @@ async function testMessagesCopy(hud, timestamp) { "Log line has the right format:\n" + lines[0] ); } - is( - lines[1], - ` ${TEST_URI}test.js:11`, - "ReferenceError second line has expected text" - ); ok( !!message.querySelector(".learn-more-link"), "There is a Learn More link in the ReferenceError message" diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_export_console_output.js b/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_export_console_output.js index cc4831a83f56..b22b06a6f425 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_export_console_output.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_context_menu_export_console_output.js @@ -101,7 +101,7 @@ function checkExportedText(text) { // Array [ "b", "c"] // test.js:5:17 // ------------------------------------------------------------------- - // Error: error object + // Error: "error object": // wrapper test.js:5 // logStuff test.js:17 // test.js:6:17 @@ -129,7 +129,7 @@ function checkExportedText(text) { is(lines[5], `test.js:5:17`); info("Check logged error object"); - is(lines[6], `Error: error object`); + is(lines[6], `Error: "error object"`); is(lines[7], ` wrapper ${TEST_URI}test.js:6`); is(lines[8], ` logStuff ${TEST_URI}test.js:10`); is(lines[9], `test.js:6:17`); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_eval_error.js b/devtools/client/webconsole/test/browser/browser_webconsole_eval_error.js index 8d1b21120758..33bc7c568896 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_eval_error.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_eval_error.js @@ -1,8 +1,8 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that throwing uncaught errors while doing console evaluations shows the expected -// error message, with or without stack, in the console. +// Tests that throwing uncaught errors while doing console evaluations shows a +// stack in the console. "use strict"; @@ -19,62 +19,17 @@ add_task(async function() { execute(hud, "throwValue(40 + 2)"); await checkMessageStack(hud, "42", [14, 10, 1]); - await checkThrowingEvaluationWithStack(hud, `"bloop"`, "Uncaught bloop"); - await checkThrowingEvaluationWithStack(hud, `""`, "Uncaught "); - await checkThrowingEvaluationWithStack(hud, `0`, "Uncaught 0"); - await checkThrowingEvaluationWithStack(hud, `null`, "Uncaught null"); - await checkThrowingEvaluationWithStack( + execute( hud, - `undefined`, - "Uncaught undefined" + ` + a = () => {throw "bloop"}; + b = () => a(); + c = () => b(); + d = () => c(); + d(); + ` ); - await checkThrowingEvaluationWithStack(hud, `false`, "Uncaught false"); - - await checkThrowingEvaluationWithStack( - hud, - `new Error("watermelon")`, - "Uncaught Error: watermelon" - ); - - await checkThrowingEvaluationWithStack( - hud, - `(err = new Error("lettuce"), err.name = "VegetableError", err)`, - "Uncaught VegetableError: lettuce" - ); - - await checkThrowingEvaluationWithStack( - hud, - `{ fav: "eggplant" }`, - `Uncaught Object { fav: "eggplant" }` - ); - info("Check that object in errors can be expanded"); - const rejectedObjectMessage = findMessage(hud, "eggplant", ".error"); - const oi = rejectedObjectMessage.querySelector(".tree"); - ok(true, "The object was rendered in an ObjectInspector"); - - info("Expanding the object"); - const onOiExpanded = waitFor(() => { - return oi.querySelectorAll(".node").length === 3; - }); - oi.querySelector(".arrow").click(); - await onOiExpanded; - - ok( - oi.querySelector(".arrow").classList.contains("expanded"), - "Object expanded" - ); - - // The object inspector now looks like: - // {...} - // | fav: "eggplant" - // | : Object { ... } - - const oiNodes = oi.querySelectorAll(".node"); - is(oiNodes.length, 3, "There is the expected number of nodes in the tree"); - - ok(oiNodes[0].textContent.includes(`{\u2026}`)); - ok(oiNodes[1].textContent.includes(`fav: "eggplant"`)); - ok(oiNodes[2].textContent.includes(`: Object { \u2026 }`)); + await checkMessageStack(hud, "Error: bloop", [2, 3, 4, 5, 6]); execute(hud, `1 + @`); const messageNode = await waitFor(() => @@ -86,17 +41,3 @@ add_task(async function() { "There's no stacktrace for a SyntaxError evaluation" ); }); - -function checkThrowingEvaluationWithStack(hud, expression, expectedMessage) { - execute( - hud, - ` - a = () => {throw ${expression}}; - b = () => a(); - c = () => b(); - d = () => c(); - d(); - ` - ); - return checkMessageStack(hud, expectedMessage, [2, 3, 4, 5, 6]); -} diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_eval_sources.js b/devtools/client/webconsole/test/browser/browser_webconsole_eval_sources.js index 95baf1cac7bf..9ecf48a5feaf 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_eval_sources.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_eval_sources.js @@ -7,6 +7,24 @@ const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" + "test/browser/test-eval-sources.html"; +async function clickFirstStackElement(hud, message, needsExpansion) { + if (needsExpansion) { + const button = message.querySelector(".collapse-button"); + ok(button, "has button"); + button.click(); + } + + let frame; + await waitUntil(() => { + frame = message.querySelector(".frame"); + return !!frame; + }); + + EventUtils.sendMouseEvent({ type: "mousedown" }, frame); + + await once(hud, "source-in-debugger-opened"); +} + // Test that stack/message links in console API and error messages originating // from eval code go to a source in the debugger. This should work even when the // console is opened first. @@ -43,21 +61,3 @@ add_task(async function() { "expected source url" ); }); - -async function clickFirstStackElement(hud, message, needsExpansion) { - if (needsExpansion) { - const button = message.querySelector(".collapse-button"); - ok(button, "has button"); - button.click(); - } - - let frame; - await waitUntil(() => { - frame = message.querySelector(".stacktrace .frame"); - return !!frame; - }); - - const onSourceOpenedInDebugger = once(hud, "source-in-debugger-opened"); - EventUtils.sendMouseEvent({ type: "mousedown" }, frame); - await onSourceOpenedInDebugger; -} diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_primitive_stacktrace.js b/devtools/client/webconsole/test/browser/browser_webconsole_primitive_stacktrace.js new file mode 100644 index 000000000000..adb45580cf8d --- /dev/null +++ b/devtools/client/webconsole/test/browser/browser_webconsole_primitive_stacktrace.js @@ -0,0 +1,19 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that stack traces are shown when primitive values are thrown instead of +// error objects. + +"use strict"; + +const TEST_URI = + "http://example.com/browser/devtools/client/webconsole/" + + "test/browser/" + + "test-primitive-stacktrace.html"; + +add_task(async function() { + const hud = await openNewTabAndConsole(TEST_URI); + + await checkMessageStack(hud, "hello", [14, 10, 7]); + await checkMessageStack(hud, "1,2,3", [20]); +}); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_promise_rejected_object.js b/devtools/client/webconsole/test/browser/browser_webconsole_promise_rejected_object.js index 0fa4eae2c494..11926541d376 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_promise_rejected_object.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_promise_rejected_object.js @@ -1,81 +1,18 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Test that rejected promise are reported to the console. +// Test that rejected non-error objects are reported to the console. "use strict"; const TEST_URI = `data:text/html;charset=utf-8, `; add_task(async function() { const hud = await openNewTabAndConsole(TEST_URI); - - const expectedErrors = [ - "Uncaught potato", - "Uncaught ", - "Uncaught 0", - "Uncaught false", - "Uncaught null", - "Uncaught undefined", - `Uncaught Object { fav: "eggplant" }`, - `Uncaught Array [ "cherry", "strawberry" ]`, - `Uncaught Error: spinach`, - `Uncaught VeggieError: carrot`, - ]; - - for (const expectedError of expectedErrors) { - await waitFor( - () => findMessage(hud, expectedError, ".error"), - `Couldn't find «${expectedError}» message` - ); - ok(true, `Found «${expectedError}» message`); - } - ok(true, "All expected messages were found"); - - info("Check that object in errors can be expanded"); - const rejectedObjectMessage = findMessage( - hud, - `Uncaught Object { fav: "eggplant" }`, - ".error" - ); - const oi = rejectedObjectMessage.querySelector(".tree"); - ok(true, "The object was rendered in an ObjectInspector"); - - info("Expanding the object"); - const onOiExpanded = waitFor(() => { - return oi.querySelectorAll(".node").length === 3; - }); - oi.querySelector(".arrow").click(); - await onOiExpanded; - - ok( - oi.querySelector(".arrow").classList.contains("expanded"), - "Object expanded" - ); - - // The object inspector now looks like: - // {...} - // | fav: "eggplant" - // | : Object { ... } - - const oiNodes = oi.querySelectorAll(".node"); - is(oiNodes.length, 3, "There is the expected number of nodes in the tree"); - - ok(oiNodes[0].textContent.includes(`{\u2026}`)); - ok(oiNodes[1].textContent.includes(`fav: "eggplant"`)); - ok(oiNodes[2].textContent.includes(`: Object { \u2026 }`)); + await waitFor(() => findMessage(hud, "Object")); + ok(true, "Message displayed for rejected object"); }); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js index 738df88634d8..c10066c61410 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js @@ -89,22 +89,5 @@ function getCommands() { evaluationResult.set(`eval throw ""`, `throw ""`); evaluationResult.set(`eval throw "tomato"`, `throw "tomato"`); - evaluationResult.set(`eval throw false`, `throw false`); - evaluationResult.set(`eval throw 0`, `throw 0`); - evaluationResult.set(`eval throw null`, `throw null`); - evaluationResult.set(`eval throw undefined`, `throw undefined`); - evaluationResult.set(`eval throw Symbol`, `throw Symbol("potato")`); - evaluationResult.set(`eval throw Object`, `throw {vegetable: "cucumber"}`); - evaluationResult.set(`eval throw Error Object`, `throw new Error("pumpkin")`); - evaluationResult.set( - `eval throw Error Object with custom name`, - ` - var err = new Error("pineapple"); - err.name = "JuicyError"; - err.flavor = "delicious"; - throw err; - ` - ); - return evaluationResult; } diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js index 664a76c62b53..6e34e16a6e8f 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js @@ -119,60 +119,7 @@ function getCommands() { `throw new Error("Long error ".repeat(10000))` ); - const evilDomain = `https://evil.com/?`; - const badDomain = `https://not-so-evil.com/?`; - const paramLength = 200; - const longParam = "a".repeat(paramLength); - - const evilURL = `${evilDomain}${longParam}`; - const badURL = `${badDomain}${longParam}`; - - pageError.set( - `throw string with URL`, - `throw "“${evilURL}“ is evil and “${badURL}“ is not good either"` - ); - pageError.set(`throw ""`, `throw ""`); pageError.set(`throw "tomato"`, `throw "tomato"`); - pageError.set(`throw false`, `throw false`); - pageError.set(`throw 0`, `throw 0`); - pageError.set(`throw null`, `throw null`); - pageError.set(`throw undefined`, `throw undefined`); - pageError.set(`throw Symbol`, `throw Symbol("potato")`); - pageError.set(`throw Object`, `throw {vegetable: "cucumber"}`); - pageError.set(`throw Error Object`, `throw new Error("pumpkin")`); - pageError.set( - `throw Error Object with custom name`, - ` - var err = new Error("pineapple"); - err.name = "JuicyError"; - err.flavor = "delicious"; - throw err; - ` - ); - pageError.set(`Promise reject ""`, `Promise.reject("")`); - pageError.set(`Promise reject "tomato"`, `Promise.reject("tomato")`); - pageError.set(`Promise reject false`, `Promise.reject(false)`); - pageError.set(`Promise reject 0`, `Promise.reject(0)`); - pageError.set(`Promise reject null`, `Promise.reject(null)`); - pageError.set(`Promise reject undefined`, `Promise.reject(undefined)`); - pageError.set(`Promise reject Symbol`, `Promise.reject(Symbol("potato"))`); - pageError.set( - `Promise reject Object`, - `Promise.reject({vegetable: "cucumber"})` - ); - pageError.set( - `Promise reject Error Object`, - `Promise.reject(new Error("pumpkin"))` - ); - pageError.set( - `Promise reject Error Object with custom name`, - ` - var err = new Error("pineapple"); - err.name = "JuicyError"; - err.flavor = "delicious"; - Promise.reject(err); - ` - ); return pageError; } diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_uncaught_exception.js b/devtools/client/webconsole/test/browser/browser_webconsole_uncaught_exception.js deleted file mode 100644 index 6f824f4f7b42..000000000000 --- a/devtools/client/webconsole/test/browser/browser_webconsole_uncaught_exception.js +++ /dev/null @@ -1,88 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Test that stack traces are shown when primitive values are thrown instead of -// error objects. - -"use strict"; - -const TEST_URI = `data:text/html,Test uncaught exception`; - -add_task(async function() { - const hud = await openNewTabAndConsole(TEST_URI); - - await checkThrowingWithStack(hud, `"tomato"`, "Uncaught tomato"); - await checkThrowingWithStack(hud, `""`, "Uncaught "); - await checkThrowingWithStack(hud, `42`, "Uncaught 42"); - await checkThrowingWithStack(hud, `0`, "Uncaught 0"); - await checkThrowingWithStack(hud, `null`, "Uncaught null"); - await checkThrowingWithStack(hud, `undefined`, "Uncaught undefined"); - await checkThrowingWithStack(hud, `false`, "Uncaught false"); - - await checkThrowingWithStack( - hud, - `new Error("watermelon")`, - "Uncaught Error: watermelon" - ); - - await checkThrowingWithStack( - hud, - `(err = new Error("lettuce"), err.name = "VegetableError", err)`, - "Uncaught VegetableError: lettuce" - ); - - await checkThrowingWithStack( - hud, - `{ fav: "eggplant" }`, - `Uncaught Object { fav: "eggplant" }` - ); - - info("Check that object in errors can be expanded"); - const rejectedObjectMessage = findMessage(hud, "eggplant", ".error"); - const oi = rejectedObjectMessage.querySelector(".tree"); - ok(true, "The object was rendered in an ObjectInspector"); - - info("Expanding the object"); - const onOiExpanded = waitFor(() => { - return oi.querySelectorAll(".node").length === 3; - }); - oi.querySelector(".arrow").click(); - await onOiExpanded; - - ok( - oi.querySelector(".arrow").classList.contains("expanded"), - "Object expanded" - ); - - // The object inspector now looks like: - // {...} - // | fav: "eggplant" - // | : Object { ... } - - const oiNodes = oi.querySelectorAll(".node"); - is(oiNodes.length, 3, "There is the expected number of nodes in the tree"); - - ok(oiNodes[0].textContent.includes(`{\u2026}`)); - ok(oiNodes[1].textContent.includes(`fav: "eggplant"`)); - ok(oiNodes[2].textContent.includes(`: Object { \u2026 }`)); -}); - -async function checkThrowingWithStack(hud, expression, expectedMessage) { - await SpecialPowers.spawn(gBrowser.selectedBrowser, [expression], function( - expr - ) { - const script = content.document.createElement("script"); - script.append( - content.document.createTextNode(` - a = () => {throw ${expr}}; - b = () => a(); - c = () => b(); - d = () => c(); - d(); - `) - ); - content.document.body.append(script); - script.remove(); - }); - return checkMessageStack(hud, expectedMessage, [2, 3, 4, 5, 6]); -} diff --git a/devtools/client/webconsole/test/browser/head.js b/devtools/client/webconsole/test/browser/head.js index 1ae0a6197ef0..a7061b43953d 100644 --- a/devtools/client/webconsole/test/browser/head.js +++ b/devtools/client/webconsole/test/browser/head.js @@ -1620,32 +1620,15 @@ function checkConsoleOutputForWarningGroup(hud, expectedMessages) { * line numbers of the frames expected in the stack */ async function checkMessageStack(hud, text, expectedFrameLines) { - info(`Checking message stack for "${text}"`); - const msgNode = await waitFor( - () => findMessage(hud, text), - `Couln't find message including "${text}"` - ); + const msgNode = await waitFor(() => findMessage(hud, text)); ok(!msgNode.classList.contains("open"), `Error logged not expanded`); - const button = await waitFor( - () => msgNode.querySelector(".collapse-button"), - `Couldn't find the expand button on "${text}" message` - ); + const button = await waitFor(() => msgNode.querySelector(".collapse-button")); button.click(); - const framesNode = await waitFor( - () => msgNode.querySelector(".message-body-wrapper > .stacktrace .frames"), - `Couldn't find stacktrace frames on "${text}" message` - ); + const framesNode = await waitFor(() => msgNode.querySelector(".frames")); const frameNodes = Array.from(framesNode.querySelectorAll(".frame")).filter( - el => { - const fileName = el.querySelector(".filename").textContent; - return ( - fileName !== "self-hosted" && - !fileName.startsWith("chrome:") && - !fileName.startsWith("resource:") - ); - } + el => el.querySelector(".filename").textContent !== "self-hosted" ); for (let i = 0; i < frameNodes.length; i++) { diff --git a/devtools/client/webconsole/test/browser/stub-generator-helpers.js b/devtools/client/webconsole/test/browser/stub-generator-helpers.js index 457c968dc8d6..69c4aedcc6b8 100644 --- a/devtools/client/webconsole/test/browser/stub-generator-helpers.js +++ b/devtools/client/webconsole/test/browser/stub-generator-helpers.js @@ -109,35 +109,11 @@ function getCleanedPacket(key, packet) { } } - if (res?.exception?.actor && existingPacket.exception.actor) { - // Clean actor ids on evaluation exception - copyExistingActor(res.exception, existingPacket.exception); - } - if (res.result && res.result._grip && existingPacket.result) { // Clean actor ids on evaluation result messages. copyExistingActor(res.result, existingPacket.result); } - if ( - res?.result?._grip?.promiseState?.reason && - existingPacket?.result?._grip?.promiseState?.reason - ) { - // Clean actor ids on evaluation promise result messages. - copyExistingActor( - res.result._grip.promiseState.reason, - existingPacket.result._grip.promiseState.reason - ); - } - - if ( - res?.result?._grip?.promiseState?.timeToSettle && - existingPacket?.result?._grip?.promiseState?.timeToSettle - ) { - res.result._grip.promiseState.timeToSettle = - existingPacket.result._grip.promiseState.timeToSettle; - } - if (res.exception && existingPacket.exception) { // Clean actor ids on exception messages. copyExistingActor(res.exception, existingPacket.exception); @@ -192,23 +168,6 @@ function getCleanedPacket(key, packet) { ); } - if ( - res.pageError.exception?._grip?.preview?.message?._grip && - existingPacket.pageError.exception?._grip?.preview?.message?._grip - ) { - copyExistingActor( - res.pageError.exception._grip.preview.message, - existingPacket.pageError.exception._grip.preview.message - ); - } - - if (res.pageError.exception && existingPacket.pageError.exception) { - copyExistingActor( - res.pageError.exception, - existingPacket.pageError.exception - ); - } - if (res.pageError.sourceId) { res.pageError.sourceId = existingPacket.pageError.sourceId; } @@ -330,10 +289,6 @@ function cleanTimeStamp(packet) { packet.result._grip.preview.timestamp = uniqueTimeStamp; } - if (packet?.result?._grip?.promiseState?.creationTimestamp) { - packet.result._grip.promiseState.creationTimestamp = uniqueTimeStamp; - } - if (packet?.exception?._grip?.preview?.timestamp) { packet.exception._grip.preview.timestamp = uniqueTimeStamp; } @@ -351,21 +306,22 @@ function cleanTimeStamp(packet) { } } -function copyExistingActor(a, b) { - if (!a || !b) { +function copyExistingActor(front1, front2) { + if (!front1 || !front2) { return; } - if (a.actorID && b.actorID) { - a.actorID = b.actorID; + if (front1.actorID && front2.actorID) { + front1.actorID = front2.actorID; } - if (a.actor && b.actor) { - a.actor = b.actor; - } - - if (a._grip && b._grip && a._grip.actor && b._grip.actor) { - a._grip.actor = b._grip.actor; + if ( + front1._grip && + front2._grip && + front1._grip.actor && + front2._grip.actor + ) { + front1._grip.actor = front2._grip.actor; } } @@ -479,12 +435,7 @@ function parsePacketAndCreateFronts(packet) { } if (typeof packet === "object") { for (const [key, value] of Object.entries(packet)) { - if (value?._grip) { - // The message of an error grip might be a longString. - if (value._grip?.preview?.message?._grip) { - value._grip.preview.message = value._grip.preview.message._grip; - } - + if (value && value._grip) { packet[key] = getAdHocFrontOrPrimitiveGrip(value._grip, { conn: { poolFor: () => {}, diff --git a/devtools/client/webconsole/test/browser/test-primitive-stacktrace.html b/devtools/client/webconsole/test/browser/test-primitive-stacktrace.html new file mode 100644 index 000000000000..87280f7302d5 --- /dev/null +++ b/devtools/client/webconsole/test/browser/test-primitive-stacktrace.html @@ -0,0 +1,22 @@ + + + + diff --git a/devtools/client/webconsole/test/node/components/evaluation-result.test.js b/devtools/client/webconsole/test/node/components/evaluation-result.test.js index 797028c0705a..917d1066e80c 100644 --- a/devtools/client/webconsole/test/node/components/evaluation-result.test.js +++ b/devtools/client/webconsole/test/node/components/evaluation-result.test.js @@ -51,7 +51,7 @@ describe("EvaluationResult component:", () => { const wrapper = render(EvaluationResult({ message, serviceContainer })); expect(wrapper.find(".message-body").text()).toBe( - "Uncaught ReferenceError: asdf is not defined[Learn More]" + "ReferenceError: asdf is not defined[Learn More]" ); expect(wrapper.hasClass("message")).toBe(true); @@ -63,7 +63,7 @@ describe("EvaluationResult component:", () => { const wrapper = render(EvaluationResult({ message, serviceContainer })); const text = wrapper.find(".message-body").text(); - expect(text.startsWith("Uncaught Error: Long error Long error")).toBe(true); + expect(text.startsWith("Error: Long error Long error")).toBe(true); expect(wrapper.hasClass("message")).toBe(true); expect(wrapper.hasClass("error")).toBe(true); }); @@ -72,7 +72,7 @@ describe("EvaluationResult component:", () => { const message = stubPreparedMessages.get(`eval throw ""`); const wrapper = render(EvaluationResult({ message, serviceContainer })); const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught "); + expect(text).toBe("Error"); expect(wrapper.hasClass("error")).toBe(true); }); @@ -80,80 +80,7 @@ describe("EvaluationResult component:", () => { const message = stubPreparedMessages.get(`eval throw "tomato"`); const wrapper = render(EvaluationResult({ message, serviceContainer })); const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught tomato"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown Boolean", () => { - const message = stubPreparedMessages.get(`eval throw false`); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught false"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown Number", () => { - const message = stubPreparedMessages.get(`eval throw 0`); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught 0"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown null", () => { - const message = stubPreparedMessages.get(`eval throw null`); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught null"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown undefined", () => { - const message = stubPreparedMessages.get(`eval throw undefined`); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught undefined"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown Symbol", () => { - const message = stubPreparedMessages.get(`eval throw Symbol`); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught Symbol(potato)"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown Object", () => { - const message = stubPreparedMessages.get(`eval throw Object`); - // We need to wrap the EvaluationResult in a Provider in order for the - // ObjectInspector to work. - const wrapper = render( - Provider( - { store: setupStore() }, - EvaluationResult({ message, serviceContainer }) - ) - ); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Object { vegetable: "cucumber" }`); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown Error Object", () => { - const message = stubPreparedMessages.get(`eval throw Error Object`); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught Error: pumpkin"); - expect(wrapper.hasClass("error")).toBe(true); - }); - - it("render thrown ErrorObject with custom name", () => { - const message = stubPreparedMessages.get( - `eval throw Error Object with custom name` - ); - const wrapper = render(EvaluationResult({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught JuicyError: pineapple"); + expect(text).toBe("Error: tomato"); expect(wrapper.hasClass("error")).toBe(true); }); diff --git a/devtools/client/webconsole/test/node/components/page-error.test.js b/devtools/client/webconsole/test/node/components/page-error.test.js index 1392f9130234..094d600e28fc 100644 --- a/devtools/client/webconsole/test/node/components/page-error.test.js +++ b/devtools/client/webconsole/test/node/components/page-error.test.js @@ -51,7 +51,7 @@ describe("PageError component:", () => { ); expect(wrapper.find(".message-body").text()).toBe( - "Uncaught ReferenceError: asdf is not defined[Learn More]" + "ReferenceError: asdf is not defined[Learn More]" ); // The stacktrace should be closed by default. @@ -85,172 +85,26 @@ describe("PageError component:", () => { const wrapper = render(PageError({ message, serviceContainer })); const text = wrapper.find(".message-body").text(); - expect(text.startsWith("Uncaught Error: Long error Long error")).toBe(true); + expect(text.startsWith("Error: Long error Long error")).toBe(true); }); it("renders thrown empty string", () => { const message = stubPreparedMessages.get(`throw ""`); const wrapper = render(PageError({ message, serviceContainer })); const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught "); + expect(text).toBe("uncaught exception: "); }); it("renders thrown string", () => { const message = stubPreparedMessages.get(`throw "tomato"`); const wrapper = render(PageError({ message, serviceContainer })); const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught tomato`); - }); - - it("renders thrown boolean", () => { - const message = stubPreparedMessages.get(`throw false`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught false`); - }); - - it("renders thrown number ", () => { - const message = stubPreparedMessages.get(`throw 0`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught 0`); - }); - - it("renders thrown null", () => { - const message = stubPreparedMessages.get(`throw null`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught null`); - }); - - it("renders thrown undefined", () => { - const message = stubPreparedMessages.get(`throw undefined`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught undefined`); - }); - - it("renders thrown Symbol", () => { - const message = stubPreparedMessages.get(`throw Symbol`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Symbol(potato)`); - }); - - it("renders thrown object", () => { - const message = stubPreparedMessages.get(`throw Object`); - - // We need to wrap the PageError in a Provider in order for the - // ObjectInspector to work. - const wrapper = render( - Provider( - { store: setupStore() }, - PageError({ message, serviceContainer }) - ) - ); - - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Object { vegetable: "cucumber" }`); - }); - - it("renders thrown error", () => { - const message = stubPreparedMessages.get(`throw Error Object`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Error: pumpkin`); - }); - - it("renders thrown Error with custom name", () => { - const message = stubPreparedMessages.get( - `throw Error Object with custom name` - ); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught JuicyError: pineapple`); - }); - - it("renders uncaught rejected Promise with empty string", () => { - const message = stubPreparedMessages.get(`Promise reject ""`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe("Uncaught "); - }); - - it("renders uncaught rejected Promise with string", () => { - const message = stubPreparedMessages.get(`Promise reject "tomato"`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught tomato`); - }); - - it("renders uncaught rejected Promise with boolean", () => { - const message = stubPreparedMessages.get(`Promise reject false`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught false`); - }); - - it("renders uncaught rejected Promise with number ", () => { - const message = stubPreparedMessages.get(`Promise reject 0`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught 0`); - }); - - it("renders uncaught rejected Promise with null", () => { - const message = stubPreparedMessages.get(`Promise reject null`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught null`); - }); - - it("renders uncaught rejected Promise with undefined", () => { - const message = stubPreparedMessages.get(`Promise reject undefined`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught undefined`); - }); - - it("renders uncaught rejected Promise with Symbol", () => { - const message = stubPreparedMessages.get(`Promise reject Symbol`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Symbol(potato)`); - }); - - it("renders uncaught rejected Promise with object", () => { - const message = stubPreparedMessages.get(`Promise reject Object`); - // We need to wrap the PageError in a Provider in order for the - // ObjectInspector to work. - const wrapper = render( - Provider( - { store: setupStore() }, - PageError({ message, serviceContainer }) - ) - ); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Object { vegetable: "cucumber" }`); - }); - - it("renders uncaught rejected Promise with error", () => { - const message = stubPreparedMessages.get(`Promise reject Error Object`); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught Error: pumpkin`); - }); - - it("renders uncaught rejected Promise with Error with custom name", () => { - const message = stubPreparedMessages.get( - `Promise reject Error Object with custom name` - ); - const wrapper = render(PageError({ message, serviceContainer })); - const text = wrapper.find(".message-body").text(); - expect(text).toBe(`Uncaught JuicyError: pineapple`); + expect(text).toBe(`uncaught exception: tomato`); }); it("renders URLs in message as actual, cropped, links", () => { // Let's replace the packet data in order to mimick a pageError. - const packet = stubPackets.get("throw string with URL"); + const packet = stubPackets.get("ReferenceError: asdf is not defined"); const evilDomain = `https://evil.com/?`; const badDomain = `https://not-so-evil.com/?`; @@ -260,6 +114,8 @@ describe("PageError component:", () => { const evilURL = `${evilDomain}${longParam}`; const badURL = `${badDomain}${longParam}`; + packet.pageError.errorMessage = `“${evilURL}“ is evil and “${badURL}“ is not good either`; + // We remove the exceptionDocURL to not have the "learn more" link. packet.pageError.exceptionDocURL = null; @@ -277,7 +133,7 @@ describe("PageError component:", () => { const text = wrapper.find(".message-body").text(); expect(text).toBe( - `Uncaught “${croppedEvil}“ is evil and “${croppedbad}“ is not good either` + `“${croppedEvil}“ is evil and “${croppedbad}“ is not good either` ); // There should be 2 links. diff --git a/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js b/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js index 2c96e422e705..13ad96b24575 100644 --- a/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js +++ b/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js @@ -20,7 +20,6 @@ const { const rawPackets = new Map(); rawPackets.set(`new Date(0)`, { "resultID": "1573832025018-0", - "hasException": false, "input": "new Date(0)", "result": { "_grip": { @@ -76,7 +75,6 @@ rawPackets.set(`asdf()`, { "functionName": null } ], - "hasException": true, "frame": { "source": "debugger eval code", "line": 1, @@ -116,7 +114,6 @@ rawPackets.set(`1 + @`, { }, "exceptionMessage": "SyntaxError: illegal character", "exceptionDocURL": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Illegal_character?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default", - "hasException": true, "frame": { "source": "debugger eval code", "line": 1, @@ -132,7 +129,6 @@ rawPackets.set(`1 + @`, { rawPackets.set(`inspect({a: 1})`, { "resultID": "1573832025122-3", - "hasException": false, "helperResult": { "type": "inspectObject", "input": "inspect({a: 1})", @@ -175,7 +171,6 @@ rawPackets.set(`inspect({a: 1})`, { rawPackets.set(`cd(document)`, { "resultID": "1573832025125-4", - "hasException": false, "helperResult": { "type": "error", "message": "cdFunctionInvalidArgument" @@ -190,7 +185,6 @@ rawPackets.set(`cd(document)`, { rawPackets.set(`undefined`, { "resultID": "1573832025127-5", - "hasException": false, "input": "undefined", "result": { "type": "undefined" @@ -248,7 +242,6 @@ rawPackets.set(`longString message Error`, { "functionName": null } ], - "hasException": true, "frame": { "source": "debugger eval code", "sourceId": "server0.conn0.child1/source31", @@ -276,7 +269,6 @@ rawPackets.set(`eval throw ""`, { "functionName": null } ], - "hasException": true, "frame": { "source": "debugger eval code", "sourceId": "server0.conn0.child1/source24", @@ -304,7 +296,6 @@ rawPackets.set(`eval throw "tomato"`, { "functionName": null } ], - "hasException": true, "frame": { "source": "debugger eval code", "sourceId": "server0.conn0.child1/source24", @@ -319,304 +310,6 @@ rawPackets.set(`eval throw "tomato"`, { "timestamp": 1572867483805 }); -rawPackets.set(`eval throw false`, { - "resultID": "1588154002962-9", - "exception": false, - "exceptionMessage": "false", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "line": 1, - "column": 1 - }, - "input": "throw false", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw 0`, { - "resultID": "1588154002979-10", - "exception": 0, - "exceptionMessage": "0", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "line": 1, - "column": 1 - }, - "input": "throw 0", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw null`, { - "resultID": "1588154003064-11", - "exception": { - "type": "null" - }, - "exceptionMessage": "null", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "line": 1, - "column": 1 - }, - "input": "throw null", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw undefined`, { - "resultID": "1588154003073-12", - "exception": { - "type": "undefined" - }, - "exceptionMessage": "undefined", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "line": 1, - "column": 1 - }, - "input": "throw undefined", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw Symbol`, { - "resultID": "1588154003077-13", - "exception": { - "type": "symbol", - "actor": "server0.conn2.child2/symbol44", - "name": "potato" - }, - "exceptionMessage": "Symbol(potato)", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source33", - "lineNumber": 1, - "columnNumber": 7, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source33", - "line": 1, - "column": 7 - }, - "input": "throw Symbol(\"potato\")", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw Object`, { - "resultID": "1588154003082-14", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn2.child2/obj46", - "class": "Object", - "ownPropertyLength": 1, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Object", - "ownProperties": { - "vegetable": { - "configurable": true, - "enumerable": true, - "writable": true, - "value": "cucumber" - } - }, - "ownSymbols": [], - "ownPropertiesLength": 1, - "ownSymbolsLength": 0, - "safeGetterValues": {} - } - }, - "actorID": "server0.conn2.child2/obj46" - }, - "exceptionMessage": "[object Object]", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source26", - "line": 1, - "column": 1 - }, - "input": "throw {vegetable: \"cucumber\"}", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw Error Object`, { - "resultID": "1588154003093-15", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn2.child2/obj48", - "class": "Error", - "ownPropertyLength": 4, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "Error", - "message": "pumpkin", - "stack": "@debugger eval code:1:7\n", - "fileName": "debugger eval code", - "lineNumber": 1, - "columnNumber": 7 - } - }, - "actorID": "server0.conn2.child2/obj48" - }, - "exceptionMessage": "Error: pumpkin", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source33", - "lineNumber": 1, - "columnNumber": 7, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source33", - "line": 1, - "column": 7 - }, - "input": "throw new Error(\"pumpkin\")", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - -rawPackets.set(`eval throw Error Object with custom name`, { - "resultID": "1588154003097-16", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn2.child2/obj50", - "class": "Error", - "ownPropertyLength": 6, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "JuicyError", - "message": "pineapple", - "stack": "@debugger eval code:2:15\n", - "fileName": "debugger eval code", - "lineNumber": 2, - "columnNumber": 15 - } - }, - "actorID": "server0.conn2.child2/obj50" - }, - "exceptionMessage": "JuicyError: pineapple", - "exceptionStack": [ - { - "filename": "debugger eval code", - "sourceId": "server0.conn2.child2/source49", - "lineNumber": 5, - "columnNumber": 5, - "functionName": null - } - ], - "hasException": true, - "frame": { - "source": "debugger eval code", - "sourceId": "server0.conn2.child2/source49", - "line": 5, - "column": 5 - }, - "input": "\n var err = new Error(\"pineapple\");\n err.name = \"JuicyError\";\n err.flavor = \"delicious\";\n throw err;\n ", - "result": { - "type": "undefined" - }, - "startTime": 1572867483805, - "timestamp": 1572867483805 -}); - const stubPackets = parsePacketsWithFronts(rawPackets); diff --git a/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js b/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js index abec6910913d..1d75cf4f2e74 100644 --- a/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js +++ b/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js @@ -82,29 +82,7 @@ rawPackets.set(`ReferenceError: asdf is not defined`, { ], "notes": null, "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj25", - "class": "Error", - "ownPropertyLength": 4, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "ReferenceError", - "message": "asdf is not defined", - "stack": "bar@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:3:5\nfoo@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:6:5\n@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:9:3\n", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 3, - "columnNumber": 5 - } - }, - "actorID": "server0.conn4.child2/obj25" - }, - "hasException": true + "cssSelectors": "" }, "type": "pageError" }); @@ -162,29 +140,7 @@ rawPackets.set(`SyntaxError: redeclaration of let a`, { } ], "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj26", - "class": "Error", - "ownPropertyLength": 4, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "SyntaxError", - "message": "redeclaration of let a", - "stack": "", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 2, - "columnNumber": 9 - } - }, - "actorID": "server0.conn4.child2/obj26" - }, - "hasException": true + "cssSelectors": "" }, "type": "pageError" }); @@ -246,93 +202,7 @@ rawPackets.set(`TypeError longString message`, { ], "notes": null, "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj29", - "class": "Error", - "ownPropertyLength": 4, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "Error", - "message": { - "_grip": { - "type": "longString", - "actor": "server0.conn4.child2/longstractor30", - "length": 110000, - "initial": "Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error" - }, - "actorID": "server0.conn4.child2/longstractor30" - }, - "stack": "@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:1:7\n", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 1, - "columnNumber": 7 - } - }, - "actorID": "server0.conn4.child2/obj29" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw string with URL`, { - "pageError": { - "errorMessage": "uncaught exception: “https://evil.com/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa“ is evil and “https://not-so-evil.com/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa“ is not good either", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn0.child2/source31", - "lineText": "", - "lineNumber": 1, - "columnNumber": 1, - "category": "content javascript", - "innerWindowID": 10737418241, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn0.child2/source31", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": "“https://evil.com/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa“ is evil and “https://not-so-evil.com/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa“ is not good either", - "hasException": true + "cssSelectors": "" }, "type": "pageError" }); @@ -386,9 +256,7 @@ rawPackets.set(`throw ""`, { ], "notes": null, "chromeContext": false, - "cssSelectors": "", - "exception": "", - "hasException": true + "cssSelectors": "" }, "type": "pageError" }); @@ -442,865 +310,7 @@ rawPackets.set(`throw "tomato"`, { ], "notes": null, "chromeContext": false, - "cssSelectors": "", - "exception": "tomato", - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw false`, { - "pageError": { - "errorMessage": "uncaught exception: false", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineText": "", - "lineNumber": 1, - "columnNumber": 1, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": false, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw 0`, { - "pageError": { - "errorMessage": "uncaught exception: 0", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineText": "", - "lineNumber": 1, - "columnNumber": 1, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": 0, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw null`, { - "pageError": { - "errorMessage": "uncaught exception: null", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineText": "", - "lineNumber": 1, - "columnNumber": 1, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "type": "null" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw undefined`, { - "pageError": { - "errorMessage": "uncaught exception: undefined", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineText": "", - "lineNumber": 1, - "columnNumber": 1, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "type": "undefined" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw Symbol`, { - "pageError": { - "errorMessage": "uncaught exception: Symbol(potato)", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source27", - "lineText": "", - "lineNumber": 1, - "columnNumber": 7, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source27", - "lineNumber": 1, - "columnNumber": 7, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "type": "symbol", - "actor": "server0.conn4.child2/symbol38", - "name": "potato" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw Object`, { - "pageError": { - "errorMessage": "uncaught exception: [object Object]", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineText": "", - "lineNumber": 1, - "columnNumber": 1, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source31", - "lineNumber": 1, - "columnNumber": 1, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj40", - "class": "Object", - "ownPropertyLength": 1, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Object", - "ownProperties": { - "vegetable": { - "configurable": true, - "enumerable": true, - "writable": true, - "value": "cucumber" - } - }, - "ownSymbols": [], - "ownPropertiesLength": 1, - "ownSymbolsLength": 0, - "safeGetterValues": {} - } - }, - "actorID": "server0.conn4.child2/obj40" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw Error Object`, { - "pageError": { - "errorMessage": "Error: pumpkin", - "errorMessageName": "", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source41", - "lineText": "", - "lineNumber": 1, - "columnNumber": 7, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source27", - "lineNumber": 1, - "columnNumber": 7, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj42", - "class": "Error", - "ownPropertyLength": 4, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "Error", - "message": "pumpkin", - "stack": "@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:1:7\n", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 1, - "columnNumber": 7 - } - }, - "actorID": "server0.conn4.child2/obj42" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`throw Error Object with custom name`, { - "pageError": { - "errorMessage": "JuicyError: pineapple", - "errorMessageName": "", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source43", - "lineText": "", - "lineNumber": 2, - "columnNumber": 15, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": [ - { - "filename": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source43", - "lineNumber": 2, - "columnNumber": 15, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js line 110 > eval", - "sourceId": null, - "lineNumber": 6, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 111, - "columnNumber": 29, - "functionName": null - }, - { - "filename": "resource://testing-common/content-task.js", - "sourceId": null, - "lineNumber": 64, - "columnNumber": 19, - "functionName": null, - "asyncCause": "MessageListener.receiveMessage" - } - ], - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj44", - "class": "Error", - "ownPropertyLength": 6, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "JuicyError", - "message": "pineapple", - "stack": "@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:2:15\n", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 2, - "columnNumber": 15 - } - }, - "actorID": "server0.conn4.child2/obj44" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject ""`, { - "pageError": { - "errorMessage": "uncaught exception: ", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": "", - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject "tomato"`, { - "pageError": { - "errorMessage": "uncaught exception: tomato", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": "tomato", - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject false`, { - "pageError": { - "errorMessage": "uncaught exception: false", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": false, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject 0`, { - "pageError": { - "errorMessage": "uncaught exception: 0", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": 0, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject null`, { - "pageError": { - "errorMessage": "uncaught exception: null", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "type": "null" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject undefined`, { - "pageError": { - "errorMessage": "uncaught exception: undefined", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "type": "undefined" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject Symbol`, { - "pageError": { - "errorMessage": "uncaught exception: Symbol(potato)", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "type": "symbol", - "actor": "server0.conn4.child2/symbol52", - "name": "potato" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject Object`, { - "pageError": { - "errorMessage": "uncaught exception: Object", - "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", - "sourceName": "", - "sourceId": null, - "lineText": "", - "lineNumber": 0, - "columnNumber": 0, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj54", - "class": "Object", - "ownPropertyLength": 1, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Object", - "ownProperties": { - "vegetable": { - "configurable": true, - "enumerable": true, - "writable": true, - "value": "cucumber" - } - }, - "ownSymbols": [], - "ownPropertiesLength": 1, - "ownSymbolsLength": 0, - "safeGetterValues": {} - } - }, - "actorID": "server0.conn4.child2/obj54" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject Error Object`, { - "pageError": { - "errorMessage": "Error: pumpkin", - "errorMessageName": "", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source55", - "lineText": "", - "lineNumber": 1, - "columnNumber": 16, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj56", - "class": "Error", - "ownPropertyLength": 4, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "Error", - "message": "pumpkin", - "stack": "@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:1:16\n", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 1, - "columnNumber": 16 - } - }, - "actorID": "server0.conn4.child2/obj56" - }, - "hasException": true - }, - "type": "pageError" -}); - -rawPackets.set(`Promise reject Error Object with custom name`, { - "pageError": { - "errorMessage": "JuicyError: pineapple", - "errorMessageName": "", - "sourceName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "sourceId": "server0.conn4.child2/source57", - "lineText": "", - "lineNumber": 2, - "columnNumber": 15, - "category": "content javascript", - "innerWindowID": 6442450946, - "timeStamp": 1572867483805, - "warning": false, - "error": true, - "info": false, - "private": false, - "stacktrace": null, - "notes": null, - "chromeContext": false, - "cssSelectors": "", - "exception": { - "_grip": { - "type": "object", - "actor": "server0.conn4.child2/obj58", - "class": "Error", - "ownPropertyLength": 6, - "extensible": true, - "frozen": false, - "sealed": false, - "preview": { - "kind": "Error", - "name": "JuicyError", - "message": "pineapple", - "stack": "@http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html:2:15\n", - "fileName": "http://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", - "lineNumber": 2, - "columnNumber": 15 - } - }, - "actorID": "server0.conn4.child2/obj58" - }, - "hasException": true + "cssSelectors": "" }, "type": "pageError" }); diff --git a/devtools/client/webconsole/test/node/mocha-test-setup.js b/devtools/client/webconsole/test/node/mocha-test-setup.js index 8dd51517884d..b222c689ca8b 100644 --- a/devtools/client/webconsole/test/node/mocha-test-setup.js +++ b/devtools/client/webconsole/test/node/mocha-test-setup.js @@ -136,8 +136,7 @@ requireHacker.global_hook("default", (path, module) => { Services: () => `module.exports = require("devtools-services")`, "devtools/server/devtools-server": () => `module.exports = {DevToolsServer: {}}`, - "devtools/client/shared/components/SmartTrace": () => - "module.exports = () => null;", + "devtools/client/shared/components/SmartTrace": () => "{}", "devtools/client/netmonitor/src/components/TabboxPanel": () => "{}", "devtools/client/webconsole/utils/context-menu": () => "{}", "devtools/client/shared/telemetry": () => `module.exports = function() { diff --git a/devtools/client/webconsole/types.js b/devtools/client/webconsole/types.js index 5d9ab9828d09..2301ced19842 100644 --- a/devtools/client/webconsole/types.js +++ b/devtools/client/webconsole/types.js @@ -55,7 +55,6 @@ exports.ConsoleMessage = function(props) { private: false, logpointId: undefined, chromeContext: false, - hasException: false, }, props ); diff --git a/devtools/client/webconsole/utils/messages.js b/devtools/client/webconsole/utils/messages.js index b3bbc8afb3fd..a690cfeb3c00 100644 --- a/devtools/client/webconsole/utils/messages.js +++ b/devtools/client/webconsole/utils/messages.js @@ -334,8 +334,6 @@ function transformPageErrorPacket(packet) { frame, errorMessageName: pageError.errorMessageName, exceptionDocURL: pageError.exceptionDocURL, - hasException: pageError.hasException, - parameters: pageError.hasException ? [pageError.exception] : null, timeStamp: pageError.timeStamp, notes: pageError.notes, private: pageError.private, @@ -372,7 +370,6 @@ function transformEvaluationResultPacket(packet) { exceptionDocURL, exception, exceptionStack, - hasException, frame, result, helperResult, @@ -380,27 +377,22 @@ function transformEvaluationResultPacket(packet) { notes, } = packet; - let parameter; + const parameter = + helperResult && helperResult.object ? helperResult.object : result; - if (hasException) { - // If we have an exception, we prefix it, and we reset the exception message, as we're - // not going to use it. - parameter = exception; - exceptionMessage = null; - } else if (helperResult?.object) { - parameter = helperResult.object; - } else if (helperResult?.type === "error") { + if (helperResult && helperResult.type === "error") { try { exceptionMessage = l10n.getStr(helperResult.message); } catch (ex) { exceptionMessage = helperResult.message; } - } else { - parameter = result; + } else if (typeof exception === "string") { + // Wrap thrown strings in Error objects, so `throw "foo"` outputs "Error: foo" + exceptionMessage = new Error(exceptionMessage).toString(); } const level = - typeof exceptionMessage !== "undefined" && packet.exceptionMessage !== null + typeof exceptionMessage !== "undefined" && exceptionMessage !== null ? MESSAGE_LEVEL.ERROR : MESSAGE_LEVEL.LOG; @@ -410,7 +402,6 @@ function transformEvaluationResultPacket(packet) { helperType: helperResult ? helperResult.type : null, level, messageText: exceptionMessage, - hasException, parameters: [parameter], errorMessageName, exceptionDocURL, diff --git a/devtools/client/webconsole/utils/object-inspector.js b/devtools/client/webconsole/utils/object-inspector.js index c8a0f382f7cb..2331c9930c79 100644 --- a/devtools/client/webconsole/utils/object-inspector.js +++ b/devtools/client/webconsole/utils/object-inspector.js @@ -89,7 +89,6 @@ function getObjectInspector( openLink: serviceContainer.openLink, sourceMapService: serviceContainer.sourceMapService, customFormat: override.customFormat !== false, - urlCropLimit: 120, renderStacktrace: stacktrace => createElement(SmartTrace, { key: "stacktrace", diff --git a/devtools/server/actors/webconsole.js b/devtools/server/actors/webconsole.js index 04229e0ab8b4..ec4d44948d13 100644 --- a/devtools/server/actors/webconsole.js +++ b/devtools/server/actors/webconsole.js @@ -1294,7 +1294,6 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, { exceptionMessage: this._createStringGrip(errorMessage), exceptionDocURL: errorDocURL, exceptionStack, - hasException: errorGrip !== null, errorMessageName, frame, helperResult: helperResult, @@ -1696,7 +1695,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, { columnNumber = stack[0].columnNumber; } - const result = { + return { errorMessage: this._createStringGrip(pageError.errorMessage), errorMessageName: pageError.errorMessageName, exceptionDocURL: ErrorDocs.GetURL(pageError), @@ -1717,21 +1716,6 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, { chromeContext: pageError.isFromChromeContext, cssSelectors: pageError.cssSelectors, }; - - // If the pageError does have an exception object, we want to return the grip for it, - // but only if we do manage to get the grip, as we're checking the property on the - // client to render things differently. - if (pageError.hasException) { - try { - const obj = this.makeDebuggeeValue(pageError.exception); - if (obj?.class !== "DeadObject") { - result.exception = this.createValueGrip(obj); - result.hasException = true; - } - } catch (e) {} - } - - return result; }, /** diff --git a/devtools/shared/specs/webconsole.js b/devtools/shared/specs/webconsole.js index 3f72890e888e..efc130133957 100644 --- a/devtools/shared/specs/webconsole.js +++ b/devtools/shared/specs/webconsole.js @@ -52,7 +52,6 @@ const webconsoleSpecPrototype = { exceptionMessage: Option(0, "nullable:string"), exceptionDocURL: Option(0, "nullable:string"), exceptionStack: Option(0, "nullable:json"), - hasException: Option(0, "nullable:boolean"), frame: Option(0, "nullable:json"), helperResult: Option(0, "nullable:json"), input: Option(0, "nullable:string"),