Bug 1476605 - Fix Error rep failure when stacktrace is a longString. r=sole, a=RyanVM
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Thu, 26 Jul 2018 15:18:08 +0200
changeset 473826 0be81adef007
parent 473825 338feb0782ff
child 473827 975058795980
push id1751
push userryanvm@gmail.com
push date2018-08-07 17:02 +0000
treeherdermozilla-release@975058795980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssole, RyanVM
bugs1476605
milestone61.0.2
Bug 1476605 - Fix Error rep failure when stacktrace is a longString. r=sole, a=RyanVM 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
devtools/client/shared/components/reps/reps.js
devtools/client/webconsole/test/mochitest/browser.ini
devtools/client/webconsole/test/mochitest/browser_webconsole_error_with_longstring_stack.js
--- a/devtools/client/shared/components/reps/reps.js
+++ b/devtools/client/shared/components/reps/reps.js
@@ -1901,17 +1901,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])) {
       let [, 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
@@ -262,16 +262,17 @@ subsuite = clipboard
 [browser_webconsole_context_menu_open_url.js]
 [browser_webconsole_context_menu_store_as_global.js]
 [browser_webconsole_csp_ignore_reflected_xss_message.js]
 skip-if = (e10s && debug) || (e10s && os == 'win') # Bug 1221499 enabled these on windows
 [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");
+});