Title: [234780] trunk
Revision
234780
Author
[email protected]
Date
2018-08-10 19:43:47 -0700 (Fri, 10 Aug 2018)

Log Message

Web Inspector: console.log fires getters for deep properties
https://bugs.webkit.org/show_bug.cgi?id=187542
<rdar://problem/42873158>

Patch by Joseph Pecoraro <[email protected]> on 2018-08-10
Reviewed by Saam Barati.

Source/_javascript_Core:

* inspector/InjectedScriptSource.js:
(RemoteObject.prototype._isPreviewableObject):
Avoid getters/setters when checking for simple properties to preview.
Here we avoid invoking `object[property]` if it could be a user getter.

LayoutTests:

* inspector/injected-script/avoid-getter-invocation-expected.txt: Added.
* inspector/injected-script/avoid-getter-invocation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234779 => 234780)


--- trunk/LayoutTests/ChangeLog	2018-08-11 02:21:10 UTC (rev 234779)
+++ trunk/LayoutTests/ChangeLog	2018-08-11 02:43:47 UTC (rev 234780)
@@ -1,5 +1,16 @@
 2018-08-10  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: console.log fires getters for deep properties
+        https://bugs.webkit.org/show_bug.cgi?id=187542
+        <rdar://problem/42873158>
+
+        Reviewed by Saam Barati.
+
+        * inspector/injected-script/avoid-getter-invocation-expected.txt: Added.
+        * inspector/injected-script/avoid-getter-invocation.html: Added.
+
+2018-08-10  Joseph Pecoraro  <[email protected]>
+
         LayoutTest inspector/worker/debugger-pause.html is a flaky failure
         https://bugs.webkit.org/show_bug.cgi?id=164833
         <rdar://problem/29295404>

Added: trunk/LayoutTests/inspector/injected-script/avoid-getter-invocation-expected.txt (0 => 234780)


--- trunk/LayoutTests/inspector/injected-script/avoid-getter-invocation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/injected-script/avoid-getter-invocation-expected.txt	2018-08-11 02:43:47 UTC (rev 234780)
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: line 11: [object Object]
+CONSOLE MESSAGE: line 12: [object Object]
+CONSOLE MESSAGE: line 13: [object Object]
+Test that certain InjectedScriptSource operations do not invoke user getters.
+
+
+== Running test suite: InjectedScript.GetterInvocation.Preview
+-- Running test case: InjectedScript.GetterInvocation.Preview
+

Added: trunk/LayoutTests/inspector/injected-script/avoid-getter-invocation.html (0 => 234780)


--- trunk/LayoutTests/inspector/injected-script/avoid-getter-invocation.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/injected-script/avoid-getter-invocation.html	2018-08-11 02:43:47 UTC (rev 234780)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerLogs() {
+    let test = {};
+    Object.defineProperty(test, "foo", {
+        get() { console.log("FAILURE: Should not fire getter") }
+    });
+    console.log(test);
+    console.log({test});
+    console.log([test]);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("InjectedScript.GetterInvocation.Preview");
+
+    suite.addTestCase({
+        name: "InjectedScript.GetterInvocation.Preview",
+        description: "Getters should not be invoked during object previews.",
+        async test() {
+            await InspectorTest.evaluateInPage(`triggerLogs()`);
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test that certain InjectedScriptSource operations do not invoke user getters.</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (234779 => 234780)


--- trunk/Source/_javascript_Core/ChangeLog	2018-08-11 02:21:10 UTC (rev 234779)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-08-11 02:43:47 UTC (rev 234780)
@@ -1,3 +1,16 @@
+2018-08-10  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: console.log fires getters for deep properties
+        https://bugs.webkit.org/show_bug.cgi?id=187542
+        <rdar://problem/42873158>
+
+        Reviewed by Saam Barati.
+
+        * inspector/InjectedScriptSource.js:
+        (RemoteObject.prototype._isPreviewableObject):
+        Avoid getters/setters when checking for simple properties to preview.
+        Here we avoid invoking `object[property]` if it could be a user getter.
+
 2018-08-10  Keith Miller  <[email protected]>
 
         Slicing an ArrayBuffer with a long number returns an ArrayBuffer with byteLength zero

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (234779 => 234780)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2018-08-11 02:21:10 UTC (rev 234779)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2018-08-11 02:43:47 UTC (rev 234780)
@@ -1286,12 +1286,15 @@
         if (object.__proto__ && object.__proto__.__proto__)
             return false;
 
-        // Objects are simple if they have 3 or less simple properties.
+        // Objects are simple if they have 3 or less simple value properties.
         let ownPropertyNames = Object.getOwnPropertyNames(object);
         if (ownPropertyNames.length > 3)
             return false;
         for (let i = 0; i < ownPropertyNames.length; ++i) {
             let propertyName = ownPropertyNames[i];
+            let descriptor = Object.getOwnPropertyDescriptor(object, propertyName);
+            if (descriptor && !("value" in descriptor))
+                return false;
             if (!this._isPreviewableObjectInternal(object[propertyName], knownObjects, depth))
                 return false;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to