⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 294844 in webkit


Ignore:
Timestamp:
May 25, 2022, 4:49:55 PM (4 years ago)
Author:
Alan Coon
Message:

Cherry-pick r294234. rdar://problem/93602100

Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
​https://bugs.webkit.org/show_bug.cgi?id=240366

Reviewed by Devin Rousso.

Source/JavaScriptCore:

  • inspector/protocol/DOM.json:

Source/WebCore:

Added test cases to inspector/model/dom-node.html

After r266885, there is no path to handle the possibility that there may not be a resulting node for calls to
DOM.querySelector. To correct this, mark the return value as optional (Web Inspector frontend already treats
it as optional) and return early if there was no Element matching the selector.

  • inspector/agents/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::querySelector):
  • inspector/agents/InspectorDOMAgent.h:

LayoutTests:

  • inspector/model/dom-node.html:
  • inspector/model/dom-node-expected.txt:

Canonical link: ​https://commits.webkit.org/250592@main
git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@294234 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-613-branch
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-613-branch/LayoutTests/ChangeLog

    r294840 r294844  
     12022-05-19  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r294234. rdar://problem/93602100
     4
     5    Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
     6    https://bugs.webkit.org/show_bug.cgi?id=240366
     7   
     8    Reviewed by Devin Rousso.
     9   
     10    Source/JavaScriptCore:
     11   
     12    * inspector/protocol/DOM.json:
     13   
     14    Source/WebCore:
     15   
     16    Added test cases to inspector/model/dom-node.html
     17   
     18    After r266885, there is no path to handle the possibility that there may not be a resulting node for calls to
     19    `DOM.querySelector`. To correct this, mark the return value as optional (Web Inspector frontend already treats
     20    it as optional) and return early if there was no Element matching the selector.
     21   
     22    * inspector/agents/InspectorDOMAgent.cpp:
     23    (WebCore::InspectorDOMAgent::querySelector):
     24    * inspector/agents/InspectorDOMAgent.h:
     25   
     26    LayoutTests:
     27   
     28    * inspector/model/dom-node.html:
     29    * inspector/model/dom-node-expected.txt:
     30   
     31    Canonical link: https://commits.webkit.org/250592@main
     32    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     33
     34    2022-05-16  Patrick Angle  <pangle@apple.com>
     35
     36            Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
     37            https://bugs.webkit.org/show_bug.cgi?id=240366
     38
     39            Reviewed by Devin Rousso.
     40
     41            * inspector/model/dom-node.html:
     42            * inspector/model/dom-node-expected.txt:
     43
    1442022-05-19  Alan Coon  <alancoon@apple.com>
    245
  • branches/safari-613-branch/LayoutTests/inspector/model/dom-node-expected.txt

    r222483 r294844  
    88data-item="test-data"
    99
     10-- Running test case: WI.DOMNode.querySelector
     11Calling querySelector("#test-id") on document node.
     12PASS: `querySelector("#test-id")` should return a WI.DOMNode
     13Calling querySelector("#non-existent-id") on document node.
     14PASS: `querySelector("#non-existent-id")` should return null.
     15Calling querySelector("^\_(invalid selector)_/^") on document node.
     16PASS: `querySelector` with an invalid selector should throw a SyntaxError.
     17
  • branches/safari-613-branch/LayoutTests/inspector/model/dom-node.html

    r253242 r294844  
    2626    });
    2727
     28    suite.addTestCase({
     29        name: "WI.DOMNode.querySelector",
     30        description: "Test getting a child node via querySelector.",
     31        async test() {
     32            let documentNode = await WI.domManager.requestDocument();
     33
     34            function querySelector(selector) {
     35                InspectorTest.log(`Calling querySelector("${selector}") on document node.`);
     36                return documentNode.querySelector(selector).then((nodeId) => {
     37                    if (!nodeId)
     38                        return null;
     39                    return WI.domManager.nodeForId(nodeId);
     40                });
     41            }
     42
     43            let nodeFromQueryingExistingId = await querySelector("#test-id");
     44            InspectorTest.expectThat(nodeFromQueryingExistingId instanceof WI.DOMNode, "`querySelector(\"#test-id\")` should return a WI.DOMNode");
     45
     46            let nodeFromQueryingNonExistantId = await querySelector("#non-existent-id");
     47            InspectorTest.expectNull(nodeFromQueryingNonExistantId, "`querySelector(\"#non-existent-id\")` should return null.");
     48
     49            await querySelector("^\\_(invalid selector)_/^").catch((error) => {
     50                InspectorTest.expectEqual(error.message, "SyntaxError", "`querySelector` with an invalid selector should throw a SyntaxError.");
     51            });
     52
     53        }
     54    });
     55
    2856    suite.runTestCasesAndFinish();
    2957}
  • branches/safari-613-branch/Source/JavaScriptCore/ChangeLog

    r294296 r294844  
     12022-05-19  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r294234. rdar://problem/93602100
     4
     5    Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
     6    https://bugs.webkit.org/show_bug.cgi?id=240366
     7   
     8    Reviewed by Devin Rousso.
     9   
     10    Source/JavaScriptCore:
     11   
     12    * inspector/protocol/DOM.json:
     13   
     14    Source/WebCore:
     15   
     16    Added test cases to inspector/model/dom-node.html
     17   
     18    After r266885, there is no path to handle the possibility that there may not be a resulting node for calls to
     19    `DOM.querySelector`. To correct this, mark the return value as optional (Web Inspector frontend already treats
     20    it as optional) and return early if there was no Element matching the selector.
     21   
     22    * inspector/agents/InspectorDOMAgent.cpp:
     23    (WebCore::InspectorDOMAgent::querySelector):
     24    * inspector/agents/InspectorDOMAgent.h:
     25   
     26    LayoutTests:
     27   
     28    * inspector/model/dom-node.html:
     29    * inspector/model/dom-node-expected.txt:
     30   
     31    Canonical link: https://commits.webkit.org/250592@main
     32    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     33
     34    2022-05-16  Patrick Angle  <pangle@apple.com>
     35
     36            Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
     37            https://bugs.webkit.org/show_bug.cgi?id=240366
     38
     39            Reviewed by Devin Rousso.
     40
     41            * inspector/protocol/DOM.json:
     42
    1432022-05-16  Alan Coon  <alancoon@apple.com>
    244
  • branches/safari-613-branch/Source/JavaScriptCore/inspector/protocol/DOM.json

    r278785 r294844  
    196196            ],
    197197            "returns": [
    198                 { "name": "nodeId", "$ref": "NodeId", "description": "Query selector result." }
     198                { "name": "nodeId", "$ref": "NodeId", "optional": true, "description": "Query selector result." }
    199199            ]
    200200        },
  • branches/safari-613-branch/Source/WebCore/ChangeLog

    r294843 r294844  
     12022-05-19  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r294234. rdar://problem/93602100
     4
     5    Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
     6    https://bugs.webkit.org/show_bug.cgi?id=240366
     7   
     8    Reviewed by Devin Rousso.
     9   
     10    Source/JavaScriptCore:
     11   
     12    * inspector/protocol/DOM.json:
     13   
     14    Source/WebCore:
     15   
     16    Added test cases to inspector/model/dom-node.html
     17   
     18    After r266885, there is no path to handle the possibility that there may not be a resulting node for calls to
     19    `DOM.querySelector`. To correct this, mark the return value as optional (Web Inspector frontend already treats
     20    it as optional) and return early if there was no Element matching the selector.
     21   
     22    * inspector/agents/InspectorDOMAgent.cpp:
     23    (WebCore::InspectorDOMAgent::querySelector):
     24    * inspector/agents/InspectorDOMAgent.h:
     25   
     26    LayoutTests:
     27   
     28    * inspector/model/dom-node.html:
     29    * inspector/model/dom-node-expected.txt:
     30   
     31    Canonical link: https://commits.webkit.org/250592@main
     32    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     33
     34    2022-05-16  Patrick Angle  <pangle@apple.com>
     35
     36            Web Inspector: Regression(r266885) Crash sometimes when rehydrating imported audit results
     37            https://bugs.webkit.org/show_bug.cgi?id=240366
     38
     39            Reviewed by Devin Rousso.
     40
     41            Added test cases to inspector/model/dom-node.html
     42
     43            After r266885, there is no path to handle the possibility that there may not be a resulting node for calls to
     44            `DOM.querySelector`. To correct this, mark the return value as optional (Web Inspector frontend already treats
     45            it as optional) and return early if there was no Element matching the selector.
     46
     47            * inspector/agents/InspectorDOMAgent.cpp:
     48            (WebCore::InspectorDOMAgent::querySelector):
     49            * inspector/agents/InspectorDOMAgent.h:
     50
    1512022-05-19  Alan Coon  <alancoon@apple.com>
    252
  • branches/safari-613-branch/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp

    r287327 r294844  
    589589}
    590590
    591 Protocol::ErrorStringOr<Protocol::DOM::NodeId> InspectorDOMAgent::querySelector(Protocol::DOM::NodeId nodeId, const String& selector)
     591Protocol::ErrorStringOr<std::optional<Protocol::DOM::NodeId>> InspectorDOMAgent::querySelector(Protocol::DOM::NodeId nodeId, const String& selector)
    592592{
    593593    Protocol::ErrorString errorString;
    … …  
    603603        return makeUnexpected(InspectorDOMAgent::toErrorString(queryResult.releaseException()));
    604604
    605     auto resultNodeId = pushNodePathToFrontend(errorString, queryResult.releaseReturnValue());
     605    auto* queryResultNode = queryResult.releaseReturnValue();
     606    if (!queryResultNode)
     607        return { };
     608
     609    auto resultNodeId = pushNodePathToFrontend(errorString, queryResultNode);
    606610    if (!resultNodeId)
    607611        return makeUnexpected(errorString);
    608612
    609     return resultNodeId;
     613    return { resultNodeId };
    610614}
    611615
  • branches/safari-613-branch/Source/WebCore/inspector/agents/InspectorDOMAgent.h

    r279439 r294844  
    104104
    105105    // DOMBackendDispatcherHandler
    106     Inspector::Protocol::ErrorStringOr<Inspector::Protocol::DOM::NodeId> querySelector(Inspector::Protocol::DOM::NodeId, const String& selector);
     106    Inspector::Protocol::ErrorStringOr<std::optional<Inspector::Protocol::DOM::NodeId>> querySelector(Inspector::Protocol::DOM::NodeId, const String& selector);
    107107    Inspector::Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Inspector::Protocol::DOM::NodeId>>> querySelectorAll(Inspector::Protocol::DOM::NodeId, const String& selector);
    108108    Inspector::Protocol::ErrorStringOr<Ref<Inspector::Protocol::DOM::Node>> getDocument();
Note: See TracChangeset for help on using the changeset viewer.