Web Inspector: Page: re-add enable/disable after r248454
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Aug 2019 16:50:14 +0000 (16:50 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Aug 2019 16:50:14 +0000 (16:50 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248943 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/page/loading-iframe-document-node.html
LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt
LayoutTests/inspector/css/getMatchedStylesForNode.html
LayoutTests/inspector/page/archive.html
LayoutTests/inspector/page/frameScheduledNavigation-async-delegates.html
LayoutTests/inspector/page/frameScheduledNavigation.html
LayoutTests/inspector/page/frameStartedLoading.html
LayoutTests/inspector/page/media-query-list-listener-exception.html
LayoutTests/inspector/timeline/line-column.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Page.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.cpp
Source/WebCore/inspector/agents/InspectorCSSAgent.cpp
Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Source/WebCore/inspector/agents/InspectorPageAgent.h
Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp
Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp
Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js

index d1ac642..974cc7a 100644 (file)
@@ -1,3 +1,20 @@
+2019-08-21  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Page: re-add enable/disable after r248454
+        https://bugs.webkit.org/show_bug.cgi?id=200947
+
+        Reviewed by Joseph Pecoraro.
+
+        * 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:
+
 2019-08-21  Rob Buis  <rbuis@igalia.com>
 
         Verify Prefetch and credential behavior
index 52f7689..51c2d9e 100644 (file)
@@ -35,14 +35,17 @@ function test()
 
     function step1_bootstrap() {
         ProtocolTest.log("step1_bootstrap");
-        // Enable the Runtime.executionContextCreated event.
-        InspectorProtocol.sendCommand("Runtime.enable", {}, function() {
-            // Initialize the DOM agent.
-            InspectorProtocol.sendCommand("DOM.getDocument", {}, function() {
-                ProtocolTest.log("Main document loaded");
-                
-                // Add the iframe to the DOM.
-                InspectorProtocol.sendCommand("Runtime.evaluate", { "expression": "appendIframe()" });
+        // Enable the frame events.
+        InspectorProtocol.sendCommand("Page.enable", {}, function() {
+            // Enable the Runtime.executionContextCreated event.
+            InspectorProtocol.sendCommand("Runtime.enable", {}, function() {
+                // Initialize the DOM agent.
+                InspectorProtocol.sendCommand("DOM.getDocument", {}, function() {
+                    ProtocolTest.log("Main document loaded");
+
+                    // Add the iframe to the DOM.
+                    InspectorProtocol.sendCommand("Runtime.evaluate", { "expression": "appendIframe()" });
+                });
             });
         });
     }
index 35c566f..2c4d524 100644 (file)
@@ -1,5 +1,6 @@
 Testing CSS.getMatchedStylesForNode.
 
+Enabling Page domain...
 Requesting document...
 Querying for "div#x"...
 Getting matched styles for "div#x"...
index 6dbbf2e..db95ddf 100644 (file)
@@ -36,6 +36,13 @@ function test()
 {
     Promise.resolve()
     .then(() => {
+        ProtocolTest.log("Enabling Page domain...");
+        return InspectorProtocol.awaitCommand({
+            method: "Page.enable",
+            params: {},
+        });
+    })
+    .then(() => {
         ProtocolTest.log("Requesting document...");
         return InspectorProtocol.awaitCommand({
             method: "DOM.getDocument",
index 6a78f8d..80691d0 100644 (file)
@@ -4,6 +4,7 @@
 <script>
 function test()
 {
+    InspectorProtocol.sendCommand("Page.enable", {});
     InspectorProtocol.sendCommand("Page.archive", {}, function(event) {
         var data = event.result.data;
         if (!data)
index 5fc883f..aaf1f81 100644 (file)
@@ -16,6 +16,7 @@ function test()
     InspectorProtocol.eventHandler["Page.frameScheduledNavigation"] = onScheduled;
     InspectorProtocol.eventHandler["Page.frameStartedLoading"] = onStarted;
     InspectorProtocol.eventHandler["Page.frameClearedScheduledNavigation"] = onCleared;
+    InspectorProtocol.sendCommand("Page.enable", {});
 
     function onScheduled(msg)
     {
index fc6a58d..ffb047e 100644 (file)
@@ -13,6 +13,7 @@ function test()
     InspectorProtocol.eventHandler["Page.frameScheduledNavigation"] = onScheduled;
     InspectorProtocol.eventHandler["Page.frameStartedLoading"] = onStarted;
     InspectorProtocol.eventHandler["Page.frameClearedScheduledNavigation"] = onCleared;
+    InspectorProtocol.sendCommand("Page.enable", {});
 
     function onScheduled(msg)
     {
index 9364bc3..3f7280c 100644 (file)
@@ -14,6 +14,7 @@ function test()
 {
     InspectorProtocol.eventHandler["Page.frameStartedLoading"] = onStart;
     InspectorProtocol.eventHandler["Page.frameStoppedLoading"] = onStop;
+    InspectorProtocol.sendCommand("Page.enable", {});
 
     function onStart()
     {
index 8ba744c..b69ad71 100644 (file)
@@ -10,6 +10,7 @@ theMediaQueryList.addListener(function(aMediaQueryList) {
 
 function test()
 {
+    InspectorProtocol.sendCommand("Page.enable", {});
     InspectorProtocol.sendCommand("Page.setEmulatedMedia", {"media": "print"}, function(messageObject) {
         if (messageObject.error)
             ProtocolTest.log("FAILED: " + messageObject.error.message);
index 035e4b1..57437ed 100644 (file)
@@ -37,6 +37,7 @@ function test()
 {
     let suite = ProtocolTest.createAsyncSuite("Timeline.LineColumn");
 
+    InspectorProtocol.sendCommand("Page.enable", {});
     InspectorProtocol.sendCommand("Timeline.enable");
 
     function replacer(key, value) {
index 2fdd74e..75f3b33 100644 (file)
@@ -1,3 +1,17 @@
+2019-08-21  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Page: re-add enable/disable after r248454
+        https://bugs.webkit.org/show_bug.cgi?id=200947
+
+        Reviewed by Joseph Pecoraro.
+
+        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:
+
 2019-08-20  Justin Michaud  <justin_michaud@apple.com>
 
         Identify memcpy loops in b3
index 1302246..f3e6a20 100644 (file)
     ],
     "commands": [
         {
+            "name": "enable",
+            "description": "Enables page domain notifications."
+        },
+        {
+            "name": "disable",
+            "description": "Disables page domain notifications."
+        },
+        {
             "name": "reload",
             "description": "Reloads the main frame of the inspected page.",
             "parameters": [
index 7a5abe8..70122c8 100644 (file)
@@ -1,3 +1,42 @@
+2019-08-21  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Page: re-add enable/disable after r248454
+        https://bugs.webkit.org/show_bug.cgi?id=200947
+
+        Reviewed by Joseph Pecoraro.
+
+        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):
+
 2019-08-20  Ryosuke Niwa  <rniwa@webkit.org>
 
         nextElementWithGreaterTabIndex should use shadowAdjustedTabIndex
index fdf044c..ec165b7 100644 (file)
@@ -85,6 +85,10 @@ void InspectorApplicationCacheAgent::disable(ErrorString& errorString)
 
 void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame)
 {
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent)
+        return;
+
     if (!frame)
         return;
 
@@ -96,7 +100,7 @@ void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame)
     int status = host.status();
     auto manifestURL = host.applicationCacheInfo().manifest.string();
 
-    m_frontendDispatcher->applicationCacheStatusUpdated(m_instrumentingAgents.inspectorPageAgent()->frameId(frame), manifestURL, status);
+    m_frontendDispatcher->applicationCacheStatusUpdated(pageAgent->frameId(frame), manifestURL, status);
 }
 
 void InspectorApplicationCacheAgent::networkStateChanged()
@@ -104,8 +108,14 @@ void InspectorApplicationCacheAgent::networkStateChanged()
     m_frontendDispatcher->networkStateUpdated(platformStrategies()->loaderStrategy()->isOnLine());
 }
 
-void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>>& result)
+void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString& errorString, RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>>& result)
 {
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent) {
+        errorString = "Page domain must be enabled"_s;
+        return;
+    }
+
     result = JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>::create();
 
     for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
@@ -117,7 +127,7 @@ void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString&, RefPtr
         String manifestURL = host.applicationCacheInfo().manifest.string();
         if (!manifestURL.isEmpty()) {
             result->addItem(Inspector::Protocol::ApplicationCache::FrameWithManifest::create()
-                .setFrameId(m_instrumentingAgents.inspectorPageAgent()->frameId(frame))
+                .setFrameId(pageAgent->frameId(frame))
                 .setManifestURL(manifestURL)
                 .setStatus(static_cast<int>(host.status()))
                 .release());
@@ -127,7 +137,13 @@ void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString&, RefPtr
 
 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(ErrorString& errorString, const String& frameId)
 {
-    Frame* frame = m_instrumentingAgents.inspectorPageAgent()->assertFrame(errorString, frameId);
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent) {
+        errorString = "Page domain must be enabled"_s;
+        return nullptr;
+    }
+
+    auto* frame = pageAgent->assertFrame(errorString, frameId);
     if (!frame)
         return nullptr;
 
index 44e9c5a..f4c3ff5 100644 (file)
@@ -681,12 +681,16 @@ void InspectorCSSAgent::setRuleSelector(ErrorString& errorString, const JSON::Ob
 
 void InspectorCSSAgent::createStyleSheet(ErrorString& errorString, const String& frameId, String* styleSheetId)
 {
-    Frame* frame = m_instrumentingAgents.inspectorPageAgent()->frameForId(frameId);
-    if (!frame) {
-        errorString = "No frame for given id found"_s;
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent) {
+        errorString = "Page domain must be enabled"_s;
         return;
     }
 
+    auto* frame = pageAgent->assertFrame(errorString, frameId);
+    if (!frame)
+        return;
+
     Document* document = frame->document();
     if (!document) {
         errorString = "No document for frame"_s;
index f0a28c1..0df0454 100644 (file)
@@ -1224,12 +1224,16 @@ void InspectorDOMAgent::highlightSelector(ErrorString& errorString, const JSON::
     RefPtr<Document> document;
 
     if (frameId) {
-        Frame* frame = m_instrumentingAgents.inspectorPageAgent()->frameForId(*frameId);
-        if (!frame) {
-            errorString = "No frame for given id found"_s;
+        auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+        if (!pageAgent) {
+            errorString = "Page domain must be enabled"_s;
             return;
         }
 
+        auto* frame = pageAgent->assertFrame(errorString, *frameId);
+        if (!frame)
+            return;
+
         document = frame->document();
     } else
         document = m_document;
@@ -1311,7 +1315,13 @@ void InspectorDOMAgent::highlightNodeList(ErrorString& errorString, const JSON::
 
 void InspectorDOMAgent::highlightFrame(ErrorString& errorString, const String& frameId, const JSON::Object* color, const JSON::Object* outlineColor)
 {
-    Frame* frame = m_instrumentingAgents.inspectorPageAgent()->assertFrame(errorString, frameId);
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent) {
+        errorString = "Page domain must be enabled"_s;
+        return;
+    }
+
+    auto* frame = pageAgent->assertFrame(errorString, frameId);
     if (!frame)
         return;
 
@@ -1551,8 +1561,11 @@ Ref<Inspector::Protocol::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node*
             value->setChildren(WTFMove(children));
     }
 
-    if (auto* frameView = node->document().view())
-        value->setFrameId(m_instrumentingAgents.inspectorPageAgent()->frameId(&frameView->frame()));
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (pageAgent) {
+        if (auto* frameView = node->document().view())
+            value->setFrameId(pageAgent->frameId(&frameView->frame()));
+    }
 
     if (is<Element>(*node)) {
         Element& element = downcast<Element>(*node);
@@ -1588,7 +1601,8 @@ Ref<Inspector::Protocol::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node*
         }
     } else if (is<Document>(*node)) {
         Document& document = downcast<Document>(*node);
-        value->setFrameId(m_instrumentingAgents.inspectorPageAgent()->frameId(document.frame()));
+        if (pageAgent)
+            value->setFrameId(pageAgent->frameId(document.frame()));
         value->setDocumentURL(documentURLString(&document));
         value->setBaseURL(documentBaseURLString(&document));
         value->setXmlVersion(document.xmlVersion());
index c641a6a..bfea6d1 100644 (file)
@@ -343,6 +343,21 @@ InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClien
 
 void InspectorPageAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
 {
+}
+
+void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
+{
+    ErrorString unused;
+    disable(unused);
+}
+
+void InspectorPageAgent::enable(ErrorString& errorString)
+{
+    if (m_instrumentingAgents.inspectorPageAgent() == this) {
+        errorString = "Page domain already enabled"_s;
+        return;
+    }
+
     m_instrumentingAgents.setInspectorPageAgent(this);
 
     auto stopwatch = m_environment.executionStopwatch();
@@ -354,8 +369,10 @@ void InspectorPageAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*,
 #endif
 }
 
-void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
+void InspectorPageAgent::disable(ErrorString&)
 {
+    m_instrumentingAgents.setInspectorPageAgent(nullptr);
+
     ErrorString unused;
     setShowPaintRects(unused, false);
     setShowRulers(unused, false);
@@ -371,8 +388,6 @@ void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReas
 #undef DISABLE_INSPECTOR_OVERRIDE_SETTING
 
     m_client->setMockCaptureDevicesEnabledOverride(WTF::nullopt);
-
-    m_instrumentingAgents.setInspectorPageAgent(nullptr);
 }
 
 double InspectorPageAgent::timestamp()
index 11d499f..3eed019 100644 (file)
@@ -88,6 +88,8 @@ public:
     static DocumentLoader* assertDocumentLoader(ErrorString&, Frame*);
 
     // PageBackendDispatcherHandler
+    void enable(ErrorString&) final;
+    void disable(ErrorString&) final;
     void reload(ErrorString&, const bool* optionalReloadFromOrigin, const bool* optionalRevalidateAllResources) final;
     void navigate(ErrorString&, const String& url) final;
     void overrideUserAgent(ErrorString&, const String* value) final;
index 30d86c7..e0e860d 100644 (file)
@@ -741,7 +741,11 @@ void InspectorTimelineAgent::setFrameIdentifier(JSON::Object* record, Frame* fra
     if (!frame)
         return;
 
-    record->setString("frameId"_s, m_instrumentingAgents.inspectorPageAgent()->frameId(frame));
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent)
+        return;
+
+    record->setString("frameId"_s, pageAgent->frameId(frame));
 }
 
 void InspectorTimelineAgent::didCompleteRecordEntry(const TimelineRecordEntry& entry)
index 980ad82..cc8cd41 100644 (file)
@@ -48,15 +48,19 @@ PageNetworkAgent::PageNetworkAgent(PageAgentContext& context)
 
 String PageNetworkAgent::loaderIdentifier(DocumentLoader* loader)
 {
-    if (loader)
-        return m_instrumentingAgents.inspectorPageAgent()->loaderId(loader);
+    if (loader) {
+        if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent())
+            return pageAgent->loaderId(loader);
+    }
     return { };
 }
 
 String PageNetworkAgent::frameIdentifier(DocumentLoader* loader)
 {
-    if (loader)
-        return m_instrumentingAgents.inspectorPageAgent()->frameId(loader->frame());
+    if (loader) {
+        if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent())
+            return pageAgent->frameId(loader->frame());
+    }
     return { };
 }
 
@@ -96,7 +100,13 @@ void PageNetworkAgent::setResourceCachingDisabled(bool disabled)
 
 ScriptExecutionContext* PageNetworkAgent::scriptExecutionContext(ErrorString& errorString, const String& frameId)
 {
-    auto* frame = m_instrumentingAgents.inspectorPageAgent()->assertFrame(errorString, frameId);
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent) {
+        errorString = "Page domain must be enabled"_s;
+        return nullptr;
+    }
+
+    auto* frame = pageAgent->assertFrame(errorString, frameId);
     if (!frame)
         return nullptr;
 
index 8985bc9..284d286 100644 (file)
@@ -85,7 +85,11 @@ void PageRuntimeAgent::disable(ErrorString& errorString)
 
 void PageRuntimeAgent::didCreateMainWorldContext(Frame& frame)
 {
-    auto frameId = m_instrumentingAgents.inspectorPageAgent()->frameId(&frame);
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent)
+        return;
+
+    auto frameId = pageAgent->frameId(&frame);
     auto* scriptState = mainWorldExecState(&frame);
     notifyContextCreated(frameId, scriptState, nullptr, true);
 }
@@ -118,11 +122,16 @@ void PageRuntimeAgent::unmuteConsole()
 
 void PageRuntimeAgent::reportExecutionContextCreation()
 {
+    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+    if (!pageAgent)
+        return;
+
     Vector<std::pair<JSC::ExecState*, SecurityOrigin*>> isolatedContexts;
     for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
             continue;
-        String frameId = m_instrumentingAgents.inspectorPageAgent()->frameId(frame);
+
+        String frameId = pageAgent->frameId(frame);
 
         JSC::ExecState* scriptState = mainWorldExecState(frame);
         notifyContextCreated(frameId, scriptState, nullptr, true);
index 80cb4d3..c3efd6b 100644 (file)
@@ -1,5 +1,20 @@
 2019-08-21  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Page: re-add enable/disable after r248454
+        https://bugs.webkit.org/show_bug.cgi?id=200947
+
+        Reviewed by Joseph Pecoraro.
+
+        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):
+
+2019-08-21  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Sources: increase the filter bar's width when it's focused if a resource type filter is active
         https://bugs.webkit.org/show_bug.cgi?id=200940
 
index 7a5c9f5..f82a987 100644 (file)
@@ -76,10 +76,7 @@ WI.NetworkManager = class NetworkManager extends WI.Object
     initializeTarget(target)
     {
         if (target.PageAgent) {
-            // COMPATIBILITY (iOS 13): Page.enable was removed.
-            if (target.PageAgent.enable)
-                target.PageAgent.enable();
-
+            target.PageAgent.enable();
             target.PageAgent.getResourceTree(this._processMainFrameResourceTreePayload.bind(this));
         }