Changeset 209958 in webkit


Ignore:
Timestamp:
Dec 16, 2016 9:05:17 PM (7 years ago)
Author:
commit-queue@webkit.org
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 <Joseph Pecoraro> on 2016-12-16
Reviewed by Matt Baker.

Source/JavaScriptCore:

  • 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.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r209956 r209958  
     12016-12-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        JSContext Inspector: Avoid some possible exceptions inspecting a JSContext
     4        https://bugs.webkit.org/show_bug.cgi?id=165986
     5        <rdar://problem/29551379>
     6
     7        Reviewed by Matt Baker.
     8
     9        * inspector/InjectedScriptSource.js:
     10        (InjectedScript.prototype.processProperties):
     11        Prefer String.prototype.endsWith now that it is available.
     12
     13        (InjectedScript.prototype._describe):
     14        Prefer Function.prototype.toString for converting functions to String.
     15        Previously we were doing String(f) which would to Symbol.toPrimitive
     16        conversion which seems unnecessary here.
     17
    1182016-12-16  Michael Catanzaro  <mcatanzaro@igalia.com>
    219
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js

    r208725 r209958  
    5656}
    5757
    58 function endsWith(str, suffix)
    59 {
    60     var position = str.length - suffix.length;
    61     if (position < 0)
    62         return false;
    63     return str.indexOf(suffix, position) === position;
    64 }
    65 
    6658function isSymbol(obj)
    6759{
     
    654646
    655647                if (nativeGettersAsValues) {
    656                     if (endsWith(String(descriptor.get), "[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
     648                    if (String(descriptor.get).endsWith("[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
    657649                        // Developers may create such a descriptor, so we should be resilient:
    658650                        // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p")
     
    816808        // NodeList in JSC is a function, check for array prior to this.
    817809        if (typeof obj === "function")
    818             return toString(obj);
     810            return obj.toString();
    819811
    820812        // If Object, try for a better name from the constructor.
  • trunk/Source/WebInspectorUI/ChangeLog

    r209933 r209958  
     12016-12-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        JSContext Inspector: Avoid some possible exceptions inspecting a JSContext
     4        https://bugs.webkit.org/show_bug.cgi?id=165986
     5        <rdar://problem/29551379>
     6
     7        Reviewed by Matt Baker.
     8
     9        * UserInterface/Base/Main.js:
     10        There will not be a main frame if we are debugging a JSContext.
     11        In those cases do not change the title.
     12
     13        * UserInterface/Views/ResourceSidebarPanel.js:
     14        (WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
     15        There may not be a parent folder in JavaScript inspection. In that case
     16        ScriptTreeElements are added to the Top Level, not folders.
     17
    1182016-12-16  Matt Baker  <mattbaker@apple.com>
    219
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r209882 r209958  
    693693{
    694694    var mainFrame = this.frameResourceManager.mainFrame;
    695     console.assert(mainFrame);
     695    if (!mainFrame)
     696        return;
    696697
    697698    var urlComponents = mainFrame.mainResource.urlComponents;
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js

    r208520 r209958  
    321321        }
    322322
    323         parentFolderTreeElement.representedObject.add(script);
     323        if (parentFolderTreeElement)
     324            parentFolderTreeElement.representedObject.add(script);
    324325
    325326        var scriptTreeElement = new WebInspector.ScriptTreeElement(script);
Note: See TracChangeset for help on using the changeset viewer.