Diff
Modified: trunk/LayoutTests/ChangeLog (269209 => 269210)
--- trunk/LayoutTests/ChangeLog 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/ChangeLog 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1,3 +1,29 @@
+2020-10-30 Brian Burg <[email protected]>
+
+ Web Inspector: move InspectorFrontendAPIDispatcher to WebCore, clean up uses
+ https://bugs.webkit.org/show_bug.cgi?id=217835
+ <rdar://problem/70384407>
+
+ Reviewed by Devin Rousso.
+
+ * inspector/dom/dom-remove-events.html:
+ * inspector/dom/remove-multiple-nodes.html:
+ The order of events received has changed slightly due to the new auto-suspend behavior
+ in InspectorFrontendAPIDispatcher. Remove event handlers when the test is complete to
+ ensure that events which arrive after the test has finished do not stomp on the expected results.
+
+ * inspector/debugger/call-frame-function-name.html:
+ * inspector/debugger/call-frame-this-host.html:
+ * inspector/debugger/hit-breakpoint-from-console.html:
+ * inspector/debugger/setBreakpoint-autoContinue.html:
+ * inspector/debugger/setBreakpoint-column.html:
+ * inspector/debugger/setBreakpoint-condition.html:
+ * inspector/debugger/setBreakpoint.html:
+ * inspector/debugger/setBreakpointByUrl-sourceURL.html:
+ Some tests seem to call ProtocolTest.completeTest() from the handler of Debugger.paused, when
+ the debugger is still paused. This causes timeouts after this refactoring, since not resuming means that
+ we'll get stuck in the debugger's nested run loop and never return.
+
2020-10-30 Fujii Hironori <[email protected]>
[TextureMapper] Replica layers don't blend correctly because computeOverlapRegions doesn't take TextureMapperPaintOptions::transform into account
Modified: trunk/LayoutTests/http/tests/inspector/resources/protocol-test.js (269209 => 269210)
--- trunk/LayoutTests/http/tests/inspector/resources/protocol-test.js 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/http/tests/inspector/resources/protocol-test.js 2020-10-30 23:56:26 UTC (rev 269210)
@@ -65,11 +65,12 @@
TestPage.closeTest = window.closeTest = function()
{
- window.internals.closeDummyInspectorFrontend();
-
// This code might be executed while the debugger is still running through a stack based EventLoop.
// Use a setTimeout to defer to a clean stack before letting the testRunner load the next test.
- setTimeout(() => { testRunner.notifyDone(); }, 0);
+ setTimeout(() => {
+ window.internals.closeDummyInspectorFrontend();
+ testRunner.notifyDone();
+ }, 0);
};
TestPage.runTest = window.runTest = function()
Modified: trunk/LayoutTests/inspector/debugger/call-frame-function-name.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/call-frame-function-name.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/call-frame-function-name.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -32,6 +32,8 @@
InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject)
{
ProtocolTest.log("Hit Breakpoint!");
+ InspectorProtocol.sendCommand("Debugger.disable");
+
var functionNames = [ ];
var i;
for (i = 0; i < 3; i++)
Modified: trunk/LayoutTests/inspector/debugger/call-frame-this-host.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/call-frame-this-host.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/call-frame-this-host.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -32,6 +32,8 @@
InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject)
{
ProtocolTest.log("Hit Breakpoint!");
+ InspectorProtocol.sendCommand("Debugger.disable");
+
var thisValues = [ ];
var i;
for (i = 0; i < 3; i++)
Modified: trunk/LayoutTests/inspector/debugger/hit-breakpoint-from-console.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/hit-breakpoint-from-console.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/hit-breakpoint-from-console.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -30,6 +30,8 @@
InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject)
{
ProtocolTest.log("Hit Breakpoint!");
+ InspectorProtocol.sendCommand("Debugger.disable");
+
ProtocolTest.log("PASS");
ProtocolTest.completeTest();
}
Modified: trunk/LayoutTests/inspector/debugger/setBreakpoint-autoContinue.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/setBreakpoint-autoContinue.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/setBreakpoint-autoContinue.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -44,6 +44,7 @@
InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject)
{
ProtocolTest.log("Hit Breakpoint!");
+ InspectorProtocol.sendCommand("Debugger.disable");
if (!allowedToHitBreakpoint) {
ProtocolTest.log("FAIL: should not have hit breakpoint.");
Modified: trunk/LayoutTests/inspector/debugger/setBreakpoint-column.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/setBreakpoint-column.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/setBreakpoint-column.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -37,6 +37,8 @@
ProtocolTest.log("Evaluted value of `a` (expecting number 1) was: " + JSON.stringify(messageObject.result.result));
InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, _expression_: "b"}, function(messageObject) {
ProtocolTest.log("Evaluted value of `b` (expecting undefined) was: " + JSON.stringify(messageObject.result.result));
+
+ InspectorProtocol.sendCommand("Debugger.disable");
ProtocolTest.completeTest();
});
});
Modified: trunk/LayoutTests/inspector/debugger/setBreakpoint-condition-expected.txt (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/setBreakpoint-condition-expected.txt 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/setBreakpoint-condition-expected.txt 2020-10-30 23:56:26 UTC (rev 269210)
@@ -16,4 +16,5 @@
Evaluted value of `a` (expecting number 4) was: {"type":"number","value":4,"description":"4"}
Evaluted value of `b` (expecting number 7) was: {"type":"number","value":7,"description":"7"}
PASS: hit breakpoints with expected values
+Test is complete, disabling breakpoints.
Modified: trunk/LayoutTests/inspector/debugger/setBreakpoint-condition.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/setBreakpoint-condition.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/setBreakpoint-condition.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -3,6 +3,7 @@
<script src=""
<script src=""
<script>
+
function test()
{
InspectorProtocol.sendCommand("Debugger.enable", {});
@@ -11,6 +12,17 @@
var inBreakpoint = false;
var breakpointTriggered = 0;
+ function disableDebuggerAndCompleteTest()
+ {
+ delete InspectorProtocol.eventHandler["Debugger.scriptParsed"];
+ delete InspectorProtocol.eventHandler["Debugger.paused"];
+ delete InspectorProtocol.eventHandler["Debugger.resumed"];
+
+ InspectorProtocol.sendCommand("Debugger.disable");
+ ProtocolTest.log("Test is complete, disabling breakpoints.");
+ ProtocolTest.completeTest();
+ }
+
InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject)
{
if (/resources\/breakpoint\.js$/.test(messageObject.params.url)) {
@@ -48,13 +60,14 @@
ProtocolTest.log("Evaluted value of `a` (expecting number 4) was: " + JSON.stringify(messageObject.result.result));
InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, _expression_: "b"}, function(messageObject) {
ProtocolTest.log("Evaluted value of `b` (expecting number 7) was: " + JSON.stringify(messageObject.result.result));
+
ProtocolTest.log("PASS: hit breakpoints with expected values");
- ProtocolTest.completeTest();
+ disableDebuggerAndCompleteTest();
});
});
} else {
ProtocolTest.log("FAIL: hit too many breakpoints.");
- ProtocolTest.completeTest();
+ disableDebuggerAndCompleteTest();
}
}
@@ -69,7 +82,7 @@
setTimeout(function() {
if (!inBreakpoint) {
ProtocolTest.log("FAIL: Did not hit conditional breakpoint the second time");
- ProtocolTest.completeTest();
+ disableDebuggerAndCompleteTest();
}
}, 100);
});
Modified: trunk/LayoutTests/inspector/debugger/setBreakpoint.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/setBreakpoint.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/setBreakpoint.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -33,6 +33,8 @@
InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject)
{
ProtocolTest.log("Hit Breakpoint!");
+ InspectorProtocol.sendCommand("Debugger.disable");
+
ProtocolTest.log("PASS");
ProtocolTest.completeTest();
}
Modified: trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html (269209 => 269210)
--- trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -32,6 +32,8 @@
ProtocolTest.log("Evaluted value of `a` (expecting number 1) was: " + JSON.stringify(messageObject.result.result));
InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, _expression_: "c"}, function(messageObject) {
ProtocolTest.log("Evaluted value of `c` (expecting undefined) was: " + JSON.stringify(messageObject.result.result));
+
+ InspectorProtocol.sendCommand("Debugger.disable");
ProtocolTest.completeTest();
});
});
Modified: trunk/LayoutTests/inspector/dom/dom-remove-events.html (269209 => 269210)
--- trunk/LayoutTests/inspector/dom/dom-remove-events.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/dom/dom-remove-events.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -71,6 +71,9 @@
// Make sure we receive the children of the "#final_container" as they are added.
InspectorProtocol.sendCommand("DOM.requestChildNodes", {nodeId: response.result.nodeId});
InspectorProtocol.sendCommand("Runtime.evaluate", {"_expression_": "moveNode()"}, function() {
+ delete InspectorProtocol.eventHandler["DOM.setChildNodes"];
+ delete InspectorProtocol.eventHandler["DOM.childNodeRemoved"];
+ delete InspectorProtocol.eventHandler["DOM.childNodeInserted"];
ProtocolTest.completeTest();
});
}
Modified: trunk/LayoutTests/inspector/dom/remove-multiple-nodes.html (269209 => 269210)
--- trunk/LayoutTests/inspector/dom/remove-multiple-nodes.html 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/LayoutTests/inspector/dom/remove-multiple-nodes.html 2020-10-30 23:56:26 UTC (rev 269210)
@@ -92,6 +92,9 @@
InspectorProtocol.sendCommand("DOM.requestChildNodes", {nodeId: response.result.nodeIds[i]});
InspectorProtocol.sendCommand("Runtime.evaluate", {"_expression_": "moveNode()"}, function() {
+ delete InspectorProtocol.eventHandler["DOM.setChildNodes"];
+ delete InspectorProtocol.eventHandler["DOM.childNodeRemoved"];
+ delete InspectorProtocol.eventHandler["DOM.childNodeInserted"];
ProtocolTest.completeTest();
});
}
Modified: trunk/Source/WebCore/ChangeLog (269209 => 269210)
--- trunk/Source/WebCore/ChangeLog 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/ChangeLog 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1,3 +1,71 @@
+2020-10-30 Brian Burg <[email protected]>
+
+ Web Inspector: move InspectorFrontendAPIDispatcher to WebCore, clean up uses
+ https://bugs.webkit.org/show_bug.cgi?id=217835
+ <rdar://problem/70384407>
+
+ Reviewed by Devin Rousso.
+
+ Expose the dispatcher as part of the InspectorFrontendClient API so that other code
+ can use the dispatcher regardless of whether it's a WebInspectorUI or RemoteWebInspectorUI.
+
+ Add an InspectorFrontendAPIDispatcher instance and getter to InspectorFrontendClientLocal.
+
+ Adopt the JSONValue-based InspectorFrontendAPIDispatcher::dispatch() method
+ in InspectorFrontendClientLocal. Remove the redundant parallel queuing implementation.
+ Remove redundant public methods that are available on InspectorFrontendAPIDispatcher.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ Moved files.
+
+ * inspector/InspectorFrontendAPIDispatcher.cpp: Renamed from Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp.
+ (WebCore::InspectorFrontendAPIDispatcher::InspectorFrontendAPIDispatcher):
+ (WebCore::InspectorFrontendAPIDispatcher::reset):
+ (WebCore::InspectorFrontendAPIDispatcher::frontendLoaded):
+ (WebCore::InspectorFrontendAPIDispatcher::suspend):
+ (WebCore::InspectorFrontendAPIDispatcher::unsuspend):
+ (WebCore::InspectorFrontendAPIDispatcher::dispatchCommand):
+ (WebCore::InspectorFrontendAPIDispatcher::dispatchMessageAsync):
+ (WebCore::InspectorFrontendAPIDispatcher::evaluateOrQueueExpression):
+ (WebCore::InspectorFrontendAPIDispatcher::evaluateQueuedExpressions):
+ (WebCore::InspectorFrontendAPIDispatcher::evaluateExpression):
+ (WebCore::InspectorFrontendAPIDispatcher::evaluateExpressionForTesting):
+ Add new dispatch() method. Remove other dispatch methods that can be expressed
+ using the new JSON::Value-based method. If it's not possible to evaluate JS
+ immediately, schedule a one-shot task to try again on a different event loop turn.
+
+ * inspector/InspectorFrontendAPIDispatcher.h: Renamed from Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h.
+ Add new dispatch() method which takes a vector of JSON::Value objects and
+ serializes them into command arguments for the frontend.
+
+ * inspector/InspectorFrontendClient.h:
+ * inspector/InspectorFrontendClientLocal.h:
+ * inspector/InspectorFrontendClientLocal.cpp:
+ (WebCore::InspectorFrontendClientLocal::InspectorFrontendClientLocal):
+ (WebCore::InspectorFrontendClientLocal::frontendLoaded):
+ (WebCore::InspectorFrontendClientLocal::pagePaused):
+ (WebCore::InspectorFrontendClientLocal::pageUnpaused):
+ (WebCore::InspectorFrontendClientLocal::setDockingUnavailable):
+ (WebCore::InspectorFrontendClientLocal::setAttachedWindow):
+ (WebCore::InspectorFrontendClientLocal::setDebuggingEnabled):
+ (WebCore::InspectorFrontendClientLocal::setTimelineProfilingEnabled):
+ (WebCore::InspectorFrontendClientLocal::startProfilingJavaScript):
+ (WebCore::InspectorFrontendClientLocal::stopProfilingJavaScript):
+ (WebCore::InspectorFrontendClientLocal::showConsole):
+ (WebCore::InspectorFrontendClientLocal::showResources):
+ (WebCore::InspectorFrontendClientLocal::showMainResourceForFrame):
+ Use InspectorFrontendAPIDispatcher to dispatch commands to the frontend.
+
+ (WebCore::InspectorFrontendClientLocal::dispatch): Deleted.
+ (WebCore::InspectorFrontendClientLocal::dispatchMessage): Deleted.
+ (WebCore::InspectorFrontendClientLocal::dispatchMessageAsync): Deleted.
+ (WebCore::InspectorFrontendClientLocal::evaluateOnLoad): Deleted.
+ These are redundant with InspectorFrontendAPIDispatcher.
+
+ * testing/Internals.cpp:
+ (WebCore::InspectorStubFrontend::sendMessageToFrontend): Use frontend dispatcher directly.
+
2020-10-30 Chris Fleizach <[email protected]>
AX: Incorrect list of voices being displayed on iOS
Modified: trunk/Source/WebCore/Headers.cmake (269209 => 269210)
--- trunk/Source/WebCore/Headers.cmake 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/Headers.cmake 2020-10-30 23:56:26 UTC (rev 269210)
@@ -696,6 +696,7 @@
inspector/InspectorClient.h
inspector/InspectorController.h
inspector/InspectorDebuggableType.h
+ inspector/InspectorFrontendAPIDispatcher.h
inspector/InspectorFrontendClient.h
inspector/InspectorFrontendClientLocal.h
inspector/InspectorFrontendHost.h
Modified: trunk/Source/WebCore/Sources.txt (269209 => 269210)
--- trunk/Source/WebCore/Sources.txt 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/Sources.txt 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1404,6 +1404,7 @@
inspector/InspectorCanvas.cpp
inspector/InspectorController.cpp
inspector/InspectorDatabaseResource.cpp
+inspector/InspectorFrontendAPIDispatcher.cpp
inspector/InspectorFrontendClientLocal.cpp
inspector/InspectorFrontendHost.cpp
inspector/InspectorHistory.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (269209 => 269210)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-10-30 23:56:26 UTC (rev 269210)
@@ -2979,6 +2979,7 @@
98CE432A129E00E5005821DC /* LinkLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 98CE4329129E00E5005821DC /* LinkLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
9920398318B95BC600B39AF9 /* UserInputBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 9920398118B95BC600B39AF9 /* UserInputBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 994C603A253A277300BDF060 /* InspectorFrontendAPIDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 994C6037253A277200BDF060 /* InspectorFrontendAPIDispatcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
996E59DF1DF0128D006612B9 /* NavigatorWebDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 996E59DC1DF00D90006612B9 /* NavigatorWebDriver.h */; };
99D1B2D323AC143100811CF0 /* InspectorDebuggableType.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D1B2D123AC143000811CF0 /* InspectorDebuggableType.h */; settings = {ATTRIBUTES = (Private, ); }; };
9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A528E8217D7F52F00AA9518 /* FloatingObjects.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11762,6 +11763,8 @@
9908B0FF1BCAD07D00ED3572 /* ReadableStreamBYOBReaderBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ReadableStreamBYOBReaderBuiltins.h; path = DerivedSources/WebCore/ReadableStreamBYOBReaderBuiltins.h; sourceTree = BUILT_PRODUCTS_DIR; };
9920398018B95BC600B39AF9 /* UserInputBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserInputBridge.cpp; sourceTree = "<group>"; };
9920398118B95BC600B39AF9 /* UserInputBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInputBridge.h; sourceTree = "<group>"; };
+ 994C6037253A277200BDF060 /* InspectorFrontendAPIDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendAPIDispatcher.h; sourceTree = "<group>"; };
+ 994C6039253A277300BDF060 /* InspectorFrontendAPIDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorFrontendAPIDispatcher.cpp; sourceTree = "<group>"; };
996E59DB1DF00D90006612B9 /* NavigatorWebDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorWebDriver.cpp; sourceTree = "<group>"; };
996E59DC1DF00D90006612B9 /* NavigatorWebDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorWebDriver.h; sourceTree = "<group>"; };
996E59DD1DF00D90006612B9 /* Navigator+WebDriver.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Navigator+WebDriver.idl"; sourceTree = "<group>"; };
@@ -18410,6 +18413,8 @@
41F062130F5F192600A07EAC /* InspectorDatabaseResource.cpp */,
41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */,
99D1B2D123AC143000811CF0 /* InspectorDebuggableType.h */,
+ 994C6039253A277300BDF060 /* InspectorFrontendAPIDispatcher.cpp */,
+ 994C6037253A277200BDF060 /* InspectorFrontendAPIDispatcher.h */,
F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */,
F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */,
F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */,
@@ -32164,6 +32169,7 @@
A5B81CAB1FAA44620037D1E6 /* InspectorDOMAgent.h in Headers */,
A5B81CAC1FAA44620037D1E6 /* InspectorDOMDebuggerAgent.h in Headers */,
A5B81CAD1FAA44620037D1E6 /* InspectorDOMStorageAgent.h in Headers */,
+ 994C603A253A277300BDF060 /* InspectorFrontendAPIDispatcher.h in Headers */,
F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */,
F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */,
7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */,
Added: trunk/Source/WebCore/inspector/InspectorFrontendAPIDispatcher.cpp (0 => 269210)
--- trunk/Source/WebCore/inspector/InspectorFrontendAPIDispatcher.cpp (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorFrontendAPIDispatcher.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorFrontendAPIDispatcher.h"
+
+#include "Frame.h"
+#include "Page.h"
+#include "ScriptController.h"
+#include "ScriptDisallowedScope.h"
+#include "ScriptSourceCode.h"
+#include "ScriptState.h"
+#include <_javascript_Core/FrameTracers.h>
+
+
+namespace WebCore {
+
+using EvaluationError = InspectorFrontendAPIDispatcher::EvaluationError;
+using EvaluationResultHandler = CompletionHandler<Expected<JSC::JSValue, EvaluationError>>;
+
+InspectorFrontendAPIDispatcher::InspectorFrontendAPIDispatcher(Page& frontendPage)
+ : m_frontendPage(makeWeakPtr(frontendPage))
+{
+}
+
+InspectorFrontendAPIDispatcher::~InspectorFrontendAPIDispatcher()
+{
+ invalidateQueuedExpressions();
+}
+
+void InspectorFrontendAPIDispatcher::reset()
+{
+ m_frontendLoaded = false;
+ m_suspended = false;
+
+ invalidateQueuedExpressions();
+}
+
+void InspectorFrontendAPIDispatcher::frontendLoaded()
+{
+ ASSERT(m_frontendPage);
+ m_frontendLoaded = true;
+
+ evaluateQueuedExpressions();
+}
+
+void InspectorFrontendAPIDispatcher::suspend(UnsuspendSoon unsuspendSoon)
+{
+ ASSERT(m_frontendLoaded);
+
+ if (m_suspended)
+ return;
+
+ m_suspended = true;
+
+ if (unsuspendSoon == UnsuspendSoon::Yes) {
+ RunLoop::main().dispatch([protectedThis = makeRef(*this)] {
+ // If the frontend page has been deallocated, there's nothing to do.
+ if (!protectedThis->m_frontendPage)
+ return;
+
+ protectedThis->unsuspend();
+ });
+ }
+}
+
+void InspectorFrontendAPIDispatcher::unsuspend()
+{
+ if (!m_suspended)
+ return;
+
+ m_suspended = false;
+
+ evaluateQueuedExpressions();
+}
+
+JSGlobalObject* InspectorFrontendAPIDispatcher::frontendGlobalObject()
+{
+ if (!m_frontendPage)
+ return nullptr;
+
+ return m_frontendPage->mainFrame().script().globalObject(mainThreadNormalWorld());
+}
+
+static String expressionForEvaluatingCommand(const String& command, Vector<Ref<JSON::Value>>&& arguments)
+{
+ StringBuilder _expression_;
+ _expression_.appendLiteral("InspectorFrontendAPI.dispatch([\"");
+ _expression_.append(command);
+ _expression_.append('"');
+
+ for (auto& argument : arguments) {
+ _expression_.appendLiteral(", ");
+ argument->writeJSON(_expression_);
+ }
+
+ _expression_.append(']');
+ _expression_.append(')');
+ return _expression_.toString();
+}
+
+InspectorFrontendAPIDispatcher::EvaluationResult InspectorFrontendAPIDispatcher::dispatchCommandWithResultSync(const String& command, Vector<Ref<JSON::Value>>&& arguments)
+{
+ if (m_suspended)
+ return makeUnexpected(EvaluationError::ExecutionSuspended);
+
+ return evaluateExpression(expressionForEvaluatingCommand(command, WTFMove(arguments)));
+}
+
+void InspectorFrontendAPIDispatcher::dispatchCommandWithResultAsync(const String& command, Vector<Ref<JSON::Value>>&& arguments, EvaluationResultHandler&& resultHandler)
+{
+ evaluateOrQueueExpression(expressionForEvaluatingCommand(command, WTFMove(arguments)), WTFMove(resultHandler));
+}
+
+void InspectorFrontendAPIDispatcher::dispatchMessageAsync(const String& message)
+{
+ evaluateOrQueueExpression(makeString("InspectorFrontendAPI.dispatchMessageAsync(", message, ")"));
+}
+
+void InspectorFrontendAPIDispatcher::evaluateOrQueueExpression(const String& _expression_, EvaluationResultHandler&& optionalResultHandler)
+{
+ // If the frontend page has been deallocated, then there is nothing to do.
+ if (!m_frontendPage) {
+ if (optionalResultHandler)
+ optionalResultHandler(makeUnexpected(EvaluationError::ContextDestroyed));
+
+ return;
+ }
+
+ // Sometimes we get here by sending messages for events triggered by DOM mutations earlier in the call stack.
+ // If this is the case, then it's not safe to evaluate script synchronously, so do it later. This only affects
+ // WebKit1 and some layout tests that use a single web process for both the inspector and inspected page.
+ if (!ScriptDisallowedScope::InMainThread::isScriptAllowed())
+ suspend(UnsuspendSoon::Yes);
+
+ if (!m_frontendLoaded || m_suspended) {
+ m_queuedEvaluations.append(std::make_pair(_expression_, WTFMove(optionalResultHandler)));
+ return;
+ }
+
+ JSC::JSValue result = evaluateExpression(_expression_);
+ if (optionalResultHandler)
+ optionalResultHandler(result);
+}
+
+void InspectorFrontendAPIDispatcher::invalidateQueuedExpressions()
+{
+ auto queuedEvaluations = std::exchange(m_queuedEvaluations, { });
+ for (auto& pair : queuedEvaluations) {
+ auto resultHandler = WTFMove(pair.second);
+ if (resultHandler)
+ resultHandler(makeUnexpected(EvaluationError::ContextDestroyed));
+ }
+}
+
+void InspectorFrontendAPIDispatcher::evaluateQueuedExpressions()
+{
+ // If the frontend page has been deallocated, then there is nothing to do.
+ if (!m_frontendPage)
+ return;
+
+ if (m_queuedEvaluations.isEmpty())
+ return;
+
+ auto queuedEvaluations = std::exchange(m_queuedEvaluations, { });
+ for (auto& pair : queuedEvaluations) {
+ auto result = evaluateExpression(pair.first);
+ if (auto resultHandler = WTFMove(pair.second))
+ resultHandler(result);
+ }
+}
+
+JSC::JSValue InspectorFrontendAPIDispatcher::evaluateExpression(const String& _expression_)
+{
+ ASSERT(m_frontendPage);
+ ASSERT(!m_suspended);
+ ASSERT(m_queuedEvaluations.isEmpty());
+
+ JSC::SuspendExceptionScope scope(&m_frontendPage->inspectorController().vm());
+ return m_frontendPage->mainFrame().script().evaluateIgnoringException(ScriptSourceCode(_expression_));
+}
+
+void InspectorFrontendAPIDispatcher::evaluateExpressionForTesting(const String& _expression_)
+{
+ evaluateOrQueueExpression(_expression_);
+}
+
+} // namespace WebKit
Added: trunk/Source/WebCore/inspector/InspectorFrontendAPIDispatcher.h (0 => 269210)
--- trunk/Source/WebCore/inspector/InspectorFrontendAPIDispatcher.h (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorFrontendAPIDispatcher.h 2020-10-30 23:56:26 UTC (rev 269210)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <_javascript_Core/JSCJSValue.h>
+#include <wtf/CompletionHandler.h>
+#include <wtf/Expected.h>
+#include <wtf/JSONValues.h>
+#include <wtf/RefCounted.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class Page;
+
+class InspectorFrontendAPIDispatcher final : public RefCounted<InspectorFrontendAPIDispatcher> {
+public:
+ enum class EvaluationError { ExecutionSuspended, ContextDestroyed };
+ using EvaluationResult = Expected<JSC::JSValue, EvaluationError>;
+ using EvaluationResultHandler = CompletionHandler<void(EvaluationResult)>;
+
+ enum class UnsuspendSoon { Yes, No };
+
+ WEBCORE_EXPORT ~InspectorFrontendAPIDispatcher();
+
+ static Ref<InspectorFrontendAPIDispatcher> create(Page& page)
+ {
+ return adoptRef(*new InspectorFrontendAPIDispatcher(page));
+ }
+
+ WEBCORE_EXPORT void reset();
+ WEBCORE_EXPORT void frontendLoaded();
+
+ // If it's not currently safe to evaluate _javascript_ on the frontend page, the
+ // dispatcher will become suspended and dispatch any queued evaluations when unsuspended.
+ WEBCORE_EXPORT void suspend(UnsuspendSoon = UnsuspendSoon::No);
+ WEBCORE_EXPORT void unsuspend();
+ bool isSuspended() const { return m_suspended; }
+
+ EvaluationResult dispatchCommandWithResultSync(const String& command, Vector<Ref<JSON::Value>>&& arguments = { });
+ WEBCORE_EXPORT void dispatchCommandWithResultAsync(const String& command, Vector<Ref<JSON::Value>>&& arguments = { }, EvaluationResultHandler&& handler = { });
+
+ // Used to forward messages from the backend connection to the frontend.
+ WEBCORE_EXPORT void dispatchMessageAsync(const String& message);
+
+ WEBCORE_EXPORT void evaluateExpressionForTesting(const String&);
+
+ // Convenience method to obtain a JSGlobalObject for the frontend page.
+ // This is used to convert between C++ values and frontend JSC::JSValue objects.
+ WEBCORE_EXPORT JSC::JSGlobalObject* frontendGlobalObject();
+private:
+ WEBCORE_EXPORT InspectorFrontendAPIDispatcher(Page&);
+
+ void evaluateOrQueueExpression(const String&, EvaluationResultHandler&& handler = { });
+ void evaluateQueuedExpressions();
+ void invalidateQueuedExpressions();
+ JSC::JSValue evaluateExpression(const String&);
+
+ WeakPtr<Page> m_frontendPage;
+ Vector<std::pair<String, EvaluationResultHandler>> m_queuedEvaluations;
+ bool m_frontendLoaded { false };
+ bool m_suspended { false };
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorFrontendClient.h (269209 => 269210)
--- trunk/Source/WebCore/inspector/InspectorFrontendClient.h 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClient.h 2020-10-30 23:56:26 UTC (rev 269210)
@@ -41,6 +41,7 @@
namespace WebCore {
class FloatRect;
+class InspectorFrontendAPIDispatcher;
class InspectorFrontendClient {
public:
@@ -56,6 +57,9 @@
WEBCORE_EXPORT virtual void windowObjectCleared() = 0;
virtual void frontendLoaded() = 0;
+ virtual void pagePaused() = 0;
+ virtual void pageUnpaused() = 0;
+
virtual void startWindowDrag() = 0;
virtual void moveWindowBy(float x, float y) = 0;
@@ -105,10 +109,8 @@
virtual void logDiagnosticEvent(const String& /* eventName */, const DiagnosticLoggingClient::ValueDictionary&) { }
#endif
- virtual void pagePaused() { }
- virtual void pageUnpaused() { }
-
WEBCORE_EXPORT virtual void sendMessageToBackend(const String&) = 0;
+ WEBCORE_EXPORT virtual InspectorFrontendAPIDispatcher& frontendAPIDispatcher() = 0;
WEBCORE_EXPORT virtual bool isUnderTest() = 0;
};
Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp (269209 => 269210)
--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -150,6 +150,7 @@
, m_settings(WTFMove(settings))
, m_dockSide(DockSide::Undocked)
, m_dispatchTask(InspectorBackendDispatchTask::create(inspectedPageController))
+ , m_frontendAPIDispatcher(InspectorFrontendAPIDispatcher::create(*frontendPage))
{
m_frontendPage->settings().setAllowFileAccessFromFileURLs(true);
}
@@ -185,12 +186,22 @@
// Thus if we call canAttachWindow first we can avoid this problem. This change does not cause any regressions on Mac.
setDockingUnavailable(!canAttachWindow());
bringToFront();
- m_frontendLoaded = true;
- for (auto& evaluate : m_evaluateOnLoad)
- evaluateOnLoad(evaluate);
- m_evaluateOnLoad.clear();
+
+ m_frontendAPIDispatcher->frontendLoaded();
}
+void InspectorFrontendClientLocal::pagePaused()
+{
+ // NOTE: pagePaused() and pageUnpaused() do not suspend/unsuspend the frontend API dispatcher
+ // for this subclass of InspectorFrontendClient. The inspected page and the frontend page
+ // exist in the same web process, so messages need to be sent even while the debugger is paused.
+ // Suspending here would stall out later commands that resume the debugger, causing the test to time out.
+}
+
+void InspectorFrontendClientLocal::pageUnpaused()
+{
+}
+
UserInterfaceLayoutDirection InspectorFrontendClientLocal::userInterfaceLayoutDirection() const
{
return m_frontendPage->userInterfaceLayoutDirection();
@@ -227,7 +238,7 @@
void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)
{
- dispatch(makeString("[\"setDockingUnavailable\", ", unavailable ? "true" : "false", ']'));
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDockingUnavailable"_s, { JSON::Value::create(unavailable) });
}
void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
@@ -297,7 +308,7 @@
m_dockSide = dockSide;
- dispatch(makeString("[\"setDockSide\", \"", side, "\"]"));
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDockSide"_s, { JSON::Value::create(side) });
}
void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
@@ -314,59 +325,57 @@
bool InspectorFrontendClientLocal::isDebuggingEnabled()
{
- if (m_frontendLoaded)
- return evaluateAsBoolean("[\"isDebuggingEnabled\"]");
- return false;
+ auto result = m_frontendAPIDispatcher->dispatchCommandWithResultSync("isDebuggingEnabled"_s);
+ return result && result.value().toBoolean(m_frontendAPIDispatcher->frontendGlobalObject());
+
}
void InspectorFrontendClientLocal::setDebuggingEnabled(bool enabled)
{
- dispatch(makeString("[\"setDebuggingEnabled\", ", enabled ? "true" : "false", ']'));
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDebuggingEnabled"_s, { JSON::Value::create(enabled) });
}
bool InspectorFrontendClientLocal::isTimelineProfilingEnabled()
{
- if (m_frontendLoaded)
- return evaluateAsBoolean("[\"isTimelineProfilingEnabled\"]");
- return false;
+ auto result = m_frontendAPIDispatcher->dispatchCommandWithResultSync("isTimelineProfilingEnabled"_s);
+ return result && result.value().toBoolean(m_frontendAPIDispatcher->frontendGlobalObject());
}
void InspectorFrontendClientLocal::setTimelineProfilingEnabled(bool enabled)
{
- dispatch(makeString("[\"setTimelineProfilingEnabled\", ", enabled ? "true" : "false", ']'));
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setTimelineProfilingEnabled"_s, { JSON::Value::create(enabled) });
}
bool InspectorFrontendClientLocal::isProfilingJavaScript()
{
- if (m_frontendLoaded)
- return evaluateAsBoolean("[\"isProfilingJavaScript\"]");
- return false;
+ auto result = m_frontendAPIDispatcher->dispatchCommandWithResultSync("isProfilingJavaScript"_s);
+ return result && result.value().toBoolean(m_frontendAPIDispatcher->frontendGlobalObject());
}
void InspectorFrontendClientLocal::startProfilingJavaScript()
{
- dispatch("[\"startProfilingJavaScript\"]");
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("startProfilingJavaScript"_s);
}
void InspectorFrontendClientLocal::stopProfilingJavaScript()
{
- dispatch("[\"stopProfilingJavaScript\"]");
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("stopProfilingJavaScript"_s);
}
void InspectorFrontendClientLocal::showConsole()
{
- dispatch("[\"showConsole\"]");
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("showConsole"_s);
}
void InspectorFrontendClientLocal::showResources()
{
- dispatch("[\"showResources\"]");
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("showResources"_s);
}
void InspectorFrontendClientLocal::showMainResourceForFrame(Frame* frame)
{
String frameId = m_inspectedPageController->ensurePageAgent().frameId(frame);
- dispatch(makeString("[\"showMainResourceForFrame\", \"", frameId, "\"]"));
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("showMainResourceForFrame"_s, { JSON::Value::create(frameId) });
}
unsigned InspectorFrontendClientLocal::constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight)
@@ -394,46 +403,6 @@
return m_inspectedPageController->inspectionLevel() + 1;
}
-void InspectorFrontendClientLocal::dispatch(const String& signature)
-{
- ASSERT(!signature.isEmpty());
- ASSERT(signature.startsWith('['));
- ASSERT(signature.endsWith(']'));
-
- evaluateOnLoad("InspectorFrontendAPI.dispatch(" + signature + ")");
-}
-
-void InspectorFrontendClientLocal::dispatchMessage(const String& messageObject)
-{
- ASSERT(!messageObject.isEmpty());
-
- evaluateOnLoad("InspectorFrontendAPI.dispatchMessage(" + messageObject + ")");
-}
-
-void InspectorFrontendClientLocal::dispatchMessageAsync(const String& messageObject)
-{
- ASSERT(!messageObject.isEmpty());
-
- evaluateOnLoad("InspectorFrontendAPI.dispatchMessageAsync(" + messageObject + ")");
-}
-
-bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& _expression_)
-{
- auto& state = *mainWorldExecState(&m_frontendPage->mainFrame());
- return m_frontendPage->mainFrame().script().executeScriptIgnoringException(_expression_).toWTFString(&state) == "true";
-}
-
-void InspectorFrontendClientLocal::evaluateOnLoad(const String& _expression_)
-{
- if (!m_frontendLoaded) {
- m_evaluateOnLoad.append(_expression_);
- return;
- }
-
- JSC::SuspendExceptionScope scope(&m_frontendPage->inspectorController().vm());
- m_frontendPage->mainFrame().script().evaluateIgnoringException(ScriptSourceCode(_expression_));
-}
-
Page* InspectorFrontendClientLocal::inspectedPage() const
{
if (!m_inspectedPageController)
Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h (269209 => 269210)
--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h 2020-10-30 23:56:26 UTC (rev 269210)
@@ -31,6 +31,7 @@
#pragma once
+#include "InspectorFrontendAPIDispatcher.h"
#include "InspectorFrontendClient.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
@@ -66,6 +67,8 @@
WEBCORE_EXPORT void windowObjectCleared() final;
WEBCORE_EXPORT void frontendLoaded() override;
+ WEBCORE_EXPORT void pagePaused() final;
+ WEBCORE_EXPORT void pageUnpaused() final;
void startWindowDrag() override { }
WEBCORE_EXPORT void moveWindowBy(float x, float y) final;
@@ -91,6 +94,8 @@
WEBCORE_EXPORT unsigned inspectionLevel() const final;
String backendCommandsURL() const final { return String(); };
+ InspectorFrontendAPIDispatcher& frontendAPIDispatcher() final { return m_frontendAPIDispatcher; }
+
WEBCORE_EXPORT bool canAttachWindow();
WEBCORE_EXPORT void setDockingUnavailable(bool);
@@ -119,10 +124,6 @@
WEBCORE_EXPORT Page* inspectedPage() const;
Page* frontendPage() const { return m_frontendPage; }
- WEBCORE_EXPORT void dispatch(const String& signature);
- WEBCORE_EXPORT void dispatchMessage(const String& messageObject);
- WEBCORE_EXPORT void dispatchMessageAsync(const String& messageObject);
-
protected:
virtual void setAttachedWindowHeight(unsigned) = 0;
virtual void setAttachedWindowWidth(unsigned) = 0;
@@ -131,19 +132,16 @@
virtual void setSheetRect(const WebCore::FloatRect&) = 0;
private:
- bool evaluateAsBoolean(const String& _expression_);
- void evaluateOnLoad(const String& _expression_);
+ friend class FrontendMenuProvider;
- friend class FrontendMenuProvider;
InspectorController* m_inspectedPageController { nullptr };
Page* m_frontendPage { nullptr };
// TODO(yurys): this ref shouldn't be needed.
RefPtr<InspectorFrontendHost> m_frontendHost;
std::unique_ptr<InspectorFrontendClientLocal::Settings> m_settings;
- bool m_frontendLoaded { false };
DockSide m_dockSide;
- Vector<String> m_evaluateOnLoad;
Ref<InspectorBackendDispatchTask> m_dispatchTask;
+ Ref<InspectorFrontendAPIDispatcher> m_frontendAPIDispatcher;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.cpp (269209 => 269210)
--- trunk/Source/WebCore/testing/Internals.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebCore/testing/Internals.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -408,7 +408,7 @@
void InspectorStubFrontend::sendMessageToFrontend(const String& message)
{
- dispatchMessageAsync(message);
+ frontendAPIDispatcher().dispatchMessageAsync(message);
}
static bool markerTypeFrom(const String& markerType, DocumentMarker::MarkerType& result)
Modified: trunk/Source/WebKit/ChangeLog (269209 => 269210)
--- trunk/Source/WebKit/ChangeLog 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/ChangeLog 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1,3 +1,55 @@
+2020-10-30 Brian Burg <[email protected]>
+
+ Web Inspector: move InspectorFrontendAPIDispatcher to WebCore, clean up uses
+ https://bugs.webkit.org/show_bug.cgi?id=217835
+ <rdar://problem/70384407>
+
+ Reviewed by Devin Rousso.
+
+ Adopt the JSONValue-based InspectorFrontendAPIDispatcher::dispatch() method
+ in WebInspectorUI and RemoteInspectorUI methods that dispatch to the frontend.
+
+ * Sources.txt:
+ * WebKit.xcodeproj/project.pbxproj: Move files.
+
+ * WebProcess/Inspector/RemoteWebInspectorUI.h:
+ * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
+ (WebKit::RemoteWebInspectorUI::RemoteWebInspectorUI):
+ (WebKit::RemoteWebInspectorUI::initialize):
+ (WebKit::RemoteWebInspectorUI::updateFindString):
+ (WebKit::RemoteWebInspectorUI::didSave):
+ (WebKit::RemoteWebInspectorUI::didAppend):
+ (WebKit::RemoteWebInspectorUI::frontendLoaded):
+ (WebKit::RemoteWebInspectorUI::sendMessageToFrontend):
+ (WebKit::RemoteWebInspectorUI::pagePaused):
+ (WebKit::RemoteWebInspectorUI::pageUnpaused):
+ (WebKit::RemoteWebInspectorUI::setDiagnosticLoggingAvailable):
+
+ * WebProcess/Inspector/WebInspectorUI.h:
+ * WebProcess/Inspector/WebInspectorUI.cpp:
+ (WebKit::WebInspectorUI::WebInspectorUI):
+ (WebKit::WebInspectorUI::setDockSide):
+ (WebKit::WebInspectorUI::setDockingUnavailable):
+ (WebKit::WebInspectorUI::setIsVisible):
+ (WebKit::WebInspectorUI::updateFindString):
+ (WebKit::WebInspectorUI::setDiagnosticLoggingAvailable):
+ (WebKit::WebInspectorUI::showConsole):
+ (WebKit::WebInspectorUI::showResources):
+ (WebKit::WebInspectorUI::showMainResourceForFrame):
+ (WebKit::WebInspectorUI::startPageProfiling):
+ (WebKit::WebInspectorUI::stopPageProfiling):
+ (WebKit::WebInspectorUI::startElementSelection):
+ (WebKit::WebInspectorUI::stopElementSelection):
+ (WebKit::WebInspectorUI::didSave):
+ (WebKit::WebInspectorUI::didAppend):
+ (WebKit::WebInspectorUI::sendMessageToFrontend):
+ (WebKit::WebInspectorUI::evaluateInFrontendForTesting):
+ (WebKit::WebInspectorUI::pagePaused):
+ (WebKit::WebInspectorUI::pageUnpaused):
+
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ Add missing header includes (related to unified sources changes from r269168).
+
2020-10-30 Brent Fulgham <[email protected]>
Correct sandbox violations in GPU Process
Modified: trunk/Source/WebKit/Sources.txt (269209 => 269210)
--- trunk/Source/WebKit/Sources.txt 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/Sources.txt 2020-10-30 23:56:26 UTC (rev 269210)
@@ -547,7 +547,6 @@
WebProcess/Inspector/RemoteWebInspectorUI.cpp
WebProcess/Inspector/WebInspector.cpp
WebProcess/Inspector/WebInspectorClient.cpp
-WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp
WebProcess/Inspector/WebInspectorInterruptDispatcher.cpp
WebProcess/Inspector/WebInspectorUI.cpp
WebProcess/Inspector/WebPageInspectorTarget.cpp
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (269209 => 269210)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1492,7 +1492,6 @@
A55BA8251BA25CFB007CD33D /* RemoteWebInspectorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = A55BA8221BA25BB8007CD33D /* RemoteWebInspectorProxyMessages.h */; };
A55BA8261BA25CFD007CD33D /* RemoteWebInspectorProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A55BA8211BA25BB8007CD33D /* RemoteWebInspectorProxyMessageReceiver.cpp */; };
A55BA82B1BA38E61007CD33D /* WebInspectorUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = A55BA8281BA38E1E007CD33D /* WebInspectorUtilities.h */; };
- A55BA8351BA3E70A007CD33D /* WebInspectorFrontendAPIDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = A55BA8331BA3E6FA007CD33D /* WebInspectorFrontendAPIDispatcher.h */; };
A5860E71230F67FC00461AAE /* WebResourceInterceptController.h in Headers */ = {isa = PBXBuildFile; fileRef = A5860E70230F67DE00461AAE /* WebResourceInterceptController.h */; };
A58B6F0818FCA733008CBA53 /* WKFileUploadPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */; };
A5C0F0A72000654D00536536 /* _WKNSWindowExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A5C0F0A62000654400536536 /* _WKNSWindowExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4672,8 +4671,6 @@
A55BA8221BA25BB8007CD33D /* RemoteWebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteWebInspectorProxyMessages.h; path = DerivedSources/WebKit2/RemoteWebInspectorProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
A55BA8271BA38E1E007CD33D /* WebInspectorUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorUtilities.cpp; sourceTree = "<group>"; };
A55BA8281BA38E1E007CD33D /* WebInspectorUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorUtilities.h; sourceTree = "<group>"; };
- A55BA8321BA3E6FA007CD33D /* WebInspectorFrontendAPIDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorFrontendAPIDispatcher.cpp; sourceTree = "<group>"; };
- A55BA8331BA3E6FA007CD33D /* WebInspectorFrontendAPIDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorFrontendAPIDispatcher.h; sourceTree = "<group>"; };
A5860E6F230F67DE00461AAE /* WebResourceInterceptController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebResourceInterceptController.cpp; path = Network/WebResourceInterceptController.cpp; sourceTree = "<group>"; };
A5860E70230F67DE00461AAE /* WebResourceInterceptController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebResourceInterceptController.h; path = Network/WebResourceInterceptController.h; sourceTree = "<group>"; };
A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFileUploadPanel.h; path = ios/forms/WKFileUploadPanel.h; sourceTree = "<group>"; };
@@ -8707,8 +8704,6 @@
1C8E2A1C1277833F00BC7BD0 /* WebInspector.messages.in */,
BC111A59112F4FBB00337BAB /* WebInspectorClient.cpp */,
BC032D6D10F4378D0058C15A /* WebInspectorClient.h */,
- A55BA8321BA3E6FA007CD33D /* WebInspectorFrontendAPIDispatcher.cpp */,
- A55BA8331BA3E6FA007CD33D /* WebInspectorFrontendAPIDispatcher.h */,
FEE43FD01E67AFC60077D6D1 /* WebInspectorInterruptDispatcher.cpp */,
FEE43FD11E67AFC60077D6D1 /* WebInspectorInterruptDispatcher.h */,
FEE43FD21E67AFC60077D6D1 /* WebInspectorInterruptDispatcher.messages.in */,
@@ -11499,7 +11494,6 @@
BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */,
1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */,
BC032D8210F4378D0058C15A /* WebInspectorClient.h in Headers */,
- A55BA8351BA3E70A007CD33D /* WebInspectorFrontendAPIDispatcher.h in Headers */,
FEE43FD31E67B0180077D6D1 /* WebInspectorInterruptDispatcher.h in Headers */,
FEDBDCD71E68D20500A59F8F /* WebInspectorInterruptDispatcherMessages.h in Headers */,
1C8E2A361277852400BC7BD0 /* WebInspectorMessages.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -53,7 +53,7 @@
RemoteWebInspectorUI::RemoteWebInspectorUI(WebPage& page)
: m_page(page)
- , m_frontendAPIDispatcher(page)
+ , m_frontendAPIDispatcher(InspectorFrontendAPIDispatcher::create(*page.corePage()))
{
WebInspectorUI::enableFrontendFeatures();
}
@@ -65,30 +65,28 @@
m_page.corePage()->inspectorController().setInspectorFrontendClient(this);
- m_frontendAPIDispatcher.reset();
- m_frontendAPIDispatcher.dispatchCommand("setDockingUnavailable"_s, true);
+ m_frontendAPIDispatcher->reset();
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDockingUnavailable"_s, { JSON::Value::create(true) });
}
void RemoteWebInspectorUI::updateFindString(const String& findString)
{
- StringBuilder builder;
- JSON::Value::escapeString(builder, findString);
- m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, builder.toString());
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("updateFindString"_s, { JSON::Value::create(findString) });
}
void RemoteWebInspectorUI::didSave(const String& url)
{
- m_frontendAPIDispatcher.dispatchCommand("savedURL"_s, url);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("savedURL"_s, { JSON::Value::create(url) });
}
void RemoteWebInspectorUI::didAppend(const String& url)
{
- m_frontendAPIDispatcher.dispatchCommand("appendedToURL"_s, url);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("appendedToURL"_s, { JSON::Value::create(url) });
}
void RemoteWebInspectorUI::sendMessageToFrontend(const String& message)
{
- m_frontendAPIDispatcher.dispatchMessageAsync(message);
+ m_frontendAPIDispatcher->dispatchMessageAsync(message);
}
void RemoteWebInspectorUI::sendMessageToBackend(const String& message)
@@ -107,13 +105,23 @@
void RemoteWebInspectorUI::frontendLoaded()
{
- m_frontendAPIDispatcher.frontendLoaded();
+ m_frontendAPIDispatcher->frontendLoaded();
- m_frontendAPIDispatcher.dispatchCommand("setIsVisible"_s, true);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setIsVisible"_s, { JSON::Value::create(true) });
bringToFront();
}
+void RemoteWebInspectorUI::pagePaused()
+{
+ m_frontendAPIDispatcher->suspend();
+}
+
+void RemoteWebInspectorUI::pageUnpaused()
+{
+ m_frontendAPIDispatcher->unsuspend();
+}
+
void RemoteWebInspectorUI::changeSheetRect(const FloatRect& rect)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::SetSheetRect(rect), m_page.identifier());
@@ -246,7 +254,7 @@
ASSERT(!available || supportsDiagnosticLogging());
m_diagnosticLoggingAvailable = available;
- m_frontendAPIDispatcher.dispatchCommand("setDiagnosticLoggingAvailable"_s, m_diagnosticLoggingAvailable);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDiagnosticLoggingAvailable"_s, { JSON::Value::create(m_diagnosticLoggingAvailable) });
}
#endif
Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h 2020-10-30 23:56:26 UTC (rev 269210)
@@ -27,7 +27,7 @@
#include "DebuggableInfoData.h"
#include "MessageReceiver.h"
-#include "WebInspectorFrontendAPIDispatcher.h"
+#include <WebCore/InspectorFrontendAPIDispatcher.h>
#include <WebCore/InspectorFrontendClient.h>
#include <WebCore/InspectorFrontendHost.h>
#include <wtf/Deque.h>
@@ -62,6 +62,10 @@
// WebCore::InspectorFrontendClient
void windowObjectCleared() override;
void frontendLoaded() override;
+
+ void pagePaused() override;
+ void pageUnpaused() override;
+
void changeSheetRect(const WebCore::FloatRect&) override;
void startWindowDrag() override;
void moveWindowBy(float x, float y) override;
@@ -92,6 +96,7 @@
void inspectedURLChanged(const String&) override;
void showCertificate(const WebCore::CertificateInfo&) override;
void sendMessageToBackend(const String&) override;
+ WebCore::InspectorFrontendAPIDispatcher& frontendAPIDispatcher() override { return m_frontendAPIDispatcher; }
#if ENABLE(INSPECTOR_TELEMETRY)
bool supportsDiagnosticLogging() override;
@@ -110,7 +115,7 @@
explicit RemoteWebInspectorUI(WebPage&);
WebPage& m_page;
- WebInspectorFrontendAPIDispatcher m_frontendAPIDispatcher;
+ Ref<WebCore::InspectorFrontendAPIDispatcher> m_frontendAPIDispatcher;
RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
DebuggableInfoData m_debuggableInfo;
String m_backendCommandsURL;
Deleted: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebInspectorFrontendAPIDispatcher.h"
-
-#include "WebPage.h"
-#include <WebCore/Frame.h>
-#include <WebCore/ScriptController.h>
-#include <WebCore/ScriptState.h>
-
-namespace WebKit {
-
-WebInspectorFrontendAPIDispatcher::WebInspectorFrontendAPIDispatcher(WebPage& page)
- : m_page(page)
-{
-}
-
-void WebInspectorFrontendAPIDispatcher::reset()
-{
- m_frontendLoaded = false;
- m_suspended = false;
- m_queue.clear();
-}
-
-void WebInspectorFrontendAPIDispatcher::frontendLoaded()
-{
- m_frontendLoaded = true;
-
- evaluateQueuedExpressions();
-}
-
-void WebInspectorFrontendAPIDispatcher::suspend()
-{
- ASSERT(m_frontendLoaded);
- ASSERT(!m_suspended);
- ASSERT(m_queue.isEmpty());
-
- m_suspended = true;
-}
-
-void WebInspectorFrontendAPIDispatcher::unsuspend()
-{
- ASSERT(m_suspended);
-
- m_suspended = false;
-
- evaluateQueuedExpressions();
-}
-
-void WebInspectorFrontendAPIDispatcher::dispatchCommand(const String& command)
-{
- evaluateOrQueueExpression(makeString("InspectorFrontendAPI.dispatch([\"", command, "\"])"));
-}
-
-void WebInspectorFrontendAPIDispatcher::dispatchCommand(const String& command, const String& argument)
-{
- evaluateOrQueueExpression(makeString("InspectorFrontendAPI.dispatch([\"", command, "\", \"", argument, "\"])"));
-}
-
-void WebInspectorFrontendAPIDispatcher::dispatchCommand(const String& command, bool argument)
-{
- evaluateOrQueueExpression(makeString("InspectorFrontendAPI.dispatch([\"", command, "\", ", argument ? "true" : "false", "])"));
-}
-
-void WebInspectorFrontendAPIDispatcher::dispatchMessageAsync(const String& message)
-{
- evaluateOrQueueExpression(makeString("InspectorFrontendAPI.dispatchMessageAsync(", message, ")"));
-}
-
-void WebInspectorFrontendAPIDispatcher::evaluateOrQueueExpression(const String& _expression_)
-{
- if (!m_frontendLoaded || m_suspended) {
- m_queue.append(_expression_);
- return;
- }
-
- ASSERT(m_queue.isEmpty());
- ASSERT(!m_page.corePage()->mainFrame().script().isPaused());
- m_page.corePage()->mainFrame().script().executeScriptIgnoringException(_expression_);
-}
-
-void WebInspectorFrontendAPIDispatcher::evaluateQueuedExpressions()
-{
- if (m_queue.isEmpty())
- return;
-
- for (const String& _expression_ : m_queue) {
- ASSERT(!m_page.corePage()->mainFrame().script().isPaused());
- m_page.corePage()->mainFrame().script().executeScriptIgnoringException(_expression_);
- }
-
- m_queue.clear();
-}
-
-void WebInspectorFrontendAPIDispatcher::evaluateExpressionForTesting(const String& _expression_)
-{
- evaluateOrQueueExpression(_expression_);
-}
-
-} // namespace WebKit
Deleted: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/Deque.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebKit {
-
-class WebPage;
-
-class WebInspectorFrontendAPIDispatcher {
-public:
- WebInspectorFrontendAPIDispatcher(WebPage&);
-
- void reset();
- void frontendLoaded();
-
- void suspend();
- void unsuspend();
-
- void dispatchCommand(const String& command);
- void dispatchCommand(const String& command, const String& argument);
- void dispatchCommand(const String& command, bool argument);
- void dispatchMessageAsync(const String& message);
-
- void evaluateExpressionForTesting(const String&);
-private:
- void evaluateOrQueueExpression(const String&);
- void evaluateQueuedExpressions();
-
- WebPage& m_page;
- Deque<String> m_queue;
- bool m_frontendLoaded { false };
- bool m_suspended { false };
-};
-
-} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -59,7 +59,7 @@
WebInspectorUI::WebInspectorUI(WebPage& page)
: m_page(page)
- , m_frontendAPIDispatcher(page)
+ , m_frontendAPIDispatcher(InspectorFrontendAPIDispatcher::create(*page.corePage()))
, m_debuggableInfo(DebuggableInfoData::empty())
{
WebInspectorUI::enableFrontendFeatures();
@@ -72,7 +72,7 @@
m_underTest = underTest;
m_inspectionLevel = inspectionLevel;
- m_frontendAPIDispatcher.reset();
+ m_frontendAPIDispatcher->reset();
m_frontendController = &m_page.corePage()->inspectorController();
m_frontendController->setInspectorFrontendClient(this);
@@ -121,7 +121,7 @@
void WebInspectorUI::frontendLoaded()
{
- m_frontendAPIDispatcher.frontendLoaded();
+ m_frontendAPIDispatcher->frontendLoaded();
// Tell the new frontend about the current dock state. If the window object
// cleared due to a reload, the dock state won't be resent from UIProcess.
@@ -244,7 +244,7 @@
m_dockSide = dockSide;
- m_frontendAPIDispatcher.dispatchCommand("setDockSide"_s, String(dockSideString));
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDockSide"_s, { JSON::Value::create(String(dockSideString)) });
}
void WebInspectorUI::setDockingUnavailable(bool unavailable)
@@ -251,7 +251,7 @@
{
m_dockingUnavailable = unavailable;
- m_frontendAPIDispatcher.dispatchCommand("setDockingUnavailable"_s, unavailable);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDockingUnavailable"_s, { JSON::Value::create(unavailable) });
}
void WebInspectorUI::setIsVisible(bool visible)
@@ -258,14 +258,12 @@
{
m_isVisible = visible;
- m_frontendAPIDispatcher.dispatchCommand("setIsVisible"_s, visible);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setIsVisible"_s, { JSON::Value::create(visible) });
}
void WebInspectorUI::updateFindString(const String& findString)
{
- StringBuilder builder;
- JSON::Value::escapeString(builder, findString);
- m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, builder.toString());
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("updateFindString"_s, { JSON::Value::create(findString) });
}
void WebInspectorUI::changeAttachedWindowHeight(unsigned height)
@@ -325,73 +323,73 @@
ASSERT(!available || supportsDiagnosticLogging());
m_diagnosticLoggingAvailable = available;
- m_frontendAPIDispatcher.dispatchCommand("setDiagnosticLoggingAvailable"_s, m_diagnosticLoggingAvailable);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setDiagnosticLoggingAvailable"_s, { JSON::Value::create(m_diagnosticLoggingAvailable) });
}
#endif
void WebInspectorUI::showConsole()
{
- m_frontendAPIDispatcher.dispatchCommand("showConsole"_s);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("showConsole"_s);
}
void WebInspectorUI::showResources()
{
- m_frontendAPIDispatcher.dispatchCommand("showResources"_s);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("showResources"_s);
}
void WebInspectorUI::showMainResourceForFrame(const String& frameIdentifier)
{
- m_frontendAPIDispatcher.dispatchCommand("showMainResourceForFrame"_s, frameIdentifier);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("showMainResourceForFrame"_s, { JSON::Value::create(frameIdentifier) });
}
void WebInspectorUI::startPageProfiling()
{
- m_frontendAPIDispatcher.dispatchCommand("setTimelineProfilingEnabled"_s, true);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setTimelineProfilingEnabled"_s, { JSON::Value::create(true) });
}
void WebInspectorUI::stopPageProfiling()
{
- m_frontendAPIDispatcher.dispatchCommand("setTimelineProfilingEnabled"_s, false);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setTimelineProfilingEnabled"_s, { JSON::Value::create(false) });
}
void WebInspectorUI::startElementSelection()
{
- m_frontendAPIDispatcher.dispatchCommand("setElementSelectionEnabled"_s, true);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setElementSelectionEnabled"_s, { JSON::Value::create(true) });
}
void WebInspectorUI::stopElementSelection()
{
- m_frontendAPIDispatcher.dispatchCommand("setElementSelectionEnabled"_s, false);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("setElementSelectionEnabled"_s, { JSON::Value::create(false) });
}
void WebInspectorUI::didSave(const String& url)
{
- m_frontendAPIDispatcher.dispatchCommand("savedURL"_s, url);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("savedURL"_s, { JSON::Value::create(url) });
}
void WebInspectorUI::didAppend(const String& url)
{
- m_frontendAPIDispatcher.dispatchCommand("appendedToURL"_s, url);
+ m_frontendAPIDispatcher->dispatchCommandWithResultAsync("appendedToURL"_s, { JSON::Value::create(url) });
}
void WebInspectorUI::sendMessageToFrontend(const String& message)
{
- m_frontendAPIDispatcher.dispatchMessageAsync(message);
+ m_frontendAPIDispatcher->dispatchMessageAsync(message);
}
void WebInspectorUI::evaluateInFrontendForTesting(const String& _expression_)
{
- m_frontendAPIDispatcher.evaluateExpressionForTesting(_expression_);
+ m_frontendAPIDispatcher->evaluateExpressionForTesting(_expression_);
}
void WebInspectorUI::pagePaused()
{
- m_frontendAPIDispatcher.suspend();
+ m_frontendAPIDispatcher->suspend();
}
void WebInspectorUI::pageUnpaused()
{
- m_frontendAPIDispatcher.unsuspend();
+ m_frontendAPIDispatcher->unsuspend();
}
void WebInspectorUI::sendMessageToBackend(const String& message)
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h 2020-10-30 23:56:26 UTC (rev 269210)
@@ -27,9 +27,9 @@
#include "Connection.h"
#include "DebuggableInfoData.h"
-#include "WebInspectorFrontendAPIDispatcher.h"
#include "WebPageProxyIdentifier.h"
#include <WebCore/InspectorDebuggableType.h>
+#include <WebCore/InspectorFrontendAPIDispatcher.h>
#include <WebCore/InspectorFrontendClient.h>
#include <WebCore/InspectorFrontendHost.h>
@@ -142,6 +142,7 @@
#endif
void sendMessageToBackend(const String&) override;
+ WebCore::InspectorFrontendAPIDispatcher& frontendAPIDispatcher() final { return m_frontendAPIDispatcher; }
void pagePaused() override;
void pageUnpaused() override;
@@ -152,7 +153,7 @@
explicit WebInspectorUI(WebPage&);
WebPage& m_page;
- WebInspectorFrontendAPIDispatcher m_frontendAPIDispatcher;
+ Ref<WebCore::InspectorFrontendAPIDispatcher> m_frontendAPIDispatcher;
RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
// Keep a pointer to the frontend's inspector controller rather than going through
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (269209 => 269210)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -103,6 +103,8 @@
#endif
#if ENABLE(WEB_AUTHN)
+#include "WebAuthnConnectionToWebProcessMessages.h"
+#include "WebAuthnProcessConnection.h"
#include <WebCore/MockWebAuthenticationConfiguration.h>
#endif
Modified: trunk/Source/WebKitLegacy/cf/ChangeLog (269209 => 269210)
--- trunk/Source/WebKitLegacy/cf/ChangeLog 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKitLegacy/cf/ChangeLog 2020-10-30 23:56:26 UTC (rev 269210)
@@ -1,3 +1,14 @@
+2020-10-30 Brian Burg <[email protected]>
+
+ Web Inspector: move InspectorFrontendAPIDispatcher to WebCore, clean up uses
+ https://bugs.webkit.org/show_bug.cgi?id=217835
+ <rdar://problem/70384407>
+
+ Reviewed by Devin Rousso.
+
+ * WebCoreSupport/WebInspectorClientCF.cpp:
+ (WebInspectorClient::sendMessageToFrontend):
+
2019-08-18 Yusuke Suzuki <[email protected]>
[WTF] Add makeUnique<T>, which ensures T is fast-allocated, makeUnique / makeUniqueWithoutFastMallocCheck part
Modified: trunk/Source/WebKitLegacy/cf/WebCoreSupport/WebInspectorClientCF.cpp (269209 => 269210)
--- trunk/Source/WebKitLegacy/cf/WebCoreSupport/WebInspectorClientCF.cpp 2020-10-30 23:52:28 UTC (rev 269209)
+++ trunk/Source/WebKitLegacy/cf/WebCoreSupport/WebInspectorClientCF.cpp 2020-10-30 23:56:26 UTC (rev 269210)
@@ -96,7 +96,7 @@
void WebInspectorClient::sendMessageToFrontend(const String& message)
{
- m_frontendClient->dispatchMessageAsync(message);
+ m_frontendClient->frontendAPIDispatcher().dispatchMessageAsync(message);
}
bool WebInspectorClient::inspectorAttachDisabled()