Bug 1481833 - Fix expanding getter returning longString; r=Honza a=lizzard
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Thu, 09 Aug 2018 15:01:45 +0000
changeset 478386 fe256fdb428c
parent 478385 1302ee69d602
child 478387 f3d5a8acef59
push id9645
push userarchaeopteryx@coole-files.de
push dateSun, 12 Aug 2018 08:18:24 +0000
treeherdermozilla-beta@fe256fdb428c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, lizzard
bugs1481833
milestone62.0
Bug 1481833 - Fix expanding getter returning longString; r=Honza a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D2949
devtools/client/shared/components/reps/reps.js
devtools/client/webconsole/test/mochitest/browser.ini
devtools/client/webconsole/test/mochitest/browser_webconsole_longstring_getter.js
--- a/devtools/client/shared/components/reps/reps.js
+++ b/devtools/client/shared/components/reps/reps.js
@@ -3376,17 +3376,23 @@ function makeNodesForProperties(objProps
 }
 
 function setNodeFullText(loadedProps, node) {
   if (nodeHasFullText(node)) {
     return node;
   }
 
   if (nodeIsLongString(node)) {
-    node.contents.value.fullText = loadedProps.fullText;
+    const {fullText} = loadedProps;
+
+    if (node.contents.value) {
+      node.contents.value.fullText = fullText;
+    } else if (node.contents.getterValue) {
+      node.contents.getterValue.fullText = fullText;
+    }
   }
 
   return node;
 }
 
 function makeNodeForPrototype(objProps, parent) {
   const { prototype } = objProps || {};
 
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -302,16 +302,17 @@ skip-if = true #	Bug 1404382
 [browser_webconsole_js_input_expansion.js]
 [browser_webconsole_keyboard_accessibility.js]
 [browser_webconsole_location_debugger_link.js]
 [browser_webconsole_location_scratchpad_link.js]
 [browser_webconsole_location_styleeditor_link.js]
 [browser_webconsole_logErrorInPage.js]
 [browser_webconsole_loglimit.js]
 [browser_webconsole_logWarningInPage.js]
+[browser_webconsole_longstring_getter.js]
 [browser_webconsole_longstring.js]
 [browser_webconsole_message_categories.js]
 [browser_webconsole_multiple_windows_and_tabs.js]
 [browser_webconsole_network_attach.js]
 [browser_webconsole_network_exceptions.js]
 [browser_webconsole_network_messages_expand.js]
 skip-if = (os == 'linux') || (os == 'win' && os_version == '10.0' && debug && bits == 64)  # Bug 1429361, disabled on Linux/Win for frequent failures
 [browser_webconsole_network_messages_openinnet.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_longstring_getter.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that getter properties that return long strings can be expanded. See Bug 1481833.
+
+"use strict";
+
+const LONGSTRING = "a ".repeat(10000);
+const TEST_URI = `data:text/html,Test expanding longString getter property
+  <svg>
+    <image xlink:href="data:image/png;base64,${LONGSTRING}"></image>
+  </svg>
+  <script>
+    console.dir("Test message", document.querySelector("svg image").href);
+  </script>`;
+
+add_task(async function() {
+  const hud = await openNewTabAndConsole(TEST_URI);
+
+  // Retrieve the logged message.
+  const message = await waitFor(() => findMessage(hud, "Test message"));
+
+  // Wait until the SVGAnimatedString is expanded.
+  await waitFor(() => message.querySelectorAll(".arrow").length > 1);
+
+  const arrow = message.querySelectorAll(".arrow")[1];
+  ok(arrow, "longString expand arrow is shown");
+
+  info("wait for long string expansion");
+  const onLongStringFullTextDisplayed = waitFor(() => findMessage(hud, LONGSTRING));
+  arrow.click();
+  await onLongStringFullTextDisplayed;
+
+  ok(true, "The full text of the longString is displayed");
+
+  info("wait for long string collapse");
+  const onLongStringCollapsed = waitFor(() => !findMessage(hud, LONGSTRING));
+  arrow.click();
+  await onLongStringCollapsed;
+
+  ok(true, "The longString can be collapsed");
+});