Changeset 253718 in webkit


Ignore:
Timestamp:
Dec 18, 2019, 2:05:27 PM (6 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: Runtime.enable reports duplicates (non existent) contexts
https://bugs.webkit.org/show_bug.cgi?id=204859

Reviewed by Devin Rousso.

Source/WebCore:

Do not report main world context as non-main world one when Runtime.enable is called.

Test: inspector/runtime/executionContextCreated-onEnable.html

  • inspector/agents/page/PageRuntimeAgent.cpp:

(WebCore::PageRuntimeAgent::enable):
(WebCore::PageRuntimeAgent::reportExecutionContextCreation):

Source/WebInspectorUI:

Assert that all contexts added to the list are unique.

  • UserInterface/Models/ExecutionContextList.js:

(WI.ExecutionContextList.prototype.add):

LayoutTests:

Test that only existing contexts are reported.

  • http/tests/inspector/resources/stable-id-map.js: Added.

(TestPage.registerInitializer.window.StableIdMap):
(TestPage.registerInitializer.window.StableIdMap.prototype.get size):
(TestPage.registerInitializer.window.StableIdMap.prototype.get let):
(TestPage.registerInitializer):

  • http/tests/inspector/target/provisional-load-cancels-previous-load.html:
  • inspector/runtime/executionContextCreated-onEnable-expected.txt: Added.
  • inspector/runtime/executionContextCreated-onEnable.html: Added.
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r253705 r253718  
     12019-12-18  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: Runtime.enable reports duplicates (non existent) contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=204859
     5
     6        Reviewed by Devin Rousso.
     7
     8        Test that only existing contexts are reported.
     9
     10        * http/tests/inspector/resources/stable-id-map.js: Added.
     11        (TestPage.registerInitializer.window.StableIdMap):
     12        (TestPage.registerInitializer.window.StableIdMap.prototype.get size):
     13        (TestPage.registerInitializer.window.StableIdMap.prototype.get let):
     14        (TestPage.registerInitializer):
     15        * http/tests/inspector/target/provisional-load-cancels-previous-load.html:
     16        * inspector/runtime/executionContextCreated-onEnable-expected.txt: Added.
     17        * inspector/runtime/executionContextCreated-onEnable.html: Added.
     18
    1192019-12-18  youenn fablet  <youenn@apple.com>
    220
  • trunk/LayoutTests/http/tests/inspector/target/provisional-load-cancels-previous-load-expected.txt

    r253097 r253718  
    44== Running test suite: Target.PSON
    55-- Running test case: ProvisionalPagePaused
    6 Current target is 1.
     6Current target is 0.
     7PASS: Should receive TargetAdded event for target 1.
     8PASS: Target 1 should be provisional.
     9PASS: Target 1 should be paused on start.
     10PASS: Should receive TargetRemoved event for target 1
    711PASS: Should receive TargetAdded event for target 2.
    812PASS: Target 2 should be provisional.
    913PASS: Target 2 should be paused on start.
    10 PASS: Should receive TargetRemoved event for target 2
    11 PASS: Should receive TargetAdded event for target 3.
    12 PASS: Target 3 should be provisional.
    13 PASS: Target 3 should be paused on start.
    14 PASS: Should receive TargetRemoved event for target 1
    15 PASS: Should receive DidCommitProvisionalTarget event 1 => 3.
     14PASS: Should receive TargetRemoved event for target 0
     15PASS: Should receive DidCommitProvisionalTarget event 0 => 2.
    1616PASS: Should have seen 3 different targets.
    1717
  • trunk/LayoutTests/http/tests/inspector/target/provisional-load-cancels-previous-load.html

    r253097 r253718  
    44<meta charset="utf-8">
    55<script src="../resources/inspector-test.js"></script>
     6<script src="../resources/stable-id-map.js"></script>
    67<script>
    78function test()
    89{
    9     let lastAssignedId = 0;
    10     let targetToId = new Map;
    11     function stableTargetId(targetId)
    12     {
    13         let id = targetToId.get(targetId);
    14         if (!id) {
    15             id = ++lastAssignedId;
    16             targetToId.set(targetId, id);
    17         }
    18         return id;
    19     }
    20 
    2110    let suite = InspectorTest.createAsyncSuite("Target.PSON");
    2211
     
    2514        description: "Check that new provisional page can be paused before navigation.",
    2615        test(resolve, reject) {
    27             InspectorTest.log(`Current target is ${stableTargetId(WI.mainTarget.identifier)}.`);
     16            let targetIdMap = new StableIdMap;
     17            InspectorTest.log(`Current target is ${targetIdMap.get(WI.mainTarget.identifier)}.`);
    2818            const url = "http://localhost:8000/inspector/target/provisional-load-cancels-previous-load.html";
    2919            let navigatedTwice = false;
     
    3121            WI.targetManager.addEventListener(WI.TargetManager.Event.TargetAdded, (event) => {
    3222                let target = event.data.target;
    33                 let targetId = stableTargetId(target.identifier);
     23                let targetId = targetIdMap.get(target.identifier);
    3424                InspectorTest.pass(`Should receive TargetAdded event for target ${targetId}.`);
    3525                InspectorTest.expectTrue(target.isProvisional, `Target ${targetId} should be provisional.`);
     
    4636            WI.targetManager.addEventListener(WI.TargetManager.Event.DidCommitProvisionalTarget, (event) => {
    4737                let {previousTargetId, target} = event.data;
    48                 InspectorTest.pass(`Should receive DidCommitProvisionalTarget event ${stableTargetId(previousTargetId)} => ${stableTargetId(target.identifier)}.`);
     38                InspectorTest.pass(`Should receive DidCommitProvisionalTarget event ${targetIdMap.get(previousTargetId)} => ${targetIdMap.get(target.identifier)}.`);
    4939            });
    5040
    5141            WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, (event) =>{
    52                 let targetId = stableTargetId(event.data.target.identifier);
     42                let targetId = targetIdMap.get(event.data.target.identifier);
    5343                InspectorTest.pass(`Should receive TargetRemoved event for target ${targetId}`);
    5444            });
     
    5747            InspectorTest.awaitEvent(FrontendTestHarness.Event.TestPageDidLoad)
    5848            .then(() => {
    59                 InspectorTest.expectEqual(lastAssignedId, 3, `Should have seen 3 different targets.`);
     49                InspectorTest.expectEqual(targetIdMap.size, 3, `Should have seen 3 different targets.`);
    6050            })
    6151            .then(resolve);
  • trunk/Source/WebCore/ChangeLog

    r253717 r253718  
     12019-12-18  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: Runtime.enable reports duplicates (non existent) contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=204859
     5
     6        Reviewed by Devin Rousso.
     7
     8        Do not report main world context as non-main world one when Runtime.enable is called.
     9
     10        Test: inspector/runtime/executionContextCreated-onEnable.html
     11
     12        * inspector/agents/page/PageRuntimeAgent.cpp:
     13        (WebCore::PageRuntimeAgent::enable):
     14        (WebCore::PageRuntimeAgent::reportExecutionContextCreation):
     15
    1162019-12-18  Antti Koivisto  <antti@apple.com>
    217
  • trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp

    r253166 r253718  
    7171void PageRuntimeAgent::enable(ErrorString& errorString)
    7272{
    73     bool enabled = m_instrumentingAgents.pageRuntimeAgent() == this;
     73    if (m_instrumentingAgents.pageRuntimeAgent() == this)
     74        return;
    7475
    7576    InspectorRuntimeAgent::enable(errorString);
     77    if (!errorString.isEmpty())
     78        return;
     79
     80    // Report initial contexts before enabling instrumentation as the reporting
     81    // can force creation of script state which could result in duplicate notifications.
     82    reportExecutionContextCreation();
    7683
    7784    m_instrumentingAgents.setPageRuntimeAgent(this);
    78 
    79     if (!enabled)
    80         reportExecutionContextCreation();
    8185}
    8286
     
    149153        if (isolatedContexts.isEmpty())
    150154            continue;
    151         for (auto& context : isolatedContexts)
    152             notifyContextCreated(frameId, context.first, context.second, false);
     155        for (auto& [globalObject, securityOrigin] : isolatedContexts) {
     156            if (globalObject != scriptState)
     157                notifyContextCreated(frameId, globalObject, securityOrigin, false);
     158        }
    153159        isolatedContexts.clear();
    154160    }
  • trunk/Source/WebInspectorUI/ChangeLog

    r253706 r253718  
     12019-12-18  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: Runtime.enable reports duplicates (non existent) contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=204859
     5
     6        Reviewed by Devin Rousso.
     7
     8        Assert that all contexts added to the list are unique.
     9
     10        * UserInterface/Models/ExecutionContextList.js:
     11        (WI.ExecutionContextList.prototype.add):
     12
    1132019-12-18  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Models/ExecutionContextList.js

    r220119 r253718  
    4646    add(context)
    4747    {
    48         // FIXME: The backend sends duplicate page context execution contexts with the same id. Why?
     48        // COMPATIBILITY (iOS 13.0): Older iOS releases will send duplicates.
     49        // Newer releases will not and this check should be removed eventually.
    4950        if (context.isPageContext && this._pageExecutionContext) {
    5051            console.assert(context.id === this._pageExecutionContext.id);
Note: See TracChangeset for help on using the changeset viewer.