Bug 1476605 - Fix Error rep failure when stacktrace is a longString; r=sole.
The actual fix for this issue will come in a future
reps bundle when https://github.com/devtools-html/debugger.html/pull/6705
gets merged.
But, I do want this change to be uplifted to release, and it should be
easier to only apply this simple change than the whole next release
which would contain unrelated code changes.
Also, this patch introduces a test to make sure we don't ever regress
this.
MozReview-Commit-ID: 3QPrx3TLln0
--- a/devtools/client/shared/components/reps/reps.js
+++ b/devtools/client/shared/components/reps/reps.js
@@ -1973,17 +1973,17 @@ function getStacktraceElements(props, pr
functionName = "<anonymous>";
}
let onLocationClick;
// Given the input: "scriptLocation:2:100"
// Result:
// ["scriptLocation:2:100", "scriptLocation", "2", "100"]
const locationParts = location.match(/^(.*):(\d+):(\d+)$/);
- if (props.onViewSourceInDebugger && location && !IGNORED_SOURCE_URLS.includes(locationParts[1]) && locationParts) {
+ if (props.onViewSourceInDebugger && location && locationParts && !IGNORED_SOURCE_URLS.includes(locationParts[1])) {
const [, url, line, column] = locationParts;
onLocationClick = e => {
// Don't trigger ObjectInspector expand/collapse.
e.stopPropagation();
props.onViewSourceInDebugger({
url,
line: Number(line),
column: Number(column)
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -271,16 +271,17 @@ subsuite = clipboard
[browser_webconsole_context_menu_object_in_sidebar.js]
[browser_webconsole_context_menu_open_url.js]
[browser_webconsole_context_menu_store_as_global.js]
[browser_webconsole_csp_ignore_reflected_xss_message.js]
[browser_webconsole_csp_violation.js]
[browser_webconsole_cspro.js]
[browser_webconsole_document_focus.js]
[browser_webconsole_duplicate_errors.js]
+[browser_webconsole_error_with_longstring_stack.js]
[browser_webconsole_error_with_unicode.js]
[browser_webconsole_errors_after_page_reload.js]
[browser_webconsole_eval_in_debugger_stackframe.js]
[browser_webconsole_eval_in_debugger_stackframe2.js]
[browser_webconsole_execution_scope.js]
[browser_webconsole_external_script_errors.js]
[browser_webconsole_file_uri.js]
skip-if = true # Bug 1404382
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_error_with_longstring_stack.js
@@ -0,0 +1,29 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Check if an error with a longString stack is displayed as expected.
+
+"use strict";
+
+const MESSAGE = "Error with longString stack";
+const TEST_URI = `data:text/html;charset=utf8,<script>
+ const x = new Error("longString stack");
+ x.stack = "s@http://exampl.com:1:1\\n".repeat(1000);
+ console.log("${MESSAGE}", x);
+</script>`;
+
+add_task(async function() {
+ const hud = await openNewTabAndConsole(TEST_URI);
+
+ info("Wait for the error to be logged");
+ const msgNode = await waitFor(() => findMessage(hud, MESSAGE));
+ ok(msgNode, `Error logged`);
+
+ const errorNode = msgNode.querySelector(".objectBox-stackTrace");
+ ok(errorNode, "The error object is logged as expected");
+ ok(errorNode.textContent.includes("longString stack"));
+ ok(errorNode.querySelectorAll(".objectBox-stackTrace-fn").length > 0,
+ "Frames functions are displayed");
+ ok(errorNode.querySelectorAll(".objectBox-stackTrace-location").length > 0,
+ "Frames location are displayed");
+});