Changeset 248943 in webkit


Ignore:
Timestamp:
Aug 21, 2019 9:50:14 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Page: re-add enable/disable after r248454
https://bugs.webkit.org/show_bug.cgi?id=200947

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

We shouldn't design the agent system with only Web Inspector in mind. Other clients may want
to have different functionality, not being told about frames creation/updates/destruction.
In these cases, we should have graceful error message failures for other agents that rely on
the Page agent.

  • inspector/protocol/Page.json:

Source/WebCore:

We shouldn't design the agent system with only Web Inspector in mind. Other clients may want
to have different functionality, not being told about frames creation/updates/destruction.
In these cases, we should have graceful error message failures for other agents that rely on
the Page agent.

  • inspector/agents/InspectorPageAgent.h:
  • inspector/agents/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::didCreateFrontendAndBackend):
(WebCore::InspectorPageAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorPageAgent::enable): Added.
(WebCore::InspectorPageAgent::disable): Added.

  • inspector/agents/InspectorApplicationCacheAgent.cpp:

(WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus):
(WebCore::InspectorApplicationCacheAgent::getFramesWithManifests):
(WebCore::InspectorApplicationCacheAgent::assertFrameWithDocumentLoader):

  • inspector/agents/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::createStyleSheet):

  • inspector/agents/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::highlightSelector):
(WebCore::InspectorDOMAgent::highlightFrame):
(WebCore::InspectorDOMAgent::buildObjectForNode):

  • inspector/agents/InspectorTimelineAgent.cpp:

(WebCore::InspectorTimelineAgent::setFrameIdentifier):

  • inspector/agents/page/PageNetworkAgent.cpp:

(WebCore::PageNetworkAgent::loaderIdentifier):
(WebCore::PageNetworkAgent::frameIdentifier):
(WebCore::PageNetworkAgent::scriptExecutionContext):

  • inspector/agents/page/PageRuntimeAgent.cpp:

(WebCore::PageRuntimeAgent::didCreateMainWorldContext):
(WebCore::PageRuntimeAgent::reportExecutionContextCreation):

Source/WebInspectorUI:

We shouldn't design the agent system with only Web Inspector in mind. Other clients may want
to have different functionality, not being told about frames creation/updates/destruction.
In these cases, we should have graceful error message failures for other agents that rely on
the Page agent.

  • UserInterface/Controllers/NetworkManager.js:

(WI.NetworkManager.prototype.initializeTarget):

LayoutTests:

  • http/tests/inspector/page/loading-iframe-document-node.html:
  • inspector/css/getMatchedStylesForNode.html:
  • inspector/css/getMatchedStylesForNode-expected.txt:
  • inspector/page/archive.html:
  • inspector/page/frameScheduledNavigation.html:
  • inspector/page/frameScheduledNavigation-async-delegates.html:
  • inspector/page/frameStartedLoading.html:
  • inspector/page/media-query-list-listener-exception.html:
  • inspector/timeline/line-column.html:
Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r248942 r248943  
     12019-08-21  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Page: re-add enable/disable after r248454
     4        https://bugs.webkit.org/show_bug.cgi?id=200947
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * http/tests/inspector/page/loading-iframe-document-node.html:
     9        * inspector/css/getMatchedStylesForNode.html:
     10        * inspector/css/getMatchedStylesForNode-expected.txt:
     11        * inspector/page/archive.html:
     12        * inspector/page/frameScheduledNavigation.html:
     13        * inspector/page/frameScheduledNavigation-async-delegates.html:
     14        * inspector/page/frameStartedLoading.html:
     15        * inspector/page/media-query-list-listener-exception.html:
     16        * inspector/timeline/line-column.html:
     17
    1182019-08-21  Rob Buis  <rbuis@igalia.com>
    219
  • trunk/LayoutTests/http/tests/inspector/page/loading-iframe-document-node.html

    r248454 r248943  
    3636    function step1_bootstrap() {
    3737        ProtocolTest.log("step1_bootstrap");
    38         // Enable the Runtime.executionContextCreated event.
    39         InspectorProtocol.sendCommand("Runtime.enable", {}, function() {
    40             // Initialize the DOM agent.
    41             InspectorProtocol.sendCommand("DOM.getDocument", {}, function() {
    42                 ProtocolTest.log("Main document loaded");
    43                
    44                 // Add the iframe to the DOM.
    45                 InspectorProtocol.sendCommand("Runtime.evaluate", { "expression": "appendIframe()" });
     38        // Enable the frame events.
     39        InspectorProtocol.sendCommand("Page.enable", {}, function() {
     40            // Enable the Runtime.executionContextCreated event.
     41            InspectorProtocol.sendCommand("Runtime.enable", {}, function() {
     42                // Initialize the DOM agent.
     43                InspectorProtocol.sendCommand("DOM.getDocument", {}, function() {
     44                    ProtocolTest.log("Main document loaded");
     45
     46                    // Add the iframe to the DOM.
     47                    InspectorProtocol.sendCommand("Runtime.evaluate", { "expression": "appendIframe()" });
     48                });
    4649            });
    4750        });
  • trunk/LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt

    r248602 r248943  
    11Testing CSS.getMatchedStylesForNode.
    22
     3Enabling Page domain...
    34Requesting document...
    45Querying for "div#x"...
  • trunk/LayoutTests/inspector/css/getMatchedStylesForNode.html

    r248602 r248943  
    3636{
    3737    Promise.resolve()
     38    .then(() => {
     39        ProtocolTest.log("Enabling Page domain...");
     40        return InspectorProtocol.awaitCommand({
     41            method: "Page.enable",
     42            params: {},
     43        });
     44    })
    3845    .then(() => {
    3946        ProtocolTest.log("Requesting document...");
  • trunk/LayoutTests/inspector/page/archive.html

    r248454 r248943  
    55function test()
    66{
     7    InspectorProtocol.sendCommand("Page.enable", {});
    78    InspectorProtocol.sendCommand("Page.archive", {}, function(event) {
    89        var data = event.result.data;
  • trunk/LayoutTests/inspector/page/frameScheduledNavigation-async-delegates.html

    r248454 r248943  
    1717    InspectorProtocol.eventHandler["Page.frameStartedLoading"] = onStarted;
    1818    InspectorProtocol.eventHandler["Page.frameClearedScheduledNavigation"] = onCleared;
     19    InspectorProtocol.sendCommand("Page.enable", {});
    1920
    2021    function onScheduled(msg)
  • trunk/LayoutTests/inspector/page/frameScheduledNavigation.html

    r248454 r248943  
    1414    InspectorProtocol.eventHandler["Page.frameStartedLoading"] = onStarted;
    1515    InspectorProtocol.eventHandler["Page.frameClearedScheduledNavigation"] = onCleared;
     16    InspectorProtocol.sendCommand("Page.enable", {});
    1617
    1718    function onScheduled(msg)
  • trunk/LayoutTests/inspector/page/frameStartedLoading.html

    r248454 r248943  
    1515    InspectorProtocol.eventHandler["Page.frameStartedLoading"] = onStart;
    1616    InspectorProtocol.eventHandler["Page.frameStoppedLoading"] = onStop;
     17    InspectorProtocol.sendCommand("Page.enable", {});
    1718
    1819    function onStart()
  • trunk/LayoutTests/inspector/page/media-query-list-listener-exception.html

    r248454 r248943  
    1111function test()
    1212{
     13    InspectorProtocol.sendCommand("Page.enable", {});
    1314    InspectorProtocol.sendCommand("Page.setEmulatedMedia", {"media": "print"}, function(messageObject) {
    1415        if (messageObject.error)
  • trunk/LayoutTests/inspector/timeline/line-column.html

    r248454 r248943  
    3838    let suite = ProtocolTest.createAsyncSuite("Timeline.LineColumn");
    3939
     40    InspectorProtocol.sendCommand("Page.enable", {});
    4041    InspectorProtocol.sendCommand("Timeline.enable");
    4142
  • trunk/Source/JavaScriptCore/ChangeLog

    r248938 r248943  
     12019-08-21  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Page: re-add enable/disable after r248454
     4        https://bugs.webkit.org/show_bug.cgi?id=200947
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        We shouldn't design the agent system with only Web Inspector in mind. Other clients may want
     9        to have different functionality, not being told about frames creation/updates/destruction.
     10        In these cases, we should have graceful error message failures for other agents that rely on
     11        the Page agent.
     12
     13        * inspector/protocol/Page.json:
     14
    1152019-08-20  Justin Michaud  <justin_michaud@apple.com>
    216
  • trunk/Source/JavaScriptCore/inspector/protocol/Page.json

    r248454 r248943  
    112112    "commands": [
    113113        {
     114            "name": "enable",
     115            "description": "Enables page domain notifications."
     116        },
     117        {
     118            "name": "disable",
     119            "description": "Disables page domain notifications."
     120        },
     121        {
    114122            "name": "reload",
    115123            "description": "Reloads the main frame of the inspected page.",
  • trunk/Source/WebCore/ChangeLog

    r248932 r248943  
     12019-08-21  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Page: re-add enable/disable after r248454
     4        https://bugs.webkit.org/show_bug.cgi?id=200947
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        We shouldn't design the agent system with only Web Inspector in mind. Other clients may want
     9        to have different functionality, not being told about frames creation/updates/destruction.
     10        In these cases, we should have graceful error message failures for other agents that rely on
     11        the Page agent.
     12
     13        * inspector/agents/InspectorPageAgent.h:
     14        * inspector/agents/InspectorPageAgent.cpp:
     15        (WebCore::InspectorPageAgent::didCreateFrontendAndBackend):
     16        (WebCore::InspectorPageAgent::willDestroyFrontendAndBackend):
     17        (WebCore::InspectorPageAgent::enable): Added.
     18        (WebCore::InspectorPageAgent::disable): Added.
     19
     20        * inspector/agents/InspectorApplicationCacheAgent.cpp:
     21        (WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus):
     22        (WebCore::InspectorApplicationCacheAgent::getFramesWithManifests):
     23        (WebCore::InspectorApplicationCacheAgent::assertFrameWithDocumentLoader):
     24        * inspector/agents/InspectorCSSAgent.cpp:
     25        (WebCore::InspectorCSSAgent::createStyleSheet):
     26        * inspector/agents/InspectorDOMAgent.cpp:
     27        (WebCore::InspectorDOMAgent::highlightSelector):
     28        (WebCore::InspectorDOMAgent::highlightFrame):
     29        (WebCore::InspectorDOMAgent::buildObjectForNode):
     30        * inspector/agents/InspectorTimelineAgent.cpp:
     31        (WebCore::InspectorTimelineAgent::setFrameIdentifier):
     32        * inspector/agents/page/PageNetworkAgent.cpp:
     33        (WebCore::PageNetworkAgent::loaderIdentifier):
     34        (WebCore::PageNetworkAgent::frameIdentifier):
     35        (WebCore::PageNetworkAgent::scriptExecutionContext):
     36        * inspector/agents/page/PageRuntimeAgent.cpp:
     37        (WebCore::PageRuntimeAgent::didCreateMainWorldContext):
     38        (WebCore::PageRuntimeAgent::reportExecutionContextCreation):
     39
    1402019-08-20  Ryosuke Niwa  <rniwa@webkit.org>
    241
  • trunk/Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.cpp

    r248846 r248943  
    8686void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame)
    8787{
     88    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     89    if (!pageAgent)
     90        return;
     91
    8892    if (!frame)
    8993        return;
     
    97101    auto manifestURL = host.applicationCacheInfo().manifest.string();
    98102
    99     m_frontendDispatcher->applicationCacheStatusUpdated(m_instrumentingAgents.inspectorPageAgent()->frameId(frame), manifestURL, status);
     103    m_frontendDispatcher->applicationCacheStatusUpdated(pageAgent->frameId(frame), manifestURL, status);
    100104}
    101105
     
    105109}
    106110
    107 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>>& result)
    108 {
     111void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString& errorString, RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>>& result)
     112{
     113    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     114    if (!pageAgent) {
     115        errorString = "Page domain must be enabled"_s;
     116        return;
     117    }
     118
    109119    result = JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>::create();
    110120
     
    118128        if (!manifestURL.isEmpty()) {
    119129            result->addItem(Inspector::Protocol::ApplicationCache::FrameWithManifest::create()
    120                 .setFrameId(m_instrumentingAgents.inspectorPageAgent()->frameId(frame))
     130                .setFrameId(pageAgent->frameId(frame))
    121131                .setManifestURL(manifestURL)
    122132                .setStatus(static_cast<int>(host.status()))
     
    128138DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(ErrorString& errorString, const String& frameId)
    129139{
    130     Frame* frame = m_instrumentingAgents.inspectorPageAgent()->assertFrame(errorString, frameId);
     140    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     141    if (!pageAgent) {
     142        errorString = "Page domain must be enabled"_s;
     143        return nullptr;
     144    }
     145
     146    auto* frame = pageAgent->assertFrame(errorString, frameId);
    131147    if (!frame)
    132148        return nullptr;
  • trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp

    r248846 r248943  
    682682void InspectorCSSAgent::createStyleSheet(ErrorString& errorString, const String& frameId, String* styleSheetId)
    683683{
    684     Frame* frame = m_instrumentingAgents.inspectorPageAgent()->frameForId(frameId);
    685     if (!frame) {
    686         errorString = "No frame for given id found"_s;
    687         return;
    688     }
     684    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     685    if (!pageAgent) {
     686        errorString = "Page domain must be enabled"_s;
     687        return;
     688    }
     689
     690    auto* frame = pageAgent->assertFrame(errorString, frameId);
     691    if (!frame)
     692        return;
    689693
    690694    Document* document = frame->document();
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp

    r248846 r248943  
    12251225
    12261226    if (frameId) {
    1227         Frame* frame = m_instrumentingAgents.inspectorPageAgent()->frameForId(*frameId);
    1228         if (!frame) {
    1229             errorString = "No frame for given id found"_s;
     1227        auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     1228        if (!pageAgent) {
     1229            errorString = "Page domain must be enabled"_s;
    12301230            return;
    12311231        }
     1232
     1233        auto* frame = pageAgent->assertFrame(errorString, *frameId);
     1234        if (!frame)
     1235            return;
    12321236
    12331237        document = frame->document();
     
    13121316void InspectorDOMAgent::highlightFrame(ErrorString& errorString, const String& frameId, const JSON::Object* color, const JSON::Object* outlineColor)
    13131317{
    1314     Frame* frame = m_instrumentingAgents.inspectorPageAgent()->assertFrame(errorString, frameId);
     1318    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     1319    if (!pageAgent) {
     1320        errorString = "Page domain must be enabled"_s;
     1321        return;
     1322    }
     1323
     1324    auto* frame = pageAgent->assertFrame(errorString, frameId);
    13151325    if (!frame)
    13161326        return;
     
    15521562    }
    15531563
    1554     if (auto* frameView = node->document().view())
    1555         value->setFrameId(m_instrumentingAgents.inspectorPageAgent()->frameId(&frameView->frame()));
     1564    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     1565    if (pageAgent) {
     1566        if (auto* frameView = node->document().view())
     1567            value->setFrameId(pageAgent->frameId(&frameView->frame()));
     1568    }
    15561569
    15571570    if (is<Element>(*node)) {
     
    15891602    } else if (is<Document>(*node)) {
    15901603        Document& document = downcast<Document>(*node);
    1591         value->setFrameId(m_instrumentingAgents.inspectorPageAgent()->frameId(document.frame()));
     1604        if (pageAgent)
     1605            value->setFrameId(pageAgent->frameId(document.frame()));
    15921606        value->setDocumentURL(documentURLString(&document));
    15931607        value->setBaseURL(documentBaseURLString(&document));
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp

    r248846 r248943  
    344344void InspectorPageAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
    345345{
     346}
     347
     348void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
     349{
     350    ErrorString unused;
     351    disable(unused);
     352}
     353
     354void InspectorPageAgent::enable(ErrorString& errorString)
     355{
     356    if (m_instrumentingAgents.inspectorPageAgent() == this) {
     357        errorString = "Page domain already enabled"_s;
     358        return;
     359    }
     360
    346361    m_instrumentingAgents.setInspectorPageAgent(this);
    347362
     
    355370}
    356371
    357 void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
    358 {
     372void InspectorPageAgent::disable(ErrorString&)
     373{
     374    m_instrumentingAgents.setInspectorPageAgent(nullptr);
     375
    359376    ErrorString unused;
    360377    setShowPaintRects(unused, false);
     
    372389
    373390    m_client->setMockCaptureDevicesEnabledOverride(WTF::nullopt);
    374 
    375     m_instrumentingAgents.setInspectorPageAgent(nullptr);
    376391}
    377392
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h

    r248454 r248943  
    8989
    9090    // PageBackendDispatcherHandler
     91    void enable(ErrorString&) final;
     92    void disable(ErrorString&) final;
    9193    void reload(ErrorString&, const bool* optionalReloadFromOrigin, const bool* optionalRevalidateAllResources) final;
    9294    void navigate(ErrorString&, const String& url) final;
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp

    r248846 r248943  
    742742        return;
    743743
    744     record->setString("frameId"_s, m_instrumentingAgents.inspectorPageAgent()->frameId(frame));
     744    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     745    if (!pageAgent)
     746        return;
     747
     748    record->setString("frameId"_s, pageAgent->frameId(frame));
    745749}
    746750
  • trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp

    r248454 r248943  
    4949String PageNetworkAgent::loaderIdentifier(DocumentLoader* loader)
    5050{
    51     if (loader)
    52         return m_instrumentingAgents.inspectorPageAgent()->loaderId(loader);
     51    if (loader) {
     52        if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent())
     53            return pageAgent->loaderId(loader);
     54    }
    5355    return { };
    5456}
     
    5658String PageNetworkAgent::frameIdentifier(DocumentLoader* loader)
    5759{
    58     if (loader)
    59         return m_instrumentingAgents.inspectorPageAgent()->frameId(loader->frame());
     60    if (loader) {
     61        if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent())
     62            return pageAgent->frameId(loader->frame());
     63    }
    6064    return { };
    6165}
     
    97101ScriptExecutionContext* PageNetworkAgent::scriptExecutionContext(ErrorString& errorString, const String& frameId)
    98102{
    99     auto* frame = m_instrumentingAgents.inspectorPageAgent()->assertFrame(errorString, frameId);
     103    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     104    if (!pageAgent) {
     105        errorString = "Page domain must be enabled"_s;
     106        return nullptr;
     107    }
     108
     109    auto* frame = pageAgent->assertFrame(errorString, frameId);
    100110    if (!frame)
    101111        return nullptr;
  • trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp

    r248846 r248943  
    8686void PageRuntimeAgent::didCreateMainWorldContext(Frame& frame)
    8787{
    88     auto frameId = m_instrumentingAgents.inspectorPageAgent()->frameId(&frame);
     88    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     89    if (!pageAgent)
     90        return;
     91
     92    auto frameId = pageAgent->frameId(&frame);
    8993    auto* scriptState = mainWorldExecState(&frame);
    9094    notifyContextCreated(frameId, scriptState, nullptr, true);
     
    119123void PageRuntimeAgent::reportExecutionContextCreation()
    120124{
     125    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     126    if (!pageAgent)
     127        return;
     128
    121129    Vector<std::pair<JSC::ExecState*, SecurityOrigin*>> isolatedContexts;
    122130    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
    123131        if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
    124132            continue;
    125         String frameId = m_instrumentingAgents.inspectorPageAgent()->frameId(frame);
     133
     134        String frameId = pageAgent->frameId(frame);
    126135
    127136        JSC::ExecState* scriptState = mainWorldExecState(frame);
  • trunk/Source/WebInspectorUI/ChangeLog

    r248940 r248943  
     12019-08-21  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Page: re-add enable/disable after r248454
     4        https://bugs.webkit.org/show_bug.cgi?id=200947
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        We shouldn't design the agent system with only Web Inspector in mind. Other clients may want
     9        to have different functionality, not being told about frames creation/updates/destruction.
     10        In these cases, we should have graceful error message failures for other agents that rely on
     11        the Page agent.
     12
     13        * UserInterface/Controllers/NetworkManager.js:
     14        (WI.NetworkManager.prototype.initializeTarget):
     15
    1162019-08-21  Devin Rousso  <drousso@apple.com>
    217
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js

    r248753 r248943  
    7777    {
    7878        if (target.PageAgent) {
    79             // COMPATIBILITY (iOS 13): Page.enable was removed.
    80             if (target.PageAgent.enable)
    81                 target.PageAgent.enable();
    82 
     79            target.PageAgent.enable();
    8380            target.PageAgent.getResourceTree(this._processMainFrameResourceTreePayload.bind(this));
    8481        }
Note: See TracChangeset for help on using the changeset viewer.