Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
browser(webkit): roll to WebKit ToT 1/29/2020 (#737)
Pavel Feldman87abfe02a4a9
diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBERindex aa309ccc9a..b065a3face 100644--- a/browser_patches/webkit/BUILD_NUMBER+++ b/browser_patches/webkit/BUILD_NUMBER@@ -1 +1 @@-1122+1123diff --git a/browser_patches/webkit/UPSTREAM_CONFIG.sh b/browser_patches/webkit/UPSTREAM_CONFIG.shindex d17ed2b781..014ffe47f9 100644--- a/browser_patches/webkit/UPSTREAM_CONFIG.sh+++ b/browser_patches/webkit/UPSTREAM_CONFIG.sh@@ -1,3 +1,3 @@REMOTE_URL="https://github.com/webkit/webkit"BASE_BRANCH="master"-BASE_REVISION="bf547c919b89d82d840e3f2182d0f380683f4816"+BASE_REVISION="2a52aca933f9fe020a3aa0d93d58837b3dcb7b44"diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diffindex 57c43cb3fe..7174cd10e3 100644--- a/browser_patches/webkit/patches/bootstrap.diff+++ b/browser_patches/webkit/patches/bootstrap.diff@@ -959,7 +959,7 @@ index 658f14f8af68073b99a01dd7332628223b67fcd7..cd28887b9a01826c2d374bdada487c81"name": "webSocketWillSendHandshakeRequest","description": "Fired when WebSocket is about to initiate handshake.",diff --git a/Source/JavaScriptCore/inspector/protocol/Page.json b/Source/JavaScriptCore/inspector/protocol/Page.json-index a8fc5332ac92424b00a3dec62152fd3c5f28544e..6dc8ac8e247631d2af6418155f088ea3cc172797 100644+index a8fc5332ac92424b00a3dec62152fd3c5f28544e..a22ffffa8c8853daf04df6358abb26ebc79e3e49 100644--- a/Source/JavaScriptCore/inspector/protocol/Page.json+++ b/Source/JavaScriptCore/inspector/protocol/Page.json@@ -110,6 +110,41 @@@@ -1041,7 +1041,7 @@ index a8fc5332ac92424b00a3dec62152fd3c5f28544e..6dc8ac8e247631d2af6418155f088ea3{"name": "snapshotNode","description": "Capture a snapshot of the specified node that does not include unrelated layers.",-@@ -276,19 +328,71 @@+@@ -276,19 +328,70 @@"returns": [{ "name": "data", "type": "string", "description": "Base64-encoded web archive." }]@@ -1078,11 +1078,10 @@ index a8fc5332ac92424b00a3dec62152fd3c5f28544e..6dc8ac8e247631d2af6418155f088ea3+ ]+ },+ {-+ "name": "createIsolatedWorld",-+ "description": "Creates an isolated world for every loaded frame.",++ "name": "createUserWorld",++ "description": "Creates an user world for every loaded frame.",+ "parameters": [-+ { "name": "name", "type": "string", "description": "Isolated world name, will be used as an execution context name." },-+ { "name": "source", "type": "string", "optional": true, "description": "Script to evaluate in the new world." }++ { "name": "name", "type": "string", "description": "Isolated world name, will be used as an execution context name." }+ ]+ },+ {@@ -1115,7 +1114,7 @@ index a8fc5332ac92424b00a3dec62152fd3c5f28544e..6dc8ac8e247631d2af6418155f088ea3]},{-@@ -298,6 +402,14 @@+@@ -298,6 +401,14 @@{ "name": "frame", "$ref": "Frame", "description": "Frame object." }]},@@ -1130,7 +1129,7 @@ index a8fc5332ac92424b00a3dec62152fd3c5f28544e..6dc8ac8e247631d2af6418155f088ea3{"name": "frameDetached","description": "Fired when frame has been detached from its parent.",-@@ -334,12 +446,36 @@+@@ -334,12 +445,36 @@{ "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }]},@@ -1237,7 +1236,7 @@ index 9e2bee913d37c79fedbb918176a43022b84fa45b..ad8926d773144114dad3842fa0fe2391},{diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h-index 944025fb4add55074eee3eb915d86fa17dd56d6b..de3020e26037d445c39b6bf549d515788d860633 100644+index 0a4667a4f5fc75b0923305783d1b06f8929061fc..64db8b4c46adea24a97378274112b06bb5cc7a79 100644--- a/Source/WTF/wtf/PlatformHave.h+++ b/Source/WTF/wtf/PlatformHave.h@@ -373,7 +373,7 @@@@ -1265,10 +1264,10 @@ index a256d2f8a42548c42ae3c955d9502cc0ad893d91..7e30dfcec151304b21b39286a841e38e}diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt-index 106740d349c4156dbef134ef19d654575cdf0c93..eb92a1092d99bb42246d2c87fde1180e6bf5c1c7 100644+index 4de75df8df0b8f90e5b258157eada4a69d3b5916..51dc93bc25fdba7a971b3fdd4f1f380f5d6b48c5 100644--- a/Source/WebCore/SourcesCocoa.txt+++ b/Source/WebCore/SourcesCocoa.txt-@@ -643,7 +643,7 @@ WHLSLStandardLibraryFunctionMap.cpp+@@ -644,7 +644,7 @@ WHLSLStandardLibraryFunctionMap.cpp#endif@@ -1290,10 +1289,10 @@ index 37d245e11e8bf3626523f076ea2b93d2c106e19b..93f4f64f705580535a8d3b077a9a1581__ZN7WebCore14DocumentLoaderD2Ev__ZN7WebCore14DocumentLoader17clearMainResourceEvdiff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj-index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918d5620cc7 100644+index cc587ce562745750aa5bd94c9100873b179d4e2b..8ce856285a9f8ce84cde2fcfb7622555a61a0f2b 100644--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj-@@ -4946,6 +4946,14 @@+@@ -4948,6 +4948,14 @@EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = EDE3A4FF0C7A430600956A37 /* ColorMac.h */; settings = {ATTRIBUTES = (Private, ); }; };EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; };EFCC6C8F20FE914400A2321B /* CanvasActivityRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = EFCC6C8D20FE914000A2321B /* CanvasActivityRecord.h */; settings = {ATTRIBUTES = (Private, ); }; };@@ -1308,7 +1307,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918F12171F516A8CED2000053CA /* WebVTTElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F12171F316A8BC63000053CA /* WebVTTElement.cpp */; };F12171F616A8CF0B000053CA /* WebVTTElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F12171F416A8BC63000053CA /* WebVTTElement.h */; };F32BDCD92363AACA0073B6AE /* UserGestureEmulationScope.h in Headers */ = {isa = PBXBuildFile; fileRef = F32BDCD72363AACA0073B6AE /* UserGestureEmulationScope.h */; };-@@ -15444,6 +15452,14 @@+@@ -15393,6 +15401,14 @@EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };EFB7287B2124C73D005C2558 /* CanvasActivityRecord.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasActivityRecord.cpp; sourceTree = "<group>"; };EFCC6C8D20FE914000A2321B /* CanvasActivityRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasActivityRecord.h; sourceTree = "<group>"; };@@ -1323,7 +1322,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918F12171F316A8BC63000053CA /* WebVTTElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTElement.cpp; sourceTree = "<group>"; };F12171F416A8BC63000053CA /* WebVTTElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTElement.h; sourceTree = "<group>"; };F32BDCD52363AAC90073B6AE /* UserGestureEmulationScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserGestureEmulationScope.cpp; sourceTree = "<group>"; };-@@ -20726,7 +20742,12 @@+@@ -20608,7 +20624,12 @@2D2E34A921A4E191004598B5 /* EditableImageReference.h */,1AF326770D78B9440068F0C4 /* EditorClient.h */,93C09A800B064F00005ABD4D /* EventHandler.cpp */,@@ -1336,7 +1335,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918E0FEF371B27C53EAC1C1FBEE /* EventSource.cpp */,E0FEF371B17C53EAC1C1FBEE /* EventSource.h */,E0FEF371B07C53EAC1C1FBEE /* EventSource.idl */,-@@ -25942,7 +25963,9 @@+@@ -25826,7 +25847,9 @@B2C3D9EC0D006C1D00EF6F26 /* text */,E188235F2031F50F00B42DF3 /* vr */,DFDB912CF8E88A6DA1AD264F /* AbortableTaskQueue.h */,@@ -1346,7 +1345,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da191849AE2D95134EE5F90072920A /* CalculationValue.h */,C330A22113EC196B0000B45B /* ColorChooser.h */,C37CDEBC149EF2030042090D /* ColorChooserClient.h */,-@@ -28170,6 +28193,7 @@+@@ -28049,6 +28072,7 @@BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */,AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */,AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */,@@ -1354,7 +1353,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da19186BDB5DC1227BD3B800919770 /* DocumentStorageAccess.cpp */,6BDB5DC0227BD3B800919770 /* DocumentStorageAccess.h */,6BDB5DC5227CA0EB00919770 /* DocumentStorageAccess.idl */,-@@ -29055,6 +29079,7 @@+@@ -28934,6 +28958,7 @@93C4F6EB1108F9A50099D0DB /* AccessibilityScrollbar.h in Headers */,29489FC712C00F0300D83F0F /* AccessibilityScrollView.h in Headers */,0709FC4E1025DEE30059CDBA /* AccessibilitySlider.h in Headers */,@@ -1362,7 +1361,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da191829D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */,69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */,AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */,-@@ -30886,6 +30911,7 @@+@@ -30769,6 +30794,7 @@6E4ABCD5138EA0B70071D291 /* JSHTMLUnknownElement.h in Headers */,E44614170CD6826900FADA75 /* JSHTMLVideoElement.h in Headers */,81BE20D311F4BC3200915DFA /* JSIDBCursor.h in Headers */,@@ -1370,7 +1369,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da19187C3D8EF01E0B21430023B084 /* JSIDBCursorDirection.h in Headers */,C585A68311D4FB08004C3E4B /* JSIDBDatabase.h in Headers */,C585A69711D4FB13004C3E4B /* JSIDBFactory.h in Headers */,-@@ -32800,9 +32826,11 @@+@@ -32684,9 +32710,11 @@A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */,B2C3DA3A0D006C1D00EF6F26 /* TextCodec.h in Headers */,26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */,@@ -1382,7 +1381,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */,B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */,9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,-@@ -33690,6 +33718,7 @@+@@ -33570,6 +33598,7 @@CDDE02ED18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm in Sources */,CDDE02F018B5651300CF7FF1 /* CDMSessionAVStreamSession.mm in Sources */,CDE5959D1BF2757100A1CBE8 /* CDMSessionMediaSourceAVFObjC.mm in Sources */,@@ -1390,7 +1389,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918A14090FB1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm in Sources */,07AFF4231EFB144900B545B3 /* CoreAudioCaptureSourceIOS.mm in Sources */,46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */,-@@ -33763,6 +33792,7 @@+@@ -33643,6 +33672,7 @@51058ADF1D67C229009A538C /* MockGamepad.cpp in Sources */,51058AE11D67C229009A538C /* MockGamepadProvider.cpp in Sources */,CDF2B0121820540600F2B424 /* MockMediaPlayerMediaSource.cpp in Sources */,@@ -1398,7 +1397,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918CDF2B0141820540600F2B424 /* MockMediaSourcePrivate.cpp in Sources */,CDF2B0161820540700F2B424 /* MockSourceBufferPrivate.cpp in Sources */,2D9BF7421DBFDC27007A7D99 /* NavigatorEME.cpp in Sources */,-@@ -33848,6 +33878,7 @@+@@ -33728,6 +33758,7 @@538EC8881F993F9C004D22A8 /* UnifiedSource23.cpp in Sources */,DE5F85801FA1ABF4006DB63A /* UnifiedSource24-mm.mm in Sources */,538EC8891F993F9D004D22A8 /* UnifiedSource24.cpp in Sources */,@@ -1406,7 +1405,7 @@ index 672f1cf7cdc9b7dbb9a601437cbd21e6701130ab..9ea20cff7697b9b6f7a19b1057da1918DE5F85811FA1ABF4006DB63A /* UnifiedSource25-mm.mm in Sources */,538EC88A1F993F9D004D22A8 /* UnifiedSource25.cpp in Sources */,DE5F85821FA1ABF4006DB63A /* UnifiedSource26-mm.mm in Sources */,-@@ -34380,6 +34411,7 @@+@@ -34260,6 +34291,7 @@2D8B92F1203D13E1009C868F /* UnifiedSource516.cpp in Sources */,2D8B92F2203D13E1009C868F /* UnifiedSource517.cpp in Sources */,2D8B92F3203D13E1009C868F /* UnifiedSource518.cpp in Sources */,@@ -1439,29 +1438,10 @@ index 4e41fd3f807e8f34bfef3f63f0ba6119a619821e..1f7be602cb2134f8867bf95afe0c9337return;diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp-index 4f18b58c6cd01e0b69a8953ad09a739c3520496a..724fdb3d8e37dfc29069e2e2a65adefb72818cf5 100644+index d0c430e2bb880a6e3583a998d6dcfc143bd6ebde..ef310ac9063c26d0c936cbc73cb94bc30b1e12a1 100644--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp-@@ -121,7 +121,7 @@ static Frame* frameForScriptExecutionContext(ScriptExecutionContext& context)-- void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world)- {-- if (&world != &mainThreadNormalWorld())-+ if (!world.isNormal())- return;-- if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())-@@ -129,9 +129,6 @@ void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgen-- if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent())- pageRuntimeAgent->didClearWindowObjectInWorld(frame);---- if (auto* pageAgent = instrumentingAgents.inspectorPageAgent())-- pageAgent->didClearWindowObjectInWorld(frame);- }-- bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents& instrumentingAgents)-@@ -624,6 +621,12 @@ void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents& instrumen+@@ -621,6 +621,12 @@ void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents& instrumenconsoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.}@@ -1474,7 +1454,7 @@ index 4f18b58c6cd01e0b69a8953ad09a739c3520496a..724fdb3d8e37dfc29069e2e2a65adefbvoid InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents& instrumentingAgents){if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())-@@ -656,20 +659,17 @@ void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents&+@@ -653,20 +659,17 @@ void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents&void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents& instrumentingAgents, Frame& frame){@@ -1498,7 +1478,7 @@ index 4f18b58c6cd01e0b69a8953ad09a739c3520496a..724fdb3d8e37dfc29069e2e2a65adefb}void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)-@@ -744,12 +744,6 @@ void InspectorInstrumentation::frameDocumentUpdatedImpl(InstrumentingAgents& ins+@@ -741,12 +744,6 @@ void InspectorInstrumentation::frameDocumentUpdatedImpl(InstrumentingAgents& inspageDOMDebuggerAgent->frameDocumentUpdated(frame);}@@ -1511,7 +1491,7 @@ index 4f18b58c6cd01e0b69a8953ad09a739c3520496a..724fdb3d8e37dfc29069e2e2a65adefbvoid InspectorInstrumentation::frameStartedLoadingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame){if (frame.isMainFrame()) {-@@ -786,6 +780,12 @@ void InspectorInstrumentation::frameClearedScheduledNavigationImpl(Instrumenting+@@ -783,6 +780,12 @@ void InspectorInstrumentation::frameClearedScheduledNavigationImpl(InstrumentinginspectorPageAgent->frameClearedScheduledNavigation(frame);}@@ -1524,7 +1504,7 @@ index 4f18b58c6cd01e0b69a8953ad09a739c3520496a..724fdb3d8e37dfc29069e2e2a65adefbvoid InspectorInstrumentation::defaultAppearanceDidChangeImpl(InstrumentingAgents& instrumentingAgents, bool useDarkAppearance){if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())-@@ -1266,6 +1266,31 @@ void InspectorInstrumentation::renderLayerDestroyedImpl(InstrumentingAgents& ins+@@ -1263,6 +1266,31 @@ void InspectorInstrumentation::renderLayerDestroyedImpl(InstrumentingAgents& inslayerTreeAgent->renderLayerDestroyed(renderLayer);}@@ -2527,7 +2507,7 @@ index a68f84520736977c8b9216616c5a178fbf5275d6..8d6ed7188bca75fb46d1a5963983f088} // namespace WebCorediff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp-index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b701029f1 100644+index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eeaafa37089 100644--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp@@ -32,6 +32,8 @@@@ -2539,8 +2519,8 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b#include "CachedResource.h"#include "CachedResourceLoader.h"#include "Cookie.h"-@@ -39,12 +41,15 @@- #include "CustomHeaderFields.h"+@@ -40,12 +42,15 @@+ #include "DOMWrapperWorld.h"#include "Document.h"#include "DocumentLoader.h"+#include "FocusController.h"@@ -2555,7 +2535,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b#include "HTMLNames.h"#include "ImageBuffer.h"#include "InspectorClient.h"-@@ -55,18 +60,24 @@+@@ -56,18 +61,24 @@#include "MIMETypeRegistry.h"#include "MemoryCache.h"#include "Page.h"@@ -2580,7 +2560,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b#include <wtf/ListHashSet.h>#include <wtf/Stopwatch.h>#include <wtf/text/Base64.h>-@@ -339,6 +350,7 @@ InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClien+@@ -340,6 +351,7 @@ InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClien, m_frontendDispatcher(makeUnique<Inspector::PageFrontendDispatcher>(context.frontendRouter)), m_backendDispatcher(Inspector::PageBackendDispatcher::create(context.backendDispatcher, this)), m_inspectedPage(context.inspectedPage)@@ -2588,7 +2568,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b, m_client(client), m_overlay(overlay){-@@ -377,6 +389,8 @@ void InspectorPageAgent::enable(ErrorString& errorString)+@@ -378,6 +390,8 @@ void InspectorPageAgent::enable(ErrorString& errorString)void InspectorPageAgent::disable(ErrorString&){m_instrumentingAgents.setInspectorPageAgent(nullptr);@@ -2597,15 +2577,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861bErrorString unused;setShowPaintRects(unused, false);-@@ -384,6 +398,7 @@ void InspectorPageAgent::disable(ErrorString&)- overrideUserAgent(unused, nullptr);- setEmulatedMedia(unused, emptyString());- setForcedAppearance(unused, emptyString());-+ m_isolatedWorldScripts.clear();-- #define DISABLE_INSPECTOR_OVERRIDE_SETTING(name) \- m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt);-@@ -414,14 +429,36 @@ void InspectorPageAgent::reload(ErrorString&, const bool* optionalReloadFromOrig+@@ -415,14 +429,36 @@ void InspectorPageAgent::reload(ErrorString&, const bool* optionalReloadFromOrigm_inspectedPage.mainFrame().loader().reload(reloadOptions);}@@ -2647,7 +2619,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b}void InspectorPageAgent::overrideUserAgent(ErrorString&, const String* value)-@@ -682,15 +719,16 @@ void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show)+@@ -683,15 +719,16 @@ void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show)m_overlay->setShowPaintRects(show);}@@ -2669,7 +2641,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b}void InspectorPageAgent::frameNavigated(Frame& frame)-@@ -698,13 +736,18 @@ void InspectorPageAgent::frameNavigated(Frame& frame)+@@ -699,13 +736,18 @@ void InspectorPageAgent::frameNavigated(Frame& frame)m_frontendDispatcher->frameNavigated(buildObjectForFrame(&frame));}@@ -2691,7 +2663,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b}Frame* InspectorPageAgent::frameForId(const String& frameId)-@@ -716,20 +759,18 @@ String InspectorPageAgent::frameId(Frame* frame)+@@ -717,20 +759,18 @@ String InspectorPageAgent::frameId(Frame* frame){if (!frame)return emptyString();@@ -2718,7 +2690,7 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b}Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& frameId)-@@ -740,11 +781,6 @@ Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& f+@@ -741,11 +781,6 @@ Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& freturn frame;}@@ -2730,30 +2702,20 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861bvoid InspectorPageAgent::frameStartedLoading(Frame& frame){m_frontendDispatcher->frameStartedLoading(frameId(&frame));-@@ -765,17 +801,15 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)+@@ -766,6 +801,12 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)m_frontendDispatcher->frameClearedScheduledNavigation(frameId(&frame));}--void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance)+void InspectorPageAgent::didNavigateWithinPage(Frame& frame)- {-- m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);++{+ String url = frame.document()->url().string();+ m_frontendDispatcher->navigatedWithinDocument(frameId(&frame), url);- }---void InspectorPageAgent::didClearWindowObjectInWorld(Frame& frame)-+void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance)++}+++ void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance){-- if (m_bootstrapScript.isEmpty())-- return;---- frame.script().evaluateIgnoringException(ScriptSourceCode(m_bootstrapScript, URL { URL(), "web-inspector://bootstrap.js"_s }));-+ m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);- }-- void InspectorPageAgent::didPaint(RenderObject& renderer, const LayoutRect& rect)-@@ -819,6 +853,38 @@ void InspectorPageAgent::didRecalculateStyle()+ m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);+@@ -823,6 +864,38 @@ void InspectorPageAgent::didRecalculateStyle()m_overlay->update();}@@ -2792,11 +2754,12 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861bRef<Inspector::Protocol::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame){ASSERT_ARG(frame, frame);-@@ -962,6 +1028,17 @@ void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, in+@@ -966,6 +1039,18 @@ void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, in*outDataURL = snapshot->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);}-+void InspectorPageAgent::setTouchEmulationEnabled(ErrorString& errorString, bool enabled) {++void InspectorPageAgent::setTouchEmulationEnabled(ErrorString& errorString, bool enabled)++{+#if ENABLE(TOUCH_EVENTS)+ RuntimeEnabledFeatures::sharedFeatures().setTouchEventsEnabled(enabled);+ UNUSED_PARAM(errorString);@@ -2810,17 +2773,19 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861bvoid InspectorPageAgent::archive(ErrorString& errorString, String* data){#if ENABLE(WEB_ARCHIVE) && USE(CF)-@@ -979,4 +1056,511 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)+@@ -983,4 +1068,514 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)#endif}-+void InspectorPageAgent::insertText(ErrorString&, const String& text) {++void InspectorPageAgent::insertText(ErrorString&, const String& text)++{+ UserGestureIndicator indicator { ProcessingUserGesture };+ Document* focusedDocument = m_inspectedPage.focusController().focusedOrMainFrame().document();+ TypingCommand::insertText(*focusedDocument, text, 0);+}+-+static String roleFromObject(RefPtr<AXCoreObject> axObject) {++static String roleFromObject(RefPtr<AXCoreObject> axObject)++{+ String computedRoleString = axObject->computedRoleString();+ if (!computedRoleString.isEmpty())+ return computedRoleString;@@ -3132,7 +3097,8 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b+ return "Unknown";+}+-+static RefPtr<Inspector::Protocol::Page::AXNode> snapshotForAXObject(RefPtr<AXCoreObject> axObject, Node* nodeToFind) {++static RefPtr<Inspector::Protocol::Page::AXNode> snapshotForAXObject(RefPtr<AXCoreObject> axObject, Node* nodeToFind)++{+ auto axNode = Inspector::Protocol::Page::AXNode::create()+ .setRole(roleFromObject(axObject))+ .release();@@ -3244,7 +3210,8 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b+}++-+void InspectorPageAgent::accessibilitySnapshot(ErrorString& errorString, const String* objectId, RefPtr<Inspector::Protocol::Page::AXNode>& out_axNode) {++void InspectorPageAgent::accessibilitySnapshot(ErrorString& errorString, const String* objectId, RefPtr<Inspector::Protocol::Page::AXNode>& out_axNode)++{+ if (!WebCore::AXObjectCache::accessibilityEnabled())+ WebCore::AXObjectCache::enableAccessibility();+ auto document = makeRefPtr(m_inspectedPage.mainFrame().document());@@ -3277,7 +3244,8 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b+ out_axNode = snapshotForAXObject(makeRefPtr(axObject), node);+}+-+void InspectorPageAgent::setInterceptFileChooserDialog(ErrorString&, bool enabled) {++void InspectorPageAgent::setInterceptFileChooserDialog(ErrorString&, bool enabled)++{+ m_interceptFileChooserDialog = enabled;+}+@@ -3295,38 +3263,36 @@ index d4e6b5d1f2151a1f4c16081b2695dd66da416ba2..7ddcea8b824043a6a17cfe2d209d861b+ view->updateBackgroundRecursively(InspectorDOMAgent::parseColor(color));+}+-+void InspectorPageAgent::createIsolatedWorld(ErrorString& errorString, const String& name, const String* optionalSource) {-+ if (m_isolatedWorldScripts.find(name) != m_isolatedWorldScripts.end()) {++void InspectorPageAgent::createUserWorld(ErrorString& errorString, const String& name)++{++ static NeverDestroyed<HashSet<String>> createdUserWorlds;++ if (createdUserWorlds->contains(name)) {+ errorString = "World with the given name already exists"_s;+ return;+ }-+ auto* pageRuntimeAgent = m_instrumentingAgents.pageRuntimeAgent();-+ if (!pageRuntimeAgent) {-+ errorString = "Runtime agent must be enabled"_s;-+ return;-+ }-+-+ String source = optionalSource ? *optionalSource : String();-+ m_isolatedWorldScripts.set(name, source);++ createdUserWorlds->add(name);+++ Ref<DOMWrapperWorld> world = ScriptController::createWorld(name, ScriptController::WorldType::User);+ for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext())-+ pageRuntimeAgent->createIsolatedWorld(*frame, name, source);++ frame->windowProxy().jsWindowProxy(world)->window();+}+-+void InspectorPageAgent::setBypassCSP(ErrorString&, bool enabled) {++void InspectorPageAgent::setBypassCSP(ErrorString&, bool enabled)++{+ m_bypassCSP = enabled;+}+-+void InspectorPageAgent::crash(ErrorString&) {++void InspectorPageAgent::crash(ErrorString&)++{+ CRASH();+}+} // namespace WebCorediff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h-index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db623c854c7 100644+index 110173dbbfe819226b6c4caa0f65a5dee8c39f2b..8cbb35194cfd408e934400ed1e3abd7b1dcd3949 100644--- a/Source/WebCore/inspector/agents/InspectorPageAgent.h+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h-@@ -40,10 +40,15 @@+@@ -40,11 +40,16 @@#include <wtf/Seconds.h>#include <wtf/text/WTFString.h>@@ -3336,13 +3302,14 @@ index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db6+namespace WebCore {+ class DOMWrapperWorld;class DocumentLoader;class Frame;+class HTMLInputElement;class InspectorClient;class InspectorOverlay;class Page;-@@ -96,7 +101,9 @@ public:+@@ -97,7 +102,9 @@ public:void enable(ErrorString&) override;void disable(ErrorString&) override;void reload(ErrorString&, const bool* optionalReloadFromOrigin, const bool* optionalRevalidateAllResources) override;@@ -3353,7 +3320,7 @@ index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db6void overrideUserAgent(ErrorString&, const String* value) override;void overrideSetting(ErrorString&, const String& setting, const bool* value) override;void getCookies(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::Cookie>>& cookies) override;-@@ -110,33 +117,45 @@ public:+@@ -111,20 +118,28 @@ public:void setShowPaintRects(ErrorString&, bool show) override;void setEmulatedMedia(ErrorString&, const String&) override;void setForcedAppearance(ErrorString&, const String&) override;@@ -3366,7 +3333,7 @@ index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db6+ void accessibilitySnapshot(ErrorString&, const String* objectId, RefPtr<Inspector::Protocol::Page::AXNode>& out_axNode) override;+ void setInterceptFileChooserDialog(ErrorString&, bool enabled) override;+ void setDefaultBackgroundColorOverride(ErrorString&, const JSON::Object*) override;-+ void createIsolatedWorld(ErrorString&, const String&, const String*) override;++ void createUserWorld(ErrorString&, const String&) override;+ void setBypassCSP(ErrorString&, bool) override;+ void crash(ErrorString&) override;@@ -3386,8 +3353,7 @@ index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db6void defaultAppearanceDidChange(bool useDarkAppearance);void applyUserAgentOverride(String&);void applyEmulatedMedia(String&);-- void didClearWindowObjectInWorld(Frame&);- void didPaint(RenderObject&, const LayoutRect&);+@@ -133,6 +148,9 @@ public:void didLayout();void didScroll();void didRecalculateStyle();@@ -3397,14 +3363,7 @@ index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db6Frame* frameForId(const String& frameId);WEBCORE_EXPORT String frameId(Frame*);- String loaderId(DocumentLoader*);- Frame* assertFrame(ErrorString&, const String& frameId);-+ HashMap<String, String> isolatedWorldScripts() { return m_isolatedWorldScripts; };-+ String bootstrapScript() { return m_bootstrapScript; }-- private:- double timestamp();-@@ -151,18 +170,20 @@ private:+@@ -152,18 +170,19 @@ private:RefPtr<Inspector::PageBackendDispatcher> m_backendDispatcher;Page& m_inspectedPage;@@ -3419,7 +3378,6 @@ index 3f3bbb8fce82044c1c230b0ae7186612cc5d45cf..a25053411467e0c87eaacd1b57d74db6String m_emulatedMedia;String m_forcedAppearance;String m_bootstrapScript;-+ HashMap<String, String> m_isolatedWorldScripts;bool m_isFirstLayoutAfterOnLoad { false };bool m_showPaintRects { false };+ bool m_interceptFileChooserDialog { false };@@ -3445,11 +3403,11 @@ index 5b7d17a424be41789f73e795736defb8fdf4ed1b..ee571acbf3a4c34cd7039ddd04febe36void InspectorWorkerAgent::disconnectFromWorkerInspectorProxy(WorkerInspectorProxy* proxy)diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp-index 864ce3cfe13994642495f2d7dfbdcc9a4cad9f24..50a4c389709d92a251214b24ba6068d96c2ea17b 100644+index 63336051bb0050d6a55eb5543b0349eb964bbb7a..71abd08516e93b087e506f54b8e093ea300dfe71 100644--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp-@@ -34,12 +34,14 @@-+@@ -35,12 +35,14 @@+ #include "DOMWrapperWorld.h"#include "Document.h"#include "Frame.h"+#include "FrameLoader.h"@@ -3463,24 +3421,10 @@ index 864ce3cfe13994642495f2d7dfbdcc9a4cad9f24..50a4c389709d92a251214b24ba6068d9#include "ScriptState.h"#include "SecurityOrigin.h"#include "UserGestureEmulationScope.h"-@@ -103,9 +105,25 @@ void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame)- if (!pageAgent)- return;+@@ -106,6 +108,15 @@ void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld+ notifyContextCreated(pageAgent->frameId(&frame), frame.script().globalObject(world), world);+ }-- auto frameId = pageAgent->frameId(&frame);-+ // Force main world creation.- auto* scriptState = mainWorldExecState(&frame);-- notifyContextCreated(frameId, scriptState, nullptr, true);-+ Document* document = frame.document();-+ String worldName = document ? document->securityOrigin().toRawString() : String();-+ notifyContextCreated(frame, scriptState, worldName, true);-+ frame.script().evaluateIgnoringException(ScriptSourceCode(pageAgent->bootstrapScript(), URL { URL(), "web-inspector://bootstrap.js"_s }));-+-+ // Create user worlds.-+ for (auto pair : pageAgent->isolatedWorldScripts())-+ createIsolatedWorld(frame, pair.key, pair.value);-+}-++void PageRuntimeAgent::didReceiveMainResourceError(Frame& frame)+{+ if (frame.loader().stateMachine().isDisplayingInitialEmptyDocument()) {@@ -3488,99 +3432,24 @@ index 864ce3cfe13994642495f2d7dfbdcc9a4cad9f24..50a4c389709d92a251214b24ba6068d9+ // it usable in case loading failed.+ mainWorldExecState(&frame);+ }- }-- InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)-@@ -142,38 +160,38 @@ void PageRuntimeAgent::reportExecutionContextCreation()-- Vector<std::pair<JSC::JSGlobalObject*, SecurityOrigin*>> isolatedContexts;- for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {-- if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))-- continue;---- String frameId = pageAgent->frameId(frame);--- JSC::JSGlobalObject* scriptState = mainWorldExecState(frame);-- notifyContextCreated(frameId, scriptState, nullptr, true);-+ Document* document = frame->document();-+ String worldName = document ? document->securityOrigin().toRawString() : String();-+ notifyContextCreated(*frame, scriptState, worldName, true);- frame->script().collectIsolatedContexts(isolatedContexts);- if (isolatedContexts.isEmpty())- continue;- for (auto& [globalObject, securityOrigin] : isolatedContexts) {-- if (globalObject != scriptState)-- notifyContextCreated(frameId, globalObject, securityOrigin, false);-+ if (globalObject == scriptState)-+ continue;-+ String name = securityOrigin ? securityOrigin->toRawString() : String();-+ notifyContextCreated(*frame, globalObject, name, false);- }- isolatedContexts.clear();- }- }---void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobalObject* scriptState, SecurityOrigin* securityOrigin, bool isPageContext)-+void PageRuntimeAgent::notifyContextCreated(Frame& frame, JSC::JSGlobalObject* scriptState, const String& contextName, bool isPageContext)- {-- ASSERT(securityOrigin || isPageContext);---+ auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();-+ if (!pageAgent)-+ return;-+ String frameId = pageAgent->frameId(&frame);- InjectedScript result = injectedScriptManager().injectedScriptFor(scriptState);- if (result.hasNoValue())- return;-- int executionContextId = injectedScriptManager().injectedScriptIdFor(scriptState);-- String name = securityOrigin ? securityOrigin->toRawString() : String();- m_frontendDispatcher->executionContextCreated(ExecutionContextDescription::create()- .setId(executionContextId)- .setIsPageContext(isPageContext)-- .setName(name)-+ .setName(contextName)- .setFrameId(frameId)- .release());- }-@@ -190,4 +208,18 @@ void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& ob- InspectorRuntimeAgent::callFunctionOn(errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);- }--+void PageRuntimeAgent::createIsolatedWorld(Frame& frame, const String& name, const String& source) {-+ auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();-+ if (!pageAgent)-+ return;-+-+ Ref<DOMWrapperWorld> world = ScriptController::createWorld();-+ frame.windowProxy().jsWindowProxy(world)->window();-+ if (!source.isEmpty())-+ frame.script().evaluateInWorldIgnoringException(ScriptSourceCode(source, URL { URL(), "web-inspector://isolate_world.js"_s }), world);-+ auto* scriptState = frame.windowProxy().jsWindowProxy(world)->window();-+ notifyContextCreated(frame, scriptState, name, false);-+ frame.script().evaluateInWorldIgnoringException(ScriptSourceCode(pageAgent->bootstrapScript(), URL { URL(), "web-inspector://bootstrap.js"_s }), world);+}+- } // namespace WebCore+ InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)+ {+ if (!executionContextId) {diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h-index 54a00e05828fbe10d7c69facf69bf0c302687786..df0aa6dbd784813514f59bf8c37d83700876399a 100644+index 2af3739b7fe7c16faa7d8d2797ce6d010215398d..80bfde6120874e16fb173f707fd0bd8a3e5067a0 100644--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h-@@ -62,17 +62,19 @@ public:+@@ -63,6 +63,7 @@ public:// InspectorInstrumentationvoid frameNavigated(Frame&);- void didClearWindowObjectInWorld(Frame&);+ void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);+ void didReceiveMainResourceError(Frame&);-+-+ void createIsolatedWorld(Frame& frame, const String& name, const String& source);private:Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;- void muteConsole() override;- void unmuteConsole() override;- void reportExecutionContextCreation();-- void notifyContextCreated(const String& frameId, JSC::JSGlobalObject*, SecurityOrigin*, bool isPageContext);-+ void notifyContextCreated(Frame&, JSC::JSGlobalObject*, const String&, bool isPageContext);+@@ -73,7 +74,6 @@ private:std::unique_ptr<Inspector::RuntimeFrontendDispatcher> m_frontendDispatcher;RefPtr<Inspector::RuntimeBackendDispatcher> m_backendDispatcher;@@ -3620,7 +3489,7 @@ index 5bc523a07233d6efab4ee18d19a6b8f105274664..d640783477744da05c5baed94dc0c168DocumentWriter& writer() const { return m_writer; }diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp-index a1285851f259d82a63a86de58c53de3e3b02d914..5d3ea7a182db378927e5124660c2e9b03c879228 100644+index a1285851f259d82a63a86de58c53de3e3b02d914..b2493d7629504bd11594fb7107a2b8b8acfe3e1c 100644--- a/Source/WebCore/loader/FrameLoader.cpp+++ b/Source/WebCore/loader/FrameLoader.cpp@@ -1180,6 +1180,7 @@ void FrameLoader::loadInSameDocument(const URL& url, SerializedScriptValue* stat@@ -3658,7 +3527,7 @@ index a1285851f259d82a63a86de58c53de3e3b02d914..5d3ea7a182db378927e5124660c2e9b0}void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)-@@ -3946,9 +3953,6 @@ String FrameLoader::referrer() const+@@ -3946,24 +3953,30 @@ String FrameLoader::referrer() constvoid FrameLoader::dispatchDidClearWindowObjectsInAllWorlds(){@@ -3667,8 +3536,21 @@ index a1285851f259d82a63a86de58c53de3e3b02d914..5d3ea7a182db378927e5124660c2e9b0-Vector<Ref<DOMWrapperWorld>> worlds;ScriptController::getAllWorlds(worlds);- for (auto& world : worlds)-@@ -3957,13 +3961,12 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()+- for (auto& world : worlds)+- dispatchDidClearWindowObjectInWorld(world);++ // It is essential that the normal world is cleared first.++ // Various subsystem (InjectedScriptManager) will reset state upon normal++ // world initialization.++ Vector<DOMWrapperWorld*> nonNormalWorlds;++ for (auto& world : worlds) {++ if (world->type() == DOMWrapperWorld::Type::Normal)++ dispatchDidClearWindowObjectInWorld(world);++ else++ nonNormalWorlds.append(&world.get());++ }++ for (auto* world : nonNormalWorlds)++ dispatchDidClearWindowObjectInWorld(*world);+ }void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world){@@ -3722,10 +3604,10 @@ index e24fded2225f1c1918f454017566717e20484eab..30e4b7a986418c4b4f6c799b858b6082void ProgressTracker::incrementProgress(unsigned long identifier, const ResourceResponse& response)diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp-index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f536cb4ada 100644+index 59be553289e3dff72c9b58a1405703ad391e5ee6..7b52800d5292ed50d0c124e6c108f63099c512b1 100644--- a/Source/WebCore/page/EventHandler.cpp+++ b/Source/WebCore/page/EventHandler.cpp-@@ -801,9 +801,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve+@@ -806,9 +806,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& evem_mousePressNode = event.targetNode();m_frame.document()->setFocusNavigationStartingNode(event.targetNode());@@ -3735,7 +3617,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5m_mousePressed = true;m_selectionInitiationState = HaveNotStartedSelection;-@@ -842,8 +840,6 @@ VisiblePosition EventHandler::selectionExtentRespectingEditingBoundary(const Vis+@@ -847,8 +845,6 @@ VisiblePosition EventHandler::selectionExtentRespectingEditingBoundary(const Visreturn targetNode->renderer()->positionForPoint(LayoutPoint(selectionEndPoint), nullptr);}@@ -3744,7 +3626,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5#if !PLATFORM(IOS_FAMILY)bool EventHandler::supportsSelectionUpdatesOnMouseDrag() const-@@ -865,8 +861,10 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e+@@ -870,8 +866,10 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& eRef<Frame> protectedFrame(m_frame);@@ -3755,7 +3637,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5Node* targetNode = event.targetNode();if (event.event().button() != LeftButton || !targetNode)-@@ -887,7 +885,9 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e+@@ -892,7 +890,9 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& eASSERT(m_mouseDownMayStartSelect || m_mouseDownMayStartAutoscroll);#endif@@ -3765,7 +3647,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) {m_autoscrollController->startAutoscrollForSelection(renderer);-@@ -904,6 +904,8 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e+@@ -909,6 +909,8 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& ereturn true;}@@ -3774,7 +3656,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const{// This is a pre-flight check of whether the event might lead to a drag being started. Be careful-@@ -935,6 +937,8 @@ bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const+@@ -940,6 +942,8 @@ bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) constreturn targetElement && page->dragController().draggableElement(&m_frame, targetElement, result.roundedPointInInnerNodeFrame(), state);}@@ -3783,7 +3665,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5void EventHandler::updateSelectionForMouseDrag(){if (!supportsSelectionUpdatesOnMouseDrag())-@@ -1026,7 +1030,6 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul+@@ -1031,7 +1035,6 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResulm_frame.selection().setSelectionByMouseIfDifferent(newSelection, m_frame.selection().granularity(),FrameSelection::AdjustEndpointsAtBidiBoundary);}@@ -3791,7 +3673,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5void EventHandler::lostMouseCapture(){-@@ -1074,9 +1077,7 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e+@@ -1079,9 +1082,7 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e// on the selection, the selection goes away. However, if we are// editing, place the caret.if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != ExtendedSelection@@ -3801,7 +3683,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5&& m_frame.selection().isRange()&& event.event().button() != RightButton) {VisibleSelection newSelection;-@@ -2029,10 +2030,8 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& platformMouseE+@@ -2034,10 +2035,8 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& platformMouseEreturn true;swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mouseEvent.targetNode(), false, 0, platformMouseEvent, true);@@ -3813,7 +3695,7 @@ index 529ecb07cdc880d37b966ea5cfa7c6b2b8dd4ef0..b1d373d90b7a3c3c5b421d025ac5e6f5return swallowEvent;}diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h-index d33ad47d4aa0a776b0b27ab682d577fd4717556d..491159be12564fd98259c4dd52a99c5ac686c16f 100644+index 14e95eed55844fd07fe0a3f407748cfb3700220b..14cb2d79c010dab366d3ed62cbf44308b5b44e25 100644--- a/Source/WebCore/page/EventHandler.h+++ b/Source/WebCore/page/EventHandler.h@@ -132,9 +132,7 @@ public:@@ -3837,7 +3719,7 @@ index d33ad47d4aa0a776b0b27ab682d577fd4717556d..491159be12564fd98259c4dd52a99c5aWEBCORE_EXPORT bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);-@@ -455,10 +451,8 @@ private:+@@ -456,10 +452,8 @@ private:void defaultTabEventHandler(KeyboardEvent&);void defaultArrowEventHandler(FocusDirection, KeyboardEvent&);@@ -3848,7 +3730,7 @@ index d33ad47d4aa0a776b0b27ab682d577fd4717556d..491159be12564fd98259c4dd52a99c5a// The following are called at the beginning of handleMouseUp and handleDrag.// If they return true it indicates that they have consumed the event.-@@ -466,9 +460,10 @@ private:+@@ -467,9 +461,10 @@ private:#if ENABLE(DRAG_SUPPORT)bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&);@@ -3860,7 +3742,7 @@ index d33ad47d4aa0a776b0b27ab682d577fd4717556d..491159be12564fd98259c4dd52a99c5aenum class SetOrClearLastScrollbar { Clear, Set };void updateLastScrollbarUnderMouse(Scrollbar*, SetOrClearLastScrollbar);-@@ -516,10 +511,7 @@ private:+@@ -519,10 +514,7 @@ private:enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };@@ -3872,7 +3754,7 @@ index d33ad47d4aa0a776b0b27ab682d577fd4717556d..491159be12564fd98259c4dd52a99c5aTimer m_cursorUpdateTimer;diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp-index 6f434d95832e2527aa2059e5907154bdf64bef63..563d961443ad3f28e32766302eeee144635154d0 100644+index 9e6b7fe76ee6d1a92c0f37c1a80daf9e651a6b3d..23571ae7294cb335065ad94818622aa1e8b3880c 100644--- a/Source/WebCore/page/Frame.cpp+++ b/Source/WebCore/page/Frame.cpp@@ -180,6 +180,7 @@ Frame::Frame(Page& page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient&@@ -4692,7 +4574,7 @@ index 44737686187a06a92c408ea60b63a48ac8481334..c754a763688b52e7ddd47493296ef9b0bool PlatformKeyboardEvent::currentCapsLockState()diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp-index c4ef81788ade1b28df808564ca694ef15d1dc05d..4550b3fb21cf6c71b237cfd73b319459bd3896f2 100644+index 56784ed6ccb93d6313df6819c0a50413fade46da..405cee0e59ecc66e736dc5f38c06f5a08fa0a10f 100644--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp@@ -26,7 +26,6 @@@@ -4928,10 +4810,10 @@ index 50e399a49549fdc951717059607d720177540c96..a42ead187b7e1c8b2f5030576e741c5a"${WEBKIT_DIR}/UIProcess/linux""${WEBKIT_DIR}/UIProcess/soup"diff --git a/Source/WebKit/PlatformWin.cmake b/Source/WebKit/PlatformWin.cmake-index 2713713d9b0bc91c6312dbe319e1e33a480e58d5..299dde6b6e18b5e2023c14c13940e536a5e8dfd5 100644+index 600db1897c6bbda2a8b3e3793b6117abf0201528..da2d19698c74e70af0eb5e23837e44a077219b99 100644--- a/Source/WebKit/PlatformWin.cmake+++ b/Source/WebKit/PlatformWin.cmake-@@ -54,9 +54,13 @@ list(APPEND WebKit_SOURCES+@@ -56,8 +56,12 @@ list(APPEND WebKit_SOURCESUIProcess/WebsiteData/win/WebsiteDataStoreWin.cpp@@ -4939,7 +4821,6 @@ index 2713713d9b0bc91c6312dbe319e1e33a480e58d5..299dde6b6e18b5e2023c14c13940e536+ UIProcess/win/InspectorBrowserAgentClientWin.cppUIProcess/win/PageClientImpl.cppUIProcess/win/WebContextMenuProxyWin.cpp- UIProcess/win/WebInspectorProxyWin.cpp+ UIProcess/win/WebPageInspectorEmulationAgentWin.cpp+ UIProcess/win/WebPageInspectorInputAgentWin.cppUIProcess/win/WebPageProxyWin.cpp@@ -5230,10 +5111,10 @@ index 88d53d236cd6d62735f03678a04ca9c198dddacb..b8f8efc57ab00dc5725660c5a8ad56a3return WebTouchEvent();}diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt-index 3da2800c9c5f7eae9fae2f36dad0131237f89e29..0e57deddddd3c852da536a4f44943a8346ff8f3d 100644+index 53109203ca22cb5f5db9351f9c236e053ab1e009..6e575ab04ab8ee65cc38a59e3be0b05809b987d0 100644--- a/Source/WebKit/Sources.txt+++ b/Source/WebKit/Sources.txt-@@ -262,17 +262,22 @@ Shared/WebsiteData/WebsiteData.cpp+@@ -261,16 +261,21 @@ Shared/WebsiteData/WebsiteData.cppUIProcess/AuxiliaryProcessProxy.cppUIProcess/BackgroundProcessResponsivenessTimer.cpp@@ -5246,30 +5127,29 @@ index 3da2800c9c5f7eae9fae2f36dad0131237f89e29..0e57deddddd3c852da536a4f44943a83UIProcess/GeolocationPermissionRequestProxy.cpp+UIProcess/InspectorBrowserAgent.cpp+UIProcess/InspectorDialogAgent.cpp- UIProcess/InspectorTargetProxy.cppUIProcess/LegacyGlobalSettings.cppUIProcess/PageLoadState.cppUIProcess/ProcessAssertion.cppUIProcess/ProcessThrottler.cppUIProcess/ProvisionalPageProxy.cpp+UIProcess/RemoteInspectorPipe.cpp- UIProcess/RemoteWebInspectorProxy.cppUIProcess/ResponsivenessTimer.cppUIProcess/StatisticsRequest.cpp-@@ -315,6 +320,8 @@ UIProcess/WebPageDiagnosticLoggingClient.cpp+ UIProcess/SuspendedPageProxy.cpp+@@ -308,6 +313,8 @@ UIProcess/WebOpenPanelResultListenerProxy.cpp+ UIProcess/WebPageDiagnosticLoggingClient.cppUIProcess/WebPageGroup.cppUIProcess/WebPageInjectedBundleClient.cpp- UIProcess/WebPageInspectorController.cpp+UIProcess/WebPageInspectorEmulationAgent.cpp+UIProcess/WebPageInspectorInputAgent.cppUIProcess/WebPageProxy.cppUIProcess/WebPasteboardProxy.cppUIProcess/WebPreferences.cppdiff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt-index 6a8e2e6905c35bc1bc48c469a6ec6c85d5f824b8..846de5fa1e5a3d664f3835d56e44565266758f8c 100644+index eaa0d84fa5cfa740d27b78b907ec9569931cb0dc..b26a0c9ed6eea66c741bb17c599cd7940b82241d 100644--- a/Source/WebKit/SourcesCocoa.txt+++ b/Source/WebKit/SourcesCocoa.txt-@@ -249,6 +249,7 @@ UIProcess/API/Cocoa/_WKApplicationManifest.mm+@@ -247,6 +247,7 @@ UIProcess/API/Cocoa/_WKApplicationManifest.mmUIProcess/API/Cocoa/_WKAttachment.mmUIProcess/API/Cocoa/_WKAutomationSession.mmUIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm@@ -5278,7 +5158,7 @@ index 6a8e2e6905c35bc1bc48c469a6ec6c85d5f824b8..846de5fa1e5a3d664f3835d56e445652UIProcess/API/Cocoa/_WKContextMenuElementInfo.mmUIProcess/API/Cocoa/_WKCustomHeaderFields.mm @no-unifydiff --git a/Source/WebKit/SourcesGTK.txt b/Source/WebKit/SourcesGTK.txt-index 1ef73bc214c6e095fe836f018fa81b63e56cfdb8..0cfeb639e2cb28deecbee22a5d6a8f1cbdf5ae4f 100644+index 85ab0a3e2c9d614d7f3a95b46fb2f3ae2a18a41c..ade26796a4f3499ebfa75db3bd2157b2a2d571e1 100644--- a/Source/WebKit/SourcesGTK.txt+++ b/Source/WebKit/SourcesGTK.txt@@ -130,6 +130,7 @@ UIProcess/API/glib/WebKitAuthenticationRequest.cpp @no-unify@@ -5289,15 +5169,16 @@ index 1ef73bc214c6e095fe836f018fa81b63e56cfdb8..0cfeb639e2cb28deecbee22a5d6a8f1cUIProcess/API/glib/WebKitContextMenuClient.cpp @no-unifyUIProcess/API/glib/WebKitCookieManager.cpp @no-unifyUIProcess/API/glib/WebKitCredential.cpp @no-unify-@@ -230,6 +231,7 @@ UIProcess/WebsiteData/unix/WebsiteDataStoreUnix.cpp+@@ -236,6 +237,8 @@ UIProcess/WebsiteData/unix/WebsiteDataStoreUnix.cppUIProcess/cairo/BackingStoreCairo.cpp @no-unify+UIProcess/glib/InspectorBrowserAgentClientGLib.cpp- UIProcess/glib/RemoteInspectorClient.cpp++UIProcess/glib/RemoteInspectorClient.cppUIProcess/glib/WebProcessPoolGLib.cppUIProcess/glib/WebProcessProxyGLib.cpp-@@ -244,6 +246,7 @@ UIProcess/gtk/AcceleratedBackingStoreX11.cpp @no-unify+ UIProcess/glib/WebsiteDataStoreGLib.cpp @no-unify+@@ -249,6 +252,7 @@ UIProcess/gtk/AcceleratedBackingStoreX11.cpp @no-unifyUIProcess/gtk/DragAndDropHandler.cppUIProcess/gtk/GestureController.cppUIProcess/gtk/HardwareAccelerationManager.cpp@@ -5305,15 +5186,17 @@ index 1ef73bc214c6e095fe836f018fa81b63e56cfdb8..0cfeb639e2cb28deecbee22a5d6a8f1cUIProcess/gtk/KeyBindingTranslator.cppUIProcess/gtk/PointerLockManager.cpp @no-unifyUIProcess/gtk/PointerLockManagerWayland.cpp @no-unify-@@ -257,6 +260,8 @@ UIProcess/gtk/WebColorPickerGtk.cpp+@@ -260,6 +264,10 @@ UIProcess/gtk/WaylandCompositor.cpp @no-unify+ UIProcess/gtk/WebColorPickerGtk.cppUIProcess/gtk/WebContextMenuProxyGtk.cppUIProcess/gtk/WebDataListSuggestionsDropdownGtk.cpp- UIProcess/gtk/WebInspectorProxyGtk.cpp++UIProcess/gtk/WebInspectorProxyGtk.cpp+UIProcess/gtk/WebPageInspectorEmulationAgentGtk.cpp+UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp- UIProcess/gtk/WebKitInspectorWindow.cpp++UIProcess/gtk/WebKitInspectorWindow.cppUIProcess/gtk/WebPageProxyGtk.cpp @no-unifyUIProcess/gtk/WebPasteboardProxyGtk.cpp+ UIProcess/gtk/WebPopupMenuProxyGtk.cppdiff --git a/Source/WebKit/SourcesWPE.txt b/Source/WebKit/SourcesWPE.txtindex 1b98c8c09e287de2bc75174a03177d26042e3ad5..c3658c9debe9733898eb57567b3c708da0a1032b 100644--- a/Source/WebKit/SourcesWPE.txt@@ -6920,515 +6803,533 @@ index 4896c404bc8b25d69360de7d1c509383282b2317..14bdebf732e929ea367c961f9d0bec85// The timeout we use when waiting for a DidUpdateGeometry message.static constexpr Seconds didUpdateBackingStoreStateTimeout() { return Seconds::fromMilliseconds(500); }-diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp b/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp-new file mode 100644-index 0000000000000000000000000000000000000000..d8dbb6391594955a23a5ed3cb34b05ca0b47acc1---- /dev/null-+++ b/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp-@@ -0,0 +1,497 @@-+/*-+ * Copyright (C) 2019 Microsoft Corporation.-+ *-+ * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT-+ * OWNER OR 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 "InspectorBrowserAgent.h"-+-+#if ENABLE(REMOTE_INSPECTOR)-+-+#include "APIPageConfiguration.h"-+#include "InspectorBrowserAgentClient.h"-+#include "InspectorTargetProxy.h"-+#include "NetworkProcessMessages.h"-+#include "NetworkProcessProxy.h"-+#include "WebGeolocationManagerProxy.h"-+#include "WebGeolocationPosition.h"+diff --git a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp+index 6928ca2fbfb6939062e3cd14bb7ba6f2fdc87f5f..8259a01bb98789c07f88cafd4f3af553e65d0cf9 100644+--- a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp++++ b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp+@@ -27,11 +27,10 @@+ #include "InspectorTargetProxy.h"++ #include "ProvisionalPageProxy.h"+-#include "WebFrameProxy.h"+#include "WebPageInspectorController.h"-+#include "WebPageInspectorTarget.h"-+#include "WebPageProxy.h"-+#include "WebProcessPool.h"-+#include "WebProcessProxy.h"-+#include <WebCore/FrameIdentifier.h>-+#include <WebCore/GeolocationPositionData.h>-+#include <WebCore/ProcessIdentifier.h>-+#include <WebCore/ResourceRequest.h>-+#include <JavaScriptCore/InspectorFrontendRouter.h>-+#include <pal/SessionID.h>-+#include <stdlib.h>-+#include <wtf/HashMap.h>-+#include <wtf/HexNumber.h>-+-+-+using namespace Inspector;-+-+namespace WebKit {-+-+namespace {-+-+Inspector::Protocol::Browser::CookieSameSitePolicy cookieSameSitePolicy(WebCore::Cookie::SameSitePolicy policy)-+{-+ switch (policy) {-+ case WebCore::Cookie::SameSitePolicy::None:-+ return Inspector::Protocol::Browser::CookieSameSitePolicy::None;-+ case WebCore::Cookie::SameSitePolicy::Lax:-+ return Inspector::Protocol::Browser::CookieSameSitePolicy::Lax;-+ case WebCore::Cookie::SameSitePolicy::Strict:-+ return Inspector::Protocol::Browser::CookieSameSitePolicy::Strict;-+ }-+ ASSERT_NOT_REACHED();-+ return Inspector::Protocol::Browser::CookieSameSitePolicy::None;-+}+ #include "WebPageInspectorTarget.h"+ #include "WebPageMessages.h"+ #include "WebPageProxy.h"+-#include "WebProcessProxy.h"++ namespace WebKit {++@@ -39,18 +38,17 @@ using namespace Inspector;++ std::unique_ptr<InspectorTargetProxy> InspectorTargetProxy::create(WebPageProxy& page, const String& targetId, Inspector::InspectorTargetType type)+ {+- return makeUnique<InspectorTargetProxy>(page, targetId, type);++ return makeUnique<InspectorTargetProxy>(page, nullptr, targetId, type);+ }++-std::unique_ptr<InspectorTargetProxy> InspectorTargetProxy::create(ProvisionalPageProxy& provisionalPage, const String& targetId, Inspector::InspectorTargetType type)++std::unique_ptr<InspectorTargetProxy> InspectorTargetProxy::create(ProvisionalPageProxy& provisionalPage, const String& targetId)+ {+- auto target = InspectorTargetProxy::create(provisionalPage.page(), targetId, type);+- target->m_provisionalPage = makeWeakPtr(provisionalPage);+- return target;++ return makeUnique<InspectorTargetProxy>(provisionalPage.page(), &provisionalPage, targetId, Inspector::InspectorTargetType::Page);+ }++-InspectorTargetProxy::InspectorTargetProxy(WebPageProxy& page, const String& targetId, Inspector::InspectorTargetType type)++InspectorTargetProxy::InspectorTargetProxy(WebPageProxy& page, ProvisionalPageProxy* provisionalPage, const String& targetId, Inspector::InspectorTargetType type)+ : m_page(page)++ , m_provisionalPage(makeWeakPtr(provisionalPage))+ , m_identifier(targetId)+ , m_type(type)+ {+@@ -83,6 +81,9 @@ void InspectorTargetProxy::disconnect()++ void InspectorTargetProxy::sendMessageToTargetBackend(const String& message)+ {++ if (m_page.inspectorController().dispatchMessageToTargetBackend(message))++ return;+-+Ref<Inspector::Protocol::Browser::Cookie> buildObjectForCookie(const WebCore::Cookie& cookie)+ if (m_provisionalPage) {+ m_provisionalPage->send(Messages::WebPage::SendMessageToTargetBackend(identifier(), message));+ return;+@@ -97,9 +98,35 @@ void InspectorTargetProxy::didCommitProvisionalTarget()+ m_provisionalPage = nullptr;+ }+++void InspectorTargetProxy::activate(String& error)+{-+ return Inspector::Protocol::Browser::Cookie::create()-+ .setName(cookie.name)-+ .setValue(cookie.value)-+ .setDomain(cookie.domain)-+ .setPath(cookie.path)-+ .setExpires(cookie.expires)-+ .setHttpOnly(cookie.httpOnly)-+ .setSecure(cookie.secure)-+ .setSession(cookie.session)-+ .setSameSite(cookieSameSitePolicy(cookie.sameSite))-+ .release();-+}++ if (m_type != Inspector::InspectorTargetType::Page)++ return InspectorTarget::activate(error);+-+Ref<Inspector::Protocol::Browser::PageProxyInfo> buildPageProxyInfo(const WebPageProxy& page) {-+ auto result = Inspector::Protocol::Browser::PageProxyInfo::create()-+ .setPageProxyId(InspectorBrowserAgent::toPageProxyIDProtocolString(page))-+ .setBrowserContextId(InspectorBrowserAgent::toBrowserContextIDProtocolString(page.sessionID()))-+ .release();-+ auto* opener = page.configuration().relatedPage();-+ if (opener)-+ result->setOpenerId(InspectorBrowserAgent::toPageProxyIDProtocolString(*opener));-+ return result;++ platformActivate(error);+}+-+} // namespace-+-+InspectorBrowserAgent::InspectorBrowserAgent(Inspector::FrontendRouter& frontendRouter, Inspector::BackendDispatcher& backendDispatcher, InspectorBrowserAgentClient* client, PageProxyIDMap& pageProxyIDMap)-+ : InspectorAgentBase("Browser"_s)-+ , m_frontendDispatcher(makeUnique<BrowserFrontendDispatcher>(frontendRouter))-+ , m_backendDispatcher(BrowserBackendDispatcher::create(backendDispatcher, this))-+ , m_client(client)-+ , m_pageProxyIDMap(pageProxyIDMap)++void InspectorTargetProxy::close(String& error, bool runBeforeUnload)+{-+}-+-+InspectorBrowserAgent::~InspectorBrowserAgent() = default;++ if (m_type != Inspector::InspectorTargetType::Page)++ return InspectorTarget::close(error, runBeforeUnload);+-+void InspectorBrowserAgent::didCreateWebPageProxy(const WebPageProxy& page)-+{-+ if (m_isConnected)-+ m_frontendDispatcher->pageProxyCreated(buildPageProxyInfo(page));++ if (runBeforeUnload)++ m_page.tryClose();++ else++ m_page.closePage();+}+-+void InspectorBrowserAgent::willDestroyWebPageProxy(const WebPageProxy& page)+ bool InspectorTargetProxy::isProvisional() const+ {+ return !!m_provisionalPage;+ }+++String InspectorTargetProxy::oldTargetID() const+{-+ if (m_isConnected)-+ m_frontendDispatcher->pageProxyDestroyed(toPageProxyIDProtocolString(page));++ if (!m_provisionalPage)++ return String();++ return WebPageInspectorTarget::toTargetID(m_page.webPageID());+}+-+void InspectorBrowserAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)+ } // namespace WebKit+diff --git a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.h b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.h+index a2239cec8e18850f35f7f88a9c4ebadc62bf4023..f53bd7717be546157dfeb92b835a1df5513a716a 100644+--- a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.h++++ b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.h+@@ -37,13 +37,13 @@ class WebPageProxy;+ // NOTE: This UIProcess side InspectorTarget doesn't care about the frontend channel, since+ // any target -> frontend messages will be routed to the WebPageProxy with a targetId.++-class InspectorTargetProxy final : public Inspector::InspectorTarget {++class InspectorTargetProxy : public Inspector::InspectorTarget {+ WTF_MAKE_FAST_ALLOCATED;+ WTF_MAKE_NONCOPYABLE(InspectorTargetProxy);+ public:+ static std::unique_ptr<InspectorTargetProxy> create(WebPageProxy&, const String& targetId, Inspector::InspectorTargetType);+- static std::unique_ptr<InspectorTargetProxy> create(ProvisionalPageProxy&, const String& targetId, Inspector::InspectorTargetType);+- InspectorTargetProxy(WebPageProxy&, const String& targetId, Inspector::InspectorTargetType);++ static std::unique_ptr<InspectorTargetProxy> create(ProvisionalPageProxy&, const String& targetId);++ InspectorTargetProxy(WebPageProxy&, ProvisionalPageProxy*, const String& targetId, Inspector::InspectorTargetType);+ ~InspectorTargetProxy() = default;++ Inspector::InspectorTargetType type() const final { return m_type; }+@@ -51,16 +51,21 @@ public:++ void didCommitProvisionalTarget();+ bool isProvisional() const override;++ String oldTargetID() const override;++ void connect(Inspector::FrontendChannel::ConnectionType) override;+ void disconnect() override;+ void sendMessageToTargetBackend(const String&) override;++ void activate(String& error) override;++ void close(String& error, bool runBeforeUnload) override;++ private:++ void platformActivate(String& error) const;+++ WebPageProxy& m_page;++ WeakPtr<ProvisionalPageProxy> m_provisionalPage;+ String m_identifier;+ Inspector::InspectorTargetType m_type;+- WeakPtr<ProvisionalPageProxy> m_provisionalPage;+ };++ } // namespace WebKit+diff --git a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp+index 1ee28bf716374371433215148aa20a51927a8a33..444894102b535a957cadb41fab23f37c217f5b1c 100644+--- a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp++++ b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp+@@ -26,10 +26,16 @@+ #include "config.h"+ #include "WebPageInspectorController.h"+++#include "APINavigation.h"++#include "InspectorDialogAgent.h"+ #include "ProvisionalPageProxy.h"+ #include "WebFrameProxy.h"++#include "WebPageInspectorEmulationAgent.h"++#include "WebPageInspectorInputAgent.h"+ #include "WebPageInspectorTarget.h"+ #include "WebPageProxy.h"++#include "WebPreferences.h"++#include <WebCore/ResourceError.h>+ #include <JavaScriptCore/InspectorAgentBase.h>+ #include <JavaScriptCore/InspectorBackendDispatcher.h>+ #include <JavaScriptCore/InspectorBackendDispatchers.h>+@@ -46,29 +52,90 @@ static String getTargetID(const ProvisionalPageProxy& provisionalPage)+ return WebPageInspectorTarget::toTargetID(provisionalPage.webPageID());+ }+++WebPageInspectorControllerObserver* WebPageInspectorController::s_observer = nullptr;++++void WebPageInspectorController::setObserver(WebPageInspectorControllerObserver* observer)+{-+ m_isConnected = true;++ s_observer = observer;+}+-+void InspectorBrowserAgent::didFailProvisionalLoad(WebPageProxy& page, uint64_t navigationID, const String& error)+ WebPageInspectorController::WebPageInspectorController(WebPageProxy& page)+ : m_page(page)+ , m_frontendRouter(FrontendRouter::create())+ , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))+{-+ if (!m_isConnected)++}++++void WebPageInspectorController::init()+ {+ auto targetAgent = makeUnique<InspectorTargetAgent>(m_frontendRouter.get(), m_backendDispatcher.get());++ m_targetAgent = targetAgent.get();++ m_agents.append(WTFMove(targetAgent));+-}++ m_agents.append(makeUnique<WebPageInspectorEmulationAgent>(m_backendDispatcher.get(), m_page));++ auto inputAgent = makeUnique<WebPageInspectorInputAgent>(m_backendDispatcher.get(), m_page);++ m_inputAgent = inputAgent.get();++ m_agents.append(WTFMove(inputAgent));++ m_agents.append(makeUnique<InspectorDialogAgent>(m_backendDispatcher.get(), m_frontendRouter.get(), m_page));++-void WebPageInspectorController::init()+-{++ if (s_observer)++ s_observer->didCreateInspectorController(m_page);++++ // window.open will create page with already running process.++ if (!m_page.hasRunningProcess())++ return;+ String pageTargetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());+ createInspectorTarget(pageTargetId, Inspector::InspectorTargetType::Page);+ }+++void WebPageInspectorController::didFinishAttachingToWebProcess()++{++ String pageTargetID = WebPageInspectorTarget::toTargetID(m_page.webPageID());++ // Create target only after attaching to a Web Process first time. Before that++ // we cannot event establish frontend connection.++ if (m_targets.contains(pageTargetID))+ return;++ createInspectorTarget(pageTargetID, Inspector::InspectorTargetType::Page);++}+-+ m_frontendDispatcher->provisionalLoadFailed(toPageProxyIDProtocolString(page), String::number(navigationID), error);+ void WebPageInspectorController::pageClosed()+ {++ String pageTargetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());++ destroyInspectorTarget(pageTargetId);+++ disconnectAllFrontends();++ m_agents.discardValues();++++ if (s_observer)++ s_observer->willDestroyInspectorController(m_page);+}+-+void InspectorBrowserAgent::willDestroyFrontendAndBackend(DisconnectReason)++bool WebPageInspectorController::pageCrashed(ProcessTerminationReason reason)+{-+ m_isConnected = false;++ if (reason != ProcessTerminationReason::Crash)++ return false;++ String targetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());++ auto it = m_targets.find(targetId);++ if (it == m_targets.end())++ return false;++ m_targetAgent->targetCrashed(*it->value);++ m_targets.remove(it);++++ return m_targetAgent->isConnected();+}+-+void InspectorBrowserAgent::close(Ref<CloseCallback>&& callback)++void WebPageInspectorController::didProcessAllPendingKeyboardEvents()+{-+ Vector<WebPageProxy*> pages;-+ for (auto& pool : WebProcessPool::allProcessPools()) {-+ for (auto& process : pool->processes()) {-+ for (auto* page : process->pages())-+ pages.append(page);-+ }-+ }-+ for (auto* page : pages)-+ page->closePage();++ if (m_frontendRouter->hasFrontends())++ m_inputAgent->didProcessAllPendingKeyboardEvents();++}+-+ WebProcessPool::allProcessPools().first()->syncLocalStorage([this, callback = WTFMove(callback)] () {-+ if (!callback->isActive())-+ return;++void WebPageInspectorController::didProcessAllPendingMouseEvents()++{++ if (m_frontendRouter->hasFrontends())++ m_inputAgent->didProcessAllPendingMouseEvents();+ }++ bool WebPageInspectorController::hasLocalFrontend() const+@@ -80,6 +147,17 @@ void WebPageInspectorController::connectFrontend(Inspector::FrontendChannel& fro+ {+ bool connectingFirstFrontend = !m_frontendRouter->hasFrontends();+++ // HACK: forcefully disconnect remote connections to show local inspector starting with initial++ // agents' state.++ if (frontendChannel.connectionType() == Inspector::FrontendChannel::ConnectionType::Local &&++ !connectingFirstFrontend && !m_frontendRouter->hasLocalFrontend()) {++ disconnectAllFrontends();++ connectingFirstFrontend = true;++ }+-+ m_browserContexts.clear();-+ if (m_client == nullptr) {-+ callback->sendFailure("no platform delegate to close browser");-+ } else {-+ m_client->closeBrowser();-+ callback->sendSuccess();-+ }-+ });++ if (connectingFirstFrontend)++ adjustPageSettings();+-+}+ m_frontendRouter->connectFrontend(frontendChannel);++ if (connectingFirstFrontend)+@@ -98,8 +176,10 @@ void WebPageInspectorController::disconnectFrontend(FrontendChannel& frontendCha+ m_frontendRouter->disconnectFrontend(frontendChannel);++ bool disconnectingLastFrontend = !m_frontendRouter->hasFrontends();+- if (disconnectingLastFrontend)++ if (disconnectingLastFrontend) {+ m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectorDestroyed);++ m_pendingNavigations.clear();++ }++ m_page.didChangeInspectorFrontendCount(m_frontendRouter->frontendCount());++@@ -122,6 +202,8 @@ void WebPageInspectorController::disconnectAllFrontends()+ // Disconnect any remaining remote frontends.+ m_frontendRouter->disconnectAllFrontends();+++ m_pendingNavigations.clear();+-+void InspectorBrowserAgent::createContext(ErrorString& errorString, String* browserContextID)+ m_page.didChangeInspectorFrontendCount(m_frontendRouter->frontendCount());++ #if ENABLE(REMOTE_INSPECTOR)+@@ -134,6 +216,11 @@ void WebPageInspectorController::dispatchMessageFromFrontend(const String& messa+ m_backendDispatcher->dispatch(message);+ }+++bool WebPageInspectorController::dispatchMessageToTargetBackend(const String& message)+{-+ BrowserContext browserContext = m_client->createBrowserContext(errorString);-+ if (!errorString.isEmpty())-+ return;-+ browserContext.processPool->setPrimaryDataStore(*browserContext.dataStore);-+ browserContext.processPool->ensureNetworkProcess(browserContext.dataStore.get());-+ PAL::SessionID sessionID = browserContext.dataStore->sessionID();-+ *browserContextID = toBrowserContextIDProtocolString(sessionID);-+ m_browserContexts.set(*browserContextID, browserContext);++ return m_backendDispatcher->dispatch(message, BackendDispatcher::Mode::ContinueIfDomainIsMissing) == BackendDispatcher::DispatchResult::Finished;+}+-+void InspectorBrowserAgent::deleteContext(ErrorString& errorString, const String& browserContextID)+ #if ENABLE(REMOTE_INSPECTOR)+ void WebPageInspectorController::setIndicating(bool indicating)+ {+@@ -148,6 +235,55 @@ void WebPageInspectorController::setIndicating(bool indicating)+ }+ #endif+++void WebPageInspectorController::navigate(WebCore::ResourceRequest&& request, WebFrameProxy* frame, NavigationHandler&& completionHandler)+{-+ BrowserContext browserContext = lookupBrowserContext(errorString, &browserContextID);-+ if (!errorString.isEmpty())++ auto navigation = m_page.loadRequestForInspector(WTFMove(request), frame);++ if (!navigation) {++ completionHandler("Failed to navigate"_s, 0);+ return;-+-+ Vector<WebPageProxy*> pages;-+ for (auto& process : browserContext.processPool->processes()) {-+ for (auto* page : process->pages())-+ pages.append(page);+ }+-+ for (auto* page : pages)-+ page->closePage();-+-+ PAL::SessionID sessionID = browserContext.dataStore->sessionID();-+ m_client->deleteBrowserContext(errorString, sessionID);-+ m_browserContexts.remove(browserContextID);++ m_pendingNavigations.set(navigation->navigationID(), WTFMove(completionHandler));+}+-+void InspectorBrowserAgent::createPage(ErrorString& errorString, const String* browserContextID, String* pageProxyID)++void WebPageInspectorController::didReceivePolicyDecision(WebCore::PolicyAction action, uint64_t navigationID)+{-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty())++ if (!m_frontendRouter->hasFrontends())+ return;-+ RefPtr<WebPageProxy> page = m_client->createPage(errorString, browserContext);-+ if (!page)++++ if (!navigationID)+ return;-+ page->setPermissionsForAutomation(m_permissions.get(browserContextID ? *browserContextID : ""));-+ *pageProxyID = toPageProxyIDProtocolString(*page);-+}-+-+WebFrameProxy* InspectorBrowserAgent::frameForID(const String& frameID, String& error)-+{-+ size_t dotPos = frameID.find(".");-+ if (dotPos == notFound) {-+ error = "Invalid frame id"_s;-+ return nullptr;-+ }-+-+ if (!frameID.isAllASCII()) {-+ error = "Invalid frame id"_s;-+ return nullptr;-+ }+-+ String processIDString = frameID.left(dotPos);-+ uint64_t pid = strtoull(processIDString.ascii().data(), 0, 10);-+ auto processID = makeObjectIdentifier<WebCore::ProcessIdentifierType>(pid);-+ WebProcessProxy* process = WebProcessProxy::processForIdentifier(processID);-+ if (!process) {-+ error = "Cannot find web process for the frame id"_s;-+ return nullptr;-+ }-+-+ String frameIDString = frameID.substring(dotPos + 1);-+ uint64_t frameIDNumber = strtoull(frameIDString.ascii().data(), 0, 10);-+ auto frameIdentifier = makeObjectIdentifier<WebCore::FrameIdentifierType>(frameIDNumber);-+ WebFrameProxy* frame = process->webFrame(frameIdentifier);-+ if (!frame) {-+ error = "Cannot find web frame for the frame id"_s;-+ return nullptr;-+ }++ auto completionHandler = m_pendingNavigations.take(navigationID);++ if (!completionHandler)++ return;+-+ return frame;++ if (action == WebCore::PolicyAction::Ignore)++ completionHandler("Navigation cancelled"_s, 0);++ else++ completionHandler(String(), navigationID);+}+-+void InspectorBrowserAgent::navigate(const String& url, const String& pageProxyID, const String* frameID, const String* referrer, Ref<NavigateCallback>&& callback)++void WebPageInspectorController::didDestroyNavigation(uint64_t navigationID)+{-+ WebPageProxy* page = m_pageProxyIDMap.findPageProxy(pageProxyID);-+ if (!page) {-+ callback->sendFailure("Cannot find page proxy with provided 'pageProxyId'"_s);++ if (!m_frontendRouter->hasFrontends())+ return;-+ }+-+ WebCore::ResourceRequest resourceRequest { url };++ auto completionHandler = m_pendingNavigations.take(navigationID);++ if (!completionHandler)++ return;+-+ if (referrer)-+ resourceRequest.setHTTPReferrer(*referrer);++ // Inspector initiated navigation is destroyed before policy check only when it++ // becomes a fragment navigation (which always reuses current navigation).++ completionHandler(String(), 0);++}+-+ if (!resourceRequest.url().isValid()) {-+ callback->sendFailure("Cannot navigate to invalid URL"_s);-+ return;-+ }++void WebPageInspectorController::didFailProvisionalLoadForFrame(uint64_t navigationID, const WebCore::ResourceError& error)++{++ if (s_observer)++ s_observer->didFailProvisionalLoad(m_page, navigationID, error.localizedDescription());++}+-+ WebFrameProxy* frame = nullptr;-+ if (frameID) {-+ String error;-+ frame = frameForID(*frameID, error);-+ if (!frame) {-+ callback->sendFailure(error);-+ return;-+ }+ void WebPageInspectorController::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type)+ {+ addTarget(InspectorTargetProxy::create(m_page, targetId, type));+@@ -167,6 +303,33 @@ void WebPageInspectorController::sendMessageToInspectorFrontend(const String& ta+ m_targetAgent->sendMessageFromTargetToFrontend(targetId, message);+ }+++void WebPageInspectorController::setPauseOnStart(bool shouldPause)++{++ ASSERT(m_frontendRouter->hasFrontends());++ String errorString;++ m_targetAgent->setPauseOnStart(errorString, shouldPause);++}+-+ if (frame->page() != page) {-+ callback->sendFailure("Frame with specified is not from the specified page"_s);-+ return;-+ }-+ }++bool WebPageInspectorController::shouldPauseLoading() const++{++ if (!m_frontendRouter->hasFrontends())++ return false;+-+ page->inspectorController().navigate(WTFMove(resourceRequest), frame, [callback = WTFMove(callback)](const String& error, uint64_t navigationID) {-+ if (!error.isEmpty()) {-+ callback->sendFailure(error);-+ return;-+ }++ if (!m_page.isPageOpenedByDOMShowingInitialEmptyDocument())++ return false;+-+ Optional<String> navigationIDString;-+ if (navigationID)-+ navigationIDString = String::number(navigationID);-+ callback->sendSuccess(navigationIDString);-+ });++ auto* target = m_targets.get(WebPageInspectorTarget::toTargetID(m_page.webPageID()));++ ASSERT(target);++ return target->isPaused();+}+-+void InspectorBrowserAgent::setIgnoreCertificateErrors(Inspector::ErrorString& errorString, const String* browserContextID, bool ignore)++void WebPageInspectorController::setContinueLoadingCallback(WTF::Function<void()>&& callback)+{-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty())-+ return;-+ browserContext.processPool->setIgnoreTLSErrors(ignore);++ auto* target = m_targets.get(WebPageInspectorTarget::toTargetID(m_page.webPageID()));++ ASSERT(target);++ target->setResumeCallback(WTFMove(callback));+}+-+void InspectorBrowserAgent::getAllCookies(const String* browserContextID, Ref<GetAllCookiesCallback>&& callback) {-+ String errorString;-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty()) {-+ callback->sendFailure(errorString);-+ return;-+ }+ bool WebPageInspectorController::shouldPauseLoading(const ProvisionalPageProxy& provisionalPage) const+ {+ if (!m_frontendRouter->hasFrontends())+@@ -186,7 +349,7 @@ void WebPageInspectorController::setContinueLoadingCallback(const ProvisionalPag++ void WebPageInspectorController::didCreateProvisionalPage(ProvisionalPageProxy& provisionalPage)+ {+- addTarget(InspectorTargetProxy::create(provisionalPage, getTargetID(provisionalPage), Inspector::InspectorTargetType::Page));++ addTarget(InspectorTargetProxy::create(provisionalPage, getTargetID(provisionalPage)));+ }++ void WebPageInspectorController::willDestroyProvisionalPage(const ProvisionalPageProxy& provisionalPage)+@@ -218,4 +381,16 @@ void WebPageInspectorController::addTarget(std::unique_ptr<InspectorTargetProxy>+ m_targets.set(target->identifier(), WTFMove(target));+ }+++void WebPageInspectorController::adjustPageSettings()++{++ // Set this to true as otherwise updating any preferences will override its++ // value in the Web Process to false (and InspectorController sets it locally++ // to true when frontend is connected).++ m_page.preferences().setDeveloperExtrasEnabled(true);+-+ PAL::SessionID sessionID = browserContext.dataStore->sessionID();-+ NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();-+ networkProcess->sendWithAsyncReply(Messages::NetworkProcess::GetAllCookies(sessionID),-+ [callback = WTFMove(callback)](Vector<WebCore::Cookie> allCookies) {-+ if (!callback->isActive())-+ return;-+ auto cookies = JSON::ArrayOf<Inspector::Protocol::Browser::Cookie>::create();-+ for (const auto& cookie : allCookies)-+ cookies->addItem(buildObjectForCookie(cookie));-+ callback->sendSuccess(WTFMove(cookies));-+ }, 0);++ // Navigation to cached pages doesn't fire some of the events (e.g. execution context created)++ // that inspector depends on. So we disable the cache when front-end connects.++ m_page.preferences().setUsesBackForwardCache(false);+}+-+void InspectorBrowserAgent::setCookies(const String* browserContextID, const JSON::Array& in_cookies, Ref<SetCookiesCallback>&& callback) {-+ String errorString;-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty()) {-+ callback->sendFailure(errorString);-+ return;-+ }+ } // namespace WebKit+diff --git a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h+index 78caedf0c0ce83675569502d150fcc44e5f9868c..46b9901263286eab6de0bc4f899349d56b1efb33 100644+--- a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h++++ b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h+@@ -26,6 +26,7 @@+ #pragma once++ #include "InspectorTargetProxy.h"++#include "ProcessTerminationReason.h"+ #include <JavaScriptCore/InspectorAgentRegistry.h>+ #include <JavaScriptCore/InspectorTargetAgent.h>+ #include <WebCore/PageIdentifier.h>+@@ -37,10 +38,30 @@ namespace Inspector {+ class BackendDispatcher;+ class FrontendChannel;+ class FrontendRouter;++class InspectorTarget;++}+-+ NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();-+ PAL::SessionID sessionID = browserContext.dataStore->sessionID();++namespace WebCore {++class ResourceError;++class ResourceRequest;++enum class PolicyAction : uint8_t;+ }++ namespace WebKit {+++class WebFrameProxy;++class WebPageInspectorInputAgent;+-+ Vector<WebCore::Cookie> cookies;-+ for (unsigned i = 0; i < in_cookies.length(); ++i) {-+ RefPtr<JSON::Value> item = in_cookies.get(i);-+ RefPtr<JSON::Object> obj;-+ if (!item->asObject(obj)) {-+ errorString = "Invalid cookie payload format"_s;-+ return;-+ }++class WebPageInspectorControllerObserver {++public:++ virtual void didCreateInspectorController(WebPageProxy&) = 0;++ virtual void willDestroyInspectorController(WebPageProxy&) = 0;++ virtual void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error) = 0;+-+ WebCore::Cookie cookie;-+ if (!obj->getString("name", cookie.name) ||-+ !obj->getString("value", cookie.value) ||-+ !obj->getString("domain", cookie.domain) ||-+ !obj->getString("path", cookie.path)) {-+ errorString = "Invalid file payload format"_s;-+ return;-+ }++protected:++ virtual ~WebPageInspectorControllerObserver() = default;++};+-+ obj->getDouble("expires", cookie.expires);-+ obj->getBoolean("httpOnly", cookie.httpOnly);-+ obj->getBoolean("secure", cookie.secure);-+ obj->getBoolean("session", cookie.session);-+ String sameSite;-+ if (obj->getString("sameSite", sameSite)) {-+ if (sameSite == "None")-+ cookie.sameSite = WebCore::Cookie::SameSitePolicy::None;-+ if (sameSite == "Lax")-+ cookie.sameSite = WebCore::Cookie::SameSitePolicy::Lax;-+ if (sameSite == "Strict")-+ cookie.sameSite = WebCore::Cookie::SameSitePolicy::Strict;-+ }-+ cookies.append(WTFMove(cookie));-+ }+ class WebPageInspectorController {+ WTF_MAKE_NONCOPYABLE(WebPageInspectorController);+ WTF_MAKE_FAST_ALLOCATED;+@@ -48,7 +69,15 @@ public:+ WebPageInspectorController(WebPageProxy&);++ void init();++ void didFinishAttachingToWebProcess();+-+ networkProcess->sendWithAsyncReply(Messages::NetworkProcess::SetCookies(sessionID, WTFMove(cookies)),-+ [callback = WTFMove(callback)](bool success) {-+ if (!callback->isActive())-+ return;++ static void setObserver(WebPageInspectorControllerObserver*);+-+ if (success)-+ callback->sendSuccess();-+ else-+ callback->sendFailure("Internal error: no network storage"_s);-+ callback->sendSuccess();-+ }, 0);-+}-+-+void InspectorBrowserAgent::deleteAllCookies(const String* browserContextID, Ref<DeleteAllCookiesCallback>&& callback) {-+ String errorString;-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty()) {-+ callback->sendFailure(errorString);-+ return;-+ }-+-+ NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();-+ PAL::SessionID sessionID = browserContext.dataStore->sessionID();-+ networkProcess->sendWithAsyncReply(Messages::NetworkProcess::DeleteAllCookies(sessionID),-+ [callback = WTFMove(callback)](bool success) {-+ if (!callback->isActive())-+ return;-+ if (success)-+ callback->sendSuccess();-+ else-+ callback->sendFailure("Internal error: no network storage"_s);-+ }, 0);-+}-+-+void InspectorBrowserAgent::grantPermissions(Inspector::ErrorString& errorString, const String* browserContextID, const String& origin, const JSON::Array& values)-+{-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty())-+ return;-+ HashSet<String> set;-+ for (const auto& value : values) {-+ String name;-+ if (!value->asString(name)) {-+ errorString = "Permission must be a string"_s;-+ return;-+ }-+ set.add(name);-+ }-+ String key = browserContextID ? *browserContextID : "";-+ auto it = m_permissions.add(key, Permissions()).iterator;-+ it->value.set(origin, WTFMove(set));-+ Vector<WebPageProxy*> pages;-+ for (auto& process : browserContext.processPool->processes()) {-+ for (auto* page : process->pages())-+ page->setPermissionsForAutomation(it->value);-+ }-+}-+-+void InspectorBrowserAgent::resetPermissions(Inspector::ErrorString& errorString, const String* browserContextID)-+{-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty())-+ return;-+ m_permissions.clear();-+ for (auto& process : browserContext.processPool->processes()) {-+ for (auto* page : process->pages())-+ page->setPermissionsForAutomation(HashMap<String, HashSet<String>>());-+ }-+}-+-+void InspectorBrowserAgent::setGeolocationOverride(Inspector::ErrorString& errorString, const String* browserContextID, const JSON::Object* geolocation)-+{-+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);-+ if (!errorString.isEmpty())-+ return;-+ auto* geoManager = browserContext.processPool->supplement<WebGeolocationManagerProxy>();-+ if (!geoManager) {-+ errorString = "Internal error: geolocation manager is not available.";-+ return;-+ }-+ if (geolocation) {-+ double timestamp = 0;-+ double latitude = 0;-+ double longitude = 0;-+ double accuracy = 0;-+ if (!geolocation->getDouble("timestamp", timestamp) ||-+ !geolocation->getDouble("latitude", latitude) ||-+ !geolocation->getDouble("longitude", longitude) ||-+ !geolocation->getDouble("accuracy", accuracy)) {-+ errorString = "Invalid geolocation format"_s;-+ return;-+ }-+ auto position = WebGeolocationPosition::create(WebCore::GeolocationPositionData(timestamp, latitude, longitude, accuracy));-+ geoManager->providerDidChangePosition(&position.get());-+ } else {-+ geoManager->providerDidFailToDeterminePosition("Position unavailable"_s);-+ }-+}+ void pageClosed();++ bool pageCrashed(ProcessTerminationReason);+-+String InspectorBrowserAgent::toBrowserContextIDProtocolString(const PAL::SessionID& sessionID)-+{-+ StringBuilder builder;-+ builder.append(hex(sessionID.toUInt64(), 16));-+ return builder.toString();-+}++ void didProcessAllPendingKeyboardEvents();++ void didProcessAllPendingMouseEvents();++ bool hasLocalFrontend() const;++@@ -57,15 +86,28 @@ public:+ void disconnectAllFrontends();++ void dispatchMessageFromFrontend(const String& message);++ bool dispatchMessageToTargetBackend(const String&);++ #if ENABLE(REMOTE_INSPECTOR)+ void setIndicating(bool);+ #endif+++ using NavigationHandler = Function<void(const String&, uint64_t)>;++ void navigate(WebCore::ResourceRequest&&, WebFrameProxy*, NavigationHandler&&);++ void didReceivePolicyDecision(WebCore::PolicyAction action, uint64_t navigationID);++ void didDestroyNavigation(uint64_t navigationID);+-+String InspectorBrowserAgent::toPageProxyIDProtocolString(const WebPageProxy& page)-+{-+ return makeString(page.identifier().toUInt64());-+}++ void didFailProvisionalLoadForFrame(uint64_t navigationID, const WebCore::ResourceError& error);+-+BrowserContext InspectorBrowserAgent::lookupBrowserContext(ErrorString& errorString, const String* browserContextID)-+{-+ if (!browserContextID) {-+ auto* pool = WebProcessPool::allProcessPools().first();-+ BrowserContext context;-+ context.processPool = pool;-+ context.dataStore = pool->websiteDataStore();-+ return context;-+ }+ void createInspectorTarget(const String& targetId, Inspector::InspectorTargetType);+ void destroyInspectorTarget(const String& targetId);+ void sendMessageToInspectorFrontend(const String& targetId, const String& message);+++ void setPauseOnStart(bool);+-+ BrowserContext browserContext = m_browserContexts.get(*browserContextID);-+ if (!browserContext.processPool)-+ errorString = "Could not find browser context for given id"_s;-+ return browserContext;-+}++ bool shouldPauseLoading() const;++ void setContinueLoadingCallback(WTF::Function<void()>&&);+-+} // namespace WebKit+ bool shouldPauseLoading(const ProvisionalPageProxy&) const;+ void setContinueLoadingCallback(const ProvisionalPageProxy&, WTF::Function<void()>&&);++@@ -75,13 +117,18 @@ public:++ private:+ void addTarget(std::unique_ptr<InspectorTargetProxy>&&);++ void adjustPageSettings();++ WebPageProxy& m_page;+ Ref<Inspector::FrontendRouter> m_frontendRouter;+ Ref<Inspector::BackendDispatcher> m_backendDispatcher;+ Inspector::AgentRegistry m_agents;+- Inspector::InspectorTargetAgent* m_targetAgent;++ Inspector::InspectorTargetAgent* m_targetAgent { nullptr };++ WebPageInspectorInputAgent* m_inputAgent { nullptr };+ HashMap<String, std::unique_ptr<InspectorTargetProxy>> m_targets;++ HashMap<uint64_t, NavigationHandler> m_pendingNavigations;+-+#endif // ENABLE(REMOTE_INSPECTOR)-diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgent.h b/Source/WebKit/UIProcess/InspectorBrowserAgent.h++ static WebPageInspectorControllerObserver* s_observer;+ };++ } // namespace WebKit+diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp b/Source/WebKit/UIProcess/InspectorBrowserAgent.cppnew file mode 100644-index 0000000000000000000000000000000000000000..8f224acabb5b2010368f25b9b6d5ca0a3b75cd0b+index 0000000000000000000000000000000000000000..d8dbb6391594955a23a5ed3cb34b05ca0b47acc1--- /dev/null-+++ b/Source/WebKit/UIProcess/InspectorBrowserAgent.h-@@ -0,0 +1,113 @@++++ b/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp+@@ -0,0 +1,497 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -7454,253 +7355,484 @@ index 0000000000000000000000000000000000000000..8f224acabb5b2010368f25b9b6d5ca0a+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+ */+-+#pragma once++#include "config.h"++#include "InspectorBrowserAgent.h"++#if ENABLE(REMOTE_INSPECTOR)+++#include "APIPageConfiguration.h"+#include "InspectorBrowserAgentClient.h"-+#include <JavaScriptCore/InspectorAgentBase.h>-+#include <JavaScriptCore/InspectorBackendDispatchers.h>-+#include <wtf/HashMap.h>++#include "InspectorTargetProxy.h"++#include "NetworkProcessMessages.h"++#include "NetworkProcessProxy.h"++#include "WebGeolocationManagerProxy.h"++#include "WebGeolocationPosition.h"++#include "WebPageInspectorController.h"++#include "WebPageInspectorTarget.h"++#include "WebPageProxy.h"++#include "WebProcessPool.h"++#include "WebProcessProxy.h"++#include <WebCore/FrameIdentifier.h>++#include <WebCore/GeolocationPositionData.h>++#include <WebCore/ProcessIdentifier.h>++#include <WebCore/ResourceRequest.h>++#include <JavaScriptCore/InspectorFrontendRouter.h>+#include <pal/SessionID.h>-+#include <wtf/Forward.h>-+#include <wtf/Noncopyable.h>++#include <stdlib.h>++#include <wtf/HashMap.h>++#include <wtf/HexNumber.h>+-+namespace Inspector {-+class BackendDispatcher;-+class BrowserFrontendDispatcher;-+class FrontendChannel;-+class FrontendRouter;-+}+-+namespace PAL {-+class SessionID;-+}++using namespace Inspector;++namespace WebKit {+-+class NetworkProcess;-+class WebFrameProxy;-+class WebProcessPool;-+-+class PageProxyIDMap {-+public:-+ virtual WebPageProxy* findPageProxy(const String& pageProxyID) = 0;++namespace {+-+protected:-+ virtual ~PageProxyIDMap() = default;-+};++Inspector::Protocol::Browser::CookieSameSitePolicy cookieSameSitePolicy(WebCore::Cookie::SameSitePolicy policy)++{++ switch (policy) {++ case WebCore::Cookie::SameSitePolicy::None:++ return Inspector::Protocol::Browser::CookieSameSitePolicy::None;++ case WebCore::Cookie::SameSitePolicy::Lax:++ return Inspector::Protocol::Browser::CookieSameSitePolicy::Lax;++ case WebCore::Cookie::SameSitePolicy::Strict:++ return Inspector::Protocol::Browser::CookieSameSitePolicy::Strict;++ }++ ASSERT_NOT_REACHED();++ return Inspector::Protocol::Browser::CookieSameSitePolicy::None;++}+-+class InspectorBrowserAgent final : public Inspector::InspectorAgentBase, public Inspector::BrowserBackendDispatcherHandler {-+ WTF_MAKE_NONCOPYABLE(InspectorBrowserAgent);-+ WTF_MAKE_FAST_ALLOCATED;-+public:-+ InspectorBrowserAgent(Inspector::FrontendRouter&, Inspector::BackendDispatcher&, InspectorBrowserAgentClient*, PageProxyIDMap&);-+ ~InspectorBrowserAgent() override;++Ref<Inspector::Protocol::Browser::Cookie> buildObjectForCookie(const WebCore::Cookie& cookie)++{++ return Inspector::Protocol::Browser::Cookie::create()++ .setName(cookie.name)++ .setValue(cookie.value)++ .setDomain(cookie.domain)++ .setPath(cookie.path)++ .setExpires(cookie.expires)++ .setHttpOnly(cookie.httpOnly)++ .setSecure(cookie.secure)++ .setSession(cookie.session)++ .setSameSite(cookieSameSitePolicy(cookie.sameSite))++ .release();++}+-+ void didCreateWebPageProxy(const WebPageProxy&);-+ void willDestroyWebPageProxy(const WebPageProxy&);-+ void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error);-+-+ // InspectorAgentBase-+ void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;-+ void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;-+-+ // BrowserBackendDispatcherHandler-+ void close(Ref<CloseCallback>&&) override;-+ void createContext(Inspector::ErrorString&, String* browserContextID) override;-+ void deleteContext(Inspector::ErrorString&, const String& browserContextID) override;-+ void createPage(Inspector::ErrorString&, const String* browserContextID, String* pageProxyID) override;-+ void navigate(const String& url, const String& pageProxyID, const String* frameId, const String* referrer, Ref<NavigateCallback>&&) override;-+ void setIgnoreCertificateErrors(Inspector::ErrorString&, const String* browserContextID, bool ignore) override;-+-+ void getAllCookies(const String* browserContextID, Ref<GetAllCookiesCallback>&&) override;-+ void setCookies(const String* browserContextID, const JSON::Array& in_cookies, Ref<SetCookiesCallback>&&) override;-+ void deleteAllCookies(const String* browserContextID, Ref<DeleteAllCookiesCallback>&&) override;-+-+ void grantPermissions(Inspector::ErrorString&, const String* browserContextID, const String& origin, const JSON::Array& permissions) override;-+ void resetPermissions(Inspector::ErrorString&, const String* browserContextID) override;-+ void setGeolocationOverride(Inspector::ErrorString&, const String* browserContextID, const JSON::Object* geolocation) override;-+-+ static String toBrowserContextIDProtocolString(const PAL::SessionID&);-+ static String toPageProxyIDProtocolString(const WebPageProxy&);-+-+private:-+ BrowserContext lookupBrowserContext(Inspector::ErrorString&, const String* browserContextID);-+ WebFrameProxy* frameForID(const String& frameID, String& error);-+-+ std::unique_ptr<Inspector::BrowserFrontendDispatcher> m_frontendDispatcher;-+ Ref<Inspector::BrowserBackendDispatcher> m_backendDispatcher;-+ InspectorBrowserAgentClient* m_client;-+ PageProxyIDMap& m_pageProxyIDMap;-+ using Permissions = HashMap<String, HashSet<String>>;-+ HashMap<String, Permissions> m_permissions;-+ HashMap<String, BrowserContext> m_browserContexts;-+ bool m_isConnected { false };-+};-+-+} // namespace WebKit-+-+#endif // ENABLE(REMOTE_INSPECTOR)-diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgentClient.h b/Source/WebKit/UIProcess/InspectorBrowserAgentClient.h-new file mode 100644-index 0000000000000000000000000000000000000000..21f8cc9bffd8f2d4a88764a4eafa13f367aa1e7c---- /dev/null-+++ b/Source/WebKit/UIProcess/InspectorBrowserAgentClient.h-@@ -0,0 +1,55 @@-+/*-+ * Copyright (C) 2019 Microsoft Corporation.-+ *-+ * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT-+ * OWNER OR 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-+-+#if ENABLE(REMOTE_INSPECTOR)-+-+#include <pal/SessionID.h>-+#include <wtf/Forward.h>-+-+namespace WebKit {-+-+class WebsiteDataStore;-+class WebPageProxy;-+class WebProcessPool;-+-+struct BrowserContext {-+ RefPtr<WebsiteDataStore> dataStore;-+ RefPtr<WebProcessPool> processPool;-+};-+-+class InspectorBrowserAgentClient {-+public:-+ virtual ~InspectorBrowserAgentClient() = default;-+ virtual RefPtr<WebKit::WebPageProxy> createPage(WTF::String& error, const BrowserContext& context) = 0;-+ virtual void closeBrowser() = 0;-+ virtual BrowserContext createBrowserContext(WTF::String& error) = 0;-+ virtual void deleteBrowserContext(WTF::String& error, PAL::SessionID) = 0;-+};-+-+} // namespace WebKit-+-+#endif // ENABLE(REMOTE_INSPECTOR)-diff --git a/Source/WebKit/UIProcess/InspectorDialogAgent.cpp b/Source/WebKit/UIProcess/InspectorDialogAgent.cpp-new file mode 100644-index 0000000000000000000000000000000000000000..ca5965f9d682c0821a40f0d1d43e5cbeda1353a5---- /dev/null-+++ b/Source/WebKit/UIProcess/InspectorDialogAgent.cpp-@@ -0,0 +1,86 @@-+/*-+ * Copyright (C) 2019 Microsoft Corporation.-+ *-+ * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT-+ * OWNER OR 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 "InspectorDialogAgent.h"++Ref<Inspector::Protocol::Browser::PageProxyInfo> buildPageProxyInfo(const WebPageProxy& page) {++ auto result = Inspector::Protocol::Browser::PageProxyInfo::create()++ .setPageProxyId(InspectorBrowserAgent::toPageProxyIDProtocolString(page))++ .setBrowserContextId(InspectorBrowserAgent::toBrowserContextIDProtocolString(page.sessionID()))++ .release();++ auto* opener = page.configuration().relatedPage();++ if (opener)++ result->setOpenerId(InspectorBrowserAgent::toPageProxyIDProtocolString(*opener));++ return result;++}+-+#include "APINavigation.h"-+#include "APIUIClient.h"-+#include "WebPageProxy.h"-+#include <JavaScriptCore/InspectorFrontendRouter.h>++} // namespace+++InspectorBrowserAgent::InspectorBrowserAgent(Inspector::FrontendRouter& frontendRouter, Inspector::BackendDispatcher& backendDispatcher, InspectorBrowserAgentClient* client, PageProxyIDMap& pageProxyIDMap)++ : InspectorAgentBase("Browser"_s)++ , m_frontendDispatcher(makeUnique<BrowserFrontendDispatcher>(frontendRouter))++ , m_backendDispatcher(BrowserBackendDispatcher::create(backendDispatcher, this))++ , m_client(client)++ , m_pageProxyIDMap(pageProxyIDMap)++{++}+-+namespace WebKit {++InspectorBrowserAgent::~InspectorBrowserAgent() = default;+-+using namespace Inspector;++void InspectorBrowserAgent::didCreateWebPageProxy(const WebPageProxy& page)++{++ if (m_isConnected)++ m_frontendDispatcher->pageProxyCreated(buildPageProxyInfo(page));++}+-+InspectorDialogAgent::InspectorDialogAgent(Inspector::BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page)-+ : InspectorAgentBase("Dialog"_s)-+ , m_frontendDispatcher(makeUnique<DialogFrontendDispatcher>(frontendRouter))-+ , m_backendDispatcher(DialogBackendDispatcher::create(backendDispatcher, this))-+ , m_page(page)++void InspectorBrowserAgent::willDestroyWebPageProxy(const WebPageProxy& page)+{++ if (m_isConnected)++ m_frontendDispatcher->pageProxyDestroyed(toPageProxyIDProtocolString(page));+}+-+InspectorDialogAgent::~InspectorDialogAgent()++void InspectorBrowserAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)+{-+ Inspector::ErrorString err;-+ disable(err);++ m_isConnected = true;+}+-+void InspectorDialogAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)++void InspectorBrowserAgent::didFailProvisionalLoad(WebPageProxy& page, uint64_t navigationID, const String& error)+{++ if (!m_isConnected)++ return;++++ m_frontendDispatcher->provisionalLoadFailed(toPageProxyIDProtocolString(page), String::number(navigationID), error);+}+-+void InspectorDialogAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)++void InspectorBrowserAgent::willDestroyFrontendAndBackend(DisconnectReason)+{++ m_isConnected = false;+}+-+void InspectorDialogAgent::enable(Inspector::ErrorString& errorString)++void InspectorBrowserAgent::close(Ref<CloseCallback>&& callback)+{-+ if (m_page.inspectorDialogAgent()) {-+ errorString = "Dialog domain is already enabled."_s;-+ return;++ Vector<WebPageProxy*> pages;++ for (auto& pool : WebProcessPool::allProcessPools()) {++ for (auto& process : pool->processes()) {++ for (auto* page : process->pages())++ pages.append(page);++ }+ }-+ m_page.setInspectorDialogAgent(this);++ for (auto* page : pages)++ page->closePage();++++ WebProcessPool::allProcessPools().first()->syncLocalStorage([this, callback = WTFMove(callback)] () {++ if (!callback->isActive())++ return;++++ m_browserContexts.clear();++ if (m_client == nullptr) {++ callback->sendFailure("no platform delegate to close browser");++ } else {++ m_client->closeBrowser();++ callback->sendSuccess();++ }++ });+++}+-+void InspectorDialogAgent::disable(Inspector::ErrorString&)++void InspectorBrowserAgent::createContext(ErrorString& errorString, String* browserContextID)+{-+ if (m_page.inspectorDialogAgent() != this)++ BrowserContext browserContext = m_client->createBrowserContext(errorString);++ if (!errorString.isEmpty())+ return;-+ m_page.setInspectorDialogAgent(nullptr);++ browserContext.processPool->setPrimaryDataStore(*browserContext.dataStore);++ browserContext.processPool->ensureNetworkProcess(browserContext.dataStore.get());++ PAL::SessionID sessionID = browserContext.dataStore->sessionID();++ *browserContextID = toBrowserContextIDProtocolString(sessionID);++ m_browserContexts.set(*browserContextID, browserContext);+}+-+void InspectorDialogAgent::handleJavaScriptDialog(Inspector::ErrorString& errorString, bool accept, const String* value)++void InspectorBrowserAgent::deleteContext(ErrorString& errorString, const String& browserContextID)+{-+ m_page.uiClient().handleJavaScriptDialog(m_page, accept, value ? *value : String());-+}++ BrowserContext browserContext = lookupBrowserContext(errorString, &browserContextID);++ if (!errorString.isEmpty())++ return;+-+void InspectorDialogAgent::javascriptDialogOpening(const String& type, const String& message, const String* defaultValue) {-+ m_frontendDispatcher->javascriptDialogOpening(type, message, defaultValue);++ Vector<WebPageProxy*> pages;++ for (auto& process : browserContext.processPool->processes()) {++ for (auto* page : process->pages())++ pages.append(page);++ }++++ for (auto* page : pages)++ page->closePage();++++ PAL::SessionID sessionID = browserContext.dataStore->sessionID();++ m_client->deleteBrowserContext(errorString, sessionID);++ m_browserContexts.remove(browserContextID);+}+-+} // namespace WebKit-diff --git a/Source/WebKit/UIProcess/InspectorDialogAgent.h b/Source/WebKit/UIProcess/InspectorDialogAgent.h-new file mode 100644-index 0000000000000000000000000000000000000000..f356c613945fd263889bc74166bef2b279ab4ca1---- /dev/null-+++ b/Source/WebKit/UIProcess/InspectorDialogAgent.h-@@ -0,0 +1,70 @@++void InspectorBrowserAgent::createPage(ErrorString& errorString, const String* browserContextID, String* pageProxyID)++{++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty())++ return;++ RefPtr<WebPageProxy> page = m_client->createPage(errorString, browserContext);++ if (!page)++ return;++ page->setPermissionsForAutomation(m_permissions.get(browserContextID ? *browserContextID : ""));++ *pageProxyID = toPageProxyIDProtocolString(*page);++}++++WebFrameProxy* InspectorBrowserAgent::frameForID(const String& frameID, String& error)++{++ size_t dotPos = frameID.find(".");++ if (dotPos == notFound) {++ error = "Invalid frame id"_s;++ return nullptr;++ }++++ if (!frameID.isAllASCII()) {++ error = "Invalid frame id"_s;++ return nullptr;++ }++++ String processIDString = frameID.left(dotPos);++ uint64_t pid = strtoull(processIDString.ascii().data(), 0, 10);++ auto processID = makeObjectIdentifier<WebCore::ProcessIdentifierType>(pid);++ WebProcessProxy* process = WebProcessProxy::processForIdentifier(processID);++ if (!process) {++ error = "Cannot find web process for the frame id"_s;++ return nullptr;++ }++++ String frameIDString = frameID.substring(dotPos + 1);++ uint64_t frameIDNumber = strtoull(frameIDString.ascii().data(), 0, 10);++ auto frameIdentifier = makeObjectIdentifier<WebCore::FrameIdentifierType>(frameIDNumber);++ WebFrameProxy* frame = process->webFrame(frameIdentifier);++ if (!frame) {++ error = "Cannot find web frame for the frame id"_s;++ return nullptr;++ }++++ return frame;++}++++void InspectorBrowserAgent::navigate(const String& url, const String& pageProxyID, const String* frameID, const String* referrer, Ref<NavigateCallback>&& callback)++{++ WebPageProxy* page = m_pageProxyIDMap.findPageProxy(pageProxyID);++ if (!page) {++ callback->sendFailure("Cannot find page proxy with provided 'pageProxyId'"_s);++ return;++ }++++ WebCore::ResourceRequest resourceRequest { url };++++ if (referrer)++ resourceRequest.setHTTPReferrer(*referrer);++++ if (!resourceRequest.url().isValid()) {++ callback->sendFailure("Cannot navigate to invalid URL"_s);++ return;++ }++++ WebFrameProxy* frame = nullptr;++ if (frameID) {++ String error;++ frame = frameForID(*frameID, error);++ if (!frame) {++ callback->sendFailure(error);++ return;++ }++++ if (frame->page() != page) {++ callback->sendFailure("Frame with specified is not from the specified page"_s);++ return;++ }++ }++++ page->inspectorController().navigate(WTFMove(resourceRequest), frame, [callback = WTFMove(callback)](const String& error, uint64_t navigationID) {++ if (!error.isEmpty()) {++ callback->sendFailure(error);++ return;++ }++++ Optional<String> navigationIDString;++ if (navigationID)++ navigationIDString = String::number(navigationID);++ callback->sendSuccess(navigationIDString);++ });++}++++void InspectorBrowserAgent::setIgnoreCertificateErrors(Inspector::ErrorString& errorString, const String* browserContextID, bool ignore)++{++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty())++ return;++ browserContext.processPool->setIgnoreTLSErrors(ignore);++}++++void InspectorBrowserAgent::getAllCookies(const String* browserContextID, Ref<GetAllCookiesCallback>&& callback) {++ String errorString;++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty()) {++ callback->sendFailure(errorString);++ return;++ }++++ PAL::SessionID sessionID = browserContext.dataStore->sessionID();++ NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();++ networkProcess->sendWithAsyncReply(Messages::NetworkProcess::GetAllCookies(sessionID),++ [callback = WTFMove(callback)](Vector<WebCore::Cookie> allCookies) {++ if (!callback->isActive())++ return;++ auto cookies = JSON::ArrayOf<Inspector::Protocol::Browser::Cookie>::create();++ for (const auto& cookie : allCookies)++ cookies->addItem(buildObjectForCookie(cookie));++ callback->sendSuccess(WTFMove(cookies));++ }, 0);++}++++void InspectorBrowserAgent::setCookies(const String* browserContextID, const JSON::Array& in_cookies, Ref<SetCookiesCallback>&& callback) {++ String errorString;++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty()) {++ callback->sendFailure(errorString);++ return;++ }++++ NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();++ PAL::SessionID sessionID = browserContext.dataStore->sessionID();++++ Vector<WebCore::Cookie> cookies;++ for (unsigned i = 0; i < in_cookies.length(); ++i) {++ RefPtr<JSON::Value> item = in_cookies.get(i);++ RefPtr<JSON::Object> obj;++ if (!item->asObject(obj)) {++ errorString = "Invalid cookie payload format"_s;++ return;++ }++++ WebCore::Cookie cookie;++ if (!obj->getString("name", cookie.name) ||++ !obj->getString("value", cookie.value) ||++ !obj->getString("domain", cookie.domain) ||++ !obj->getString("path", cookie.path)) {++ errorString = "Invalid file payload format"_s;++ return;++ }++++ obj->getDouble("expires", cookie.expires);++ obj->getBoolean("httpOnly", cookie.httpOnly);++ obj->getBoolean("secure", cookie.secure);++ obj->getBoolean("session", cookie.session);++ String sameSite;++ if (obj->getString("sameSite", sameSite)) {++ if (sameSite == "None")++ cookie.sameSite = WebCore::Cookie::SameSitePolicy::None;++ if (sameSite == "Lax")++ cookie.sameSite = WebCore::Cookie::SameSitePolicy::Lax;++ if (sameSite == "Strict")++ cookie.sameSite = WebCore::Cookie::SameSitePolicy::Strict;++ }++ cookies.append(WTFMove(cookie));++ }++++ networkProcess->sendWithAsyncReply(Messages::NetworkProcess::SetCookies(sessionID, WTFMove(cookies)),++ [callback = WTFMove(callback)](bool success) {++ if (!callback->isActive())++ return;++++ if (success)++ callback->sendSuccess();++ else++ callback->sendFailure("Internal error: no network storage"_s);++ callback->sendSuccess();++ }, 0);++}++++void InspectorBrowserAgent::deleteAllCookies(const String* browserContextID, Ref<DeleteAllCookiesCallback>&& callback) {++ String errorString;++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty()) {++ callback->sendFailure(errorString);++ return;++ }++++ NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();++ PAL::SessionID sessionID = browserContext.dataStore->sessionID();++ networkProcess->sendWithAsyncReply(Messages::NetworkProcess::DeleteAllCookies(sessionID),++ [callback = WTFMove(callback)](bool success) {++ if (!callback->isActive())++ return;++ if (success)++ callback->sendSuccess();++ else++ callback->sendFailure("Internal error: no network storage"_s);++ }, 0);++}++++void InspectorBrowserAgent::grantPermissions(Inspector::ErrorString& errorString, const String* browserContextID, const String& origin, const JSON::Array& values)++{++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty())++ return;++ HashSet<String> set;++ for (const auto& value : values) {++ String name;++ if (!value->asString(name)) {++ errorString = "Permission must be a string"_s;++ return;++ }++ set.add(name);++ }++ String key = browserContextID ? *browserContextID : "";++ auto it = m_permissions.add(key, Permissions()).iterator;++ it->value.set(origin, WTFMove(set));++ Vector<WebPageProxy*> pages;++ for (auto& process : browserContext.processPool->processes()) {++ for (auto* page : process->pages())++ page->setPermissionsForAutomation(it->value);++ }++}++++void InspectorBrowserAgent::resetPermissions(Inspector::ErrorString& errorString, const String* browserContextID)++{++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty())++ return;++ m_permissions.clear();++ for (auto& process : browserContext.processPool->processes()) {++ for (auto* page : process->pages())++ page->setPermissionsForAutomation(HashMap<String, HashSet<String>>());++ }++}++++void InspectorBrowserAgent::setGeolocationOverride(Inspector::ErrorString& errorString, const String* browserContextID, const JSON::Object* geolocation)++{++ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);++ if (!errorString.isEmpty())++ return;++ auto* geoManager = browserContext.processPool->supplement<WebGeolocationManagerProxy>();++ if (!geoManager) {++ errorString = "Internal error: geolocation manager is not available.";++ return;++ }++ if (geolocation) {++ double timestamp = 0;++ double latitude = 0;++ double longitude = 0;++ double accuracy = 0;++ if (!geolocation->getDouble("timestamp", timestamp) ||++ !geolocation->getDouble("latitude", latitude) ||++ !geolocation->getDouble("longitude", longitude) ||++ !geolocation->getDouble("accuracy", accuracy)) {++ errorString = "Invalid geolocation format"_s;++ return;++ }++ auto position = WebGeolocationPosition::create(WebCore::GeolocationPositionData(timestamp, latitude, longitude, accuracy));++ geoManager->providerDidChangePosition(&position.get());++ } else {++ geoManager->providerDidFailToDeterminePosition("Position unavailable"_s);++ }++}++++String InspectorBrowserAgent::toBrowserContextIDProtocolString(const PAL::SessionID& sessionID)++{++ StringBuilder builder;++ builder.append(hex(sessionID.toUInt64(), 16));++ return builder.toString();++}++++String InspectorBrowserAgent::toPageProxyIDProtocolString(const WebPageProxy& page)++{++ return makeString(page.identifier().toUInt64());++}++++BrowserContext InspectorBrowserAgent::lookupBrowserContext(ErrorString& errorString, const String* browserContextID)++{++ if (!browserContextID) {++ auto* pool = WebProcessPool::allProcessPools().first();++ BrowserContext context;++ context.processPool = pool;++ context.dataStore = pool->websiteDataStore();++ return context;++ }++++ BrowserContext browserContext = m_browserContexts.get(*browserContextID);++ if (!browserContext.processPool)++ errorString = "Could not find browser context for given id"_s;++ return browserContext;++}++++} // namespace WebKit++++#endif // ENABLE(REMOTE_INSPECTOR)+diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgent.h b/Source/WebKit/UIProcess/InspectorBrowserAgent.h+new file mode 100644+index 0000000000000000000000000000000000000000..8f224acabb5b2010368f25b9b6d5ca0a3b75cd0b+--- /dev/null++++ b/Source/WebKit/UIProcess/InspectorBrowserAgent.h+@@ -0,0 +1,113 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -7728,186 +7860,98 @@ index 0000000000000000000000000000000000000000..f356c613945fd263889bc74166bef2b2++#pragma once+-+#include "WebEvent.h"++#if ENABLE(REMOTE_INSPECTOR)+++#include "InspectorBrowserAgentClient.h"+#include <JavaScriptCore/InspectorAgentBase.h>+#include <JavaScriptCore/InspectorBackendDispatchers.h>-+#include <JavaScriptCore/InspectorFrontendDispatchers.h>-+++#include <wtf/HashMap.h>++#include <pal/SessionID.h>+#include <wtf/Forward.h>+#include <wtf/Noncopyable.h>++namespace Inspector {++class BackendDispatcher;++class BrowserFrontendDispatcher;+class FrontendChannel;+class FrontendRouter;+}+++namespace PAL {++class SessionID;++}+++namespace WebKit {+-+class NativeWebKeyboardEvent;-+class WebPageProxy;++class NetworkProcess;++class WebFrameProxy;++class WebProcessPool;+-+class InspectorDialogAgent : public Inspector::InspectorAgentBase, public Inspector::DialogBackendDispatcherHandler {-+ WTF_MAKE_NONCOPYABLE(InspectorDialogAgent);-+ WTF_MAKE_FAST_ALLOCATED;++class PageProxyIDMap {+public:-+ InspectorDialogAgent(Inspector::BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page);-+ ~InspectorDialogAgent() override;++ virtual WebPageProxy* findPageProxy(const String& pageProxyID) = 0;+-+ void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;-+ void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;++protected:++ virtual ~PageProxyIDMap() = default;++};+-+ void enable(Inspector::ErrorString&) override;-+ void disable(Inspector::ErrorString&) override;-+ void handleJavaScriptDialog(Inspector::ErrorString& errorString, bool accept, const String* promptText) override;++class InspectorBrowserAgent final : public Inspector::InspectorAgentBase, public Inspector::BrowserBackendDispatcherHandler {++ WTF_MAKE_NONCOPYABLE(InspectorBrowserAgent);++ WTF_MAKE_FAST_ALLOCATED;++public:++ InspectorBrowserAgent(Inspector::FrontendRouter&, Inspector::BackendDispatcher&, InspectorBrowserAgentClient*, PageProxyIDMap&);++ ~InspectorBrowserAgent() override;+-+ void javascriptDialogOpening(const String& type, const String& message, const String* defaultValue = nullptr);++ void didCreateWebPageProxy(const WebPageProxy&);++ void willDestroyWebPageProxy(const WebPageProxy&);++ void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error);+-+private:-+ void platformHandleJavaScriptDialog(bool accept, const String* promptText);-+ std::unique_ptr<Inspector::DialogFrontendDispatcher> m_frontendDispatcher;-+ Ref<Inspector::DialogBackendDispatcher> m_backendDispatcher;-+ WebPageProxy& m_page;-+};++ // InspectorAgentBase++ void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;++ void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;+-+} // namespace WebKit-diff --git a/Source/WebKit/UIProcess/InspectorTargetProxy.cpp b/Source/WebKit/UIProcess/InspectorTargetProxy.cpp-index 6928ca2fbfb6939062e3cd14bb7ba6f2fdc87f5f..8259a01bb98789c07f88cafd4f3af553e65d0cf9 100644---- a/Source/WebKit/UIProcess/InspectorTargetProxy.cpp-+++ b/Source/WebKit/UIProcess/InspectorTargetProxy.cpp-@@ -27,11 +27,10 @@- #include "InspectorTargetProxy.h"-- #include "ProvisionalPageProxy.h"--#include "WebFrameProxy.h"-+#include "WebPageInspectorController.h"- #include "WebPageInspectorTarget.h"- #include "WebPageMessages.h"- #include "WebPageProxy.h"--#include "WebProcessProxy.h"-- namespace WebKit {--@@ -39,18 +38,17 @@ using namespace Inspector;-- std::unique_ptr<InspectorTargetProxy> InspectorTargetProxy::create(WebPageProxy& page, const String& targetId, Inspector::InspectorTargetType type)- {-- return makeUnique<InspectorTargetProxy>(page, targetId, type);-+ return makeUnique<InspectorTargetProxy>(page, nullptr, targetId, type);- }---std::unique_ptr<InspectorTargetProxy> InspectorTargetProxy::create(ProvisionalPageProxy& provisionalPage, const String& targetId, Inspector::InspectorTargetType type)-+std::unique_ptr<InspectorTargetProxy> InspectorTargetProxy::create(ProvisionalPageProxy& provisionalPage, const String& targetId)- {-- auto target = InspectorTargetProxy::create(provisionalPage.page(), targetId, type);-- target->m_provisionalPage = makeWeakPtr(provisionalPage);-- return target;-+ return makeUnique<InspectorTargetProxy>(provisionalPage.page(), &provisionalPage, targetId, Inspector::InspectorTargetType::Page);- }---InspectorTargetProxy::InspectorTargetProxy(WebPageProxy& page, const String& targetId, Inspector::InspectorTargetType type)-+InspectorTargetProxy::InspectorTargetProxy(WebPageProxy& page, ProvisionalPageProxy* provisionalPage, const String& targetId, Inspector::InspectorTargetType type)- : m_page(page)-+ , m_provisionalPage(makeWeakPtr(provisionalPage))- , m_identifier(targetId)- , m_type(type)- {-@@ -83,6 +81,9 @@ void InspectorTargetProxy::disconnect()-- void InspectorTargetProxy::sendMessageToTargetBackend(const String& message)- {-+ if (m_page.inspectorController().dispatchMessageToTargetBackend(message))-+ return;++ // BrowserBackendDispatcherHandler++ void close(Ref<CloseCallback>&&) override;++ void createContext(Inspector::ErrorString&, String* browserContextID) override;++ void deleteContext(Inspector::ErrorString&, const String& browserContextID) override;++ void createPage(Inspector::ErrorString&, const String* browserContextID, String* pageProxyID) override;++ void navigate(const String& url, const String& pageProxyID, const String* frameId, const String* referrer, Ref<NavigateCallback>&&) override;++ void setIgnoreCertificateErrors(Inspector::ErrorString&, const String* browserContextID, bool ignore) override;+- if (m_provisionalPage) {- m_provisionalPage->send(Messages::WebPage::SendMessageToTargetBackend(identifier(), message));- return;-@@ -97,9 +98,35 @@ void InspectorTargetProxy::didCommitProvisionalTarget()- m_provisionalPage = nullptr;- }--+void InspectorTargetProxy::activate(String& error)-+{-+ if (m_type != Inspector::InspectorTargetType::Page)-+ return InspectorTarget::activate(error);++ void getAllCookies(const String* browserContextID, Ref<GetAllCookiesCallback>&&) override;++ void setCookies(const String* browserContextID, const JSON::Array& in_cookies, Ref<SetCookiesCallback>&&) override;++ void deleteAllCookies(const String* browserContextID, Ref<DeleteAllCookiesCallback>&&) override;+-+ platformActivate(error);-+}++ void grantPermissions(Inspector::ErrorString&, const String* browserContextID, const String& origin, const JSON::Array& permissions) override;++ void resetPermissions(Inspector::ErrorString&, const String* browserContextID) override;++ void setGeolocationOverride(Inspector::ErrorString&, const String* browserContextID, const JSON::Object* geolocation) override;+-+void InspectorTargetProxy::close(String& error, bool runBeforeUnload)-+{-+ if (m_type != Inspector::InspectorTargetType::Page)-+ return InspectorTarget::close(error, runBeforeUnload);++ static String toBrowserContextIDProtocolString(const PAL::SessionID&);++ static String toPageProxyIDProtocolString(const WebPageProxy&);+-+ if (runBeforeUnload)-+ m_page.tryClose();-+ else-+ m_page.closePage();-+}++private:++ BrowserContext lookupBrowserContext(Inspector::ErrorString&, const String* browserContextID);++ WebFrameProxy* frameForID(const String& frameID, String& error);+- bool InspectorTargetProxy::isProvisional() const- {- return !!m_provisionalPage;- }--+String InspectorTargetProxy::oldTargetID() const-+{-+ if (!m_provisionalPage)-+ return String();-+ return WebPageInspectorTarget::toTargetID(m_page.webPageID());-+}++ std::unique_ptr<Inspector::BrowserFrontendDispatcher> m_frontendDispatcher;++ Ref<Inspector::BrowserBackendDispatcher> m_backendDispatcher;++ InspectorBrowserAgentClient* m_client;++ PageProxyIDMap& m_pageProxyIDMap;++ using Permissions = HashMap<String, HashSet<String>>;++ HashMap<String, Permissions> m_permissions;++ HashMap<String, BrowserContext> m_browserContexts;++ bool m_isConnected { false };++};+- } // namespace WebKit-diff --git a/Source/WebKit/UIProcess/InspectorTargetProxy.h b/Source/WebKit/UIProcess/InspectorTargetProxy.h-index a2239cec8e18850f35f7f88a9c4ebadc62bf4023..f53bd7717be546157dfeb92b835a1df5513a716a 100644---- a/Source/WebKit/UIProcess/InspectorTargetProxy.h-+++ b/Source/WebKit/UIProcess/InspectorTargetProxy.h-@@ -37,13 +37,13 @@ class WebPageProxy;- // NOTE: This UIProcess side InspectorTarget doesn't care about the frontend channel, since- // any target -> frontend messages will be routed to the WebPageProxy with a targetId.---class InspectorTargetProxy final : public Inspector::InspectorTarget {-+class InspectorTargetProxy : public Inspector::InspectorTarget {- WTF_MAKE_FAST_ALLOCATED;- WTF_MAKE_NONCOPYABLE(InspectorTargetProxy);- public:- static std::unique_ptr<InspectorTargetProxy> create(WebPageProxy&, const String& targetId, Inspector::InspectorTargetType);-- static std::unique_ptr<InspectorTargetProxy> create(ProvisionalPageProxy&, const String& targetId, Inspector::InspectorTargetType);-- InspectorTargetProxy(WebPageProxy&, const String& targetId, Inspector::InspectorTargetType);-+ static std::unique_ptr<InspectorTargetProxy> create(ProvisionalPageProxy&, const String& targetId);-+ InspectorTargetProxy(WebPageProxy&, ProvisionalPageProxy*, const String& targetId, Inspector::InspectorTargetType);- ~InspectorTargetProxy() = default;-- Inspector::InspectorTargetType type() const final { return m_type; }-@@ -51,16 +51,21 @@ public:-- void didCommitProvisionalTarget();- bool isProvisional() const override;-+ String oldTargetID() const override;-- void connect(Inspector::FrontendChannel::ConnectionType) override;- void disconnect() override;- void sendMessageToTargetBackend(const String&) override;-+ void activate(String& error) override;-+ void close(String& error, bool runBeforeUnload) override;-- private:-+ void platformActivate(String& error) const;++} // namespace WebKit+- WebPageProxy& m_page;-+ WeakPtr<ProvisionalPageProxy> m_provisionalPage;- String m_identifier;- Inspector::InspectorTargetType m_type;-- WeakPtr<ProvisionalPageProxy> m_provisionalPage;- };-- } // namespace WebKit-diff --git a/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp++#endif // ENABLE(REMOTE_INSPECTOR)+diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgentClient.h b/Source/WebKit/UIProcess/InspectorBrowserAgentClient.hnew file mode 100644-index 0000000000000000000000000000000000000000..0b4ec2de5671723f4045e98b3e398fc11180b3b8+index 0000000000000000000000000000000000000000..21f8cc9bffd8f2d4a88764a4eafa13f367aa1e7c--- /dev/null-+++ b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp-@@ -0,0 +1,219 @@++++ b/Source/WebKit/UIProcess/InspectorBrowserAgentClient.h+@@ -0,0 +1,55 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -7933,206 +7977,134 @@ index 0000000000000000000000000000000000000000..0b4ec2de5671723f4045e98b3e398fc1+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+ */+-+#include "config.h"-+#include "RemoteInspectorPipe.h"++#pragma once++#if ENABLE(REMOTE_INSPECTOR)+-+#include "BrowserInspectorController.h"-+#include <JavaScriptCore/InspectorFrontendChannel.h>-+#include <wtf/MainThread.h>-+#include <wtf/RunLoop.h>-+#include <wtf/UniqueArray.h>-+#include <wtf/Vector.h>-+#include <wtf/WorkQueue.h>-+-+#if OS(UNIX)-+#include <stdio.h>-+#include <unistd.h>-+#endif-+-+#if PLATFORM(WIN)-+#include <io.h>-+#endif++#include <pal/SessionID.h>++#include <wtf/Forward.h>++namespace WebKit {+-+namespace {-+-+const int readFD = 3;-+const int writeFD = 4;-+-+const size_t kWritePacketSize = 1 << 16;-+-+#if PLATFORM(WIN)-+HANDLE readHandle;-+HANDLE writeHandle;-+#endif++class WebsiteDataStore;++class WebPageProxy;++class WebProcessPool;+-+size_t ReadBytes(void* buffer, size_t size, bool exact_size)-+{-+ size_t bytesRead = 0;-+ while (bytesRead < size) {-+#if PLATFORM(WIN)-+ DWORD sizeRead = 0;-+ bool hadError = !ReadFile(readHandle, static_cast<char*>(buffer) + bytesRead,-+ size - bytesRead, &sizeRead, nullptr);-+#else-+ int sizeRead = read(readFD, static_cast<char*>(buffer) + bytesRead,-+ size - bytesRead);-+ if (sizeRead < 0 && errno == EINTR)-+ continue;-+ bool hadError = sizeRead <= 0;-+#endif-+ if (hadError) {-+ return 0;-+ }-+ bytesRead += sizeRead;-+ if (!exact_size)-+ break;-+ }-+ return bytesRead;-+}++struct BrowserContext {++ RefPtr<WebsiteDataStore> dataStore;++ RefPtr<WebProcessPool> processPool;++};+-+void WriteBytes(const char* bytes, size_t size)-+{-+ size_t totalWritten = 0;-+ while (totalWritten < size) {-+ size_t length = size - totalWritten;-+ if (length > kWritePacketSize)-+ length = kWritePacketSize;-+#if PLATFORM(WIN)-+ DWORD bytesWritten = 0;-+ bool hadError = !WriteFile(writeHandle, bytes + totalWritten, static_cast<DWORD>(length), &bytesWritten, nullptr);-+#else-+ int bytesWritten = write(writeFD, bytes + totalWritten, length);-+ if (bytesWritten < 0 && errno == EINTR)-+ continue;-+ bool hadError = bytesWritten <= 0;-+#endif-+ if (hadError)-+ return;-+ totalWritten += bytesWritten;-+ }-+}++class InspectorBrowserAgentClient {++public:++ virtual ~InspectorBrowserAgentClient() = default;++ virtual RefPtr<WebKit::WebPageProxy> createPage(WTF::String& error, const BrowserContext& context) = 0;++ virtual void closeBrowser() = 0;++ virtual BrowserContext createBrowserContext(WTF::String& error) = 0;++ virtual void deleteBrowserContext(WTF::String& error, PAL::SessionID) = 0;++};+-+} // namespace++} // namespace WebKit+-+class RemoteInspectorPipe::RemoteFrontendChannel : public Inspector::FrontendChannel {-+ WTF_MAKE_FAST_ALLOCATED;++#endif // ENABLE(REMOTE_INSPECTOR)+diff --git a/Source/WebKit/UIProcess/InspectorDialogAgent.cpp b/Source/WebKit/UIProcess/InspectorDialogAgent.cpp+new file mode 100644+index 0000000000000000000000000000000000000000..ca5965f9d682c0821a40f0d1d43e5cbeda1353a5+--- /dev/null++++ b/Source/WebKit/UIProcess/InspectorDialogAgent.cpp+@@ -0,0 +1,86 @@++/*++ * Copyright (C) 2019 Microsoft Corporation.++ *++ * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT++ * OWNER OR 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.++ */+-+public:-+ RemoteFrontendChannel()-+ : m_senderQueue(WorkQueue::create("Inspector pipe writer"))-+ {-+ }++#include "config.h"++#include "InspectorDialogAgent.h"+-+ ~RemoteFrontendChannel() override = default;++#include "APINavigation.h"++#include "APIUIClient.h"++#include "WebPageProxy.h"++#include <JavaScriptCore/InspectorFrontendRouter.h>+-+ ConnectionType connectionType() const override-+ {-+ return ConnectionType::Remote;-+ }+-+ void sendMessageToFrontend(const String& message) override-+ {-+ m_senderQueue->dispatch([message = message.isolatedCopy()]() {-+ WriteBytes(message.ascii().data(), message.length());-+ WriteBytes("\0", 1);-+ });-+ }++namespace WebKit {+-+private:-+ Ref<WorkQueue> m_senderQueue;-+};++using namespace Inspector;+-+RemoteInspectorPipe::RemoteInspectorPipe(BrowserInspectorController& browserInspectorController)-+ : m_remoteFrontendChannel(makeUnique<RemoteFrontendChannel>())-+ , m_browserInspectorController(browserInspectorController)++InspectorDialogAgent::InspectorDialogAgent(Inspector::BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page)++ : InspectorAgentBase("Dialog"_s)++ , m_frontendDispatcher(makeUnique<DialogFrontendDispatcher>(frontendRouter))++ , m_backendDispatcher(DialogBackendDispatcher::create(backendDispatcher, this))++ , m_page(page)+{-+ start();+}+-+RemoteInspectorPipe::~RemoteInspectorPipe()++InspectorDialogAgent::~InspectorDialogAgent()+{-+ stop();++ Inspector::ErrorString err;++ disable(err);+}+-+bool RemoteInspectorPipe::start()++void InspectorDialogAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)+{-+ if (m_receiverThread)-+ return true;-+-+#if PLATFORM(WIN)-+ readHandle = reinterpret_cast<HANDLE>(_get_osfhandle(readFD));-+ writeHandle = reinterpret_cast<HANDLE>(_get_osfhandle(writeFD));-+#endif++}+-+ m_browserInspectorController.connectFrontend(*m_remoteFrontendChannel);-+ m_terminated = false;-+ m_receiverThread = Thread::create("Inspector pipe reader", [this] {-+ workerRun();-+ });-+ return true;++void InspectorDialogAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)++{+}+-+void RemoteInspectorPipe::stop()++void InspectorDialogAgent::enable(Inspector::ErrorString& errorString)+{-+ if (!m_receiverThread)++ if (m_page.inspectorDialogAgent()) {++ errorString = "Dialog domain is already enabled."_s;+ return;++ }++ m_page.setInspectorDialogAgent(this);++}+-+ m_browserInspectorController.disconnectFrontend();-+-+ m_terminated = true;-+ m_receiverThread->waitForCompletion();-+ m_receiverThread = nullptr;++void InspectorDialogAgent::disable(Inspector::ErrorString&)++{++ if (m_page.inspectorDialogAgent() != this)++ return;++ m_page.setInspectorDialogAgent(nullptr);+}+-+void RemoteInspectorPipe::workerRun()++void InspectorDialogAgent::handleJavaScriptDialog(Inspector::ErrorString& errorString, bool accept, const String* value)+{-+ const size_t bufSize = 256 * 1024;-+ auto buffer = makeUniqueArray<char>(bufSize);-+ Vector<char> line;-+ while (!m_terminated) {-+ size_t size = ReadBytes(buffer.get(), bufSize, false);-+ if (!size)-+ break;-+ size_t start = 0;-+ size_t end = line.size();-+ line.append(buffer.get(), size);-+ while (true) {-+ for (; end < line.size(); ++end) {-+ if (line[end] == '\0')-+ break;-+ }-+ if (end == line.size())-+ break;++ m_page.uiClient().handleJavaScriptDialog(m_page, accept, value ? *value : String());++}+-+ if (end > start) {-+ String message = String::fromUTF8(line.data() + start, end - start);-+ RunLoop::main().dispatch([this, message] {-+ if (!m_terminated)-+ m_browserInspectorController.dispatchMessageFromFrontend(message);-+ });-+ }-+ ++end;-+ start = end;-+ }-+ if (start != 0 && start < line.size())-+ memmove(line.data(), line.data() + start, line.size() - start);-+ line.shrink(line.size() - start);-+ }++void InspectorDialogAgent::javascriptDialogOpening(const String& type, const String& message, const String* defaultValue) {++ m_frontendDispatcher->javascriptDialogOpening(type, message, defaultValue);+}++} // namespace WebKit-+-+#endif // ENABLE(REMOTE_INSPECTOR)-diff --git a/Source/WebKit/UIProcess/RemoteInspectorPipe.h b/Source/WebKit/UIProcess/RemoteInspectorPipe.h+diff --git a/Source/WebKit/UIProcess/InspectorDialogAgent.h b/Source/WebKit/UIProcess/InspectorDialogAgent.hnew file mode 100644-index 0000000000000000000000000000000000000000..b1307da8b9ee02d63ef98d276473d65a1d8c3556+index 0000000000000000000000000000000000000000..f356c613945fd263889bc74166bef2b279ab4ca1--- /dev/null-+++ b/Source/WebKit/UIProcess/RemoteInspectorPipe.h-@@ -0,0 +1,65 @@++++ b/Source/WebKit/UIProcess/InspectorDialogAgent.h+@@ -0,0 +1,70 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -8160,460 +8132,371 @@ index 0000000000000000000000000000000000000000..b1307da8b9ee02d63ef98d276473d65a++#pragma once+-+#if ENABLE(REMOTE_INSPECTOR)++#include "WebEvent.h"+-+#include <wtf/Ref.h>-+#include <wtf/RefPtr.h>-+#include <wtf/Threading.h>++#include <JavaScriptCore/InspectorAgentBase.h>++#include <JavaScriptCore/InspectorBackendDispatchers.h>++#include <JavaScriptCore/InspectorFrontendDispatchers.h>++++#include <wtf/Forward.h>++#include <wtf/Noncopyable.h>++namespace Inspector {+class FrontendChannel;++class FrontendRouter;+}++namespace WebKit {+-+class BrowserInspectorController;++class NativeWebKeyboardEvent;++class WebPageProxy;+-+class RemoteInspectorPipe {-+ WTF_MAKE_NONCOPYABLE(RemoteInspectorPipe);++class InspectorDialogAgent : public Inspector::InspectorAgentBase, public Inspector::DialogBackendDispatcherHandler {++ WTF_MAKE_NONCOPYABLE(InspectorDialogAgent);+ WTF_MAKE_FAST_ALLOCATED;+public:-+ explicit RemoteInspectorPipe(BrowserInspectorController&);-+ ~RemoteInspectorPipe();++ InspectorDialogAgent(Inspector::BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page);++ ~InspectorDialogAgent() override;+-+private:-+ class RemoteFrontendChannel;++ void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;++ void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;+-+ bool start();-+ void stop();++ void enable(Inspector::ErrorString&) override;++ void disable(Inspector::ErrorString&) override;++ void handleJavaScriptDialog(Inspector::ErrorString& errorString, bool accept, const String* promptText) override;+-+ void workerRun();++ void javascriptDialogOpening(const String& type, const String& message, const String* defaultValue = nullptr);+-+ RefPtr<Thread> m_receiverThread;-+ std::atomic<bool> m_terminated { false };-+ std::unique_ptr<Inspector::FrontendChannel> m_remoteFrontendChannel;-+ BrowserInspectorController& m_browserInspectorController;++private:++ void platformHandleJavaScriptDialog(bool accept, const String* promptText);++ std::unique_ptr<Inspector::DialogFrontendDispatcher> m_frontendDispatcher;++ Ref<Inspector::DialogBackendDispatcher> m_backendDispatcher;++ WebPageProxy& m_page;+};++} // namespace WebKit+diff --git a/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp+new file mode 100644+index 0000000000000000000000000000000000000000..0b4ec2de5671723f4045e98b3e398fc11180b3b8+--- /dev/null++++ b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp+@@ -0,0 +1,219 @@++/*++ * Copyright (C) 2019 Microsoft Corporation.++ *++ * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT++ * OWNER OR 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.++ */+-+#endif // ENABLE(REMOTE_INSPECTOR)-diff --git a/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp b/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp-index 3db63ef6bd5ea32b296ac046aa43a0d1497c5e74..4f04cf936b5521fd9528942fd5027b611421884d 100644---- a/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp-+++ b/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp-@@ -35,6 +35,7 @@- #include "NfcService.h"- #include "WebPageProxy.h"- #include "WebPreferencesKeys.h"-+#include "WebProcessProxy.h"- #include <WebCore/AuthenticatorTransport.h>- #include <WebCore/PublicKeyCredentialCreationOptions.h>- #include <WebCore/WebAuthenticationConstants.h>-diff --git a/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp-index 846a5aa27dfab3d274cffa4873861f2587d17fd8..cf0dc99f5601636c48abff09cd47ace49d127a08 100644---- a/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp-+++ b/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp-@@ -118,7 +118,8 @@ void WebGeolocationManagerProxy::startUpdating(IPC::Connection& connection)- if (!wasUpdating) {- m_provider->setEnableHighAccuracy(*this, isHighAccuracyEnabled());- m_provider->startUpdating(*this);-- } else if (m_lastPosition)-+ }-+ if (m_lastPosition)- connection.send(Messages::WebGeolocationManager::DidChangePosition(m_lastPosition.value()), 0);- }--diff --git a/Source/WebKit/UIProcess/WebPageInspectorController.cpp b/Source/WebKit/UIProcess/WebPageInspectorController.cpp-index 1ee28bf716374371433215148aa20a51927a8a33..444894102b535a957cadb41fab23f37c217f5b1c 100644---- a/Source/WebKit/UIProcess/WebPageInspectorController.cpp-+++ b/Source/WebKit/UIProcess/WebPageInspectorController.cpp-@@ -26,10 +26,16 @@- #include "config.h"- #include "WebPageInspectorController.h"--+#include "APINavigation.h"-+#include "InspectorDialogAgent.h"- #include "ProvisionalPageProxy.h"- #include "WebFrameProxy.h"-+#include "WebPageInspectorEmulationAgent.h"-+#include "WebPageInspectorInputAgent.h"- #include "WebPageInspectorTarget.h"- #include "WebPageProxy.h"-+#include "WebPreferences.h"-+#include <WebCore/ResourceError.h>- #include <JavaScriptCore/InspectorAgentBase.h>- #include <JavaScriptCore/InspectorBackendDispatcher.h>- #include <JavaScriptCore/InspectorBackendDispatchers.h>-@@ -46,29 +52,90 @@ static String getTargetID(const ProvisionalPageProxy& provisionalPage)- return WebPageInspectorTarget::toTargetID(provisionalPage.webPageID());- }--+WebPageInspectorControllerObserver* WebPageInspectorController::s_observer = nullptr;-+-+void WebPageInspectorController::setObserver(WebPageInspectorControllerObserver* observer)-+{-+ s_observer = observer;-+}-+- WebPageInspectorController::WebPageInspectorController(WebPageProxy& page)- : m_page(page)- , m_frontendRouter(FrontendRouter::create())- , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))-+{-+}-+-+void WebPageInspectorController::init()- {- auto targetAgent = makeUnique<InspectorTargetAgent>(m_frontendRouter.get(), m_backendDispatcher.get());-- m_targetAgent = targetAgent.get();-- m_agents.append(WTFMove(targetAgent));--}-+ m_agents.append(makeUnique<WebPageInspectorEmulationAgent>(m_backendDispatcher.get(), m_page));-+ auto inputAgent = makeUnique<WebPageInspectorInputAgent>(m_backendDispatcher.get(), m_page);-+ m_inputAgent = inputAgent.get();-+ m_agents.append(WTFMove(inputAgent));-+ m_agents.append(makeUnique<InspectorDialogAgent>(m_backendDispatcher.get(), m_frontendRouter.get(), m_page));---void WebPageInspectorController::init()--{-+ if (s_observer)-+ s_observer->didCreateInspectorController(m_page);-+-+ // window.open will create page with already running process.-+ if (!m_page.hasRunningProcess())-+ return;- String pageTargetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());- createInspectorTarget(pageTargetId, Inspector::InspectorTargetType::Page);- }--+void WebPageInspectorController::didFinishAttachingToWebProcess()-+{-+ String pageTargetID = WebPageInspectorTarget::toTargetID(m_page.webPageID());-+ // Create target only after attaching to a Web Process first time. Before that-+ // we cannot event establish frontend connection.-+ if (m_targets.contains(pageTargetID))-+ return;-+ createInspectorTarget(pageTargetID, Inspector::InspectorTargetType::Page);-+}++#include "config.h"++#include "RemoteInspectorPipe.h"+- void WebPageInspectorController::pageClosed()- {-+ String pageTargetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());-+ destroyInspectorTarget(pageTargetId);++#if ENABLE(REMOTE_INSPECTOR)+- disconnectAllFrontends();-- m_agents.discardValues();++#include "BrowserInspectorController.h"++#include <JavaScriptCore/InspectorFrontendChannel.h>++#include <wtf/MainThread.h>++#include <wtf/RunLoop.h>++#include <wtf/UniqueArray.h>++#include <wtf/Vector.h>++#include <wtf/WorkQueue.h>+-+ if (s_observer)-+ s_observer->willDestroyInspectorController(m_page);-+}++#if OS(UNIX)++#include <stdio.h>++#include <unistd.h>++#endif+-+bool WebPageInspectorController::pageCrashed(ProcessTerminationReason reason)-+{-+ if (reason != ProcessTerminationReason::Crash)-+ return false;-+ String targetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());-+ auto it = m_targets.find(targetId);-+ if (it == m_targets.end())-+ return false;-+ m_targetAgent->targetCrashed(*it->value);-+ m_targets.remove(it);++#if PLATFORM(WIN)++#include <io.h>++#endif+-+ return m_targetAgent->isConnected();-+}++namespace WebKit {+-+void WebPageInspectorController::didProcessAllPendingKeyboardEvents()-+{-+ if (m_frontendRouter->hasFrontends())-+ m_inputAgent->didProcessAllPendingKeyboardEvents();-+}++namespace {+-+void WebPageInspectorController::didProcessAllPendingMouseEvents()-+{-+ if (m_frontendRouter->hasFrontends())-+ m_inputAgent->didProcessAllPendingMouseEvents();- }-- bool WebPageInspectorController::hasLocalFrontend() const-@@ -80,6 +147,17 @@ void WebPageInspectorController::connectFrontend(Inspector::FrontendChannel& fro- {- bool connectingFirstFrontend = !m_frontendRouter->hasFrontends();--+ // HACK: forcefully disconnect remote connections to show local inspector starting with initial-+ // agents' state.-+ if (frontendChannel.connectionType() == Inspector::FrontendChannel::ConnectionType::Local &&-+ !connectingFirstFrontend && !m_frontendRouter->hasLocalFrontend()) {-+ disconnectAllFrontends();-+ connectingFirstFrontend = true;-+ }++const int readFD = 3;++const int writeFD = 4;+-+ if (connectingFirstFrontend)-+ adjustPageSettings();++const size_t kWritePacketSize = 1 << 16;+- m_frontendRouter->connectFrontend(frontendChannel);-- if (connectingFirstFrontend)-@@ -98,8 +176,10 @@ void WebPageInspectorController::disconnectFrontend(FrontendChannel& frontendCha- m_frontendRouter->disconnectFrontend(frontendChannel);-- bool disconnectingLastFrontend = !m_frontendRouter->hasFrontends();-- if (disconnectingLastFrontend)-+ if (disconnectingLastFrontend) {- m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectorDestroyed);-+ m_pendingNavigations.clear();-+ }-- m_page.didChangeInspectorFrontendCount(m_frontendRouter->frontendCount());--@@ -122,6 +202,8 @@ void WebPageInspectorController::disconnectAllFrontends()- // Disconnect any remaining remote frontends.- m_frontendRouter->disconnectAllFrontends();--+ m_pendingNavigations.clear();++#if PLATFORM(WIN)++HANDLE readHandle;++HANDLE writeHandle;++#endif+- m_page.didChangeInspectorFrontendCount(m_frontendRouter->frontendCount());-- #if ENABLE(REMOTE_INSPECTOR)-@@ -134,6 +216,11 @@ void WebPageInspectorController::dispatchMessageFromFrontend(const String& messa- m_backendDispatcher->dispatch(message);- }--+bool WebPageInspectorController::dispatchMessageToTargetBackend(const String& message)++size_t ReadBytes(void* buffer, size_t size, bool exact_size)+{-+ return m_backendDispatcher->dispatch(message, BackendDispatcher::Mode::ContinueIfDomainIsMissing) == BackendDispatcher::DispatchResult::Finished;++ size_t bytesRead = 0;++ while (bytesRead < size) {++#if PLATFORM(WIN)++ DWORD sizeRead = 0;++ bool hadError = !ReadFile(readHandle, static_cast<char*>(buffer) + bytesRead,++ size - bytesRead, &sizeRead, nullptr);++#else++ int sizeRead = read(readFD, static_cast<char*>(buffer) + bytesRead,++ size - bytesRead);++ if (sizeRead < 0 && errno == EINTR)++ continue;++ bool hadError = sizeRead <= 0;++#endif++ if (hadError) {++ return 0;++ }++ bytesRead += sizeRead;++ if (!exact_size)++ break;++ }++ return bytesRead;+}+- #if ENABLE(REMOTE_INSPECTOR)- void WebPageInspectorController::setIndicating(bool indicating)- {-@@ -148,6 +235,55 @@ void WebPageInspectorController::setIndicating(bool indicating)- }- #endif--+void WebPageInspectorController::navigate(WebCore::ResourceRequest&& request, WebFrameProxy* frame, NavigationHandler&& completionHandler)++void WriteBytes(const char* bytes, size_t size)+{-+ auto navigation = m_page.loadRequestForInspector(WTFMove(request), frame);-+ if (!navigation) {-+ completionHandler("Failed to navigate"_s, 0);-+ return;++ size_t totalWritten = 0;++ while (totalWritten < size) {++ size_t length = size - totalWritten;++ if (length > kWritePacketSize)++ length = kWritePacketSize;++#if PLATFORM(WIN)++ DWORD bytesWritten = 0;++ bool hadError = !WriteFile(writeHandle, bytes + totalWritten, static_cast<DWORD>(length), &bytesWritten, nullptr);++#else++ int bytesWritten = write(writeFD, bytes + totalWritten, length);++ if (bytesWritten < 0 && errno == EINTR)++ continue;++ bool hadError = bytesWritten <= 0;++#endif++ if (hadError)++ return;++ totalWritten += bytesWritten;+ }-+-+ m_pendingNavigations.set(navigation->navigationID(), WTFMove(completionHandler));+}+-+void WebPageInspectorController::didReceivePolicyDecision(WebCore::PolicyAction action, uint64_t navigationID)-+{-+ if (!m_frontendRouter->hasFrontends())-+ return;++} // namespace+-+ if (!navigationID)-+ return;++class RemoteInspectorPipe::RemoteFrontendChannel : public Inspector::FrontendChannel {++ WTF_MAKE_FAST_ALLOCATED;+-+ auto completionHandler = m_pendingNavigations.take(navigationID);-+ if (!completionHandler)-+ return;++public:++ RemoteFrontendChannel()++ : m_senderQueue(WorkQueue::create("Inspector pipe writer"))++ {++ }+-+ if (action == WebCore::PolicyAction::Ignore)-+ completionHandler("Navigation cancelled"_s, 0);-+ else-+ completionHandler(String(), navigationID);-+}++ ~RemoteFrontendChannel() override = default;+-+void WebPageInspectorController::didDestroyNavigation(uint64_t navigationID)-+{-+ if (!m_frontendRouter->hasFrontends())-+ return;++ ConnectionType connectionType() const override++ {++ return ConnectionType::Remote;++ }+-+ auto completionHandler = m_pendingNavigations.take(navigationID);-+ if (!completionHandler)-+ return;++ void sendMessageToFrontend(const String& message) override++ {++ m_senderQueue->dispatch([message = message.isolatedCopy()]() {++ WriteBytes(message.ascii().data(), message.length());++ WriteBytes("\0", 1);++ });++ }+-+ // Inspector initiated navigation is destroyed before policy check only when it-+ // becomes a fragment navigation (which always reuses current navigation).-+ completionHandler(String(), 0);++private:++ Ref<WorkQueue> m_senderQueue;++};++++RemoteInspectorPipe::RemoteInspectorPipe(BrowserInspectorController& browserInspectorController)++ : m_remoteFrontendChannel(makeUnique<RemoteFrontendChannel>())++ , m_browserInspectorController(browserInspectorController)++{++ start();+}+-+void WebPageInspectorController::didFailProvisionalLoadForFrame(uint64_t navigationID, const WebCore::ResourceError& error)++RemoteInspectorPipe::~RemoteInspectorPipe()+{-+ if (s_observer)-+ s_observer->didFailProvisionalLoad(m_page, navigationID, error.localizedDescription());++ stop();+}+- void WebPageInspectorController::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type)- {- addTarget(InspectorTargetProxy::create(m_page, targetId, type));-@@ -167,6 +303,33 @@ void WebPageInspectorController::sendMessageToInspectorFrontend(const String& ta- m_targetAgent->sendMessageFromTargetToFrontend(targetId, message);- }--+void WebPageInspectorController::setPauseOnStart(bool shouldPause)++bool RemoteInspectorPipe::start()+{-+ ASSERT(m_frontendRouter->hasFrontends());-+ String errorString;-+ m_targetAgent->setPauseOnStart(errorString, shouldPause);++ if (m_receiverThread)++ return true;++++#if PLATFORM(WIN)++ readHandle = reinterpret_cast<HANDLE>(_get_osfhandle(readFD));++ writeHandle = reinterpret_cast<HANDLE>(_get_osfhandle(writeFD));++#endif++++ m_browserInspectorController.connectFrontend(*m_remoteFrontendChannel);++ m_terminated = false;++ m_receiverThread = Thread::create("Inspector pipe reader", [this] {++ workerRun();++ });++ return true;+}+-+bool WebPageInspectorController::shouldPauseLoading() const++void RemoteInspectorPipe::stop()+{-+ if (!m_frontendRouter->hasFrontends())-+ return false;++ if (!m_receiverThread)++ return;+-+ if (!m_page.isPageOpenedByDOMShowingInitialEmptyDocument())-+ return false;++ m_browserInspectorController.disconnectFrontend();+-+ auto* target = m_targets.get(WebPageInspectorTarget::toTargetID(m_page.webPageID()));-+ ASSERT(target);-+ return target->isPaused();++ m_terminated = true;++ m_receiverThread->waitForCompletion();++ m_receiverThread = nullptr;+}+-+void WebPageInspectorController::setContinueLoadingCallback(WTF::Function<void()>&& callback)++void RemoteInspectorPipe::workerRun()+{-+ auto* target = m_targets.get(WebPageInspectorTarget::toTargetID(m_page.webPageID()));-+ ASSERT(target);-+ target->setResumeCallback(WTFMove(callback));++ const size_t bufSize = 256 * 1024;++ auto buffer = makeUniqueArray<char>(bufSize);++ Vector<char> line;++ while (!m_terminated) {++ size_t size = ReadBytes(buffer.get(), bufSize, false);++ if (!size)++ break;++ size_t start = 0;++ size_t end = line.size();++ line.append(buffer.get(), size);++ while (true) {++ for (; end < line.size(); ++end) {++ if (line[end] == '\0')++ break;++ }++ if (end == line.size())++ break;++++ if (end > start) {++ String message = String::fromUTF8(line.data() + start, end - start);++ RunLoop::main().dispatch([this, message] {++ if (!m_terminated)++ m_browserInspectorController.dispatchMessageFromFrontend(message);++ });++ }++ ++end;++ start = end;++ }++ if (start != 0 && start < line.size())++ memmove(line.data(), line.data() + start, line.size() - start);++ line.shrink(line.size() - start);++ }+}+- bool WebPageInspectorController::shouldPauseLoading(const ProvisionalPageProxy& provisionalPage) const- {- if (!m_frontendRouter->hasFrontends())-@@ -186,7 +349,7 @@ void WebPageInspectorController::setContinueLoadingCallback(const ProvisionalPag-- void WebPageInspectorController::didCreateProvisionalPage(ProvisionalPageProxy& provisionalPage)- {-- addTarget(InspectorTargetProxy::create(provisionalPage, getTargetID(provisionalPage), Inspector::InspectorTargetType::Page));-+ addTarget(InspectorTargetProxy::create(provisionalPage, getTargetID(provisionalPage)));- }-- void WebPageInspectorController::willDestroyProvisionalPage(const ProvisionalPageProxy& provisionalPage)-@@ -218,4 +381,16 @@ void WebPageInspectorController::addTarget(std::unique_ptr<InspectorTargetProxy>- m_targets.set(target->identifier(), WTFMove(target));- }--+void WebPageInspectorController::adjustPageSettings()-+{-+ // Set this to true as otherwise updating any preferences will override its-+ // value in the Web Process to false (and InspectorController sets it locally-+ // to true when frontend is connected).-+ m_page.preferences().setDeveloperExtrasEnabled(true);++} // namespace WebKit+-+ // Navigation to cached pages doesn't fire some of the events (e.g. execution context created)-+ // that inspector depends on. So we disable the cache when front-end connects.-+ m_page.preferences().setUsesBackForwardCache(false);-+}++#endif // ENABLE(REMOTE_INSPECTOR)+diff --git a/Source/WebKit/UIProcess/RemoteInspectorPipe.h b/Source/WebKit/UIProcess/RemoteInspectorPipe.h+new file mode 100644+index 0000000000000000000000000000000000000000..b1307da8b9ee02d63ef98d276473d65a1d8c3556+--- /dev/null++++ b/Source/WebKit/UIProcess/RemoteInspectorPipe.h+@@ -0,0 +1,65 @@++/*++ * Copyright (C) 2019 Microsoft Corporation.++ *++ * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT++ * OWNER OR 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.++ */+- } // namespace WebKit-diff --git a/Source/WebKit/UIProcess/WebPageInspectorController.h b/Source/WebKit/UIProcess/WebPageInspectorController.h-index 78caedf0c0ce83675569502d150fcc44e5f9868c..46b9901263286eab6de0bc4f899349d56b1efb33 100644---- a/Source/WebKit/UIProcess/WebPageInspectorController.h-+++ b/Source/WebKit/UIProcess/WebPageInspectorController.h-@@ -26,6 +26,7 @@- #pragma once-- #include "InspectorTargetProxy.h"-+#include "ProcessTerminationReason.h"- #include <JavaScriptCore/InspectorAgentRegistry.h>- #include <JavaScriptCore/InspectorTargetAgent.h>- #include <WebCore/PageIdentifier.h>-@@ -37,10 +38,30 @@ namespace Inspector {- class BackendDispatcher;- class FrontendChannel;- class FrontendRouter;-+class InspectorTarget;-+}++#pragma once+-+namespace WebCore {-+class ResourceError;-+class ResourceRequest;-+enum class PolicyAction : uint8_t;- }-- namespace WebKit {--+class WebFrameProxy;-+class WebPageInspectorInputAgent;++#if ENABLE(REMOTE_INSPECTOR)+-+class WebPageInspectorControllerObserver {-+public:-+ virtual void didCreateInspectorController(WebPageProxy&) = 0;-+ virtual void willDestroyInspectorController(WebPageProxy&) = 0;-+ virtual void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error) = 0;++#include <wtf/Ref.h>++#include <wtf/RefPtr.h>++#include <wtf/Threading.h>+-+protected:-+ virtual ~WebPageInspectorControllerObserver() = default;-+};++namespace Inspector {++class FrontendChannel;++}+- class WebPageInspectorController {- WTF_MAKE_NONCOPYABLE(WebPageInspectorController);- WTF_MAKE_FAST_ALLOCATED;-@@ -48,7 +69,15 @@ public:- WebPageInspectorController(WebPageProxy&);-- void init();-+ void didFinishAttachingToWebProcess();++namespace WebKit {+-+ static void setObserver(WebPageInspectorControllerObserver*);++class BrowserInspectorController;+- void pageClosed();-+ bool pageCrashed(ProcessTerminationReason);++class RemoteInspectorPipe {++ WTF_MAKE_NONCOPYABLE(RemoteInspectorPipe);++ WTF_MAKE_FAST_ALLOCATED;++public:++ explicit RemoteInspectorPipe(BrowserInspectorController&);++ ~RemoteInspectorPipe();+-+ void didProcessAllPendingKeyboardEvents();-+ void didProcessAllPendingMouseEvents();-- bool hasLocalFrontend() const;--@@ -57,15 +86,28 @@ public:- void disconnectAllFrontends();-- void dispatchMessageFromFrontend(const String& message);-+ bool dispatchMessageToTargetBackend(const String&);-- #if ENABLE(REMOTE_INSPECTOR)- void setIndicating(bool);- #endif--+ using NavigationHandler = Function<void(const String&, uint64_t)>;-+ void navigate(WebCore::ResourceRequest&&, WebFrameProxy*, NavigationHandler&&);-+ void didReceivePolicyDecision(WebCore::PolicyAction action, uint64_t navigationID);-+ void didDestroyNavigation(uint64_t navigationID);++private:++ class RemoteFrontendChannel;+-+ void didFailProvisionalLoadForFrame(uint64_t navigationID, const WebCore::ResourceError& error);++ bool start();++ void stop();+- void createInspectorTarget(const String& targetId, Inspector::InspectorTargetType);- void destroyInspectorTarget(const String& targetId);- void sendMessageToInspectorFrontend(const String& targetId, const String& message);--+ void setPauseOnStart(bool);++ void workerRun();+-+ bool shouldPauseLoading() const;-+ void setContinueLoadingCallback(WTF::Function<void()>&&);++ RefPtr<Thread> m_receiverThread;++ std::atomic<bool> m_terminated { false };++ std::unique_ptr<Inspector::FrontendChannel> m_remoteFrontendChannel;++ BrowserInspectorController& m_browserInspectorController;++};+- bool shouldPauseLoading(const ProvisionalPageProxy&) const;- void setContinueLoadingCallback(const ProvisionalPageProxy&, WTF::Function<void()>&&);--@@ -75,13 +117,18 @@ public:-- private:- void addTarget(std::unique_ptr<InspectorTargetProxy>&&);-+ void adjustPageSettings();-- WebPageProxy& m_page;- Ref<Inspector::FrontendRouter> m_frontendRouter;- Ref<Inspector::BackendDispatcher> m_backendDispatcher;- Inspector::AgentRegistry m_agents;-- Inspector::InspectorTargetAgent* m_targetAgent;-+ Inspector::InspectorTargetAgent* m_targetAgent { nullptr };-+ WebPageInspectorInputAgent* m_inputAgent { nullptr };- HashMap<String, std::unique_ptr<InspectorTargetProxy>> m_targets;-+ HashMap<uint64_t, NavigationHandler> m_pendingNavigations;++} // namespace WebKit+-+ static WebPageInspectorControllerObserver* s_observer;- };++#endif // ENABLE(REMOTE_INSPECTOR)+diff --git a/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp b/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp+index 3db63ef6bd5ea32b296ac046aa43a0d1497c5e74..4f04cf936b5521fd9528942fd5027b611421884d 100644+--- a/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp++++ b/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp+@@ -35,6 +35,7 @@+ #include "NfcService.h"+ #include "WebPageProxy.h"+ #include "WebPreferencesKeys.h"++#include "WebProcessProxy.h"+ #include <WebCore/AuthenticatorTransport.h>+ #include <WebCore/PublicKeyCredentialCreationOptions.h>+ #include <WebCore/WebAuthenticationConstants.h>+diff --git a/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp+index 846a5aa27dfab3d274cffa4873861f2587d17fd8..cf0dc99f5601636c48abff09cd47ace49d127a08 100644+--- a/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp++++ b/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp+@@ -118,7 +118,8 @@ void WebGeolocationManagerProxy::startUpdating(IPC::Connection& connection)+ if (!wasUpdating) {+ m_provider->setEnableHighAccuracy(*this, isHighAccuracyEnabled());+ m_provider->startUpdating(*this);+- } else if (m_lastPosition)++ }++ if (m_lastPosition)+ connection.send(Messages::WebGeolocationManager::DidChangePosition(m_lastPosition.value()), 0);+ }- } // namespace WebKitdiff --git a/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cpp b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cppnew file mode 100644index 0000000000000000000000000000000000000000..78815bc17978a23ca811ff99039b4fe86e6fb4a0@@ -9128,10 +9011,10 @@ index 0000000000000000000000000000000000000000..76290475097e756e3d932d22be4d8c79++} // namespace WebKitdiff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp-index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390a0f7c786 100644+index 985bdc9a64e10275ae4b5f05f70049880482edc2..15ad171facbd1d9efd3fe33a7383410ef01d97eb 100644--- a/Source/WebKit/UIProcess/WebPageProxy.cpp+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp-@@ -903,6 +903,7 @@ void WebPageProxy::finishAttachingToWebProcess(ProcessLaunchReason reason)+@@ -904,6 +904,7 @@ void WebPageProxy::finishAttachingToWebProcess(ProcessLaunchReason reason)m_pageLoadState.didSwapWebProcesses();if (reason != ProcessLaunchReason::InitialProcess)m_drawingArea->waitForBackingStoreUpdateOnNextPaint();@@ -9139,7 +9022,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390}void WebPageProxy::didAttachToRunningProcess()-@@ -1238,6 +1239,21 @@ WebProcessProxy& WebPageProxy::ensureRunningProcess()+@@ -1239,6 +1240,21 @@ WebProcessProxy& WebPageProxy::ensureRunningProcess()return m_process;}@@ -9161,7 +9044,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390RefPtr<API::Navigation> WebPageProxy::loadRequest(ResourceRequest&& request, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, API::Object* userData){if (m_isClosed)-@@ -1674,6 +1690,19 @@ void WebPageProxy::setControlledByAutomation(bool controlled)+@@ -1675,6 +1691,19 @@ void WebPageProxy::setControlledByAutomation(bool controlled)m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::SetSessionIsControlledByAutomation(m_websiteDataStore->sessionID(), m_controlledByAutomation));}@@ -9181,7 +9064,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390void WebPageProxy::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type){m_inspectorController->createInspectorTarget(targetId, type);-@@ -2740,7 +2769,7 @@ static TrackingType mergeTrackingTypes(TrackingType a, TrackingType b)+@@ -2764,7 +2793,7 @@ static TrackingType mergeTrackingTypes(TrackingType a, TrackingType b)void WebPageProxy::updateTouchEventTracking(const WebTouchEvent& touchStartEvent){@@ -9190,7 +9073,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390const EventNames& names = eventNames();for (auto& touchPoint : touchStartEvent.touchPoints()) {IntPoint location = touchPoint.location();-@@ -2773,7 +2802,7 @@ void WebPageProxy::updateTouchEventTracking(const WebTouchEvent& touchStartEvent+@@ -2797,7 +2826,7 @@ void WebPageProxy::updateTouchEventTracking(const WebTouchEvent& touchStartEventm_touchAndPointerEventTracking.touchStartTracking = TrackingType::Synchronous;m_touchAndPointerEventTracking.touchMoveTracking = TrackingType::Synchronous;m_touchAndPointerEventTracking.touchEndTracking = TrackingType::Synchronous;@@ -9199,7 +9082,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390}TrackingType WebPageProxy::touchEventTrackingType(const WebTouchEvent& touchStartEvent) const-@@ -3106,6 +3135,7 @@ void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, A+@@ -3130,6 +3159,7 @@ void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, Avoid WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, Optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess){@@ -9207,7 +9090,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390if (!hasRunningProcess()) {sender->send(PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt);return;-@@ -4199,6 +4229,7 @@ void WebPageProxy::didDestroyNavigation(uint64_t navigationID)+@@ -4223,6 +4253,7 @@ void WebPageProxy::didDestroyNavigation(uint64_t navigationID)// FIXME: Message check the navigationID.m_navigationState->didDestroyNavigation(navigationID);@@ -9215,7 +9098,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390}void WebPageProxy::didStartProvisionalLoadForFrame(FrameIdentifier frameID, uint64_t navigationID, URL&& url, URL&& unreachableURL, const UserData& userData)-@@ -4420,6 +4451,8 @@ void WebPageProxy::didFailProvisionalLoadForFrameShared(Ref<WebProcessProxy>&& p+@@ -4444,6 +4475,8 @@ void WebPageProxy::didFailProvisionalLoadForFrameShared(Ref<WebProcessProxy>&& pm_failingProvisionalLoadURL = { };@@ -9224,7 +9107,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390// If the provisional page's load fails then we destroy the provisional page.if (m_provisionalPage && m_provisionalPage->mainFrame() == frame && willContinueLoading == WillContinueLoading::No)m_provisionalPage = nullptr;-@@ -4857,8 +4890,16 @@ void WebPageProxy::decidePolicyForNavigationActionAsync(FrameIdentifier frameID,+@@ -4881,8 +4914,16 @@ void WebPageProxy::decidePolicyForNavigationActionAsync(FrameIdentifier frameID,NavigationActionData&& navigationActionData, FrameInfoData&& frameInfoData, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&& request,IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, const UserData& userData, uint64_t listenerID){@@ -9243,7 +9126,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390}void WebPageProxy::decidePolicyForNavigationActionAsyncShared(Ref<WebProcessProxy>&& process, PageIdentifier webPageID, FrameIdentifier frameID, WebCore::SecurityOriginData&& frameSecurityOrigin,-@@ -5430,6 +5471,8 @@ void WebPageProxy::runJavaScriptAlert(FrameIdentifier frameID, SecurityOriginDat+@@ -5454,6 +5495,8 @@ void WebPageProxy::runJavaScriptAlert(FrameIdentifier frameID, SecurityOriginDatif (auto* automationSession = process().processPool().automationSession())automationSession->willShowJavaScriptDialog(*this);}@@ -9252,7 +9135,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390m_uiClient->runJavaScriptAlert(*this, message, frame, WTFMove(securityOrigin), WTFMove(reply));}-@@ -5449,6 +5492,8 @@ void WebPageProxy::runJavaScriptConfirm(FrameIdentifier frameID, SecurityOriginD+@@ -5473,6 +5516,8 @@ void WebPageProxy::runJavaScriptConfirm(FrameIdentifier frameID, SecurityOriginDif (auto* automationSession = process().processPool().automationSession())automationSession->willShowJavaScriptDialog(*this);}@@ -9261,7 +9144,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390m_uiClient->runJavaScriptConfirm(*this, message, frame, WTFMove(securityOrigin), WTFMove(reply));}-@@ -5468,6 +5513,8 @@ void WebPageProxy::runJavaScriptPrompt(FrameIdentifier frameID, SecurityOriginDa+@@ -5492,6 +5537,8 @@ void WebPageProxy::runJavaScriptPrompt(FrameIdentifier frameID, SecurityOriginDaif (auto* automationSession = process().processPool().automationSession())automationSession->willShowJavaScriptDialog(*this);}@@ -9270,7 +9153,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390m_uiClient->runJavaScriptPrompt(*this, message, defaultValue, frame, WTFMove(securityOrigin), WTFMove(reply));}-@@ -5627,6 +5674,8 @@ void WebPageProxy::runBeforeUnloadConfirmPanel(FrameIdentifier frameID, Security+@@ -5651,6 +5698,8 @@ void WebPageProxy::runBeforeUnloadConfirmPanel(FrameIdentifier frameID, Securityreturn;}}@@ -9279,15 +9162,15 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390// Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer and the tryClose timer.m_process->responsivenessTimer().stop();-@@ -6686,6 +6735,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)+@@ -6705,6 +6754,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)if (auto* automationSession = process().processPool().automationSession())automationSession->mouseEventsFlushedForPage(*this);- pageClient().didFinishProcessingAllPendingMouseEvents();+ didFinishProcessingAllPendingMouseEvents();+ m_inspectorController->didProcessAllPendingMouseEvents();}break;-@@ -6712,7 +6762,6 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)+@@ -6731,7 +6781,6 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)case WebEvent::RawKeyDown:case WebEvent::Char: {LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s (queue empty %d)", webKeyboardEventTypeString(type), m_keyEventQueue.isEmpty());@@ -9295,7 +9178,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390MESSAGE_CHECK(m_process, !m_keyEventQueue.isEmpty());NativeWebKeyboardEvent event = m_keyEventQueue.takeFirst();-@@ -6732,7 +6781,6 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)+@@ -6751,7 +6800,6 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)// The call to doneWithKeyEvent may close this WebPage.// Protect against this being destroyed.Ref<WebPageProxy> protect(*this);@@ -9303,7 +9186,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390pageClient().doneWithKeyEvent(event, handled);if (!handled)m_uiClient->didNotHandleKeyEvent(this, event);-@@ -6741,6 +6789,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)+@@ -6760,6 +6808,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)if (!canProcessMoreKeyEvents) {if (auto* automationSession = process().processPool().automationSession())automationSession->keyboardEventsFlushedForPage(*this);@@ -9311,7 +9194,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390}break;}-@@ -7209,8 +7258,10 @@ static bool shouldReloadAfterProcessTermination(ProcessTerminationReason reason)+@@ -7228,8 +7277,10 @@ static bool shouldReloadAfterProcessTermination(ProcessTerminationReason reason)void WebPageProxy::dispatchProcessDidTerminate(ProcessTerminationReason reason){RELEASE_LOG_IF_ALLOWED(Loading, "dispatchProcessDidTerminate: reason = %d", reason);@@ -9323,7 +9206,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390if (m_loaderClient)handledByClient = reason != ProcessTerminationReason::RequestedByClient && m_loaderClient->processDidCrash(*this);else-@@ -7668,6 +7719,14 @@ void WebPageProxy::gamepadActivity(const Vector<GamepadData>& gamepadDatas, bool+@@ -7687,6 +7738,14 @@ void WebPageProxy::gamepadActivity(const Vector<GamepadData>& gamepadDatas, boolvoid WebPageProxy::didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&& authenticationChallenge){@@ -9338,7 +9221,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get());}-@@ -7729,7 +7788,8 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID,+@@ -7748,7 +7807,8 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID,MESSAGE_CHECK(m_process, frame);// FIXME: Geolocation should probably be using toString() as its string representation instead of databaseIdentifier().@@ -9348,7 +9231,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390auto request = m_geolocationPermissionRequestManager.createRequest(geolocationID);Function<void(bool)> completionHandler = [request = WTFMove(request)](bool allowed) {if (allowed)-@@ -7737,6 +7797,11 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID,+@@ -7756,6 +7816,11 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID,elserequest->deny();};@@ -9361,7 +9244,7 @@ index 6f1a3ea0b45d339fc8029046de6895530208db5d..83956f40de2f476c313244298f686390// FIXME: Once iOS migrates to the new WKUIDelegate SPI, clean this up// and make it one UIClient call that calls the completionHandler with falsediff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h-index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59dd1a3a46 100644+index c99fe0f8f76e3f5ece7578d6eb8f2f42c7f099b6..73acf30236f1f2eecd7c5fcf25c0da409786ad32 100644--- a/Source/WebKit/UIProcess/WebPageProxy.h+++ b/Source/WebKit/UIProcess/WebPageProxy.h@@ -35,6 +35,7 @@@@ -9372,7 +9255,7 @@ index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59#include "LayerTreeContext.h"#include "MessageSender.h"#include "NotificationPermissionRequestManagerProxy.h"-@@ -486,6 +487,8 @@ public:+@@ -487,6 +488,8 @@ public:void setControlledByAutomation(bool);WebPageInspectorController& inspectorController() { return *m_inspectorController; }@@ -9381,7 +9264,7 @@ index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59#if PLATFORM(IOS_FAMILY)void showInspectorIndication();-@@ -552,6 +555,10 @@ public:+@@ -553,6 +556,10 @@ public:void setPageLoadStateObserver(std::unique_ptr<PageLoadState::Observer>&&);@@ -9392,7 +9275,7 @@ index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59void initializeWebPage();void setDrawingArea(std::unique_ptr<DrawingAreaProxy>&&);-@@ -577,6 +584,7 @@ public:+@@ -578,6 +585,7 @@ public:void closePage();void addPlatformLoadParameters(LoadParameters&);@@ -9400,7 +9283,7 @@ index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59RefPtr<API::Navigation> loadRequest(WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, API::Object* userData = nullptr);RefPtr<API::Navigation> loadFile(const String& fileURL, const String& resourceDirectoryURL, API::Object* userData = nullptr);RefPtr<API::Navigation> loadData(const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);-@@ -2286,6 +2294,7 @@ private:+@@ -2290,6 +2298,7 @@ private:bool m_treatsSHA1CertificatesAsInsecure { true };RefPtr<WebInspectorProxy> m_inspector;@@ -9408,7 +9291,7 @@ index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59#if ENABLE(FULLSCREEN_API)std::unique_ptr<WebFullScreenManagerProxy> m_fullScreenManager;-@@ -2698,6 +2707,8 @@ private:+@@ -2703,6 +2712,8 @@ private:bool m_isLayerTreeFrozenDueToSwipeAnimation { false };String m_overriddenMediaType;@@ -9418,7 +9301,7 @@ index ac6615a1a96cb0b8dd2cc0811c994ccaa35f573f..a0597f1dafb76bf233505ed5a28b6a59#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)std::unique_ptr<WebDeviceOrientationUpdateProviderProxy> m_webDeviceOrientationUpdateProviderProxy;diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in-index 3a746011ea8da8ee8ccaf7b77f954b007783c342..62918ecc3246b1ab7e70796344421249e110c673 100644+index a6d4c6173b0fd75a5f507e44f60f7dfd14f433b4..d2721d8356841fd5b3b16c808c35522d1c4cbdc0 100644--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in@@ -29,6 +29,7 @@ messages -> WebPageProxy {@@ -10165,7 +10048,7 @@ index 0000000000000000000000000000000000000000..721826c8c98fc85b68a4f45deaee69c1++#endifdiff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.h b/Source/WebKit/UIProcess/mac/PageClientImplMac.h-index 8016b56c160acc7b4269600f07f737b3793767bb..651a86c41af3305e215d7baf7f149cc7f401c470 100644+index 52b85bb1058c4ab53de6db14c8ffdf2c178353f6..775a2bd1413f69e4e0fa96a3680bc844bdc4b7a8 100644--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.h+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.h@@ -53,6 +53,8 @@ class PageClientImpl final : public PageClientImplCocoa@@ -10189,7 +10072,7 @@ index 8016b56c160acc7b4269600f07f737b3793767bb..651a86c41af3305e215d7baf7f149cc7void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm-index bf7dc132b1ef9e081275cbecb562dd1bfd3a2a0e..e389900c57adb50ae8802b58fd1992c01f44e8ed 100644+index b45b2e8cc34604a03a02a7feff44b980ee44bfd6..5df25e27ef3c3b197c6e6d79f8a2383636438cef 100644--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm@@ -78,6 +78,7 @@@@ -10277,7 +10160,7 @@ index bf7dc132b1ef9e081275cbecb562dd1bfd3a2a0e..e389900c57adb50ae8802b58fd1992c0void PageClientImpl::navigationGestureDidBegin(){m_impl->dismissContentRelativeChildWindowsWithAnimation(true);-@@ -931,6 +958,9 @@ void PageClientImpl::didRestoreScrollPosition()+@@ -926,6 +953,9 @@ void PageClientImpl::didRestoreScrollPosition()bool PageClientImpl::windowIsFrontWindowUnderMouse(const NativeWebMouseEvent& event){@@ -10971,10 +10854,10 @@ index 0000000000000000000000000000000000000000..585fb151f302e4b376c705ed0d0974d5++} // namespace WebKitdiff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj-index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937dc0fc15c 100644+index 7697c4c58d472c64c6bb90c4cdde6cd5c6e59bca..e28a685ea3154283430857474dd4fd5eac6fe32c 100644--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj-@@ -1728,6 +1728,19 @@+@@ -1727,6 +1727,19 @@CEE4AE2B1A5DCF430002F49B /* UIKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CEE4AE2A1A5DCF430002F49B /* UIKitSPI.h */; };D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484311FF4B6500032B39 /* WebPopupMenu.h */; };D3B9484911FF4B6500032B39 /* WebSearchPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */; };@@ -10994,7 +10877,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E105FE5318D7B9DE008F57A8 /* EditingRange.h */; };E11D35AE16B63D1B006D23D7 /* com.apple.WebProcess.sb in Resources */ = {isa = PBXBuildFile; fileRef = E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */; };E14A954A16E016A40068DE82 /* NetworkProcessPlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = E14A954816E016A40068DE82 /* NetworkProcessPlatformStrategies.h */; };-@@ -4990,6 +5003,20 @@+@@ -4986,6 +4999,20 @@D3B9484311FF4B6500032B39 /* WebPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenu.h; sourceTree = "<group>"; };D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSearchPopupMenu.cpp; sourceTree = "<group>"; };D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSearchPopupMenu.h; sourceTree = "<group>"; };@@ -11015,7 +10898,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937DF58C6311371AC5800F9A37C /* NativeWebWheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebWheelEvent.h; sourceTree = "<group>"; };DF58C6351371ACA000F9A37C /* NativeWebWheelEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebWheelEventMac.mm; sourceTree = "<group>"; };E105FE5318D7B9DE008F57A8 /* EditingRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingRange.h; sourceTree = "<group>"; };-@@ -6802,6 +6829,7 @@+@@ -6792,6 +6819,7 @@37C4C08318149C2A003688B9 /* Cocoa */ = {isa = PBXGroup;children = (@@ -11023,7 +10906,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749371A43E826188F38E2009E4D30 /* Deprecated */,37A5E01218BBF937000A081E /* _WKActivatedElementInfo.h */,37A5E01118BBF937000A081E /* _WKActivatedElementInfo.mm */,-@@ -8363,6 +8391,13 @@+@@ -8425,6 +8453,13 @@BC032DC310F438260058C15A /* UIProcess */ = {isa = PBXGroup;children = (@@ -11037,7 +10920,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937BC032DC410F4387C0058C15A /* API */,512F588D12A8836F00629530 /* Authentication */,9955A6E81C79809000EB6A93 /* Automation */,-@@ -8653,6 +8688,7 @@+@@ -8702,6 +8737,7 @@BC0C376610F807660076D7CB /* C */ = {isa = PBXGroup;children = (@@ -11045,7 +10928,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749375123CF18133D25E60056F800 /* cg */,6EE849C41368D9040038D481 /* mac */,BCB63477116BF10600603215 /* WebKit2_C.h */,-@@ -9256,6 +9292,11 @@+@@ -9304,6 +9340,11 @@BCCF085C113F3B7500C650C5 /* mac */ = {isa = PBXGroup;children = (@@ -11057,7 +10940,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937B878B613133428DC006888E9 /* CorrectionPanel.h */,B878B614133428DC006888E9 /* CorrectionPanel.mm */,C1817362205844A900DFDA65 /* DisplayLink.cpp */,-@@ -9960,6 +10001,7 @@+@@ -10001,6 +10042,7 @@5CAFDE452130846300B1F7E1 /* _WKInspector.h in Headers */,991F492F23A812C60054642B /* _WKInspectorDebuggableInfo.h in Headers */,99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */,@@ -11065,7 +10948,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749375CAFDE472130846A00B1F7E1 /* _WKInspectorInternal.h in Headers */,9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */,A5C0F0AB2000658200536536 /* _WKInspectorWindow.h in Headers */,-@@ -10083,6 +10125,7 @@+@@ -10124,6 +10166,7 @@7C89D2981A6753B2003A5FDE /* APIPageConfiguration.h in Headers */,1AC1336C18565C7A00F3EC05 /* APIPageHandle.h in Headers */,1AFDD3151891B54000153970 /* APIPolicyClient.h in Headers */,@@ -11073,7 +10956,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749377CE4D2201A4914CA00C7F152 /* APIProcessPoolConfiguration.h in Headers */,49BCA19223A177660028A836 /* APIResourceLoadStatisticsFirstParty.h in Headers */,49BCA19723A1930D0028A836 /* APIResourceLoadStatisticsThirdParty.h in Headers */,-@@ -10208,6 +10251,7 @@+@@ -10248,6 +10291,7 @@BC06F43A12DBCCFB002D78DE /* GeolocationPermissionRequestProxy.h in Headers */,2DA944A41884E4F000ED86DB /* GestureTypes.h in Headers */,2DA049B8180CCD0A00AAFA9E /* GraphicsLayerCARemote.h in Headers */,@@ -11081,7 +10964,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937C0CE72AD1247E78D00BC0EC4 /* HandleMessage.h in Headers */,1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */,57AC8F50217FEED90055438C /* HidConnection.h in Headers */,-@@ -10331,8 +10375,10 @@+@@ -10371,8 +10415,10 @@41DC45961E3D6E2200B11F51 /* NetworkRTCProvider.h in Headers */,413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */,5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */,@@ -11092,7 +10975,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937570DAAC22303730300E8FC04 /* NfcConnection.h in Headers */,570DAAAE23026F5C00E8FC04 /* NfcService.h in Headers */,31A2EC5614899C0900810D71 /* NotificationPermissionRequest.h in Headers */,-@@ -10414,6 +10460,7 @@+@@ -10454,6 +10500,7 @@CD2865EE2255562000606AC7 /* ProcessTaskStateObserver.h in Headers */,463FD4821EB94EC000A2982C /* ProcessTerminationReason.h in Headers */,86E67A251910B9D100004AB7 /* ProcessThrottler.h in Headers */,@@ -11100,7 +10983,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c5137493783048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */,A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */,57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */,-@@ -10824,6 +10871,7 @@+@@ -10864,6 +10911,7 @@BCD25F1711D6BDE100169B0E /* WKBundleFrame.h in Headers */,BCF049E611FE20F600F86A58 /* WKBundleFramePrivate.h in Headers */,BC49862F124D18C100D834E1 /* WKBundleHitTestResult.h in Headers */,@@ -11108,7 +10991,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937BC204EF211C83EC8008F3375 /* WKBundleInitialize.h in Headers */,65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */,1A8B66B41BC45B010082DF77 /* WKBundleMac.h in Headers */,-@@ -10873,6 +10921,7 @@+@@ -10913,6 +10961,7 @@5C795D71229F3757003FF1C4 /* WKContextMenuElementInfoPrivate.h in Headers */,51A555F6128C6C47009ABCEC /* WKContextMenuItem.h in Headers */,51A55601128C6D92009ABCEC /* WKContextMenuItemTypes.h in Headers */,@@ -11116,7 +10999,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c51374937A1EA02381DABFF7E0096021F /* WKContextMenuListener.h in Headers */,BCC938E11180DE440085E5FE /* WKContextPrivate.h in Headers */,9FB5F395169E6A80002C25BF /* WKContextPrivateMac.h in Headers */,-@@ -11022,6 +11071,7 @@+@@ -11062,6 +11111,7 @@1AB8A1F818400BB800E9AE69 /* WKPageContextMenuClient.h in Headers */,8372DB251A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h in Headers */,1AB8A1F418400B8F00E9AE69 /* WKPageFindClient.h in Headers */,@@ -11124,7 +11007,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749371AB8A1F618400B9D00E9AE69 /* WKPageFindMatchesClient.h in Headers */,1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,BC7B633712A45ABA00D174A4 /* WKPageGroup.h in Headers */,-@@ -12048,6 +12098,7 @@+@@ -12088,6 +12138,7 @@CDA93DB122F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp in Sources */,2749F6442146561B008380BF /* InjectedBundleNodeHandle.cpp in Sources */,2749F6452146561E008380BF /* InjectedBundleRangeHandle.cpp in Sources */,@@ -11132,7 +11015,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749372D913441212CF9F000128AFD /* JSNPMethod.cpp in Sources */,2D913442212CF9F000128AFD /* JSNPObject.cpp in Sources */,2984F588164BA095004BC0C6 /* LegacyCustomProtocolManagerMessageReceiver.cpp in Sources */,-@@ -12058,6 +12109,7 @@+@@ -12098,6 +12149,7 @@2D92A781212B6A7100F493FD /* MessageReceiverMap.cpp in Sources */,2D92A782212B6A7100F493FD /* MessageSender.cpp in Sources */,2D92A77A212B6A6100F493FD /* Module.cpp in Sources */,@@ -11140,7 +11023,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c5137493757B826452304F14000B72EB0 /* NearFieldSoftLink.mm in Sources */,2D913443212CF9F000128AFD /* NetscapeBrowserFuncs.cpp in Sources */,2D913444212CF9F000128AFD /* NetscapePlugin.cpp in Sources */,-@@ -12082,6 +12134,7 @@+@@ -12122,6 +12174,7 @@1A2D8439127F65D5001EB962 /* NPObjectMessageReceiverMessageReceiver.cpp in Sources */,2D92A792212B6AD400F493FD /* NPObjectProxy.cpp in Sources */,2D92A793212B6AD400F493FD /* NPRemoteObjectMap.cpp in Sources */,@@ -11148,7 +11031,7 @@ index e8787899ef02ff0eb8f45f0e11f2637b3dcf0b7b..3ba252852f9b2fd87aac761c513749372D913447212CF9F000128AFD /* NPRuntimeObjectMap.cpp in Sources */,2D913448212CF9F000128AFD /* NPRuntimeUtilities.cpp in Sources */,2D92A794212B6AD400F493FD /* NPVariantData.cpp in Sources */,-@@ -12351,6 +12404,7 @@+@@ -12391,6 +12444,7 @@2D92A78C212B6AB100F493FD /* WebMouseEvent.cpp in Sources */,31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */,2DF6FE52212E110900469030 /* WebPage.cpp in Sources */,@@ -11318,7 +11201,7 @@ index f127d64d005ab7b93875591b94a5899205e91579..df0de26e4dc449a0fbf93e7037444df4uint64_t m_navigationID;};diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp-index 862b13ac7d78e3cba0e7ede53791a8547720d64a..fc1a141e0aed0c5f6ad650cf0883b6ab1386b591 100644+index bd341068fb725f9ee15a3ab15e97a97f3c9ff692..7b8d60a8b2ab831bb5dc818d4ce4ac6c6f0a61de 100644--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp@@ -1557,6 +1557,22 @@ void WebPage::platformDidReceiveLoadParameters(const LoadParameters& loadParamet@@ -11420,7 +11303,7 @@ index 862b13ac7d78e3cba0e7ede53791a8547720d64a..fc1a141e0aed0c5f6ad650cf0883b6ab}void WebPage::listenForLayoutMilestones(OptionSet<WebCore::LayoutMilestone> milestones)-@@ -6291,6 +6290,9 @@ Ref<DocumentLoader> WebPage::createDocumentLoader(Frame& frame, const ResourceRe+@@ -6290,6 +6289,9 @@ Ref<DocumentLoader> WebPage::createDocumentLoader(Frame& frame, const ResourceReWebsitePoliciesData::applyToDocumentLoader(WTFMove(*m_pendingWebsitePolicies), documentLoader);m_pendingWebsitePolicies = WTF::nullopt;}@@ -11431,7 +11314,7 @@ index 862b13ac7d78e3cba0e7ede53791a8547720d64a..fc1a141e0aed0c5f6ad650cf0883b6abreturn documentLoader;diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h-index 4a6d4f29717c5566c0fcfdb4253ef971e755fb81..d394dd650fe64a81902eec8b6d48817cc109bf89 100644+index d540081f1d3ed670d07afb1bfae1ea93c92c8852..70dc9a6ef4024cffb98b635d0eba5d3b4d4729ff 100644--- a/Source/WebKit/WebProcess/WebPage/WebPage.h+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h@@ -1370,6 +1370,7 @@ private:@@ -11461,7 +11344,7 @@ index 4a6d4f29717c5566c0fcfdb4253ef971e755fb81..d394dd650fe64a81902eec8b6d48817cbool m_mainFrameProgressCompleted { false };diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in-index d6dd3705763d94e2896c54eb8efd17d731b299dc..45546585228f047bb809bf3137b278b4fb1a73ae 100644+index d61df803b235d94e6f2bcbcc6153b1e938469514..2bebc404fdf564c8d03b4e31bb65e1954fa1f7b1 100644--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in@@ -167,6 +167,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType@@ -11473,7 +11356,7 @@ index d6dd3705763d94e2896c54eb8efd17d731b299dc..45546585228f047bb809bf3137b278b4LoadData(struct WebKit::LoadParameters loadParameters)LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp-index 65c9bc4ca76ac950dd9682e1224dcb8f6e0e48fe..1c0061063af2df56ad154206372a92a2333c3646 100644+index 67a790a7a832642948638dd574791d0802310171..fe1f87e491fdb4317689f28ba8fa21b5fdefd110 100644--- a/Source/WebKit/WebProcess/WebProcess.cpp+++ b/Source/WebKit/WebProcess/WebProcess.cpp@@ -77,6 +77,7 @@@@ -11507,10 +11390,10 @@ index b2a1d085938ef3e7d2259fef166ddbcf53897f8d..9a362468b347e053a079f6f5531753d2- (void)touch:(WebEvent *)event{diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm-index 5c296b61cc16a71b60632db6083d48b702a9fcd3..ae989cf2f188466ce09ba2ef1872dfd2aef52948 100644+index 6d0daa6be2be1da41ac47747d24d368b2bf5a77f..c5b800e0035c625705d7d897dec5f2b8874029dc 100644--- a/Source/WebKitLegacy/mac/WebView/WebView.mm+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm-@@ -4343,7 +4343,7 @@ IGNORE_WARNINGS_END+@@ -4344,7 +4344,7 @@ IGNORE_WARNINGS_END}#endif // PLATFORM(IOS_FAMILY)@@ -11519,7 +11402,7 @@ index 5c296b61cc16a71b60632db6083d48b702a9fcd3..ae989cf2f188466ce09ba2ef1872dfd2- (NSArray *)_touchEventRegions{auto* frame = [self _mainCoreFrame];-@@ -4389,7 +4389,7 @@ IGNORE_WARNINGS_END+@@ -4390,7 +4390,7 @@ IGNORE_WARNINGS_ENDreturn eventRegionArray;}@@ -11529,7 +11412,7 @@ index 5c296b61cc16a71b60632db6083d48b702a9fcd3..ae989cf2f188466ce09ba2ef1872dfd2// For backwards compatibility with the WebBackForwardList API, we honor both// a per-WebView and a per-preferences setting for whether to use the back/forward cache.diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake-index 904e379acd88151193fc285b5a1e4c56cd4d2a4d..465f1898a4a846cd9b6eea327ca9d6b71b51ea80 100644+index c72a89204675c2d6b5c13933580b0181637e23b6..e349858738933a34849b14c83f8bab4deff1555f 100644--- a/Source/cmake/OptionsGTK.cmake+++ b/Source/cmake/OptionsGTK.cmake@@ -3,6 +3,7 @@ include(VersioningUtils)@@ -11541,7 +11424,7 @@ index 904e379acd88151193fc285b5a1e4c56cd4d2a4d..465f1898a4a846cd9b6eea327ca9d6b7CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT 80 0 43)CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 34 0 16)diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake-index 149a592c891e8b375f441c17fb421099e3c477dc..10173cd7d06e5014c978aec90027d71b3c0b98d7 100644+index 5f0963cc1a3255b31c6a2f186c07ff3204a041cf..3eeab81c5e90af47926003407a52f7adb35b844d 100644--- a/Source/cmake/OptionsWPE.cmake+++ b/Source/cmake/OptionsWPE.cmake@@ -3,6 +3,7 @@ include(VersioningUtils)@@ -11561,7 +11444,7 @@ index 149a592c891e8b375f441c17fb421099e3c477dc..10173cd7d06e5014c978aec90027d71bWEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML PRIVATE ON)WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF)diff --git a/Source/cmake/OptionsWin.cmake b/Source/cmake/OptionsWin.cmake-index 935a7fd136754694c5301100ad4699ccb2210e67..2a04380900326ec5ef03ff5b78c67643132aac93 100644+index bca9670392b3d84895b4afc42575b4a1aeccba55..993010339a65b657ca4237d30182160a689b7fac 100644--- a/Source/cmake/OptionsWin.cmake+++ b/Source/cmake/OptionsWin.cmake@@ -7,8 +7,9 @@ add_definitions(-D_WINDOWS -DWINVER=0x601 -D_WIN32_WINNT=0x601)@@ -15339,7 +15222,7 @@ index fc0664a6505546f428c7514b9675119b75a62140..14556b3742856ba88d9363957ea97f33# WebInspectorUI must come after JavaScriptCore and WebCore but before WebKit and WebKit2my $webKitIndex = first { $projects[$_] eq "Source/WebKitLegacy" } 0..$#projects;diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp-index ecb882fbe072bb046e54950f826a10d1bbc958fb..d61d873088f5be31682b733d800cbbfa7d5818b5 100644+index 3c2bf2ae9b1a2402d66de5685246f5c231440178..a820642e074e3c2cdda2cd7062d17c09e68f0139 100644--- a/Tools/WebKitTestRunner/TestController.cpp+++ b/Tools/WebKitTestRunner/TestController.cpp@@ -718,7 +718,8 @@ void TestController::createWebViewWithOptions(const TestOptions& options)