Title: [209958] trunk/Source
Revision
209958
Author
commit-qu...@webkit.org
Date
2016-12-16 21:05:17 -0800 (Fri, 16 Dec 2016)

Log Message

JSContext Inspector: Avoid some possible exceptions inspecting a JSContext
https://bugs.webkit.org/show_bug.cgi?id=165986
<rdar://problem/29551379>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2016-12-16
Reviewed by Matt Baker.

Source/_javascript_Core:

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.processProperties):
Prefer String.prototype.endsWith now that it is available.

(InjectedScript.prototype._describe):
Prefer Function.prototype.toString for converting functions to String.
Previously we were doing String(f) which would to Symbol.toPrimitive
conversion which seems unnecessary here.

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
There will not be a main frame if we are debugging a JSContext.
In those cases do not change the title.

* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
There may not be a parent folder in _javascript_ inspection. In that case
ScriptTreeElements are added to the Top Level, not folders.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (209957 => 209958)


--- trunk/Source/_javascript_Core/ChangeLog	2016-12-17 04:04:08 UTC (rev 209957)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-12-17 05:05:17 UTC (rev 209958)
@@ -1,3 +1,20 @@
+2016-12-16  Joseph Pecoraro  <pecor...@apple.com>
+
+        JSContext Inspector: Avoid some possible exceptions inspecting a JSContext
+        https://bugs.webkit.org/show_bug.cgi?id=165986
+        <rdar://problem/29551379>
+
+        Reviewed by Matt Baker.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.prototype.processProperties):
+        Prefer String.prototype.endsWith now that it is available.
+
+        (InjectedScript.prototype._describe):
+        Prefer Function.prototype.toString for converting functions to String.
+        Previously we were doing String(f) which would to Symbol.toPrimitive
+        conversion which seems unnecessary here.
+
 2016-12-16  Michael Catanzaro  <mcatanz...@igalia.com>
 
         Unreviewed, fix GCC 6 build failure after r209952

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (209957 => 209958)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-12-17 04:04:08 UTC (rev 209957)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-12-17 05:05:17 UTC (rev 209958)
@@ -55,14 +55,6 @@
     return "" + (obj >>> 0) === obj;
 }
 
-function endsWith(str, suffix)
-{
-    var position = str.length - suffix.length;
-    if (position < 0)
-        return false;
-    return str.indexOf(suffix, position) === position;
-}
-
 function isSymbol(obj)
 {
     return typeof obj === "symbol";
@@ -653,7 +645,7 @@
                 }
 
                 if (nativeGettersAsValues) {
-                    if (endsWith(String(descriptor.get), "[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
+                    if (String(descriptor.get).endsWith("[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
                         // Developers may create such a descriptor, so we should be resilient:
                         // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p")
                         var fakeDescriptor = createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, true);
@@ -815,7 +807,7 @@
 
         // NodeList in JSC is a function, check for array prior to this.
         if (typeof obj === "function")
-            return toString(obj);
+            return obj.toString();
 
         // If Object, try for a better name from the constructor.
         if (className === "Object") {

Modified: trunk/Source/WebInspectorUI/ChangeLog (209957 => 209958)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-12-17 04:04:08 UTC (rev 209957)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-12-17 05:05:17 UTC (rev 209958)
@@ -1,3 +1,20 @@
+2016-12-16  Joseph Pecoraro  <pecor...@apple.com>
+
+        JSContext Inspector: Avoid some possible exceptions inspecting a JSContext
+        https://bugs.webkit.org/show_bug.cgi?id=165986
+        <rdar://problem/29551379>
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Base/Main.js:
+        There will not be a main frame if we are debugging a JSContext.
+        In those cases do not change the title.
+
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
+        There may not be a parent folder in _javascript_ inspection. In that case
+        ScriptTreeElements are added to the Top Level, not folders.
+
 2016-12-16  Matt Baker  <mattba...@apple.com>
 
         Web Inspector: REGRESSION (r209882): Opening find banner in editor causes UI to hang

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (209957 => 209958)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-12-17 04:04:08 UTC (rev 209957)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-12-17 05:05:17 UTC (rev 209958)
@@ -692,7 +692,8 @@
 WebInspector.updateWindowTitle = function()
 {
     var mainFrame = this.frameResourceManager.mainFrame;
-    console.assert(mainFrame);
+    if (!mainFrame)
+        return;
 
     var urlComponents = mainFrame.mainResource.urlComponents;
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (209957 => 209958)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js	2016-12-17 04:04:08 UTC (rev 209957)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js	2016-12-17 05:05:17 UTC (rev 209958)
@@ -320,7 +320,8 @@
             }
         }
 
-        parentFolderTreeElement.representedObject.add(script);
+        if (parentFolderTreeElement)
+            parentFolderTreeElement.representedObject.add(script);
 
         var scriptTreeElement = new WebInspector.ScriptTreeElement(script);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to