15151 lines
		
	
	
		
			671 KiB
		
	
	
	
		
			Diff
		
	
	
	
			
		
		
	
	
			15151 lines
		
	
	
		
			671 KiB
		
	
	
	
		
			Diff
		
	
	
	
| diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
 | |
| index 0d1fe3000ab2b4b08af449d9532277be47a6dc87..13faf01e0f759ce60ecee29373f292a3753e2d45 100644
 | |
| --- a/Source/JavaScriptCore/CMakeLists.txt
 | |
| +++ b/Source/JavaScriptCore/CMakeLists.txt
 | |
| @@ -1160,21 +1160,26 @@ set(JavaScriptCore_INSPECTOR_DOMAINS
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/CSS.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Canvas.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Console.json
 | |
| +    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Dialog.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOM.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOMDebugger.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOMStorage.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Database.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Debugger.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Browser.json
 | |
| +    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Emulation.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/GenericTypes.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Heap.json
 | |
| +    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Input.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Inspector.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/LayerTree.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Network.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Page.json
 | |
| +    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Playwright.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Recording.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Runtime.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/ScriptProfiler.json
 | |
| +    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Screencast.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Security.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Target.json
 | |
|      ${JAVASCRIPTCORE_DIR}/inspector/protocol/Timeline.json
 | |
| diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make
 | |
| index 00d2a57b3ed2dc3c299742984e5057aa6a1c3ede..2fc5504339ec62be894c894a05483833bf8a9b5a 100644
 | |
| --- a/Source/JavaScriptCore/DerivedSources.make
 | |
| +++ b/Source/JavaScriptCore/DerivedSources.make
 | |
| @@ -246,21 +246,26 @@ INSPECTOR_DOMAINS := \
 | |
|      $(JavaScriptCore)/inspector/protocol/CSS.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Canvas.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Console.json \
 | |
| +    $(JavaScriptCore)/inspector/protocol/Dialog.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/DOM.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/DOMDebugger.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/DOMStorage.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Database.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Debugger.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Browser.json \
 | |
| +    $(JavaScriptCore)/inspector/protocol/Emulation.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/GenericTypes.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Heap.json \
 | |
| +    $(JavaScriptCore)/inspector/protocol/Input.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Inspector.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/LayerTree.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Network.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Page.json \
 | |
| +    $(JavaScriptCore)/inspector/protocol/Playwright.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Recording.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Runtime.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/ScriptProfiler.json \
 | |
| +    $(JavaScriptCore)/inspector/protocol/Screencast.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Security.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Target.json \
 | |
|      $(JavaScriptCore)/inspector/protocol/Timeline.json \
 | |
| diff --git a/Source/JavaScriptCore/bindings/ScriptValue.cpp b/Source/JavaScriptCore/bindings/ScriptValue.cpp
 | |
| index dece6ac51e3a85b1e094e405effc6203887ddfd4..9bf7519d894eceb06b40d754c4fb7940399eba84 100644
 | |
| --- a/Source/JavaScriptCore/bindings/ScriptValue.cpp
 | |
| +++ b/Source/JavaScriptCore/bindings/ScriptValue.cpp
 | |
| @@ -81,7 +81,10 @@ static RefPtr<JSON::Value> jsToInspectorValue(JSGlobalObject* globalObject, JSVa
 | |
|          PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
 | |
|          object.methodTable(vm)->getOwnPropertyNames(&object, globalObject, propertyNames, EnumerationMode());
 | |
|          for (auto& name : propertyNames) {
 | |
| -            auto inspectorValue = jsToInspectorValue(globalObject, object.get(globalObject, name), maxDepth);
 | |
| +            JSValue childValue = object.get(globalObject, name);
 | |
| +            if (childValue.isUndefined())
 | |
| +                continue;
 | |
| +            auto inspectorValue = jsToInspectorValue(globalObject, childValue, maxDepth);
 | |
|              if (!inspectorValue)
 | |
|                  return nullptr;
 | |
|              inspectorObject->setValue(name.string(), WTFMove(inspectorValue));
 | |
| diff --git a/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp b/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp
 | |
| index 95cd87b01b15cb8667e57bc5bb51a71f06bc3760..0481fa93227f297be9d9cf000c5a72235956a390 100644
 | |
| --- a/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp
 | |
| +++ b/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp
 | |
| @@ -30,14 +30,21 @@
 | |
|  namespace Inspector {
 | |
|  
 | |
|  namespace {
 | |
| +static uint64_t s_processID = 0;
 | |
|  static long s_lastUsedIdentifier = 0;
 | |
|  }
 | |
|  
 | |
|  static String addPrefixToIdentifier(const String& identifier)
 | |
|  {
 | |
| -    return makeString("0.", identifier);
 | |
| +    return makeString(s_processID, ".", identifier);
 | |
|  }
 | |
|  
 | |
| +void IdentifiersFactory::initializeWithProcessID(uint64_t processID) {
 | |
| +    ASSERT(!s_processID);
 | |
| +    s_processID = processID;
 | |
| +}
 | |
| +
 | |
| +
 | |
|  String IdentifiersFactory::createIdentifier()
 | |
|  {
 | |
|      return addPrefixToIdentifier(String::number(++s_lastUsedIdentifier));
 | |
| diff --git a/Source/JavaScriptCore/inspector/IdentifiersFactory.h b/Source/JavaScriptCore/inspector/IdentifiersFactory.h
 | |
| index eb25aedee4cd9ebe007e06c2515b37ee095b06f4..badf6559595c8377db1089ca3c25008e1be2c8f1 100644
 | |
| --- a/Source/JavaScriptCore/inspector/IdentifiersFactory.h
 | |
| +++ b/Source/JavaScriptCore/inspector/IdentifiersFactory.h
 | |
| @@ -31,6 +31,7 @@ namespace Inspector {
 | |
|  
 | |
|  class JS_EXPORT_PRIVATE IdentifiersFactory {
 | |
|  public:
 | |
| +    static void initializeWithProcessID(uint64_t);
 | |
|      static String createIdentifier();
 | |
|      static String requestId(unsigned long identifier);
 | |
|  };
 | |
| diff --git a/Source/JavaScriptCore/inspector/InjectedScript.cpp b/Source/JavaScriptCore/inspector/InjectedScript.cpp
 | |
| index cc849f051fa40518a9d1a03429bc2b4dbcfb3102..11b05346f6098fa23f51ba9abc1af0e0e60a626c 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InjectedScript.cpp
 | |
| +++ b/Source/JavaScriptCore/inspector/InjectedScript.cpp
 | |
| @@ -287,9 +287,13 @@ RefPtr<Protocol::Runtime::RemoteObject> InjectedScript::wrapObject(JSC::JSValue
 | |
|      auto callResult = callFunctionWithEvalEnabled(wrapFunction);
 | |
|      if (!callResult)
 | |
|          return nullptr;
 | |
| +    auto callResultValue = callResult.value();
 | |
| +    // callResultValue could be missing if the execution was terminated
 | |
| +    if (!callResultValue)
 | |
| +        return nullptr;
 | |
|  
 | |
|      RefPtr<JSON::Object> resultObject;
 | |
| -    bool castSucceeded = toInspectorValue(globalObject(), callResult.value())->asObject(resultObject);
 | |
| +    bool castSucceeded = toInspectorValue(globalObject(), callResultValue)->asObject(resultObject);
 | |
|      ASSERT_UNUSED(castSucceeded, castSucceeded);
 | |
|  
 | |
|      return BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
 | |
| diff --git a/Source/JavaScriptCore/inspector/InjectedScriptSource.js b/Source/JavaScriptCore/inspector/InjectedScriptSource.js
 | |
| index cd593a24af4fe24ba59577b73b26947765edcc32..1f7a04d72065dbd60761c1a72f3254f953d3b9a9 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InjectedScriptSource.js
 | |
| +++ b/Source/JavaScriptCore/inspector/InjectedScriptSource.js
 | |
| @@ -136,7 +136,7 @@ let InjectedScript = class InjectedScript
 | |
|              return;
 | |
|          }
 | |
|  
 | |
| -        if (!(promiseObject instanceof Promise)) {
 | |
| +        if (InjectedScriptHost.internalConstructorName(promiseObject) !== 'Promise') {
 | |
|              callback("Object with given id is not a Promise");
 | |
|              return;
 | |
|          }
 | |
| diff --git a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
 | |
| index 038cb646d31706905deff8935040d63c0afd00f9..54bf8bf6aba07039109f61369b5e441eee0ba184 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
 | |
| +++ b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
 | |
| @@ -102,7 +102,7 @@ void BackendDispatcher::registerDispatcherForDomain(const String& domain, Supple
 | |
|      m_dispatchers.set(domain, dispatcher);
 | |
|  }
 | |
|  
 | |
| -void BackendDispatcher::dispatch(const String& message)
 | |
| +void BackendDispatcher::dispatch(const String& message, Interceptor&& interceptor)
 | |
|  {
 | |
|      Ref<BackendDispatcher> protect(*this);
 | |
|  
 | |
| @@ -143,6 +143,9 @@ void BackendDispatcher::dispatch(const String& message)
 | |
|          }
 | |
|      }
 | |
|  
 | |
| +    if (interceptor && interceptor(messageObject) == InterceptionResult::Intercepted)
 | |
| +        return;
 | |
| +
 | |
|      {
 | |
|          // We could be called re-entrantly from a nested run loop, so restore the previous id.
 | |
|          SetForScope<Optional<long>> scopedRequestId(m_currentRequestId, requestId);
 | |
| diff --git a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h
 | |
| index 95d9d81188e735e8f1b70cc0deee2682cb6714f0..fbab25a07bf35c49faf026a3dfaccd50f50d1ab8 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h
 | |
| +++ b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h
 | |
| @@ -82,7 +82,10 @@ public:
 | |
|      };
 | |
|  
 | |
|      void registerDispatcherForDomain(const String& domain, SupplementalBackendDispatcher*);
 | |
| -    void dispatch(const String& message);
 | |
| +
 | |
| +    enum class InterceptionResult { Intercepted, Continue };
 | |
| +    using Interceptor = WTF::Function<InterceptionResult(const RefPtr<JSON::Object>&)>;
 | |
| +    void dispatch(const String& message, Interceptor&& interceptor = Interceptor());
 | |
|  
 | |
|      // Note that 'unused' is a workaround so the compiler can pick the right sendResponse based on arity.
 | |
|      // When <http://webkit.org/b/179847> is fixed or this class is renamed for the JSON::Object case,
 | |
| diff --git a/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp b/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp
 | |
| index d408d364f1986983161f9d44efbc8bc6f6898676..1375ce9990f0c63d7e6f33ee62930051d6cd44cb 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp
 | |
| +++ b/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp
 | |
| @@ -49,7 +49,7 @@ void FrontendRouter::connectFrontend(FrontendChannel& connection)
 | |
|  void FrontendRouter::disconnectFrontend(FrontendChannel& connection)
 | |
|  {
 | |
|      if (!m_connections.contains(&connection)) {
 | |
| -        ASSERT_NOT_REACHED();
 | |
| +        ASSERT(m_connections.isEmpty());
 | |
|          return;
 | |
|      }
 | |
|  
 | |
| diff --git a/Source/JavaScriptCore/inspector/InspectorTarget.cpp b/Source/JavaScriptCore/inspector/InspectorTarget.cpp
 | |
| index 0cc2127c9c12c2d82dea9550bad73f4ffb99ba24..8ca65cc042d435cbc0e05dcc5c5dfc958eb24f5a 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InspectorTarget.cpp
 | |
| +++ b/Source/JavaScriptCore/inspector/InspectorTarget.cpp
 | |
| @@ -44,6 +44,8 @@ void InspectorTarget::resume()
 | |
|      ASSERT(m_isPaused);
 | |
|      m_isPaused = false;
 | |
|  
 | |
| +    willResume();
 | |
| +
 | |
|      if (m_resumeCallback) {
 | |
|          m_resumeCallback();
 | |
|          m_resumeCallback = nullptr;
 | |
| @@ -52,7 +54,6 @@ void InspectorTarget::resume()
 | |
|  
 | |
|  void InspectorTarget::setResumeCallback(WTF::Function<void()>&& callback)
 | |
|  {
 | |
| -    ASSERT(!m_resumeCallback);
 | |
|      m_resumeCallback = WTFMove(callback);
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/JavaScriptCore/inspector/InspectorTarget.h b/Source/JavaScriptCore/inspector/InspectorTarget.h
 | |
| index 4b95964db4d902b4b7f4b0b4c40afea51654ff2f..966a5927702b65edb343369decafda7fc83eaec7 100644
 | |
| --- a/Source/JavaScriptCore/inspector/InspectorTarget.h
 | |
| +++ b/Source/JavaScriptCore/inspector/InspectorTarget.h
 | |
| @@ -56,8 +56,12 @@ public:
 | |
|      virtual void connect(FrontendChannel::ConnectionType) = 0;
 | |
|      virtual void disconnect() = 0;
 | |
|      virtual void sendMessageToTargetBackend(const String&) = 0;
 | |
| +    virtual void activate(String& error) { error = "Target cannot be activated"; }
 | |
| +    virtual void close(String& error, bool /* runBeforeUnload */) { error = "Target cannot be closed"; }
 | |
|  
 | |
|  private:
 | |
| +    virtual void willResume() { }
 | |
| +
 | |
|      WTF::Function<void()> m_resumeCallback;
 | |
|      bool m_isPaused { false };
 | |
|  };
 | |
| diff --git a/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.cpp
 | |
| index 8fcb5a1e55750d325a84824d86c49cfe6fb04268..ed2525df326bfe649793701a112eefa30952e375 100644
 | |
| --- a/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.cpp
 | |
| +++ b/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.cpp
 | |
| @@ -87,6 +87,28 @@ void InspectorTargetAgent::sendMessageToTarget(ErrorString& errorString, const S
 | |
|      target->sendMessageToTargetBackend(message);
 | |
|  }
 | |
|  
 | |
| +void InspectorTargetAgent::activate(ErrorString& errorString, const String& targetId)
 | |
| +{
 | |
| +    InspectorTarget* target = m_targets.get(targetId);
 | |
| +    if (!target) {
 | |
| +        errorString = "Missing target for given targetId"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    target->activate(errorString);
 | |
| +}
 | |
| +
 | |
| +void InspectorTargetAgent::close(ErrorString& errorString, const String& targetId, const bool* runBeforeUnload)
 | |
| +{
 | |
| +    InspectorTarget* target = m_targets.get(targetId);
 | |
| +    if (!target) {
 | |
| +        errorString = "Missing target for given targetId"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    target->close(errorString, runBeforeUnload && *runBeforeUnload);
 | |
| +}
 | |
| +
 | |
|  void InspectorTargetAgent::sendMessageFromTargetToFrontend(const String& targetId, const String& message)
 | |
|  {
 | |
|      ASSERT_WITH_MESSAGE(m_targets.get(targetId), "Sending a message from an untracked target to the frontend.");
 | |
| @@ -144,7 +166,17 @@ void InspectorTargetAgent::targetDestroyed(InspectorTarget& target)
 | |
|      if (!m_isConnected)
 | |
|          return;
 | |
|  
 | |
| -    m_frontendDispatcher->targetDestroyed(target.identifier());
 | |
| +    m_frontendDispatcher->targetDestroyed(target.identifier(), false);
 | |
| +}
 | |
| +
 | |
| +void InspectorTargetAgent::targetCrashed(InspectorTarget& target)
 | |
| +{
 | |
| +    m_targets.remove(target.identifier());
 | |
| +
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +
 | |
| +    m_frontendDispatcher->targetDestroyed(target.identifier(), true);
 | |
|  }
 | |
|  
 | |
|  void InspectorTargetAgent::didCommitProvisionalTarget(const String& oldTargetID, const String& committedTargetID)
 | |
| @@ -159,6 +191,18 @@ void InspectorTargetAgent::didCommitProvisionalTarget(const String& oldTargetID,
 | |
|      m_frontendDispatcher->didCommitProvisionalTarget(oldTargetID, committedTargetID);
 | |
|  }
 | |
|  
 | |
| +void InspectorTargetAgent::ensureConnected(const String& targetID)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +
 | |
| +    auto* target = m_targets.get(targetID);
 | |
| +    if (!target)
 | |
| +        return;
 | |
| +
 | |
| +    target->connect(connectionType());
 | |
| +}
 | |
| +
 | |
|  FrontendChannel::ConnectionType InspectorTargetAgent::connectionType() const
 | |
|  {
 | |
|      return m_router.hasLocalFrontend() ? Inspector::FrontendChannel::ConnectionType::Local : Inspector::FrontendChannel::ConnectionType::Remote;
 | |
| diff --git a/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.h
 | |
| index b929ddffe29c3fb088ab6714087c99302c275214..2670ff3ba9b15afd2bb99993c3240c49b24907f5 100644
 | |
| --- a/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.h
 | |
| +++ b/Source/JavaScriptCore/inspector/agents/InspectorTargetAgent.h
 | |
| @@ -52,15 +52,21 @@ public:
 | |
|      void setPauseOnStart(ErrorString&, bool pauseOnStart) final;
 | |
|      void resume(ErrorString&, const String& targetId) final;
 | |
|      void sendMessageToTarget(ErrorString&, const String& targetId, const String& message) final;
 | |
| +    void activate(ErrorString&, const String& targetId) override;
 | |
| +    void close(ErrorString&, const String& targetId, const bool* runBeforeUnload) override;
 | |
|  
 | |
|      // Target lifecycle.
 | |
|      void targetCreated(InspectorTarget&);
 | |
|      void targetDestroyed(InspectorTarget&);
 | |
| +    void targetCrashed(InspectorTarget&);
 | |
|      void didCommitProvisionalTarget(const String& oldTargetID, const String& committedTargetID);
 | |
| +    void ensureConnected(const String& targetID);
 | |
|  
 | |
|      // Target messages.
 | |
|      void sendMessageFromTargetToFrontend(const String& targetId, const String& message);
 | |
|  
 | |
| +    bool isConnected() { return m_isConnected; }
 | |
| +
 | |
|  private:
 | |
|      // FrontendChannel
 | |
|      FrontendChannel::ConnectionType connectionType() const;
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/DOM.json b/Source/JavaScriptCore/inspector/protocol/DOM.json
 | |
| index 38cb48bedf2b168149ff79423b7fafc1e63ce8b3..e3d044934f5a0dc2331534439daa53116019548f 100644
 | |
| --- a/Source/JavaScriptCore/inspector/protocol/DOM.json
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/DOM.json
 | |
| @@ -79,6 +79,16 @@
 | |
|                  { "name": "value", "type": "string", "description": "The value that is resolved to with this data binding relationship." }
 | |
|              ]
 | |
|          },
 | |
| +        {
 | |
| +          "id": "Rect",
 | |
| +          "type": "object",
 | |
| +          "properties": [
 | |
| +            { "name": "x", "type": "integer", "description": "X coordinate" },
 | |
| +            { "name": "y", "type": "integer", "description": "Y coordinate" },
 | |
| +            { "name": "width", "type": "integer", "description": "Rectangle width" },
 | |
| +            { "name": "height", "type": "integer", "description": "Rectangle height" }
 | |
| +      ]
 | |
| +        },
 | |
|          {
 | |
|              "id": "EventListener",
 | |
|              "type": "object",
 | |
| @@ -167,6 +177,16 @@
 | |
|                  { "name": "borderColor", "$ref": "RGBAColor", "optional": true, "description": "The border highlight fill color (default: transparent)." },
 | |
|                  { "name": "marginColor", "$ref": "RGBAColor", "optional": true, "description": "The margin highlight fill color (default: transparent)." }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "FilePayload",
 | |
| +            "type": "object",
 | |
| +            "description": "Data to construct File object.",
 | |
| +            "properties": [
 | |
| +                { "name": "name", "type": "string", "description": "File name." },
 | |
| +                { "name": "type", "type": "string", "description": "File type." },
 | |
| +                { "name": "data", "type": "string", "description": "Base64-encoded file data." }
 | |
| +            ]
 | |
|          }
 | |
|      ],
 | |
|      "commands": [
 | |
| @@ -481,7 +501,9 @@
 | |
|              "name": "resolveNode",
 | |
|              "description": "Resolves JavaScript node object for given node id.",
 | |
|              "parameters": [
 | |
| -                { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node to resolve." },
 | |
| +                { "name": "nodeId", "$ref": "NodeId", "optional": true, "description": "Id of the node to resolve." },
 | |
| +                { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "optional": true, "description": "Source element handle." },
 | |
| +                { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "optional": true, "description": "Specifies in which execution context to adopt to." },
 | |
|                  { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }
 | |
|              ],
 | |
|              "returns": [
 | |
| @@ -542,6 +564,45 @@
 | |
|              "parameters": [
 | |
|                  { "name": "allow", "type": "boolean" }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "describeNode",
 | |
| +            "description": "Returns node description.",
 | |
| +            "parameters": [
 | |
| +                { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "JavaScript object id of the node wrapper." }
 | |
| +            ],
 | |
| +            "returns": [
 | |
| +                { "name": "contentFrameId", "$ref": "Network.FrameId", "optional": true, "description": "Frame ID for frame owner elements." },
 | |
| +                { "name": "ownerFrameId", "$ref": "Network.FrameId", "optional": true, "description": "ID of the owning frame element." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +          "name": "scrollIntoViewIfNeeded",
 | |
| +          "description": "Scrolls the given rect into view if not already in the viewport.",
 | |
| +          "parameters": [
 | |
| +              { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "JavaScript object id of the node wrapper." },
 | |
| +              { "name": "rect", "$ref": "Rect", "optional": true, "description": "Rect relative to the node's border box, in CSS pixels." }
 | |
| +          ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "getContentQuads",
 | |
| +            "description": "Returns quads that describe node position on the page. This method\nmight return multiple quads for inline nodes.",
 | |
| +            "parameters": [
 | |
| +                { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "JavaScript object id of the node wrapper." }
 | |
| +            ],
 | |
| +            "returns": [
 | |
| +                {
 | |
| +                    "name": "quads", "type": "array", "items": { "$ref": "Quad" }, "description": "Quads that describe node layout relative to viewport."
 | |
| +                }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setInputFiles",
 | |
| +            "description": "Sets input files for given <input type=file>",
 | |
| +            "parameters": [
 | |
| +                { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Input element handle." },
 | |
| +                { "name": "files", "type": "array", "items": { "$ref": "FilePayload" }, "description": "Files to set" }
 | |
| +            ]
 | |
|          }
 | |
|      ],
 | |
|      "events": [
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Dialog.json b/Source/JavaScriptCore/inspector/protocol/Dialog.json
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..79edea03fed4e9be5da96e1275e182a479cb7a0a
 | |
| --- /dev/null
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Dialog.json
 | |
| @@ -0,0 +1,36 @@
 | |
| +{
 | |
| +    "domain": "Dialog",
 | |
| +    "description": "Actions and events related to alert boxes.",
 | |
| +    "availability": ["web"],
 | |
| +    "types": [
 | |
| +    ],
 | |
| +    "commands": [
 | |
| +        {
 | |
| +            "name": "enable",
 | |
| +            "description": "Enables dialog domain notifications."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "disable",
 | |
| +            "description": "Disables dialog domain notifications."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "handleJavaScriptDialog",
 | |
| +            "description": "Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).",
 | |
| +            "parameters": [
 | |
| +                { "name": "accept", "type": "boolean", "description": "Whether to accept or dismiss the dialog."},
 | |
| +                { "name": "promptText", "optional": true, "type": "string", "description": "The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog."}
 | |
| +            ]
 | |
| +        }
 | |
| +    ],
 | |
| +    "events": [
 | |
| +        {
 | |
| +            "name": "javascriptDialogOpening",
 | |
| +            "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to open.",
 | |
| +            "parameters": [
 | |
| +                { "name": "type", "type": "string", "description": "Dialog type."},
 | |
| +                { "name": "message", "type": "string", "description": "Message that will be displayed by the dialog."},
 | |
| +                { "name": "defaultPrompt", "optional": true, "type": "string", "description": "Default dialog prompt."}
 | |
| +            ]
 | |
| +        }
 | |
| +    ]
 | |
| +}
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Emulation.json b/Source/JavaScriptCore/inspector/protocol/Emulation.json
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..3f28f8e41b39c517369c8ca69415486a75657489
 | |
| --- /dev/null
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Emulation.json
 | |
| @@ -0,0 +1,51 @@
 | |
| +{
 | |
| +    "domain": "Emulation",
 | |
| +    "availability": ["web"],
 | |
| +    "commands": [
 | |
| +        {
 | |
| +            "name": "setDeviceMetricsOverride",
 | |
| +            "description": "Overrides device metrics with provided values.",
 | |
| +            "async": true,
 | |
| +            "parameters": [
 | |
| +                { "name": "width", "type": "integer" },
 | |
| +                { "name": "height", "type": "integer" },
 | |
| +                { "name": "deviceScaleFactor", "type": "number" },
 | |
| +                { "name": "fixedLayout", "type": "boolean" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setJavaScriptEnabled",
 | |
| +            "description": "Allows to disable script execution for the page.",
 | |
| +            "parameters": [
 | |
| +                { "name": "enabled", "type": "boolean" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setAuthCredentials",
 | |
| +            "description": "Credentials to use during HTTP authentication.",
 | |
| +            "parameters": [
 | |
| +                { "name": "username", "type": "string", "optional": true },
 | |
| +                { "name": "password", "type": "string", "optional": true }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setActiveAndFocused",
 | |
| +            "description": "Makes page focused for test.",
 | |
| +            "parameters": [
 | |
| +                { "name": "active", "type": "boolean", "optional": true }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "grantPermissions",
 | |
| +            "parameters": [
 | |
| +                { "name": "origin", "type": "string" },
 | |
| +                { "name": "permissions", "type": "array", "items": { "type": "string" } }
 | |
| +            ],
 | |
| +            "description": "Overrides the permissions."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "resetPermissions",
 | |
| +            "description": "Clears permission overrides."
 | |
| +        }
 | |
| +    ]
 | |
| +}
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Input.json b/Source/JavaScriptCore/inspector/protocol/Input.json
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..34909cce9f6d8d7c74be4c96e40f80cadb2f931d
 | |
| --- /dev/null
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Input.json
 | |
| @@ -0,0 +1,165 @@
 | |
| +{
 | |
| +    "domain": "Input",
 | |
| +    "availability": ["web"],
 | |
| +    "types": [
 | |
| +        {
 | |
| +            "id": "TimeSinceEpoch",
 | |
| +            "description": "UTC time in seconds, counted from January 1, 1970.",
 | |
| +            "type": "number"
 | |
| +        }
 | |
| +    ],
 | |
| +    "commands": [
 | |
| +        {
 | |
| +            "name": "dispatchKeyEvent",
 | |
| +            "description": "Dispatches a key event to the page.",
 | |
| +            "async": true,
 | |
| +            "parameters": [
 | |
| +                {
 | |
| +                    "name": "type",
 | |
| +                    "description": "Type of the key event.",
 | |
| +                    "type": "string",
 | |
| +                    "enum": [
 | |
| +                        "keyDown",
 | |
| +                        "keyUp"
 | |
| +                    ]
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "modifiers",
 | |
| +                    "description": "Bit field representing pressed modifier keys. (default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "text",
 | |
| +                    "description": "Text as generated by processing a virtual key code with a keyboard layout. Not needed for\nfor `keyUp` and `rawKeyDown` events (default: \"\")",
 | |
| +                    "optional": true,
 | |
| +                    "type": "string"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "unmodifiedText",
 | |
| +                    "description": "Text that would have been generated by the keyboard if no modifiers were pressed (except for\nshift). Useful for shortcut (accelerator) key handling (default: \"\").",
 | |
| +                    "optional": true,
 | |
| +                    "type": "string"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "code",
 | |
| +                    "description": "Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: \"\").",
 | |
| +                    "optional": true,
 | |
| +                    "type": "string"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "key",
 | |
| +                    "description": "Unique DOM defined string value describing the meaning of the key in the context of active\nmodifiers, keyboard layout, etc (e.g., 'AltGr') (default: \"\").",
 | |
| +                    "optional": true,
 | |
| +                    "type": "string"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "windowsVirtualKeyCode",
 | |
| +                    "description": "Windows virtual key code (default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "nativeVirtualKeyCode",
 | |
| +                    "description": "Native virtual key code (default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "autoRepeat",
 | |
| +                    "description": "Whether the event was generated from auto repeat (default: false).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "boolean"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "isKeypad",
 | |
| +                    "description": "Whether the event was generated from the keypad (default: false).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "boolean"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "isSystemKey",
 | |
| +                    "description": "Whether the event was a system key event (default: false).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "boolean"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "macCommands",
 | |
| +                    "description": "Mac editing commands associated with this key",
 | |
| +                    "type": "array",
 | |
| +                    "optional": true,
 | |
| +                    "items": {
 | |
| +                      "type": "string"
 | |
| +                    }
 | |
| +                }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "dispatchMouseEvent",
 | |
| +            "description": "Dispatches a mouse event to the page.",
 | |
| +            "async": true,
 | |
| +            "parameters": [
 | |
| +                {
 | |
| +                    "name": "type",
 | |
| +                    "description": "Type of the mouse event.",
 | |
| +                    "type": "string",
 | |
| +                    "enum": [ "move", "down", "up", "wheel"]
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "x",
 | |
| +                    "description": "X coordinate of the event relative to the main frame's viewport in CSS pixels.",
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "y",
 | |
| +                    "description": "Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to\nthe top of the viewport and Y increases as it proceeds towards the bottom of the viewport.",
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "modifiers",
 | |
| +                    "description": "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8\n(default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "button",
 | |
| +                    "description": "Mouse button (default: \"none\").",
 | |
| +                    "optional": true,
 | |
| +                    "type": "string",
 | |
| +                    "enum": [
 | |
| +                        "none",
 | |
| +                        "left",
 | |
| +                        "middle",
 | |
| +                        "right",
 | |
| +                        "back",
 | |
| +                        "forward"
 | |
| +                    ]
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "buttons",
 | |
| +                    "description": "A number indicating which buttons are pressed on the mouse when a mouse event is triggered.\nLeft=1, Right=2, Middle=4, Back=8, Forward=16, None=0.",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "clickCount",
 | |
| +                    "description": "Number of times the mouse button was clicked (default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "deltaX",
 | |
| +                    "description": "X delta in CSS pixels for mouse wheel event (default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "deltaY",
 | |
| +                    "description": "Y delta in CSS pixels for mouse wheel event (default: 0).",
 | |
| +                    "optional": true,
 | |
| +                    "type": "integer"
 | |
| +                }
 | |
| +            ]
 | |
| +        }
 | |
| +    ]
 | |
| +}
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Network.json b/Source/JavaScriptCore/inspector/protocol/Network.json
 | |
| index 777a54166ed6664561b3f8249a6abb4ac59d0480..e738f34f65fa8137a16bf7b66bc237b85b2f5208 100644
 | |
| --- a/Source/JavaScriptCore/inspector/protocol/Network.json
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Network.json
 | |
| @@ -231,7 +231,8 @@
 | |
|              "name": "setInterceptionEnabled",
 | |
|              "description": "Enable interception of network requests.",
 | |
|              "parameters": [
 | |
| -                { "name": "enabled", "type": "boolean" }
 | |
| +                { "name": "enabled", "type": "boolean" },
 | |
| +                { "name": "interceptRequests", "type": "boolean", "optional": true }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
| @@ -258,7 +259,18 @@
 | |
|              "name": "interceptContinue",
 | |
|              "description": "Continue an interception with no modifications.",
 | |
|              "parameters": [
 | |
| -                { "name": "requestId", "$ref": "RequestId", "description": "Identifier for the intercepted Network request or response to continue." }
 | |
| +                { "name": "requestId", "$ref": "RequestId", "description": "Identifier for the intercepted Network request or response to continue." },
 | |
| +                { "name": "method", "type": "string", "optional": true,"description": "HTTP request method." },
 | |
| +                { "name": "headers", "$ref": "Headers", "optional": true, "description": "HTTP response headers. Pass through original values if unmodified." },
 | |
| +                { "name": "postData", "type": "string", "optional": true, "description": "HTTP POST request data." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "interceptAsError",
 | |
| +            "description": "Abort the intercepted request with given reason.",
 | |
| +            "parameters": [
 | |
| +                { "name": "requestId", "$ref": "RequestId", "description": "Identifier for the intercepted Network request." },
 | |
| +                { "name": "reason", "type": "string", "description": "Deliver error reason for the request." }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
| @@ -266,13 +278,20 @@
 | |
|              "description": "Provide response content for an intercepted response.",
 | |
|              "parameters": [
 | |
|                  { "name": "requestId", "$ref": "RequestId", "description": "Identifier for the intercepted Network response to modify." },
 | |
| -                { "name": "content", "type": "string" },
 | |
| -                { "name": "base64Encoded", "type": "boolean", "description": "True, if content was sent as base64." },
 | |
| +                { "name": "content", "type": "string", "optional": true },
 | |
| +                { "name": "base64Encoded", "type": "boolean", "optional": true, "description": "True, if content was sent as base64." },
 | |
|                  { "name": "mimeType", "type": "string", "optional": true, "description": "MIME Type for the data." },
 | |
|                  { "name": "status", "type": "integer", "optional": true, "description": "HTTP response status code. Pass through original values if unmodified." },
 | |
|                  { "name": "statusText", "type": "string", "optional": true, "description": "HTTP response status text. Pass through original values if unmodified." },
 | |
|                  { "name": "headers", "$ref": "Headers", "optional": true, "description": "HTTP response headers. Pass through original values if unmodified." }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setEmulateOfflineState",
 | |
| +            "description": "Emulate offline state overriding the actual state.",
 | |
| +            "parameters": [
 | |
| +                { "name": "offline", "type": "boolean", "description": "True to emulate offline." }
 | |
| +            ]
 | |
|          }
 | |
|      ],
 | |
|      "events": [
 | |
| @@ -356,6 +375,14 @@
 | |
|                  { "name": "response", "$ref": "Response", "description": "Original response content that would proceed if this is continued." }
 | |
|              ]
 | |
|          },
 | |
| +        {
 | |
| +            "name": "requestIntercepted",
 | |
| +            "description": "Fired when HTTP request has been intercepted. The frontend must response with <code>Network.interceptContinue</code> or <code>Network.interceptWithRespons</code>` to continue this response.",
 | |
| +            "parameters": [
 | |
| +                { "name": "requestId", "$ref": "RequestId", "description": "Identifier for this intercepted network. Corresponds with an earlier <code>Network.requestWillBeSent</code>." },
 | |
| +                { "name": "request", "$ref": "Request", "description": "Original request content that would proceed if this is continued." }
 | |
| +            ]
 | |
| +        },
 | |
|          {
 | |
|              "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 d27512a4f00779b8f1171999953fdc76107a9815..8fc6eebd1677a0acf548aaeb9f78c5856847553f 100644
 | |
| --- a/Source/JavaScriptCore/inspector/protocol/Page.json
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Page.json
 | |
| @@ -111,6 +111,41 @@
 | |
|                  { "name": "secure", "type": "boolean", "description": "True if cookie is secure." },
 | |
|                  { "name": "sameSite", "$ref": "CookieSameSitePolicy", "description": "Cookie Same-Site policy." }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "AXNode",
 | |
| +            "type": "object",
 | |
| +            "description": "Accessibility Node",
 | |
| +            "properties": [
 | |
| +                { "name": "role", "type": "string", "description": "The role."},
 | |
| +                { "name": "name", "type": "string","optional": true, "description": "A human readable name for the node."},
 | |
| +                { "name": "value", "type": "any", "optional": true, "description": "The current value of the node."},
 | |
| +                { "name": "description", "type": "string", "optional": true, "description": "An additional human readable description of the node."},
 | |
| +                { "name": "keyshortcuts", "type": "string", "optional": true, "description": "Keyboard shortcuts associated with this node."},
 | |
| +                { "name": "roledescription", "type": "string", "optional": true, "description": "A human readable alternative to the role."},
 | |
| +                { "name": "valuetext", "type": "string", "optional": true, "description": "A description of the current value."},
 | |
| +                { "name": "disabled", "type": "boolean", "optional": true, "description": "Whether the node is disabled."},
 | |
| +                { "name": "expanded", "type": "boolean", "optional": true, "description": "Whether the node is expanded or collapsed."},
 | |
| +                { "name": "focused", "type": "boolean", "optional": true, "description": "Whether the node is focused."},
 | |
| +                { "name": "modal", "type": "boolean", "optional": true, "description": "Whether the node is modal."},
 | |
| +                { "name": "multiline", "type": "boolean", "optional": true, "description": "Whether the node text input supports multiline."},
 | |
| +                { "name": "multiselectable", "type": "boolean", "optional": true, "description": "Whether more than one child can be selected."},
 | |
| +                { "name": "readonly", "type": "boolean", "optional": true, "description": "Whether the node is read only."},
 | |
| +                { "name": "required", "type": "boolean", "optional": true, "description": "Whether the node is required."},
 | |
| +                { "name": "selected", "type": "boolean", "optional": true, "description": "Whether the node is selected in its parent node."},
 | |
| +                { "name": "checked", "type": "string", "optional": true, "enum": ["true", "false", "mixed"], "description": "Whether the checkbox is checked, or \"mixed\"."},
 | |
| +                { "name": "pressed", "type": "string", "optional": true, "enum": ["true", "false", "mixed"], "description": "Whether the toggle button is checked, or \"mixed\"."},
 | |
| +                { "name": "level", "type": "integer", "optional": true, "description": "The level of a heading."},
 | |
| +                { "name": "valuemin", "type": "number", "optional": true, "description": "The minimum value in a node."},
 | |
| +                { "name": "valuemax", "type": "number", "optional": true, "description": "The maximum value in a node."},
 | |
| +                { "name": "autocomplete", "type": "string", "optional": true, "description": "What kind of autocomplete is supported by a control."},
 | |
| +                { "name": "haspopup", "type": "string", "optional": true, "description": "What kind of popup is currently being shown for a node."},
 | |
| +                { "name": "invalid", "type": "string", "optional": true, "enum": ["true", "false", "grammar", "spelling"], "description": "Whether and in what way this node's value is invalid."},
 | |
| +                { "name": "orientation", "type": "string", "optional": true, "description": "Whether the node is oriented horizontally or vertically."},
 | |
| +                { "name": "focusable", "type": "boolean", "optional": true, "description": "Whether the node is focusable."},
 | |
| +                { "name": "children", "type": "array", "optional": true, "items": { "$ref": "AXNode"}, "description": "Child AXNodes of this node, if any."},
 | |
| +                { "name": "found", "type": "boolean", "optional": true, "description": "True if this AXNode corresponds with the ObjectId passed into acessibilitySnapshot."}
 | |
| +            ]
 | |
|          }
 | |
|      ],
 | |
|      "commands": [
 | |
| @@ -130,11 +165,21 @@
 | |
|                  { "name": "revalidateAllResources", "type": "boolean", "optional": true, "description": "If true, all cached subresources will be revalidated when the main resource loads. Otherwise, only expired cached subresources will be revalidated (the default behavior for most WebKit clients)." }
 | |
|              ]
 | |
|          },
 | |
| +        {
 | |
| +            "name": "goBack",
 | |
| +            "description": "Goes back in the history."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "goForward",
 | |
| +            "description": "Goes forward in the history."
 | |
| +        },
 | |
|          {
 | |
|              "name": "navigate",
 | |
|              "description": "Navigates current page to the given URL.",
 | |
|              "parameters": [
 | |
| -                { "name": "url", "type": "string", "description": "URL to navigate the page to." }
 | |
| +                { "name": "url", "type": "string", "description": "URL to navigate the page to." },
 | |
| +                { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "Id of the frame to navigate."},
 | |
| +                { "name": "referrer", "type": "string", "optional": true, "description": "Referrer URL." }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
| @@ -254,6 +299,20 @@
 | |
|                  { "name": "appearance", "$ref": "Appearance", "description": "Appearance name to force. Empty string disables the override." }
 | |
|              ]
 | |
|          },
 | |
| +        {
 | |
| +            "name": "setTimeZone",
 | |
| +            "description": "Enables time zone emulation.",
 | |
| +            "parameters": [
 | |
| +                { "name": "timeZone", "type": "string", "optional": true }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setTouchEmulationEnabled",
 | |
| +            "description": "Enables touch events on platforms that lack them.",
 | |
| +            "parameters": [
 | |
| +                {"name": "enabled", "type": "boolean", "description": "Whether touch should be enabled."}
 | |
| +            ]
 | |
| +        },
 | |
|          {
 | |
|              "name": "snapshotNode",
 | |
|              "description": "Capture a snapshot of the specified node that does not include unrelated layers.",
 | |
| @@ -284,19 +343,92 @@
 | |
|              "returns": [
 | |
|                  { "name": "data", "type": "string", "description": "Base64-encoded web archive." }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "insertText",
 | |
| +            "description": "Insert text into the current selection of the page.",
 | |
| +            "parameters": [
 | |
| +                { "name": "text", "type": "string", "description": "Text to insert." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "accessibilitySnapshot",
 | |
| +            "description": "Serializes and returns all of the accessibility nodes of the page.",
 | |
| +            "parameters": [
 | |
| +                { "name": "objectId", "type": "string", "optional": true, "description": "Object Id of a node to find in the accessibility tree."}
 | |
| +            ],
 | |
| +            "returns": [
 | |
| +                { "name": "axNode", "$ref": "AXNode", "description": "The root AXNode."}
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setInterceptFileChooserDialog",
 | |
| +            "description": "Intercepts file chooser dialog",
 | |
| +            "parameters": [
 | |
| +                { "name": "enabled", "type": "boolean", "description": "True to enable." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setDefaultBackgroundColorOverride",
 | |
| +            "description": "Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.",
 | |
| +            "parameters": [
 | |
| +                { "name": "color", "$ref": "DOM.RGBAColor", "optional": true, "description": "RGBA of the default background color. If not specified, any existing override will be cleared." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "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": "setBypassCSP",
 | |
| +            "description": "Enable page Content Security Policy by-passing.",
 | |
| +            "parameters": [
 | |
| +                { "name": "enabled", "type": "boolean", "description": "Whether to bypass page CSP." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "crash",
 | |
| +            "description": "Crashes the page process"
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setScreenSizeOverride",
 | |
| +            "description": "Overrides screen size with provided values.",
 | |
| +            "parameters": [
 | |
| +                { "name": "width", "type": "integer" },
 | |
| +                { "name": "height", "type": "integer" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setOrientationOverride",
 | |
| +            "description": "Overrides window.orientation with provided value.",
 | |
| +            "parameters": [
 | |
| +                { "name": "angle", "type": "integer", "optional": true }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setActivityPaused",
 | |
| +            "description": "Pauses page activity (active objects, animations).",
 | |
| +            "parameters": [
 | |
| +                { "name": "paused", "type": "boolean" }
 | |
| +            ]
 | |
|          }
 | |
|      ],
 | |
|      "events": [
 | |
|          {
 | |
|              "name": "domContentEventFired",
 | |
|              "parameters": [
 | |
| -                { "name": "timestamp", "type": "number" }
 | |
| +                { "name": "timestamp", "type": "number" },
 | |
| +                { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has fired DOMContentLoaded event." }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
|              "name": "loadEventFired",
 | |
|              "parameters": [
 | |
| -                { "name": "timestamp", "type": "number" }
 | |
| +              { "name": "timestamp", "type": "number" },
 | |
| +              { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has fired load event." }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
| @@ -306,6 +438,14 @@
 | |
|                  { "name": "frame", "$ref": "Frame", "description": "Frame object." }
 | |
|              ]
 | |
|          },
 | |
| +        {
 | |
| +          "name": "frameAttached",
 | |
| +          "description": "Fired when frame has been attached to its parent.",
 | |
| +          "parameters": [
 | |
| +              { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has been detached." },
 | |
| +              { "name": "parentFrameId", "$ref": "Network.FrameId", "optional": true, "description": "Parent frame id if non-root." }
 | |
| +          ]
 | |
| +        },
 | |
|          {
 | |
|              "name": "frameDetached",
 | |
|              "description": "Fired when frame has been detached from its parent.",
 | |
| @@ -342,12 +482,50 @@
 | |
|                  { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }
 | |
|              ]
 | |
|          },
 | |
| +        {
 | |
| +            "name": "navigatedWithinDocument",
 | |
| +            "description": "Fired when same-document navigation happens, e.g. due to history API usage or anchor navigation.",
 | |
| +            "parameters": [
 | |
| +                {
 | |
| +                    "name": "frameId",
 | |
| +                    "description": "Id of the frame.",
 | |
| +                    "$ref": "Network.FrameId"
 | |
| +                },
 | |
| +                {
 | |
| +                    "name": "url",
 | |
| +                    "description": "Frame's new url.",
 | |
| +                    "type": "string"
 | |
| +                }
 | |
| +            ]
 | |
| +        },
 | |
|          {
 | |
|              "name": "defaultAppearanceDidChange",
 | |
|              "description": "Fired when page's default appearance changes, even if there is a forced appearance.",
 | |
|              "parameters": [
 | |
|                  { "name": "appearance", "$ref": "Appearance", "description": "Name of the appearance that is active (not considering any forced appearance.)" }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +          "name": "willRequestOpenWindow",
 | |
| +          "description": "Fired when page tries to open a new window.",
 | |
| +          "parameters": [
 | |
| +              { "name": "url", "type": "string" }
 | |
| +          ]
 | |
| +        },
 | |
| +        {
 | |
| +          "name": "didRequestOpenWindow",
 | |
| +          "description": "Fired after page did try to open a new window.",
 | |
| +          "parameters": [
 | |
| +              { "name": "opened", "type": "boolean" }
 | |
| +          ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "fileChooserOpened",
 | |
| +            "description": "Fired when the page shows file chooser for it's <input type=file>.",
 | |
| +            "parameters": [
 | |
| +                { "name": "frameId", "$ref": "Network.FrameId", "description": "Frame where file chooser is opened." },
 | |
| +                { "name": "element", "$ref": "Runtime.RemoteObject", "description": "Input element." }
 | |
| +            ]
 | |
|          }
 | |
|      ]
 | |
|  }
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Playwright.json b/Source/JavaScriptCore/inspector/protocol/Playwright.json
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..6b46980f8a8278b78cdd849b96f969434f397f71
 | |
| --- /dev/null
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Playwright.json
 | |
| @@ -0,0 +1,237 @@
 | |
| +{
 | |
| +    "domain": "Playwright",
 | |
| +    "availability": ["web"],
 | |
| +    "types": [
 | |
| +        {
 | |
| +            "id": "ContextID",
 | |
| +            "type": "string",
 | |
| +            "description": "Id of Browser context."
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "PageProxyID",
 | |
| +            "type": "string",
 | |
| +            "description": "Id of WebPageProxy."
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "PageProxyInfo",
 | |
| +            "type": "object",
 | |
| +            "description": "Tab info object",
 | |
| +            "properties": [
 | |
| +                { "name": "pageProxyId", "$ref": "PageProxyID" },
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "description": "Unique identifier of the context." },
 | |
| +                { "name": "openerId", "$ref": "PageProxyID", "optional": true, "description": "Unique identifier of the opening page. Only set for pages created by window.open()." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "CookieSameSitePolicy",
 | |
| +            "type": "string",
 | |
| +            "enum": ["None", "Lax", "Strict"],
 | |
| +            "description": "Same-Site policy of a cookie."
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "Cookie",
 | |
| +            "type": "object",
 | |
| +            "description": "Cookie object",
 | |
| +            "properties": [
 | |
| +                { "name": "name", "type": "string", "description": "Cookie name." },
 | |
| +                { "name": "value", "type": "string", "description": "Cookie value." },
 | |
| +                { "name": "domain", "type": "string", "description": "Cookie domain." },
 | |
| +                { "name": "path", "type": "string", "description": "Cookie path." },
 | |
| +                { "name": "expires", "type": "number", "description": "Cookie expires." },
 | |
| +                { "name": "httpOnly", "type": "boolean", "description": "True if cookie is http-only." },
 | |
| +                { "name": "secure", "type": "boolean", "description": "True if cookie is secure." },
 | |
| +                { "name": "session", "type": "boolean", "description": "True if cookie is session cookie." },
 | |
| +                { "name": "sameSite", "$ref": "CookieSameSitePolicy", "description": "Cookie Same-Site policy." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "SetCookieParam",
 | |
| +            "type": "object",
 | |
| +            "description": "Cookie object",
 | |
| +            "properties": [
 | |
| +                { "name": "name", "type": "string", "description": "Cookie name." },
 | |
| +                { "name": "value", "type": "string", "description": "Cookie value." },
 | |
| +                { "name": "domain", "type": "string", "description": "Cookie domain." },
 | |
| +                { "name": "path", "type": "string", "description": "Cookie path." },
 | |
| +                { "name": "expires", "type": "number", "optional": true, "description": "Cookie expires." },
 | |
| +                { "name": "httpOnly", "type": "boolean", "optional": true, "description": "True if cookie is http-only." },
 | |
| +                { "name": "secure", "type": "boolean", "optional": true, "description": "True if cookie is secure." },
 | |
| +                { "name": "session", "type": "boolean", "optional": true, "description": "True if cookie is session cookie." },
 | |
| +                { "name": "sameSite", "$ref": "CookieSameSitePolicy", "optional": true, "description": "Cookie Same-Site policy." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "id": "Geolocation",
 | |
| +            "type": "object",
 | |
| +            "description": "Geolocation",
 | |
| +            "properties": [
 | |
| +                { "name": "timestamp", "type": "number", "description": "Mock latitude" },
 | |
| +                { "name": "latitude", "type": "number", "description": "Mock latitude" },
 | |
| +                { "name": "longitude", "type": "number", "description": "Mock longitude" },
 | |
| +                { "name": "accuracy", "type": "number", "description": "Mock accuracy" }
 | |
| +            ]
 | |
| +        }
 | |
| +    ],
 | |
| +    "commands": [
 | |
| +        {
 | |
| +            "name": "close",
 | |
| +            "async": true,
 | |
| +            "description": "Close browser."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "createContext",
 | |
| +            "description": "Creates new ephemeral browser context.",
 | |
| +            "returns": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "description": "Unique identifier of the context." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "deleteContext",
 | |
| +            "async": true,
 | |
| +            "description": "Deletes browser context previously created with createContect. The command will automatically close all pages that use the context.",
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "description": "Identifier of the context to delete." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "createPage",
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "JSON Inspector Protocol message (command) to be dispatched on the backend." }
 | |
| +            ],
 | |
| +            "returns": [
 | |
| +                { "name": "pageProxyId", "$ref": "PageProxyID", "description": "Unique identifier of the page proxy." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "navigate",
 | |
| +            "async": true,
 | |
| +            "description": "Navigates current page to the given URL.",
 | |
| +            "parameters": [
 | |
| +                { "name": "url", "type": "string", "description": "URL to navigate the page to." },
 | |
| +                { "name": "pageProxyId", "$ref": "PageProxyID", "description": "Unique identifier of the page proxy." },
 | |
| +                { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "Id of the frame to navigate."},
 | |
| +                { "name": "referrer", "type": "string", "optional": true, "description": "Referrer URL." }
 | |
| +            ],
 | |
| +            "returns": [
 | |
| +                { "name": "loaderId", "$ref": "Network.LoaderId", "optional": true, "description": "Identifier of the loader associated with the navigation." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setIgnoreCertificateErrors",
 | |
| +            "description": "Change whether all certificate errors should be ignored.",
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." },
 | |
| +                { "name": "ignore", "type": "boolean" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "getAllCookies",
 | |
| +            "description": "Returns all cookies in the given browser context.",
 | |
| +            "async": true,
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." }
 | |
| +            ],
 | |
| +            "returns": [
 | |
| +                { "name": "cookies", "type": "array", "items": { "$ref": "Cookie" }, "description": "Cookies." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setCookies",
 | |
| +            "description": "Sets cookies in the given browser context.",
 | |
| +            "async": true,
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." },
 | |
| +                { "name": "cookies", "type": "array", "items": { "$ref": "SetCookieParam" }, "description": "Cookies." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "deleteAllCookies",
 | |
| +            "description": "Deletes cookies in the given browser context.",
 | |
| +            "async": true,
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setGeolocationOverride",
 | |
| +            "parameters": [
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." },
 | |
| +                { "name": "geolocation", "$ref": "Geolocation", "optional": true, "description": "Geolocation to set, if missing emulates position unavailable." }
 | |
| +            ],
 | |
| +            "description": "Overrides the geolocation position or error."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setLanguages",
 | |
| +            "description": "Allows to set locale language for context.",
 | |
| +            "parameters": [
 | |
| +                { "name": "languages", "type": "array", "items": { "type": "string" } },
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "setDownloadBehavior",
 | |
| +            "description": "Allows to override download behavior.",
 | |
| +            "parameters": [
 | |
| +                { "name": "behavior", "optional": true, "type": "string", "enum": ["allow", "deny"] },
 | |
| +                { "name": "downloadPath", "optional": true, "type": "string" },
 | |
| +                { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." }
 | |
| +            ]
 | |
| +        }
 | |
| +    ],
 | |
| +    "events": [
 | |
| +        {
 | |
| +            "name": "pageProxyCreated",
 | |
| +            "parameters": [
 | |
| +                { "name": "pageProxyInfo", "$ref": "PageProxyInfo" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "pageProxyDestroyed",
 | |
| +            "parameters": [
 | |
| +                { "name": "pageProxyId", "$ref": "PageProxyID" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "provisionalLoadFailed",
 | |
| +            "description": "Fired when provisional load fails.",
 | |
| +            "parameters": [
 | |
| +                { "name": "pageProxyId", "$ref": "PageProxyID", "description": "Unique identifier of the page proxy." },
 | |
| +                { "name": "loaderId", "$ref": "Network.LoaderId", "description": "Identifier of the loader associated with the navigation." },
 | |
| +                { "name": "error", "type": "string", "description": "Localized error string." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +          "name": "windowOpen",
 | |
| +          "description": "Fired when page opens a new window.",
 | |
| +          "parameters": [
 | |
| +              { "name": "pageProxyId", "$ref": "PageProxyID", "description": "Unique identifier of the page proxy." },
 | |
| +              { "name": "url", "type": "string" },
 | |
| +              { "name": "windowFeatures", "type": "array", "items": { "type": "string" } }
 | |
| +          ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "downloadCreated",
 | |
| +            "parameters": [
 | |
| +                { "name": "uuid", "type": "string" },
 | |
| +                { "name": "url", "type": "string" },
 | |
| +                { "name": "pageProxyId", "$ref": "PageProxyID", "description": "Unique identifier of the page proxy." },
 | |
| +                { "name": "browserContextId", "$ref": "ContextID" },
 | |
| +                { "name": "frameId", "$ref": "Network.FrameId", "description": "Unique identifier of the originating frame." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "downloadFilenameSuggested",
 | |
| +            "parameters": [
 | |
| +                { "name": "uuid", "type": "string" },
 | |
| +                { "name": "suggestedFilename", "type": "string" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "downloadFinished",
 | |
| +            "parameters": [
 | |
| +                { "name": "uuid", "type": "string" },
 | |
| +                { "name": "error", "type": "string" }
 | |
| +            ]
 | |
| +        }
 | |
| +    ]
 | |
| +}
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Screencast.json b/Source/JavaScriptCore/inspector/protocol/Screencast.json
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..dd8bc8a94df9f3ffe5be0686c2a58eb412351f6d
 | |
| --- /dev/null
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Screencast.json
 | |
| @@ -0,0 +1,38 @@
 | |
| +{
 | |
| +    "domain": "Screencast",
 | |
| +    "availability": ["web"],
 | |
| +    "types": [
 | |
| +        {
 | |
| +            "id": "ImageFormat",
 | |
| +            "type": "string",
 | |
| +            "enum": ["jpeg", "png"]
 | |
| +        }
 | |
| +    ],
 | |
| +    "commands": [
 | |
| +        {
 | |
| +            "name": "start",
 | |
| +            "description": "Starts screencast.",
 | |
| +            "parameters": [
 | |
| +                { "name": "format", "$ref": "ImageFormat", "description": "Frame data format." },
 | |
| +                { "name": "quality", "type": "integer", "optional": true, "description": "For JPEG quality from range [0..100]. Ignored for PNG." }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "stop",
 | |
| +            "description": "Stops screencast."
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "frameAck",
 | |
| +            "description": "Sent by the client when a frame has been received."
 | |
| +        }
 | |
| +    ],
 | |
| +    "events": [
 | |
| +        {
 | |
| +            "name": "frame",
 | |
| +            "description": "Event describing captured frame. The client is expcted to send frameAck in response.",
 | |
| +            "parameters": [
 | |
| +                { "name": "data", "type": "string", "description": "Base64-encoded image." }
 | |
| +            ]
 | |
| +        }
 | |
| +    ]
 | |
| +}
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Target.json b/Source/JavaScriptCore/inspector/protocol/Target.json
 | |
| index 52920cded24a9c6b0ef6fb4e518664955db4f9fa..bbbabc4e7259088b9404e8cc07eecd6f45077da0 100644
 | |
| --- a/Source/JavaScriptCore/inspector/protocol/Target.json
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Target.json
 | |
| @@ -10,7 +10,7 @@
 | |
|              "properties": [
 | |
|                  { "name": "targetId", "type": "string", "description": "Unique identifier for the target." },
 | |
|                  { "name": "type", "type": "string", "enum": ["page", "service-worker", "worker"] },
 | |
| -                { "name": "isProvisional", "type": "boolean", "optional": true, "description": "Whether this is a provisional page target." },
 | |
| +                { "name": "isProvisional", "type": "boolean", "optional": true, "description": "True value indicates that this is a provisional page target i.e. Such target may be created when current page starts cross-origin navigation. Eventually each provisional target is either committed and swaps with the current target or gets destroyed, e.g. in case of load request failure." },
 | |
|                  { "name": "isPaused", "type": "boolean", "optional": true, "description": "Whether the target is paused on start and has to be explicitely resumed by inspector." }
 | |
|              ]
 | |
|          }
 | |
| @@ -37,6 +37,21 @@
 | |
|                  { "name": "targetId", "type": "string" },
 | |
|                  { "name": "message", "type": "string", "description": "JSON Inspector Protocol message (command) to be dispatched on the backend." }
 | |
|              ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "activate",
 | |
| +            "description": "Reveals the target on screen.",
 | |
| +            "parameters": [
 | |
| +                { "name": "targetId", "type": "string" }
 | |
| +            ]
 | |
| +        },
 | |
| +        {
 | |
| +            "name": "close",
 | |
| +            "description": "Closes the target.",
 | |
| +            "parameters": [
 | |
| +                { "name": "targetId", "type": "string" },
 | |
| +                { "name": "runBeforeUnload", "type": "boolean", "optional": true }
 | |
| +            ]
 | |
|          }
 | |
|      ],
 | |
|      "events": [
 | |
| @@ -49,7 +64,8 @@
 | |
|          {
 | |
|              "name": "targetDestroyed",
 | |
|              "parameters": [
 | |
| -                { "name": "targetId", "type": "string" }
 | |
| +                { "name": "targetId", "type": "string" },
 | |
| +                { "name": "crashed", "type": "boolean" }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
| diff --git a/Source/JavaScriptCore/inspector/protocol/Worker.json b/Source/JavaScriptCore/inspector/protocol/Worker.json
 | |
| index 638612413466efc87b737e8a81042ed07ca12703..6f9e518ff0bfa2a6228675d25b6b785f1ed3022a 100644
 | |
| --- a/Source/JavaScriptCore/inspector/protocol/Worker.json
 | |
| +++ b/Source/JavaScriptCore/inspector/protocol/Worker.json
 | |
| @@ -16,7 +16,7 @@
 | |
|              "description": "Sent after the frontend has sent all initialization messages and can resume this worker. This command is required to allow execution in the worker.",
 | |
|              "parameters": [
 | |
|                  { "name": "workerId", "type": "string" }
 | |
| -            ]            
 | |
| +            ]
 | |
|          },
 | |
|          {
 | |
|              "name": "sendMessageToWorker",
 | |
| @@ -33,7 +33,8 @@
 | |
|              "parameters": [
 | |
|                  { "name": "workerId", "type": "string" },
 | |
|                  { "name": "url", "type": "string" },
 | |
| -                { "name": "name", "type": "string" }
 | |
| +                { "name": "name", "type": "string" },
 | |
| +                { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame this worker belongs to." }
 | |
|              ]
 | |
|          },
 | |
|          {
 | |
| diff --git a/Source/JavaScriptCore/runtime/DateConversion.cpp b/Source/JavaScriptCore/runtime/DateConversion.cpp
 | |
| index 955756ba405f400970610f9a68c7ed42a67cb015..1520c0a1475a90de2795e4ccd8919c1bb1384066 100644
 | |
| --- a/Source/JavaScriptCore/runtime/DateConversion.cpp
 | |
| +++ b/Source/JavaScriptCore/runtime/DateConversion.cpp
 | |
| @@ -100,17 +100,23 @@ String formatDateTime(const GregorianDateTime& t, DateTimeFormat format, bool as
 | |
|              appendNumber<2>(builder, offset / 60);
 | |
|              appendNumber<2>(builder, offset % 60);
 | |
|  
 | |
| -#if OS(WINDOWS)
 | |
| -            TIME_ZONE_INFORMATION timeZoneInformation;
 | |
| -            GetTimeZoneInformation(&timeZoneInformation);
 | |
| -            const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
 | |
| -            String timeZoneName(winTimeZoneName);
 | |
| +            String timeZoneName;
 | |
| +            if (!WTF::timeZoneDisplayNameForAutomation().isEmpty()) {
 | |
| +                timeZoneName = WTF::timeZoneDisplayNameForAutomation();
 | |
| +            } else {
 | |
| + #if OS(WINDOWS)
 | |
| +                TIME_ZONE_INFORMATION timeZoneInformation;
 | |
| +                GetTimeZoneInformation(&timeZoneInformation);
 | |
| +                const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
 | |
| +                timeZoneName = String(winTimeZoneName);
 | |
|  #else
 | |
| -            struct tm gtm = t;
 | |
| -            char timeZoneName[70];
 | |
| -            strftime(timeZoneName, sizeof(timeZoneName), "%Z", >m);
 | |
| +                struct tm gtm = t;
 | |
| +                char tzName[70];
 | |
| +                strftime(tzName, sizeof(tzName), "%Z", >m);
 | |
| +                timeZoneName = String(tzName);
 | |
|  #endif
 | |
| -            if (timeZoneName[0]) {
 | |
| +            }
 | |
| +            if (!timeZoneName.isEmpty()) {
 | |
|                  builder.appendLiteral(" (");
 | |
|                  builder.append(timeZoneName);
 | |
|                  builder.append(')');
 | |
| diff --git a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
 | |
| index deee885b011925087e29348deeb12b1fbdc5664b..e1fa396864bdf87bb0c5c3f79d8db36c08536f9d 100644
 | |
| --- a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
 | |
| +++ b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
 | |
| @@ -37,6 +37,7 @@
 | |
|  #include <unicode/ucal.h>
 | |
|  #include <unicode/udatpg.h>
 | |
|  #include <unicode/uenum.h>
 | |
| +#include <wtf/DateMath.h>
 | |
|  #include <wtf/text/StringBuilder.h>
 | |
|  #include <wtf/unicode/icu/ICUHelpers.h>
 | |
|  
 | |
| @@ -105,6 +106,10 @@ static ALWAYS_INLINE bool isUTCEquivalent(StringView timeZone)
 | |
|  // https://tc39.es/ecma402/#sec-defaulttimezone
 | |
|  static String defaultTimeZone()
 | |
|  {
 | |
| +    String tz = WTF::timeZoneForAutomation();
 | |
| +    if (!tz.isEmpty())
 | |
| +        return tz;
 | |
| +
 | |
|      String canonical;
 | |
|  
 | |
|      Vector<UChar, 32> buffer;
 | |
| diff --git a/Source/WTF/wtf/DateMath.cpp b/Source/WTF/wtf/DateMath.cpp
 | |
| index af92f674770349cc8e7be9a53b1cee6e7840e781..f0a960db046292a3505d339a333f03098f3d8418 100644
 | |
| --- a/Source/WTF/wtf/DateMath.cpp
 | |
| +++ b/Source/WTF/wtf/DateMath.cpp
 | |
| @@ -76,9 +76,14 @@
 | |
|  #include <limits>
 | |
|  #include <stdint.h>
 | |
|  #include <time.h>
 | |
| +#include <unicode/ucal.h>
 | |
|  #include <wtf/Assertions.h>
 | |
|  #include <wtf/ASCIICType.h>
 | |
| +#include <wtf/Language.h>
 | |
| +#include <wtf/NeverDestroyed.h>
 | |
| +#include <wtf/ThreadSpecific.h>
 | |
|  #include <wtf/text/StringBuilder.h>
 | |
| +#include <wtf/unicode/UTF8Conversion.h>
 | |
|  
 | |
|  #if OS(WINDOWS)
 | |
|  #include <windows.h>
 | |
| @@ -92,6 +97,18 @@ template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const c
 | |
|      return equalLettersIgnoringASCIICase(string, lowercaseLetters, length - 1);
 | |
|  }
 | |
|  
 | |
| +struct TimeZoneForAutomation {
 | |
| +    UCalendar* cal;
 | |
| +    String id;
 | |
| +    String displayName;
 | |
| +};
 | |
| +
 | |
| +static TimeZoneForAutomation& innerTimeZoneForAutomation()
 | |
| +{
 | |
| +    static NeverDestroyed<WTF::ThreadSpecific<TimeZoneForAutomation>> timeZoneForAutomation;
 | |
| +    return *timeZoneForAutomation.get();
 | |
| +}
 | |
| +
 | |
|  /* Constants */
 | |
|  
 | |
|  const char* const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
 | |
| @@ -318,6 +335,14 @@ static double calculateDSTOffset(time_t localTime, double utcOffset)
 | |
|  // Returns combined offset in millisecond (UTC + DST).
 | |
|  LocalTimeOffset calculateLocalTimeOffset(double ms, TimeType inputTimeType)
 | |
|  {
 | |
| +    TimeZoneForAutomation& tz = innerTimeZoneForAutomation();
 | |
| +    if (tz.cal) {
 | |
| +        UErrorCode status = U_ZERO_ERROR;
 | |
| +        ucal_setMillis(tz.cal, ms, &status);
 | |
| +        int32_t offset = ucal_get(tz.cal, UCAL_ZONE_OFFSET, &status);
 | |
| +        int32_t dstOffset = ucal_get(tz.cal, UCAL_DST_OFFSET, &status);
 | |
| +        return LocalTimeOffset(dstOffset, offset + dstOffset);
 | |
| +    }
 | |
|  #if HAVE(TM_GMTOFF)
 | |
|      double localToUTCTimeOffset = inputTimeType == LocalTime ? calculateUTCOffset() : 0;
 | |
|  #else
 | |
| @@ -1019,4 +1044,65 @@ String makeRFC2822DateString(unsigned dayOfWeek, unsigned day, unsigned month, u
 | |
|      return stringBuilder.toString();
 | |
|  }
 | |
|  
 | |
| +bool setTimeZoneForAutomation(const String& timeZone)
 | |
| +{
 | |
| +    innerTimeZoneForAutomation().displayName = String();
 | |
| +    if (innerTimeZoneForAutomation().cal) {
 | |
| +        ucal_close(innerTimeZoneForAutomation().cal);
 | |
| +        innerTimeZoneForAutomation().cal = nullptr;
 | |
| +    }
 | |
| +    if (timeZone.isEmpty()) {
 | |
| +        innerTimeZoneForAutomation().id = String();
 | |
| +        return true;
 | |
| +    }
 | |
| +
 | |
| +    // Timezone is ascii.
 | |
| +    Vector<UChar> buffer(timeZone.length());
 | |
| +    UChar* bufferStart = buffer.data();
 | |
| +    CString ctz = timeZone.utf8();
 | |
| +    if (!Unicode::convertUTF8ToUTF16(ctz.data(), ctz.data() + ctz.length(), &bufferStart, bufferStart + timeZone.length()))
 | |
| +        return false;
 | |
| +
 | |
| +    Vector<UChar, 32> canonicalBuffer(32);
 | |
| +    UErrorCode status = U_ZERO_ERROR;
 | |
| +    auto canonicalLength = ucal_getCanonicalTimeZoneID(buffer.data(), buffer.size(), canonicalBuffer.data(), canonicalBuffer.size(), nullptr, &status);
 | |
| +    if (status == U_BUFFER_OVERFLOW_ERROR) {
 | |
| +        status = U_ZERO_ERROR;
 | |
| +        canonicalBuffer.grow(canonicalLength);
 | |
| +        ucal_getCanonicalTimeZoneID(buffer.data(), buffer.size(), canonicalBuffer.data(), canonicalLength, nullptr, &status);
 | |
| +    }
 | |
| +    if (!U_SUCCESS(status))
 | |
| +        return false;
 | |
| +
 | |
| +    UCalendar* cal = ucal_open(canonicalBuffer.data(), canonicalLength, nullptr, UCAL_TRADITIONAL, &status);
 | |
| +    if (!U_SUCCESS(status))
 | |
| +        return false;
 | |
| +
 | |
| +    Vector<UChar, 32> displayNameBuffer(32);
 | |
| +    auto displayNameLength = ucal_getTimeZoneDisplayName(cal, UCAL_STANDARD, defaultLanguage().utf8().data(), displayNameBuffer.data(), displayNameBuffer.size(), &status);
 | |
| +    if (status == U_BUFFER_OVERFLOW_ERROR) {
 | |
| +        status = U_ZERO_ERROR;
 | |
| +        displayNameBuffer.grow(displayNameLength);
 | |
| +        ucal_getTimeZoneDisplayName(cal, UCAL_STANDARD, defaultLanguage().utf8().data(), displayNameBuffer.data(), displayNameLength, &status);
 | |
| +    }
 | |
| +    if (!U_SUCCESS(status))
 | |
| +        return false;
 | |
| +
 | |
| +    TimeZoneForAutomation& tzfa = innerTimeZoneForAutomation();
 | |
| +    tzfa.cal = cal;
 | |
| +    tzfa.id = String(canonicalBuffer.data(), canonicalLength);
 | |
| +    tzfa.displayName = String(displayNameBuffer.data(), displayNameLength);
 | |
| +    return true;
 | |
| +}
 | |
| +
 | |
| +String timeZoneForAutomation()
 | |
| +{
 | |
| +    return innerTimeZoneForAutomation().id;
 | |
| +}
 | |
| +
 | |
| +String timeZoneDisplayNameForAutomation()
 | |
| +{
 | |
| +    return innerTimeZoneForAutomation().displayName;
 | |
| +}
 | |
| +
 | |
|  } // namespace WTF
 | |
| diff --git a/Source/WTF/wtf/DateMath.h b/Source/WTF/wtf/DateMath.h
 | |
| index 246ba67c764b629042a7927d24fe89b049d82a0b..68d536878d1f0ba832d1c1d3e36e10b8227bbfac 100644
 | |
| --- a/Source/WTF/wtf/DateMath.h
 | |
| +++ b/Source/WTF/wtf/DateMath.h
 | |
| @@ -389,6 +389,10 @@ inline int dayInMonthFromDayInYear(int dayInYear, bool leapYear)
 | |
|      return d - step;
 | |
|  }
 | |
|  
 | |
| +WTF_EXPORT_PRIVATE bool setTimeZoneForAutomation(const String& timeZone);
 | |
| +WTF_EXPORT_PRIVATE String timeZoneForAutomation();
 | |
| +WTF_EXPORT_PRIVATE String timeZoneDisplayNameForAutomation();
 | |
| +
 | |
|  // Returns combined offset in millisecond (UTC + DST).
 | |
|  WTF_EXPORT_PRIVATE LocalTimeOffset calculateLocalTimeOffset(double utcInMilliseconds, TimeType = UTCTime);
 | |
|  
 | |
| diff --git a/Source/WTF/wtf/PlatformEnable.h b/Source/WTF/wtf/PlatformEnable.h
 | |
| index fe5164e4a8f5aad58b278b44943d3e328d9a4700..b1cdbe461511e8ac8b3f44721490c04eefe1a65b 100644
 | |
| --- a/Source/WTF/wtf/PlatformEnable.h
 | |
| +++ b/Source/WTF/wtf/PlatformEnable.h
 | |
| @@ -403,7 +403,7 @@
 | |
|  #endif
 | |
|  
 | |
|  #if !defined(ENABLE_ORIENTATION_EVENTS)
 | |
| -#define ENABLE_ORIENTATION_EVENTS 0
 | |
| +#define ENABLE_ORIENTATION_EVENTS 1
 | |
|  #endif
 | |
|  
 | |
|  #if OS(WINDOWS)
 | |
| diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h
 | |
| index 48ab5e978a71768fcb5712e5583c36838aa2b465..7e59b62fca1939e9ed04ae72da2c5cd7e888d862 100644
 | |
| --- a/Source/WTF/wtf/PlatformHave.h
 | |
| +++ b/Source/WTF/wtf/PlatformHave.h
 | |
| @@ -347,7 +347,7 @@
 | |
|  #define HAVE_NSHTTPCOOKIESTORAGE__INITWITHIDENTIFIER_WITH_INACCURATE_NULLABILITY 1
 | |
|  #endif
 | |
|  
 | |
| -#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST)
 | |
| +#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(GTK) || PLATFORM(WPE) || PLATFORM(WIN)
 | |
|  #define HAVE_OS_DARK_MODE_SUPPORT 1
 | |
|  #endif
 | |
|  
 | |
| diff --git a/Source/WebCore/Modules/geolocation/Geolocation.cpp b/Source/WebCore/Modules/geolocation/Geolocation.cpp
 | |
| index 6d5be9a591a272cd67d6e9d097b30505bdf8ae5e..8f67ba28c380e844c8e4191ee704466559d88f97 100644
 | |
| --- a/Source/WebCore/Modules/geolocation/Geolocation.cpp
 | |
| +++ b/Source/WebCore/Modules/geolocation/Geolocation.cpp
 | |
| @@ -356,8 +356,9 @@ bool Geolocation::shouldBlockGeolocationRequests()
 | |
|      bool isSecure = SecurityOrigin::isSecure(document()->url());
 | |
|      bool hasMixedContent = !document()->foundMixedContent().isEmpty();
 | |
|      bool isLocalOrigin = securityOrigin()->isLocal();
 | |
| +    bool isPotentiallyTrustworthy = securityOrigin()->isPotentiallyTrustworthy();
 | |
|      if (securityOrigin()->canRequestGeolocation()) {
 | |
| -        if (isLocalOrigin || (isSecure && !hasMixedContent) || isRequestFromIBooks())
 | |
| +        if (isLocalOrigin || isPotentiallyTrustworthy || (isSecure && !hasMixedContent) || isRequestFromIBooks())
 | |
|              return false;
 | |
|      }
 | |
|      
 | |
| diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt
 | |
| index cd7b65d4970ee5643279e227f0812b0ee1eb92c7..f2339abdb5739e0db57697973d8234fa1e8332d2 100644
 | |
| --- a/Source/WebCore/Sources.txt
 | |
| +++ b/Source/WebCore/Sources.txt
 | |
| @@ -1424,6 +1424,7 @@ inspector/agents/InspectorLayerTreeAgent.cpp
 | |
|  inspector/agents/InspectorMemoryAgent.cpp
 | |
|  inspector/agents/InspectorNetworkAgent.cpp
 | |
|  inspector/agents/InspectorPageAgent.cpp
 | |
| +inspector/agents/InspectorScreencastAgent.cpp
 | |
|  inspector/agents/InspectorTimelineAgent.cpp
 | |
|  inspector/agents/InspectorWorkerAgent.cpp
 | |
|  inspector/agents/WebConsoleAgent.cpp
 | |
| diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt
 | |
| index dbf7f63893e328b4c4df1c745c12f99c9e403d92..062e726892344e134c7fd1f144af24fce6134640 100644
 | |
| --- a/Source/WebCore/SourcesCocoa.txt
 | |
| +++ b/Source/WebCore/SourcesCocoa.txt
 | |
| @@ -659,7 +659,7 @@ WHLSLStandardLibraryFunctionMap.cpp
 | |
|  
 | |
|  #endif
 | |
|  
 | |
| -#if ENABLE_IOS_TOUCH_EVENTS
 | |
| +#if ENABLE_TOUCH_EVENTS
 | |
|  
 | |
|      JSTouch.cpp
 | |
|      JSTouchEvent.cpp
 | |
| diff --git a/Source/WebCore/WebCore.order b/Source/WebCore/WebCore.order
 | |
| index 34f1a72596fb89c8b647fff3348cca3d959c014c..ab6e42c4da2a8a77f66ce532a3a12bb9ee991207 100644
 | |
| --- a/Source/WebCore/WebCore.order
 | |
| +++ b/Source/WebCore/WebCore.order
 | |
| @@ -3094,7 +3094,6 @@ __ZN7WebCore14DocumentLoader23stopLoadingSubresourcesEv
 | |
|  __ZN7WebCore14DocumentLoader18stopLoadingPlugInsEv
 | |
|  __ZN7WebCore14DocumentLoader15detachFromFrameEv
 | |
|  __ZN7WebCore20ApplicationCacheHost22setDOMApplicationCacheEPNS_19DOMApplicationCacheE
 | |
| -__ZN7WebCore24InspectorInstrumentation27loaderDetachedFromFrameImplEPNS_19InstrumentingAgentsEPNS_14DocumentLoaderE
 | |
|  __ZN7WebCore14DocumentLoaderD0Ev
 | |
|  __ZN7WebCore14DocumentLoaderD2Ev
 | |
|  __ZN7WebCore14DocumentLoader17clearMainResourceEv
 | |
| diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 | |
| index d7590a4fbf0fb3d612e74353931fc93a8e778d2f..ca2c05b18317c196caa88f1f51fdac9ded5e6d6d 100644
 | |
| --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 | |
| +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 | |
| @@ -5038,6 +5038,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, ); }; };
 | |
| +		F050E16823AC9C080011CE47 /* PlatformTouchEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F050E16623AC9C070011CE47 /* PlatformTouchEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
| +		F050E16A23AD660C0011CE47 /* Touch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F050E16923AD660C0011CE47 /* Touch.cpp */; };
 | |
| +		F050E16D23AD66630011CE47 /* TouchList.h in Headers */ = {isa = PBXBuildFile; fileRef = F050E16B23AD66620011CE47 /* TouchList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
| +		F050E16E23AD66630011CE47 /* TouchList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F050E16C23AD66630011CE47 /* TouchList.cpp */; };
 | |
| +		F050E17123AD669F0011CE47 /* TouchEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F050E16F23AD669E0011CE47 /* TouchEvent.cpp */; };
 | |
| +		F050E17223AD669F0011CE47 /* TouchEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F050E17023AD669F0011CE47 /* TouchEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
| +		F050E17423AD6A800011CE47 /* DocumentTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F050E17323AD6A800011CE47 /* DocumentTouch.cpp */; };
 | |
| +		F050E17823AD70C50011CE47 /* PlatformTouchPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = F050E17623AD70C40011CE47 /* PlatformTouchPoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
|  		F12171F516A8CED2000053CA /* 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 */; };
 | |
| @@ -15697,6 +15705,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>"; };
 | |
| +		F050E16623AC9C070011CE47 /* PlatformTouchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformTouchEvent.h; sourceTree = "<group>"; };
 | |
| +		F050E16923AD660C0011CE47 /* Touch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Touch.cpp; path = dom/Touch.cpp; sourceTree = SOURCE_ROOT; };
 | |
| +		F050E16B23AD66620011CE47 /* TouchList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TouchList.h; path = dom/TouchList.h; sourceTree = SOURCE_ROOT; };
 | |
| +		F050E16C23AD66630011CE47 /* TouchList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TouchList.cpp; path = dom/TouchList.cpp; sourceTree = SOURCE_ROOT; };
 | |
| +		F050E16F23AD669E0011CE47 /* TouchEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TouchEvent.cpp; path = dom/TouchEvent.cpp; sourceTree = SOURCE_ROOT; };
 | |
| +		F050E17023AD669F0011CE47 /* TouchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TouchEvent.h; path = dom/TouchEvent.h; sourceTree = SOURCE_ROOT; };
 | |
| +		F050E17323AD6A800011CE47 /* DocumentTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentTouch.cpp; sourceTree = "<group>"; };
 | |
| +		F050E17623AD70C40011CE47 /* PlatformTouchPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformTouchPoint.h; sourceTree = "<group>"; };
 | |
|  		F12171F316A8BC63000053CA /* 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>"; };
 | |
| @@ -20983,7 +20999,12 @@
 | |
|  				2D2E34A921A4E191004598B5 /* EditableImageReference.h */,
 | |
|  				1AF326770D78B9440068F0C4 /* EditorClient.h */,
 | |
|  				93C09A800B064F00005ABD4D /* EventHandler.cpp */,
 | |
| +				F050E16F23AD669E0011CE47 /* TouchEvent.cpp */,
 | |
| +				F050E17023AD669F0011CE47 /* TouchEvent.h */,
 | |
|  				93C09A520B064DB3005ABD4D /* EventHandler.h */,
 | |
| +				F050E16923AD660C0011CE47 /* Touch.cpp */,
 | |
| +				F050E16C23AD66630011CE47 /* TouchList.cpp */,
 | |
| +				F050E16B23AD66620011CE47 /* TouchList.h */,
 | |
|  				E0FEF371B27C53EAC1C1FBEE /* EventSource.cpp */,
 | |
|  				E0FEF371B17C53EAC1C1FBEE /* EventSource.h */,
 | |
|  				E0FEF371B07C53EAC1C1FBEE /* EventSource.idl */,
 | |
| @@ -26262,7 +26283,9 @@
 | |
|  				B2C3D9EC0D006C1D00EF6F26 /* text */,
 | |
|  				E1EE8B6B2412B2A700E794D6 /* xr */,
 | |
|  				DFDB912CF8E88A6DA1AD264F /* AbortableTaskQueue.h */,
 | |
| +				F050E16623AC9C070011CE47 /* PlatformTouchEvent.h */,
 | |
|  				49AE2D94134EE5F90072920A /* CalculationValue.cpp */,
 | |
| +				F050E17623AD70C40011CE47 /* PlatformTouchPoint.h */,
 | |
|  				49AE2D95134EE5F90072920A /* CalculationValue.h */,
 | |
|  				C330A22113EC196B0000B45B /* ColorChooser.h */,
 | |
|  				C37CDEBC149EF2030042090D /* ColorChooserClient.h */,
 | |
| @@ -28622,6 +28645,7 @@
 | |
|  				BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */,
 | |
|  				AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */,
 | |
|  				AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */,
 | |
| +				F050E17323AD6A800011CE47 /* DocumentTouch.cpp */,
 | |
|  				6BDB5DC1227BD3B800919770 /* DocumentStorageAccess.cpp */,
 | |
|  				6BDB5DC0227BD3B800919770 /* DocumentStorageAccess.h */,
 | |
|  				6BDB5DC5227CA0EB00919770 /* DocumentStorageAccess.idl */,
 | |
| @@ -29506,6 +29530,7 @@
 | |
|  				93C4F6EB1108F9A50099D0DB /* AccessibilityScrollbar.h in Headers */,
 | |
|  				29489FC712C00F0300D83F0F /* AccessibilityScrollView.h in Headers */,
 | |
|  				0709FC4E1025DEE30059CDBA /* AccessibilitySlider.h in Headers */,
 | |
| +				F050E16D23AD66630011CE47 /* TouchList.h in Headers */,
 | |
|  				29D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */,
 | |
|  				69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */,
 | |
|  				AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */,
 | |
| @@ -31374,6 +31399,7 @@
 | |
|  				6E4ABCD5138EA0B70071D291 /* JSHTMLUnknownElement.h in Headers */,
 | |
|  				E44614170CD6826900FADA75 /* JSHTMLVideoElement.h in Headers */,
 | |
|  				81BE20D311F4BC3200915DFA /* JSIDBCursor.h in Headers */,
 | |
| +				F050E17823AD70C50011CE47 /* PlatformTouchPoint.h in Headers */,
 | |
|  				7C3D8EF01E0B21430023B084 /* JSIDBCursorDirection.h in Headers */,
 | |
|  				C585A68311D4FB08004C3E4B /* JSIDBDatabase.h in Headers */,
 | |
|  				C585A69711D4FB13004C3E4B /* JSIDBFactory.h in Headers */,
 | |
| @@ -33296,9 +33322,11 @@
 | |
|  				A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */,
 | |
|  				B2C3DA3A0D006C1D00EF6F26 /* TextCodec.h in Headers */,
 | |
|  				26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */,
 | |
| +				F050E16823AC9C080011CE47 /* PlatformTouchEvent.h in Headers */,
 | |
|  				B2C3DA3C0D006C1D00EF6F26 /* TextCodecICU.h in Headers */,
 | |
|  				B2C3DA3E0D006C1D00EF6F26 /* TextCodecLatin1.h in Headers */,
 | |
|  				57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */,
 | |
| +				F050E17223AD669F0011CE47 /* TouchEvent.h in Headers */,
 | |
|  				B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */,
 | |
|  				B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */,
 | |
|  				9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,
 | |
| @@ -34198,6 +34226,7 @@
 | |
|  				CDDE02ED18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm in Sources */,
 | |
|  				CDDE02F018B5651300CF7FF1 /* CDMSessionAVStreamSession.mm in Sources */,
 | |
|  				CDE5959D1BF2757100A1CBE8 /* CDMSessionMediaSourceAVFObjC.mm in Sources */,
 | |
| +				F050E17123AD669F0011CE47 /* TouchEvent.cpp in Sources */,
 | |
|  				A14090FB1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm in Sources */,
 | |
|  				07AFF4231EFB144900B545B3 /* CoreAudioCaptureSourceIOS.mm in Sources */,
 | |
|  				46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */,
 | |
| @@ -34271,6 +34300,7 @@
 | |
|  				51058ADF1D67C229009A538C /* MockGamepad.cpp in Sources */,
 | |
|  				51058AE11D67C229009A538C /* MockGamepadProvider.cpp in Sources */,
 | |
|  				CDF2B0121820540600F2B424 /* MockMediaPlayerMediaSource.cpp in Sources */,
 | |
| +				F050E17423AD6A800011CE47 /* DocumentTouch.cpp in Sources */,
 | |
|  				CDF2B0141820540600F2B424 /* MockMediaSourcePrivate.cpp in Sources */,
 | |
|  				CDF2B0161820540700F2B424 /* MockSourceBufferPrivate.cpp in Sources */,
 | |
|  				2D9BF7421DBFDC27007A7D99 /* NavigatorEME.cpp in Sources */,
 | |
| @@ -34360,6 +34390,7 @@
 | |
|  				538EC8881F993F9C004D22A8 /* UnifiedSource23.cpp in Sources */,
 | |
|  				DE5F85801FA1ABF4006DB63A /* UnifiedSource24-mm.mm in Sources */,
 | |
|  				538EC8891F993F9D004D22A8 /* UnifiedSource24.cpp in Sources */,
 | |
| +				F050E16E23AD66630011CE47 /* TouchList.cpp in Sources */,
 | |
|  				DE5F85811FA1ABF4006DB63A /* UnifiedSource25-mm.mm in Sources */,
 | |
|  				538EC88A1F993F9D004D22A8 /* UnifiedSource25.cpp in Sources */,
 | |
|  				DE5F85821FA1ABF4006DB63A /* UnifiedSource26-mm.mm in Sources */,
 | |
| @@ -34892,6 +34923,7 @@
 | |
|  				2D8B92F1203D13E1009C868F /* UnifiedSource516.cpp in Sources */,
 | |
|  				2D8B92F2203D13E1009C868F /* UnifiedSource517.cpp in Sources */,
 | |
|  				2D8B92F3203D13E1009C868F /* UnifiedSource518.cpp in Sources */,
 | |
| +				F050E16A23AD660C0011CE47 /* Touch.cpp in Sources */,
 | |
|  				2D8B92F4203D13E1009C868F /* UnifiedSource519.cpp in Sources */,
 | |
|  				2D8B92F5203D13E1009C868F /* UnifiedSource520.cpp in Sources */,
 | |
|  				2D8B92F6203D13E1009C868F /* UnifiedSource521.cpp in Sources */,
 | |
| diff --git a/Source/WebCore/accessibility/AccessibilityObject.cpp b/Source/WebCore/accessibility/AccessibilityObject.cpp
 | |
| index 3f800102457083c873d9bf81592bbb085cb70460..387c77e51b8268d39757608faa6f3f1f98ddd442 100644
 | |
| --- a/Source/WebCore/accessibility/AccessibilityObject.cpp
 | |
| +++ b/Source/WebCore/accessibility/AccessibilityObject.cpp
 | |
| @@ -58,6 +58,7 @@
 | |
|  #include "HTMLParserIdioms.h"
 | |
|  #include "HTMLTextAreaElement.h"
 | |
|  #include "HitTestResult.h"
 | |
| +#include "InspectorInstrumentation.h"
 | |
|  #include "LocalizedStrings.h"
 | |
|  #include "MathMLNames.h"
 | |
|  #include "NodeList.h"
 | |
| @@ -3250,10 +3251,15 @@ AccessibilityObjectInclusion AccessibilityObject::defaultObjectInclusion() const
 | |
|      
 | |
|      if (useParentData ? m_isIgnoredFromParentData.isPresentationalChildOfAriaRole : isPresentationalChildOfAriaRole())
 | |
|          return AccessibilityObjectInclusion::IgnoreObject;
 | |
| -    
 | |
| -    return accessibilityPlatformIncludesObject();
 | |
| +
 | |
| +    AccessibilityObjectInclusion platformBehavior = accessibilityPlatformIncludesObject();
 | |
| +    if (platformBehavior != AccessibilityObjectInclusion::DefaultBehavior) {
 | |
| +        if (auto* page = this->page())
 | |
| +            InspectorInstrumentation::maybeOverrideDefaultObjectInclusion(*page, platformBehavior);
 | |
| +    }
 | |
| +    return platformBehavior;
 | |
|  }
 | |
| -    
 | |
| +
 | |
|  bool AccessibilityObject::accessibilityIsIgnored() const
 | |
|  {
 | |
|      AXComputedObjectAttributeCache* attributeCache = nullptr;
 | |
| diff --git a/Source/WebCore/css/MediaQueryEvaluator.cpp b/Source/WebCore/css/MediaQueryEvaluator.cpp
 | |
| index 8118b7ab3c50b3ced8120fc106dce9c73141afe4..2aea3ba07eae2a23b6364074d253356165757549 100644
 | |
| --- a/Source/WebCore/css/MediaQueryEvaluator.cpp
 | |
| +++ b/Source/WebCore/css/MediaQueryEvaluator.cpp
 | |
| @@ -388,7 +388,7 @@ static bool deviceAspectRatioEvaluate(CSSValue* value, const CSSToLengthConversi
 | |
|      if (!value)
 | |
|          return true;
 | |
|  
 | |
| -    auto size = screenRect(frame.mainFrame().view()).size();
 | |
| +    auto size = frame.page()->screenSize();
 | |
|      bool result = compareAspectRatioValue(value, size.width(), size.height(), op);
 | |
|      LOG_WITH_STREAM(MediaQueries, stream << "  deviceAspectRatioEvaluate: " << op << " " << aspectRatioValueAsString(value) << " actual screen size " << size << ": " << result);
 | |
|      return result;
 | |
| @@ -506,7 +506,7 @@ static bool deviceHeightEvaluate(CSSValue* value, const CSSToLengthConversionDat
 | |
|      if (!value)
 | |
|          return true;
 | |
|      int length;
 | |
| -    auto height = screenRect(frame.mainFrame().view()).height();
 | |
| +    auto height = frame.page()->screenSize().height();
 | |
|      if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length))
 | |
|          return false;
 | |
|  
 | |
| @@ -521,8 +521,10 @@ static bool deviceWidthEvaluate(CSSValue* value, const CSSToLengthConversionData
 | |
|      // assume if we have a device, assume non-zero
 | |
|      if (!value)
 | |
|          return true;
 | |
| +    if (!frame.mainFrame().view())
 | |
| +        return false;
 | |
|      int length;
 | |
| -    auto width = screenRect(frame.mainFrame().view()).width();
 | |
| +    auto width = frame.page()->screenSize().width();
 | |
|      if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length))
 | |
|          return false;
 | |
|  
 | |
| diff --git a/Source/WebCore/dom/UserGestureIndicator.cpp b/Source/WebCore/dom/UserGestureIndicator.cpp
 | |
| index dfec93b644f72a51bad0bebf396da61c57f6e428..353833a7614a55566862c196bafc598a475536a1 100644
 | |
| --- a/Source/WebCore/dom/UserGestureIndicator.cpp
 | |
| +++ b/Source/WebCore/dom/UserGestureIndicator.cpp
 | |
| @@ -56,8 +56,7 @@ UserGestureIndicator::UserGestureIndicator(Optional<ProcessingUserGestureState>
 | |
|  
 | |
|      if (state)
 | |
|          currentToken() = UserGestureToken::create(state.value(), gestureType);
 | |
| -
 | |
| -    if (document && currentToken()->processingUserGesture() && state) {
 | |
| +    if (document && state && currentToken()->processingUserGesture()) {
 | |
|          document->updateLastHandledUserGestureTimestamp(currentToken()->startTime());
 | |
|          if (processInteractionStyle == ProcessInteractionStyle::Immediate)
 | |
|              ResourceLoadObserver::shared().logUserInteractionWithReducedTimeResolution(document->topDocument());
 | |
| diff --git a/Source/WebCore/html/FileInputType.cpp b/Source/WebCore/html/FileInputType.cpp
 | |
| index 3e2f9beaf00d25860436b7b608bfe9fb23195bae..e1a18032645fc9f9803ee891a41930307c1a2ec7 100644
 | |
| --- a/Source/WebCore/html/FileInputType.cpp
 | |
| +++ b/Source/WebCore/html/FileInputType.cpp
 | |
| @@ -36,6 +36,7 @@
 | |
|  #include "HTMLNames.h"
 | |
|  #include "Icon.h"
 | |
|  #include "InputTypeNames.h"
 | |
| +#include "InspectorInstrumentation.h"
 | |
|  #include "LocalizedStrings.h"
 | |
|  #include "RenderFileUploadControl.h"
 | |
|  #include "RuntimeEnabledFeatures.h"
 | |
| @@ -207,6 +208,11 @@ void FileInputType::handleDOMActivateEvent(Event& event)
 | |
|      if (input.isDisabledFormControl())
 | |
|          return;
 | |
|  
 | |
| +    bool intercept = false;
 | |
| +    InspectorInstrumentation::runOpenPanel(input.document().frame(), element(), &intercept);
 | |
| +    if (intercept)
 | |
| +        return;
 | |
| +
 | |
|      if (!UserGestureIndicator::processingUserGesture())
 | |
|          return;
 | |
|  
 | |
| diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp
 | |
| index b5b22cb2863ebc6fdd825e5d3fdec34598703826..b2d45001e08173178f9aa8e7c39496157863d376 100644
 | |
| --- a/Source/WebCore/inspector/InspectorController.cpp
 | |
| +++ b/Source/WebCore/inspector/InspectorController.cpp
 | |
| @@ -84,6 +84,9 @@
 | |
|  #include <JavaScriptCore/JSLock.h>
 | |
|  #include <wtf/Stopwatch.h>
 | |
|  
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +#include "InspectorScreencastAgent.h"
 | |
| +#endif
 | |
|  #if ENABLE(REMOTE_INSPECTOR)
 | |
|  #include "PageDebuggable.h"
 | |
|  #endif
 | |
| @@ -185,6 +188,9 @@ void InspectorController::createLazyAgents()
 | |
|      m_agents.append(makeUnique<PageHeapAgent>(pageContext));
 | |
|      m_agents.append(makeUnique<PageAuditAgent>(pageContext));
 | |
|      m_agents.append(makeUnique<InspectorCanvasAgent>(pageContext));
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +    m_agents.append(makeUnique<InspectorScreencastAgent>(pageContext));
 | |
| +#endif
 | |
|      m_agents.append(makeUnique<InspectorTimelineAgent>(pageContext));
 | |
|      m_agents.append(makeUnique<InspectorAnimationAgent>(pageContext));
 | |
|  
 | |
| @@ -371,8 +377,8 @@ void InspectorController::inspect(Node* node)
 | |
|      if (!enabled())
 | |
|          return;
 | |
|  
 | |
| -    if (!hasRemoteFrontend())
 | |
| -        show();
 | |
| +    // HACK: Always attempt to show inspector even if there is a remote connection.
 | |
| +    show();
 | |
|  
 | |
|      ensureDOMAgent().inspect(node);
 | |
|  }
 | |
| @@ -505,6 +511,13 @@ JSC::VM& InspectorController::vm()
 | |
|      return commonVM();
 | |
|  }
 | |
|  
 | |
| +// Playwright begin
 | |
| +void InspectorController::willDisplay()
 | |
| +{
 | |
| +    InspectorInstrumentation::willDisplay(m_page);
 | |
| +}
 | |
| +// Playwright end
 | |
| +
 | |
|  void InspectorController::willComposite(Frame& frame)
 | |
|  {
 | |
|      InspectorInstrumentation::willComposite(frame);
 | |
| @@ -515,4 +528,24 @@ void InspectorController::didComposite(Frame& frame)
 | |
|      InspectorInstrumentation::didComposite(frame);
 | |
|  }
 | |
|  
 | |
| +void InspectorController::pauseWhenShown()
 | |
| +{
 | |
| +    m_pauseWhenShown = true;
 | |
| +}
 | |
| +
 | |
| +void InspectorController::resumeIfPausedInNewWindow()
 | |
| +{
 | |
| +    m_pauseWhenShown = false;
 | |
| +}
 | |
| +
 | |
| +void InspectorController::didShowNewWindow()
 | |
| +{
 | |
| +    if (!m_pauseWhenShown)
 | |
| +        return;
 | |
| +    while (m_pauseWhenShown) {
 | |
| +        if (RunLoop::cycle() == RunLoop::CycleResult::Stop)
 | |
| +            break;
 | |
| +    }
 | |
| +}
 | |
| +
 | |
|  } // namespace WebCore
 | |
| diff --git a/Source/WebCore/inspector/InspectorController.h b/Source/WebCore/inspector/InspectorController.h
 | |
| index d2f18172df139dd68cf94b715e847da18a8a5845..378faa8166d57167344fbd224bcf25829a1a54ed 100644
 | |
| --- a/Source/WebCore/inspector/InspectorController.h
 | |
| +++ b/Source/WebCore/inspector/InspectorController.h
 | |
| @@ -98,9 +98,16 @@ public:
 | |
|  
 | |
|      WEBCORE_EXPORT void setIndicating(bool);
 | |
|  
 | |
| +// Playwright begin
 | |
| +    WEBCORE_EXPORT void willDisplay();
 | |
| +// Playwright end
 | |
|      WEBCORE_EXPORT void willComposite(Frame&);
 | |
|      WEBCORE_EXPORT void didComposite(Frame&);
 | |
|  
 | |
| +    WEBCORE_EXPORT void pauseWhenShown();
 | |
| +    WEBCORE_EXPORT void resumeIfPausedInNewWindow();
 | |
| +    WEBCORE_EXPORT void didShowNewWindow();
 | |
| +
 | |
|      bool isUnderTest() const { return m_isUnderTest; }
 | |
|      void setIsUnderTest(bool isUnderTest) { m_isUnderTest = isUnderTest; }
 | |
|      WEBCORE_EXPORT void evaluateForTestInFrontend(const String& script);
 | |
| @@ -150,6 +157,7 @@ private:
 | |
|      bool m_isAutomaticInspection { false };
 | |
|      bool m_pauseAfterInitialization = { false };
 | |
|      bool m_didCreateLazyAgents { false };
 | |
| +    bool m_pauseWhenShown { false };
 | |
|  };
 | |
|  
 | |
|  } // namespace WebCore
 | |
| diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp
 | |
| index 0c442ee908877d2067d65e87441652a8cf00c88e..6fb448784e0d97fe60eb233853905138992c6bb6 100644
 | |
| --- a/Source/WebCore/inspector/InspectorInstrumentation.cpp
 | |
| +++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp
 | |
| @@ -81,6 +81,12 @@
 | |
|  #include <JavaScriptCore/ScriptCallStack.h>
 | |
|  #include <wtf/StdLibExtras.h>
 | |
|  
 | |
| +// Playwright begin
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +#include "InspectorScreencastAgent.h"
 | |
| +#endif
 | |
| +// Playwright end
 | |
| +
 | |
|  #if ENABLE(WEBGPU)
 | |
|  #include "WebGPUSwapChain.h"
 | |
|  #endif
 | |
| @@ -502,6 +508,19 @@ void InspectorInstrumentation::didLayoutImpl(InstrumentingAgents& instrumentingA
 | |
|          pageAgent->didLayout();
 | |
|  }
 | |
|  
 | |
| +// Playwright begin
 | |
| +void InspectorInstrumentation::willDisplayImpl(InstrumentingAgents& instrumentingAgents)
 | |
| +{
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +
 | |
| +    if (auto* screencastAgent = instrumentingAgents.inspectorScreencastAgent())
 | |
| +        screencastAgent->willDisplay();
 | |
| +#else
 | |
| +    UNUSED_PARAM(instrumentingAgents);
 | |
| +#endif
 | |
| +}
 | |
| +// Playwright end
 | |
| +
 | |
|  void InspectorInstrumentation::willCompositeImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 | |
|  {
 | |
|      if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent())
 | |
| @@ -628,6 +647,12 @@ void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents& instrumen
 | |
|          consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
 | |
|  }
 | |
|  
 | |
| +void InspectorInstrumentation::didReceiveMainResourceErrorImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const ResourceError&)
 | |
| +{
 | |
| +    if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent())
 | |
| +        pageRuntimeAgent->didReceiveMainResourceError(frame);
 | |
| +}
 | |
| +
 | |
|  void InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents& instrumentingAgents)
 | |
|  {
 | |
|      if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
 | |
| @@ -660,20 +685,17 @@ void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents&
 | |
|  
 | |
|  void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 | |
|  {
 | |
| -    if (!frame.isMainFrame())
 | |
| -        return;
 | |
| -
 | |
|      if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| -        pageAgent->domContentEventFired();
 | |
| +        pageAgent->domContentEventFired(frame);
 | |
|  }
 | |
|  
 | |
|  void InspectorInstrumentation::loadEventFiredImpl(InstrumentingAgents& instrumentingAgents, Frame* frame)
 | |
|  {
 | |
| -    if (!frame || !frame->isMainFrame())
 | |
| +    if (!frame)
 | |
|          return;
 | |
|  
 | |
|      if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| -        pageAgent->loadEventFired();
 | |
| +        pageAgent->loadEventFired(*frame);
 | |
|  }
 | |
|  
 | |
|  void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 | |
| @@ -751,12 +773,6 @@ void InspectorInstrumentation::frameDocumentUpdatedImpl(InstrumentingAgents& ins
 | |
|          pageDOMDebuggerAgent->frameDocumentUpdated(frame);
 | |
|  }
 | |
|  
 | |
| -void InspectorInstrumentation::loaderDetachedFromFrameImpl(InstrumentingAgents& instrumentingAgents, DocumentLoader& loader)
 | |
| -{
 | |
| -    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| -        inspectorPageAgent->loaderDetachedFromFrame(loader);
 | |
| -}
 | |
| -
 | |
|  void InspectorInstrumentation::frameStartedLoadingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 | |
|  {
 | |
|      if (frame.isMainFrame()) {
 | |
| @@ -793,6 +809,12 @@ void InspectorInstrumentation::frameClearedScheduledNavigationImpl(Instrumenting
 | |
|          inspectorPageAgent->frameClearedScheduledNavigation(frame);
 | |
|  }
 | |
|  
 | |
| +void InspectorInstrumentation::didNavigateWithinPageImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 | |
| +{
 | |
| +    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| +        inspectorPageAgent->didNavigateWithinPage(frame);
 | |
| +}
 | |
| +
 | |
|  void InspectorInstrumentation::defaultAppearanceDidChangeImpl(InstrumentingAgents& instrumentingAgents, bool useDarkAppearance)
 | |
|  {
 | |
|      if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| @@ -1295,6 +1317,43 @@ void InspectorInstrumentation::renderLayerDestroyedImpl(InstrumentingAgents& ins
 | |
|          layerTreeAgent->renderLayerDestroyed(renderLayer);
 | |
|  }
 | |
|  
 | |
| +void InspectorInstrumentation::runOpenPanelImpl(InstrumentingAgents& instrumentingAgents, HTMLInputElement* element, bool* intercept)
 | |
| +{
 | |
| +    if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| +        pageAgent->runOpenPanel(element, intercept);
 | |
| +}
 | |
| +
 | |
| +void InspectorInstrumentation::frameAttachedImpl(InstrumentingAgents& instrumentingAgents, Frame& frame) {
 | |
| +    if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| +        pageAgent->frameAttached(frame);
 | |
| +}
 | |
| +
 | |
| +bool InspectorInstrumentation::shouldBypassCSPImpl(InstrumentingAgents& instrumentingAgents)
 | |
| +{
 | |
| +    if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| +        return pageAgent->shouldBypassCSP();
 | |
| +    return false;
 | |
| +}
 | |
| +
 | |
| +void InspectorInstrumentation::willCheckNewWindowPolicyImpl(InstrumentingAgents& instrumentingAgents, const URL& url)
 | |
| +{
 | |
| +    if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| +        pageAgent->willCheckNewWindowPolicy(url);
 | |
| +}
 | |
| +
 | |
| +void InspectorInstrumentation::didCheckNewWindowPolicyImpl(InstrumentingAgents& instrumentingAgents, bool allowed)
 | |
| +{
 | |
| +    if (InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent())
 | |
| +        pageAgent->didCheckNewWindowPolicy(allowed);
 | |
| +}
 | |
| +
 | |
| +bool InspectorInstrumentation::interceptRequestImpl(InstrumentingAgents& instrumentingAgents, ResourceLoader& loader, Function<void(bool handled)>&& handler)
 | |
| +{
 | |
| +    if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
 | |
| +        return networkAgent->interceptRequest(loader, WTFMove(handler));
 | |
| +    return false;
 | |
| +}
 | |
| +
 | |
|  InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope& workerGlobalScope)
 | |
|  {
 | |
|      return workerGlobalScope.inspectorController().m_instrumentingAgents;
 | |
| @@ -1306,6 +1365,13 @@ InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForPage(Page&
 | |
|      return page.inspectorController().m_instrumentingAgents.get();
 | |
|  }
 | |
|  
 | |
| +void InspectorInstrumentation::maybeOverrideDefaultObjectInclusion(Page& page, AccessibilityObjectInclusion& inclusion) {
 | |
| +    if (InspectorPageAgent* pageAgent = InspectorInstrumentation::instrumentingAgentsForPage(page).inspectorPageAgent()) {
 | |
| +        if (pageAgent->doingAccessibilitySnapshot())
 | |
| +            inclusion = AccessibilityObjectInclusion::DefaultBehavior;
 | |
| +    }
 | |
| +}
 | |
| +
 | |
|  InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext& context)
 | |
|  {
 | |
|      if (is<Document>(context))
 | |
| diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h
 | |
| index 03bdd55cc930de0cfc61f8d9e4210f4952aa4633..cd95112f4ed24429dfe27343228592e1d4ff7db4 100644
 | |
| --- a/Source/WebCore/inspector/InspectorInstrumentation.h
 | |
| +++ b/Source/WebCore/inspector/InspectorInstrumentation.h
 | |
| @@ -31,6 +31,7 @@
 | |
|  
 | |
|  #pragma once
 | |
|  
 | |
| +#include "AccessibilityObjectInterface.h"
 | |
|  #include "CSSSelector.h"
 | |
|  #include "CallTracerTypes.h"
 | |
|  #include "CanvasBase.h"
 | |
| @@ -45,12 +46,14 @@
 | |
|  #include "HitTestResult.h"
 | |
|  #include "InspectorInstrumentationPublic.h"
 | |
|  #include "Page.h"
 | |
| +#include "ResourceLoader.h"
 | |
|  #include "StorageArea.h"
 | |
|  #include "WebAnimation.h"
 | |
|  #include "WorkerInspectorProxy.h"
 | |
|  #include <JavaScriptCore/ConsoleMessage.h>
 | |
|  #include <initializer_list>
 | |
|  #include <wtf/CompletionHandler.h>
 | |
| +#include <wtf/Function.h>
 | |
|  #include <wtf/MemoryPressureHandler.h>
 | |
|  #include <wtf/RefPtr.h>
 | |
|  
 | |
| @@ -78,6 +81,7 @@ class DOMWrapperWorld;
 | |
|  class Document;
 | |
|  class DocumentLoader;
 | |
|  class EventListener;
 | |
| +class HTMLInputElement;
 | |
|  class HTTPHeaderMap;
 | |
|  class InspectorTimelineAgent;
 | |
|  class InstrumentingAgents;
 | |
| @@ -181,6 +185,9 @@ public:
 | |
|      static void willLayout(Frame&);
 | |
|      static void didLayout(Frame&, RenderObject&);
 | |
|      static void didScroll(Page&);
 | |
| +// Playwright begin
 | |
| +    static void willDisplay(Page&);
 | |
| +// Playwright end
 | |
|      static void willComposite(Frame&);
 | |
|      static void didComposite(Frame&);
 | |
|      static void willPaint(RenderObject&);
 | |
| @@ -198,6 +205,7 @@ public:
 | |
|      static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
 | |
|      static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);
 | |
|      static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
 | |
| +    static void didReceiveMainResourceError(Frame&, const ResourceError&);
 | |
|  
 | |
|      static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
 | |
|      static void didReceiveResourceResponse(WorkerGlobalScope&, unsigned long identifier, const ResourceResponse&);
 | |
| @@ -224,11 +232,11 @@ public:
 | |
|      static void frameDetachedFromParent(Frame&);
 | |
|      static void didCommitLoad(Frame&, DocumentLoader*);
 | |
|      static void frameDocumentUpdated(Frame&);
 | |
| -    static void loaderDetachedFromFrame(Frame&, DocumentLoader&);
 | |
|      static void frameStartedLoading(Frame&);
 | |
|      static void frameStoppedLoading(Frame&);
 | |
|      static void frameScheduledNavigation(Frame&, Seconds delay);
 | |
|      static void frameClearedScheduledNavigation(Frame&);
 | |
| +    static void didNavigateWithinPage(Frame&);
 | |
|      static void defaultAppearanceDidChange(Page&, bool useDarkAppearance);
 | |
|      static void willDestroyCachedResource(CachedResource&);
 | |
|  
 | |
| @@ -318,6 +326,13 @@ public:
 | |
|      static void layerTreeDidChange(Page*);
 | |
|      static void renderLayerDestroyed(Page*, const RenderLayer&);
 | |
|  
 | |
| +    static void runOpenPanel(Frame*, HTMLInputElement*, bool*);
 | |
| +    static void frameAttached(Frame*);
 | |
| +    static bool shouldBypassCSP(ScriptExecutionContext*);
 | |
| +    static void willCheckNewWindowPolicy(Frame&, const URL&);
 | |
| +    static void didCheckNewWindowPolicy(Frame&, bool allowed);
 | |
| +    static bool interceptRequest(ResourceLoader&, Function<void(bool handled)>&&);
 | |
| +
 | |
|      static void frontendCreated();
 | |
|      static void frontendDeleted();
 | |
|      static bool hasFrontends() { return InspectorInstrumentationPublic::hasFrontends(); }
 | |
| @@ -333,6 +348,8 @@ public:
 | |
|      static void registerInstrumentingAgents(InstrumentingAgents&);
 | |
|      static void unregisterInstrumentingAgents(InstrumentingAgents&);
 | |
|  
 | |
| +    static void maybeOverrideDefaultObjectInclusion(Page&, AccessibilityObjectInclusion&);
 | |
| +
 | |
|  private:
 | |
|      static void didClearWindowObjectInWorldImpl(InstrumentingAgents&, Frame&, DOMWrapperWorld&);
 | |
|      static bool isDebuggerPausedImpl(InstrumentingAgents&);
 | |
| @@ -400,6 +417,9 @@ private:
 | |
|      static void willLayoutImpl(InstrumentingAgents&, Frame&);
 | |
|      static void didLayoutImpl(InstrumentingAgents&, RenderObject&);
 | |
|      static void didScrollImpl(InstrumentingAgents&);
 | |
| +// Playwright begin
 | |
| +    static void willDisplayImpl(InstrumentingAgents&);
 | |
| +// Playwright end
 | |
|      static void willCompositeImpl(InstrumentingAgents&, Frame&);
 | |
|      static void didCompositeImpl(InstrumentingAgents&);
 | |
|      static void willPaintImpl(InstrumentingAgents&, RenderObject&);
 | |
| @@ -419,6 +439,7 @@ private:
 | |
|      static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
 | |
|      static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
 | |
|      static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
 | |
| +    static void didReceiveMainResourceErrorImpl(InstrumentingAgents&, Frame&, const ResourceError&);
 | |
|      static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
 | |
|      static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
 | |
|      static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
 | |
| @@ -429,11 +450,11 @@ private:
 | |
|      static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&);
 | |
|      static void didCommitLoadImpl(InstrumentingAgents&, Frame&, DocumentLoader*);
 | |
|      static void frameDocumentUpdatedImpl(InstrumentingAgents&, Frame&);
 | |
| -    static void loaderDetachedFromFrameImpl(InstrumentingAgents&, DocumentLoader&);
 | |
|      static void frameStartedLoadingImpl(InstrumentingAgents&, Frame&);
 | |
|      static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
 | |
|      static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, Seconds delay);
 | |
|      static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
 | |
| +    static void didNavigateWithinPageImpl(InstrumentingAgents&, Frame&);
 | |
|      static void defaultAppearanceDidChangeImpl(InstrumentingAgents&, bool useDarkAppearance);
 | |
|      static void willDestroyCachedResourceImpl(CachedResource&);
 | |
|  
 | |
| @@ -519,6 +540,13 @@ private:
 | |
|      static void layerTreeDidChangeImpl(InstrumentingAgents&);
 | |
|      static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
 | |
|  
 | |
| +    static void runOpenPanelImpl(InstrumentingAgents&, HTMLInputElement*, bool*);
 | |
| +    static void frameAttachedImpl(InstrumentingAgents&, Frame&);
 | |
| +    static bool shouldBypassCSPImpl(InstrumentingAgents&);
 | |
| +    static void willCheckNewWindowPolicyImpl(InstrumentingAgents&, const URL&);
 | |
| +    static void didCheckNewWindowPolicyImpl(InstrumentingAgents&, bool allowed);
 | |
| +    static bool interceptRequestImpl(InstrumentingAgents&, ResourceLoader&, Function<void(bool handled)>&&);
 | |
| +
 | |
|      static InstrumentingAgents& instrumentingAgentsForPage(Page&);
 | |
|      static InstrumentingAgents& instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope&);
 | |
|  
 | |
| @@ -968,6 +996,14 @@ inline void InspectorInstrumentation::didScroll(Page& page)
 | |
|      didScrollImpl(instrumentingAgentsForPage(page));
 | |
|  }
 | |
|  
 | |
| +// Playwright begin
 | |
| +inline void InspectorInstrumentation::willDisplay(Page& page)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    willDisplayImpl(instrumentingAgentsForPage(page));
 | |
| +}
 | |
| +// Playwright end
 | |
| +
 | |
|  inline void InspectorInstrumentation::willComposite(Frame& frame)
 | |
|  {
 | |
|      FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| @@ -1107,6 +1143,13 @@ inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoade
 | |
|          didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
 | |
|  }
 | |
|  
 | |
| +inline void InspectorInstrumentation::didReceiveMainResourceError(Frame& frame, const ResourceError& error)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
 | |
| +        didReceiveMainResourceErrorImpl(*instrumentingAgents, frame, error);
 | |
| +}
 | |
| +
 | |
|  inline void InspectorInstrumentation::didFailLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceError& error)
 | |
|  {
 | |
|      didFailLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, error);
 | |
| @@ -1202,13 +1245,6 @@ inline void InspectorInstrumentation::frameDocumentUpdated(Frame& frame)
 | |
|          frameDocumentUpdatedImpl(*instrumentingAgents, frame);
 | |
|  }
 | |
|  
 | |
| -inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame& frame, DocumentLoader& loader)
 | |
| -{
 | |
| -    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| -    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
 | |
| -        loaderDetachedFromFrameImpl(*instrumentingAgents, loader);
 | |
| -}
 | |
| -
 | |
|  inline void InspectorInstrumentation::frameStartedLoading(Frame& frame)
 | |
|  {
 | |
|      FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| @@ -1237,6 +1273,13 @@ inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& fra
 | |
|          frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
 | |
|  }
 | |
|  
 | |
| +inline void InspectorInstrumentation::didNavigateWithinPage(Frame& frame)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
 | |
| +        didNavigateWithinPageImpl(*instrumentingAgents, frame);
 | |
| +}
 | |
| +
 | |
|  inline void InspectorInstrumentation::defaultAppearanceDidChange(Page& page, bool useDarkAppearance)
 | |
|  {
 | |
|      FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| @@ -1687,6 +1730,50 @@ inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const Ren
 | |
|          renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
 | |
|  }
 | |
|  
 | |
| +inline void InspectorInstrumentation::runOpenPanel(Frame* frame, HTMLInputElement* element, bool* intercept)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(*frame))
 | |
| +        runOpenPanelImpl(*instrumentingAgents, element, intercept);
 | |
| +}
 | |
| +
 | |
| +inline void InspectorInstrumentation::frameAttached(Frame* frame)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
 | |
| +        frameAttachedImpl(*instrumentingAgents, *frame);
 | |
| +}
 | |
| +
 | |
| +inline bool InspectorInstrumentation::shouldBypassCSP(ScriptExecutionContext* context)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(false);
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
 | |
| +        return shouldBypassCSPImpl(*instrumentingAgents);
 | |
| +    return false;
 | |
| +}
 | |
| +
 | |
| +inline void InspectorInstrumentation::willCheckNewWindowPolicy(Frame& frame, const URL& url)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
 | |
| +        willCheckNewWindowPolicyImpl(*instrumentingAgents, url);
 | |
| +}
 | |
| +
 | |
| +inline void InspectorInstrumentation::didCheckNewWindowPolicy(Frame& frame, bool allowed)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(void());
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
 | |
| +        didCheckNewWindowPolicyImpl(*instrumentingAgents, allowed);
 | |
| +}
 | |
| +
 | |
| +inline bool InspectorInstrumentation::interceptRequest(ResourceLoader& loader, Function<void(bool handled)>&& handler)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(false);
 | |
| +    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(loader.frame()))
 | |
| +        return interceptRequestImpl(*instrumentingAgents, loader, WTFMove(handler));
 | |
| +    return false;
 | |
| +}
 | |
| +
 | |
|  inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
 | |
|  {
 | |
|      return context ? instrumentingAgentsForContext(*context) : nullptr;
 | |
| diff --git a/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp b/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp
 | |
| index 954aaf121a9fa507d83bc10ae37de1f128f7dcfc..9f16be3dbcf4857742ec2ab131e2b2f962a2a47c 100644
 | |
| --- a/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp
 | |
| +++ b/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp
 | |
| @@ -30,6 +30,11 @@
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| +bool InspectorInstrumentationWebKit::interceptRequestInternal(ResourceLoader& loader, Function<void(bool handled)>&& handler)
 | |
| +{
 | |
| +    return InspectorInstrumentation::interceptRequest(loader, WTFMove(handler));
 | |
| +}
 | |
| +
 | |
|  bool InspectorInstrumentationWebKit::shouldInterceptResponseInternal(const Frame& frame, const ResourceResponse& response)
 | |
|  {
 | |
|      return InspectorInstrumentation::shouldInterceptResponse(frame, response);
 | |
| diff --git a/Source/WebCore/inspector/InspectorInstrumentationWebKit.h b/Source/WebCore/inspector/InspectorInstrumentationWebKit.h
 | |
| index b67e89b80b4e7a8586cac81ade5d58a1bcb0d431..c468bc0981d1fb13272b28095f9f7584840b5861 100644
 | |
| --- a/Source/WebCore/inspector/InspectorInstrumentationWebKit.h
 | |
| +++ b/Source/WebCore/inspector/InspectorInstrumentationWebKit.h
 | |
| @@ -27,6 +27,7 @@
 | |
|  
 | |
|  #include "InspectorInstrumentationPublic.h"
 | |
|  #include <wtf/CompletionHandler.h>
 | |
| +#include <wtf/Function.h>
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| @@ -36,14 +37,22 @@ class SharedBuffer;
 | |
|  
 | |
|  class WEBCORE_EXPORT InspectorInstrumentationWebKit {
 | |
|  public:
 | |
| +    static bool interceptRequest(ResourceLoader&, Function<void(bool handled)>&&);
 | |
|      static bool shouldInterceptResponse(const Frame*, const ResourceResponse&);
 | |
|      static void interceptResponse(const Frame*, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 | |
|  
 | |
|  private:
 | |
| +    static bool interceptRequestInternal(ResourceLoader&, Function<void(bool handled)>&&);
 | |
|      static bool shouldInterceptResponseInternal(const Frame&, const ResourceResponse&);
 | |
|      static void interceptResponseInternal(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 | |
|  };
 | |
|  
 | |
| +inline bool InspectorInstrumentationWebKit::interceptRequest(ResourceLoader& loader, Function<void(bool handled)>&& handler)
 | |
| +{
 | |
| +    FAST_RETURN_IF_NO_FRONTENDS(false);
 | |
| +    return interceptRequestInternal(loader, WTFMove(handler));
 | |
| +}
 | |
| +
 | |
|  inline bool InspectorInstrumentationWebKit::shouldInterceptResponse(const Frame* frame, const ResourceResponse& response)
 | |
|  {
 | |
|      FAST_RETURN_IF_NO_FRONTENDS(false);
 | |
| diff --git a/Source/WebCore/inspector/InstrumentingAgents.cpp b/Source/WebCore/inspector/InstrumentingAgents.cpp
 | |
| index d7a2f71958d943cccac434eac93e33dae27cc404..6cd053bd72ef6d14f15b0bd6739f672b0468198b 100644
 | |
| --- a/Source/WebCore/inspector/InstrumentingAgents.cpp
 | |
| +++ b/Source/WebCore/inspector/InstrumentingAgents.cpp
 | |
| @@ -46,6 +46,7 @@ void InstrumentingAgents::reset()
 | |
|  {
 | |
|      m_inspectorAgent = nullptr;
 | |
|      m_inspectorPageAgent = nullptr;
 | |
| +    m_inspectorScreencastAgent = nullptr;
 | |
|      m_inspectorCSSAgent = nullptr;
 | |
|      m_inspectorLayerTreeAgent = nullptr;
 | |
|      m_inspectorWorkerAgent = nullptr;
 | |
| diff --git a/Source/WebCore/inspector/InstrumentingAgents.h b/Source/WebCore/inspector/InstrumentingAgents.h
 | |
| index f59c3dbdcaf78cf9c6d8dbb432dccf22f15d507d..e6abccfbf286613180ecea948947c61075bc57b3 100644
 | |
| --- a/Source/WebCore/inspector/InstrumentingAgents.h
 | |
| +++ b/Source/WebCore/inspector/InstrumentingAgents.h
 | |
| @@ -57,6 +57,7 @@ class InspectorLayerTreeAgent;
 | |
|  class InspectorMemoryAgent;
 | |
|  class InspectorNetworkAgent;
 | |
|  class InspectorPageAgent;
 | |
| +class InspectorScreencastAgent;
 | |
|  class InspectorTimelineAgent;
 | |
|  class InspectorWorkerAgent;
 | |
|  class Page;
 | |
| @@ -88,6 +89,9 @@ public:
 | |
|      InspectorPageAgent* inspectorPageAgent() const { return m_inspectorPageAgent; }
 | |
|      void setInspectorPageAgent(InspectorPageAgent* agent) { m_inspectorPageAgent = agent; }
 | |
|  
 | |
| +    InspectorScreencastAgent* inspectorScreencastAgent() const { return m_inspectorScreencastAgent; }
 | |
| +    void setInspectorScreencastAgent(InspectorScreencastAgent* agent) { m_inspectorScreencastAgent = agent; }
 | |
| +
 | |
|      InspectorCanvasAgent* inspectorCanvasAgent() const { return m_inspectorCanvasAgent; }
 | |
|      void setInspectorCanvasAgent(InspectorCanvasAgent* agent) { m_inspectorCanvasAgent = agent; }
 | |
|  
 | |
| @@ -169,6 +173,7 @@ private:
 | |
|  
 | |
|      Inspector::InspectorAgent* m_inspectorAgent { nullptr };
 | |
|      InspectorPageAgent* m_inspectorPageAgent { nullptr };
 | |
| +    InspectorScreencastAgent* m_inspectorScreencastAgent { nullptr };
 | |
|      InspectorCSSAgent* m_inspectorCSSAgent { nullptr };
 | |
|      InspectorLayerTreeAgent* m_inspectorLayerTreeAgent { nullptr };
 | |
|      InspectorWorkerAgent* m_inspectorWorkerAgent { nullptr };
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp b/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
 | |
| index a2f8dfa1624ddff42e359c862e0748e72ecbc96c..b7a4e23bf12b1367f1eda92bc9ae113055c455d5 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
 | |
| @@ -61,12 +61,16 @@
 | |
|  #include "Event.h"
 | |
|  #include "EventListener.h"
 | |
|  #include "EventNames.h"
 | |
| +#include "File.h"
 | |
| +#include "FileList.h"
 | |
|  #include "Frame.h"
 | |
|  #include "FrameTree.h"
 | |
|  #include "FrameView.h"
 | |
|  #include "FullscreenManager.h"
 | |
| +#include "FloatQuad.h"
 | |
|  #include "HTMLElement.h"
 | |
|  #include "HTMLFrameOwnerElement.h"
 | |
| +#include "HTMLInputElement.h"
 | |
|  #include "HTMLMediaElement.h"
 | |
|  #include "HTMLNames.h"
 | |
|  #include "HTMLParserIdioms.h"
 | |
| @@ -93,11 +97,14 @@
 | |
|  #include "Page.h"
 | |
|  #include "Pasteboard.h"
 | |
|  #include "PseudoElement.h"
 | |
| +#include "RenderLayer.h"
 | |
| +#include "RenderObject.h"
 | |
|  #include "RenderStyle.h"
 | |
|  #include "RenderStyleConstants.h"
 | |
|  #include "ScriptState.h"
 | |
|  #include "SelectorChecker.h"
 | |
|  #include "ShadowRoot.h"
 | |
| +#include "SharedBuffer.h"
 | |
|  #include "StaticNodeList.h"
 | |
|  #include "StyleProperties.h"
 | |
|  #include "StyleResolver.h"
 | |
| @@ -128,7 +135,8 @@ using namespace HTMLNames;
 | |
|  static const size_t maxTextSize = 10000;
 | |
|  static const UChar ellipsisUChar[] = { 0x2026, 0 };
 | |
|  
 | |
| -static Color parseColor(const JSON::Object* colorObject)
 | |
| +// static
 | |
| +Color InspectorDOMAgent::parseColor(const JSON::Object* colorObject)
 | |
|  {
 | |
|      if (!colorObject)
 | |
|          return Color::transparent;
 | |
| @@ -157,7 +165,7 @@ static Color parseConfigColor(const String& fieldName, const JSON::Object* confi
 | |
|      RefPtr<JSON::Object> colorObject;
 | |
|      configObject->getObject(fieldName, colorObject);
 | |
|  
 | |
| -    return parseColor(colorObject.get());
 | |
| +    return InspectorDOMAgent::parseColor(colorObject.get());
 | |
|  }
 | |
|  
 | |
|  static bool parseQuad(const JSON::Array& quadArray, FloatQuad* quad)
 | |
| @@ -438,6 +446,20 @@ Node* InspectorDOMAgent::assertNode(ErrorString& errorString, int nodeId)
 | |
|      return node;
 | |
|  }
 | |
|  
 | |
| +Node* InspectorDOMAgent::assertNode(ErrorString& errorString, const int* nodeId, const String* objectId)
 | |
| +{
 | |
| +    Node* node = nullptr;
 | |
| +    if (nodeId) {
 | |
| +        node = assertNode(errorString, *nodeId);
 | |
| +    } else if (objectId) {
 | |
| +        node = nodeForObjectId(*objectId);
 | |
| +        if (!node)
 | |
| +            errorString = "Missing node for given objectId"_s;
 | |
| +    } else
 | |
| +        errorString = "Either nodeId or objectId must be specified"_s;
 | |
| +    return node;
 | |
| +}
 | |
| +
 | |
|  Document* InspectorDOMAgent::assertDocument(ErrorString& errorString, int nodeId)
 | |
|  {
 | |
|      Node* node = assertNode(errorString, nodeId);
 | |
| @@ -1328,16 +1350,7 @@ void InspectorDOMAgent::highlightSelector(ErrorString& errorString, const JSON::
 | |
|  
 | |
|  void InspectorDOMAgent::highlightNode(ErrorString& errorString, const JSON::Object& highlightInspectorObject, const int* nodeId, const String* objectId)
 | |
|  {
 | |
| -    Node* node = nullptr;
 | |
| -    if (nodeId)
 | |
| -        node = assertNode(errorString, *nodeId);
 | |
| -    else if (objectId) {
 | |
| -        node = nodeForObjectId(*objectId);
 | |
| -        if (!node)
 | |
| -            errorString = "Missing node for given objectId"_s;
 | |
| -    } else
 | |
| -        errorString = "Either nodeId or objectId must be specified"_s;
 | |
| -
 | |
| +    Node* node = assertNode(errorString, nodeId, objectId);
 | |
|      if (!node)
 | |
|          return;
 | |
|  
 | |
| @@ -1485,18 +1498,147 @@ void InspectorDOMAgent::setInspectedNode(ErrorString& errorString, int nodeId)
 | |
|      m_suppressEventListenerChangedEvent = false;
 | |
|  }
 | |
|  
 | |
| -void InspectorDOMAgent::resolveNode(ErrorString& errorString, int nodeId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
 | |
| +static FloatPoint contentsToRootView(FrameView& containingView, const FloatPoint& point)
 | |
|  {
 | |
| -    String objectGroupName = objectGroup ? *objectGroup : emptyString();
 | |
| -    Node* node = assertNode(errorString, nodeId);
 | |
| +    return containingView.convertToRootView(point - toFloatSize(containingView.documentScrollPositionRelativeToViewOrigin()));
 | |
| +}
 | |
| +
 | |
| +static void frameQuadToViewport(FrameView& containingView, FloatQuad& quad, float pageScaleFactor)
 | |
| +{
 | |
| +    // Return css (not dip) coordinates by scaling back.
 | |
| +    quad.setP1(contentsToRootView(containingView, quad.p1()).scaled(1 / pageScaleFactor));
 | |
| +    quad.setP2(contentsToRootView(containingView, quad.p2()).scaled(1 / pageScaleFactor));
 | |
| +    quad.setP3(contentsToRootView(containingView, quad.p3()).scaled(1 / pageScaleFactor));
 | |
| +    quad.setP4(contentsToRootView(containingView, quad.p4()).scaled(1 / pageScaleFactor));
 | |
| +}
 | |
| +
 | |
| +static RefPtr<Inspector::Protocol::DOM::Quad> buildObjectForQuad(const FloatQuad& quad)
 | |
| +{
 | |
| +    auto result = Inspector::Protocol::DOM::Quad::create();
 | |
| +    result->addItem(quad.p1().x());
 | |
| +    result->addItem(quad.p1().y());
 | |
| +    result->addItem(quad.p2().x());
 | |
| +    result->addItem(quad.p2().y());
 | |
| +    result->addItem(quad.p3().x());
 | |
| +    result->addItem(quad.p3().y());
 | |
| +    result->addItem(quad.p4().x());
 | |
| +    result->addItem(quad.p4().y());
 | |
| +    return result;
 | |
| +}
 | |
| +
 | |
| +static RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::Quad>> buildArrayOfQuads(const Vector<FloatQuad>& quads)
 | |
| +{
 | |
| +    auto result = JSON::ArrayOf<Inspector::Protocol::DOM::Quad>::create();
 | |
| +    for (const auto& quad : quads)
 | |
| +        result->addItem(buildObjectForQuad(quad));
 | |
| +    return result;
 | |
| +}
 | |
| +
 | |
| +void InspectorDOMAgent::describeNode(ErrorString& errorString, const String& objectId, Optional<String>& contentFrameId, Optional<String>& ownerFrameId)
 | |
| +{
 | |
| +    Node* node = nodeForObjectId(objectId);
 | |
| +    if (!node) {
 | |
| +        errorString = "Node not found"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
 | |
| +    if (!pageAgent) {
 | |
| +        errorString = "Page agent must be enabled"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    String frameId = pageAgent->frameId(node->document().frame());
 | |
| +    if (!frameId.isEmpty())
 | |
| +        ownerFrameId = frameId;
 | |
| +
 | |
| +    if (is<HTMLFrameOwnerElement>(*node)) {
 | |
| +        const auto& frameOwner = downcast<HTMLFrameOwnerElement>(*node);
 | |
| +        String frameId = pageAgent->frameId(frameOwner.contentFrame());
 | |
| +        if (!frameId.isEmpty())
 | |
| +            contentFrameId = frameId;
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +void InspectorDOMAgent::scrollIntoViewIfNeeded(ErrorString& errorString, const String& objectId, const JSON::Object* rect)
 | |
| +{
 | |
| +    Node* node = nodeForObjectId(objectId);
 | |
| +    if (!node) {
 | |
| +        errorString = "Node not found"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    m_inspectedPage.updateRendering();
 | |
| +    if (!node->isConnected()) {
 | |
| +        errorString = "Node is detached from document"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    RenderObject* renderer = node->renderer();
 | |
| +    if (!renderer) {
 | |
| +        errorString = "Node does not have a layout object"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    bool insideFixed;
 | |
| +    LayoutRect absoluteBounds = renderer->absoluteBoundingBoxRect(true, &insideFixed);
 | |
| +    if (rect) {
 | |
| +        double x = 0.0;
 | |
| +        double y = 0.0;
 | |
| +        double width = 0.0;
 | |
| +        double height = 0.0;
 | |
| +        if (!rect->getDouble("x", x) || !rect->getDouble("y", y) || !rect->getDouble("width", width) || !rect->getDouble("height", height)) {
 | |
| +            errorString = "Malformed rect"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        absoluteBounds.setX(absoluteBounds.x() + LayoutUnit(x));
 | |
| +        absoluteBounds.setY(absoluteBounds.y() + LayoutUnit(y));
 | |
| +        absoluteBounds.setWidth(LayoutUnit(std::max(width, 1.0)));
 | |
| +        absoluteBounds.setHeight(LayoutUnit(std::max(height, 1.0)));
 | |
| +    }
 | |
| +    // Note: we should use ScrollAlignment::alignCenterIfNotVisible, but
 | |
| +    // RenderLayer insists on no horizontal scroll if enough of the rect is visible.
 | |
| +    ScrollAlignment alignment = ScrollAlignment::alignCenterAlways;
 | |
| +    renderer->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes });
 | |
| +}
 | |
| +
 | |
| +void InspectorDOMAgent::getContentQuads(ErrorString& errorString, const String& objectId, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::Quad>>& contentQuads)
 | |
| +{
 | |
| +    Node* node = nodeForObjectId(objectId);
 | |
| +    if (!node) {
 | |
| +        errorString = "Node not found"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    RenderObject* renderer = node->renderer();
 | |
| +    if (!renderer) {
 | |
| +        errorString = "Node doesn't have renderer"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    // Ensure quads are up to date.
 | |
| +    m_inspectedPage.updateRendering();
 | |
| +
 | |
| +    Frame* containingFrame = renderer->document().frame();
 | |
| +    FrameView* containingView = containingFrame ? containingFrame->view() : nullptr;
 | |
| +    if (!containingView) {
 | |
| +        errorString = "Internal error: no containing view"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    Vector<FloatQuad> quads;
 | |
| +    renderer->absoluteQuads(quads);
 | |
| +    for (auto& quad : quads)
 | |
| +        frameQuadToViewport(*containingView, quad, m_inspectedPage.pageScaleFactor());
 | |
| +    contentQuads = buildArrayOfQuads(quads);
 | |
| +}
 | |
| +
 | |
| +void InspectorDOMAgent::resolveNode(ErrorString& errorString, const int* nodeId, const String* objectId, const int* contextId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
 | |
| +{
 | |
| +    Node* node = assertNode(errorString, nodeId, objectId);
 | |
|      if (!node)
 | |
|          return;
 | |
| -    RefPtr<Inspector::Protocol::Runtime::RemoteObject> object = resolveNode(node, objectGroupName);
 | |
| -    if (!object) {
 | |
| +    String objectGroupName = objectGroup ? *objectGroup : emptyString();
 | |
| +    result = resolveNode(node, objectGroupName, contextId);
 | |
| +    if (!result) {
 | |
|          errorString = "Missing injected script for given nodeId"_s;
 | |
|          return;
 | |
|      }
 | |
| -    result = object;
 | |
|  }
 | |
|  
 | |
|  void InspectorDOMAgent::getAttributes(ErrorString& errorString, int nodeId, RefPtr<JSON::ArrayOf<String>>& result)
 | |
| @@ -2661,7 +2803,7 @@ void InspectorDOMAgent::pushNodeByPathToFrontend(ErrorString& errorString, const
 | |
|          errorString = "Missing node for given path"_s;
 | |
|  }
 | |
|  
 | |
| -RefPtr<Inspector::Protocol::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(Node* node, const String& objectGroup)
 | |
| +RefPtr<Inspector::Protocol::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(Node* node, const String& objectGroup, const int* contextId)
 | |
|  {
 | |
|      Document* document = &node->document();
 | |
|      if (auto* templateHost = document->templateDocumentHost())
 | |
| @@ -2670,12 +2812,16 @@ RefPtr<Inspector::Protocol::Runtime::RemoteObject> InspectorDOMAgent::resolveNod
 | |
|      if (!frame)
 | |
|          return nullptr;
 | |
|  
 | |
| -    auto& state = *mainWorldExecState(frame);
 | |
| -    auto injectedScript = m_injectedScriptManager.injectedScriptFor(&state);
 | |
| +    InjectedScript injectedScript;
 | |
| +    if (contextId) {
 | |
| +        injectedScript = m_injectedScriptManager.injectedScriptForId(*contextId);
 | |
| +    } else {
 | |
| +        injectedScript = m_injectedScriptManager.injectedScriptFor(mainWorldExecState(frame));
 | |
| +    }
 | |
|      if (injectedScript.hasNoValue())
 | |
|          return nullptr;
 | |
|  
 | |
| -    return injectedScript.wrapObject(nodeAsScriptValue(state, node), objectGroup);
 | |
| +    return injectedScript.wrapObject(nodeAsScriptValue(*injectedScript.globalObject(), node), objectGroup);
 | |
|  }
 | |
|  
 | |
|  Node* InspectorDOMAgent::scriptValueAsNode(JSC::JSValue value)
 | |
| @@ -2696,4 +2842,46 @@ void InspectorDOMAgent::setAllowEditingUserAgentShadowTrees(ErrorString&, bool a
 | |
|      m_allowEditingUserAgentShadowTrees = allow;
 | |
|  }
 | |
|  
 | |
| +void InspectorDOMAgent::setInputFiles(ErrorString& errorString, const String& objectId, const JSON::Array& files) {
 | |
| +    InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
 | |
| +    if (injectedScript.hasNoValue()) {
 | |
| +        errorString = "Can not find element's context for given id"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    Node* node = scriptValueAsNode(injectedScript.findObjectById(objectId));
 | |
| +    if (!node) {
 | |
| +        errorString = "Can not find element for given id"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    if (node->nodeType() != Node::ELEMENT_NODE || node->nodeName() != "INPUT") {
 | |
| +        errorString = "Not an input node"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    HTMLInputElement* element = static_cast<HTMLInputElement*>(node);
 | |
| +    Vector<Ref<File>> fileObjects;
 | |
| +    for (unsigned i = 0; i < files.length(); ++i) {
 | |
| +        RefPtr<JSON::Value> item = files.get(i);
 | |
| +        RefPtr<JSON::Object> obj;
 | |
| +        if (!item->asObject(obj)) {
 | |
| +            errorString = "Invalid file payload format"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        String name;
 | |
| +        String type;
 | |
| +        String data;
 | |
| +        if (!obj->getString("name", name) || !obj->getString("type", type) || !obj->getString("data", data)) {
 | |
| +            errorString = "Invalid file payload format"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        Vector<uint8_t> buffer;
 | |
| +        if (!base64Decode(data, buffer)) {
 | |
| +            errorString = "Unable to decode given content"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        fileObjects.append(File::create(Blob::create(SharedBuffer::create(WTFMove(buffer)), type), name));
 | |
| +    }
 | |
| +    RefPtr<FileList> fileList = FileList::create(WTFMove(fileObjects));
 | |
| +    element->setFiles(WTFMove(fileList));
 | |
| +}
 | |
| +
 | |
|  } // namespace WebCore
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorDOMAgent.h b/Source/WebCore/inspector/agents/InspectorDOMAgent.h
 | |
| index 7df0e83eb53d75c41c554f1401235ba21719414c..ae6f961a7b7fe63ece60e34210bf333bedef2eee 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorDOMAgent.h
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorDOMAgent.h
 | |
| @@ -54,6 +54,7 @@ namespace WebCore {
 | |
|  
 | |
|  class AXCoreObject;
 | |
|  class CharacterData;
 | |
| +class Color;
 | |
|  class DOMEditor;
 | |
|  class Document;
 | |
|  class Element;
 | |
| @@ -88,6 +89,7 @@ public:
 | |
|      static String toErrorString(Exception&&);
 | |
|  
 | |
|      static String documentURLString(Document*);
 | |
| +    static Color parseColor(const JSON::Object*);
 | |
|  
 | |
|      // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently.
 | |
|      // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics.
 | |
| @@ -129,7 +131,7 @@ public:
 | |
|      void performSearch(ErrorString&, const String& query, const JSON::Array* nodeIds, const bool* caseSensitive, String* searchId, int* resultCount) override;
 | |
|      void getSearchResults(ErrorString&, const String& searchId, int fromIndex, int toIndex, RefPtr<JSON::ArrayOf<int>>&) override;
 | |
|      void discardSearchResults(ErrorString&, const String& searchId) override;
 | |
| -    void resolveNode(ErrorString&, int nodeId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) override;
 | |
| +    void resolveNode(ErrorString&, const int* nodeId, const String* objectId, const int* contextId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) override;
 | |
|      void getAttributes(ErrorString&, int nodeId, RefPtr<JSON::ArrayOf<String>>& result) override;
 | |
|      void setInspectModeEnabled(ErrorString&, bool enabled, const JSON::Object* highlightConfig, const bool* showRulers) override;
 | |
|      void requestNode(ErrorString&, const String& objectId, int* nodeId) override;
 | |
| @@ -148,6 +150,10 @@ public:
 | |
|      void focus(ErrorString&, int nodeId) override;
 | |
|      void setInspectedNode(ErrorString&, int nodeId) override;
 | |
|      void setAllowEditingUserAgentShadowTrees(ErrorString&, bool allow) final;
 | |
| +    void describeNode(ErrorString&, const String& objectId, Optional<String>& contentFrameId, Optional<String>& ownerFrameId) override;
 | |
| +    void scrollIntoViewIfNeeded(ErrorString&, const String& objectId, const JSON::Object* rect) override;
 | |
| +    void getContentQuads(ErrorString&, const String& objectId, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::Quad>>&) override;
 | |
| +    void setInputFiles(ErrorString&, const String& objectId, const JSON::Array& files) override;
 | |
|  
 | |
|      // InspectorInstrumentation
 | |
|      int identifierForNode(Node&);
 | |
| @@ -185,7 +191,7 @@ public:
 | |
|      Node* nodeForId(int nodeId);
 | |
|      int boundNodeId(const Node*);
 | |
|  
 | |
| -    RefPtr<Inspector::Protocol::Runtime::RemoteObject> resolveNode(Node*, const String& objectGroup);
 | |
| +    RefPtr<Inspector::Protocol::Runtime::RemoteObject> resolveNode(Node*, const String& objectGroup, const int* contextId);
 | |
|      bool handleMousePress();
 | |
|      void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
 | |
|      void inspect(Node*);
 | |
| @@ -196,12 +202,15 @@ public:
 | |
|      void reset();
 | |
|  
 | |
|      Node* assertNode(ErrorString&, int nodeId);
 | |
| +    Node* assertNode(ErrorString&, const int* nodeId, const String* objectId);
 | |
|      Element* assertElement(ErrorString&, int nodeId);
 | |
|      Document* assertDocument(ErrorString&, int nodeId);
 | |
|  
 | |
|      bool hasBreakpointForEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
 | |
|      int idForEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
 | |
|  
 | |
| +    Node* nodeForObjectId(const String& objectId);
 | |
| +
 | |
|  private:
 | |
|  #if ENABLE(VIDEO)
 | |
|      void mediaMetricsTimerFired();
 | |
| @@ -228,9 +237,8 @@ private:
 | |
|      Ref<Inspector::Protocol::DOM::EventListener> buildObjectForEventListener(const RegisteredEventListener&, int identifier, EventTarget&, const AtomString& eventType, bool disabled, bool hasBreakpoint);
 | |
|      RefPtr<Inspector::Protocol::DOM::AccessibilityProperties> buildObjectForAccessibilityProperties(Node*);
 | |
|      void processAccessibilityChildren(AXCoreObject&, JSON::ArrayOf<int>&);
 | |
| -    
 | |
| +
 | |
|      Node* nodeForPath(const String& path);
 | |
| -    Node* nodeForObjectId(const String& objectId);
 | |
|  
 | |
|      void discardBindings();
 | |
|  
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h b/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h
 | |
| index ddbb5d5347f3beabe3cfab201d6838c896d21e39..25f1798cad5a4ef135a27d3bd5146798d1077a13 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h
 | |
| @@ -40,6 +40,7 @@ class DOMStorageFrontendDispatcher;
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| +class Color;
 | |
|  class Frame;
 | |
|  class Page;
 | |
|  class SecurityOrigin;
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp b/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
 | |
| index afcdd2a7faffe0bec982072d894bc85c6e30c44c..6d9e9d4f220a0cff557fb3b020bf29d8c2964d04 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
 | |
| @@ -44,6 +44,7 @@
 | |
|  #include "DocumentLoader.h"
 | |
|  #include "DocumentThreadableLoader.h"
 | |
|  #include "Frame.h"
 | |
| +#include "FormData.h"
 | |
|  #include "FrameLoader.h"
 | |
|  #include "HTTPHeaderMap.h"
 | |
|  #include "HTTPHeaderNames.h"
 | |
| @@ -56,6 +57,7 @@
 | |
|  #include "MIMETypeRegistry.h"
 | |
|  #include "MemoryCache.h"
 | |
|  #include "NetworkResourcesData.h"
 | |
| +#include "NetworkStateNotifier.h"
 | |
|  #include "Page.h"
 | |
|  #include "PlatformStrategies.h"
 | |
|  #include "ProgressTracker.h"
 | |
| @@ -99,6 +101,11 @@ using namespace Inspector;
 | |
|  
 | |
|  namespace {
 | |
|  
 | |
| +String inspectorInitiatorPrefix()
 | |
| +{
 | |
| +    return "InspectorPageAgent.navigate referrer:"_s;
 | |
| +}
 | |
| +
 | |
|  class InspectorThreadableLoaderClient final : public ThreadableLoaderClient {
 | |
|      WTF_MAKE_NONCOPYABLE(InspectorThreadableLoaderClient);
 | |
|  public:
 | |
| @@ -453,6 +460,13 @@ void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLo
 | |
|      for (auto& entry : m_extraRequestHeaders)
 | |
|          request.setHTTPHeaderField(entry.key, entry.value);
 | |
|  
 | |
| +    if (request.initiatorIdentifier().startsWith(inspectorInitiatorPrefix())) {
 | |
| +        String referrer = request.initiatorIdentifier().substring(inspectorInitiatorPrefix().length());
 | |
| +        if (!referrer.isEmpty())
 | |
| +            request.setHTTPReferrer(referrer);
 | |
| +        request.setInitiatorIdentifier(String());
 | |
| +    }
 | |
| +
 | |
|      auto protocolResourceType = InspectorPageAgent::resourceTypeJSON(type);
 | |
|  
 | |
|      Document* document = loader && loader->frame() ? loader->frame()->document() : nullptr;
 | |
| @@ -841,6 +855,7 @@ void InspectorNetworkAgent::disable(ErrorString&)
 | |
|      m_resourcesData->clear();
 | |
|      m_extraRequestHeaders.clear();
 | |
|  
 | |
| +    continuePendingRequests();
 | |
|      continuePendingResponses();
 | |
|  
 | |
|      setResourceCachingDisabled(false);
 | |
| @@ -864,6 +879,16 @@ bool InspectorNetworkAgent::shouldIntercept(URL url)
 | |
|      return false;
 | |
|  }
 | |
|  
 | |
| +void InspectorNetworkAgent::continuePendingRequests()
 | |
| +{
 | |
| +    for (auto& pendingRequest : m_pendingInterceptRequests.values()) {
 | |
| +        ResourceLoader* loader = pendingRequest->m_loader.get();
 | |
| +        if (loader->identifier())
 | |
| +            pendingRequest->m_callback(false);
 | |
| +    }
 | |
| +    m_pendingInterceptRequests.clear();
 | |
| +}
 | |
| +
 | |
|  void InspectorNetworkAgent::continuePendingResponses()
 | |
|  {
 | |
|      for (auto& pendingInterceptResponse : m_pendingInterceptResponses.values())
 | |
| @@ -1020,17 +1045,15 @@ void InspectorNetworkAgent::resolveWebSocket(ErrorString& errorString, const Str
 | |
|      result = injectedScript.wrapObject(webSocketAsScriptValue(state, webSocket), objectGroupName);
 | |
|  }
 | |
|  
 | |
| -void InspectorNetworkAgent::setInterceptionEnabled(ErrorString& errorString, bool enabled)
 | |
| +void InspectorNetworkAgent::setInterceptionEnabled(ErrorString&, bool enabled, const bool* interceptRequests)
 | |
|  {
 | |
| -    if (m_interceptionEnabled == enabled) {
 | |
| -        errorString = m_interceptionEnabled ? "Interception already enabled"_s : "Interception already disabled"_s;
 | |
| -        return;
 | |
| -    }
 | |
| -
 | |
|      m_interceptionEnabled = enabled;
 | |
| +    m_interceptRequests = interceptRequests && *interceptRequests;
 | |
|  
 | |
|      if (!m_interceptionEnabled)
 | |
|          continuePendingResponses();
 | |
| +    if (!m_interceptionEnabled || !m_interceptRequests)
 | |
| +        continuePendingRequests();
 | |
|  }
 | |
|  
 | |
|  void InspectorNetworkAgent::addInterception(ErrorString& errorString, const String& url, const bool* optionalCaseSensitive, const bool* optionalIsRegex, const String* networkStageString)
 | |
| @@ -1112,19 +1135,133 @@ void InspectorNetworkAgent::interceptResponse(const ResourceResponse& response,
 | |
|      m_frontendDispatcher->responseIntercepted(requestId, buildObjectForResourceResponse(response, nullptr));
 | |
|  }
 | |
|  
 | |
| -void InspectorNetworkAgent::interceptContinue(ErrorString& errorString, const String& requestId)
 | |
| -{
 | |
| +bool InspectorNetworkAgent::interceptRequest(ResourceLoader& loader, Function<void(bool handled)>&& handler) {
 | |
| +    if (!m_interceptionEnabled || !m_interceptRequests)
 | |
| +        return false;
 | |
| +    String requestId = IdentifiersFactory::requestId(loader.identifier());
 | |
| +    auto pendingRequest = makeUnique<PendingInterceptRequest>();
 | |
| +    pendingRequest->m_loader = &loader;
 | |
| +    pendingRequest->m_callback = WTFMove(handler);
 | |
| +    m_pendingInterceptRequests.set(requestId, WTFMove(pendingRequest));
 | |
| +    m_frontendDispatcher->requestIntercepted(requestId, buildObjectForResourceRequest(loader.request()));
 | |
| +    return true;
 | |
| +}
 | |
| +
 | |
| +void InspectorNetworkAgent::interceptContinue(ErrorString& errorString, const String& requestId, const String* method, const JSON::Object* headers, const String* postData)
 | |
| +{
 | |
| +    auto pendingRequest = m_pendingInterceptRequests.take(requestId);
 | |
| +    if (pendingRequest) {
 | |
| +        ResourceLoader* loader = pendingRequest->m_loader.get();
 | |
| +        if (!loader->identifier()) {
 | |
| +            // Do not throw upon continue of canceled requests.
 | |
| +            return;
 | |
| +        }
 | |
| +        // Safe to const cast at this point, we are only adjusting the method / headers / post.
 | |
| +        ResourceRequest* request = const_cast<ResourceRequest*>(&loader->request());
 | |
| +        if (method)
 | |
| +            request->setHTTPMethod(*method);
 | |
| +        if (headers) {
 | |
| +            HTTPHeaderMap explicitHeaders;
 | |
| +            for (auto& header : *headers) {
 | |
| +                String headerValue;
 | |
| +                if (header.value->asString(headerValue))
 | |
| +                    explicitHeaders.add(header.key, headerValue);
 | |
| +            }
 | |
| +            request->setHTTPHeaderFields(WTFMove(explicitHeaders));
 | |
| +        }
 | |
| +        if (postData) {
 | |
| +            Vector<uint8_t> buffer;
 | |
| +            if (!base64Decode(*postData, buffer)) {
 | |
| +                errorString = "Unable to decode given postData"_s;
 | |
| +                return;
 | |
| +            }
 | |
| +            Ref<FormData> data = FormData::create(buffer);
 | |
| +            request->setHTTPBody(WTFMove(data));
 | |
| +        }
 | |
| +        pendingRequest->m_callback(false);
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      auto pendingInterceptResponse = m_pendingInterceptResponses.take(requestId);
 | |
| -    if (!pendingInterceptResponse) {
 | |
| -        errorString = "Missing pending intercept response for given requestId"_s;
 | |
| +    if (pendingInterceptResponse) {
 | |
| +        pendingInterceptResponse->respondWithOriginalResponse();
 | |
|          return;
 | |
|      }
 | |
|  
 | |
| -    pendingInterceptResponse->respondWithOriginalResponse();
 | |
| +    errorString = "Missing pending intercept response for given requestId"_s;
 | |
|  }
 | |
|  
 | |
| -void InspectorNetworkAgent::interceptWithResponse(ErrorString& errorString, const String& requestId, const String& content, bool base64Encoded, const String* mimeType, const int* status, const String* statusText, const JSON::Object* headers)
 | |
| +void InspectorNetworkAgent::interceptAsError(ErrorString& errorString, const String& requestId, const String& reason)
 | |
|  {
 | |
| +    auto pendingRequest = m_pendingInterceptRequests.take(requestId);
 | |
| +    if (pendingRequest) {
 | |
| +        ResourceLoader* loader = pendingRequest->m_loader.get();
 | |
| +        if (!loader->identifier()) {
 | |
| +            errorString = "Unable to abort request, it has already been processed"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        ResourceError error(errorDomainWebKitInternal, 0, loader->url(), "Request intercepted"_s, ResourceError::Type::General);
 | |
| +        if (reason == "AccessControl")
 | |
| +            error = ResourceError(errorDomainWebKitInternal, 0, loader->url(), "Access denied"_s, ResourceError::Type::AccessControl);
 | |
| +        else if (reason == "Cancellation")
 | |
| +            error = ResourceError(errorDomainWebKitInternal, 0, loader->url(), "Request canceled"_s, ResourceError::Type::Cancellation);
 | |
| +        else if (reason == "Timeout")
 | |
| +            error = ResourceError(errorDomainWebKitInternal, 0, loader->url(), "Request timed out"_s, ResourceError::Type::Timeout);
 | |
| +        loader->didFail(error);
 | |
| +        pendingRequest->m_callback(true);
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    errorString = "Missing pending intercept response for given requestId"_s;
 | |
| +}
 | |
| +
 | |
| +void InspectorNetworkAgent::interceptWithResponse(ErrorString& errorString, const String& requestId, const String* content, const bool* base64Encoded, const String* mimeType, const int* status, const String* statusText, const JSON::Object* headers)
 | |
| +{
 | |
| +    auto pendingRequest = m_pendingInterceptRequests.take(requestId);
 | |
| +    if (pendingRequest && status && statusText && mimeType && headers) {
 | |
| +        RefPtr<ResourceLoader> loader = pendingRequest->m_loader.get();
 | |
| +        if (!loader->identifier()) {
 | |
| +            errorString = "Unable to fulfill request, it has already been processed"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        RefPtr<SharedBuffer> data;
 | |
| +        if (base64Encoded && *base64Encoded && content) {
 | |
| +            Vector<uint8_t> buffer;
 | |
| +            if (!base64Decode(*content, buffer)) {
 | |
| +                errorString = "Unable to decode given content"_s;
 | |
| +                return;
 | |
| +            }
 | |
| +            data = SharedBuffer::create(WTFMove(buffer));
 | |
| +        } else if (content) {
 | |
| +            data = SharedBuffer::create(content->utf8().data(), content->utf8().length());
 | |
| +        }
 | |
| +
 | |
| +        ResourceResponse response(pendingRequest->m_loader->url(), *mimeType, data->size(), String());
 | |
| +        response.setSource(ResourceResponse::Source::InspectorOverride);
 | |
| +        response.setHTTPStatusCode(*status);
 | |
| +        response.setHTTPStatusText(*statusText);
 | |
| +        HTTPHeaderMap explicitHeaders;
 | |
| +        for (auto& header : *headers) {
 | |
| +            String headerValue;
 | |
| +            if (header.value->asString(headerValue))
 | |
| +                explicitHeaders.add(header.key, headerValue);
 | |
| +        }
 | |
| +        response.setHTTPHeaderFields(WTFMove(explicitHeaders));
 | |
| +        response.setHTTPHeaderField(HTTPHeaderName::ContentType, response.mimeType());
 | |
| +        if (response.isRedirection()) {
 | |
| +            loader->setRequest(loader->request().redirectedRequest(response, false));
 | |
| +            pendingRequest->m_callback(false);
 | |
| +        } else {
 | |
| +            loader->didReceiveResponse(response, [loader, data = data.releaseNonNull()]() mutable {
 | |
| +                if (data->size())
 | |
| +                    loader->didReceiveBuffer(WTFMove(data), data->size(), DataPayloadWholeResource);
 | |
| +                loader->didFinishLoading(NetworkLoadMetrics());
 | |
| +            });
 | |
| +            pendingRequest->m_callback(true);
 | |
| +        }
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      auto pendingInterceptResponse = m_pendingInterceptResponses.take(requestId);
 | |
|      if (!pendingInterceptResponse) {
 | |
|          errorString = "Missing pending intercept response for given requestId"_s;
 | |
| @@ -1152,20 +1289,26 @@ void InspectorNetworkAgent::interceptWithResponse(ErrorString& errorString, cons
 | |
|      }
 | |
|  
 | |
|      RefPtr<SharedBuffer> overrideData;
 | |
| -    if (base64Encoded) {
 | |
| +    if (base64Encoded && *base64Encoded && content) {
 | |
|          Vector<uint8_t> buffer;
 | |
| -        if (!base64Decode(content, buffer)) {
 | |
| +        if (!base64Decode(*content, buffer)) {
 | |
|              errorString = "Unable to decode given content"_s;
 | |
|              pendingInterceptResponse->respondWithOriginalResponse();
 | |
|              return;
 | |
|          }
 | |
|          overrideData = SharedBuffer::create(WTFMove(buffer));
 | |
| -    } else
 | |
| -        overrideData = SharedBuffer::create(content.utf8().data(), content.utf8().length());
 | |
| +    } else if (content) {
 | |
| +        overrideData = SharedBuffer::create(content->utf8().data(), content->utf8().length());
 | |
| +    }
 | |
|  
 | |
|      pendingInterceptResponse->respond(overrideResponse, overrideData);
 | |
|  }
 | |
|  
 | |
| +void InspectorNetworkAgent::setEmulateOfflineState(ErrorString&, bool offline)
 | |
| +{
 | |
| +    platformStrategies()->loaderStrategy()->setEmulateOfflineState(offline);
 | |
| +}
 | |
| +
 | |
|  bool InspectorNetworkAgent::shouldTreatAsText(const String& mimeType)
 | |
|  {
 | |
|      return startsWithLettersIgnoringASCIICase(mimeType, "text/")
 | |
| @@ -1295,6 +1438,11 @@ void InspectorNetworkAgent::searchInRequest(ErrorString& errorString, const Stri
 | |
|      results = ContentSearchUtilities::searchInTextByLines(resourceData->content(), query, caseSensitive, isRegex);
 | |
|  }
 | |
|  
 | |
| +String InspectorNetworkAgent::createInitiatorIdentifierForInspectorNavigation(const String& referrer)
 | |
| +{
 | |
| +    return inspectorInitiatorPrefix() + referrer;
 | |
| +}
 | |
| +
 | |
|  void InspectorNetworkAgent::mainFrameNavigated(DocumentLoader& loader)
 | |
|  {
 | |
|      m_resourcesData->clear(loaderIdentifier(&loader));
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorNetworkAgent.h b/Source/WebCore/inspector/agents/InspectorNetworkAgent.h
 | |
| index bfd131e9b5856c84da7724805e71397b7c7486a9..724353b696bfc01c7f0aaf4a04a36dd22967b2f7 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorNetworkAgent.h
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorNetworkAgent.h
 | |
| @@ -87,11 +87,13 @@ public:
 | |
|      void loadResource(const String& frameId, const String& url, Ref<LoadResourceCallback>&&) final;
 | |
|      void getSerializedCertificate(ErrorString&, const String& requestId, String* serializedCertificate) final;
 | |
|      void resolveWebSocket(ErrorString&, const String& requestId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>&) final;
 | |
| -    void setInterceptionEnabled(ErrorString&, bool enabled) final;
 | |
| +    void setInterceptionEnabled(ErrorString&, bool enabled, const bool* interceptRequests) final;
 | |
|      void addInterception(ErrorString&, const String& url, const bool* caseSensitive, const bool* isRegex, const String* networkStageString) final;
 | |
|      void removeInterception(ErrorString&, const String& url, const bool* caseSensitive, const bool* isRegex, const String* networkStageString) final;
 | |
| -    void interceptContinue(ErrorString&, const String& requestId) final;
 | |
| -    void interceptWithResponse(ErrorString&, const String& requestId, const String& content, bool base64Encoded, const String* mimeType, const int* status, const String* statusText, const JSON::Object* headers) final;
 | |
| +    void interceptContinue(ErrorString&, const String& requestId, const String* method, const JSON::Object* headers, const String* postData) final;
 | |
| +    void interceptAsError(ErrorString&, const String& requestId, const String& reason) final;
 | |
| +    void interceptWithResponse(ErrorString&, const String& requestId, const String* content, const bool* base64Encoded, const String* mimeType, const int* status, const String* statusText, const JSON::Object* headers) final;
 | |
| +    void setEmulateOfflineState(ErrorString&, bool offline) final;
 | |
|  
 | |
|      // InspectorInstrumentation
 | |
|      void willRecalculateStyle();
 | |
| @@ -121,10 +123,13 @@ public:
 | |
|      bool willInterceptRequest(const ResourceRequest&);
 | |
|      bool shouldInterceptResponse(const ResourceResponse&);
 | |
|      void interceptResponse(const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 | |
| +    bool interceptRequest(ResourceLoader& loader, Function<void(bool handled)>&&);
 | |
|  
 | |
|      void searchOtherRequests(const JSC::Yarr::RegularExpression&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::SearchResult>>&);
 | |
|      void searchInRequest(ErrorString&, const String& requestId, const String& query, bool caseSensitive, bool isRegex, RefPtr<JSON::ArrayOf<Inspector::Protocol::GenericTypes::SearchMatch>>&);
 | |
|  
 | |
| +    static String createInitiatorIdentifierForInspectorNavigation(const String& referrer);
 | |
| +
 | |
|  protected:
 | |
|      InspectorNetworkAgent(WebAgentContext&);
 | |
|  
 | |
| @@ -141,6 +146,7 @@ private:
 | |
|      void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, InspectorPageAgent::ResourceType);
 | |
|  
 | |
|      bool shouldIntercept(URL);
 | |
| +    void continuePendingRequests();
 | |
|      void continuePendingResponses();
 | |
|  
 | |
|      WebSocket* webSocketForRequestId(const String& requestId);
 | |
| @@ -191,6 +197,15 @@ private:
 | |
|          bool m_responded { false };
 | |
|      };
 | |
|  
 | |
| +    class PendingInterceptRequest {
 | |
| +        WTF_MAKE_NONCOPYABLE(PendingInterceptRequest);
 | |
| +        WTF_MAKE_FAST_ALLOCATED;
 | |
| +    public:
 | |
| +        PendingInterceptRequest() = default;
 | |
| +        RefPtr<ResourceLoader> m_loader;
 | |
| +        CompletionHandler<void(bool handled)> m_callback;
 | |
| +    };
 | |
| +
 | |
|      std::unique_ptr<Inspector::NetworkFrontendDispatcher> m_frontendDispatcher;
 | |
|      RefPtr<Inspector::NetworkBackendDispatcher> m_backendDispatcher;
 | |
|      Inspector::InjectedScriptManager& m_injectedScriptManager;
 | |
| @@ -214,6 +229,7 @@ private:
 | |
|      };
 | |
|      Vector<Intercept> m_intercepts;
 | |
|      HashMap<String, std::unique_ptr<PendingInterceptResponse>> m_pendingInterceptResponses;
 | |
| +    HashMap<String, std::unique_ptr<PendingInterceptRequest>> m_pendingInterceptRequests;
 | |
|  
 | |
|      // FIXME: InspectorNetworkAgent should not be aware of style recalculation.
 | |
|      RefPtr<Inspector::Protocol::Network::Initiator> m_styleRecalculationInitiator;
 | |
| @@ -222,6 +238,7 @@ private:
 | |
|      bool m_enabled { false };
 | |
|      bool m_loadingXHRSynchronously { false };
 | |
|      bool m_interceptionEnabled { false };
 | |
| +    bool m_interceptRequests { false };
 | |
|  };
 | |
|  
 | |
|  } // namespace WebCore
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
 | |
| index 02edd43859609cc0fcd79bababd6f33955070da9..95d010d4462db3c17c1f06da74e615992f9fbd0d 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
 | |
| @@ -32,20 +32,27 @@
 | |
|  #include "config.h"
 | |
|  #include "InspectorPageAgent.h"
 | |
|  
 | |
| +#include "AXObjectCache.h"
 | |
| +#include "BackForwardController.h"
 | |
|  #include "CachedResource.h"
 | |
|  #include "CachedResourceLoader.h"
 | |
|  #include "Cookie.h"
 | |
|  #include "CookieJar.h"
 | |
|  #include "CustomHeaderFields.h"
 | |
| +#include "CSSAnimationController.h"
 | |
|  #include "DOMWrapperWorld.h"
 | |
|  #include "Document.h"
 | |
| +#include "DocumentTimeline.h"
 | |
|  #include "DocumentLoader.h"
 | |
| +#include "FocusController.h"
 | |
|  #include "Frame.h"
 | |
|  #include "FrameLoadRequest.h"
 | |
|  #include "FrameLoader.h"
 | |
| +#include "FrameLoaderClient.h"
 | |
|  #include "FrameSnapshotting.h"
 | |
|  #include "FrameView.h"
 | |
|  #include "HTMLFrameOwnerElement.h"
 | |
| +#include "HTMLInputElement.h"
 | |
|  #include "HTMLNames.h"
 | |
|  #include "ImageBuffer.h"
 | |
|  #include "InspectorClient.h"
 | |
| @@ -56,19 +63,30 @@
 | |
|  #include "MIMETypeRegistry.h"
 | |
|  #include "MemoryCache.h"
 | |
|  #include "Page.h"
 | |
| +#include "PageRuntimeAgent.h"
 | |
|  #include "RenderObject.h"
 | |
|  #include "RenderTheme.h"
 | |
| +#include "RuntimeEnabledFeatures.h"
 | |
|  #include "ScriptController.h"
 | |
|  #include "ScriptSourceCode.h"
 | |
| +#include "ScriptState.h"
 | |
|  #include "SecurityOrigin.h"
 | |
|  #include "Settings.h"
 | |
|  #include "StyleScope.h"
 | |
| +#include "SVGDocumentExtensions.h"
 | |
|  #include "TextEncoding.h"
 | |
| +#include "TypingCommand.h"
 | |
|  #include "UserGestureIndicator.h"
 | |
|  #include <JavaScriptCore/ContentSearchUtilities.h>
 | |
|  #include <JavaScriptCore/IdentifiersFactory.h>
 | |
| +#include <JavaScriptCore/InjectedScriptManager.h>
 | |
|  #include <JavaScriptCore/RegularExpression.h>
 | |
| +#include <wtf/DateMath.h>
 | |
|  #include <wtf/ListHashSet.h>
 | |
| +#include <wtf/MainThread.h>
 | |
| +#include <wtf/NeverDestroyed.h>
 | |
| +#include <wtf/Ref.h>
 | |
| +#include <wtf/RefPtr.h>
 | |
|  #include <wtf/Stopwatch.h>
 | |
|  #include <wtf/text/Base64.h>
 | |
|  #include <wtf/text/StringBuilder.h>
 | |
| @@ -81,11 +99,15 @@
 | |
|  #include "LegacyWebArchive.h"
 | |
|  #endif
 | |
|  
 | |
| -
 | |
|  namespace WebCore {
 | |
|  
 | |
|  using namespace Inspector;
 | |
|  
 | |
| +static HashMap<String, Ref<DOMWrapperWorld>>& createdUserWorlds() {
 | |
| +    static NeverDestroyed<HashMap<String, Ref<DOMWrapperWorld>>> nameToWorld;
 | |
| +    return nameToWorld;
 | |
| +}
 | |
| +
 | |
|  static bool decodeBuffer(const char* buffer, unsigned size, const String& textEncodingName, String* result)
 | |
|  {
 | |
|      if (buffer) {
 | |
| @@ -326,6 +348,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)
 | |
| +    , m_injectedScriptManager(context.injectedScriptManager)
 | |
|      , m_client(client)
 | |
|      , m_overlay(overlay)
 | |
|  {
 | |
| @@ -359,11 +382,20 @@ void InspectorPageAgent::enable(ErrorString& errorString)
 | |
|  #if HAVE(OS_DARK_MODE_SUPPORT)
 | |
|      defaultAppearanceDidChange(m_inspectedPage.defaultUseDarkAppearance());
 | |
|  #endif
 | |
| +
 | |
| +    if (!createdUserWorlds().isEmpty()) {
 | |
| +        Vector<DOMWrapperWorld*> worlds;
 | |
| +        for (const auto& world : createdUserWorlds().values())
 | |
| +            worlds.append(world.ptr());
 | |
| +        ensureUserWorldsExistInAllFrames(worlds);
 | |
| +    }
 | |
|  }
 | |
|  
 | |
|  void InspectorPageAgent::disable(ErrorString&)
 | |
|  {
 | |
|      m_instrumentingAgents.setInspectorPageAgent(nullptr);
 | |
| +    m_interceptFileChooserDialog = false;
 | |
| +    m_bypassCSP = false;
 | |
|  
 | |
|      ErrorString unused;
 | |
|      setShowPaintRects(unused, false);
 | |
| @@ -409,12 +441,34 @@ void InspectorPageAgent::reload(ErrorString&, const bool* optionalReloadFromOrig
 | |
|      m_inspectedPage.mainFrame().loader().reload(reloadOptions);
 | |
|  }
 | |
|  
 | |
| -void InspectorPageAgent::navigate(ErrorString&, const String& url)
 | |
| +void InspectorPageAgent::goBack(ErrorString& errorString)
 | |
| +{
 | |
| +    if (!m_inspectedPage.backForward().goBack())
 | |
| +        errorString = "Failed to go back"_s;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::goForward(ErrorString& errorString)
 | |
| +{
 | |
| +    if (!m_inspectedPage.backForward().goForward())
 | |
| +        errorString = "Failed to go forward"_s;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::navigate(ErrorString& errorString, const String& url, const String* frameId, const String* referrer)
 | |
|  {
 | |
|      UserGestureIndicator indicator { ProcessingUserGesture };
 | |
| -    Frame& frame = m_inspectedPage.mainFrame();
 | |
| +    Frame* maybeFrame = frameId ? assertFrame(errorString, *frameId) : &m_inspectedPage.mainFrame();
 | |
| +    if (!maybeFrame)
 | |
| +        return;
 | |
| +    Frame& frame = *maybeFrame;
 | |
|  
 | |
|      ResourceRequest resourceRequest { frame.document()->completeURL(url) };
 | |
| +    if (!resourceRequest.url().isValid()) {
 | |
| +        errorString = "Cannot navigate to invalid URL"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    if (referrer)
 | |
| +        resourceRequest.setInitiatorIdentifier(InspectorNetworkAgent::createInitiatorIdentifierForInspectorNavigation(*referrer));
 | |
| +
 | |
|      FrameLoadRequest frameLoadRequest { *frame.document(), frame.document()->securityOrigin(), WTFMove(resourceRequest), "_self"_s, InitiatedByMainFrame::Unknown };
 | |
|      frameLoadRequest.disableNavigationToInvalidURL();
 | |
|      frame.loader().changeLocation(WTFMove(frameLoadRequest));
 | |
| @@ -786,15 +840,16 @@ void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show)
 | |
|      m_overlay->setShowPaintRects(show);
 | |
|  }
 | |
|  
 | |
| -void InspectorPageAgent::domContentEventFired()
 | |
| +void InspectorPageAgent::domContentEventFired(Frame& frame)
 | |
|  {
 | |
| -    m_isFirstLayoutAfterOnLoad = true;
 | |
| -    m_frontendDispatcher->domContentEventFired(timestamp());
 | |
| +    if (frame.isMainFrame())
 | |
| +        m_isFirstLayoutAfterOnLoad = true;
 | |
| +    m_frontendDispatcher->domContentEventFired(timestamp(), frameId(&frame));
 | |
|  }
 | |
|  
 | |
| -void InspectorPageAgent::loadEventFired()
 | |
| +void InspectorPageAgent::loadEventFired(Frame& frame)
 | |
|  {
 | |
| -    m_frontendDispatcher->loadEventFired(timestamp());
 | |
| +    m_frontendDispatcher->loadEventFired(timestamp(), frameId(&frame));
 | |
|  }
 | |
|  
 | |
|  void InspectorPageAgent::frameNavigated(Frame& frame)
 | |
| @@ -802,13 +857,23 @@ void InspectorPageAgent::frameNavigated(Frame& frame)
 | |
|      m_frontendDispatcher->frameNavigated(buildObjectForFrame(&frame));
 | |
|  }
 | |
|  
 | |
| +String InspectorPageAgent::makeFrameID(ProcessIdentifier processID,  FrameIdentifier frameID)
 | |
| +{
 | |
| +    return makeString(processID.toUInt64(), ".", frameID.toUInt64());
 | |
| +}
 | |
| +
 | |
| +static String globalIDForFrame(Frame& frame)
 | |
| +{
 | |
| +    return InspectorPageAgent::makeFrameID(Process::identifier(), *frame.loader().client().frameID());
 | |
| +}
 | |
| +
 | |
|  void InspectorPageAgent::frameDetached(Frame& frame)
 | |
|  {
 | |
| -    auto identifier = m_frameToIdentifier.take(&frame);
 | |
| -    if (identifier.isNull())
 | |
| +    String identifier = globalIDForFrame(frame);
 | |
| +    if (!m_identifierToFrame.take(identifier))
 | |
|          return;
 | |
| +
 | |
|      m_frontendDispatcher->frameDetached(identifier);
 | |
| -    m_identifierToFrame.remove(identifier);
 | |
|  }
 | |
|  
 | |
|  Frame* InspectorPageAgent::frameForId(const String& frameId)
 | |
| @@ -820,20 +885,18 @@ String InspectorPageAgent::frameId(Frame* frame)
 | |
|  {
 | |
|      if (!frame)
 | |
|          return emptyString();
 | |
| -    return m_frameToIdentifier.ensure(frame, [this, frame] {
 | |
| -        auto identifier = IdentifiersFactory::createIdentifier();
 | |
| -        m_identifierToFrame.set(identifier, frame);
 | |
| -        return identifier;
 | |
| -    }).iterator->value;
 | |
| +
 | |
| +    String identifier = globalIDForFrame(*frame);
 | |
| +    m_identifierToFrame.set(identifier, frame);
 | |
| +    return identifier;
 | |
|  }
 | |
|  
 | |
|  String InspectorPageAgent::loaderId(DocumentLoader* loader)
 | |
|  {
 | |
|      if (!loader)
 | |
|          return emptyString();
 | |
| -    return m_loaderToIdentifier.ensure(loader, [] {
 | |
| -        return IdentifiersFactory::createIdentifier();
 | |
| -    }).iterator->value;
 | |
| +
 | |
| +    return String::number(loader->loaderIDForInspector());
 | |
|  }
 | |
|  
 | |
|  Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& frameId)
 | |
| @@ -844,11 +907,6 @@ Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& f
 | |
|      return frame;
 | |
|  }
 | |
|  
 | |
| -void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader& loader)
 | |
| -{
 | |
| -    m_loaderToIdentifier.remove(&loader);
 | |
| -}
 | |
| -
 | |
|  void InspectorPageAgent::frameStartedLoading(Frame& frame)
 | |
|  {
 | |
|      m_frontendDispatcher->frameStartedLoading(frameId(&frame));
 | |
| @@ -869,6 +927,12 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)
 | |
|      m_frontendDispatcher->frameClearedScheduledNavigation(frameId(&frame));
 | |
|  }
 | |
|  
 | |
| +void InspectorPageAgent::didNavigateWithinPage(Frame& frame)
 | |
| +{
 | |
| +    String url = frame.document()->url().string();
 | |
| +    m_frontendDispatcher->navigatedWithinDocument(frameId(&frame), url);
 | |
| +}
 | |
| +
 | |
|  void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance)
 | |
|  {
 | |
|      m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);
 | |
| @@ -926,6 +990,48 @@ void InspectorPageAgent::didRecalculateStyle()
 | |
|      m_overlay->update();
 | |
|  }
 | |
|  
 | |
| +void InspectorPageAgent::runOpenPanel(HTMLInputElement* element, bool* intercept)
 | |
| +{
 | |
| +    if (m_interceptFileChooserDialog) {
 | |
| +        *intercept = true;
 | |
| +    } else {
 | |
| +        return;
 | |
| +    }
 | |
| +    Document& document = element->document();
 | |
| +    auto* frame =  document.frame();
 | |
| +    if (!frame)
 | |
| +        return;
 | |
| +
 | |
| +    auto& state = *mainWorldExecState(frame);
 | |
| +    auto injectedScript = m_injectedScriptManager.injectedScriptFor(&state);
 | |
| +    if (injectedScript.hasNoValue())
 | |
| +        return;
 | |
| +
 | |
| +    m_frontendDispatcher->fileChooserOpened(frameId(frame), injectedScript.wrapObject(InspectorDOMAgent::nodeAsScriptValue(state, element), WTF::String()));
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::frameAttached(Frame& frame)
 | |
| +{
 | |
| +    Frame* parent = frame.tree().parent();
 | |
| +    String parentFrameId = frameId(parent);
 | |
| +    m_frontendDispatcher->frameAttached(frameId(&frame), parent ? &parentFrameId : nullptr);
 | |
| +}
 | |
| +
 | |
| +bool InspectorPageAgent::shouldBypassCSP()
 | |
| +{
 | |
| +    return m_bypassCSP;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::willCheckNewWindowPolicy(const URL& url)
 | |
| +{
 | |
| +    m_frontendDispatcher->willRequestOpenWindow(url.string());
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::didCheckNewWindowPolicy(bool allowed)
 | |
| +{
 | |
| +    m_frontendDispatcher->didRequestOpenWindow(allowed);
 | |
| +}
 | |
| +
 | |
|  Ref<Inspector::Protocol::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame)
 | |
|  {
 | |
|      ASSERT_ARG(frame, frame);
 | |
| @@ -1069,6 +1175,29 @@ void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, in
 | |
|      *outDataURL = snapshot->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
 | |
|  }
 | |
|  
 | |
| +void InspectorPageAgent::setTimeZone(ErrorString& errorString, const String* timeZone)
 | |
| +{
 | |
| +    if (!timeZone) {
 | |
| +        WTF::setTimeZoneForAutomation(String());
 | |
| +        return;
 | |
| +    }
 | |
| +    bool success = WTF::setTimeZoneForAutomation(*timeZone);
 | |
| +    if (!success)
 | |
| +        errorString = "Invalid time zone " + *timeZone;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setTouchEmulationEnabled(ErrorString& errorString, bool enabled)
 | |
| +{
 | |
| +#if ENABLE(TOUCH_EVENTS)
 | |
| +    RuntimeEnabledFeatures::sharedFeatures().setTouchEventsEnabled(enabled);
 | |
| +    UNUSED_PARAM(errorString);
 | |
| +#else
 | |
| +    UNUSED_PARAM(enabled);
 | |
| +    errorString = "Not supported"_s;
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +
 | |
|  void InspectorPageAgent::archive(ErrorString& errorString, String* data)
 | |
|  {
 | |
|  #if ENABLE(WEB_ARCHIVE) && USE(CF)
 | |
| @@ -1086,4 +1215,578 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)
 | |
|  #endif
 | |
|  }
 | |
|  
 | |
| +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)
 | |
| +{
 | |
| +    String computedRoleString = axObject->computedRoleString();
 | |
| +    if (!computedRoleString.isEmpty())
 | |
| +        return computedRoleString;
 | |
| +    AccessibilityRole role = axObject->roleValue();
 | |
| +    switch(role) {
 | |
| +        case AccessibilityRole::Annotation:
 | |
| +            return "Annotation";
 | |
| +        case AccessibilityRole::Application:
 | |
| +            return "Application";
 | |
| +        case AccessibilityRole::ApplicationAlert:
 | |
| +            return "ApplicationAlert";
 | |
| +        case AccessibilityRole::ApplicationAlertDialog:
 | |
| +            return "ApplicationAlertDialog";
 | |
| +        case AccessibilityRole::ApplicationDialog:
 | |
| +            return "ApplicationDialog";
 | |
| +        case AccessibilityRole::ApplicationGroup:
 | |
| +            return "ApplicationGroup";
 | |
| +        case AccessibilityRole::ApplicationLog:
 | |
| +            return "ApplicationLog";
 | |
| +        case AccessibilityRole::ApplicationMarquee:
 | |
| +            return "ApplicationMarquee";
 | |
| +        case AccessibilityRole::ApplicationStatus:
 | |
| +            return "ApplicationStatus";
 | |
| +        case AccessibilityRole::ApplicationTextGroup:
 | |
| +            return "ApplicationTextGroup";
 | |
| +        case AccessibilityRole::ApplicationTimer:
 | |
| +            return "ApplicationTimer";
 | |
| +        case AccessibilityRole::Audio:
 | |
| +            return "Audio";
 | |
| +        case AccessibilityRole::Blockquote:
 | |
| +            return "Blockquote";
 | |
| +        case AccessibilityRole::Browser:
 | |
| +            return "Browser";
 | |
| +        case AccessibilityRole::BusyIndicator:
 | |
| +            return "BusyIndicator";
 | |
| +        case AccessibilityRole::Button:
 | |
| +            return "Button";
 | |
| +        case AccessibilityRole::Canvas:
 | |
| +            return "Canvas";
 | |
| +        case AccessibilityRole::Caption:
 | |
| +            return "Caption";
 | |
| +        case AccessibilityRole::Cell:
 | |
| +            return "Cell";
 | |
| +        case AccessibilityRole::CheckBox:
 | |
| +            return "CheckBox";
 | |
| +        case AccessibilityRole::ColorWell:
 | |
| +            return "ColorWell";
 | |
| +        case AccessibilityRole::Column:
 | |
| +            return "Column";
 | |
| +        case AccessibilityRole::ColumnHeader:
 | |
| +            return "ColumnHeader";
 | |
| +        case AccessibilityRole::ComboBox:
 | |
| +            return "ComboBox";
 | |
| +        case AccessibilityRole::Definition:
 | |
| +            return "Definition";
 | |
| +        case AccessibilityRole::Deletion:
 | |
| +            return "Deletion";
 | |
| +        case AccessibilityRole::DescriptionList:
 | |
| +            return "DescriptionList";
 | |
| +        case AccessibilityRole::DescriptionListTerm:
 | |
| +            return "DescriptionListTerm";
 | |
| +        case AccessibilityRole::DescriptionListDetail:
 | |
| +            return "DescriptionListDetail";
 | |
| +        case AccessibilityRole::Details:
 | |
| +            return "Details";
 | |
| +        case AccessibilityRole::Directory:
 | |
| +            return "Directory";
 | |
| +        case AccessibilityRole::DisclosureTriangle:
 | |
| +            return "DisclosureTriangle";
 | |
| +        case AccessibilityRole::Div:
 | |
| +            return "Div";
 | |
| +        case AccessibilityRole::Document:
 | |
| +            return "Document";
 | |
| +        case AccessibilityRole::DocumentArticle:
 | |
| +            return "DocumentArticle";
 | |
| +        case AccessibilityRole::DocumentMath:
 | |
| +            return "DocumentMath";
 | |
| +        case AccessibilityRole::DocumentNote:
 | |
| +            return "DocumentNote";
 | |
| +        case AccessibilityRole::Drawer:
 | |
| +            return "Drawer";
 | |
| +        case AccessibilityRole::EditableText:
 | |
| +            return "EditableText";
 | |
| +        case AccessibilityRole::Feed:
 | |
| +            return "Feed";
 | |
| +        case AccessibilityRole::Figure:
 | |
| +            return "Figure";
 | |
| +        case AccessibilityRole::Footer:
 | |
| +            return "Footer";
 | |
| +        case AccessibilityRole::Footnote:
 | |
| +            return "Footnote";
 | |
| +        case AccessibilityRole::Form:
 | |
| +            return "Form";
 | |
| +        case AccessibilityRole::GraphicsDocument:
 | |
| +            return "GraphicsDocument";
 | |
| +        case AccessibilityRole::GraphicsObject:
 | |
| +            return "GraphicsObject";
 | |
| +        case AccessibilityRole::GraphicsSymbol:
 | |
| +            return "GraphicsSymbol";
 | |
| +        case AccessibilityRole::Grid:
 | |
| +            return "Grid";
 | |
| +        case AccessibilityRole::GridCell:
 | |
| +            return "GridCell";
 | |
| +        case AccessibilityRole::Group:
 | |
| +            return "Group";
 | |
| +        case AccessibilityRole::GrowArea:
 | |
| +            return "GrowArea";
 | |
| +        case AccessibilityRole::Heading:
 | |
| +            return "Heading";
 | |
| +        case AccessibilityRole::HelpTag:
 | |
| +            return "HelpTag";
 | |
| +        case AccessibilityRole::HorizontalRule:
 | |
| +            return "HorizontalRule";
 | |
| +        case AccessibilityRole::Ignored:
 | |
| +            return "Ignored";
 | |
| +        case AccessibilityRole::Inline:
 | |
| +            return "Inline";
 | |
| +        case AccessibilityRole::Image:
 | |
| +            return "Image";
 | |
| +        case AccessibilityRole::ImageMap:
 | |
| +            return "ImageMap";
 | |
| +        case AccessibilityRole::ImageMapLink:
 | |
| +            return "ImageMapLink";
 | |
| +        case AccessibilityRole::Incrementor:
 | |
| +            return "Incrementor";
 | |
| +        case AccessibilityRole::Insertion:
 | |
| +            return "Insertion";
 | |
| +        case AccessibilityRole::Label:
 | |
| +            return "Label";
 | |
| +        case AccessibilityRole::LandmarkBanner:
 | |
| +            return "LandmarkBanner";
 | |
| +        case AccessibilityRole::LandmarkComplementary:
 | |
| +            return "LandmarkComplementary";
 | |
| +        case AccessibilityRole::LandmarkContentInfo:
 | |
| +            return "LandmarkContentInfo";
 | |
| +        case AccessibilityRole::LandmarkDocRegion:
 | |
| +            return "LandmarkDocRegion";
 | |
| +        case AccessibilityRole::LandmarkMain:
 | |
| +            return "LandmarkMain";
 | |
| +        case AccessibilityRole::LandmarkNavigation:
 | |
| +            return "LandmarkNavigation";
 | |
| +        case AccessibilityRole::LandmarkRegion:
 | |
| +            return "LandmarkRegion";
 | |
| +        case AccessibilityRole::LandmarkSearch:
 | |
| +            return "LandmarkSearch";
 | |
| +        case AccessibilityRole::Legend:
 | |
| +            return "Legend";
 | |
| +        case AccessibilityRole::Link:
 | |
| +            return "Link";
 | |
| +        case AccessibilityRole::List:
 | |
| +            return "List";
 | |
| +        case AccessibilityRole::ListBox:
 | |
| +            return "ListBox";
 | |
| +        case AccessibilityRole::ListBoxOption:
 | |
| +            return "ListBoxOption";
 | |
| +        case AccessibilityRole::ListItem:
 | |
| +            return "ListItem";
 | |
| +        case AccessibilityRole::ListMarker:
 | |
| +            return "ListMarker";
 | |
| +        case AccessibilityRole::Mark:
 | |
| +            return "Mark";
 | |
| +        case AccessibilityRole::MathElement:
 | |
| +            return "MathElement";
 | |
| +        case AccessibilityRole::Matte:
 | |
| +            return "Matte";
 | |
| +        case AccessibilityRole::Menu:
 | |
| +            return "Menu";
 | |
| +        case AccessibilityRole::MenuBar:
 | |
| +            return "MenuBar";
 | |
| +        case AccessibilityRole::MenuButton:
 | |
| +            return "MenuButton";
 | |
| +        case AccessibilityRole::MenuItem:
 | |
| +            return "MenuItem";
 | |
| +        case AccessibilityRole::MenuItemCheckbox:
 | |
| +            return "MenuItemCheckbox";
 | |
| +        case AccessibilityRole::MenuItemRadio:
 | |
| +            return "MenuItemRadio";
 | |
| +        case AccessibilityRole::MenuListPopup:
 | |
| +            return "MenuListPopup";
 | |
| +        case AccessibilityRole::MenuListOption:
 | |
| +            return "MenuListOption";
 | |
| +        case AccessibilityRole::Meter:
 | |
| +            return "Meter";
 | |
| +        case AccessibilityRole::Outline:
 | |
| +            return "Outline";
 | |
| +        case AccessibilityRole::Paragraph:
 | |
| +            return "Paragraph";
 | |
| +        case AccessibilityRole::PopUpButton:
 | |
| +            return "PopUpButton";
 | |
| +        case AccessibilityRole::Pre:
 | |
| +            return "Pre";
 | |
| +        case AccessibilityRole::Presentational:
 | |
| +            return "Presentational";
 | |
| +        case AccessibilityRole::ProgressIndicator:
 | |
| +            return "ProgressIndicator";
 | |
| +        case AccessibilityRole::RadioButton:
 | |
| +            return "RadioButton";
 | |
| +        case AccessibilityRole::RadioGroup:
 | |
| +            return "RadioGroup";
 | |
| +        case AccessibilityRole::RowHeader:
 | |
| +            return "RowHeader";
 | |
| +        case AccessibilityRole::Row:
 | |
| +            return "Row";
 | |
| +        case AccessibilityRole::RowGroup:
 | |
| +            return "RowGroup";
 | |
| +        case AccessibilityRole::RubyBase:
 | |
| +            return "RubyBase";
 | |
| +        case AccessibilityRole::RubyBlock:
 | |
| +            return "RubyBlock";
 | |
| +        case AccessibilityRole::RubyInline:
 | |
| +            return "RubyInline";
 | |
| +        case AccessibilityRole::RubyRun:
 | |
| +            return "RubyRun";
 | |
| +        case AccessibilityRole::RubyText:
 | |
| +            return "RubyText";
 | |
| +        case AccessibilityRole::Ruler:
 | |
| +            return "Ruler";
 | |
| +        case AccessibilityRole::RulerMarker:
 | |
| +            return "RulerMarker";
 | |
| +        case AccessibilityRole::ScrollArea:
 | |
| +            return "ScrollArea";
 | |
| +        case AccessibilityRole::ScrollBar:
 | |
| +            return "ScrollBar";
 | |
| +        case AccessibilityRole::SearchField:
 | |
| +            return "SearchField";
 | |
| +        case AccessibilityRole::Sheet:
 | |
| +            return "Sheet";
 | |
| +        case AccessibilityRole::Slider:
 | |
| +            return "Slider";
 | |
| +        case AccessibilityRole::SliderThumb:
 | |
| +            return "SliderThumb";
 | |
| +        case AccessibilityRole::SpinButton:
 | |
| +            return "SpinButton";
 | |
| +        case AccessibilityRole::SpinButtonPart:
 | |
| +            return "SpinButtonPart";
 | |
| +        case AccessibilityRole::SplitGroup:
 | |
| +            return "SplitGroup";
 | |
| +        case AccessibilityRole::Splitter:
 | |
| +            return "Splitter";
 | |
| +        case AccessibilityRole::StaticText:
 | |
| +            return "StaticText";
 | |
| +        case AccessibilityRole::Subscript:
 | |
| +            return "Subscript";
 | |
| +        case AccessibilityRole::Summary:
 | |
| +            return "Summary";
 | |
| +        case AccessibilityRole::Superscript:
 | |
| +            return "Superscript";
 | |
| +        case AccessibilityRole::Switch:
 | |
| +            return "Switch";
 | |
| +        case AccessibilityRole::SystemWide:
 | |
| +            return "SystemWide";
 | |
| +        case AccessibilityRole::SVGRoot:
 | |
| +            return "SVGRoot";
 | |
| +        case AccessibilityRole::SVGText:
 | |
| +            return "SVGText";
 | |
| +        case AccessibilityRole::SVGTSpan:
 | |
| +            return "SVGTSpan";
 | |
| +        case AccessibilityRole::SVGTextPath:
 | |
| +            return "SVGTextPath";
 | |
| +        case AccessibilityRole::TabGroup:
 | |
| +            return "TabGroup";
 | |
| +        case AccessibilityRole::TabList:
 | |
| +            return "TabList";
 | |
| +        case AccessibilityRole::TabPanel:
 | |
| +            return "TabPanel";
 | |
| +        case AccessibilityRole::Tab:
 | |
| +            return "Tab";
 | |
| +        case AccessibilityRole::Table:
 | |
| +            return "Table";
 | |
| +        case AccessibilityRole::TableHeaderContainer:
 | |
| +            return "TableHeaderContainer";
 | |
| +        case AccessibilityRole::TextArea:
 | |
| +            return "TextArea";
 | |
| +        case AccessibilityRole::TextGroup:
 | |
| +            return "TextGroup";
 | |
| +        case AccessibilityRole::Term:
 | |
| +            return "Term";
 | |
| +        case AccessibilityRole::Time:
 | |
| +            return "Time";
 | |
| +        case AccessibilityRole::Tree:
 | |
| +            return "Tree";
 | |
| +        case AccessibilityRole::TreeGrid:
 | |
| +            return "TreeGrid";
 | |
| +        case AccessibilityRole::TreeItem:
 | |
| +            return "TreeItem";
 | |
| +        case AccessibilityRole::TextField:
 | |
| +            return "TextField";
 | |
| +        case AccessibilityRole::ToggleButton:
 | |
| +            return "ToggleButton";
 | |
| +        case AccessibilityRole::Toolbar:
 | |
| +            return "Toolbar";
 | |
| +        case AccessibilityRole::Unknown:
 | |
| +            return "Unknown";
 | |
| +        case AccessibilityRole::UserInterfaceTooltip:
 | |
| +            return "UserInterfaceTooltip";
 | |
| +        case AccessibilityRole::ValueIndicator:
 | |
| +            return "ValueIndicator";
 | |
| +        case AccessibilityRole::Video:
 | |
| +            return "Video";
 | |
| +        case AccessibilityRole::WebApplication:
 | |
| +            return "WebApplication";
 | |
| +        case AccessibilityRole::WebArea:
 | |
| +            return "WebArea";
 | |
| +        case AccessibilityRole::WebCoreLink:
 | |
| +            return "WebCoreLink";
 | |
| +        case AccessibilityRole::Window:
 | |
| +            return "Window";
 | |
| +    };
 | |
| +    return "Unknown";
 | |
| +}
 | |
| +
 | |
| +static RefPtr<Inspector::Protocol::Page::AXNode> snapshotForAXObject(RefPtr<AXCoreObject> axObject, Node* nodeToFind)
 | |
| +{
 | |
| +    auto axNode = Inspector::Protocol::Page::AXNode::create()
 | |
| +        .setRole(roleFromObject(axObject))
 | |
| +        .release();
 | |
| +
 | |
| +    if (!axObject->computedLabel().isEmpty())
 | |
| +        axNode->setName(axObject->computedLabel());
 | |
| +    if (!axObject->stringValue().isEmpty())
 | |
| +        axNode->setValue(JSON::Value::create(axObject->stringValue()));
 | |
| +    if (!axObject->accessibilityDescription().isEmpty())
 | |
| +        axNode->setDescription(axObject->accessibilityDescription());
 | |
| +    if (!axObject->keyShortcutsValue().isEmpty())
 | |
| +        axNode->setKeyshortcuts(axObject->keyShortcutsValue());
 | |
| +    if (!axObject->valueDescription().isEmpty())
 | |
| +        axNode->setValuetext(axObject->valueDescription());
 | |
| +    if (!axObject->roleDescription().isEmpty())
 | |
| +        axNode->setRoledescription(axObject->roleDescription());
 | |
| +    if (!axObject->isEnabled())
 | |
| +        axNode->setDisabled(!axObject->isEnabled());
 | |
| +    if (axObject->supportsExpanded())
 | |
| +        axNode->setExpanded(axObject->isExpanded());
 | |
| +    if (axObject->isFocused())
 | |
| +        axNode->setFocused(axObject->isFocused());
 | |
| +    if (axObject->isModalNode())
 | |
| +        axNode->setModal(axObject->isModalNode());
 | |
| +    bool multiline = axObject->ariaIsMultiline() || axObject->roleValue() == AccessibilityRole::TextArea;
 | |
| +    if (multiline)
 | |
| +        axNode->setMultiline(multiline);
 | |
| +    if (axObject->isMultiSelectable())
 | |
| +        axNode->setMultiselectable(axObject->isMultiSelectable());
 | |
| +    if (axObject->supportsReadOnly() && !axObject->canSetValueAttribute() && axObject->isEnabled())
 | |
| +        axNode->setReadonly(true);
 | |
| +    if (axObject->supportsRequiredAttribute())
 | |
| +        axNode->setRequired(axObject->isRequired());
 | |
| +    if (axObject->isSelected())
 | |
| +        axNode->setSelected(axObject->isSelected());
 | |
| +    if (axObject->supportsChecked()) {
 | |
| +        AccessibilityButtonState checkedState = axObject->checkboxOrRadioValue();
 | |
| +        switch (checkedState) {
 | |
| +            case AccessibilityButtonState::On:
 | |
| +                axNode->setChecked(Inspector::Protocol::Page::AXNode::Checked::True);
 | |
| +                break;
 | |
| +            case AccessibilityButtonState::Off:
 | |
| +                axNode->setChecked(Inspector::Protocol::Page::AXNode::Checked::False);
 | |
| +                break;
 | |
| +            case AccessibilityButtonState::Mixed:
 | |
| +                axNode->setChecked(Inspector::Protocol::Page::AXNode::Checked::Mixed);
 | |
| +                break;
 | |
| +        }
 | |
| +    }
 | |
| +    if (axObject->supportsPressed()) {
 | |
| +        AccessibilityButtonState checkedState = axObject->checkboxOrRadioValue();
 | |
| +        switch (checkedState) {
 | |
| +            case AccessibilityButtonState::On:
 | |
| +                axNode->setPressed(Inspector::Protocol::Page::AXNode::Pressed::True);
 | |
| +                break;
 | |
| +            case AccessibilityButtonState::Off:
 | |
| +                axNode->setPressed(Inspector::Protocol::Page::AXNode::Pressed::False);
 | |
| +                break;
 | |
| +            case AccessibilityButtonState::Mixed:
 | |
| +                axNode->setPressed(Inspector::Protocol::Page::AXNode::Pressed::Mixed);
 | |
| +                break;
 | |
| +        }
 | |
| +    }
 | |
| +    unsigned level = axObject->hierarchicalLevel() ? axObject->hierarchicalLevel() : axObject->headingLevel();
 | |
| +    if (level)
 | |
| +        axNode->setLevel(level);
 | |
| +    if (axObject->minValueForRange() != 0)
 | |
| +        axNode->setValuemin(axObject->minValueForRange());
 | |
| +    if (axObject->maxValueForRange() != 0)
 | |
| +        axNode->setValuemax(axObject->maxValueForRange());
 | |
| +    if (axObject->supportsAutoComplete())
 | |
| +        axNode->setAutocomplete(axObject->autoCompleteValue());
 | |
| +    if (axObject->hasPopup())
 | |
| +        axNode->setHaspopup(axObject->popupValue());
 | |
| +
 | |
| +    String invalidValue = axObject->invalidStatus();
 | |
| +    if (invalidValue != "false") {
 | |
| +        if (invalidValue == "grammar")
 | |
| +            axNode->setInvalid(Inspector::Protocol::Page::AXNode::Invalid::Grammar);
 | |
| +        else if (invalidValue == "spelling")
 | |
| +            axNode->setInvalid(Inspector::Protocol::Page::AXNode::Invalid::Spelling);
 | |
| +        else // Future versions of ARIA may allow additional truthy values. Ex. format, order, or size.
 | |
| +            axNode->setInvalid(Inspector::Protocol::Page::AXNode::Invalid::True);
 | |
| +    }
 | |
| +    switch (axObject->orientation()) {
 | |
| +        case AccessibilityOrientation::Undefined:
 | |
| +            break;
 | |
| +        case AccessibilityOrientation::Vertical:
 | |
| +            axNode->setOrientation("vertical"_s);
 | |
| +            break;
 | |
| +        case AccessibilityOrientation::Horizontal:
 | |
| +            axNode->setOrientation("horizontal"_s);
 | |
| +            break;
 | |
| +    }
 | |
| +
 | |
| +    if (axObject->isKeyboardFocusable())
 | |
| +        axNode->setFocusable(axObject->isKeyboardFocusable());
 | |
| +
 | |
| +    if (nodeToFind && axObject->node() == nodeToFind)
 | |
| +        axNode->setFound(true);
 | |
| +
 | |
| +    if (axObject->hasChildren()) {
 | |
| +        RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::AXNode>> children = JSON::ArrayOf<Inspector::Protocol::Page::AXNode>::create();
 | |
| +        for (auto& childObject : axObject->children())
 | |
| +            children->addItem(snapshotForAXObject(childObject, nodeToFind));
 | |
| +        axNode->setChildren(children);
 | |
| +    }
 | |
| +    return 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());
 | |
| +    if (!document) {
 | |
| +        errorString = "No document for main frame"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    AXObjectCache* axObjectCache = document->axObjectCache();
 | |
| +    if (!axObjectCache) {
 | |
| +        errorString = "No AXObjectCache for main document"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    AXCoreObject* axObject = axObjectCache->rootObject();
 | |
| +    if (!axObject) {
 | |
| +        errorString = "No AXObject for main document"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    Node* node = nullptr;
 | |
| +    if (objectId) {
 | |
| +        InspectorDOMAgent* domAgent = m_instrumentingAgents.inspectorDOMAgent();
 | |
| +        ASSERT(domAgent);
 | |
| +        node = domAgent->nodeForObjectId(*objectId);
 | |
| +        if (!node) {
 | |
| +            errorString = "No Node for objectId"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +    }
 | |
| +
 | |
| +    m_doingAccessibilitySnapshot = true;
 | |
| +    out_axNode = snapshotForAXObject(makeRefPtr(axObject), node);
 | |
| +    m_doingAccessibilitySnapshot = false;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setInterceptFileChooserDialog(ErrorString&, bool enabled)
 | |
| +{
 | |
| +    m_interceptFileChooserDialog = enabled;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setDefaultBackgroundColorOverride(ErrorString& errorString, const JSON::Object* color)
 | |
| +{
 | |
| +    FrameView* view = m_inspectedPage.mainFrame().view();
 | |
| +    if (!view) {
 | |
| +        errorString = "Internal error: No frame view to set color two"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    if (!color) {
 | |
| +        view->updateBackgroundRecursively(Optional<Color>());
 | |
| +        return;
 | |
| +    }
 | |
| +    view->updateBackgroundRecursively(InspectorDOMAgent::parseColor(color));
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::createUserWorld(ErrorString& errorString, const String& name)
 | |
| +{
 | |
| +    if (createdUserWorlds().contains(name)) {
 | |
| +        errorString = "World with the given name already exists"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    Ref<DOMWrapperWorld> world = ScriptController::createWorld(name, ScriptController::WorldType::User);
 | |
| +    ensureUserWorldsExistInAllFrames({world.ptr()});
 | |
| +    createdUserWorlds().set(name, WTFMove(world));
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::ensureUserWorldsExistInAllFrames(const Vector<DOMWrapperWorld*>& worlds)
 | |
| +{
 | |
| +    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
 | |
| +        for (auto* world : worlds)
 | |
| +            frame->windowProxy().jsWindowProxy(*world)->window();
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setBypassCSP(ErrorString&, bool enabled)
 | |
| +{
 | |
| +    m_bypassCSP = enabled;
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::crash(ErrorString&)
 | |
| +{
 | |
| +    CRASH();
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setScreenSizeOverride(ErrorString&, int width, int height)
 | |
| +{
 | |
| +    Optional<FloatSize> size;
 | |
| +    if (width && height)
 | |
| +        size = FloatSize(width, height);
 | |
| +    m_inspectedPage.setOverrideScreenSize(size);
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setOrientationOverride(Inspector::ErrorString& errorString, const int* angle)
 | |
| +{
 | |
| +#if ENABLE(ORIENTATION_EVENTS)
 | |
| +    UNUSED_PARAM(errorString);
 | |
| +    Optional<int> orientation;
 | |
| +    if (angle)
 | |
| +        orientation = *angle;
 | |
| +    m_inspectedPage.setOverrideOrientation(orientation);
 | |
| +#else
 | |
| +    errorString = "Orientation events are disabled in this build";
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +void InspectorPageAgent::setActivityPaused(Inspector::ErrorString&, bool paused)
 | |
| +{
 | |
| +    setMainThreadCallbacksPaused(paused);
 | |
| +    bool webAnimationsCSSIntegrationEnabled = RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled();
 | |
| +    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
 | |
| +        ASSERT(frame->document());
 | |
| +        auto& document = *frame->document();
 | |
| +        if (paused) {
 | |
| +            document.suspendScriptedAnimationControllerCallbacks();
 | |
| +            document.suspendActiveDOMObjects(ReasonForSuspension::JavaScriptDebuggerPaused);
 | |
| +            if (webAnimationsCSSIntegrationEnabled) {
 | |
| +                if (auto* timeline = document.existingTimeline())
 | |
| +                    timeline->suspendAnimations();
 | |
| +            }
 | |
| +            if (document.svgExtensions())
 | |
| +                document.accessSVGExtensions().pauseAnimations();
 | |
| +        } else {
 | |
| +            document.resumeActiveDOMObjects(ReasonForSuspension::JavaScriptDebuggerPaused);
 | |
| +            document.resumeScriptedAnimationControllerCallbacks();
 | |
| +            if (webAnimationsCSSIntegrationEnabled) {
 | |
| +                if (auto* timeline = document.existingTimeline())
 | |
| +                    timeline->resumeAnimations();
 | |
| +            }
 | |
| +            if (document.svgExtensions())
 | |
| +                document.accessSVGExtensions().unpauseAnimations();
 | |
| +        }
 | |
| +    }
 | |
| +    if (!webAnimationsCSSIntegrationEnabled) {
 | |
| +      if (paused)
 | |
| +        m_inspectedPage.mainFrame().legacyAnimation().suspendAnimations();
 | |
| +      else
 | |
| +        m_inspectedPage.mainFrame().legacyAnimation().resumeAnimations();
 | |
| +    }
 | |
| +}
 | |
| +
 | |
|  } // namespace WebCore
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h
 | |
| index 6c75829502336b0806db2531e78186d2c559e44c..1ad6b8e863c56fd572910db6c6fb524d367f2ad8 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorPageAgent.h
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h
 | |
| @@ -34,17 +34,23 @@
 | |
|  #include "CachedResource.h"
 | |
|  #include "InspectorWebAgentBase.h"
 | |
|  #include "LayoutRect.h"
 | |
| +#include "ProcessIdentifier.h"
 | |
|  #include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
|  #include <JavaScriptCore/InspectorFrontendDispatchers.h>
 | |
|  #include <wtf/HashMap.h>
 | |
|  #include <wtf/Seconds.h>
 | |
|  #include <wtf/text/WTFString.h>
 | |
|  
 | |
| +namespace Inspector {
 | |
| +class InjectedScriptManager;
 | |
| +}
 | |
| +
 | |
|  namespace WebCore {
 | |
|  
 | |
|  class DOMWrapperWorld;
 | |
|  class DocumentLoader;
 | |
|  class Frame;
 | |
| +class HTMLInputElement;
 | |
|  class InspectorClient;
 | |
|  class InspectorOverlay;
 | |
|  class Page;
 | |
| @@ -77,6 +83,7 @@ public:
 | |
|          OtherResource,
 | |
|      };
 | |
|  
 | |
| +    WEBCORE_EXPORT static String makeFrameID(ProcessIdentifier processID,  FrameIdentifier frameID);
 | |
|      static bool sharedBufferContent(RefPtr<SharedBuffer>&&, const String& textEncodingName, bool withBase64Encode, String* result);
 | |
|      static Vector<CachedResource*> cachedResourcesForFrame(Frame*);
 | |
|      static void resourceContent(ErrorString&, Frame*, const URL&, String* result, bool* base64Encoded);
 | |
| @@ -97,7 +104,9 @@ public:
 | |
|      void enable(ErrorString&) override;
 | |
|      void disable(ErrorString&) override;
 | |
|      void reload(ErrorString&, const bool* optionalReloadFromOrigin, const bool* optionalRevalidateAllResources) override;
 | |
| -    void navigate(ErrorString&, const String& url) override;
 | |
| +    void goBack(ErrorString&) override;
 | |
| +    void goForward(ErrorString&) override;
 | |
| +    void navigate(ErrorString&, const String& url, const String* frameId, const String* referrer) override;
 | |
|      void 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;
 | |
| @@ -112,20 +121,32 @@ public:
 | |
|      void setShowPaintRects(ErrorString&, bool show) override;
 | |
|      void setEmulatedMedia(ErrorString&, const String&) override;
 | |
|      void setForcedAppearance(ErrorString&, const String&) override;
 | |
| +    void setTimeZone(ErrorString&, const String*) override;
 | |
| +    void setTouchEmulationEnabled(ErrorString&, bool) override;
 | |
|      void snapshotNode(ErrorString&, int nodeId, String* outDataURL) override;
 | |
| -    void snapshotRect(ErrorString&, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL) override;
 | |
| +    void snapshotRect(ErrorString&, int x, int y, int width,  int height, const String& coordinateSystem, String* outDataURL) override;
 | |
|      void archive(ErrorString&, String* data) override;
 | |
| +    void insertText(ErrorString&, const String& text) override;
 | |
| +    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 createUserWorld(ErrorString&, const String&) override;
 | |
| +    void setBypassCSP(ErrorString&, bool) override;
 | |
| +    void crash(ErrorString&) override;
 | |
| +    void setScreenSizeOverride(ErrorString&, int width, int height) override;
 | |
| +    void setOrientationOverride(Inspector::ErrorString&, const int* angle) override;
 | |
| +    void setActivityPaused(Inspector::ErrorString&, bool) override;
 | |
|  
 | |
|      // InspectorInstrumentation
 | |
| -    void domContentEventFired();
 | |
| -    void loadEventFired();
 | |
| +    void domContentEventFired(Frame&);
 | |
| +    void loadEventFired(Frame&);
 | |
|      void frameNavigated(Frame&);
 | |
|      void frameDetached(Frame&);
 | |
| -    void loaderDetachedFromFrame(DocumentLoader&);
 | |
|      void frameStartedLoading(Frame&);
 | |
|      void frameStoppedLoading(Frame&);
 | |
|      void frameScheduledNavigation(Frame&, Seconds delay);
 | |
|      void frameClearedScheduledNavigation(Frame&);
 | |
| +    void didNavigateWithinPage(Frame&);
 | |
|      void defaultAppearanceDidChange(bool useDarkAppearance);
 | |
|      void applyUserAgentOverride(String&);
 | |
|      void applyEmulatedMedia(String&);
 | |
| @@ -134,6 +155,12 @@ public:
 | |
|      void didLayout();
 | |
|      void didScroll();
 | |
|      void didRecalculateStyle();
 | |
| +    void runOpenPanel(HTMLInputElement* element, bool* intercept);
 | |
| +    void frameAttached(Frame&);
 | |
| +    bool shouldBypassCSP();
 | |
| +    void willCheckNewWindowPolicy(const URL&);
 | |
| +    void didCheckNewWindowPolicy(bool allowed);
 | |
| +    bool doingAccessibilitySnapshot() const { return m_doingAccessibilitySnapshot; };
 | |
|  
 | |
|      Frame* frameForId(const String& frameId);
 | |
|      WEBCORE_EXPORT String frameId(Frame*);
 | |
| @@ -142,6 +169,7 @@ public:
 | |
|  
 | |
|  private:
 | |
|      double timestamp();
 | |
| +    void ensureUserWorldsExistInAllFrames(const Vector<DOMWrapperWorld*>&);
 | |
|  
 | |
|      static bool mainResourceContent(Frame*, bool withBase64Encode, String* result);
 | |
|      static bool dataContent(const char* data, unsigned size, const String& textEncodingName, bool withBase64Encode, String* result);
 | |
| @@ -153,18 +181,20 @@ private:
 | |
|      RefPtr<Inspector::PageBackendDispatcher> m_backendDispatcher;
 | |
|  
 | |
|      Page& m_inspectedPage;
 | |
| +    Inspector::InjectedScriptManager& m_injectedScriptManager;
 | |
|      InspectorClient* m_client { nullptr };
 | |
|      InspectorOverlay* m_overlay { nullptr };
 | |
|  
 | |
| -    HashMap<Frame*, String> m_frameToIdentifier;
 | |
|      HashMap<String, Frame*> m_identifierToFrame;
 | |
| -    HashMap<DocumentLoader*, String> m_loaderToIdentifier;
 | |
|      String m_userAgentOverride;
 | |
|      String m_emulatedMedia;
 | |
|      String m_forcedAppearance;
 | |
|      String m_bootstrapScript;
 | |
|      bool m_isFirstLayoutAfterOnLoad { false };
 | |
|      bool m_showPaintRects { false };
 | |
| +    bool m_interceptFileChooserDialog { false };
 | |
| +    bool m_bypassCSP { false };
 | |
| +    bool m_doingAccessibilitySnapshot { false };
 | |
|  };
 | |
|  
 | |
|  } // namespace WebCore
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorScreencastAgent.cpp b/Source/WebCore/inspector/agents/InspectorScreencastAgent.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..13ca5202e8e3ee5add01634037c2111798c58936
 | |
| --- /dev/null
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorScreencastAgent.cpp
 | |
| @@ -0,0 +1,150 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "InspectorScreencastAgent.h"
 | |
| +
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +
 | |
| +#include "Page.h"
 | |
| +#include "FrameSnapshotting.h"
 | |
| +#include "ImageBuffer.h"
 | |
| +#include <JavaScriptCore/InspectorFrontendDispatchers.h>
 | |
| +#include <JavaScriptCore/InspectorFrontendRouter.h>
 | |
| +
 | |
| +namespace WebCore {
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +InspectorScreencastAgent::InspectorScreencastAgent(PageAgentContext& context)
 | |
| +    : InspectorAgentBase("Screencast"_s, context)
 | |
| +    , m_frontendDispatcher(makeUnique<ScreencastFrontendDispatcher>(context.frontendRouter))
 | |
| +    , m_backendDispatcher(ScreencastBackendDispatcher::create(context.backendDispatcher, this))
 | |
| +    , m_inspectedPage(context.inspectedPage)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +InspectorScreencastAgent::~InspectorScreencastAgent()
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::willDestroyFrontendAndBackend(DisconnectReason)
 | |
| +{
 | |
| +    ErrorString errorString;
 | |
| +    stop(errorString);
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::start(Inspector::ErrorString& errorString, const String& format, const int* quality)
 | |
| +{
 | |
| +    if (isEnabled())
 | |
| +      return;
 | |
| +
 | |
| +    if (format == "jpeg") {
 | |
| +        m_format = "image/jpeg";
 | |
| +    } else if (format == "png") {
 | |
| +        m_format = "image/png";
 | |
| +    } else {
 | |
| +        errorString = "Unsupported format."_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    if (quality && (*quality < 0 || *quality >100)) {
 | |
| +        errorString = "Unsupported quality."_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    if (quality)
 | |
| +        m_quality = *quality;
 | |
| +    m_instrumentingAgents.setInspectorScreencastAgent(this);
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::stop(Inspector::ErrorString&)
 | |
| +{
 | |
| +    if (!isEnabled())
 | |
| +      return;
 | |
| +
 | |
| +    m_instrumentingAgents.setInspectorScreencastAgent(nullptr);
 | |
| +    m_inflightFrames = 0;
 | |
| +    m_quality = WTF::nullopt;
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::frameAck(Inspector::ErrorString& errorString)
 | |
| +{
 | |
| +    if (!m_inflightFrames) {
 | |
| +        errorString = "No inflight frames to ack"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    --m_inflightFrames;
 | |
| +}
 | |
| +
 | |
| +bool InspectorScreencastAgent::isEnabled() const
 | |
| +{
 | |
| +    return m_instrumentingAgents.inspectorScreencastAgent();
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::willDisplay()
 | |
| +{
 | |
| +    if (!isEnabled())
 | |
| +        return;
 | |
| +
 | |
| +    if (m_inflightFrames > 2)
 | |
| +        return;
 | |
| +
 | |
| +    String snapshot = takeSnapshot();
 | |
| +    if (snapshot.isEmpty())
 | |
| +        return;
 | |
| +
 | |
| +    ++m_inflightFrames;
 | |
| +    m_frontendDispatcher->frame(snapshot);
 | |
| +}
 | |
| +
 | |
| +String InspectorScreencastAgent::takeSnapshot()
 | |
| +{
 | |
| +    SnapshotOptions options = SnapshotOptionsNone;
 | |
| +    options |= SnapshotOptionsInViewCoordinates;
 | |
| +    IntSize size = m_inspectedPage.mainFrame().view()->visibleSize();
 | |
| +    fprintf(stderr, "view().visibleSize() = %s\n", size.toJSONString().ascii().data());
 | |
| +    IntRect rectangle({0, 0}, size);
 | |
| +    std::unique_ptr<ImageBuffer> snapshot = snapshotFrameRect(m_inspectedPage.mainFrame(), rectangle, options);
 | |
| +
 | |
| +    if (!snapshot)
 | |
| +        return String();
 | |
| +
 | |
| +    Optional<double> quality;
 | |
| +    if (m_quality)
 | |
| +        quality = *m_quality / 100.0;
 | |
| +
 | |
| +    Vector<uint8_t> data = snapshot->toData(m_format, quality);
 | |
| +    return base64Encode(data);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebCore
 | |
| +
 | |
| +#endif  // PLATFORM(WPE) || PLATFORM(WIN)
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorScreencastAgent.h b/Source/WebCore/inspector/agents/InspectorScreencastAgent.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..031911914c9fd89fb3ee8e42a95f97cdf1b9c4cd
 | |
| --- /dev/null
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorScreencastAgent.h
 | |
| @@ -0,0 +1,79 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +
 | |
| +#include "InspectorWebAgentBase.h"
 | |
| +#include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| +#include <JavaScriptCore/InspectorFrontendDispatchers.h>
 | |
| +
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/Noncopyable.h>
 | |
| +#include <wtf/WeakPtr.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class BackendDispatcher;
 | |
| +class FrontendChannel;
 | |
| +class FrontendRouter;
 | |
| +class ScreencastFrontendDispatcher;
 | |
| +}
 | |
| +
 | |
| +namespace WebCore {
 | |
| +
 | |
| +class Page;
 | |
| +
 | |
| +class InspectorScreencastAgent : public InspectorAgentBase, public Inspector::ScreencastBackendDispatcherHandler, public CanMakeWeakPtr<InspectorScreencastAgent> {
 | |
| +    WTF_MAKE_NONCOPYABLE(InspectorScreencastAgent);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorScreencastAgent(PageAgentContext&);
 | |
| +    ~InspectorScreencastAgent() override;
 | |
| +
 | |
| +    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
 | |
| +    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
 | |
| +
 | |
| +    void start(Inspector::ErrorString&, const String& format, const int* quality) override;
 | |
| +    void stop(Inspector::ErrorString&) override;
 | |
| +    void frameAck(Inspector::ErrorString&) override;
 | |
| +
 | |
| +    void willDisplay();
 | |
| +
 | |
| +private:
 | |
| +    bool isEnabled() const;
 | |
| +    String takeSnapshot();
 | |
| +
 | |
| +    std::unique_ptr<Inspector::ScreencastFrontendDispatcher> m_frontendDispatcher;
 | |
| +    Ref<Inspector::ScreencastBackendDispatcher> m_backendDispatcher;
 | |
| +    Page& m_inspectedPage;
 | |
| +    int m_inflightFrames { 0 };
 | |
| +    String m_format;
 | |
| +    Optional<int> m_quality;
 | |
| +};
 | |
| +
 | |
| +} // namespace WebCore
 | |
| +
 | |
| +#endif // PLATFORM(WPE) || PLATFORM(WIN)
 | |
| diff --git a/Source/WebCore/inspector/agents/InspectorWorkerAgent.cpp b/Source/WebCore/inspector/agents/InspectorWorkerAgent.cpp
 | |
| index a7a20f7234743d65382b5c93077c95f2bfa793bb..ba10548085cc4012c1d42d78112445c9a5777070 100644
 | |
| --- a/Source/WebCore/inspector/agents/InspectorWorkerAgent.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/InspectorWorkerAgent.cpp
 | |
| @@ -160,7 +160,11 @@ void InspectorWorkerAgent::connectToWorkerInspectorProxy(WorkerInspectorProxy& p
 | |
|  
 | |
|      m_connectedProxies.set(proxy.identifier(), &proxy);
 | |
|  
 | |
| -    m_frontendDispatcher->workerCreated(proxy.identifier(), proxy.url().string(), proxy.name());
 | |
| +    ASSERT(is<Document>(proxy.scriptExecutionContext()));
 | |
| +    Document& document = downcast<Document>(*proxy.scriptExecutionContext());
 | |
| +    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
 | |
| +    m_frontendDispatcher->workerCreated(proxy.identifier(), proxy.url().string(), proxy.name(),
 | |
| +        pageAgent ? pageAgent->frameId(document.frame()) : emptyString());
 | |
|  }
 | |
|  
 | |
|  void InspectorWorkerAgent::disconnectFromWorkerInspectorProxy(WorkerInspectorProxy& proxy)
 | |
| diff --git a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp b/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
 | |
| index cc0b0526f19f806ce621521d0771cc5f30d43840..6b54fa315ac22af78f2bf1befef204ca48308200 100644
 | |
| --- a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
 | |
| @@ -38,6 +38,7 @@
 | |
|  #include "Frame.h"
 | |
|  #include "InspectorPageAgent.h"
 | |
|  #include "InstrumentingAgents.h"
 | |
| +#include "JSDOMWindowBase.h"
 | |
|  #include "Page.h"
 | |
|  #include "PageConsoleClient.h"
 | |
|  #include "PageScriptDebugServer.h"
 | |
| @@ -70,8 +71,11 @@ bool PageDebuggerAgent::enabled() const
 | |
|  
 | |
|  void PageDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
 | |
|  {
 | |
| +    InjectedScript injectedScript = injectedScriptManager().injectedScriptForObjectId(callFrameId);
 | |
| +    JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
 | |
| +    Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
 | |
|      auto shouldEmulateUserGesture = emulateUserGesture && *emulateUserGesture;
 | |
| -    UserGestureEmulationScope userGestureScope(m_inspectedPage, shouldEmulateUserGesture);
 | |
| +    UserGestureEmulationScope userGestureScope(m_inspectedPage, shouldEmulateUserGesture, document);
 | |
|  
 | |
|      WebDebuggerAgent::evaluateOnCallFrame(errorString, callFrameId, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
 | |
|  }
 | |
| diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
 | |
| index 63336051bb0050d6a55eb5543b0349eb964bbb7a..eecfb5a50196c6d9ca353e9b7aedbd4d6feb690c 100644
 | |
| --- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
 | |
| @@ -35,12 +35,14 @@
 | |
|  #include "DOMWrapperWorld.h"
 | |
|  #include "Document.h"
 | |
|  #include "Frame.h"
 | |
| +#include "FrameLoader.h"
 | |
|  #include "InspectorPageAgent.h"
 | |
|  #include "InstrumentingAgents.h"
 | |
|  #include "JSDOMWindowBase.h"
 | |
|  #include "Page.h"
 | |
|  #include "PageConsoleClient.h"
 | |
|  #include "ScriptController.h"
 | |
| +#include "ScriptSourceCode.h"
 | |
|  #include "ScriptState.h"
 | |
|  #include "SecurityOrigin.h"
 | |
|  #include "UserGestureEmulationScope.h"
 | |
| @@ -106,6 +108,15 @@ void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld
 | |
|      notifyContextCreated(pageAgent->frameId(&frame), frame.script().globalObject(world), world);
 | |
|  }
 | |
|  
 | |
| +void PageRuntimeAgent::didReceiveMainResourceError(Frame& frame)
 | |
| +{
 | |
| +    if (frame.loader().stateMachine().isDisplayingInitialEmptyDocument()) {
 | |
| +        // Ensure execution context is created for the empty docment to make
 | |
| +        // it usable in case loading failed.
 | |
| +        mainWorldExecState(&frame);
 | |
| +    }
 | |
| +}
 | |
| +
 | |
|  InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
 | |
|  {
 | |
|      if (!executionContextId) {
 | |
| @@ -194,13 +205,21 @@ void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobal
 | |
|  
 | |
|  void PageRuntimeAgent::evaluate(ErrorString& errorString, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
 | |
|  {
 | |
| -    UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture));
 | |
| +    InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
 | |
| +    if (!errorString.isEmpty())
 | |
| +        return;
 | |
| +    JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
 | |
| +    Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
 | |
| +    UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture), document);
 | |
|      InspectorRuntimeAgent::evaluate(errorString, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, executionContextId, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
 | |
|  }
 | |
|  
 | |
|  void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const JSON::Array* optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown)
 | |
|  {
 | |
| -    UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture));
 | |
| +    InjectedScript injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
 | |
| +    JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
 | |
| +    Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
 | |
| +    UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture), document);
 | |
|      InspectorRuntimeAgent::callFunctionOn(errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
 | |
| index 2af3739b7fe7c16faa7d8d2797ce6d010215398d..80bfde6120874e16fb173f707fd0bd8a3e5067a0 100644
 | |
| --- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
 | |
| +++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
 | |
| @@ -63,6 +63,7 @@ public:
 | |
|      // InspectorInstrumentation
 | |
|      void frameNavigated(Frame&);
 | |
|      void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
 | |
| +    void didReceiveMainResourceError(Frame&);
 | |
|  
 | |
|  private:
 | |
|      Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
 | |
| @@ -73,7 +74,6 @@ private:
 | |
|  
 | |
|      std::unique_ptr<Inspector::RuntimeFrontendDispatcher> m_frontendDispatcher;
 | |
|      RefPtr<Inspector::RuntimeBackendDispatcher> m_backendDispatcher;
 | |
| -
 | |
|      InstrumentingAgents& m_instrumentingAgents;
 | |
|  
 | |
|      Page& m_inspectedPage;
 | |
| diff --git a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp
 | |
| index 633bce6e8f3c0785632eb7f26d172f6016b3efd9..14f531504bb2b96646d1a48092a0b132b0510f55 100644
 | |
| --- a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp
 | |
| +++ b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp
 | |
| @@ -39,9 +39,9 @@
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| -UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture)
 | |
| +UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document)
 | |
|      : m_pageChromeClient(inspectedPage.chrome().client())
 | |
| -    , m_gestureIndicator(emulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt)
 | |
| +    , m_gestureIndicator(emulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt, document)
 | |
|      , m_emulateUserGesture(emulateUserGesture)
 | |
|      , m_userWasInteracting(false)
 | |
|  {
 | |
| diff --git a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h
 | |
| index b94ed78ad3dbea19543c1fd54653f0481e52fb7c..6341c7ff7ef53577f33c19ecad1b8bfbd674d051 100644
 | |
| --- a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h
 | |
| +++ b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h
 | |
| @@ -38,11 +38,12 @@ namespace WebCore {
 | |
|  
 | |
|  class ChromeClient;
 | |
|  class Page;
 | |
| +class Document;
 | |
|  
 | |
|  class UserGestureEmulationScope {
 | |
|      WTF_MAKE_NONCOPYABLE(UserGestureEmulationScope);
 | |
|  public:
 | |
| -    UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture);
 | |
| +    UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document);
 | |
|      ~UserGestureEmulationScope();
 | |
|  
 | |
|  private:
 | |
| diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp
 | |
| index 77790ce512c13a0a0043d540898071fbc27d94b4..c51586fd2e656e636b81dc6a08b65b060ffc07ee 100644
 | |
| --- a/Source/WebCore/loader/DocumentLoader.cpp
 | |
| +++ b/Source/WebCore/loader/DocumentLoader.cpp
 | |
| @@ -1295,8 +1295,6 @@ void DocumentLoader::detachFromFrame()
 | |
|      if (!m_frame)
 | |
|          return;
 | |
|  
 | |
| -    InspectorInstrumentation::loaderDetachedFromFrame(*m_frame, *this);
 | |
| -
 | |
|      observeFrame(nullptr);
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebCore/loader/DocumentLoader.h b/Source/WebCore/loader/DocumentLoader.h
 | |
| index 048c1d5d1d5df6b3bcaaa60b65d93ba8376a7364..0d4f613c99d37a6654a323effcd8130c819bc9e8 100644
 | |
| --- a/Source/WebCore/loader/DocumentLoader.h
 | |
| +++ b/Source/WebCore/loader/DocumentLoader.h
 | |
| @@ -170,9 +170,13 @@ public:
 | |
|  
 | |
|      WEBCORE_EXPORT virtual void detachFromFrame();
 | |
|  
 | |
| +    virtual void replacedByFragmentNavigation(Frame&) { }
 | |
| +
 | |
|      WEBCORE_EXPORT FrameLoader* frameLoader() const;
 | |
|      WEBCORE_EXPORT SubresourceLoader* mainResourceLoader() const;
 | |
|      WEBCORE_EXPORT RefPtr<SharedBuffer> mainResourceData() const;
 | |
| +
 | |
| +    virtual uint64_t loaderIDForInspector() { return 0; }
 | |
|      
 | |
|      DocumentWriter& writer() const { return m_writer; }
 | |
|  
 | |
| diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
 | |
| index d2e51d86d7e414dca65f421de6cd173401be7b05..1982fc8605329cf9dabf23831f4ea874ee20c49f 100644
 | |
| --- a/Source/WebCore/loader/FrameLoader.cpp
 | |
| +++ b/Source/WebCore/loader/FrameLoader.cpp
 | |
| @@ -1191,6 +1191,7 @@ void FrameLoader::loadInSameDocument(const URL& url, SerializedScriptValue* stat
 | |
|      }
 | |
|  
 | |
|      m_client->dispatchDidNavigateWithinPage();
 | |
| +    InspectorInstrumentation::didNavigateWithinPage(m_frame);
 | |
|  
 | |
|      m_frame.document()->statePopped(stateObject ? Ref<SerializedScriptValue> { *stateObject } : SerializedScriptValue::nullValue());
 | |
|      m_client->dispatchDidPopStateWithinPage();
 | |
| @@ -1376,6 +1377,8 @@ void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& ref
 | |
|  
 | |
|      ASSERT(newLoadType != FrameLoadType::Same);
 | |
|  
 | |
| +    request.setInitiatorIdentifier(frameLoadRequest.resourceRequest().initiatorIdentifier());
 | |
| +
 | |
|      if (!isNavigationAllowed())
 | |
|          return;
 | |
|  
 | |
| @@ -1502,6 +1505,7 @@ void FrameLoader::load(FrameLoadRequest&& request)
 | |
|  
 | |
|  void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, NavigationAction&& action, FrameLoadType type, RefPtr<FormState>&& formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL, CompletionHandler<void()>&& completionHandler)
 | |
|  {
 | |
| +    InspectorInstrumentation::frameScheduledNavigation(m_frame, Seconds(0));
 | |
|      FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "loadWithNavigationAction: frame load started");
 | |
|  
 | |
|      Ref<DocumentLoader> loader = m_client->createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
 | |
| @@ -1605,6 +1609,8 @@ void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType t
 | |
|      const String& httpMethod = loader->request().httpMethod();
 | |
|  
 | |
|      if (shouldPerformFragmentNavigation(isFormSubmission, httpMethod, policyChecker().loadType(), newURL)) {
 | |
| +        loader->replacedByFragmentNavigation(m_frame);
 | |
| +
 | |
|          RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
 | |
|          NavigationAction action { *m_frame.document(), loader->request(), InitiatedByMainFrame::Unknown, policyChecker().loadType(), isFormSubmission };
 | |
|  
 | |
| @@ -3156,6 +3162,8 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error)
 | |
|      checkCompleted();
 | |
|      if (m_frame.page())
 | |
|          checkLoadComplete();
 | |
| +
 | |
| +    InspectorInstrumentation::didReceiveMainResourceError(m_frame, error);
 | |
|  }
 | |
|  
 | |
|  void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
 | |
| @@ -3915,9 +3923,6 @@ String FrameLoader::referrer() const
 | |
|  
 | |
|  void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
 | |
|  {
 | |
| -    if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript))
 | |
| -        return;
 | |
| -
 | |
|      Vector<Ref<DOMWrapperWorld>> worlds;
 | |
|      ScriptController::getAllWorlds(worlds);
 | |
|      for (auto& world : worlds)
 | |
| @@ -3926,13 +3931,13 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
 | |
|  
 | |
|  void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world)
 | |
|  {
 | |
| -    if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript) || !m_frame.windowProxy().existingJSWindowProxy(world))
 | |
| -        return;
 | |
| +    if (m_frame.windowProxy().existingJSWindowProxy(world)) {
 | |
| +        if (m_frame.script().canExecuteScripts(NotAboutToExecuteScript))
 | |
| +            m_client->dispatchDidClearWindowObjectInWorld(world);
 | |
|  
 | |
| -    m_client->dispatchDidClearWindowObjectInWorld(world);
 | |
| -
 | |
| -    if (Page* page = m_frame.page())
 | |
| -        page->inspectorController().didClearWindowObjectInWorld(m_frame, world);
 | |
| +        if (Page* page = m_frame.page())
 | |
| +            page->inspectorController().didClearWindowObjectInWorld(m_frame, world);
 | |
| +    }
 | |
|  
 | |
|      InspectorInstrumentation::didClearWindowObjectInWorld(m_frame, world);
 | |
|  }
 | |
| diff --git a/Source/WebCore/loader/LoaderStrategy.h b/Source/WebCore/loader/LoaderStrategy.h
 | |
| index 579d9038f317d45d27c84a27e3f21cff0ae8fddf..9dc41a6ff78b85e229927409b309e01adce2f27a 100644
 | |
| --- a/Source/WebCore/loader/LoaderStrategy.h
 | |
| +++ b/Source/WebCore/loader/LoaderStrategy.h
 | |
| @@ -80,6 +80,7 @@ public:
 | |
|  
 | |
|      virtual bool isOnLine() const = 0;
 | |
|      virtual void addOnlineStateChangeListener(WTF::Function<void(bool)>&&) = 0;
 | |
| +    virtual void setEmulateOfflineState(bool) {};
 | |
|  
 | |
|      virtual bool shouldPerformSecurityChecks() const { return false; }
 | |
|      virtual bool havePerformedSecurityChecks(const ResourceResponse&) const { return false; }
 | |
| diff --git a/Source/WebCore/loader/PolicyChecker.cpp b/Source/WebCore/loader/PolicyChecker.cpp
 | |
| index c5c4ea85a464f8d9d332d4476876c2cc934b29c4..c79861c3572fe629b199829615ee7e4e83715648 100644
 | |
| --- a/Source/WebCore/loader/PolicyChecker.cpp
 | |
| +++ b/Source/WebCore/loader/PolicyChecker.cpp
 | |
| @@ -46,6 +46,7 @@
 | |
|  #include "HTMLFormElement.h"
 | |
|  #include "HTMLFrameOwnerElement.h"
 | |
|  #include "HTMLPlugInElement.h"
 | |
| +#include "InspectorInstrumentation.h"
 | |
|  #include "Logging.h"
 | |
|  #include <wtf/CompletionHandler.h>
 | |
|  
 | |
| @@ -257,26 +258,32 @@ void FrameLoader::PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigat
 | |
|  
 | |
|      auto blobURLLifetimeExtension = extendBlobURLLifetimeIfNecessary(request);
 | |
|  
 | |
| +    InspectorInstrumentation::willCheckNewWindowPolicy(m_frame, request.url());
 | |
|      auto requestIdentifier = PolicyCheckIdentifier::create();
 | |
|      m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationAction, request, formState.get(), frameName, requestIdentifier, [frame = makeRef(m_frame), request,
 | |
|          formState = WTFMove(formState), frameName, navigationAction, function = WTFMove(function), blobURLLifetimeExtension = WTFMove(blobURLLifetimeExtension),
 | |
|          requestIdentifier] (PolicyAction policyAction, PolicyCheckIdentifier responseIdentifier) mutable {
 | |
|  
 | |
| -        if (!responseIdentifier.isValidFor(requestIdentifier))
 | |
| +        if (!responseIdentifier.isValidFor(requestIdentifier)) {
 | |
| +            InspectorInstrumentation::didCheckNewWindowPolicy(frame.get(), false);
 | |
|              return function({ }, nullptr, { }, { }, ShouldContinuePolicyCheck::No);
 | |
| +        }
 | |
|  
 | |
|          switch (policyAction) {
 | |
|          case PolicyAction::Download:
 | |
|              frame->loader().client().startDownload(request);
 | |
|              FALLTHROUGH;
 | |
|          case PolicyAction::Ignore:
 | |
| +            InspectorInstrumentation::didCheckNewWindowPolicy(frame.get(), false);
 | |
|              function({ }, nullptr, { }, { }, ShouldContinuePolicyCheck::No);
 | |
|              return;
 | |
|          case PolicyAction::StopAllLoads:
 | |
|              ASSERT_NOT_REACHED();
 | |
| +            InspectorInstrumentation::didCheckNewWindowPolicy(frame.get(), false);
 | |
|              function({ }, nullptr, { }, { }, ShouldContinuePolicyCheck::No);
 | |
|              return;
 | |
|          case PolicyAction::Use:
 | |
| +            InspectorInstrumentation::didCheckNewWindowPolicy(frame.get(), true);
 | |
|              function(request, makeWeakPtr(formState.get()), frameName, navigationAction, ShouldContinuePolicyCheck::Yes);
 | |
|              return;
 | |
|          }
 | |
| diff --git a/Source/WebCore/loader/ProgressTracker.cpp b/Source/WebCore/loader/ProgressTracker.cpp
 | |
| index e24fded2225f1c1918f454017566717e20484eab..30e4b7a986418c4b4f6c799b858b608206e22bb5 100644
 | |
| --- a/Source/WebCore/loader/ProgressTracker.cpp
 | |
| +++ b/Source/WebCore/loader/ProgressTracker.cpp
 | |
| @@ -154,6 +154,8 @@ void ProgressTracker::progressCompleted(Frame& frame)
 | |
|      if (!m_numProgressTrackedFrames || m_originatingProgressFrame == &frame)
 | |
|          finalProgressComplete();
 | |
|  
 | |
| +    InspectorInstrumentation::frameStoppedLoading(frame);
 | |
| +
 | |
|      m_client->didChangeEstimatedProgress();
 | |
|  }
 | |
|  
 | |
| @@ -179,8 +181,6 @@ void ProgressTracker::finalProgressComplete()
 | |
|      frame->loader().client().setMainFrameDocumentReady(true);
 | |
|      m_client->progressFinished(*frame);
 | |
|      frame->loader().loadProgressingStatusChanged();
 | |
| -
 | |
| -    InspectorInstrumentation::frameStoppedLoading(*frame);
 | |
|  }
 | |
|  
 | |
|  void ProgressTracker::incrementProgress(unsigned long identifier, const ResourceResponse& response)
 | |
| diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h
 | |
| index eb092b81a64f28050bdb6b85d0289849b719e2c6..2d383e1a7540e5512b14df45dfab9f30d474f2cf 100644
 | |
| --- a/Source/WebCore/page/ChromeClient.h
 | |
| +++ b/Source/WebCore/page/ChromeClient.h
 | |
| @@ -277,7 +277,7 @@ public:
 | |
|  #endif
 | |
|  
 | |
|  #if ENABLE(ORIENTATION_EVENTS)
 | |
| -    virtual int deviceOrientation() const = 0;
 | |
| +    virtual int deviceOrientation() const { return 0; }
 | |
|  #endif
 | |
|  
 | |
|  #if ENABLE(INPUT_TYPE_COLOR)
 | |
| diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
 | |
| index 2cdee17f7b094674a88d62b4d146449c0ce1b52b..7ad4440e38ce4d28bc3e887999ddcea2c57ae96e 100644
 | |
| --- a/Source/WebCore/page/EventHandler.cpp
 | |
| +++ b/Source/WebCore/page/EventHandler.cpp
 | |
| @@ -837,9 +837,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
 | |
|      m_mousePressNode = event.targetNode();
 | |
|      m_frame.document()->setFocusNavigationStartingNode(event.targetNode());
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|      m_dragStartPosition = event.event().position();
 | |
| -#endif
 | |
|  
 | |
|      m_mousePressed = true;
 | |
|      m_selectionInitiationState = HaveNotStartedSelection;
 | |
| @@ -878,8 +876,6 @@ VisiblePosition EventHandler::selectionExtentRespectingEditingBoundary(const Vis
 | |
|      return targetNode->renderer()->positionForPoint(LayoutPoint(selectionEndPoint), nullptr);
 | |
|  }
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
| -
 | |
|  #if !PLATFORM(IOS_FAMILY)
 | |
|  
 | |
|  bool EventHandler::supportsSelectionUpdatesOnMouseDrag() const
 | |
| @@ -901,8 +897,10 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
 | |
|  
 | |
|      Ref<Frame> protectedFrame(m_frame);
 | |
|  
 | |
| +#if ENABLE(DRAG_SUPPORT)
 | |
|      if (handleDrag(event, checkDragHysteresis))
 | |
|          return true;
 | |
| +#endif
 | |
|  
 | |
|      Node* targetNode = event.targetNode();
 | |
|      if (event.event().button() != LeftButton || !targetNode)
 | |
| @@ -923,7 +921,9 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
 | |
|      ASSERT(m_mouseDownMayStartSelect || m_mouseDownMayStartAutoscroll);
 | |
|  #endif
 | |
|  
 | |
| +#if ENABLE(DRAG_SUPPORT)
 | |
|      m_mouseDownMayStartDrag = false;
 | |
| +#endif
 | |
|  
 | |
|      if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) {
 | |
|          m_autoscrollController->startAutoscrollForSelection(renderer);
 | |
| @@ -940,6 +940,8 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
 | |
|      return true;
 | |
|  }
 | |
|      
 | |
| +#if ENABLE(DRAG_SUPPORT)
 | |
| +
 | |
|  bool 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
 | |
| @@ -971,6 +973,8 @@ bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const
 | |
|      return targetElement && page->dragController().draggableElement(&m_frame, targetElement, result.roundedPointInInnerNodeFrame(), state);
 | |
|  }
 | |
|  
 | |
| +#endif // ENABLE(DRAG_SUPPORT)
 | |
| +
 | |
|  void EventHandler::updateSelectionForMouseDrag()
 | |
|  {
 | |
|      if (!supportsSelectionUpdatesOnMouseDrag())
 | |
| @@ -1062,7 +1066,6 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
 | |
|      m_frame.selection().setSelectionByMouseIfDifferent(newSelection, m_frame.selection().granularity(),
 | |
|          FrameSelection::EndPointsAdjustmentMode::AdjustAtBidiBoundary);
 | |
|  }
 | |
| -#endif // ENABLE(DRAG_SUPPORT)
 | |
|  
 | |
|  void EventHandler::lostMouseCapture()
 | |
|  {
 | |
| @@ -1110,9 +1113,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
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|              && m_dragStartPosition == event.event().position()
 | |
| -#endif
 | |
|              && m_frame.selection().isRange()
 | |
|              && event.event().button() != RightButton) {
 | |
|          VisibleSelection newSelection;
 | |
| @@ -2073,10 +2074,8 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& platformMouseE
 | |
|      
 | |
|      swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mouseEvent.targetNode(), 0, platformMouseEvent, FireMouseOverOut::Yes);
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|      if (!swallowEvent)
 | |
|          swallowEvent = handleMouseDraggedEvent(mouseEvent);
 | |
| -#endif
 | |
|  
 | |
|      return swallowEvent;
 | |
|  }
 | |
| diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h
 | |
| index 6ffc83c012ffe095046414051161d7506af192a1..8b5095998153f0c3a5762022459dbd09c21b7dda 100644
 | |
| --- a/Source/WebCore/page/EventHandler.h
 | |
| +++ b/Source/WebCore/page/EventHandler.h
 | |
| @@ -132,9 +132,7 @@ public:
 | |
|  
 | |
|      WEBCORE_EXPORT VisiblePosition selectionExtentRespectingEditingBoundary(const VisibleSelection&, const LayoutPoint&, Node*);
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|      void updateSelectionForMouseDrag();
 | |
| -#endif
 | |
|  
 | |
|  #if ENABLE(PAN_SCROLLING)
 | |
|      void didPanScrollStart();
 | |
| @@ -364,10 +362,8 @@ private:
 | |
|      bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
 | |
|      bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|      bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis);
 | |
|      bool shouldAllowMouseDownToStartDrag() const;
 | |
| -#endif
 | |
|  
 | |
|      WEBCORE_EXPORT bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
 | |
|  
 | |
| @@ -464,10 +460,8 @@ private:
 | |
|      void defaultTabEventHandler(KeyboardEvent&);
 | |
|      void defaultArrowEventHandler(FocusDirection, KeyboardEvent&);
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|      DragSourceAction updateDragSourceActionsAllowed() const;
 | |
|      bool supportsSelectionUpdatesOnMouseDrag() const;
 | |
| -#endif
 | |
|  
 | |
|      // The following are called at the beginning of handleMouseUp and handleDrag.  
 | |
|      // If they return true it indicates that they have consumed the event.
 | |
| @@ -475,9 +469,10 @@ private:
 | |
|  
 | |
|  #if ENABLE(DRAG_SUPPORT)
 | |
|      bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&);
 | |
| -    void updateSelectionForMouseDrag(const HitTestResult&);
 | |
|  #endif
 | |
|  
 | |
| +    void updateSelectionForMouseDrag(const HitTestResult&);
 | |
| +
 | |
|      enum class SetOrClearLastScrollbar { Clear, Set };
 | |
|      void updateLastScrollbarUnderMouse(Scrollbar*, SetOrClearLastScrollbar);
 | |
|      
 | |
| @@ -528,10 +523,7 @@ private:
 | |
|      enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
 | |
|      SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };
 | |
|  
 | |
| -#if ENABLE(DRAG_SUPPORT)
 | |
|      LayoutPoint m_dragStartPosition;
 | |
| -#endif
 | |
| -
 | |
|      Timer m_hoverTimer;
 | |
|      bool m_hasScheduledCursorUpdate { false };
 | |
|  
 | |
| diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
 | |
| index 540f456ee82199bbff71e6688bc0e81fa525dda9..a8bc604ba4a04e180af0605cfe246958d8329026 100644
 | |
| --- a/Source/WebCore/page/Frame.cpp
 | |
| +++ b/Source/WebCore/page/Frame.cpp
 | |
| @@ -182,6 +182,7 @@ Frame::Frame(Page& page, HTMLFrameOwnerElement* ownerElement, UniqueRef<FrameLoa
 | |
|  void Frame::init()
 | |
|  {
 | |
|      m_loader->init();
 | |
| +    InspectorInstrumentation::frameAttached(this);
 | |
|  }
 | |
|  
 | |
|  Ref<Frame> Frame::create(Page* page, HTMLFrameOwnerElement* ownerElement, UniqueRef<FrameLoaderClient>&& client)
 | |
| @@ -340,7 +341,7 @@ void Frame::orientationChanged()
 | |
|  int Frame::orientation() const
 | |
|  {
 | |
|      if (m_page)
 | |
| -        return m_page->chrome().client().deviceOrientation();
 | |
| +        return m_page->orientation();
 | |
|      return 0;
 | |
|  }
 | |
|  #endif // ENABLE(ORIENTATION_EVENTS)
 | |
| diff --git a/Source/WebCore/page/FrameSnapshotting.cpp b/Source/WebCore/page/FrameSnapshotting.cpp
 | |
| index 73587787f88a6ad4e4baffb0beb0b87e7782916f..88492f501e6ec9e38455dbe6fd27537bf0ee6970 100644
 | |
| --- a/Source/WebCore/page/FrameSnapshotting.cpp
 | |
| +++ b/Source/WebCore/page/FrameSnapshotting.cpp
 | |
| @@ -114,7 +114,12 @@ std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRe
 | |
|      std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, scaleFactor);
 | |
|      if (!buffer)
 | |
|          return nullptr;
 | |
| +#if !PLATFORM(MAC)
 | |
| +    buffer->context().scale(scaleFactor);
 | |
| +#endif
 | |
|      buffer->context().translate(-imageRect.x(), -imageRect.y());
 | |
| +    if (coordinateSpace != FrameView::ViewCoordinates)
 | |
| +      buffer->context().scale(1 / frame.page()->pageScaleFactor());
 | |
|  
 | |
|      if (!clipRects.isEmpty()) {
 | |
|          Path clipPath;
 | |
| @@ -123,7 +128,10 @@ std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRe
 | |
|          buffer->context().clipPath(clipPath);
 | |
|      }
 | |
|  
 | |
| -    frame.view()->paintContentsForSnapshot(buffer->context(), imageRect, shouldIncludeSelection, coordinateSpace);
 | |
| +    FloatRect fr = imageRect;
 | |
| +    if (coordinateSpace != FrameView::ViewCoordinates)
 | |
| +      fr.scale(frame.page()->pageScaleFactor());
 | |
| +    frame.view()->paintContentsForSnapshot(buffer->context(), enclosingIntRect(fr), shouldIncludeSelection, coordinateSpace);
 | |
|      return buffer;
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
 | |
| index f48ae6ccfc5dc7f982a881a421fe703cb3e65faa..753172cd3c93657c12ab1cca5def44e7be795a19 100644
 | |
| --- a/Source/WebCore/page/FrameView.cpp
 | |
| +++ b/Source/WebCore/page/FrameView.cpp
 | |
| @@ -2990,7 +2990,7 @@ void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
 | |
|  
 | |
|  void FrameView::updateBackgroundRecursively(const Optional<Color>& backgroundColor)
 | |
|  {
 | |
| -#if HAVE(OS_DARK_MODE_SUPPORT)
 | |
| +#if HAVE(OS_DARK_MODE_SUPPORT) && (defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC) || (defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY)
 | |
|      Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions()));
 | |
|  #else
 | |
|      Color baseBackgroundColor = backgroundColor.valueOr(Color::white);
 | |
| diff --git a/Source/WebCore/page/History.cpp b/Source/WebCore/page/History.cpp
 | |
| index 38fd7b29b53eab484e30963b51c8ae525c5d7a38..37b2a2b8baeba64a50f12c773f2a1072595806c5 100644
 | |
| --- a/Source/WebCore/page/History.cpp
 | |
| +++ b/Source/WebCore/page/History.cpp
 | |
| @@ -260,6 +260,7 @@ ExceptionOr<void> History::stateObjectAdded(RefPtr<SerializedScriptValue>&& data
 | |
|  
 | |
|      if (!urlString.isEmpty())
 | |
|          frame->document()->updateURLForPushOrReplaceState(fullURL);
 | |
| +    InspectorInstrumentation::didNavigateWithinPage(*frame);
 | |
|  
 | |
|      if (stateObjectType == StateObjectType::Push) {
 | |
|          frame->loader().history().pushState(WTFMove(data), title, fullURL.string());
 | |
| diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
 | |
| index 07beb4e66e280c2adad8a020ff07e81aba438dfd..711aba5dbfa4477ca462e11b06c6ac92757888a1 100644
 | |
| --- a/Source/WebCore/page/Page.cpp
 | |
| +++ b/Source/WebCore/page/Page.cpp
 | |
| @@ -90,6 +90,7 @@
 | |
|  #include "PerformanceLoggingClient.h"
 | |
|  #include "PerformanceMonitor.h"
 | |
|  #include "PlatformMediaSessionManager.h"
 | |
| +#include "PlatformScreen.h"
 | |
|  #include "PlatformStrategies.h"
 | |
|  #include "PlugInClient.h"
 | |
|  #include "PluginData.h"
 | |
| @@ -428,6 +429,37 @@ void Page::setOverrideViewportArguments(const Optional<ViewportArguments>& viewp
 | |
|          document->updateViewportArguments();
 | |
|  }
 | |
|  
 | |
| +FloatSize Page::screenSize()
 | |
| +{
 | |
| +    return m_overrideScreenSize.valueOr(screenRect(mainFrame().view()).size());
 | |
| +}
 | |
| +
 | |
| +void Page::setOverrideScreenSize(Optional<FloatSize> size)
 | |
| +{
 | |
| +    if (size == m_overrideScreenSize)
 | |
| +        return;
 | |
| +
 | |
| +    m_overrideScreenSize = size;
 | |
| +    if (auto* document = mainFrame().document())
 | |
| +        document->updateViewportArguments();
 | |
| +}
 | |
| +
 | |
| +#if ENABLE(ORIENTATION_EVENTS)
 | |
| +int Page::orientation() const
 | |
| +{
 | |
| +    return m_overrideOrientation.valueOr(chrome().client().deviceOrientation());
 | |
| +}
 | |
| +
 | |
| +void Page::setOverrideOrientation(Optional<int> orientation)
 | |
| +{
 | |
| +    if (orientation == m_overrideOrientation)
 | |
| +        return;
 | |
| +
 | |
| +    m_overrideOrientation = orientation;
 | |
| +    mainFrame().orientationChanged();
 | |
| +}
 | |
| +#endif
 | |
| +
 | |
|  ScrollingCoordinator* Page::scrollingCoordinator()
 | |
|  {
 | |
|      if (!m_scrollingCoordinator && m_settings->scrollingCoordinatorEnabled()) {
 | |
| diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h
 | |
| index eb92e7402cefea3736f13939ad90611c027741a4..c9f18164ed3bd64dcfb4f5c23b70865142f04d8d 100644
 | |
| --- a/Source/WebCore/page/Page.h
 | |
| +++ b/Source/WebCore/page/Page.h
 | |
| @@ -194,6 +194,9 @@ public:
 | |
|      const Optional<ViewportArguments>& overrideViewportArguments() const { return m_overrideViewportArguments; }
 | |
|      WEBCORE_EXPORT void setOverrideViewportArguments(const Optional<ViewportArguments>&);
 | |
|  
 | |
| +    WEBCORE_EXPORT FloatSize screenSize();
 | |
| +    void setOverrideScreenSize(Optional<FloatSize> size);
 | |
| +
 | |
|      static void refreshPlugins(bool reload);
 | |
|      WEBCORE_EXPORT PluginData& pluginData();
 | |
|      void clearPluginData();
 | |
| @@ -740,6 +743,11 @@ public:
 | |
|  
 | |
|      WEBCORE_EXPORT Vector<Ref<Element>> editableElementsInRect(const FloatRect&) const;
 | |
|  
 | |
| +#if ENABLE(ORIENTATION_EVENTS)
 | |
| +    int orientation() const;
 | |
| +    void setOverrideOrientation(Optional<int>);
 | |
| +#endif
 | |
| +
 | |
|  #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
 | |
|      DeviceOrientationUpdateProvider* deviceOrientationUpdateProvider() const { return m_deviceOrientationUpdateProvider.get(); }
 | |
|  #endif
 | |
| @@ -1035,6 +1043,11 @@ private:
 | |
|  #endif
 | |
|  
 | |
|      Optional<ViewportArguments> m_overrideViewportArguments;
 | |
| +    Optional<FloatSize> m_overrideScreenSize;
 | |
| +
 | |
| +#if ENABLE(ORIENTATION_EVENTS)
 | |
| +    Optional<int> m_overrideOrientation;
 | |
| +#endif
 | |
|  
 | |
|  #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
 | |
|      RefPtr<DeviceOrientationUpdateProvider> m_deviceOrientationUpdateProvider;
 | |
| diff --git a/Source/WebCore/page/Screen.cpp b/Source/WebCore/page/Screen.cpp
 | |
| index a9d228ca404918860c40651994db78a1e76db5ca..1fc3c345308dfed8384d1c02334f2030e879383d 100644
 | |
| --- a/Source/WebCore/page/Screen.cpp
 | |
| +++ b/Source/WebCore/page/Screen.cpp
 | |
| @@ -32,6 +32,7 @@
 | |
|  #include "FloatRect.h"
 | |
|  #include "Frame.h"
 | |
|  #include "FrameView.h"
 | |
| +#include "Page.h"
 | |
|  #include "PlatformScreen.h"
 | |
|  #include "ResourceLoadObserver.h"
 | |
|  #include "RuntimeEnabledFeatures.h"
 | |
| @@ -53,7 +54,7 @@ unsigned Screen::height() const
 | |
|          return 0;
 | |
|      if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
 | |
|          ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::Height);
 | |
| -    long height = static_cast<long>(screenRect(frame->view()).height());
 | |
| +    long height = static_cast<long>(frame->page()->screenSize().height());
 | |
|      return static_cast<unsigned>(height);
 | |
|  }
 | |
|  
 | |
| @@ -64,7 +65,7 @@ unsigned Screen::width() const
 | |
|          return 0;
 | |
|      if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
 | |
|          ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::Width);
 | |
| -    long width = static_cast<long>(screenRect(frame->view()).width());
 | |
| +    long width = static_cast<long>(frame->page()->screenSize().width());
 | |
|      return static_cast<unsigned>(width);
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebCore/page/SocketProvider.cpp b/Source/WebCore/page/SocketProvider.cpp
 | |
| index 803ac83155ff4df1becf75cd4710f6fbf7bbc32a..cc08682748a6d2fdf5d79980cd629812c98aa7ce 100644
 | |
| --- a/Source/WebCore/page/SocketProvider.cpp
 | |
| +++ b/Source/WebCore/page/SocketProvider.cpp
 | |
| @@ -33,7 +33,7 @@ namespace WebCore {
 | |
|      
 | |
|  Ref<SocketStreamHandle> SocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, const StorageSessionProvider* provider)
 | |
|  {
 | |
| -    return SocketStreamHandleImpl::create(url, client, sessionID, credentialPartition, { }, provider);
 | |
| +    return SocketStreamHandleImpl::create(url, false, client, sessionID, credentialPartition, { }, provider);
 | |
|  }
 | |
|  
 | |
|  RefPtr<ThreadableWebSocketChannel> SocketProvider::createWebSocketChannel(Document&, WebSocketChannelClient&)
 | |
| diff --git a/Source/WebCore/page/csp/ContentSecurityPolicy.cpp b/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
 | |
| index fbfe9fe2ee17b2e11ed495d5032d9a1d2fa68a18..96cd3d00306a55ad6995ffd10d2ca9041914b3bb 100644
 | |
| --- a/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
 | |
| +++ b/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
 | |
| @@ -298,6 +298,8 @@ bool ContentSecurityPolicy::protocolMatchesSelf(const URL& url) const
 | |
|  template<typename Predicate, typename... Args>
 | |
|  typename std::enable_if<!std::is_convertible<Predicate, ContentSecurityPolicy::ViolatedDirectiveCallback>::value, bool>::type ContentSecurityPolicy::allPoliciesWithDispositionAllow(Disposition disposition, Predicate&& predicate, Args&&... args) const
 | |
|  {
 | |
| +    if (InspectorInstrumentation::shouldBypassCSP(m_scriptExecutionContext))
 | |
| +        return true;
 | |
|      bool isReportOnly = disposition == ContentSecurityPolicy::Disposition::ReportOnly;
 | |
|      for (auto& policy : m_policies) {
 | |
|          if (policy->isReportOnly() != isReportOnly)
 | |
| @@ -311,6 +313,8 @@ typename std::enable_if<!std::is_convertible<Predicate, ContentSecurityPolicy::V
 | |
|  template<typename Predicate, typename... Args>
 | |
|  bool ContentSecurityPolicy::allPoliciesWithDispositionAllow(Disposition disposition, ViolatedDirectiveCallback&& callback, Predicate&& predicate, Args&&... args) const
 | |
|  {
 | |
| +    if (InspectorInstrumentation::shouldBypassCSP(m_scriptExecutionContext))
 | |
| +        return true;
 | |
|      bool isReportOnly = disposition == ContentSecurityPolicy::Disposition::ReportOnly;
 | |
|      bool isAllowed = true;
 | |
|      for (auto& policy : m_policies) {
 | |
| @@ -327,6 +331,8 @@ bool ContentSecurityPolicy::allPoliciesWithDispositionAllow(Disposition disposit
 | |
|  template<typename Predicate, typename... Args>
 | |
|  bool ContentSecurityPolicy::allPoliciesAllow(ViolatedDirectiveCallback&& callback, Predicate&& predicate, Args&&... args) const
 | |
|  {
 | |
| +    if (InspectorInstrumentation::shouldBypassCSP(m_scriptExecutionContext))
 | |
| +        return true;
 | |
|      bool isAllowed = true;
 | |
|      for (auto& policy : m_policies) {
 | |
|          if (const ContentSecurityPolicyDirective* violatedDirective = (policy.get()->*predicate)(std::forward<Args>(args)...)) {
 | |
| diff --git a/Source/WebCore/platform/Cairo.cmake b/Source/WebCore/platform/Cairo.cmake
 | |
| index fc6c5f3cd046269566822c08a482cc3bd6a883c0..083c03903a3111ee2cb6f9882dd2efe146d7dc35 100644
 | |
| --- a/Source/WebCore/platform/Cairo.cmake
 | |
| +++ b/Source/WebCore/platform/Cairo.cmake
 | |
| @@ -17,6 +17,7 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
 | |
|      platform/graphics/cairo/ImageBufferCairoGLSurfaceBackend.h
 | |
|      platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.h
 | |
|      platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h
 | |
| +    platform/graphics/cairo/ImageBufferUtilitiesCairo.h
 | |
|      platform/graphics/cairo/PlatformContextCairo.h
 | |
|      platform/graphics/cairo/RefPtrCairo.h
 | |
|  )
 | |
| diff --git a/Source/WebCore/platform/PlatformKeyboardEvent.h b/Source/WebCore/platform/PlatformKeyboardEvent.h
 | |
| index f423a4a1d5399326fc48fe4d4a8a8fb9d4df861e..b4b60162d8b0d34113df052b04a1695d481d266e 100644
 | |
| --- a/Source/WebCore/platform/PlatformKeyboardEvent.h
 | |
| +++ b/Source/WebCore/platform/PlatformKeyboardEvent.h
 | |
| @@ -138,6 +138,7 @@ namespace WebCore {
 | |
|          static String keyCodeForHardwareKeyCode(unsigned);
 | |
|          static String keyIdentifierForGdkKeyCode(unsigned);
 | |
|          static int windowsKeyCodeForGdkKeyCode(unsigned);
 | |
| +        static unsigned gdkKeyCodeForWindowsKeyCode(int);
 | |
|          static String singleCharacterString(unsigned);
 | |
|          static bool modifiersContainCapsLock(unsigned);
 | |
|  #endif
 | |
| @@ -147,6 +148,7 @@ namespace WebCore {
 | |
|          static String keyCodeForHardwareKeyCode(unsigned);
 | |
|          static String keyIdentifierForWPEKeyCode(unsigned);
 | |
|          static int windowsKeyCodeForWPEKeyCode(unsigned);
 | |
| +        static unsigned WPEKeyCodeForWindowsKeyCode(int);
 | |
|          static String singleCharacterString(unsigned);
 | |
|  #endif
 | |
|  
 | |
| diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h
 | |
| index 892d8de6d345d91fda80cfa5334c4aa68b757da3..a22497d801a349487be10b15139e9c761a4a3ea5 100644
 | |
| --- a/Source/WebCore/platform/ScrollableArea.h
 | |
| +++ b/Source/WebCore/platform/ScrollableArea.h
 | |
| @@ -110,7 +110,7 @@ public:
 | |
|      void updateScrollSnapState();
 | |
|  
 | |
|  #if ENABLE(TOUCH_EVENTS)
 | |
| -    virtual bool handleTouchEvent(const PlatformTouchEvent&);
 | |
| +    WEBCORE_EXPORT virtual bool handleTouchEvent(const PlatformTouchEvent&);
 | |
|  #endif
 | |
|  
 | |
|  #if PLATFORM(IOS_FAMILY)
 | |
| diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp
 | |
| index d79728555b7db9b59cb615c55a7a7a6851cb57c8..61d3cc4b488e35ef9e1afa1ce3ac5f5d60ebe9a7 100644
 | |
| --- a/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp
 | |
| +++ b/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp
 | |
| @@ -48,6 +48,13 @@
 | |
|  #include <wtf/glib/GUniquePtr.h>
 | |
|  #endif
 | |
|  
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +#include <stdio.h> // Needed by jpeglib.h for FILE.
 | |
| +extern "C" {
 | |
| +#include "jpeglib.h"
 | |
| +}
 | |
| +#endif
 | |
| +
 | |
|  namespace WebCore {
 | |
|  
 | |
|  #if !PLATFORM(GTK)
 | |
| @@ -65,8 +72,75 @@ static bool encodeImage(cairo_surface_t* image, const String& mimeType, Vector<u
 | |
|      return cairo_surface_write_to_png_stream(image, writeFunction, output) == CAIRO_STATUS_SUCCESS;
 | |
|  }
 | |
|  
 | |
| -Vector<uint8_t> data(cairo_surface_t* image, const String& mimeType, Optional<double>)
 | |
| +static Vector<uint8_t> encodeJpeg(cairo_surface_t* image, int quality)
 | |
| +{
 | |
| +    if (cairo_surface_get_type(image) != CAIRO_SURFACE_TYPE_IMAGE) {
 | |
| +        fprintf(stderr, "Unexpected cairo surface type: %d\n", cairo_surface_get_type(image));
 | |
| +        return { };
 | |
| +    }
 | |
| +
 | |
| +    if (cairo_image_surface_get_format(image) != CAIRO_FORMAT_ARGB32) {
 | |
| +        fprintf(stderr, "Unexpected surface image format: %d\n", cairo_image_surface_get_format(image));
 | |
| +        return { };
 | |
| +    }
 | |
| +
 | |
| +    struct jpeg_compress_struct info;
 | |
| +    struct jpeg_error_mgr error;
 | |
| +    info.err = jpeg_std_error(&error);
 | |
| +    jpeg_create_compress(&info);
 | |
| +
 | |
| +    unsigned char* bufferPtr = nullptr;
 | |
| +    unsigned long bufferSize;
 | |
| +    jpeg_mem_dest(&info, &bufferPtr, &bufferSize);
 | |
| +    info.image_width = cairo_image_surface_get_width(image);
 | |
| +    info.image_height = cairo_image_surface_get_height(image);
 | |
| +
 | |
| +#ifndef LIBJPEG_TURBO_VERSION
 | |
| +    COMPILE_ASSERT(false, only_libjpeg_turbo_is_supported);
 | |
| +#endif
 | |
| +
 | |
| +#if CPU(LITTLE_ENDIAN)
 | |
| +    info.in_color_space = JCS_EXT_BGRA;
 | |
| +#else
 | |
| +    info.in_color_space = JCS_EXT_ARGB;
 | |
| +#endif
 | |
| +    // # of color components in input image
 | |
| +    info.input_components = 4;
 | |
| +
 | |
| +    jpeg_set_defaults(&info);
 | |
| +    jpeg_set_quality(&info, quality, true);
 | |
| +
 | |
| +    jpeg_start_compress(&info, true);
 | |
| +
 | |
| +    while (info.next_scanline < info.image_height)
 | |
| +    {
 | |
| +        JSAMPROW row = cairo_image_surface_get_data(image) + (info.next_scanline * cairo_image_surface_get_stride(image));
 | |
| +        if (jpeg_write_scanlines(&info, &row, 1) != 1) {
 | |
| +            fprintf(stderr, "JPEG library failed to encode line\n");
 | |
| +            break;
 | |
| +        }
 | |
| +    }
 | |
| +
 | |
| +    jpeg_finish_compress(&info);
 | |
| +    jpeg_destroy_compress(&info);
 | |
| +
 | |
| +    Vector<uint8_t> output;
 | |
| +    output.append(bufferPtr, bufferSize);
 | |
| +    // Cannot use unique_ptr as bufferPtr changes during compression. GUniquePtr would work
 | |
| +    // but it's under GLib and won't work on Windows.
 | |
| +    free(bufferPtr);
 | |
| +    return output;
 | |
| +}
 | |
| +
 | |
| +Vector<uint8_t> data(cairo_surface_t* image, const String& mimeType, Optional<double> quality)
 | |
|  {
 | |
| +    if (mimeType == "image/jpeg") {
 | |
| +        int qualityPercent = 100;
 | |
| +        if (quality)
 | |
| +            qualityPercent = static_cast<int>(*quality * 100.0 + 0.5);
 | |
| +        return encodeJpeg(image, qualityPercent);
 | |
| +    }
 | |
| +
 | |
|      Vector<uint8_t> encodedImage;
 | |
|      if (!image || !encodeImage(image, mimeType, &encodedImage))
 | |
|          return { };
 | |
| diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h b/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h
 | |
| index bc87758878d5163a938af8242c7a6800ea9bd13c..3d0751f8dfe1124bbe054daa2fa0c7552fecab32 100644
 | |
| --- a/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h
 | |
| +++ b/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h
 | |
| @@ -42,7 +42,7 @@ WEBCORE_EXPORT uint8_t verifyImageBufferIsBigEnough(const void* buffer, size_t b
 | |
|  CFStringRef jpegUTI();
 | |
|  RetainPtr<CFStringRef> utiFromImageBufferMIMEType(const String&);
 | |
|  
 | |
| -bool encodeImage(CGImageRef, CFStringRef uti, Optional<double> quality, CFMutableDataRef);
 | |
| +WEBCORE_EXPORT bool encodeImage(CGImageRef, CFStringRef uti, Optional<double> quality, CFMutableDataRef);
 | |
|  
 | |
|  String dataURL(CFDataRef, const String& mimeType);
 | |
|  String dataURL(const ImageData&, const String& mimeType, Optional<double> quality);
 | |
| diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp
 | |
| index 445c7d78a4a1a8cdb0e08a859d3912e5cc62b6c6..93a8006dd5237018b573b976d0bbe28f02b8254f 100644
 | |
| --- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp
 | |
| +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp
 | |
| @@ -27,7 +27,7 @@
 | |
|  #include "config.h"
 | |
|  #include "GraphicsContextGLOpenGL.h"
 | |
|  
 | |
| -#if ENABLE(GRAPHICS_CONTEXT_GL) && (USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES)))
 | |
| +#if !PLATFORM(WIN) && ENABLE(GRAPHICS_CONTEXT_GL) && (USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES)))
 | |
|  
 | |
|  #if PLATFORM(IOS_FAMILY)
 | |
|  #include "GraphicsContextGLOpenGLESIOS.h"
 | |
| diff --git a/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp b/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp
 | |
| index 0516e70973e0078de6ad0216375d34dd9ef51a8d..ffd9a02deb5518e0c8c77b156815c11eb4b16829 100644
 | |
| --- a/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp
 | |
| +++ b/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp
 | |
| @@ -37,8 +37,10 @@
 | |
|  #include "WindowsKeyboardCodes.h"
 | |
|  #include <gdk/gdk.h>
 | |
|  #include <gdk/gdkkeysyms.h>
 | |
| +#include <wtf/HashMap.h>
 | |
|  #include <wtf/HexNumber.h>
 | |
|  #include <wtf/glib/GUniquePtr.h>
 | |
| +#include <mutex>
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| @@ -1294,6 +1296,246 @@ int PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(unsigned keycode)
 | |
|  
 | |
|  }
 | |
|  
 | |
| +static const HashMap<int, unsigned>& gdkToWindowsKeyCodeMap()
 | |
| +{
 | |
| +    static HashMap<int, unsigned>* result;
 | |
| +    static std::once_flag once;
 | |
| +    std::call_once(
 | |
| +        once,
 | |
| +        [] {
 | |
| +            const unsigned gdkKeyCodes[] = {
 | |
| +                GDK_KEY_Cancel,
 | |
| +                // FIXME: non-keypad keys should take precedence, so we skip GDK_KEY_KP_*
 | |
| +                // GDK_KEY_KP_0,
 | |
| +                // GDK_KEY_KP_1,
 | |
| +                // GDK_KEY_KP_2,
 | |
| +                // GDK_KEY_KP_3,
 | |
| +                // GDK_KEY_KP_4,
 | |
| +                // GDK_KEY_KP_5,
 | |
| +                // GDK_KEY_KP_6,
 | |
| +                // GDK_KEY_KP_7,
 | |
| +                // GDK_KEY_KP_8,
 | |
| +                // GDK_KEY_KP_9,
 | |
| +                // GDK_KEY_KP_Multiply,
 | |
| +                // GDK_KEY_KP_Add,
 | |
| +                // GDK_KEY_KP_Subtract,
 | |
| +                // GDK_KEY_KP_Decimal,
 | |
| +                // GDK_KEY_KP_Divide,
 | |
| +                // GDK_KEY_KP_Page_Up,
 | |
| +                // GDK_KEY_KP_Page_Down,
 | |
| +                // GDK_KEY_KP_End,
 | |
| +                // GDK_KEY_KP_Home,
 | |
| +                // GDK_KEY_KP_Left,
 | |
| +                // GDK_KEY_KP_Up,
 | |
| +                // GDK_KEY_KP_Right,
 | |
| +                // GDK_KEY_KP_Down,
 | |
| +                GDK_KEY_BackSpace,
 | |
| +                // GDK_KEY_ISO_Left_Tab,
 | |
| +                // GDK_KEY_3270_BackTab,
 | |
| +                GDK_KEY_Tab,
 | |
| +                GDK_KEY_Clear,
 | |
| +                // GDK_KEY_ISO_Enter,
 | |
| +                // GDK_KEY_KP_Enter,
 | |
| +                GDK_KEY_Return,
 | |
| +                GDK_KEY_Menu,
 | |
| +                GDK_KEY_Pause,
 | |
| +                GDK_KEY_AudioPause,
 | |
| +                GDK_KEY_Caps_Lock,
 | |
| +                GDK_KEY_Kana_Lock,
 | |
| +                GDK_KEY_Kana_Shift,
 | |
| +                GDK_KEY_Hangul,
 | |
| +                GDK_KEY_Hangul_Hanja,
 | |
| +                GDK_KEY_Kanji,
 | |
| +                GDK_KEY_Escape,
 | |
| +                GDK_KEY_space,
 | |
| +                GDK_KEY_Page_Up,
 | |
| +                GDK_KEY_Page_Down,
 | |
| +                GDK_KEY_End,
 | |
| +                GDK_KEY_Home,
 | |
| +                GDK_KEY_Left,
 | |
| +                GDK_KEY_Up,
 | |
| +                GDK_KEY_Right,
 | |
| +                GDK_KEY_Down,
 | |
| +                GDK_KEY_Select,
 | |
| +                GDK_KEY_Print,
 | |
| +                GDK_KEY_Execute,
 | |
| +                GDK_KEY_Insert,
 | |
| +                GDK_KEY_KP_Insert,
 | |
| +                GDK_KEY_Delete,
 | |
| +                GDK_KEY_KP_Delete,
 | |
| +                GDK_KEY_Help,
 | |
| +                GDK_KEY_0,
 | |
| +                GDK_KEY_parenright,
 | |
| +                GDK_KEY_1,
 | |
| +                GDK_KEY_exclam,
 | |
| +                GDK_KEY_2,
 | |
| +                GDK_KEY_at,
 | |
| +                GDK_KEY_3,
 | |
| +                GDK_KEY_numbersign,
 | |
| +                GDK_KEY_4,
 | |
| +                GDK_KEY_dollar,
 | |
| +                GDK_KEY_5,
 | |
| +                GDK_KEY_percent,
 | |
| +                GDK_KEY_6,
 | |
| +                GDK_KEY_asciicircum,
 | |
| +                GDK_KEY_7,
 | |
| +                GDK_KEY_ampersand,
 | |
| +                GDK_KEY_8,
 | |
| +                GDK_KEY_asterisk,
 | |
| +                GDK_KEY_9,
 | |
| +                GDK_KEY_parenleft,
 | |
| +                GDK_KEY_a,
 | |
| +                GDK_KEY_A,
 | |
| +                GDK_KEY_b,
 | |
| +                GDK_KEY_B,
 | |
| +                GDK_KEY_c,
 | |
| +                GDK_KEY_C,
 | |
| +                GDK_KEY_d,
 | |
| +                GDK_KEY_D,
 | |
| +                GDK_KEY_e,
 | |
| +                GDK_KEY_E,
 | |
| +                GDK_KEY_f,
 | |
| +                GDK_KEY_F,
 | |
| +                GDK_KEY_g,
 | |
| +                GDK_KEY_G,
 | |
| +                GDK_KEY_h,
 | |
| +                GDK_KEY_H,
 | |
| +                GDK_KEY_i,
 | |
| +                GDK_KEY_I,
 | |
| +                GDK_KEY_j,
 | |
| +                GDK_KEY_J,
 | |
| +                GDK_KEY_k,
 | |
| +                GDK_KEY_K,
 | |
| +                GDK_KEY_l,
 | |
| +                GDK_KEY_L,
 | |
| +                GDK_KEY_m,
 | |
| +                GDK_KEY_M,
 | |
| +                GDK_KEY_n,
 | |
| +                GDK_KEY_N,
 | |
| +                GDK_KEY_o,
 | |
| +                GDK_KEY_O,
 | |
| +                GDK_KEY_p,
 | |
| +                GDK_KEY_P,
 | |
| +                GDK_KEY_q,
 | |
| +                GDK_KEY_Q,
 | |
| +                GDK_KEY_r,
 | |
| +                GDK_KEY_R,
 | |
| +                GDK_KEY_s,
 | |
| +                GDK_KEY_S,
 | |
| +                GDK_KEY_t,
 | |
| +                GDK_KEY_T,
 | |
| +                GDK_KEY_u,
 | |
| +                GDK_KEY_U,
 | |
| +                GDK_KEY_v,
 | |
| +                GDK_KEY_V,
 | |
| +                GDK_KEY_w,
 | |
| +                GDK_KEY_W,
 | |
| +                GDK_KEY_x,
 | |
| +                GDK_KEY_X,
 | |
| +                GDK_KEY_y,
 | |
| +                GDK_KEY_Y,
 | |
| +                GDK_KEY_z,
 | |
| +                GDK_KEY_Z,
 | |
| +                GDK_KEY_Meta_L,
 | |
| +                GDK_KEY_Meta_R,
 | |
| +                GDK_KEY_Sleep,
 | |
| +                GDK_KEY_Num_Lock,
 | |
| +                GDK_KEY_Scroll_Lock,
 | |
| +                GDK_KEY_Shift_L,
 | |
| +                GDK_KEY_Shift_R,
 | |
| +                GDK_KEY_Control_L,
 | |
| +                GDK_KEY_Control_R,
 | |
| +                GDK_KEY_Alt_L,
 | |
| +                GDK_KEY_Alt_R,
 | |
| +                GDK_KEY_Back,
 | |
| +                GDK_KEY_Forward,
 | |
| +                GDK_KEY_Refresh,
 | |
| +                GDK_KEY_Stop,
 | |
| +                GDK_KEY_Search,
 | |
| +                GDK_KEY_Favorites,
 | |
| +                GDK_KEY_HomePage,
 | |
| +                GDK_KEY_AudioMute,
 | |
| +                GDK_KEY_AudioLowerVolume,
 | |
| +                GDK_KEY_AudioRaiseVolume,
 | |
| +                GDK_KEY_AudioNext,
 | |
| +                GDK_KEY_AudioPrev,
 | |
| +                GDK_KEY_AudioStop,
 | |
| +                GDK_KEY_AudioMedia,
 | |
| +                GDK_KEY_semicolon,
 | |
| +                GDK_KEY_colon,
 | |
| +                GDK_KEY_plus,
 | |
| +                GDK_KEY_equal,
 | |
| +                GDK_KEY_comma,
 | |
| +                GDK_KEY_less,
 | |
| +                GDK_KEY_minus,
 | |
| +                GDK_KEY_underscore,
 | |
| +                GDK_KEY_period,
 | |
| +                GDK_KEY_greater,
 | |
| +                GDK_KEY_slash,
 | |
| +                GDK_KEY_question,
 | |
| +                GDK_KEY_asciitilde,
 | |
| +                GDK_KEY_quoteleft,
 | |
| +                GDK_KEY_bracketleft,
 | |
| +                GDK_KEY_braceleft,
 | |
| +                GDK_KEY_backslash,
 | |
| +                GDK_KEY_bar,
 | |
| +                GDK_KEY_bracketright,
 | |
| +                GDK_KEY_braceright,
 | |
| +                GDK_KEY_quoteright,
 | |
| +                GDK_KEY_quotedbl,
 | |
| +                GDK_KEY_AudioRewind,
 | |
| +                GDK_KEY_AudioForward,
 | |
| +                GDK_KEY_AudioPlay,
 | |
| +                GDK_KEY_F1,
 | |
| +                GDK_KEY_F2,
 | |
| +                GDK_KEY_F3,
 | |
| +                GDK_KEY_F4,
 | |
| +                GDK_KEY_F5,
 | |
| +                GDK_KEY_F6,
 | |
| +                GDK_KEY_F7,
 | |
| +                GDK_KEY_F8,
 | |
| +                GDK_KEY_F9,
 | |
| +                GDK_KEY_F10,
 | |
| +                GDK_KEY_F11,
 | |
| +                GDK_KEY_F12,
 | |
| +                GDK_KEY_F13,
 | |
| +                GDK_KEY_F14,
 | |
| +                GDK_KEY_F15,
 | |
| +                GDK_KEY_F16,
 | |
| +                GDK_KEY_F17,
 | |
| +                GDK_KEY_F18,
 | |
| +                GDK_KEY_F19,
 | |
| +                GDK_KEY_F20,
 | |
| +                GDK_KEY_F21,
 | |
| +                GDK_KEY_F22,
 | |
| +                GDK_KEY_F23,
 | |
| +                GDK_KEY_F24,
 | |
| +                GDK_KEY_VoidSymbol,
 | |
| +                GDK_KEY_Red,
 | |
| +                GDK_KEY_Green,
 | |
| +                GDK_KEY_Yellow,
 | |
| +                GDK_KEY_Blue,
 | |
| +                GDK_KEY_PowerOff,
 | |
| +                GDK_KEY_AudioRecord,
 | |
| +                GDK_KEY_Display,
 | |
| +                GDK_KEY_Subtitle,
 | |
| +                GDK_KEY_Video
 | |
| +            };
 | |
| +            result = new HashMap<int, unsigned>();
 | |
| +            for (unsigned gdkKeyCode : gdkKeyCodes) {
 | |
| +                int winKeyCode = PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(gdkKeyCode);
 | |
| +                // If several gdk key codes map to the same win key code first one is used.
 | |
| +                result->add(winKeyCode, gdkKeyCode);
 | |
| +            }
 | |
| +        });
 | |
| +    return *result;
 | |
| +}
 | |
| +
 | |
| +unsigned PlatformKeyboardEvent::gdkKeyCodeForWindowsKeyCode(int keycode)
 | |
| +{
 | |
| +    return gdkToWindowsKeyCodeMap().get(keycode);
 | |
| +}
 | |
| +
 | |
|  String PlatformKeyboardEvent::singleCharacterString(unsigned val)
 | |
|  {
 | |
|      switch (val) {
 | |
| diff --git a/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp b/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp
 | |
| index a34dc220bbb9a92b40dfb463e8724e81ac745b2c..8ecedd5dae88469366a619b96960598c1232a32d 100644
 | |
| --- a/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp
 | |
| +++ b/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp
 | |
| @@ -30,8 +30,10 @@
 | |
|  
 | |
|  #include "WindowsKeyboardCodes.h"
 | |
|  #include <wpe/wpe.h>
 | |
| +#include <wtf/HashMap.h>
 | |
|  #include <wtf/HexNumber.h>
 | |
|  #include <wtf/text/StringBuilder.h>
 | |
| +#include <mutex>
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| @@ -1291,6 +1293,246 @@ int PlatformKeyboardEvent::windowsKeyCodeForWPEKeyCode(unsigned keycode)
 | |
|      return 0;
 | |
|  }
 | |
|  
 | |
| +static const HashMap<int, unsigned>& WPEToWindowsKeyCodeMap()
 | |
| +{
 | |
| +    static HashMap<int, unsigned>* result;
 | |
| +    static std::once_flag once;
 | |
| +    std::call_once(
 | |
| +        once,
 | |
| +        [] {
 | |
| +            const unsigned WPEKeyCodes[] = {
 | |
| +                WPE_KEY_Cancel,
 | |
| +                // FIXME: non-keypad keys should take precedence, so we skip WPE_KEY_KP_*
 | |
| +                // WPE_KEY_KP_0,
 | |
| +                // WPE_KEY_KP_1,
 | |
| +                // WPE_KEY_KP_2,
 | |
| +                // WPE_KEY_KP_3,
 | |
| +                // WPE_KEY_KP_4,
 | |
| +                // WPE_KEY_KP_5,
 | |
| +                // WPE_KEY_KP_6,
 | |
| +                // WPE_KEY_KP_7,
 | |
| +                // WPE_KEY_KP_8,
 | |
| +                // WPE_KEY_KP_9,
 | |
| +                // WPE_KEY_KP_Multiply,
 | |
| +                // WPE_KEY_KP_Add,
 | |
| +                // WPE_KEY_KP_Subtract,
 | |
| +                // WPE_KEY_KP_Decimal,
 | |
| +                // WPE_KEY_KP_Divide,
 | |
| +                // WPE_KEY_KP_Page_Up,
 | |
| +                // WPE_KEY_KP_Page_Down,
 | |
| +                // WPE_KEY_KP_End,
 | |
| +                // WPE_KEY_KP_Home,
 | |
| +                // WPE_KEY_KP_Left,
 | |
| +                // WPE_KEY_KP_Up,
 | |
| +                // WPE_KEY_KP_Right,
 | |
| +                // WPE_KEY_KP_Down,
 | |
| +                WPE_KEY_BackSpace,
 | |
| +                // WPE_KEY_ISO_Left_Tab,
 | |
| +                // WPE_KEY_3270_BackTab,
 | |
| +                WPE_KEY_Tab,
 | |
| +                WPE_KEY_Clear,
 | |
| +                // WPE_KEY_ISO_Enter,
 | |
| +                // WPE_KEY_KP_Enter,
 | |
| +                WPE_KEY_Return,
 | |
| +                WPE_KEY_Menu,
 | |
| +                WPE_KEY_Pause,
 | |
| +                WPE_KEY_AudioPause,
 | |
| +                WPE_KEY_Caps_Lock,
 | |
| +                WPE_KEY_Kana_Lock,
 | |
| +                WPE_KEY_Kana_Shift,
 | |
| +                WPE_KEY_Hangul,
 | |
| +                WPE_KEY_Hangul_Hanja,
 | |
| +                WPE_KEY_Kanji,
 | |
| +                WPE_KEY_Escape,
 | |
| +                WPE_KEY_space,
 | |
| +                WPE_KEY_Page_Up,
 | |
| +                WPE_KEY_Page_Down,
 | |
| +                WPE_KEY_End,
 | |
| +                WPE_KEY_Home,
 | |
| +                WPE_KEY_Left,
 | |
| +                WPE_KEY_Up,
 | |
| +                WPE_KEY_Right,
 | |
| +                WPE_KEY_Down,
 | |
| +                WPE_KEY_Select,
 | |
| +                WPE_KEY_Print,
 | |
| +                WPE_KEY_Execute,
 | |
| +                WPE_KEY_Insert,
 | |
| +                WPE_KEY_KP_Insert,
 | |
| +                WPE_KEY_Delete,
 | |
| +                WPE_KEY_KP_Delete,
 | |
| +                WPE_KEY_Help,
 | |
| +                WPE_KEY_0,
 | |
| +                WPE_KEY_parenright,
 | |
| +                WPE_KEY_1,
 | |
| +                WPE_KEY_exclam,
 | |
| +                WPE_KEY_2,
 | |
| +                WPE_KEY_at,
 | |
| +                WPE_KEY_3,
 | |
| +                WPE_KEY_numbersign,
 | |
| +                WPE_KEY_4,
 | |
| +                WPE_KEY_dollar,
 | |
| +                WPE_KEY_5,
 | |
| +                WPE_KEY_percent,
 | |
| +                WPE_KEY_6,
 | |
| +                WPE_KEY_asciicircum,
 | |
| +                WPE_KEY_7,
 | |
| +                WPE_KEY_ampersand,
 | |
| +                WPE_KEY_8,
 | |
| +                WPE_KEY_asterisk,
 | |
| +                WPE_KEY_9,
 | |
| +                WPE_KEY_parenleft,
 | |
| +                WPE_KEY_a,
 | |
| +                WPE_KEY_A,
 | |
| +                WPE_KEY_b,
 | |
| +                WPE_KEY_B,
 | |
| +                WPE_KEY_c,
 | |
| +                WPE_KEY_C,
 | |
| +                WPE_KEY_d,
 | |
| +                WPE_KEY_D,
 | |
| +                WPE_KEY_e,
 | |
| +                WPE_KEY_E,
 | |
| +                WPE_KEY_f,
 | |
| +                WPE_KEY_F,
 | |
| +                WPE_KEY_g,
 | |
| +                WPE_KEY_G,
 | |
| +                WPE_KEY_h,
 | |
| +                WPE_KEY_H,
 | |
| +                WPE_KEY_i,
 | |
| +                WPE_KEY_I,
 | |
| +                WPE_KEY_j,
 | |
| +                WPE_KEY_J,
 | |
| +                WPE_KEY_k,
 | |
| +                WPE_KEY_K,
 | |
| +                WPE_KEY_l,
 | |
| +                WPE_KEY_L,
 | |
| +                WPE_KEY_m,
 | |
| +                WPE_KEY_M,
 | |
| +                WPE_KEY_n,
 | |
| +                WPE_KEY_N,
 | |
| +                WPE_KEY_o,
 | |
| +                WPE_KEY_O,
 | |
| +                WPE_KEY_p,
 | |
| +                WPE_KEY_P,
 | |
| +                WPE_KEY_q,
 | |
| +                WPE_KEY_Q,
 | |
| +                WPE_KEY_r,
 | |
| +                WPE_KEY_R,
 | |
| +                WPE_KEY_s,
 | |
| +                WPE_KEY_S,
 | |
| +                WPE_KEY_t,
 | |
| +                WPE_KEY_T,
 | |
| +                WPE_KEY_u,
 | |
| +                WPE_KEY_U,
 | |
| +                WPE_KEY_v,
 | |
| +                WPE_KEY_V,
 | |
| +                WPE_KEY_w,
 | |
| +                WPE_KEY_W,
 | |
| +                WPE_KEY_x,
 | |
| +                WPE_KEY_X,
 | |
| +                WPE_KEY_y,
 | |
| +                WPE_KEY_Y,
 | |
| +                WPE_KEY_z,
 | |
| +                WPE_KEY_Z,
 | |
| +                WPE_KEY_Meta_L,
 | |
| +                WPE_KEY_Meta_R,
 | |
| +                WPE_KEY_Sleep,
 | |
| +                WPE_KEY_Num_Lock,
 | |
| +                WPE_KEY_Scroll_Lock,
 | |
| +                WPE_KEY_Shift_L,
 | |
| +                WPE_KEY_Shift_R,
 | |
| +                WPE_KEY_Control_L,
 | |
| +                WPE_KEY_Control_R,
 | |
| +                WPE_KEY_Alt_L,
 | |
| +                WPE_KEY_Alt_R,
 | |
| +                WPE_KEY_Back,
 | |
| +                WPE_KEY_Forward,
 | |
| +                WPE_KEY_Refresh,
 | |
| +                WPE_KEY_Stop,
 | |
| +                WPE_KEY_Search,
 | |
| +                WPE_KEY_Favorites,
 | |
| +                WPE_KEY_HomePage,
 | |
| +                WPE_KEY_AudioMute,
 | |
| +                WPE_KEY_AudioLowerVolume,
 | |
| +                WPE_KEY_AudioRaiseVolume,
 | |
| +                WPE_KEY_AudioNext,
 | |
| +                WPE_KEY_AudioPrev,
 | |
| +                WPE_KEY_AudioStop,
 | |
| +                WPE_KEY_AudioMedia,
 | |
| +                WPE_KEY_semicolon,
 | |
| +                WPE_KEY_colon,
 | |
| +                WPE_KEY_plus,
 | |
| +                WPE_KEY_equal,
 | |
| +                WPE_KEY_comma,
 | |
| +                WPE_KEY_less,
 | |
| +                WPE_KEY_minus,
 | |
| +                WPE_KEY_underscore,
 | |
| +                WPE_KEY_period,
 | |
| +                WPE_KEY_greater,
 | |
| +                WPE_KEY_slash,
 | |
| +                WPE_KEY_question,
 | |
| +                WPE_KEY_asciitilde,
 | |
| +                WPE_KEY_quoteleft,
 | |
| +                WPE_KEY_bracketleft,
 | |
| +                WPE_KEY_braceleft,
 | |
| +                WPE_KEY_backslash,
 | |
| +                WPE_KEY_bar,
 | |
| +                WPE_KEY_bracketright,
 | |
| +                WPE_KEY_braceright,
 | |
| +                WPE_KEY_quoteright,
 | |
| +                WPE_KEY_quotedbl,
 | |
| +                WPE_KEY_AudioRewind,
 | |
| +                WPE_KEY_AudioForward,
 | |
| +                WPE_KEY_AudioPlay,
 | |
| +                WPE_KEY_F1,
 | |
| +                WPE_KEY_F2,
 | |
| +                WPE_KEY_F3,
 | |
| +                WPE_KEY_F4,
 | |
| +                WPE_KEY_F5,
 | |
| +                WPE_KEY_F6,
 | |
| +                WPE_KEY_F7,
 | |
| +                WPE_KEY_F8,
 | |
| +                WPE_KEY_F9,
 | |
| +                WPE_KEY_F10,
 | |
| +                WPE_KEY_F11,
 | |
| +                WPE_KEY_F12,
 | |
| +                WPE_KEY_F13,
 | |
| +                WPE_KEY_F14,
 | |
| +                WPE_KEY_F15,
 | |
| +                WPE_KEY_F16,
 | |
| +                WPE_KEY_F17,
 | |
| +                WPE_KEY_F18,
 | |
| +                WPE_KEY_F19,
 | |
| +                WPE_KEY_F20,
 | |
| +                WPE_KEY_F21,
 | |
| +                WPE_KEY_F22,
 | |
| +                WPE_KEY_F23,
 | |
| +                WPE_KEY_F24,
 | |
| +                WPE_KEY_VoidSymbol,
 | |
| +                WPE_KEY_Red,
 | |
| +                WPE_KEY_Green,
 | |
| +                WPE_KEY_Yellow,
 | |
| +                WPE_KEY_Blue,
 | |
| +                WPE_KEY_PowerOff,
 | |
| +                WPE_KEY_AudioRecord,
 | |
| +                WPE_KEY_Display,
 | |
| +                WPE_KEY_Subtitle,
 | |
| +                WPE_KEY_Video
 | |
| +            };
 | |
| +            result = new HashMap<int, unsigned>();
 | |
| +            for (unsigned WPEKeyCode : WPEKeyCodes) {
 | |
| +                int winKeyCode = PlatformKeyboardEvent::windowsKeyCodeForWPEKeyCode(WPEKeyCode);
 | |
| +                // If several gdk key codes map to the same win key code first one is used.
 | |
| +                result->add(winKeyCode, WPEKeyCode);
 | |
| +            }
 | |
| +        });
 | |
| +    return *result;
 | |
| +}
 | |
| +
 | |
| +unsigned PlatformKeyboardEvent::WPEKeyCodeForWindowsKeyCode(int keycode)
 | |
| +{
 | |
| +    return WPEToWindowsKeyCodeMap().get(keycode);
 | |
| +}
 | |
| +
 | |
|  String PlatformKeyboardEvent::singleCharacterString(unsigned val)
 | |
|  {
 | |
|      switch (val) {
 | |
| diff --git a/Source/WebCore/platform/network/NetworkStateNotifier.h b/Source/WebCore/platform/network/NetworkStateNotifier.h
 | |
| index 87930048f4fd18d6098af7de4da25be532df5931..2bb2afcf9473b0d5d97efbe18dd7b8145bc5f932 100644
 | |
| --- a/Source/WebCore/platform/network/NetworkStateNotifier.h
 | |
| +++ b/Source/WebCore/platform/network/NetworkStateNotifier.h
 | |
| @@ -72,6 +72,7 @@ private:
 | |
|  #endif
 | |
|  
 | |
|      Optional<bool> m_isOnLine;
 | |
| +    Optional<bool> m_emulatedIsOnLine;
 | |
|      Vector<WTF::Function<void(bool)>> m_listeners;
 | |
|      Timer m_updateStateTimer;
 | |
|  
 | |
| diff --git a/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h b/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h
 | |
| index d677280d2b5e7b053a240c155d64bc881f1737bb..1be949e09982b34366d162e6d45ebc51a76dcfb0 100644
 | |
| --- a/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h
 | |
| +++ b/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h
 | |
| @@ -47,7 +47,7 @@ class SocketStreamHandleClient;
 | |
|  
 | |
|  class SocketStreamHandleImpl : public SocketStreamHandle {
 | |
|  public:
 | |
| -    static Ref<SocketStreamHandleImpl> create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData, const StorageSessionProvider* provider) { return adoptRef(*new SocketStreamHandleImpl(url, client, sessionID, credentialPartition, WTFMove(auditData), provider)); }
 | |
| +    static Ref<SocketStreamHandleImpl> create(const URL& url, bool ignoreCertificateErrors, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData, const StorageSessionProvider* provider) { return adoptRef(*new SocketStreamHandleImpl(url, ignoreCertificateErrors, client, sessionID, credentialPartition, WTFMove(auditData), provider)); }
 | |
|  
 | |
|      virtual ~SocketStreamHandleImpl();
 | |
|  
 | |
| @@ -61,7 +61,7 @@ private:
 | |
|      Optional<size_t> platformSendInternal(const uint8_t*, size_t);
 | |
|      bool sendPendingData();
 | |
|  
 | |
| -    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, SourceApplicationAuditToken&&, const StorageSessionProvider*);
 | |
| +    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, bool ignoreCertificateErrors, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, SourceApplicationAuditToken&&, const StorageSessionProvider*);
 | |
|      void createStreams();
 | |
|      void scheduleStreams();
 | |
|      void chooseProxy();
 | |
| @@ -106,6 +106,7 @@ private:
 | |
|      String m_credentialPartition;
 | |
|      SourceApplicationAuditToken m_auditData;
 | |
|      RefPtr<const StorageSessionProvider> m_storageSessionProvider;
 | |
| +    bool m_ignoreCertificateErrors { false };
 | |
|  
 | |
|      StreamBuffer<uint8_t, 1024 * 1024> m_buffer;
 | |
|      static const unsigned maxBufferSize = 100 * 1024 * 1024;
 | |
| diff --git a/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp b/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp
 | |
| index 545c28e62f72771de5f3f3e9fed2e8cf6147ed0f..a6fc5f5b3fc62adce2604821bd29f9aed378c24c 100644
 | |
| --- a/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp
 | |
| +++ b/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp
 | |
| @@ -96,7 +96,7 @@ static inline auto callbacksRunLoopMode()
 | |
|  #endif
 | |
|  }
 | |
|  
 | |
| -SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData, const StorageSessionProvider* provider)
 | |
| +SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, bool ignoreCertificateErrors, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData, const StorageSessionProvider* provider)
 | |
|      : SocketStreamHandle(url, client)
 | |
|      , m_connectingSubstate(New)
 | |
|      , m_connectionType(Unknown)
 | |
| @@ -104,6 +104,7 @@ SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandl
 | |
|      , m_credentialPartition(credentialPartition)
 | |
|      , m_auditData(WTFMove(auditData))
 | |
|      , m_storageSessionProvider(provider)
 | |
| +    , m_ignoreCertificateErrors(ignoreCertificateErrors)
 | |
|  {
 | |
|      LOG(Network, "SocketStreamHandle %p new client %p", this, &m_client);
 | |
|  
 | |
| @@ -360,7 +361,7 @@ void SocketStreamHandleImpl::createStreams()
 | |
|      }
 | |
|  
 | |
|      if (shouldUseSSL()) {
 | |
| -        CFBooleanRef validateCertificateChain = DeprecatedGlobalSettings::allowsAnySSLCertificate() ? kCFBooleanFalse : kCFBooleanTrue;
 | |
| +        CFBooleanRef validateCertificateChain = m_ignoreCertificateErrors || DeprecatedGlobalSettings::allowsAnySSLCertificate() ? kCFBooleanFalse : kCFBooleanTrue;
 | |
|          const void* keys[] = {
 | |
|              kCFStreamSSLPeerName,
 | |
|              kCFStreamSSLLevel,
 | |
| diff --git a/Source/WebCore/platform/network/curl/CookieJarDB.h b/Source/WebCore/platform/network/curl/CookieJarDB.h
 | |
| index 112f632128b1aa72b4639b62a3eb5a79e37c5f80..0ba51dfb3f80ce0cc09ba9065fd5ed7c9588d931 100644
 | |
| --- a/Source/WebCore/platform/network/curl/CookieJarDB.h
 | |
| +++ b/Source/WebCore/platform/network/curl/CookieJarDB.h
 | |
| @@ -69,7 +69,7 @@ public:
 | |
|      WEBCORE_EXPORT ~CookieJarDB();
 | |
|  
 | |
|  private:
 | |
| -    CookieAcceptPolicy m_acceptPolicy { CookieAcceptPolicy::Always };
 | |
| +    CookieAcceptPolicy m_acceptPolicy { CookieAcceptPolicy::OnlyFromMainDocumentDomain };
 | |
|      String m_databasePath;
 | |
|  
 | |
|      bool m_detectedDatabaseCorruption { false };
 | |
| diff --git a/Source/WebCore/platform/network/curl/CurlStream.cpp b/Source/WebCore/platform/network/curl/CurlStream.cpp
 | |
| index 26dc7bef4b74bc6b4e2e526dec6523c3ad6d3643..c783aa5a7984f3966312e5e0ffd76f93ed6208f8 100644
 | |
| --- a/Source/WebCore/platform/network/curl/CurlStream.cpp
 | |
| +++ b/Source/WebCore/platform/network/curl/CurlStream.cpp
 | |
| @@ -33,7 +33,7 @@
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| -CurlStream::CurlStream(CurlStreamScheduler& scheduler, CurlStreamID streamID, URL&& url)
 | |
| +CurlStream::CurlStream(CurlStreamScheduler& scheduler, CurlStreamID streamID, bool ignoreCertificateErrors, URL&& url)
 | |
|      : m_scheduler(scheduler)
 | |
|      , m_streamID(streamID)
 | |
|  {
 | |
| @@ -49,6 +49,9 @@ CurlStream::CurlStream(CurlStreamScheduler& scheduler, CurlStreamID streamID, UR
 | |
|      m_curlHandle->setUrl(urlForConnection);
 | |
|  
 | |
|      m_curlHandle->enableConnectionOnly();
 | |
| +    if (ignoreCertificateErrors)
 | |
| +        m_curlHandle->disableServerTrustEvaluation();
 | |
| +
 | |
|  
 | |
|      auto errorCode = m_curlHandle->perform();
 | |
|      if (errorCode != CURLE_OK) {
 | |
| diff --git a/Source/WebCore/platform/network/curl/CurlStream.h b/Source/WebCore/platform/network/curl/CurlStream.h
 | |
| index 313b0173da5cd404a1e3fcad9573b8ff7c3abd4f..020980a0f61d47e8c7929bfaab2f8394d014766d 100644
 | |
| --- a/Source/WebCore/platform/network/curl/CurlStream.h
 | |
| +++ b/Source/WebCore/platform/network/curl/CurlStream.h
 | |
| @@ -50,12 +50,12 @@ public:
 | |
|          virtual void didFail(CurlStreamID, CURLcode) = 0;
 | |
|      };
 | |
|  
 | |
| -    static std::unique_ptr<CurlStream> create(CurlStreamScheduler& scheduler, CurlStreamID streamID, URL&& url)
 | |
| +    static std::unique_ptr<CurlStream> create(CurlStreamScheduler& scheduler, CurlStreamID streamID, bool ignoreCertificateErrors, URL&& url)
 | |
|      {
 | |
| -        return WTF::makeUnique<CurlStream>(scheduler, streamID, WTFMove(url));
 | |
| +        return WTF::makeUnique<CurlStream>(scheduler, streamID, ignoreCertificateErrors, WTFMove(url));
 | |
|      }
 | |
|  
 | |
| -    CurlStream(CurlStreamScheduler&, CurlStreamID, URL&&);
 | |
| +    CurlStream(CurlStreamScheduler&, CurlStreamID, bool ignoreCertificateErrors, URL&&);
 | |
|      virtual ~CurlStream();
 | |
|  
 | |
|      void send(UniqueArray<uint8_t>&&, size_t);
 | |
| diff --git a/Source/WebCore/platform/network/curl/CurlStreamScheduler.cpp b/Source/WebCore/platform/network/curl/CurlStreamScheduler.cpp
 | |
| index 3fb8759984aa31a7d44baa2f69afe2fee461ea4f..bb7ad47477d97fa1eaff5d3da6b9a3705ff1e32f 100644
 | |
| --- a/Source/WebCore/platform/network/curl/CurlStreamScheduler.cpp
 | |
| +++ b/Source/WebCore/platform/network/curl/CurlStreamScheduler.cpp
 | |
| @@ -40,7 +40,7 @@ CurlStreamScheduler::~CurlStreamScheduler()
 | |
|      ASSERT(isMainThread());
 | |
|  }
 | |
|  
 | |
| -CurlStreamID CurlStreamScheduler::createStream(const URL& url, CurlStream::Client& client)
 | |
| +CurlStreamID CurlStreamScheduler::createStream(const URL& url, bool ignoreCertificateErrors, CurlStream::Client& client)
 | |
|  {
 | |
|      ASSERT(isMainThread());
 | |
|  
 | |
| @@ -51,8 +51,8 @@ CurlStreamID CurlStreamScheduler::createStream(const URL& url, CurlStream::Clien
 | |
|      auto streamID = m_currentStreamID;
 | |
|      m_clientList.add(streamID, &client);
 | |
|  
 | |
| -    callOnWorkerThread([this, streamID, url = url.isolatedCopy()]() mutable {
 | |
| -        m_streamList.add(streamID, CurlStream::create(*this, streamID, WTFMove(url)));
 | |
| +    callOnWorkerThread([this, streamID, ignoreCertificateErrors, url = url.isolatedCopy()]() mutable {
 | |
| +        m_streamList.add(streamID, CurlStream::create(*this, streamID, ignoreCertificateErrors, WTFMove(url)));
 | |
|      });
 | |
|  
 | |
|      return streamID;
 | |
| diff --git a/Source/WebCore/platform/network/curl/CurlStreamScheduler.h b/Source/WebCore/platform/network/curl/CurlStreamScheduler.h
 | |
| index 7d881206c9689f433227969c9b7f9ff268bdaaed..2e8118f11f87fa5f32adcedc165aec8220b36d58 100644
 | |
| --- a/Source/WebCore/platform/network/curl/CurlStreamScheduler.h
 | |
| +++ b/Source/WebCore/platform/network/curl/CurlStreamScheduler.h
 | |
| @@ -38,7 +38,7 @@ public:
 | |
|      CurlStreamScheduler();
 | |
|      virtual ~CurlStreamScheduler();
 | |
|  
 | |
| -    CurlStreamID createStream(const URL&, CurlStream::Client&);
 | |
| +    CurlStreamID createStream(const URL&, bool ignoreCertificateErrors, CurlStream::Client&);
 | |
|      void destroyStream(CurlStreamID);
 | |
|      void send(CurlStreamID, UniqueArray<uint8_t>&&, size_t);
 | |
|  
 | |
| diff --git a/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h b/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h
 | |
| index fad4ef9198118f5e6e5ed7d3c14b99e574593451..a2d59843896f252fccdddbb94c5275eec6300f1b 100644
 | |
| --- a/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h
 | |
| +++ b/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h
 | |
| @@ -44,7 +44,7 @@ class StorageSessionProvider;
 | |
|  
 | |
|  class SocketStreamHandleImpl : public SocketStreamHandle, public CurlStream::Client {
 | |
|  public:
 | |
| -    static Ref<SocketStreamHandleImpl> create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider* provider) { return adoptRef(*new SocketStreamHandleImpl(url, client, provider)); }
 | |
| +    static Ref<SocketStreamHandleImpl> create(const URL& url, bool ignoreCertificateErrors, SocketStreamHandleClient& client, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider* provider) { return adoptRef(*new SocketStreamHandleImpl(url, ignoreCertificateErrors, client, provider)); }
 | |
|  
 | |
|      virtual ~SocketStreamHandleImpl();
 | |
|  
 | |
| @@ -53,7 +53,7 @@ public:
 | |
|      WEBCORE_EXPORT void platformClose() final;
 | |
|  
 | |
|  private:
 | |
| -    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, const StorageSessionProvider*);
 | |
| +    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, bool ignoreCertificateErrors, SocketStreamHandleClient&, const StorageSessionProvider*);
 | |
|  
 | |
|      size_t bufferedAmount() final;
 | |
|      Optional<size_t> platformSendInternal(const uint8_t*, size_t);
 | |
| diff --git a/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp b/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp
 | |
| index 3b6dea9ed2552d81aaf7e694a5f922e96dbf94d6..6b5bd9b9782b0fb55341e76fc3cff8625f7a30a8 100644
 | |
| --- a/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp
 | |
| +++ b/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp
 | |
| @@ -43,7 +43,7 @@
 | |
|  
 | |
|  namespace WebCore {
 | |
|  
 | |
| -SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, const StorageSessionProvider* provider)
 | |
| +SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, bool ignoreCertificateErrors, SocketStreamHandleClient& client, const StorageSessionProvider* provider)
 | |
|      : SocketStreamHandle(url, client)
 | |
|      , m_storageSessionProvider(provider)
 | |
|      , m_scheduler(CurlContext::singleton().streamScheduler())
 | |
| @@ -52,7 +52,7 @@ SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandl
 | |
|      if (m_url.protocolIs("wss") && DeprecatedGlobalSettings::allowsAnySSLCertificate())
 | |
|          CurlContext::singleton().sslHandle().setIgnoreSSLErrors(true);
 | |
|  
 | |
| -    m_streamID = m_scheduler.createStream(m_url, *this);
 | |
| +    m_streamID = m_scheduler.createStream(m_url, ignoreCertificateErrors, *this);
 | |
|  }
 | |
|  
 | |
|  SocketStreamHandleImpl::~SocketStreamHandleImpl()
 | |
| diff --git a/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h b/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h
 | |
| index 3ecf866005da6da9cec7c7930e6a4f93cb39d6e0..d81dc9ac0c433e00ab4ad73e206856098ab9230e 100644
 | |
| --- a/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h
 | |
| +++ b/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h
 | |
| @@ -47,7 +47,7 @@ class StorageSessionProvider;
 | |
|  
 | |
|  class SocketStreamHandleImpl final : public SocketStreamHandle {
 | |
|  public:
 | |
| -    static Ref<SocketStreamHandleImpl> create(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider*)
 | |
| +    static Ref<SocketStreamHandleImpl> create(const URL&, bool, SocketStreamHandleClient&, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider*)
 | |
|      {
 | |
|          RELEASE_ASSERT_NOT_REACHED();
 | |
|      }
 | |
| diff --git a/Source/WebCore/platform/win/KeyEventWin.cpp b/Source/WebCore/platform/win/KeyEventWin.cpp
 | |
| index 44737686187a06a92c408ea60b63a48ac8481334..c754a763688b52e7ddd47493296ef9b0c6adc527 100644
 | |
| --- a/Source/WebCore/platform/win/KeyEventWin.cpp
 | |
| +++ b/Source/WebCore/platform/win/KeyEventWin.cpp
 | |
| @@ -239,10 +239,16 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData,
 | |
|  {
 | |
|  }
 | |
|  
 | |
| -void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type, bool)
 | |
| +void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardsCompatibility)
 | |
|  {
 | |
| -    // No KeyDown events on Windows to disambiguate.
 | |
| -    ASSERT_NOT_REACHED();
 | |
| +    m_type = type;
 | |
| +    if (type == PlatformEvent::RawKeyDown) {
 | |
| +        m_text = String();
 | |
| +        m_unmodifiedText = String();
 | |
| +    } else {
 | |
| +        m_keyIdentifier = String();
 | |
| +        m_windowsVirtualKeyCode = 0;
 | |
| +    }
 | |
|  }
 | |
|  
 | |
|  bool PlatformKeyboardEvent::currentCapsLockState()
 | |
| diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp
 | |
| index 5b46d33340e5160efc46345d6f45a8f1e95b1a76..54beed33e140550a98b0e34ff81964898c54996e 100644
 | |
| --- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp
 | |
| +++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp
 | |
| @@ -26,7 +26,6 @@
 | |
|  
 | |
|  #include "config.h"
 | |
|  #include "NetworkProcess.h"
 | |
| -
 | |
|  #include "ArgumentCoders.h"
 | |
|  #include "Attachment.h"
 | |
|  #include "AuthenticationManager.h"
 | |
| @@ -597,6 +596,41 @@ void NetworkProcess::destroySession(PAL::SessionID sessionID)
 | |
|          webIDBServer->close();
 | |
|  }
 | |
|  
 | |
| +void NetworkProcess::getAllCookies(PAL::SessionID sessionID, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&& completionHandler)
 | |
| +{
 | |
| +    if (auto* networkStorageSession = storageSession(sessionID)) {
 | |
| +        completionHandler(networkStorageSession->getAllCookies());
 | |
| +        return;
 | |
| +    }
 | |
| +    completionHandler({ });
 | |
| +}
 | |
| +
 | |
| +void NetworkProcess::setCookies(PAL::SessionID sessionID, Vector<WebCore::Cookie> cookies, CompletionHandler<void(bool)>&& completionHandler) {
 | |
| +    if (auto* networkStorageSession = storageSession(sessionID)) {
 | |
| +        for (auto cookie : cookies)
 | |
| +            networkStorageSession->setCookie(cookie);
 | |
| +        completionHandler(true);
 | |
| +        return;
 | |
| +    }
 | |
| +    completionHandler(false);
 | |
| +}
 | |
| +
 | |
| +void NetworkProcess::deleteAllCookies(PAL::SessionID sessionID, CompletionHandler<void(bool)>&& completionHandler)
 | |
| +{
 | |
| +    if (auto* networkStorageSession = storageSession(sessionID)) {
 | |
| +        networkStorageSession->deleteAllCookies();
 | |
| +        completionHandler(true);
 | |
| +        return;
 | |
| +    }
 | |
| +    completionHandler(false);
 | |
| +}
 | |
| +
 | |
| +void NetworkProcess::setIgnoreCertificateErrors(PAL::SessionID sessionID, bool ignore)
 | |
| +{
 | |
| +    if (auto* networkSession = this->networkSession(sessionID))
 | |
| +        networkSession->setIgnoreCertificateErrors(ignore);
 | |
| +}
 | |
| +
 | |
|  #if ENABLE(RESOURCE_LOAD_STATISTICS)
 | |
|  void NetworkProcess::dumpResourceLoadStatistics(PAL::SessionID sessionID, CompletionHandler<void(String)>&& completionHandler)
 | |
|  {
 | |
| diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h
 | |
| index 6bd38187b1d0a4c5abeb69f07d20b96d21d6d568..0a5e25aed878ba89e4a580dda7fc2c8e6d2097e1 100644
 | |
| --- a/Source/WebKit/NetworkProcess/NetworkProcess.h
 | |
| +++ b/Source/WebKit/NetworkProcess/NetworkProcess.h
 | |
| @@ -72,6 +72,7 @@ class SessionID;
 | |
|  
 | |
|  namespace WebCore {
 | |
|  class CertificateInfo;
 | |
| +struct Cookie;
 | |
|  class CurlProxySettings;
 | |
|  class DownloadID;
 | |
|  class ProtectionSpace;
 | |
| @@ -200,6 +201,11 @@ public:
 | |
|  
 | |
|      void addWebsiteDataStore(WebsiteDataStoreParameters&&);
 | |
|  
 | |
| +    void getAllCookies(PAL::SessionID, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&&);
 | |
| +    void setCookies(PAL::SessionID, Vector<WebCore::Cookie>, CompletionHandler<void(bool)>&&);
 | |
| +    void deleteAllCookies(PAL::SessionID, CompletionHandler<void(bool)>&&);
 | |
| +    void setIgnoreCertificateErrors(PAL::SessionID, bool);
 | |
| +
 | |
|  #if ENABLE(RESOURCE_LOAD_STATISTICS)
 | |
|      void clearPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
 | |
|      void clearUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
 | |
| diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
 | |
| index 50bae4382fcd1b491d9745270712637db8a231cb..59889a245fc1477a7806bdd75fdf7f686f45d470 100644
 | |
| --- a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
 | |
| +++ b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
 | |
| @@ -82,6 +82,11 @@ messages -> NetworkProcess LegacyReceiver {
 | |
|  
 | |
|      PreconnectTo(PAL::SessionID sessionID, URL url, String userAgent, enum:uint8_t WebCore::StoredCredentialsPolicy storedCredentialsPolicy, enum:bool Optional<WebKit::NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain);
 | |
|  
 | |
| +    GetAllCookies(PAL::SessionID sessionID) -> (Vector<WebCore::Cookie> cookies) Async
 | |
| +    SetCookies(PAL::SessionID sessionID, Vector<WebCore::Cookie> cookies) -> (bool success) Async
 | |
| +    DeleteAllCookies(PAL::SessionID sessionID) -> (bool success) Async
 | |
| +    SetIgnoreCertificateErrors(PAL::SessionID sessionID, bool ignoreTLSErrors)
 | |
| +
 | |
|  #if ENABLE(RESOURCE_LOAD_STATISTICS)
 | |
|      ClearPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async
 | |
|      ClearUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async
 | |
| diff --git a/Source/WebKit/NetworkProcess/NetworkSession.h b/Source/WebKit/NetworkProcess/NetworkSession.h
 | |
| index d8d3ecbad8e688506a885640891848a2ba06e43a..62047204ac144fbcdeb5fd35dffa9956a26c43da 100644
 | |
| --- a/Source/WebKit/NetworkProcess/NetworkSession.h
 | |
| +++ b/Source/WebKit/NetworkProcess/NetworkSession.h
 | |
| @@ -138,6 +138,9 @@ public:
 | |
|  
 | |
|      bool isStaleWhileRevalidateEnabled() const { return m_isStaleWhileRevalidateEnabled; }
 | |
|  
 | |
| +    void setIgnoreCertificateErrors(bool ignore) { m_ignoreCertificateErrors = ignore; }
 | |
| +    bool ignoreCertificateErrors() { return m_ignoreCertificateErrors; }
 | |
| +
 | |
|  #if ENABLE(SERVICE_WORKER)
 | |
|      void addSoftUpdateLoader(std::unique_ptr<ServiceWorkerSoftUpdateLoader>&& loader) { m_softUpdateLoaders.add(WTFMove(loader)); }
 | |
|      void removeSoftUpdateLoader(ServiceWorkerSoftUpdateLoader* loader) { m_softUpdateLoaders.remove(loader); }
 | |
| @@ -168,6 +171,7 @@ protected:
 | |
|  #endif
 | |
|      bool m_isStaleWhileRevalidateEnabled { false };
 | |
|      UniqueRef<AdClickAttributionManager> m_adClickAttribution;
 | |
| +    bool m_ignoreCertificateErrors { false };
 | |
|  
 | |
|      HashSet<Ref<NetworkResourceLoader>> m_keptAliveLoads;
 | |
|  
 | |
| diff --git a/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp b/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp
 | |
| index d1fa427d82884fc43569d1bf0df7d728921502fc..30450ab01cddfcd406e46ac8e08ac50a2983f7a6 100644
 | |
| --- a/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp
 | |
| +++ b/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp
 | |
| @@ -43,7 +43,7 @@ Ref<NetworkSocketStream> NetworkSocketStream::create(NetworkProcess& networkProc
 | |
|  NetworkSocketStream::NetworkSocketStream(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, WebSocketIdentifier identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
 | |
|      : m_identifier(identifier)
 | |
|      , m_connection(connection)
 | |
| -    , m_impl(SocketStreamHandleImpl::create(url, *this, sessionID, credentialPartition, WTFMove(auditData), NetworkStorageSessionProvider::create(networkProcess, sessionID).ptr()))
 | |
| +    , m_impl(SocketStreamHandleImpl::create(url, networkProcess.networkSession(sessionID)->ignoreCertificateErrors(), *this, sessionID, credentialPartition, WTFMove(auditData), NetworkStorageSessionProvider::create(networkProcess, sessionID).ptr()))
 | |
|  {
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
 | |
| index 906612866d67bd4f2e23407038b948f1438762b2..c0b52ce5f70222ebd7cb9a66e7221578e00210ec 100644
 | |
| --- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
 | |
| +++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
 | |
| @@ -656,7 +656,7 @@ static inline void processServerTrustEvaluation(NetworkSessionCocoa& session, Se
 | |
|      NegotiatedLegacyTLS negotiatedLegacyTLS = NegotiatedLegacyTLS::No;
 | |
|  
 | |
|      if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
 | |
| -        if (NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost(challenge))
 | |
| +        if (sessionCocoa->ignoreCertificateErrors() || sessionCocoa->allowsSpecificHTTPSCertificateForHost(challenge))
 | |
|              return completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
 | |
|  
 | |
|  #if HAVE(TLS_PROTOCOL_VERSION_T)
 | |
| diff --git a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
 | |
| index 26d961d4e9bc5bcd8064361f9d2e9bc478573b72..c5056df4833dd7d4e713a5edabf8c87fb6feb980 100644
 | |
| --- a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
 | |
| +++ b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
 | |
| @@ -26,9 +26,13 @@
 | |
|  #include "config.h"
 | |
|  #include "NetworkDataTaskCurl.h"
 | |
|  
 | |
| +#include "APIError.h"
 | |
|  #include "AuthenticationChallengeDisposition.h"
 | |
|  #include "AuthenticationManager.h"
 | |
| +#include "DataReference.h"
 | |
| +#include "Download.h"
 | |
|  #include "NetworkSessionCurl.h"
 | |
| +#include "NetworkProcess.h"
 | |
|  #include <WebCore/AuthenticationChallenge.h>
 | |
|  #include <WebCore/CookieJar.h>
 | |
|  #include <WebCore/CurlRequest.h>
 | |
| @@ -38,6 +42,8 @@
 | |
|  #include <WebCore/ResourceError.h>
 | |
|  #include <WebCore/SameSiteInfo.h>
 | |
|  #include <WebCore/SynchronousLoaderClient.h>
 | |
| +#include <WebCore/TextEncoding.h>
 | |
| +#include <wtf/FileSystem.h>
 | |
|  
 | |
|  namespace WebKit {
 | |
|  
 | |
| @@ -71,6 +77,8 @@ NetworkDataTaskCurl::NetworkDataTaskCurl(NetworkSession& session, NetworkDataTas
 | |
|          m_curlRequest->setUserPass(m_initialCredential.user(), m_initialCredential.password());
 | |
|          m_curlRequest->setAuthenticationScheme(ProtectionSpaceAuthenticationSchemeHTTPBasic);
 | |
|      }
 | |
| +    if (m_session->ignoreCertificateErrors())
 | |
| +        m_curlRequest->disableServerTrustEvaluation();
 | |
|      m_curlRequest->setStartTime(m_startTime);
 | |
|      m_curlRequest->start();
 | |
|  }
 | |
| @@ -177,7 +185,12 @@ void NetworkDataTaskCurl::curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&
 | |
|      auto protectedThis = makeRef(*this);
 | |
|      if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
 | |
|          return;
 | |
| -
 | |
| +    if (isDownload()) {
 | |
| +        FileSystem::PlatformFileHandle file = FileSystem::openFile(m_pendingDownloadLocation, FileSystem::FileOpenMode::Write);
 | |
| +        FileSystem::writeToFile(file, buffer->data(), buffer->size());
 | |
| +        FileSystem::closeFile(file);
 | |
| +        return;
 | |
| +    }
 | |
|      m_client->didReceiveData(WTFMove(buffer));
 | |
|  }
 | |
|  
 | |
| @@ -186,6 +199,12 @@ void NetworkDataTaskCurl::curlDidComplete(CurlRequest&, NetworkLoadMetrics&& net
 | |
|      if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
 | |
|          return;
 | |
|  
 | |
| +    if (isDownload()) {
 | |
| +        auto* download = m_session->networkProcess().downloadManager().download(m_pendingDownloadID);
 | |
| +        ASSERT(download);
 | |
| +        download->didFinish();
 | |
| +        return;
 | |
| +    }
 | |
|      m_client->didCompleteWithError({ }, WTFMove(networkLoadMetrics));
 | |
|  }
 | |
|  
 | |
| @@ -199,6 +218,13 @@ void NetworkDataTaskCurl::curlDidFailWithError(CurlRequest& request, ResourceErr
 | |
|          return;
 | |
|      }
 | |
|  
 | |
| +    if (isDownload()) {
 | |
| +        auto* download = m_session->networkProcess().downloadManager().download(m_pendingDownloadID);
 | |
| +        ASSERT(download);
 | |
| +        download->didFail(resourceError, IPC::DataReference());
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      m_client->didCompleteWithError(resourceError);
 | |
|  }
 | |
|  
 | |
| @@ -235,6 +261,18 @@ void NetworkDataTaskCurl::invokeDidReceiveResponse()
 | |
|              break;
 | |
|          case PolicyAction::Ignore:
 | |
|              break;
 | |
| +        case PolicyAction::Download: {
 | |
| +            FileSystem::deleteFile(m_pendingDownloadLocation);
 | |
| +            auto& downloadManager = m_session->networkProcess().downloadManager();
 | |
| +            auto download = makeUnique<Download>(downloadManager, m_pendingDownloadID, *this, *m_session, suggestedFilename());
 | |
| +            auto* downloadPtr = download.get();
 | |
| +            downloadManager.dataTaskBecameDownloadTask(m_pendingDownloadID, WTFMove(download));
 | |
| +            downloadPtr->didCreateDestination(m_pendingDownloadLocation);
 | |
| +
 | |
| +            if (m_curlRequest)
 | |
| +                m_curlRequest->completeDidReceiveResponse();
 | |
| +            break;
 | |
| +        }
 | |
|          default:
 | |
|              notImplemented();
 | |
|              break;
 | |
| @@ -312,6 +350,8 @@ void NetworkDataTaskCurl::willPerformHTTPRedirection()
 | |
|              m_curlRequest->setUserPass(m_initialCredential.user(), m_initialCredential.password());
 | |
|              m_curlRequest->setAuthenticationScheme(ProtectionSpaceAuthenticationSchemeHTTPBasic);
 | |
|          }
 | |
| +        if (m_session->ignoreCertificateErrors())
 | |
| +            m_curlRequest->disableServerTrustEvaluation();
 | |
|          m_curlRequest->setStartTime(m_startTime);
 | |
|          m_curlRequest->start();
 | |
|  
 | |
| @@ -462,4 +502,16 @@ void NetworkDataTaskCurl::handleCookieHeaders(const WebCore::ResourceRequest& re
 | |
|      }
 | |
|  }
 | |
|  
 | |
| +String NetworkDataTaskCurl::suggestedFilename() const
 | |
| +{
 | |
| +    if (!m_suggestedFilename.isEmpty())
 | |
| +        return m_suggestedFilename;
 | |
| +
 | |
| +    String suggestedFilename = m_response.suggestedFilename();
 | |
| +    if (!suggestedFilename.isEmpty())
 | |
| +        return suggestedFilename;
 | |
| +
 | |
| +    return decodeURLEscapeSequences(m_response.url().lastPathComponent());
 | |
| +}
 | |
| +
 | |
|  } // namespace WebKit
 | |
| diff --git a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
 | |
| index 52d085b44c17e60f6133fba0e0cd6933ee3af255..7c95b368df416300ce095c77c4a2ef29a3ffb0bb 100644
 | |
| --- a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
 | |
| +++ b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
 | |
| @@ -81,6 +81,7 @@ private:
 | |
|  
 | |
|      void appendCookieHeader(WebCore::ResourceRequest&);
 | |
|      void handleCookieHeaders(const WebCore::ResourceRequest&, const WebCore::CurlResponse&);
 | |
| +    String suggestedFilename() const override;
 | |
|  
 | |
|      State m_state { State::Suspended };
 | |
|  
 | |
| diff --git a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
 | |
| index 9c0465058939cf65fc10f4771ed216662b6b9f8b..53b7425514c7adbbe02085e6d8c810ed112b28c0 100644
 | |
| --- a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
 | |
| +++ b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
 | |
| @@ -450,6 +450,8 @@ bool NetworkDataTaskSoup::tlsConnectionAcceptCertificate(GTlsCertificate* certif
 | |
|  {
 | |
|      ASSERT(m_soupRequest);
 | |
|      URL url = soupURIToURL(soup_request_get_uri(m_soupRequest.get()));
 | |
| +    if (m_session->ignoreCertificateErrors())
 | |
| +        return true;
 | |
|      auto error = SoupNetworkSession::checkTLSErrors(url, certificate, tlsErrors);
 | |
|      if (!error)
 | |
|          return true;
 | |
| diff --git a/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp b/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp
 | |
| index 407361f036e79891767d807fbb63c9044b260a70..24773d8f349d441e2b6b1981baa5af170a96b384 100644
 | |
| --- a/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp
 | |
| +++ b/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp
 | |
| @@ -106,6 +106,11 @@ static gboolean webSocketAcceptCertificateCallback(GTlsConnection*, GTlsCertific
 | |
|      return !SoupNetworkSession::checkTLSErrors(soupURIToURL(soup_message_get_uri(soupMessage)), certificate, errors);
 | |
|  }
 | |
|  
 | |
| +static gboolean webSocketAcceptCertificateCallbackIgnoreTLSErrors(GTlsConnection*, GTlsCertificate* certificate, GTlsCertificateFlags errors, SoupMessage* soupMessage)
 | |
| +{
 | |
| +    return TRUE;
 | |
| +}
 | |
| +
 | |
|  static void webSocketMessageNetworkEventCallback(SoupMessage* soupMessage, GSocketClientEvent event, GIOStream* connection)
 | |
|  {
 | |
|      if (event != G_SOCKET_CLIENT_TLS_HANDSHAKING)
 | |
| @@ -114,6 +119,14 @@ static void webSocketMessageNetworkEventCallback(SoupMessage* soupMessage, GSock
 | |
|      g_signal_connect(connection, "accept-certificate", G_CALLBACK(webSocketAcceptCertificateCallback), soupMessage);
 | |
|  }
 | |
|  
 | |
| +static void webSocketMessageNetworkEventCallbackIgnoreTLSErrors(SoupMessage* soupMessage, GSocketClientEvent event, GIOStream* connection)
 | |
| +{
 | |
| +    if (event != G_SOCKET_CLIENT_TLS_HANDSHAKING)
 | |
| +        return;
 | |
| +
 | |
| +    g_signal_connect(connection, "accept-certificate", G_CALLBACK(webSocketAcceptCertificateCallbackIgnoreTLSErrors), soupMessage);
 | |
| +}
 | |
| +
 | |
|  std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(NetworkSocketChannel& channel, const ResourceRequest& request, const String& protocol)
 | |
|  {
 | |
|      GUniquePtr<SoupURI> soupURI = request.createSoupURI();
 | |
| @@ -122,8 +135,12 @@ std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(NetworkSo
 | |
|  
 | |
|      GRefPtr<SoupMessage> soupMessage = adoptGRef(soup_message_new_from_uri(SOUP_METHOD_GET, soupURI.get()));
 | |
|      request.updateSoupMessage(soupMessage.get(), blobRegistry());
 | |
| -    if (request.url().protocolIs("wss"))
 | |
| -        g_signal_connect(soupMessage.get(), "network-event", G_CALLBACK(webSocketMessageNetworkEventCallback), nullptr);
 | |
| +    if (request.url().protocolIs("wss")) {
 | |
| +        if (ignoreCertificateErrors())
 | |
| +          g_signal_connect(soupMessage.get(), "network-event", G_CALLBACK(webSocketMessageNetworkEventCallbackIgnoreTLSErrors), nullptr);
 | |
| +        else
 | |
| +          g_signal_connect(soupMessage.get(), "network-event", G_CALLBACK(webSocketMessageNetworkEventCallback), nullptr);
 | |
| +    }
 | |
|      return makeUnique<WebSocketTask>(channel, soupSession(), soupMessage.get(), protocol);
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebKit/PlatformWPE.cmake b/Source/WebKit/PlatformWPE.cmake
 | |
| index 8320e310e6c466924a083ee46ae31f5486420fcd..33e1a5f6d846a490bb66848cfc1518a5b17104fd 100644
 | |
| --- a/Source/WebKit/PlatformWPE.cmake
 | |
| +++ b/Source/WebKit/PlatformWPE.cmake
 | |
| @@ -255,6 +255,7 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES
 | |
|      "${WEBKIT_DIR}/UIProcess/API/wpe"
 | |
|      "${WEBKIT_DIR}/UIProcess/CoordinatedGraphics"
 | |
|      "${WEBKIT_DIR}/UIProcess/geoclue"
 | |
| +    "${WEBKIT_DIR}/UIProcess/glib"
 | |
|      "${WEBKIT_DIR}/UIProcess/gstreamer"
 | |
|      "${WEBKIT_DIR}/UIProcess/linux"
 | |
|      "${WEBKIT_DIR}/UIProcess/soup"
 | |
| diff --git a/Source/WebKit/PlatformWin.cmake b/Source/WebKit/PlatformWin.cmake
 | |
| index a94c7e11ce6898fa0c58a6b06b193107807dfa84..7854a489e30420c615d78234da373e97fe6a3dc2 100644
 | |
| --- a/Source/WebKit/PlatformWin.cmake
 | |
| +++ b/Source/WebKit/PlatformWin.cmake
 | |
| @@ -59,8 +59,12 @@ list(APPEND WebKit_SOURCES
 | |
|  
 | |
|      UIProcess/WebsiteData/win/WebsiteDataStoreWin.cpp
 | |
|  
 | |
| +    UIProcess/win/InspectorTargetProxyWin.cpp
 | |
| +    UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
 | |
|      UIProcess/win/PageClientImpl.cpp
 | |
|      UIProcess/win/WebContextMenuProxyWin.cpp
 | |
| +    UIProcess/win/WebPageInspectorEmulationAgentWin.cpp
 | |
| +    UIProcess/win/WebPageInspectorInputAgentWin.cpp
 | |
|      UIProcess/win/WebPageProxyWin.cpp
 | |
|      UIProcess/win/WebPopupMenuProxyWin.cpp
 | |
|      UIProcess/win/WebProcessPoolWin.cpp
 | |
| diff --git a/Source/WebKit/Shared/API/c/wpe/WebKit.h b/Source/WebKit/Shared/API/c/wpe/WebKit.h
 | |
| index 898e30b370db8176e886fbbde0cd960e38a64818..74945e06fac0eb14936578de6a599a123364a63a 100644
 | |
| --- a/Source/WebKit/Shared/API/c/wpe/WebKit.h
 | |
| +++ b/Source/WebKit/Shared/API/c/wpe/WebKit.h
 | |
| @@ -78,6 +78,7 @@
 | |
|  // From Source/WebKit/UIProcess/API/C
 | |
|  #include <WebKit/WKBackForwardListItemRef.h>
 | |
|  #include <WebKit/WKBackForwardListRef.h>
 | |
| +#include <WebKit/WKBrowserInspector.h>
 | |
|  #include <WebKit/WKContext.h>
 | |
|  #include <WebKit/WKContextConfigurationRef.h>
 | |
|  #include <WebKit/WKCredential.h>
 | |
| diff --git a/Source/WebKit/Shared/NativeWebKeyboardEvent.h b/Source/WebKit/Shared/NativeWebKeyboardEvent.h
 | |
| index 24d54e8c21f7a3eeeeb2ba3ddd4ebc6ae42bf321..f39e2369abfab72ae1df5e1706c3188974c29411 100644
 | |
| --- a/Source/WebKit/Shared/NativeWebKeyboardEvent.h
 | |
| +++ b/Source/WebKit/Shared/NativeWebKeyboardEvent.h
 | |
| @@ -34,6 +34,7 @@
 | |
|  #if USE(APPKIT)
 | |
|  #include <wtf/RetainPtr.h>
 | |
|  OBJC_CLASS NSView;
 | |
| +OBJC_CLASS NSEvent;
 | |
|  
 | |
|  namespace WebCore {
 | |
|  struct CompositionUnderline;
 | |
| @@ -71,18 +72,34 @@ public:
 | |
|  #if USE(APPKIT)
 | |
|      // FIXME: Share iOS's HandledByInputMethod enum here instead of passing a boolean.
 | |
|      NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>&);
 | |
| +    NativeWebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp, Vector<WebCore::KeypressCommand>&& commands)
 | |
| +        : WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp, WTFMove(commands))
 | |
| +    {
 | |
| +    }
 | |
|  #elif PLATFORM(GTK)
 | |
|      NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
 | |
|      enum class HandledByInputMethod : bool { No, Yes };
 | |
|      NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands);
 | |
| +    NativeWebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp, Vector<String>&& commands)
 | |
| +        : WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp, WTFMove(commands))
 | |
| +    {
 | |
| +    }
 | |
|  #elif PLATFORM(IOS_FAMILY)
 | |
|      enum class HandledByInputMethod : bool { No, Yes };
 | |
|      NativeWebKeyboardEvent(::WebEvent *, HandledByInputMethod);
 | |
|  #elif USE(LIBWPE)
 | |
|      enum class HandledByInputMethod : bool { No, Yes };
 | |
|      NativeWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, HandledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&);
 | |
| +    NativeWebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| +        : WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp)
 | |
| +    {
 | |
| +    }
 | |
|  #elif PLATFORM(WIN)
 | |
|      NativeWebKeyboardEvent(HWND, UINT message, WPARAM, LPARAM, Vector<MSG>&& pendingCharEvents);
 | |
| +    NativeWebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| +        : WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp)
 | |
| +    {
 | |
| +    }
 | |
|  #endif
 | |
|  
 | |
|  #if USE(APPKIT)
 | |
| diff --git a/Source/WebKit/Shared/NativeWebMouseEvent.h b/Source/WebKit/Shared/NativeWebMouseEvent.h
 | |
| index 35fdfbb3097a8174ecc536b181d92c7cd9149581..a98424581b326c780375968b0db5e0082a96de23 100644
 | |
| --- a/Source/WebKit/Shared/NativeWebMouseEvent.h
 | |
| +++ b/Source/WebKit/Shared/NativeWebMouseEvent.h
 | |
| @@ -76,6 +76,11 @@ public:
 | |
|      NativeWebMouseEvent(HWND, UINT message, WPARAM, LPARAM, bool);
 | |
|  #endif
 | |
|  
 | |
| +#if PLATFORM(GTK) || USE(LIBWPE) || PLATFORM(WIN)
 | |
| +    NativeWebMouseEvent(Type type, Button button, unsigned short buttons, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| +       : WebMouseEvent(type, button, buttons, position, globalPosition, deltaX, deltaY, deltaZ, clickCount, modifiers, timestamp) { }
 | |
| +#endif
 | |
| +
 | |
|  #if USE(APPKIT)
 | |
|      NSEvent* nativeEvent() const { return m_nativeEvent.get(); }
 | |
|  #elif PLATFORM(GTK)
 | |
| diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
 | |
| index 9d32dbad703e70428775dc99a069d8e5de5060f5..fe8b25b0acbc3c2efa0f4812018c08f2f2bd420b 100644
 | |
| --- a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
 | |
| +++ b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
 | |
| @@ -1495,6 +1495,9 @@ void ArgumentCoder<WindowFeatures>::encode(Encoder& encoder, const WindowFeature
 | |
|      encoder << windowFeatures.resizable;
 | |
|      encoder << windowFeatures.fullscreen;
 | |
|      encoder << windowFeatures.dialog;
 | |
| +    encoder << windowFeatures.noopener;
 | |
| +    encoder << windowFeatures.noreferrer;
 | |
| +    encoder << windowFeatures.additionalFeatures;
 | |
|  }
 | |
|  
 | |
|  bool ArgumentCoder<WindowFeatures>::decode(Decoder& decoder, WindowFeatures& windowFeatures)
 | |
| @@ -1523,6 +1526,12 @@ bool ArgumentCoder<WindowFeatures>::decode(Decoder& decoder, WindowFeatures& win
 | |
|          return false;
 | |
|      if (!decoder.decode(windowFeatures.dialog))
 | |
|          return false;
 | |
| +    if (!decoder.decode(windowFeatures.noopener))
 | |
| +        return false;
 | |
| +    if (!decoder.decode(windowFeatures.noreferrer))
 | |
| +        return false;
 | |
| +    if (!decoder.decode(windowFeatures.additionalFeatures))
 | |
| +        return false;
 | |
|      return true;
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebKit/Shared/WebEvent.h b/Source/WebKit/Shared/WebEvent.h
 | |
| index c6f7d29cae4ae37f000ac34f6d315d9d3acce4d9..a4a8f20bfb7aeec45b71d5751671528e328394db 100644
 | |
| --- a/Source/WebKit/Shared/WebEvent.h
 | |
| +++ b/Source/WebKit/Shared/WebEvent.h
 | |
| @@ -37,6 +37,7 @@
 | |
|  #include <WebCore/IntSize.h>
 | |
|  #include <WebCore/KeypressCommand.h>
 | |
|  #include <wtf/OptionSet.h>
 | |
| +#include <wtf/RefCounted.h>
 | |
|  #include <wtf/WallTime.h>
 | |
|  #include <wtf/text/WTFString.h>
 | |
|  
 | |
| @@ -252,14 +253,18 @@ public:
 | |
|  
 | |
|  #if USE(APPKIT)
 | |
|      WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
 | |
| +    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp, Vector<WebCore::KeypressCommand>&& commands);
 | |
|  #elif PLATFORM(GTK)
 | |
|      WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
 | |
| +    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp, Vector<String>&& commands);
 | |
|  #elif PLATFORM(IOS_FAMILY)
 | |
|      WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
 | |
|  #elif USE(LIBWPE)
 | |
|      WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
 | |
| +    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
 | |
|  #else
 | |
|      WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
 | |
| +    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
 | |
|  #endif
 | |
|  
 | |
|      const String& text() const { return m_text; }
 | |
| diff --git a/Source/WebKit/Shared/WebKeyboardEvent.cpp b/Source/WebKit/Shared/WebKeyboardEvent.cpp
 | |
| index cccb560418f32fad40587ac083b95f398eb1399d..f6b0aee44e5f12055dd14ad0636d780d2d4ece5d 100644
 | |
| --- a/Source/WebKit/Shared/WebKeyboardEvent.cpp
 | |
| +++ b/Source/WebKit/Shared/WebKeyboardEvent.cpp
 | |
| @@ -35,6 +35,7 @@ WebKeyboardEvent::WebKeyboardEvent()
 | |
|  {
 | |
|  }
 | |
|  
 | |
| +
 | |
|  #if USE(APPKIT)
 | |
|  
 | |
|  WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| @@ -56,6 +57,24 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
 | |
|      ASSERT(isKeyboardEventType(type));
 | |
|  }
 | |
|  
 | |
| +WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp, Vector<WebCore::KeypressCommand>&& commands)
 | |
| +    : WebEvent(type, modifiers, timestamp)
 | |
| +    , m_text(text)
 | |
| +    , m_unmodifiedText(text)
 | |
| +    , m_key(key)
 | |
| +    , m_code(code)
 | |
| +    , m_keyIdentifier(keyIdentifier)
 | |
| +    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
 | |
| +    , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
 | |
| +    , m_macCharCode(0)
 | |
| +    , m_commands(WTFMove(commands))
 | |
| +    , m_isAutoRepeat(isAutoRepeat)
 | |
| +    , m_isKeypad(isKeypad)
 | |
| +    , m_isSystemKey(isSystemKey)
 | |
| +{
 | |
| +    ASSERT(isKeyboardEventType(type));
 | |
| +}
 | |
| +
 | |
|  #elif PLATFORM(GTK)
 | |
|  
 | |
|  WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| @@ -79,6 +98,24 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
 | |
|      ASSERT(isKeyboardEventType(type));
 | |
|  }
 | |
|  
 | |
| +WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp, Vector<String>&& commands)
 | |
| +    : WebEvent(type, modifiers, timestamp)
 | |
| +    , m_text(text)
 | |
| +    , m_unmodifiedText(text)
 | |
| +    , m_key(key)
 | |
| +    , m_code(code)
 | |
| +    , m_keyIdentifier(keyIdentifier)
 | |
| +    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
 | |
| +    , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
 | |
| +    , m_macCharCode(0)
 | |
| +    , m_commands(WTFMove(commands))
 | |
| +    , m_isAutoRepeat(isAutoRepeat)
 | |
| +    , m_isKeypad(isKeypad)
 | |
| +    , m_isSystemKey(isSystemKey)
 | |
| +{
 | |
| +    ASSERT(isKeyboardEventType(type));
 | |
| +}
 | |
| +
 | |
|  #elif PLATFORM(IOS_FAMILY)
 | |
|  
 | |
|  WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| @@ -144,6 +181,27 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
 | |
|  
 | |
|  #endif
 | |
|  
 | |
| +#if PLATFORM(WIN) || USE(LIBWPE)
 | |
| +
 | |
| +WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
 | |
| +    : WebEvent(type, modifiers, timestamp)
 | |
| +    , m_text(text)
 | |
| +    , m_unmodifiedText(text)
 | |
| +    , m_key(key)
 | |
| +    , m_code(code)
 | |
| +    , m_keyIdentifier(keyIdentifier)
 | |
| +    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
 | |
| +    , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
 | |
| +    , m_macCharCode(0)
 | |
| +    , m_isAutoRepeat(isAutoRepeat)
 | |
| +    , m_isKeypad(isKeypad)
 | |
| +    , m_isSystemKey(isSystemKey)
 | |
| +{
 | |
| +    ASSERT(isKeyboardEventType(type));
 | |
| +}
 | |
| +
 | |
| +#endif
 | |
| +
 | |
|  WebKeyboardEvent::~WebKeyboardEvent()
 | |
|  {
 | |
|  }
 | |
| diff --git a/Source/WebKit/Shared/WebPageCreationParameters.cpp b/Source/WebKit/Shared/WebPageCreationParameters.cpp
 | |
| index 8c80de2f32ec46809ffd0e3007f774bfa4851fe4..033a6530a75044ed5d8ecb2678b88031e865af31 100644
 | |
| --- a/Source/WebKit/Shared/WebPageCreationParameters.cpp
 | |
| +++ b/Source/WebKit/Shared/WebPageCreationParameters.cpp
 | |
| @@ -140,6 +140,8 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
 | |
|      encoder << crossOriginAccessControlCheckEnabled;
 | |
|      encoder << processDisplayName;
 | |
|  
 | |
| +    encoder << shouldPauseInInspectorWhenShown;
 | |
| +
 | |
|      encoder << shouldCaptureAudioInUIProcess;
 | |
|      encoder << shouldCaptureAudioInGPUProcess;
 | |
|      encoder << shouldCaptureVideoInUIProcess;
 | |
| @@ -452,7 +454,10 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod
 | |
|      if (!processDisplayName)
 | |
|          return WTF::nullopt;
 | |
|      parameters.processDisplayName = WTFMove(*processDisplayName);
 | |
| -    
 | |
| +
 | |
| +    if (!decoder.decode(parameters.shouldPauseInInspectorWhenShown))
 | |
| +        return WTF::nullopt;
 | |
| +
 | |
|      if (!decoder.decode(parameters.shouldCaptureAudioInUIProcess))
 | |
|          return WTF::nullopt;
 | |
|  
 | |
| @@ -473,10 +478,10 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod
 | |
|  
 | |
|      if (!decoder.decode(parameters.needsInAppBrowserPrivacyQuirks))
 | |
|          return WTF::nullopt;
 | |
| -    
 | |
| +
 | |
|      if (!decoder.decode(parameters.limitsNavigationsToAppBoundDomains))
 | |
|          return WTF::nullopt;
 | |
| -    
 | |
| +
 | |
|  #if PLATFORM(GTK)
 | |
|      if (!decoder.decode(parameters.themeName))
 | |
|          return WTF::nullopt;
 | |
| diff --git a/Source/WebKit/Shared/WebPageCreationParameters.h b/Source/WebKit/Shared/WebPageCreationParameters.h
 | |
| index cff31355c1a2618aa8372c527b81469bc46e41dd..9067b4e0eb6be67407472e56d7cb11c141ff6ca3 100644
 | |
| --- a/Source/WebKit/Shared/WebPageCreationParameters.h
 | |
| +++ b/Source/WebKit/Shared/WebPageCreationParameters.h
 | |
| @@ -221,6 +221,8 @@ struct WebPageCreationParameters {
 | |
|      bool needsInAppBrowserPrivacyQuirks { false };
 | |
|      bool limitsNavigationsToAppBoundDomains { false };
 | |
|  
 | |
| +    bool shouldPauseInInspectorWhenShown { false };
 | |
| +
 | |
|  #if PLATFORM(GTK)
 | |
|      String themeName;
 | |
|  #endif
 | |
| diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml
 | |
| index 30a59ec337439cd439869e80ae92469024795a87..4ad6d371f1e1f04fde3fa9995e87232f26067792 100644
 | |
| --- a/Source/WebKit/Shared/WebPreferences.yaml
 | |
| +++ b/Source/WebKit/Shared/WebPreferences.yaml
 | |
| @@ -317,7 +317,7 @@ MediaControlsScaleWithPageZoom:
 | |
|  
 | |
|  InspectorStartsAttached:
 | |
|    type: bool
 | |
| -  defaultValue: true
 | |
| +  defaultValue: false
 | |
|    webcoreBinding: none
 | |
|  
 | |
|  ShowsToolTipOverTruncatedText:
 | |
| diff --git a/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp b/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp
 | |
| index 8c0df4282fd58ac94daa2d0d93144acd3e57eff7..224a76f44bbbb59c47b9cf4f70f0bd3a3f107882 100644
 | |
| --- a/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp
 | |
| +++ b/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp
 | |
| @@ -40,7 +40,7 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& te
 | |
|  }
 | |
|  
 | |
|  NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
 | |
| -    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Optional<Vector<WebCore::CompositionUnderline>>(event.preeditUnderlines()), Optional<EditingRange>(event.preeditSelectionRange()), Vector<String>(event.commands())))
 | |
| +    : WebKeyboardEvent(event)
 | |
|      , m_nativeEvent(gdk_event_copy(event.nativeEvent()))
 | |
|  {
 | |
|  }
 | |
| diff --git a/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp b/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp
 | |
| index 7acd94bec601ac985ac4908f3167403ca8a422db..75af4d9bc4f53fb73cc2da15090ec865d9ab1888 100644
 | |
| --- a/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp
 | |
| +++ b/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp
 | |
| @@ -49,7 +49,7 @@ NativeWebMouseEvent::NativeWebMouseEvent(const WebCore::IntPoint& position)
 | |
|  }
 | |
|  
 | |
|  NativeWebMouseEvent::NativeWebMouseEvent(const NativeWebMouseEvent& event)
 | |
| -    : WebMouseEvent(WebEventFactory::createWebMouseEvent(event.nativeEvent(), event.position(), event.globalPosition(), event.clickCount(), WebCore::IntPoint(event.deltaX(), event.deltaY())))
 | |
| +    : WebMouseEvent(event)
 | |
|      , m_nativeEvent(event.nativeEvent() ? gdk_event_copy(const_cast<GdkEvent*>(event.nativeEvent())) : nullptr)
 | |
|  {
 | |
|  }
 | |
| diff --git a/Source/WebKit/Shared/ios/WebPlatformTouchPointIOS.cpp b/Source/WebKit/Shared/ios/WebPlatformTouchPointIOS.cpp
 | |
| index 7b5eb372880d8662544334cd4697276d543de45b..ba06ecbb2cf5088a4c8c0824b50cb7797605dc57 100644
 | |
| --- a/Source/WebKit/Shared/ios/WebPlatformTouchPointIOS.cpp
 | |
| +++ b/Source/WebKit/Shared/ios/WebPlatformTouchPointIOS.cpp
 | |
| @@ -26,7 +26,7 @@
 | |
|  #include "config.h"
 | |
|  #include "WebEvent.h"
 | |
|  
 | |
| -#if ENABLE(TOUCH_EVENTS)
 | |
| +#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
 | |
|  
 | |
|  #include "WebCoreArgumentCoders.h"
 | |
|  
 | |
| @@ -79,4 +79,4 @@ Optional<WebPlatformTouchPoint> WebPlatformTouchPoint::decode(IPC::Decoder& deco
 | |
|  
 | |
|  } // namespace WebKit
 | |
|  
 | |
| -#endif // ENABLE(TOUCH_EVENTS)
 | |
| +#endif // ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
 | |
| diff --git a/Source/WebKit/Shared/ios/WebTouchEventIOS.cpp b/Source/WebKit/Shared/ios/WebTouchEventIOS.cpp
 | |
| index 45a56eb3b0fda13c3b78d57594a0092e4e1866f6..5e29e15813be6abe82790e6a98d3947e7a6fae44 100644
 | |
| --- a/Source/WebKit/Shared/ios/WebTouchEventIOS.cpp
 | |
| +++ b/Source/WebKit/Shared/ios/WebTouchEventIOS.cpp
 | |
| @@ -26,7 +26,7 @@
 | |
|  #include "config.h"
 | |
|  #include "WebEvent.h"
 | |
|  
 | |
| -#if ENABLE(TOUCH_EVENTS)
 | |
| +#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
 | |
|  
 | |
|  #include "ArgumentCoders.h"
 | |
|  #include "WebCoreArgumentCoders.h"
 | |
| @@ -71,4 +71,4 @@ bool WebTouchEvent::decode(IPC::Decoder& decoder, WebTouchEvent& result)
 | |
|  
 | |
|  } // namespace WebKit
 | |
|  
 | |
| -#endif // ENABLE(TOUCH_EVENTS)
 | |
| +#endif // ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
 | |
| diff --git a/Source/WebKit/Shared/win/WebEventFactory.cpp b/Source/WebKit/Shared/win/WebEventFactory.cpp
 | |
| index 88d53d236cd6d62735f03678a04ca9c198dddacb..b8f8efc57ab00dc5725660c5a8ad56a3e6384de5 100644
 | |
| --- a/Source/WebKit/Shared/win/WebEventFactory.cpp
 | |
| +++ b/Source/WebKit/Shared/win/WebEventFactory.cpp
 | |
| @@ -473,7 +473,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(HWND hwnd, UINT message
 | |
|  }
 | |
|  
 | |
|  #if ENABLE(TOUCH_EVENTS)
 | |
| -WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector<WebPlatformTouchPoint>&& touchPoints)
 | |
| +WebTouchEvent WebEventFactory::createWebTouchEvent()
 | |
|  {
 | |
|      return WebTouchEvent();
 | |
|  }
 | |
| diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt
 | |
| index 89434b54cde8a18a87c755238fffb0c0c2a372c8..bf86020632afb1dbffd812352f8bda4e0a5ed54b 100644
 | |
| --- a/Source/WebKit/Sources.txt
 | |
| +++ b/Source/WebKit/Sources.txt
 | |
| @@ -275,16 +275,21 @@ Shared/WebsiteData/WebsiteData.cpp
 | |
|  
 | |
|  UIProcess/AuxiliaryProcessProxy.cpp
 | |
|  UIProcess/BackgroundProcessResponsivenessTimer.cpp
 | |
| +UIProcess/BrowserInspectorController.cpp
 | |
| +UIProcess/BrowserInspectorPipe.cpp
 | |
|  UIProcess/DeviceIdHashSaltStorage.cpp
 | |
|  UIProcess/DrawingAreaProxy.cpp
 | |
|  UIProcess/FrameLoadState.cpp
 | |
|  UIProcess/GeolocationPermissionRequestManagerProxy.cpp
 | |
|  UIProcess/GeolocationPermissionRequestProxy.cpp
 | |
| +UIProcess/InspectorDialogAgent.cpp
 | |
| +UIProcess/InspectorPlaywrightAgent.cpp
 | |
|  UIProcess/LegacyGlobalSettings.cpp
 | |
|  UIProcess/PageLoadState.cpp
 | |
|  UIProcess/ProcessAssertion.cpp
 | |
|  UIProcess/ProcessThrottler.cpp
 | |
|  UIProcess/ProvisionalPageProxy.cpp
 | |
| +UIProcess/RemoteInspectorPipe.cpp
 | |
|  UIProcess/ResponsivenessTimer.cpp
 | |
|  UIProcess/SuspendedPageProxy.cpp
 | |
|  UIProcess/SystemPreviewController.cpp
 | |
| @@ -321,6 +326,8 @@ UIProcess/WebOpenPanelResultListenerProxy.cpp
 | |
|  UIProcess/WebPageDiagnosticLoggingClient.cpp
 | |
|  UIProcess/WebPageGroup.cpp
 | |
|  UIProcess/WebPageInjectedBundleClient.cpp
 | |
| +UIProcess/WebPageInspectorEmulationAgent.cpp
 | |
| +UIProcess/WebPageInspectorInputAgent.cpp
 | |
|  UIProcess/WebPageProxy.cpp
 | |
|  UIProcess/WebPasteboardProxy.cpp
 | |
|  UIProcess/WebPreferences.cpp
 | |
| @@ -440,6 +447,7 @@ UIProcess/Inspector/WebPageDebuggable.cpp
 | |
|  UIProcess/Inspector/WebPageInspectorController.cpp
 | |
|  
 | |
|  UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp
 | |
| +UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp
 | |
|  
 | |
|  UIProcess/Media/AudioSessionRoutingArbitratorProxy.cpp
 | |
|  UIProcess/Media/MediaUsageManager.cpp
 | |
| diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt
 | |
| index b72ac530c1d19d4803dd548186a4fbfbff899dd0..298205de7664a1c3cd4d330d7154999d49f87f06 100644
 | |
| --- a/Source/WebKit/SourcesCocoa.txt
 | |
| +++ b/Source/WebKit/SourcesCocoa.txt
 | |
| @@ -249,6 +249,7 @@ UIProcess/API/Cocoa/_WKApplicationManifest.mm
 | |
|  UIProcess/API/Cocoa/_WKAttachment.mm
 | |
|  UIProcess/API/Cocoa/_WKAutomationSession.mm
 | |
|  UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm
 | |
| +UIProcess/API/Cocoa/_WKBrowserInspector.mm
 | |
|  UIProcess/API/Cocoa/_WKContentRuleListAction.mm
 | |
|  UIProcess/API/Cocoa/_WKContextMenuElementInfo.mm
 | |
|  UIProcess/API/Cocoa/_WKCustomHeaderFields.mm @no-unify
 | |
| @@ -409,6 +410,7 @@ UIProcess/Inspector/Cocoa/InspectorDelegate.mm
 | |
|  UIProcess/Inspector/ios/WKInspectorHighlightView.mm
 | |
|  UIProcess/Inspector/ios/WKInspectorNodeSearchGestureRecognizer.mm
 | |
|  
 | |
| +UIProcess/Inspector/mac/InspectorScreencastAgentMac.mm
 | |
|  UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm
 | |
|  UIProcess/Inspector/mac/WebInspectorProxyMac.mm
 | |
|  UIProcess/Inspector/mac/WKInspectorViewController.mm
 | |
| diff --git a/Source/WebKit/SourcesGTK.txt b/Source/WebKit/SourcesGTK.txt
 | |
| index 76f1e08ca934a654edc48e199ce3eb120604c28c..4c2d98de146282d0be953bb2c1ddee856f4c60b7 100644
 | |
| --- a/Source/WebKit/SourcesGTK.txt
 | |
| +++ b/Source/WebKit/SourcesGTK.txt
 | |
| @@ -136,6 +136,7 @@ UIProcess/API/glib/WebKitAuthenticationRequest.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitAutomationSession.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitBackForwardList.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitBackForwardListItem.cpp @no-unify
 | |
| +UIProcess/API/glib/WebKitBrowserInspector.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitContextMenuClient.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitCookieManager.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitCredential.cpp @no-unify
 | |
| @@ -247,6 +248,7 @@ UIProcess/WebsiteData/unix/WebsiteDataStoreUnix.cpp
 | |
|  
 | |
|  UIProcess/cairo/BackingStoreCairo.cpp @no-unify
 | |
|  
 | |
| +UIProcess/glib/InspectorPlaywrightAgentClientGLib.cpp
 | |
|  UIProcess/glib/WebProcessPoolGLib.cpp
 | |
|  UIProcess/glib/WebProcessProxyGLib.cpp
 | |
|  UIProcess/glib/WebsiteDataStoreGLib.cpp @no-unify
 | |
| @@ -262,6 +264,7 @@ UIProcess/gtk/ClipboardGtk3.cpp @no-unify
 | |
|  UIProcess/gtk/ClipboardGtk4.cpp @no-unify
 | |
|  UIProcess/gtk/GestureController.cpp
 | |
|  UIProcess/gtk/HardwareAccelerationManager.cpp
 | |
| +UIProcess/gtk/InspectorTargetProxyGtk.cpp
 | |
|  UIProcess/gtk/KeyBindingTranslator.cpp
 | |
|  UIProcess/gtk/PointerLockManager.cpp @no-unify
 | |
|  UIProcess/gtk/PointerLockManagerWayland.cpp @no-unify
 | |
| @@ -272,6 +275,8 @@ UIProcess/gtk/WaylandCompositor.cpp @no-unify
 | |
|  UIProcess/gtk/WebColorPickerGtk.cpp
 | |
|  UIProcess/gtk/WebContextMenuProxyGtk.cpp
 | |
|  UIProcess/gtk/WebDataListSuggestionsDropdownGtk.cpp
 | |
| +UIProcess/gtk/WebPageInspectorEmulationAgentGtk.cpp
 | |
| +UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp
 | |
|  UIProcess/gtk/WebPageProxyGtk.cpp @no-unify
 | |
|  UIProcess/gtk/WebPasteboardProxyGtk.cpp
 | |
|  UIProcess/gtk/WebPopupMenuProxyGtk.cpp
 | |
| diff --git a/Source/WebKit/SourcesWPE.txt b/Source/WebKit/SourcesWPE.txt
 | |
| index 8b934e81e74890eba674f5faaa6a5ade0f605c11..4f5bcc18e576a656709dfcfccd75d09e00f8e80c 100644
 | |
| --- a/Source/WebKit/SourcesWPE.txt
 | |
| +++ b/Source/WebKit/SourcesWPE.txt
 | |
| @@ -125,6 +125,7 @@ UIProcess/API/glib/WebKitAuthenticationRequest.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitAutomationSession.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitBackForwardList.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitBackForwardListItem.cpp @no-unify
 | |
| +UIProcess/API/glib/WebKitBrowserInspector.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitContextMenuClient.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitCookieManager.cpp @no-unify
 | |
|  UIProcess/API/glib/WebKitCredential.cpp @no-unify
 | |
| @@ -200,7 +201,7 @@ UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp
 | |
|  UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp
 | |
|  
 | |
|  UIProcess/geoclue/GeoclueGeolocationProvider.cpp
 | |
| -
 | |
| +UIProcess/glib/InspectorPlaywrightAgentClientGLib.cpp
 | |
|  UIProcess/glib/WebProcessPoolGLib.cpp
 | |
|  UIProcess/glib/WebProcessProxyGLib.cpp
 | |
|  UIProcess/glib/WebsiteDataStoreGLib.cpp @no-unify
 | |
| @@ -225,6 +226,10 @@ UIProcess/linux/MemoryPressureMonitor.cpp
 | |
|  UIProcess/soup/WebCookieManagerProxySoup.cpp
 | |
|  UIProcess/soup/WebProcessPoolSoup.cpp
 | |
|  
 | |
| +UIProcess/wpe/InspectorTargetProxyWPE.cpp
 | |
| +UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cpp
 | |
| +UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp
 | |
| +
 | |
|  UIProcess/wpe/WebPageProxyWPE.cpp
 | |
|  
 | |
|  WebProcess/GPU/media/gstreamer/VideoLayerRemoteGStreamer.cpp
 | |
| diff --git a/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp b/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
 | |
| index a65f066f9813e8f54673c8f3348853c17a6df60d..8a58eebddd0d147246b478ba24b7db17da0621b4 100644
 | |
| --- a/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
 | |
| @@ -53,6 +53,9 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::copy()
 | |
|      copy->m_ignoreSynchronousMessagingTimeoutsForTesting = this->m_ignoreSynchronousMessagingTimeoutsForTesting;
 | |
|      copy->m_attrStyleEnabled = this->m_attrStyleEnabled;
 | |
|      copy->m_overrideLanguages = this->m_overrideLanguages;
 | |
| +#if PLATFORM(MAC)
 | |
| +    copy->m_forceOverlayScrollbars = this->m_forceOverlayScrollbars;
 | |
| +#endif
 | |
|      copy->m_alwaysRunsAtBackgroundPriority = this->m_alwaysRunsAtBackgroundPriority;
 | |
|      copy->m_shouldTakeUIBackgroundAssertion = this->m_shouldTakeUIBackgroundAssertion;
 | |
|      copy->m_shouldCaptureDisplayInUIProcess = this->m_shouldCaptureDisplayInUIProcess;
 | |
| diff --git a/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h b/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
 | |
| index ecbf2455a1e102b596244f149e86ef3ffc68b7d2..3ca7d1a0af5e351b5b419bd75243f3f6bf558413 100644
 | |
| --- a/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
 | |
| +++ b/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
 | |
| @@ -98,6 +98,11 @@ public:
 | |
|      const Vector<WTF::String>& overrideLanguages() const { return m_overrideLanguages; }
 | |
|      void setOverrideLanguages(Vector<WTF::String>&& languages) { m_overrideLanguages = WTFMove(languages); }
 | |
|      
 | |
| +#if PLATFORM(MAC)
 | |
| +    bool forceOverlayScrollbars() const { return m_forceOverlayScrollbars; }
 | |
| +    void setForceOverlayScrollbars(bool forceOverlayScrollbars) { m_forceOverlayScrollbars = forceOverlayScrollbars; }
 | |
| +#endif
 | |
| +
 | |
|      bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
 | |
|      void setAlwaysRunsAtBackgroundPriority(bool alwaysRunsAtBackgroundPriority) { m_alwaysRunsAtBackgroundPriority = alwaysRunsAtBackgroundPriority; }
 | |
|  
 | |
| @@ -146,6 +151,9 @@ private:
 | |
|      bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
 | |
|      bool m_attrStyleEnabled { false };
 | |
|      Vector<WTF::String> m_overrideLanguages;
 | |
| +#if PLATFORM(MAC)
 | |
| +    bool m_forceOverlayScrollbars { false };
 | |
| +#endif
 | |
|      bool m_alwaysRunsAtBackgroundPriority { false };
 | |
|      bool m_shouldTakeUIBackgroundAssertion { true };
 | |
|      bool m_shouldCaptureDisplayInUIProcess { DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS };
 | |
| diff --git a/Source/WebKit/UIProcess/API/APIUIClient.h b/Source/WebKit/UIProcess/API/APIUIClient.h
 | |
| index acf7d0404736335521d1b4aa9cf408a154315b83..c14d1bd945844df507ed91c17769b08a955282d0 100644
 | |
| --- a/Source/WebKit/UIProcess/API/APIUIClient.h
 | |
| +++ b/Source/WebKit/UIProcess/API/APIUIClient.h
 | |
| @@ -97,6 +97,7 @@ public:
 | |
|      virtual void runJavaScriptAlert(WebKit::WebPageProxy&, const WTF::String&, WebKit::WebFrameProxy*, WebKit::FrameInfoData&&, Function<void()>&& completionHandler) { completionHandler(); }
 | |
|      virtual void runJavaScriptConfirm(WebKit::WebPageProxy&, const WTF::String&, WebKit::WebFrameProxy*, WebKit::FrameInfoData&&, Function<void(bool)>&& completionHandler) { completionHandler(false); }
 | |
|      virtual void runJavaScriptPrompt(WebKit::WebPageProxy&, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, WebKit::FrameInfoData&&, Function<void(const WTF::String&)>&& completionHandler) { completionHandler(WTF::String()); }
 | |
| +    virtual void handleJavaScriptDialog(WebKit::WebPageProxy&, bool, const WTF::String&) { }
 | |
|  
 | |
|      virtual void setStatusText(WebKit::WebPageProxy*, const WTF::String&) { }
 | |
|      virtual void mouseDidMoveOverElement(WebKit::WebPageProxy&, const WebKit::WebHitTestResultData&, OptionSet<WebKit::WebEvent::Modifier>, Object*) { }
 | |
| diff --git a/Source/WebKit/UIProcess/API/C/WKContext.cpp b/Source/WebKit/UIProcess/API/C/WKContext.cpp
 | |
| index 6d278423685e030a7357ed3772504edcec94caf6..2551fc578be731511dfd4b1ac668b49c20763fec 100644
 | |
| --- a/Source/WebKit/UIProcess/API/C/WKContext.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/C/WKContext.cpp
 | |
| @@ -436,6 +436,11 @@ WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef)
 | |
|      return WKWebsiteDataStoreGetDefaultDataStore();
 | |
|  }
 | |
|  
 | |
| +void WKContextSetPrimaryDataStore(WKContextRef contextRef, WKWebsiteDataStoreRef dataStoreRef)
 | |
| +{
 | |
| +    WebKit::toImpl(contextRef)->setPrimaryDataStore(*WebKit::toImpl(dataStoreRef));
 | |
| +}
 | |
| +
 | |
|  WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context)
 | |
|  {
 | |
|      return reinterpret_cast<WKApplicationCacheManagerRef>(WKWebsiteDataStoreGetDefaultDataStore());
 | |
| diff --git a/Source/WebKit/UIProcess/API/C/WKContext.h b/Source/WebKit/UIProcess/API/C/WKContext.h
 | |
| index 08f54ff5057f8d04e26adfe2c0e3a472647935e7..8f3ae0f0346514cec926ea7babff40c22fd4097a 100644
 | |
| --- a/Source/WebKit/UIProcess/API/C/WKContext.h
 | |
| +++ b/Source/WebKit/UIProcess/API/C/WKContext.h
 | |
| @@ -168,6 +168,7 @@ WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef int
 | |
|  WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
 | |
|  
 | |
|  WK_EXPORT WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef context) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKWebsiteDataStoreGetDefaultDataStore);
 | |
| +WK_EXPORT void WKContextSetPrimaryDataStore(WKContextRef context, WKWebsiteDataStoreRef dataStore);
 | |
|  
 | |
|  WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKWebsiteDataStoreGetDefaultDataStore);
 | |
|  WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context) WK_C_API_DEPRECATED;
 | |
| diff --git a/Source/WebKit/UIProcess/API/C/WKInspector.cpp b/Source/WebKit/UIProcess/API/C/WKInspector.cpp
 | |
| index 39327c5c9230591e4f52e4574c416e36687788f0..269dc87a6ab35481d2b45bea86fff893a9bddfb2 100644
 | |
| --- a/Source/WebKit/UIProcess/API/C/WKInspector.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/C/WKInspector.cpp
 | |
| @@ -28,6 +28,11 @@
 | |
|  
 | |
|  #if !PLATFORM(IOS_FAMILY)
 | |
|  
 | |
| +#if PLATFORM(WIN)
 | |
| +#include "BrowserInspectorPipe.h"
 | |
| +#include "InspectorPlaywrightAgentClientWin.h"
 | |
| +#endif
 | |
| +
 | |
|  #include "WKAPICast.h"
 | |
|  #include "WebInspectorProxy.h"
 | |
|  #include "WebPageProxy.h"
 | |
| @@ -130,4 +135,11 @@ void WKInspectorToggleElementSelection(WKInspectorRef inspectorRef)
 | |
|      toImpl(inspectorRef)->toggleElementSelection();
 | |
|  }
 | |
|  
 | |
| +void WKInspectorInitializeRemoteInspectorPipe(CreatePageCallback createPage, QuitCallback quit)
 | |
| +{
 | |
| +#if PLATFORM(WIN)
 | |
| +    initializeBrowserInspectorPipe(makeUnique<InspectorPlaywrightAgentClientWin>(createPage, quit));
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
|  #endif // !PLATFORM(IOS_FAMILY)
 | |
| diff --git a/Source/WebKit/UIProcess/API/C/WKInspector.h b/Source/WebKit/UIProcess/API/C/WKInspector.h
 | |
| index 026121d114c5fcad84c1396be8d692625beaa3bd..1f707641766b51e3bddcdde0c49ee8cfcd83db0b 100644
 | |
| --- a/Source/WebKit/UIProcess/API/C/WKInspector.h
 | |
| +++ b/Source/WebKit/UIProcess/API/C/WKInspector.h
 | |
| @@ -66,6 +66,9 @@ WK_EXPORT void WKInspectorTogglePageProfiling(WKInspectorRef inspector);
 | |
|  WK_EXPORT bool WKInspectorIsElementSelectionActive(WKInspectorRef inspector);
 | |
|  WK_EXPORT void WKInspectorToggleElementSelection(WKInspectorRef inspector);
 | |
|  
 | |
| +typedef WKPageRef (*CreatePageCallback)(WKPageConfigurationRef configuration);
 | |
| +typedef void (*QuitCallback)();
 | |
| +WK_EXPORT void WKInspectorInitializeRemoteInspectorPipe(CreatePageCallback, QuitCallback);
 | |
|  #ifdef __cplusplus
 | |
|  }
 | |
|  #endif
 | |
| diff --git a/Source/WebKit/UIProcess/API/C/WKPage.cpp b/Source/WebKit/UIProcess/API/C/WKPage.cpp
 | |
| index ba2feecd2885acc45dd153ff502d49f7650f2c6d..9c4bb27242bfa23a91122d899200a1f1ce151fdb 100644
 | |
| --- a/Source/WebKit/UIProcess/API/C/WKPage.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/C/WKPage.cpp
 | |
| @@ -1689,6 +1689,13 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
 | |
|              completionHandler(String());
 | |
|          }
 | |
|  
 | |
| +        void handleJavaScriptDialog(WebPageProxy& page, bool accept, const String& value) final {
 | |
| +            if (m_client.handleJavaScriptDialog) {
 | |
| +                m_client.handleJavaScriptDialog(toAPI(&page), accept, toAPI(value.impl()), m_client.base.clientInfo);
 | |
| +                return;
 | |
| +            }
 | |
| +        }
 | |
| +
 | |
|          void setStatusText(WebPageProxy* page, const String& text) final
 | |
|          {
 | |
|              if (!m_client.setStatusText)
 | |
| @@ -1749,6 +1756,8 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
 | |
|          {
 | |
|              if (!m_client.didNotHandleKeyEvent)
 | |
|                  return;
 | |
| +            if (!event.nativeEvent())
 | |
| +                return;
 | |
|              m_client.didNotHandleKeyEvent(toAPI(page), event.nativeEvent(), m_client.base.clientInfo);
 | |
|          }
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/API/C/WKPageUIClient.h b/Source/WebKit/UIProcess/API/C/WKPageUIClient.h
 | |
| index 1d2febfba8833912f72216aa53c8c20090ee2d8b..1b2c3d84b15b12f1a187c0b7622db43cbbcd5996 100644
 | |
| --- a/Source/WebKit/UIProcess/API/C/WKPageUIClient.h
 | |
| +++ b/Source/WebKit/UIProcess/API/C/WKPageUIClient.h
 | |
| @@ -90,6 +90,7 @@ typedef void (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStri
 | |
|  typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptAlertResultListenerRef listener, const void *clientInfo);
 | |
|  typedef void (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptConfirmResultListenerRef listener, const void *clientInfo);
 | |
|  typedef void (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptPromptResultListenerRef listener, const void *clientInfo);
 | |
| +typedef void (*WKPageHandleJavaScriptDialogCallback)(WKPageRef page, bool accept, WKStringRef value, const void *clientInfo);
 | |
|  typedef void (*WKPageRequestStorageAccessConfirmCallback)(WKPageRef page, WKFrameRef frame, WKStringRef requestingDomain, WKStringRef currentDomain, WKPageRequestStorageAccessConfirmResultListenerRef listener, const void *clientInfo);
 | |
|  typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
 | |
|  typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
 | |
| @@ -1352,6 +1353,7 @@ typedef struct WKPageUIClientV14 {
 | |
|  
 | |
|      // Version 14.
 | |
|      WKPageRunWebAuthenticationPanelCallback                             runWebAuthenticationPanel;
 | |
| +    WKPageHandleJavaScriptDialogCallback                                handleJavaScriptDialog;
 | |
|  } WKPageUIClientV14;
 | |
|  
 | |
|  #ifdef __cplusplus
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
 | |
| index 569557047cf56dc88e674efed4b9b3a0988b8dda..4e885f9c5459d89217039f7800b49ec4ba5b3e59 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
 | |
| @@ -47,6 +47,7 @@
 | |
|  #import "_WKDownloadDelegate.h"
 | |
|  #import "_WKDownloadInternal.h"
 | |
|  #import "_WKProcessPoolConfigurationInternal.h"
 | |
| +#import "_WKWebsiteDataStoreInternal.h"
 | |
|  #import <WebCore/CertificateInfo.h>
 | |
|  #import <WebCore/HTTPCookieAcceptPolicyCocoa.h>
 | |
|  #import <WebCore/PluginData.h>
 | |
| @@ -85,6 +86,18 @@ static WKProcessPool *sharedProcessPool;
 | |
|      return self;
 | |
|  }
 | |
|  
 | |
| +- (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration AndDataStore:(WKWebsiteDataStore*)dataStore
 | |
| +{
 | |
| +    if (!(self = [super init]))
 | |
| +        return nil;
 | |
| +
 | |
| +    API::Object::constructInWrapper<WebKit::WebProcessPool>(self, *configuration->_processPoolConfiguration);
 | |
| +    _processPool->setPrimaryDataStore(*dataStore->_websiteDataStore);
 | |
| +
 | |
| +    return self;
 | |
| +}
 | |
| +
 | |
| +
 | |
|  - (instancetype)init
 | |
|  {
 | |
|      return [self _initWithConfiguration:adoptNS([[_WKProcessPoolConfiguration alloc] init]).get()];
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
 | |
| index 551168ede1c80c36e75cee437f9ebec7440e6674..635b119e455bf22fcfdf7bd9d684e0a3c4a1905b 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
 | |
| @@ -38,6 +38,7 @@
 | |
|  
 | |
|  @interface WKProcessPool ()
 | |
|  - (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration __attribute__((objc_method_family(init))) NS_DESIGNATED_INITIALIZER;
 | |
| +- (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration AndDataStore:(WKWebsiteDataStore *)dataStore __attribute__((objc_method_family(init))) NS_DESIGNATED_INITIALIZER;
 | |
|  @end
 | |
|  
 | |
|  @interface WKProcessPool (WKPrivate)
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h
 | |
| index cad87f3ef2ab93d93a74cec0c34b47c695de6bc6..66145a384638b97ee08516e56e1e86a83713c634 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h
 | |
| @@ -123,6 +123,13 @@ NS_ASSUME_NONNULL_BEGIN
 | |
|   */
 | |
|  - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * _Nullable result))completionHandler;
 | |
|  
 | |
| +/*! @abstract Handle a JavaScript dialog.
 | |
| + @param webView The web view invoking the delegate method.
 | |
| + @param accept Whether to accept the dialog.
 | |
| + @param value Value to use for prompt dialog.
 | |
| + */
 | |
| +- (void)webView:(WKWebView *)webView handleJavaScriptDialog:(BOOL)accept value:(nullable NSString *)value;
 | |
| +
 | |
|  #if TARGET_OS_IPHONE
 | |
|  
 | |
|  /*! @abstract Allows your app to determine whether or not the given element should show a preview.
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h
 | |
| index 726c4972aa0b32e0dc602e0ab2d71f6ae8ef93ae..c67f408797724cb6d68ed441c0ef1cccd33ca1e0 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h
 | |
| @@ -24,7 +24,6 @@
 | |
|   */
 | |
|  
 | |
|  #import <WebKit/WKFoundation.h>
 | |
| -
 | |
|  #import <WebKit/WKWebsiteDataRecord.h>
 | |
|  
 | |
|  NS_ASSUME_NONNULL_BEGIN
 | |
| @@ -78,6 +77,8 @@ WK_CLASS_AVAILABLE(macos(10.11), ios(9.0))
 | |
|  /*! @abstract Returns the cookie store representing HTTP cookies in this website data store. */
 | |
|  @property (nonatomic, readonly) WKHTTPCookieStore *httpCookieStore WK_API_AVAILABLE(macos(10.13), ios(11.0));
 | |
|  
 | |
| +- (uint64_t)sessionID;
 | |
| +
 | |
|  @end
 | |
|  
 | |
|  NS_ASSUME_NONNULL_END
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
 | |
| index 591428f7f579e76ff01bc94b83f5994af8e48e00..03fc6cf2d3074d9227d7815ac5c72fdb33e8a694 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
 | |
| @@ -44,6 +44,7 @@
 | |
|  #import "_WKWebsiteDataStoreDelegate.h"
 | |
|  #import <WebCore/Credential.h>
 | |
|  #import <WebCore/RegistrationDatabase.h>
 | |
| +#import <pal/SessionID.h>
 | |
|  #import <wtf/BlockPtr.h>
 | |
|  #import <wtf/URL.h>
 | |
|  #import <wtf/WeakObjCPtr.h>
 | |
| @@ -184,6 +185,11 @@ static WallTime toSystemClockTime(NSDate *date)
 | |
|      });
 | |
|  }
 | |
|  
 | |
| +- (uint64_t) sessionID
 | |
| +{
 | |
| +    return _websiteDataStore->sessionID().toUInt64();
 | |
| +}
 | |
| +
 | |
|  static Vector<WebKit::WebsiteDataRecord> toWebsiteDataRecords(NSArray *dataRecords)
 | |
|  {
 | |
|      Vector<WebKit::WebsiteDataRecord> result;
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.h b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..b64d1a6d54ec15a99164294706543cee626d1050
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.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.
 | |
| + */
 | |
| +
 | |
| +#import <WebKit/WKFoundation.h>
 | |
| +#import <WebKit/WKProcessPool.h>
 | |
| +#import <WebKit/WKWebsiteDataStore.h>
 | |
| +#import <Foundation/Foundation.h>
 | |
| +
 | |
| +NS_ASSUME_NONNULL_BEGIN
 | |
| +
 | |
| +@class WKWebView;
 | |
| +
 | |
| +WK_CLASS_AVAILABLE(macos(10.14.0))
 | |
| +@interface _WKBrowserContext : NSObject
 | |
| +@property (nonatomic, strong) WKWebsiteDataStore *dataStore;
 | |
| +@property (nonatomic, strong) WKProcessPool *processPool;
 | |
| +@end
 | |
| +
 | |
| +@protocol _WKBrowserInspectorDelegate <NSObject>
 | |
| +- (WKWebView *)createNewPage:(uint64_t)sessionID;
 | |
| +- (_WKBrowserContext *)createBrowserContext;
 | |
| +- (void)deleteBrowserContext:(uint64_t)sessionID;
 | |
| +- (void)quit;
 | |
| +@end
 | |
| +
 | |
| +WK_CLASS_AVAILABLE(macos(10.14.0))
 | |
| +@interface _WKBrowserInspector : NSObject
 | |
| ++ (void)initializeRemoteInspectorPipe:(id<_WKBrowserInspectorDelegate>)delegate headless:(BOOL)headless;
 | |
| +@end
 | |
| +
 | |
| +
 | |
| +NS_ASSUME_NONNULL_END
 | |
| +
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.mm
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..e7143513ea2be8e1cdab5c86a28643fffea626dd
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.mm
 | |
| @@ -0,0 +1,60 @@
 | |
| +/*
 | |
| + * 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 "_WKBrowserInspector.h"
 | |
| +
 | |
| +#include "BrowserInspectorPipe.h"
 | |
| +#include "InspectorPlaywrightAgentClientMac.h"
 | |
| +#include "PageClientImplMac.h"
 | |
| +#include "WebKit2Initialize.h"
 | |
| +
 | |
| +#import "WKWebView.h"
 | |
| +
 | |
| +using namespace WebKit;
 | |
| +
 | |
| +@implementation _WKBrowserInspector
 | |
| +
 | |
| ++ (void)initializeRemoteInspectorPipe:(id<_WKBrowserInspectorDelegate>)delegate headless:(BOOL)headless
 | |
| +{
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +    InitializeWebKit2();
 | |
| +    PageClientImpl::setHeadless(headless);
 | |
| +    initializeBrowserInspectorPipe(makeUnique<InspectorPlaywrightAgentClientMac>(delegate));
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +@end
 | |
| +
 | |
| +@implementation _WKBrowserContext
 | |
| +- (void)dealloc
 | |
| +{
 | |
| +    [_dataStore release];
 | |
| +    [_processPool release];
 | |
| +    _dataStore = nil;
 | |
| +    _processPool = nil;
 | |
| +    [super dealloc];
 | |
| +}
 | |
| +@end
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
 | |
| index df2b919c9ba18cc9cc0471a4334eb85c45e3820e..b5a73c8d6863217da0edb97688d17a7debab3c11 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
 | |
| @@ -62,6 +62,7 @@ WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
 | |
|  #endif
 | |
|  @property (nonatomic) pid_t presentingApplicationPID WK_API_AVAILABLE(macos(10.13), ios(11.0));
 | |
|  @property (nonatomic) BOOL processSwapsOnNavigation WK_API_AVAILABLE(macos(10.14), ios(12.0));
 | |
| +@property (nonatomic) BOOL forceOverlayScrollbars WK_API_AVAILABLE(macos(10.14));
 | |
|  @property (nonatomic) BOOL alwaysKeepAndReuseSwappedProcesses WK_API_AVAILABLE(macos(10.14), ios(12.0));
 | |
|  @property (nonatomic) BOOL processSwapsOnWindowOpenWithOpener WK_API_AVAILABLE(macos(10.14), ios(12.0));
 | |
|  @property (nonatomic) BOOL prewarmsProcessesAutomatically WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
 | |
| index c43d4271e5f5c35e33d69141d472291ca7ad203e..996f81ba8e177f9d6107007afa63ed5fc4ac0d66 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
 | |
| @@ -231,6 +231,16 @@
 | |
|      return _processPoolConfiguration->processSwapsOnNavigation();
 | |
|  }
 | |
|  
 | |
| +- (void)setForceOverlayScrollbars:(BOOL)force
 | |
| +{
 | |
| +    _processPoolConfiguration->setForceOverlayScrollbars(force);
 | |
| +}
 | |
| +
 | |
| +- (BOOL)forceOverlayScrollbars
 | |
| +{
 | |
| +    return _processPoolConfiguration->forceOverlayScrollbars();
 | |
| +}
 | |
| +
 | |
|  - (void)setPrewarmsProcessesAutomatically:(BOOL)prewarms
 | |
|  {
 | |
|      _processPoolConfiguration->setIsAutomaticProcessWarmingEnabled(prewarms);
 | |
| diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
 | |
| index 2bdb8b9e7256f22096ebaa5d51959aa52389ca0a..2141d9d17497861a6c711f99306de10992a93ce8 100644
 | |
| --- a/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
 | |
| +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
 | |
| @@ -25,6 +25,7 @@
 | |
|  
 | |
|  #import "config.h"
 | |
|  #import "_WKRemoteWebInspectorViewController.h"
 | |
| +#import "WKWebViewPrivate.h"
 | |
|  
 | |
|  #if PLATFORM(MAC)
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/API/glib/WebKitBrowserInspector.cpp b/Source/WebKit/UIProcess/API/glib/WebKitBrowserInspector.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..1884526cd6ce7d436af6596ab3a45b103031dba1
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/API/glib/WebKitBrowserInspector.cpp
 | |
| @@ -0,0 +1,136 @@
 | |
| +/*
 | |
| + * 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 "WebKitBrowserInspector.h"
 | |
| +
 | |
| +#include "BrowserInspectorPipe.h"
 | |
| +#include "InspectorPlaywrightAgentClientGLib.h"
 | |
| +#include "WebKitBrowserInspectorPrivate.h"
 | |
| +#include "WebKitWebViewPrivate.h"
 | |
| +#include <wtf/glib/GRefPtr.h>
 | |
| +#include <wtf/glib/WTFGType.h>
 | |
| +
 | |
| +/**
 | |
| + * SECTION: WebKitBrowserInspector
 | |
| + * @Short_description: Access to the WebKit browser inspector
 | |
| + * @Title: WebKitBrowserInspector
 | |
| + *
 | |
| + * The WebKit Browser Inspector is an experimental API that provides
 | |
| + * access to the inspector via the remote debugging protocol. The protocol
 | |
| + * allows to create ephemeral contexts and create pages in them and then
 | |
| + * manipulate them using the inspector commands. This may be useful for
 | |
| + * the browser automation or remote debugging.
 | |
| + *
 | |
| + * Currently the protocol can be exposed to the parent process via a unix
 | |
| + * pipe.
 | |
| + */
 | |
| +
 | |
| +enum {
 | |
| +    CREATE_NEW_PAGE,
 | |
| +
 | |
| +    LAST_SIGNAL
 | |
| +};
 | |
| +
 | |
| +struct _WebKitBrowserInspectorPrivate {
 | |
| +    int unused { 0 };
 | |
| +};
 | |
| +
 | |
| +WEBKIT_DEFINE_TYPE(WebKitBrowserInspector, webkit_browser_inspector, G_TYPE_OBJECT)
 | |
| +
 | |
| +static guint signals[LAST_SIGNAL] = { 0, };
 | |
| +
 | |
| +static void webkit_browser_inspector_class_init(WebKitBrowserInspectorClass* findClass)
 | |
| +{
 | |
| +    GObjectClass* gObjectClass = G_OBJECT_CLASS(findClass);
 | |
| +
 | |
| +    /**
 | |
| +     * WebKitBrowserInspector::create-new-page:
 | |
| +     * @inspector: the #WebKitBrowserInspector on which the signal is emitted
 | |
| +     *
 | |
| +     * Emitted when the inspector is requested to create a new page in the provided
 | |
| +     * #WebKitWebContext.
 | |
| +     *
 | |
| +     * This signal is emitted when inspector receives 'Browser.createPage' command
 | |
| +     * from its remote client. If the signla is not handled the command will fail.
 | |
| +     *
 | |
| +     * Returns: %WebKitWebView that contains created page.
 | |
| +     */
 | |
| +    signals[CREATE_NEW_PAGE] = g_signal_new(
 | |
| +        "create-new-page",
 | |
| +        G_TYPE_FROM_CLASS(gObjectClass),
 | |
| +        G_SIGNAL_RUN_LAST,
 | |
| +        G_STRUCT_OFFSET(WebKitBrowserInspectorClass, create_new_page),
 | |
| +        nullptr, nullptr,
 | |
| +        g_cclosure_marshal_generic,
 | |
| +#if PLATFORM(GTK)
 | |
| +        GTK_TYPE_WIDGET,
 | |
| +#else
 | |
| +        WEBKIT_TYPE_WEB_VIEW,
 | |
| +#endif
 | |
| +        1,
 | |
| +        WEBKIT_TYPE_WEB_CONTEXT);
 | |
| +}
 | |
| +
 | |
| +WebKit::WebPageProxy* webkitBrowserInspectorCreateNewPageInContext(WebKitWebContext* context)
 | |
| +{
 | |
| +    WebKitWebView* newWebView;
 | |
| +    g_signal_emit(webkit_browser_inspector_get_default(), signals[CREATE_NEW_PAGE], 0, context, &newWebView);
 | |
| +    if (!newWebView)
 | |
| +        return nullptr;
 | |
| +    return  &webkitWebViewGetPage(newWebView);
 | |
| +}
 | |
| +
 | |
| +static gpointer createWebKitBrowserInspector(gpointer)
 | |
| +{
 | |
| +    static GRefPtr<WebKitBrowserInspector> browserInspector = adoptGRef(WEBKIT_BROWSER_INSPECTOR(g_object_new(WEBKIT_TYPE_BROWSER_INSPECTOR, nullptr)));
 | |
| +    return browserInspector.get();
 | |
| +}
 | |
| +
 | |
| +/**
 | |
| + * webkit_browser_inspector_get_default:
 | |
| + *
 | |
| + * Gets the default instance of the browser inspector.
 | |
| + *
 | |
| + * Returns: (transfer none): a #WebKitBrowserInspector
 | |
| + */
 | |
| +WebKitBrowserInspector* webkit_browser_inspector_get_default(void)
 | |
| +{
 | |
| +    static GOnce onceInit = G_ONCE_INIT;
 | |
| +    return WEBKIT_BROWSER_INSPECTOR(g_once(&onceInit, createWebKitBrowserInspector, 0));
 | |
| +}
 | |
| +
 | |
| +/**
 | |
| + * webkit_browser_inspector_initialize_pipe:
 | |
| + *
 | |
| + * Creates browser inspector and configures pipe handler to communicate with
 | |
| + * the parent process.
 | |
| + */
 | |
| +void webkit_browser_inspector_initialize_pipe(GMainLoop* mainLoop)
 | |
| +{
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +    WebKit::initializeBrowserInspectorPipe(makeUnique<WebKit::InspectorPlaywrightAgentClientGlib>(mainLoop));
 | |
| +#endif
 | |
| +}
 | |
| diff --git a/Source/WebKit/UIProcess/API/glib/WebKitBrowserInspectorPrivate.h b/Source/WebKit/UIProcess/API/glib/WebKitBrowserInspectorPrivate.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..1bff4e694f19264d1be418198b7921780e4f8309
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/API/glib/WebKitBrowserInspectorPrivate.h
 | |
| @@ -0,0 +1,31 @@
 | |
| +/*
 | |
| + * 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
 | |
| +
 | |
| +#include "WebKitBrowserInspector.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +
 | |
| +WebKit::WebPageProxy* webkitBrowserInspectorCreateNewPageInContext(WebKitWebContext*);
 | |
| diff --git a/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp b/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
 | |
| index 07da96138db1333ce5a49093dc2187fd12032214..33f04f575dc99ce09adb107fc3f97128583898c3 100644
 | |
| --- a/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
 | |
| @@ -65,7 +65,8 @@ private:
 | |
|      void createNewPage(WebPageProxy& page, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& apiNavigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
 | |
|      {
 | |
|          WebKitNavigationAction navigationAction(WTFMove(apiNavigationAction));
 | |
| -        completionHandler(webkitWebViewCreateNewPage(m_webView, windowFeatures, &navigationAction));
 | |
| +        WebPageProxy* newPage = webkitWebViewCreateNewPage(m_webView, windowFeatures, &navigationAction);
 | |
| +        completionHandler(adoptRef(newPage));
 | |
|      }
 | |
|  
 | |
|      void showPage(WebPageProxy*) final
 | |
| @@ -92,6 +93,10 @@ private:
 | |
|      {
 | |
|          webkitWebViewRunJavaScriptPrompt(m_webView, message.utf8(), defaultValue.utf8(), WTFMove(completionHandler));
 | |
|      }
 | |
| +    void handleJavaScriptDialog(WebPageProxy&, bool accept, const String& value) final
 | |
| +    {
 | |
| +        webkitWebViewHandleJavaScriptDialog(m_webView, accept, value);
 | |
| +    }
 | |
|  
 | |
|      bool canRunBeforeUnloadConfirmPanel() const final { return true; }
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
 | |
| index 7222a91cb95a5e370f9229ee6425e412b5f8b078..c4031ba28fc89c771c0a64ee787fd24599edf19d 100644
 | |
| --- a/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
 | |
| @@ -119,8 +119,8 @@ enum {
 | |
|      PROP_LOCAL_STORAGE_DIRECTORY,
 | |
|  #endif
 | |
|      PROP_WEBSITE_DATA_MANAGER,
 | |
| -#if PLATFORM(GTK)
 | |
|      PROP_PSON_ENABLED,
 | |
| +#if PLATFORM(GTK)
 | |
|  #if !USE(GTK4)
 | |
|      PROP_USE_SYSYEM_APPEARANCE_FOR_SCROLLBARS
 | |
|  #endif
 | |
| @@ -205,8 +205,8 @@ struct _WebKitWebContextPrivate {
 | |
|  
 | |
|      RefPtr<WebProcessPool> processPool;
 | |
|      bool clientsDetached;
 | |
| -#if PLATFORM(GTK)
 | |
|      bool psonEnabled;
 | |
| +#if PLATFORM(GTK)
 | |
|  #if !USE(GTK4)
 | |
|      bool useSystemAppearanceForScrollbars;
 | |
|  #endif
 | |
| @@ -335,10 +335,10 @@ static void webkitWebContextGetProperty(GObject* object, guint propID, GValue* v
 | |
|      case PROP_WEBSITE_DATA_MANAGER:
 | |
|          g_value_set_object(value, webkit_web_context_get_website_data_manager(context));
 | |
|          break;
 | |
| -#if PLATFORM(GTK)
 | |
|      case PROP_PSON_ENABLED:
 | |
|          g_value_set_boolean(value, context->priv->psonEnabled);
 | |
|          break;
 | |
| +#if PLATFORM(GTK)
 | |
|  #if !USE(GTK4)
 | |
|      case PROP_USE_SYSYEM_APPEARANCE_FOR_SCROLLBARS:
 | |
|          g_value_set_boolean(value, webkit_web_context_get_use_system_appearance_for_scrollbars(context));
 | |
| @@ -365,10 +365,10 @@ static void webkitWebContextSetProperty(GObject* object, guint propID, const GVa
 | |
|          context->priv->websiteDataManager = manager ? WEBKIT_WEBSITE_DATA_MANAGER(manager) : nullptr;
 | |
|          break;
 | |
|      }
 | |
| -#if PLATFORM(GTK)
 | |
|      case PROP_PSON_ENABLED:
 | |
|          context->priv->psonEnabled = g_value_get_boolean(value);
 | |
|          break;
 | |
| +#if PLATFORM(GTK)
 | |
|  #if !USE(GTK4)
 | |
|      case PROP_USE_SYSYEM_APPEARANCE_FOR_SCROLLBARS:
 | |
|          webkit_web_context_set_use_system_appearance_for_scrollbars(context, g_value_get_boolean(value));
 | |
| @@ -391,8 +391,8 @@ static void webkitWebContextConstructed(GObject* object)
 | |
|  
 | |
|      API::ProcessPoolConfiguration configuration;
 | |
|      configuration.setInjectedBundlePath(FileSystem::stringFromFileSystemRepresentation(bundleFilename.get()));
 | |
| -#if PLATFORM(GTK)
 | |
|      configuration.setProcessSwapsOnNavigation(priv->psonEnabled);
 | |
| +#if PLATFORM(GTK)
 | |
|  #if !USE(GTK4)
 | |
|      configuration.setUseSystemAppearanceForScrollbars(priv->useSystemAppearanceForScrollbars);
 | |
|  #endif
 | |
| @@ -404,6 +404,11 @@ static void webkitWebContextConstructed(GObject* object)
 | |
|      if (!webkit_website_data_manager_is_ephemeral(priv->websiteDataManager.get()))
 | |
|          WebKit::LegacyGlobalSettings::singleton().setHSTSStorageDirectory(FileSystem::stringFromFileSystemRepresentation(webkit_website_data_manager_get_hsts_cache_directory(priv->websiteDataManager.get())));
 | |
|  
 | |
| +    const gchar *singleprocess = g_getenv("MINIBROWSER_SINGLEPROCESS");
 | |
| +    if (singleprocess && *singleprocess) {
 | |
| +        // processModel is not set at this point, force single process.
 | |
| +        configuration.setUsesSingleWebProcess(true);
 | |
| +    }
 | |
|      priv->processPool = WebProcessPool::create(configuration);
 | |
|      priv->processPool->setPrimaryDataStore(webkitWebsiteDataManagerGetDataStore(priv->websiteDataManager.get()));
 | |
|      priv->processPool->setUserMessageHandler([webContext](UserMessage&& message, CompletionHandler<void(UserMessage&&)>&& completionHandler) {
 | |
| @@ -515,7 +520,6 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass
 | |
|              WEBKIT_TYPE_WEBSITE_DATA_MANAGER,
 | |
|              static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
 | |
|  
 | |
| -#if PLATFORM(GTK)
 | |
|      /**
 | |
|       * WebKitWebContext:process-swap-on-cross-site-navigation-enabled:
 | |
|       *
 | |
| @@ -539,6 +543,7 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass
 | |
|              FALSE,
 | |
|              static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
 | |
|  
 | |
| +#if PLATFORM(GTK)
 | |
|  #if !USE(GTK4)
 | |
|      /**
 | |
|       * WebKitWebContext:use-system-appearance-for-scrollbars:
 | |
| diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
 | |
| index e67e9b580ffbaed8f36a76325f23b018497fbf0d..70be44e3f1fb43e7c45d29232119edf74d9c7e27 100644
 | |
| --- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
 | |
| @@ -130,6 +130,7 @@ enum {
 | |
|      CLOSE,
 | |
|  
 | |
|      SCRIPT_DIALOG,
 | |
| +    SCRIPT_DIALOG_HANDLED,
 | |
|  
 | |
|      DECIDE_POLICY,
 | |
|      PERMISSION_REQUEST,
 | |
| @@ -1535,6 +1536,15 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
 | |
|          G_TYPE_BOOLEAN, 1,
 | |
|          WEBKIT_TYPE_SCRIPT_DIALOG);
 | |
|  
 | |
| +    signals[SCRIPT_DIALOG_HANDLED] = g_signal_new(
 | |
| +        "script-dialog-handled",
 | |
| +        G_TYPE_FROM_CLASS(webViewClass),
 | |
| +        G_SIGNAL_RUN_LAST,
 | |
| +        G_STRUCT_OFFSET(WebKitWebViewClass, script_dialog),
 | |
| +        g_signal_accumulator_true_handled, nullptr,
 | |
| +        g_cclosure_marshal_generic,
 | |
| +        G_TYPE_BOOLEAN, 1);
 | |
| +
 | |
|      /**
 | |
|       * WebKitWebView::decide-policy:
 | |
|       * @web_view: the #WebKitWebView on which the signal is emitted
 | |
| @@ -2416,6 +2426,23 @@ void webkitWebViewRunJavaScriptBeforeUnloadConfirm(WebKitWebView* webView, const
 | |
|      webkit_script_dialog_unref(webView->priv->currentScriptDialog);
 | |
|  }
 | |
|  
 | |
| +void webkitWebViewHandleJavaScriptDialog(WebKitWebView* webView, bool accept, const String& value) {
 | |
| +    auto* dialog = webView->priv->currentScriptDialog;
 | |
| +#if PLATFORM(WPE)
 | |
| +    dialog->isUserHandled = false;
 | |
| +#endif
 | |
| +    webkit_script_dialog_ref(dialog);
 | |
| +    if (!value.isNull())
 | |
| +        webkitWebViewSetCurrentScriptDialogUserInput(webView, value);
 | |
| +    if (accept)
 | |
| +        webkitWebViewAcceptCurrentScriptDialog(webView);
 | |
| +    else
 | |
| +        webkitWebViewDismissCurrentScriptDialog(webView);
 | |
| +    gboolean returnValue;
 | |
| +    g_signal_emit(webView, signals[SCRIPT_DIALOG_HANDLED], 0, dialog, &returnValue);
 | |
| +    webkit_script_dialog_unref(dialog);
 | |
| +}
 | |
| +
 | |
|  bool webkitWebViewIsShowingScriptDialog(WebKitWebView* webView)
 | |
|  {
 | |
|      if (!webView->priv->currentScriptDialog)
 | |
| diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h b/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
 | |
| index 5ab7574c9378f52db87ce75157627c04e9b2e962..5322d725238f5989c04b045615a2de8163329fdf 100644
 | |
| --- a/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
 | |
| +++ b/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
 | |
| @@ -60,6 +60,7 @@ void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message, Fun
 | |
|  void webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message, Function<void(bool)>&& completionHandler);
 | |
|  void webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText, Function<void(const String&)>&& completionHandler);
 | |
|  void webkitWebViewRunJavaScriptBeforeUnloadConfirm(WebKitWebView*, const CString& message, Function<void(bool)>&& completionHandler);
 | |
| +void webkitWebViewHandleJavaScriptDialog(WebKitWebView*, bool accept, const String& value);
 | |
|  bool webkitWebViewIsShowingScriptDialog(WebKitWebView*);
 | |
|  bool webkitWebViewIsScriptDialogRunning(WebKitWebView*, WebKitScriptDialog*);
 | |
|  String webkitWebViewGetCurrentScriptDialogMessage(WebKitWebView*);
 | |
| diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
 | |
| index aab0f7ed0ad0cd00b1769a2f5b1b21ba8cc86978..22ba2103f6b93561039a67719ac4881b4d4d421b 100644
 | |
| --- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
 | |
| +++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
 | |
| @@ -241,6 +241,8 @@ void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool
 | |
|  {
 | |
|      if (wasEventHandled || event.type() != WebEvent::Type::KeyDown)
 | |
|          return;
 | |
| +    if (!event.nativeEvent())
 | |
| +        return;
 | |
|  
 | |
|      WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(m_viewWidget);
 | |
|      webkitWebViewBaseForwardNextKeyEvent(webkitWebViewBase);
 | |
| diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitBrowserInspector.h b/Source/WebKit/UIProcess/API/gtk/WebKitBrowserInspector.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..a51cfebc270ca5a91cd94645eeeb005ba9a67caf
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/API/gtk/WebKitBrowserInspector.h
 | |
| @@ -0,0 +1,79 @@
 | |
| +/*
 | |
| + * 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.
 | |
| + */
 | |
| +
 | |
| +#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
 | |
| +#error "Only <webkit2/webkit2.h> can be included directly."
 | |
| +#endif
 | |
| +
 | |
| +#ifndef WebKitBrowserInspector_h
 | |
| +#define WebKitBrowserInspector_h
 | |
| +
 | |
| +#include <glib-object.h>
 | |
| +#include <webkit2/WebKitDefines.h>
 | |
| +#include <webkit2/WebKitWebView.h>
 | |
| +
 | |
| +G_BEGIN_DECLS
 | |
| +
 | |
| +#define WEBKIT_TYPE_BROWSER_INSPECTOR            (webkit_browser_inspector_get_type())
 | |
| +#define WEBKIT_BROWSER_INSPECTOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BROWSER_INSPECTOR, WebKitBrowserInspector))
 | |
| +#define WEBKIT_IS_BROWSER_INSPECTOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BROWSER_INSPECTOR))
 | |
| +#define WEBKIT_BROWSER_INSPECTOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_BROWSER_INSPECTOR, WebKitBrowserInspectorClass))
 | |
| +#define WEBKIT_IS_BROWSER_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_BROWSER_INSPECTOR))
 | |
| +#define WEBKIT_BROWSER_INSPECTOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_BROWSER_INSPECTOR, WebKitBrowserInspectorClass))
 | |
| +
 | |
| +typedef struct _WebKitBrowserInspector        WebKitBrowserInspector;
 | |
| +typedef struct _WebKitBrowserInspectorClass   WebKitBrowserInspectorClass;
 | |
| +typedef struct _WebKitBrowserInspectorPrivate WebKitBrowserInspectorPrivate;
 | |
| +
 | |
| +struct _WebKitBrowserInspector {
 | |
| +    GObject parent;
 | |
| +
 | |
| +    WebKitBrowserInspectorPrivate *priv;
 | |
| +};
 | |
| +
 | |
| +struct _WebKitBrowserInspectorClass {
 | |
| +    GObjectClass parent_class;
 | |
| +
 | |
| +    WebKitWebView *(* create_new_page)           (WebKitBrowserInspector    *browser_inspector,
 | |
| +                                                  WebKitWebContext          *context);
 | |
| +
 | |
| +    void (*_webkit_reserved0) (void);
 | |
| +    void (*_webkit_reserved1) (void);
 | |
| +    void (*_webkit_reserved2) (void);
 | |
| +    void (*_webkit_reserved3) (void);
 | |
| +};
 | |
| +
 | |
| +WEBKIT_API GType
 | |
| +webkit_browser_inspector_get_type                     (void);
 | |
| +
 | |
| +WEBKIT_API WebKitBrowserInspector *
 | |
| +webkit_browser_inspector_get_default                  (void);
 | |
| +
 | |
| +WEBKIT_API void
 | |
| +webkit_browser_inspector_initialize_pipe              (GMainLoop*);
 | |
| +
 | |
| +G_END_DECLS
 | |
| +
 | |
| +#endif
 | |
| diff --git a/Source/WebKit/UIProcess/API/gtk/webkit2.h b/Source/WebKit/UIProcess/API/gtk/webkit2.h
 | |
| index 930b17b6629e04d0dfa2222bbc3217877c6e1812..395462e5f01c195231e9296d1204167cded99ad3 100644
 | |
| --- a/Source/WebKit/UIProcess/API/gtk/webkit2.h
 | |
| +++ b/Source/WebKit/UIProcess/API/gtk/webkit2.h
 | |
| @@ -32,6 +32,7 @@
 | |
|  #include <webkit2/WebKitAutomationSession.h>
 | |
|  #include <webkit2/WebKitBackForwardList.h>
 | |
|  #include <webkit2/WebKitBackForwardListItem.h>
 | |
| +#include <webkit2/WebKitBrowserInspector.h>
 | |
|  #include <webkit2/WebKitContextMenu.h>
 | |
|  #include <webkit2/WebKitContextMenuActions.h>
 | |
|  #include <webkit2/WebKitContextMenuItem.h>
 | |
| diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitBrowserInspector.h b/Source/WebKit/UIProcess/API/wpe/WebKitBrowserInspector.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..6dffa4fa10a9a64f778a0a77c760c2e76b2f9968
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/API/wpe/WebKitBrowserInspector.h
 | |
| @@ -0,0 +1,79 @@
 | |
| +/*
 | |
| + * 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.
 | |
| + */
 | |
| +
 | |
| +#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
 | |
| +#error "Only <wpe/webkit.h> can be included directly."
 | |
| +#endif
 | |
| +
 | |
| +#ifndef WebKitBrowserInspector_h
 | |
| +#define WebKitBrowserInspector_h
 | |
| +
 | |
| +#include <glib-object.h>
 | |
| +#include <wpe/WebKitDefines.h>
 | |
| +#include <wpe/WebKitWebView.h>
 | |
| +
 | |
| +G_BEGIN_DECLS
 | |
| +
 | |
| +#define WEBKIT_TYPE_BROWSER_INSPECTOR            (webkit_browser_inspector_get_type())
 | |
| +#define WEBKIT_BROWSER_INSPECTOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BROWSER_INSPECTOR, WebKitBrowserInspector))
 | |
| +#define WEBKIT_IS_BROWSER_INSPECTOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BROWSER_INSPECTOR))
 | |
| +#define WEBKIT_BROWSER_INSPECTOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_BROWSER_INSPECTOR, WebKitBrowserInspectorClass))
 | |
| +#define WEBKIT_IS_BROWSER_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_BROWSER_INSPECTOR))
 | |
| +#define WEBKIT_BROWSER_INSPECTOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_BROWSER_INSPECTOR, WebKitBrowserInspectorClass))
 | |
| +
 | |
| +typedef struct _WebKitBrowserInspector        WebKitBrowserInspector;
 | |
| +typedef struct _WebKitBrowserInspectorClass   WebKitBrowserInspectorClass;
 | |
| +typedef struct _WebKitBrowserInspectorPrivate WebKitBrowserInspectorPrivate;
 | |
| +
 | |
| +struct _WebKitBrowserInspector {
 | |
| +    GObject parent;
 | |
| +
 | |
| +    WebKitBrowserInspectorPrivate *priv;
 | |
| +};
 | |
| +
 | |
| +struct _WebKitBrowserInspectorClass {
 | |
| +    GObjectClass parent_class;
 | |
| +
 | |
| +    WebKitWebView *(* create_new_page)           (WebKitBrowserInspector    *browser_inspector,
 | |
| +                                                  WebKitWebContext          *context);
 | |
| +
 | |
| +    void (*_webkit_reserved0) (void);
 | |
| +    void (*_webkit_reserved1) (void);
 | |
| +    void (*_webkit_reserved2) (void);
 | |
| +    void (*_webkit_reserved3) (void);
 | |
| +};
 | |
| +
 | |
| +WEBKIT_API GType
 | |
| +webkit_browser_inspector_get_type                     (void);
 | |
| +
 | |
| +WEBKIT_API WebKitBrowserInspector *
 | |
| +webkit_browser_inspector_get_default                  (void);
 | |
| +
 | |
| +WEBKIT_API void
 | |
| +webkit_browser_inspector_initialize_pipe              (GMainLoop*);
 | |
| +
 | |
| +G_END_DECLS
 | |
| +
 | |
| +#endif
 | |
| diff --git a/Source/WebKit/UIProcess/API/wpe/webkit.h b/Source/WebKit/UIProcess/API/wpe/webkit.h
 | |
| index 02e258253e47fbf6594c20f743d0faeac8a4eefe..e051fdf396dc65717def6b36168b5538e3cb2f4d 100644
 | |
| --- a/Source/WebKit/UIProcess/API/wpe/webkit.h
 | |
| +++ b/Source/WebKit/UIProcess/API/wpe/webkit.h
 | |
| @@ -32,6 +32,7 @@
 | |
|  #include <wpe/WebKitAutomationSession.h>
 | |
|  #include <wpe/WebKitBackForwardList.h>
 | |
|  #include <wpe/WebKitBackForwardListItem.h>
 | |
| +#include <wpe/WebKitBrowserInspector.h>
 | |
|  #include <wpe/WebKitContextMenu.h>
 | |
|  #include <wpe/WebKitContextMenuActions.h>
 | |
|  #include <wpe/WebKitContextMenuItem.h>
 | |
| diff --git a/Source/WebKit/UIProcess/Automation/WebAutomationSession.h b/Source/WebKit/UIProcess/Automation/WebAutomationSession.h
 | |
| index 23b992f3ce45f82f0dcdede6007a2e3a46b7b0b6..7e711e8f5132931e01eac66db6ea60c33d65b3d6 100644
 | |
| --- a/Source/WebKit/UIProcess/Automation/WebAutomationSession.h
 | |
| +++ b/Source/WebKit/UIProcess/Automation/WebAutomationSession.h
 | |
| @@ -217,6 +217,8 @@ public:
 | |
|      void markEventAsSynthesizedForAutomation(NSEvent *);
 | |
|  #endif
 | |
|  
 | |
| +    static Optional<String> platformGetBase64EncodedPNGData(const ViewSnapshot&);
 | |
| +
 | |
|  private:
 | |
|      WebPageProxy* webPageProxyForHandle(const String&);
 | |
|      String handleForWebPageProxy(const WebPageProxy&);
 | |
| @@ -262,7 +264,6 @@ private:
 | |
|  
 | |
|      // Get base64-encoded PNG data from a bitmap.
 | |
|      static Optional<String> platformGetBase64EncodedPNGData(const ShareableBitmap::Handle&);
 | |
| -    static Optional<String> platformGetBase64EncodedPNGData(const ViewSnapshot&);
 | |
|  
 | |
|      // Save base64-encoded file contents to a local file path and return the path.
 | |
|      // This reuses the basename of the remote file path so that the filename exposed to DOM API remains the same.
 | |
| diff --git a/Source/WebKit/UIProcess/BrowserInspectorController.cpp b/Source/WebKit/UIProcess/BrowserInspectorController.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..df23f11858e6e60ca238793fe3f37cf19036fbee
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/BrowserInspectorController.cpp
 | |
| @@ -0,0 +1,244 @@
 | |
| +/*
 | |
| + * 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 "BrowserInspectorController.h"
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include "InspectorPlaywrightAgent.h"
 | |
| +#include "InspectorPlaywrightAgentClient.h"
 | |
| +#include "WebPageInspectorController.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include "WebProcessPool.h"
 | |
| +#include "WebProcessProxy.h"
 | |
| +#include <JavaScriptCore/InspectorBackendDispatcher.h>
 | |
| +#include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| +#include <JavaScriptCore/InspectorFrontendChannel.h>
 | |
| +#include <JavaScriptCore/InspectorFrontendRouter.h>
 | |
| +#include <JavaScriptCore/InspectorTarget.h>
 | |
| +#include <WebCore/WindowFeatures.h>
 | |
| +#include <wtf/Ref.h>
 | |
| +#include <wtf/RefPtr.h>
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +static Vector<WebPageProxy*> allPages()
 | |
| +{
 | |
| +    ASSERT(isMainThread());
 | |
| +    Vector<WebPageProxy*> result;
 | |
| +    for (WebProcessPool* pool : WebProcessPool::allProcessPools()) {
 | |
| +        for (auto& process : pool->processes()) {
 | |
| +            result.appendRange(process->pages().begin(), process->pages().end());
 | |
| +        }
 | |
| +    }
 | |
| +    return result;
 | |
| +}
 | |
| +
 | |
| +class BrowserInspectorController::PageProxyChannel : public FrontendChannel {
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    PageProxyChannel(FrontendChannel& frontendChannel, String pageProxyID, WebPageProxy& page)
 | |
| +        : m_pageProxyID(pageProxyID)
 | |
| +        , m_frontendChannel(frontendChannel)
 | |
| +        , m_page(page)
 | |
| +    {
 | |
| +    }
 | |
| +
 | |
| +    ~PageProxyChannel() override = default;
 | |
| +
 | |
| +    void dispatchMessageFromFrontend(const String& message)
 | |
| +    {
 | |
| +        m_page.inspectorController().dispatchMessageFromFrontend(message);
 | |
| +    }
 | |
| +
 | |
| +    WebPageProxy& page() { return m_page; }
 | |
| +
 | |
| +    void disconnect()
 | |
| +    {
 | |
| +        m_page.inspectorController().disconnectFrontend(*this);
 | |
| +    }
 | |
| +
 | |
| +private:
 | |
| +    ConnectionType connectionType() const override { return m_frontendChannel.connectionType(); }
 | |
| +    void sendMessageToFrontend(const String& message) override
 | |
| +    {
 | |
| +        m_frontendChannel.sendMessageToFrontend(addTabIdToMessage(message));
 | |
| +    }
 | |
| +
 | |
| +    String addTabIdToMessage(const String& message) {
 | |
| +        RefPtr<JSON::Value> parsedMessage;
 | |
| +        if (!JSON::Value::parseJSON(message, parsedMessage))
 | |
| +            return message;
 | |
| +
 | |
| +        RefPtr<JSON::Object> messageObject;
 | |
| +        if (!parsedMessage->asObject(messageObject))
 | |
| +            return message;
 | |
| +
 | |
| +        messageObject->setString("pageProxyId"_s, m_pageProxyID);
 | |
| +        return messageObject->toJSONString();
 | |
| +    }
 | |
| +
 | |
| +    String m_pageProxyID;
 | |
| +    FrontendChannel& m_frontendChannel;
 | |
| +    WebPageProxy& m_page;
 | |
| +};
 | |
| +
 | |
| +BrowserInspectorController::BrowserInspectorController(std::unique_ptr<InspectorPlaywrightAgentClient> client)
 | |
| +    : m_frontendChannel(nullptr)
 | |
| +    , m_frontendRouter(FrontendRouter::create())
 | |
| +    , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))
 | |
| +    , m_browserAgentClient(std::move(client))
 | |
| +{
 | |
| +    PageProxyIDMap* map = this;
 | |
| +    auto browserAgent = makeUnique<InspectorPlaywrightAgent>(m_frontendRouter, m_backendDispatcher, m_browserAgentClient.get(), *map);
 | |
| +    m_browserAgent = browserAgent.get();
 | |
| +    m_agents.append(WTFMove(browserAgent));
 | |
| +}
 | |
| +
 | |
| +BrowserInspectorController::~BrowserInspectorController()
 | |
| +{
 | |
| +    if (m_frontendChannel)
 | |
| +        disconnectFrontend();
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::connectFrontend(FrontendChannel& frontendChannel)
 | |
| +{
 | |
| +    ASSERT(!m_frontendChannel);
 | |
| +    m_frontendChannel = &frontendChannel;
 | |
| +    WebPageInspectorController::setObserver(this);
 | |
| +
 | |
| +    bool connectingFirstFrontend = !m_frontendRouter->hasFrontends();
 | |
| +    m_frontendRouter->connectFrontend(frontendChannel);
 | |
| +    if (connectingFirstFrontend)
 | |
| +        m_agents.didCreateFrontendAndBackend(&m_frontendRouter.get(), &m_backendDispatcher.get());
 | |
| +
 | |
| +    connectToAllPages();
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::disconnectFrontend()
 | |
| +{
 | |
| +    ASSERT(m_frontendChannel);
 | |
| +    disconnectFromAllPages();
 | |
| +
 | |
| +    m_frontendRouter->disconnectFrontend(*m_frontendChannel);
 | |
| +    if (!m_frontendRouter->hasFrontends())
 | |
| +        m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectorDestroyed);
 | |
| +
 | |
| +    WebPageInspectorController::setObserver(nullptr);
 | |
| +    m_frontendChannel = nullptr;
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::dispatchMessageFromFrontend(const String& message)
 | |
| +{
 | |
| +    m_backendDispatcher->dispatch(message, [&](const RefPtr<JSON::Object>& messageObject) {
 | |
| +        RefPtr<JSON::Value> pageProxyIDValue;
 | |
| +        if (!messageObject->getValue("pageProxyId"_s, pageProxyIDValue))
 | |
| +            return BackendDispatcher::InterceptionResult::Continue;
 | |
| +
 | |
| +        String pageProxyID;
 | |
| +        if (!pageProxyIDValue->asString(pageProxyID)) {
 | |
| +            m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidRequest, "The type of 'pageProxyId' must be string"_s);
 | |
| +            m_backendDispatcher->sendPendingErrors();
 | |
| +            return BackendDispatcher::InterceptionResult::Intercepted;
 | |
| +        }
 | |
| +
 | |
| +
 | |
| +        if (auto pageProxyChannel = m_pageProxyChannels.get(pageProxyID)) {
 | |
| +            pageProxyChannel->dispatchMessageFromFrontend(message);
 | |
| +            return BackendDispatcher::InterceptionResult::Intercepted;
 | |
| +        }
 | |
| +
 | |
| +        m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidRequest, "Cannot find page proxy with provided 'pageProxyId'"_s);
 | |
| +        m_backendDispatcher->sendPendingErrors();
 | |
| +        return BackendDispatcher::InterceptionResult::Intercepted;
 | |
| +    });
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::connectToAllPages()
 | |
| +{
 | |
| +    for (auto* page : allPages())
 | |
| +        connectToPage(*page);
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::disconnectFromAllPages()
 | |
| +{
 | |
| +    for (auto it = m_pageProxyChannels.begin(); it != m_pageProxyChannels.end(); ++it)
 | |
| +        it->value->disconnect();
 | |
| +    m_pageProxyChannels.clear();
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::connectToPage(WebPageProxy& page)
 | |
| +{
 | |
| +    String pageProxyID = InspectorPlaywrightAgent::toPageProxyIDProtocolString(page);
 | |
| +    auto pageProxyChannel = makeUnique<PageProxyChannel>(*m_frontendChannel, pageProxyID, page);
 | |
| +    page.inspectorController().connectFrontend(*pageProxyChannel);
 | |
| +    // Always pause new targets if controlled remotely.
 | |
| +    page.inspectorController().setPauseOnStart(true);
 | |
| +    m_pageProxyChannels.set(pageProxyID, WTFMove(pageProxyChannel));
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::didCreateInspectorController(WebPageProxy& page)
 | |
| +{
 | |
| +    ASSERT(m_frontendChannel);
 | |
| +    // Auto-connect to all new pages.
 | |
| +    connectToPage(page);
 | |
| +    m_browserAgent->didCreateWebPageProxy(page);
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::willDestroyInspectorController(WebPageProxy& page)
 | |
| +{
 | |
| +    m_browserAgent->willDestroyWebPageProxy(page);
 | |
| +
 | |
| +    String pageProxyID = InspectorPlaywrightAgent::toPageProxyIDProtocolString(page);
 | |
| +    auto it = m_pageProxyChannels.find(pageProxyID);
 | |
| +    ASSERT(it != m_pageProxyChannels.end());
 | |
| +    it->value->disconnect();
 | |
| +    m_pageProxyChannels.remove(it);
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::didFailProvisionalLoad(WebPageProxy& page, uint64_t navigationID, const String& error)
 | |
| +{
 | |
| +    m_browserAgent->didFailProvisionalLoad(page, navigationID, error);
 | |
| +}
 | |
| +
 | |
| +void BrowserInspectorController::willCreateNewPage(WebPageProxy& page, const WebCore::WindowFeatures& features, const URL& url)
 | |
| +{
 | |
| +    m_browserAgent->willCreateNewPage(page, features, url);
 | |
| +}
 | |
| +
 | |
| +WebPageProxy* BrowserInspectorController::findPageProxy(const String& pageProxyID)
 | |
| +{
 | |
| +    if (auto* pageProxyChannel = m_pageProxyChannels.get(pageProxyID))
 | |
| +        return &pageProxyChannel->page();
 | |
| +
 | |
| +    return nullptr;
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/BrowserInspectorController.h b/Source/WebKit/UIProcess/BrowserInspectorController.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..b8e7b1c9f301c99baf62dc52ad4591b0376f00b3
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/BrowserInspectorController.h
 | |
| @@ -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.
 | |
| + */
 | |
| +
 | |
| +#pragma once
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include "InspectorPlaywrightAgent.h"
 | |
| +#include "WebPageInspectorController.h"
 | |
| +#include <JavaScriptCore/InspectorAgentRegistry.h>
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/Noncopyable.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class BackendDispatcher;
 | |
| +class FrontendChannel;
 | |
| +class FrontendRouter;
 | |
| +}
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class InspectorPlaywrightAgent;
 | |
| +class InspectorPlaywrightAgentClient;
 | |
| +
 | |
| +class BrowserInspectorController : private WebPageInspectorControllerObserver, private PageProxyIDMap {
 | |
| +    WTF_MAKE_NONCOPYABLE(BrowserInspectorController);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    BrowserInspectorController(std::unique_ptr<InspectorPlaywrightAgentClient> client);
 | |
| +    ~BrowserInspectorController();
 | |
| +
 | |
| +    void connectFrontend(Inspector::FrontendChannel&);
 | |
| +    void disconnectFrontend();
 | |
| +    void dispatchMessageFromFrontend(const String& message);
 | |
| +
 | |
| +private:
 | |
| +    class TargetHandler;
 | |
| +    class PageProxyChannel;
 | |
| +
 | |
| +    // WebPageInspectorControllerObserver
 | |
| +    void didCreateInspectorController(WebPageProxy&) override;
 | |
| +    void willDestroyInspectorController(WebPageProxy&) override;
 | |
| +    void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error) override;
 | |
| +    void willCreateNewPage(WebPageProxy&, const WebCore::WindowFeatures&, const URL&) override;
 | |
| +
 | |
| +    // PageProxyIDMap
 | |
| +    WebPageProxy* findPageProxy(const String& pageProxyID) override;
 | |
| +
 | |
| +    void connectToAllPages();
 | |
| +    void disconnectFromAllPages();
 | |
| +    void connectToPage(WebPageProxy&);
 | |
| +
 | |
| +    Inspector::FrontendChannel* m_frontendChannel { nullptr };
 | |
| +    Ref<Inspector::FrontendRouter> m_frontendRouter;
 | |
| +    Ref<Inspector::BackendDispatcher> m_backendDispatcher;
 | |
| +    std::unique_ptr<InspectorPlaywrightAgentClient> m_browserAgentClient;
 | |
| +    Inspector::AgentRegistry m_agents;
 | |
| +    InspectorPlaywrightAgent* m_browserAgent { nullptr };
 | |
| +    HashMap<String, std::unique_ptr<PageProxyChannel>> m_pageProxyChannels;
 | |
| +};
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/BrowserInspectorPipe.cpp b/Source/WebKit/UIProcess/BrowserInspectorPipe.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..e07123453ecab2611ff4918cec37ee6e744a23a6
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/BrowserInspectorPipe.cpp
 | |
| @@ -0,0 +1,57 @@
 | |
| +/*
 | |
| + * 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 "BrowserInspectorPipe.h"
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include "BrowserInspectorController.h"
 | |
| +#include "RemoteInspectorPipe.h"
 | |
| +#include <wtf/NeverDestroyed.h>
 | |
| +#include "InspectorPlaywrightAgentClient.h"
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void initializeBrowserInspectorPipe(std::unique_ptr<InspectorPlaywrightAgentClient> client)
 | |
| +{
 | |
| +    class BrowserInspectorPipe {
 | |
| +    public:
 | |
| +        BrowserInspectorPipe(std::unique_ptr<InspectorPlaywrightAgentClient> client)
 | |
| +            : m_browserInspectorController(std::move(client))
 | |
| +            , m_remoteInspectorPipe(m_browserInspectorController)
 | |
| +        {
 | |
| +        }
 | |
| +
 | |
| +        BrowserInspectorController m_browserInspectorController;
 | |
| +        RemoteInspectorPipe m_remoteInspectorPipe;
 | |
| +    };
 | |
| +
 | |
| +    static NeverDestroyed<BrowserInspectorPipe> pipe(std::move(client));
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/BrowserInspectorPipe.h b/Source/WebKit/UIProcess/BrowserInspectorPipe.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..cd66887de171cda7d15a8e4dc6dbff63665dc619
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/BrowserInspectorPipe.h
 | |
| @@ -0,0 +1,38 @@
 | |
| +/*
 | |
| + * 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)
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class InspectorPlaywrightAgentClient;
 | |
| +
 | |
| +void initializeBrowserInspectorPipe(std::unique_ptr<InspectorPlaywrightAgentClient> client);
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm b/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
 | |
| index d96a0ef4f017b9b5052f9372a49522b038ba4e84..43777025804c5b6b8d84e57c889330fef0f87edd 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
 | |
| @@ -36,7 +36,7 @@ namespace WebKit {
 | |
|  
 | |
|  PageClientImplCocoa::PageClientImplCocoa(WKWebView *webView)
 | |
|      : m_webView { webView }
 | |
| -    , m_alternativeTextUIController { makeUnique<AlternativeTextUIController>() }
 | |
| +    , m_alternativeTextUIController { makeUnique<WebCore::AlternativeTextUIController>() }
 | |
|  {
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h
 | |
| index 454c61ffdefecc476d1560c7c43f5b5d345f281d..6de7509037b7683ddd403ee247bdf2845ce4e87a 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h
 | |
| @@ -27,6 +27,8 @@
 | |
|  
 | |
|  #if HAVE(APP_SSO)
 | |
|  
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/CompletionHandler.h>
 | |
|  #include "SOAuthorizationSession.h"
 | |
|  #include <wtf/CompletionHandler.h>
 | |
|  
 | |
| @@ -39,6 +41,8 @@ class NavigationAction;
 | |
|  
 | |
|  namespace WebKit {
 | |
|  
 | |
| +class WebPageProxy;
 | |
| +
 | |
|  // FSM: Idle => Active => Completed
 | |
|  class PopUpSOAuthorizationSession final : public SOAuthorizationSession {
 | |
|  public:
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm
 | |
| index 0f18038de989e69a8432c85b71b6c04e931302b3..82a966779403346aed174dcfcd01a79691956d7b 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm
 | |
| @@ -29,6 +29,7 @@
 | |
|  #if HAVE(APP_SSO)
 | |
|  
 | |
|  #import "APINavigationAction.h"
 | |
| +#import "WebPageProxy.h"
 | |
|  #import "WKNavigationDelegatePrivate.h"
 | |
|  #import "WKUIDelegate.h"
 | |
|  #import "WKWebViewConfigurationPrivate.h"
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h b/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
 | |
| index 206246741e96e5d454d2a41e66399980426ebfe1..6f21ff815e22fe3c419911a28a09f901184a5f63 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
 | |
| @@ -91,6 +91,7 @@ private:
 | |
|          void runJavaScriptAlert(WebPageProxy&, const WTF::String&, WebFrameProxy*, FrameInfoData&&, Function<void()>&& completionHandler) final;
 | |
|          void runJavaScriptConfirm(WebPageProxy&, const WTF::String&, WebFrameProxy*, FrameInfoData&&, Function<void(bool)>&& completionHandler) final;
 | |
|          void runJavaScriptPrompt(WebPageProxy&, const WTF::String&, const WTF::String&, WebFrameProxy*, FrameInfoData&&, Function<void(const WTF::String&)>&&) final;
 | |
| +        void handleJavaScriptDialog(WebKit::WebPageProxy&, bool accept, const WTF::String&) final;
 | |
|          void presentStorageAccessConfirmDialog(const WTF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&&);
 | |
|          void requestStorageAccessConfirm(WebPageProxy&, WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&&) final;
 | |
|          void decidePolicyForGeolocationPermissionRequest(WebPageProxy&, WebFrameProxy&, const FrameInfoData&, Function<void(bool)>&) final;
 | |
| @@ -170,6 +171,7 @@ private:
 | |
|          bool webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler : 1;
 | |
|          bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
 | |
|          bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
 | |
| +        bool webViewHandleJavaScriptDialogValue : 1;
 | |
|          bool webViewRequestStorageAccessPanelUnderFirstPartyCompletionHandler : 1;
 | |
|          bool webViewRunBeforeUnloadConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
 | |
|          bool webViewRequestGeolocationPermissionForFrameDecisionHandler : 1;
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm b/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
 | |
| index 39bdcacbca56ab9969da677d6def85e9cd1424d3..e5571ee1e30f1d0c60d60af52640aaf6a4a9e697 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
 | |
| @@ -99,6 +99,7 @@ void UIDelegate::setDelegate(id <WKUIDelegate> delegate)
 | |
|      m_delegateMethods.webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)];
 | |
|      m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
 | |
|      m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
 | |
| +    m_delegateMethods.webViewHandleJavaScriptDialogValue = [delegate respondsToSelector:@selector(webView:handleJavaScriptDialog:value:)];
 | |
|      m_delegateMethods.webViewRequestStorageAccessPanelUnderFirstPartyCompletionHandler = [delegate respondsToSelector:@selector(_webView:requestStorageAccessPanelForDomain:underCurrentDomain:completionHandler:)];
 | |
|      m_delegateMethods.webViewRunBeforeUnloadConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(_webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
 | |
|      m_delegateMethods.webViewRequestGeolocationPermissionForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestGeolocationPermissionForFrame:decisionHandler:)];
 | |
| @@ -336,6 +337,15 @@ void UIDelegate::UIClient::runJavaScriptPrompt(WebPageProxy& page, const WTF::St
 | |
|      }).get()];
 | |
|  }
 | |
|  
 | |
| +void UIDelegate::UIClient::handleJavaScriptDialog(WebKit::WebPageProxy&, bool accept, const WTF::String& value) {
 | |
| +    if (!m_uiDelegate.m_delegateMethods.webViewHandleJavaScriptDialogValue)
 | |
| +        return;
 | |
| +    auto delegate = m_uiDelegate.m_delegate.get();
 | |
| +    if (!delegate)
 | |
| +        return;
 | |
| +    [delegate webView:m_uiDelegate.m_webView handleJavaScriptDialog:accept value:value];
 | |
| +}
 | |
| +
 | |
|  void UIDelegate::UIClient::requestStorageAccessConfirm(WebPageProxy&, WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&& completionHandler)
 | |
|  {
 | |
|      auto delegate = m_uiDelegate.m_delegate.get();
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm b/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
 | |
| index 3060a62f2eee2c87da4f7050c176a58e4a3b237f..1e9aff10ae6dfe7e74b36b5b336b75e8195e94fa 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
 | |
| @@ -373,7 +373,7 @@ void WebProcessPool::platformInitializeWebProcess(const WebProcessProxy& process
 | |
|      auto screenProperties = WebCore::collectScreenProperties();
 | |
|      parameters.screenProperties = WTFMove(screenProperties);
 | |
|  #if PLATFORM(MAC)
 | |
| -    parameters.useOverlayScrollbars = ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay);
 | |
| +    parameters.useOverlayScrollbars = m_configuration->forceOverlayScrollbars() || ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay);
 | |
|  #endif
 | |
|      
 | |
|  #if PLATFORM(IOS)
 | |
| @@ -687,8 +687,8 @@ void WebProcessPool::registerNotificationObservers()
 | |
|  
 | |
|  #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
 | |
|      m_scrollerStyleNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSPreferredScrollerStyleDidChangeNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
 | |
| -        auto scrollbarStyle = [NSScroller preferredScrollerStyle];
 | |
| -        sendToAllProcesses(Messages::WebProcess::ScrollerStylePreferenceChanged(scrollbarStyle));
 | |
| +        bool useOverlayScrollbars = m_configuration->forceOverlayScrollbars() || ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay);
 | |
| +        sendToAllProcesses(Messages::WebProcess::ScrollerStylePreferenceChanged(useOverlayScrollbars));
 | |
|      }];
 | |
|  #endif
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
 | |
| index d8f25b7ed5194616f064f5e2e1c3ec81490608b3..54048e141a5c23186191718f91fad219d66dbfe6 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
 | |
| @@ -478,6 +478,9 @@ public:
 | |
|      void provideDataForPasteboard(NSPasteboard *, NSString *type);
 | |
|      NSArray *namesOfPromisedFilesDroppedAtDestination(NSURL *dropDestination);
 | |
|  
 | |
| +// Paywright begin
 | |
| +    RetainPtr<CGImageRef> takeSnapshotForAutomation();
 | |
| +// Paywright end
 | |
|      RefPtr<ViewSnapshot> takeViewSnapshot();
 | |
|      void saveBackForwardSnapshotForCurrentItem();
 | |
|      void saveBackForwardSnapshotForItem(WebBackForwardListItem&);
 | |
| diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
 | |
| index ba70fbe27d2e5e0010ae02e1a1af37fbf8f1eda1..8a37bd4ea0fe1e9d4a388556106b7a8819ff4a09 100644
 | |
| --- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
 | |
| +++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
 | |
| @@ -4404,6 +4404,18 @@ static RetainPtr<CGImageRef> takeWindowSnapshot(CGSWindowID windowID, bool captu
 | |
|      return adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions));
 | |
|  }
 | |
|  
 | |
| +// Paywright begin
 | |
| +RetainPtr<CGImageRef> WebViewImpl::takeSnapshotForAutomation() {
 | |
| +    NSWindow *window = [m_view window];
 | |
| +
 | |
| +    CGSWindowID windowID = (CGSWindowID)window.windowNumber;
 | |
| +    if (!windowID || !window.isVisible)
 | |
| +        return nullptr;
 | |
| +
 | |
| +    return takeWindowSnapshot(windowID, false);
 | |
| +}
 | |
| +// Paywright end
 | |
| +
 | |
|  RefPtr<ViewSnapshot> WebViewImpl::takeViewSnapshot()
 | |
|  {
 | |
|      NSWindow *window = [m_view window];
 | |
| diff --git a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp
 | |
| index 6bbd1cabd27ae2847648a8c2edcf9acfcd556ff5..38d101b9a96986e40f6e9f0261fa429a3d516e2e 100644
 | |
| --- a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp
 | |
| +++ b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp
 | |
| @@ -37,6 +37,7 @@
 | |
|  #include "WebProcessProxy.h"
 | |
|  #include <WebCore/PlatformDisplay.h>
 | |
|  #include <WebCore/Region.h>
 | |
| +#include <wtf/Vector.h>
 | |
|  
 | |
|  #if PLATFORM(GTK)
 | |
|  #include <gtk/gtk.h>
 | |
| @@ -119,6 +120,10 @@ void DrawingAreaProxyCoordinatedGraphics::paint(BackingStore::PlatformGraphicsCo
 | |
|  
 | |
|  void DrawingAreaProxyCoordinatedGraphics::sizeDidChange()
 | |
|  {
 | |
| +    for (auto& value : m_callbacks)
 | |
| +        value();
 | |
| +    m_callbacks.clear();
 | |
| +
 | |
|  #if USE(DIRECT2D)
 | |
|      m_backingStore = nullptr;
 | |
|  #endif
 | |
| @@ -133,6 +138,11 @@ void DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange()
 | |
|      backingStoreStateDidChange(RespondImmediately);
 | |
|  }
 | |
|  
 | |
| +void DrawingAreaProxyCoordinatedGraphics::waitForSizeUpdate(Function<void ()>&& callback)
 | |
| +{
 | |
| +    m_callbacks.append(WTFMove(callback));
 | |
| +}
 | |
| +
 | |
|  void DrawingAreaProxyCoordinatedGraphics::waitForBackingStoreUpdateOnNextPaint()
 | |
|  {
 | |
|      m_hasReceivedFirstUpdate = true;
 | |
| diff --git a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h
 | |
| index d7695088e7cfc4f638f157338754f9f157489749..ba114d47ac079661702e44f19853398f5c1d6b55 100644
 | |
| --- a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h
 | |
| +++ b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h
 | |
| @@ -30,6 +30,7 @@
 | |
|  #include "BackingStore.h"
 | |
|  #include "DrawingAreaProxy.h"
 | |
|  #include "LayerTreeContext.h"
 | |
| +#include <wtf/HashMap.h>
 | |
|  #include <wtf/RunLoop.h>
 | |
|  
 | |
|  namespace WebCore {
 | |
| @@ -49,6 +50,7 @@ public:
 | |
|  
 | |
|      bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
 | |
|      const LayerTreeContext& layerTreeContext() const { return m_layerTreeContext; }
 | |
| +    void waitForSizeUpdate(Function<void ()>&&);
 | |
|  
 | |
|  private:
 | |
|      // DrawingAreaProxy
 | |
| @@ -126,6 +128,8 @@ private:
 | |
|      // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
 | |
|      bool m_hasReceivedFirstUpdate { false };
 | |
|  
 | |
| +    Vector<Function<void ()>> m_callbacks;
 | |
| +
 | |
|  #if !PLATFORM(WPE)
 | |
|      bool m_isBackingStoreDiscardable { true };
 | |
|      std::unique_ptr<BackingStore> m_backingStore;
 | |
| diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
 | |
| index 592fa4c4d9a45eb1e9b95e0cdabc8d404b40018d..e7889c60fffb8979ee3965295b3221989ea48e05 100644
 | |
| --- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
 | |
| +++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
 | |
| @@ -42,8 +42,10 @@
 | |
|  #include <WebCore/MIMETypeRegistry.h>
 | |
|  #include <WebCore/ResourceResponseBase.h>
 | |
|  #include <wtf/FileSystem.h>
 | |
| +#include <wtf/NeverDestroyed.h>
 | |
|  #include <wtf/text/CString.h>
 | |
|  #include <wtf/text/WTFString.h>
 | |
| +#include <wtf/UUID.h>
 | |
|  
 | |
|  namespace WebKit {
 | |
|  using namespace WebCore;
 | |
| @@ -62,7 +64,10 @@ DownloadProxy::DownloadProxy(DownloadProxyMap& downloadProxyMap, WebsiteDataStor
 | |
|      , m_request(resourceRequest)
 | |
|      , m_originatingPage(makeWeakPtr(originatingPage))
 | |
|      , m_frameInfo(API::FrameInfo::create(FrameInfoData { frameInfoData }, originatingPage))
 | |
| +    , m_uuid(createCanonicalUUIDString())
 | |
|  {
 | |
| +    if (auto* instrumentation = m_dataStore->downloadInstrumentation())
 | |
| +      instrumentation->downloadCreated(m_uuid, m_request, frameInfoData, originatingPage);
 | |
|  }
 | |
|  
 | |
|  DownloadProxy::~DownloadProxy()
 | |
| @@ -178,7 +183,21 @@ void DownloadProxy::decideDestinationWithSuggestedFilenameAsync(DownloadID downl
 | |
|  {
 | |
|      if (!m_processPool)
 | |
|          return;
 | |
| -    
 | |
| +
 | |
| +    if (auto* instrumentation = m_dataStore->downloadInstrumentation())
 | |
| +      instrumentation->downloadFilenameSuggested(m_uuid, suggestedFilename);
 | |
| +
 | |
| +    if (m_processPool->networkProcess() && m_dataStore->allowDownloadForAutomation()) {
 | |
| +        SandboxExtension::Handle sandboxExtensionHandle;
 | |
| +        String destination;
 | |
| +        if (*m_dataStore->allowDownloadForAutomation()) {
 | |
| +            destination = FileSystem::pathByAppendingComponent(m_dataStore->downloadPathForAutomation(), m_uuid);
 | |
| +            SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
 | |
| +        }
 | |
| +        m_processPool->networkProcess()->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, true), 0);
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*this, ResourceResponseBase::sanitizeSuggestedFilename(suggestedFilename), [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) {
 | |
|          SandboxExtension::Handle sandboxExtensionHandle;
 | |
|          if (!destination.isNull())
 | |
| @@ -206,6 +225,8 @@ void DownloadProxy::didFinish()
 | |
|          return;
 | |
|  
 | |
|      m_processPool->downloadClient().didFinish(*this);
 | |
| +    if (auto* instrumentation = m_dataStore->downloadInstrumentation())
 | |
| +      instrumentation->downloadFinished(m_uuid, String());
 | |
|  
 | |
|      // This can cause the DownloadProxy object to be deleted.
 | |
|      m_downloadProxyMap.downloadFinished(*this);
 | |
| @@ -227,6 +248,8 @@ void DownloadProxy::didFail(const ResourceError& error, const IPC::DataReference
 | |
|      m_resumeData = createData(resumeData);
 | |
|  
 | |
|      m_processPool->downloadClient().didFail(*this, error);
 | |
| +    if (auto* instrumentation = m_dataStore->downloadInstrumentation())
 | |
| +      instrumentation->downloadFinished(m_uuid, error.localizedDescription());
 | |
|  
 | |
|      // This can cause the DownloadProxy object to be deleted.
 | |
|      m_downloadProxyMap.downloadFinished(*this);
 | |
| @@ -237,6 +260,8 @@ void DownloadProxy::didCancel(const IPC::DataReference& resumeData)
 | |
|      m_resumeData = createData(resumeData);
 | |
|  
 | |
|      m_processPool->downloadClient().didCancel(*this);
 | |
| +    if (auto* instrumentation = m_dataStore->downloadInstrumentation())
 | |
| +      instrumentation->downloadFinished(m_uuid, "canceled"_s);
 | |
|  
 | |
|      // This can cause the DownloadProxy object to be deleted.
 | |
|      m_downloadProxyMap.downloadFinished(*this);
 | |
| diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.h b/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
 | |
| index a0ccbe0663c3c126437704bcc8f91b4724ccca9f..5d52ca9048562410c686c6fb30a0fae654bbb6db 100644
 | |
| --- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
 | |
| +++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
 | |
| @@ -141,6 +141,7 @@ private:
 | |
|      Vector<URL> m_redirectChain;
 | |
|      bool m_wasUserInitiated { true };
 | |
|      Ref<API::FrameInfo> m_frameInfo;
 | |
| +    String m_uuid;
 | |
|  };
 | |
|  
 | |
|  } // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/DrawingAreaProxy.h b/Source/WebKit/UIProcess/DrawingAreaProxy.h
 | |
| index 59cdfdafab1d85ea3a5aecb3cd2293e6dfb1eb8d..52fe7990b1c18b964ee3cfa9f324e3c2875eefe9 100644
 | |
| --- a/Source/WebKit/UIProcess/DrawingAreaProxy.h
 | |
| +++ b/Source/WebKit/UIProcess/DrawingAreaProxy.h
 | |
| @@ -75,6 +75,7 @@ public:
 | |
|  
 | |
|      const WebCore::IntSize& size() const { return m_size; }
 | |
|      bool setSize(const WebCore::IntSize&, const WebCore::IntSize& scrollOffset = { });
 | |
| +    void waitForSizeUpdate(Function<void ()>&&);
 | |
|  
 | |
|  #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
 | |
|      // The timeout we use when waiting for a DidUpdateGeometry message.
 | |
| diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..f301bc4d2782a4ba1deca8bb59da46c00ae09896
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp
 | |
| @@ -0,0 +1,206 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "InspectorScreencastAgent.h"
 | |
| +
 | |
| +#include "PageClient.h"
 | |
| +#include "WebAutomationSession.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <JavaScriptCore/InspectorFrontendDispatchers.h>
 | |
| +#include <JavaScriptCore/InspectorFrontendRouter.h>
 | |
| +#include <WebCore/NotImplemented.h>
 | |
| +
 | |
| +#if PLATFORM(GTK)
 | |
| +#include <WebCore/ImageBufferUtilitiesCairo.h>
 | |
| +#include <gtk/gtk.h>
 | |
| +#include <wtf/text/Base64.h>
 | |
| +#endif
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +InspectorScreencastAgent::InspectorScreencastAgent(BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page)
 | |
| +    : InspectorAgentBase("Screencast"_s)
 | |
| +    , m_frontendDispatcher(makeUnique<ScreencastFrontendDispatcher>(frontendRouter))
 | |
| +    , m_backendDispatcher(ScreencastBackendDispatcher::create(backendDispatcher, this))
 | |
| +    , m_page(page)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +InspectorScreencastAgent::~InspectorScreencastAgent()
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::willDestroyFrontendAndBackend(DisconnectReason)
 | |
| +{
 | |
| +    ErrorString errorString;
 | |
| +    stop(errorString);
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::start(Inspector::ErrorString& errorString, const String& format, const int* quality)
 | |
| +{
 | |
| +    if (m_enabled)
 | |
| +        return;
 | |
| +
 | |
| +    if (format == "jpeg") {
 | |
| +        m_format = ImageFormat::Jpeg;
 | |
| +    } else if (format == "png") {
 | |
| +        m_format = ImageFormat::Png;
 | |
| +    } else {
 | |
| +        errorString = "Unsupported format."_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    if (quality && (*quality < 0 || *quality >100)) {
 | |
| +        errorString = "Unsupported quality."_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    m_enabled = true;
 | |
| +    if (quality)
 | |
| +        m_quality = *quality;
 | |
| +    fprintf(stderr, "InspectorScreencastAgent::start %p\n", this);
 | |
| +#if PLATFORM(GTK)
 | |
| +    g_signal_connect_swapped(m_page.viewWidget(), "draw", reinterpret_cast<GCallback>(InspectorScreencastAgent::webViewDrawCallback), this);
 | |
| +#else
 | |
| +    scheduleSnapshot();
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::stop(Inspector::ErrorString&)
 | |
| +{
 | |
| +    if (!m_enabled)
 | |
| +        return;
 | |
| +
 | |
| +    m_enabled = false;
 | |
| +    m_inflightFrames = 0;
 | |
| +    m_quality = WTF::nullopt;
 | |
| +#if PLATFORM(GTK)
 | |
| +    g_signal_handlers_disconnect_by_func(m_page.viewWidget(), reinterpret_cast<gpointer>(InspectorScreencastAgent::webViewDrawCallback), this);
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::frameAck(Inspector::ErrorString& errorString)
 | |
| +{
 | |
| +    fprintf(stderr, "InspectorScreencastAgent::frameAck m_inflightFrames=%d\n", m_inflightFrames);
 | |
| +    if (!m_inflightFrames) {
 | |
| +        errorString = "No inflight frames to ack"_s;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    --m_inflightFrames;
 | |
| +#if !PLATFORM(GTK)
 | |
| +    scheduleSnapshot();
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::scheduleSnapshot()
 | |
| +{
 | |
| +    if (!m_enabled)
 | |
| +        return;
 | |
| +
 | |
| +    fprintf(stderr, "InspectorScreencastAgent::scheduleSnapshot m_inflightFrames=%d\n", m_inflightFrames);
 | |
| +
 | |
| +    m_page.callAfterNextPresentationUpdate([agent = makeWeakPtr(this)](CallbackBase::Error error) mutable {
 | |
| +        fprintf(stderr, "callAfterNextPresentationUpdate 1 error= %d\n", error);
 | |
| +        if (!agent)
 | |
| +            return;
 | |
| +
 | |
| +        fprintf(stderr, "callAfterNextPresentationUpdate 2 error= %d\n", error);
 | |
| +        if (error == CallbackBase::Error::None) {
 | |
| +            agent->takeSnapshot();
 | |
| +        } else {
 | |
| +            fprintf(stderr, "callAfterNextPresentationUpdate error= %d\n", error);
 | |
| +        }
 | |
| +        agent->scheduleSnapshot();
 | |
| +        fprintf(stderr, "callAfterNextPresentationUpdate 3 error= %d\n", error);
 | |
| +    });
 | |
| +}
 | |
| +
 | |
| +void InspectorScreencastAgent::takeSnapshot()
 | |
| +{
 | |
| +    if (!m_enabled)
 | |
| +        return;
 | |
| +
 | |
| +    if (m_inflightFrames > 2)
 | |
| +        return;
 | |
| +
 | |
| +    String snapshot = platformTakeSnapshot();
 | |
| +    ++m_inflightFrames;
 | |
| +    m_frontendDispatcher->frame(snapshot);
 | |
| +}
 | |
| +
 | |
| +#if PLATFORM(GTK)
 | |
| +gboolean InspectorScreencastAgent::webViewDrawCallback(InspectorScreencastAgent* agent)
 | |
| +{
 | |
| +    agent->takeSnapshot();
 | |
| +    // Let default handler draw on the screen.
 | |
| +    return FALSE;
 | |
| +}
 | |
| +
 | |
| +String InspectorScreencastAgent::platformTakeSnapshot()
 | |
| +{
 | |
| +    auto viewSnapshot = m_page.takeViewSnapshot(WTF::nullopt);
 | |
| +    if (!viewSnapshot) {
 | |
| +        fprintf(stderr, "   takeViewSnapshot failed\n");
 | |
| +        return String();
 | |
| +    }
 | |
| +
 | |
| +    String format;
 | |
| +    switch (m_format) {
 | |
| +    case ImageFormat::Jpeg:
 | |
| +        format = "image/jpeg";
 | |
| +        break;
 | |
| +    case ImageFormat::Png:
 | |
| +        format = "image/png";
 | |
| +        break;
 | |
| +    };
 | |
| +
 | |
| +    Optional<double> quality;
 | |
| +    if (m_quality)
 | |
| +        quality = *m_quality / 100.0;
 | |
| +
 | |
| +    Vector<uint8_t> data = WebCore::data(viewSnapshot->surface(), format, quality);
 | |
| +    return base64Encode(data);
 | |
| +}
 | |
| +
 | |
| +#elif PLATFORM(COCOA)
 | |
| +// in its own file
 | |
| +#else
 | |
| +String InspectorScreencastAgent::platformTakeSnapshot()
 | |
| +{
 | |
| +    // WPE and Windows implementation lives in the Web Process.
 | |
| +    notImplemented();
 | |
| +    return String();
 | |
| +}
 | |
| +#endif
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..a1d8892da8bebd48346a4ccb9e9836dab9da7909
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h
 | |
| @@ -0,0 +1,78 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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
 | |
| +
 | |
| +#include <JavaScriptCore/InspectorAgentBase.h>
 | |
| +#include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| +
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/Noncopyable.h>
 | |
| +#include <wtf/WeakPtr.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class BackendDispatcher;
 | |
| +class FrontendChannel;
 | |
| +class FrontendRouter;
 | |
| +class ScreencastFrontendDispatcher;
 | |
| +}
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class WebPageProxy;
 | |
| +
 | |
| +class InspectorScreencastAgent : public Inspector::InspectorAgentBase, public Inspector::ScreencastBackendDispatcherHandler, public CanMakeWeakPtr<InspectorScreencastAgent> {
 | |
| +    WTF_MAKE_NONCOPYABLE(InspectorScreencastAgent);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorScreencastAgent(Inspector::BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page);
 | |
| +    ~InspectorScreencastAgent() override;
 | |
| +
 | |
| +    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
 | |
| +    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
 | |
| +
 | |
| +    void start(Inspector::ErrorString&, const String& format, const int* quality) override;
 | |
| +    void stop(Inspector::ErrorString&) override;
 | |
| +    void frameAck(Inspector::ErrorString&) override;
 | |
| +
 | |
| +private:
 | |
| +#if PLATFORM(GTK)
 | |
| +    static gboolean webViewDrawCallback(InspectorScreencastAgent*);
 | |
| +#endif
 | |
| +    void scheduleSnapshot();
 | |
| +    void takeSnapshot();
 | |
| +    String platformTakeSnapshot();
 | |
| +
 | |
| +    std::unique_ptr<Inspector::ScreencastFrontendDispatcher> m_frontendDispatcher;
 | |
| +    Ref<Inspector::ScreencastBackendDispatcher> m_backendDispatcher;
 | |
| +    WebPageProxy& m_page;
 | |
| +    bool m_enabled { false };
 | |
| +    int m_inflightFrames { 0 };
 | |
| +    enum class ImageFormat { Jpeg, Png };
 | |
| +    ImageFormat m_format { ImageFormat::Jpeg };
 | |
| +    Optional<int> m_quality;
 | |
| +};
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp
 | |
| index 6928ca2fbfb6939062e3cd14bb7ba6f2fdc87f5f..621b99e233ed5cf504fedbd3ca3209c03bcd611f 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 "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)
 | |
|  {
 | |
| @@ -97,6 +95,31 @@ void InspectorTargetProxy::didCommitProvisionalTarget()
 | |
|      m_provisionalPage = nullptr;
 | |
|  }
 | |
|  
 | |
| +void InspectorTargetProxy::willResume()
 | |
| +{
 | |
| +    if (m_page.hasRunningProcess())
 | |
| +        m_page.send(Messages::WebPage::ResumeInspectorIfPausedInNewWindow());
 | |
| +}
 | |
| +
 | |
| +void InspectorTargetProxy::activate(String& error)
 | |
| +{
 | |
| +    if (m_type != Inspector::InspectorTargetType::Page)
 | |
| +        return InspectorTarget::activate(error);
 | |
| +
 | |
| +    platformActivate(error);
 | |
| +}
 | |
| +
 | |
| +void InspectorTargetProxy::close(String& error, bool runBeforeUnload)
 | |
| +{
 | |
| +    if (m_type != Inspector::InspectorTargetType::Page)
 | |
| +        return InspectorTarget::close(error, runBeforeUnload);
 | |
| +
 | |
| +    if (runBeforeUnload)
 | |
| +        m_page.tryClose();
 | |
| +    else
 | |
| +        m_page.closePage();
 | |
| +}
 | |
| +
 | |
|  bool InspectorTargetProxy::isProvisional() const
 | |
|  {
 | |
|      return !!m_provisionalPage;
 | |
| diff --git a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.h b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.h
 | |
| index a2239cec8e18850f35f7f88a9c4ebadc62bf4023..79f3ff84327dc075ec96983e04db4b10343b7fae 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; }
 | |
| @@ -55,12 +55,17 @@ public:
 | |
|      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 willResume() override;
 | |
| +    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 1861cff806131196ea49b4f8aca6665beebbf6e8..57cb5bd0a6916b00da01af17b743da9e04094a77 100644
 | |
| --- a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
 | |
| +++ b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
 | |
| @@ -26,12 +26,20 @@
 | |
|  #include "config.h"
 | |
|  #include "WebPageInspectorController.h"
 | |
|  
 | |
| +#include "APINavigation.h"
 | |
|  #include "InspectorBrowserAgent.h"
 | |
| +#include "InspectorDialogAgent.h"
 | |
| +#include "InspectorScreencastAgent.h"
 | |
|  #include "ProvisionalPageProxy.h"
 | |
|  #include "WebFrameProxy.h"
 | |
|  #include "WebPageInspectorAgentBase.h"
 | |
| +#include "WebPageInspectorEmulationAgent.h"
 | |
| +#include "WebPageInspectorInputAgent.h"
 | |
|  #include "WebPageInspectorTarget.h"
 | |
|  #include "WebPageProxy.h"
 | |
| +#include "WebPreferences.h"
 | |
| +#include <WebCore/ResourceError.h>
 | |
| +#include <WebCore/WindowFeatures.h>
 | |
|  #include <JavaScriptCore/InspectorAgentBase.h>
 | |
|  #include <JavaScriptCore/InspectorBackendDispatcher.h>
 | |
|  #include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| @@ -48,27 +56,104 @@ 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_frontendRouter(FrontendRouter::create())
 | |
|      , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))
 | |
|      , m_page(page)
 | |
|  {
 | |
| -    auto targetAgent = makeUnique<InspectorTargetAgent>(m_frontendRouter.get(), m_backendDispatcher.get());
 | |
| -    m_targetAgent = targetAgent.get();
 | |
| -    m_agents.append(WTFMove(targetAgent));
 | |
|  }
 | |
|  
 | |
|  void WebPageInspectorController::init()
 | |
|  {
 | |
| +    auto targetAgent = makeUnique<InspectorTargetAgent>(m_frontendRouter.get(), m_backendDispatcher.get());
 | |
| +    m_targetAgent = targetAgent.get();
 | |
| +    m_agents.append(WTFMove(targetAgent));
 | |
| +    auto emulationAgent = makeUnique<WebPageInspectorEmulationAgent>(m_backendDispatcher.get(), m_page);
 | |
| +    m_emulationAgent = emulationAgent.get();
 | |
| +    m_agents.append(WTFMove(emulationAgent));
 | |
| +    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));
 | |
| +#if !PLATFORM(WPE) && !PLATFORM(WIN)
 | |
| +    m_agents.append(makeUnique<InspectorScreencastAgent>(m_backendDispatcher.get(), m_frontendRouter.get(), m_page));
 | |
| +#endif
 | |
| +    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);
 | |
| +}
 | |
| +
 | |
|  void WebPageInspectorController::pageClosed()
 | |
|  {
 | |
| +    String pageTargetId = WebPageInspectorTarget::toTargetID(m_page.webPageID());
 | |
| +    destroyInspectorTarget(pageTargetId);
 | |
| +
 | |
|      disconnectAllFrontends();
 | |
|  
 | |
|      m_agents.discardValues();
 | |
| +
 | |
| +    if (s_observer)
 | |
| +        s_observer->willDestroyInspectorController(m_page);
 | |
| +}
 | |
| +
 | |
| +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);
 | |
| +
 | |
| +    return m_targetAgent->isConnected();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::willCreateNewPage(const WebCore::WindowFeatures& features, const URL& url)
 | |
| +{
 | |
| +    if (s_observer)
 | |
| +        s_observer->willCreateNewPage(m_page, features, url);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::didShowPage()
 | |
| +{
 | |
| +    if (m_frontendRouter->hasFrontends())
 | |
| +        m_emulationAgent->didShowPage();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::didProcessAllPendingKeyboardEvents()
 | |
| +{
 | |
| +    if (m_frontendRouter->hasFrontends())
 | |
| +        m_inputAgent->didProcessAllPendingKeyboardEvents();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::didProcessAllPendingMouseEvents()
 | |
| +{
 | |
| +    if (m_frontendRouter->hasFrontends())
 | |
| +        m_inputAgent->didProcessAllPendingMouseEvents();
 | |
|  }
 | |
|  
 | |
|  bool WebPageInspectorController::hasLocalFrontend() const
 | |
| @@ -82,6 +167,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;
 | |
| +    }
 | |
| +
 | |
| +    if (connectingFirstFrontend)
 | |
| +        adjustPageSettings();
 | |
| +
 | |
|      m_frontendRouter->connectFrontend(frontendChannel);
 | |
|  
 | |
|      if (connectingFirstFrontend)
 | |
| @@ -100,8 +196,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());
 | |
|  
 | |
| @@ -124,6 +222,8 @@ void WebPageInspectorController::disconnectAllFrontends()
 | |
|      // Disconnect any remaining remote frontends.
 | |
|      m_frontendRouter->disconnectAllFrontends();
 | |
|  
 | |
| +    m_pendingNavigations.clear();
 | |
| +
 | |
|      m_page.didChangeInspectorFrontendCount(m_frontendRouter->frontendCount());
 | |
|  
 | |
|  #if ENABLE(REMOTE_INSPECTOR)
 | |
| @@ -150,6 +250,55 @@ void WebPageInspectorController::setIndicating(bool indicating)
 | |
|  }
 | |
|  #endif
 | |
|  
 | |
| +void WebPageInspectorController::navigate(WebCore::ResourceRequest&& request, WebFrameProxy* frame, NavigationHandler&& completionHandler)
 | |
| +{
 | |
| +    auto navigation = m_page.loadRequestForInspector(WTFMove(request), frame);
 | |
| +    if (!navigation) {
 | |
| +        completionHandler("Failed to navigate"_s, 0);
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    m_pendingNavigations.set(navigation->navigationID(), WTFMove(completionHandler));
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::didReceivePolicyDecision(WebCore::PolicyAction action, uint64_t navigationID)
 | |
| +{
 | |
| +    if (!m_frontendRouter->hasFrontends())
 | |
| +        return;
 | |
| +
 | |
| +    if (!navigationID)
 | |
| +        return;
 | |
| +
 | |
| +    auto completionHandler = m_pendingNavigations.take(navigationID);
 | |
| +    if (!completionHandler)
 | |
| +        return;
 | |
| +
 | |
| +    if (action == WebCore::PolicyAction::Ignore)
 | |
| +        completionHandler("Navigation cancelled"_s, 0);
 | |
| +    else
 | |
| +        completionHandler(String(), navigationID);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::didDestroyNavigation(uint64_t navigationID)
 | |
| +{
 | |
| +    if (!m_frontendRouter->hasFrontends())
 | |
| +        return;
 | |
| +
 | |
| +    auto completionHandler = m_pendingNavigations.take(navigationID);
 | |
| +    if (!completionHandler)
 | |
| +        return;
 | |
| +
 | |
| +    // Inspector initiated navigation is destroyed before policy check only when it
 | |
| +    // becomes a fragment navigation (which always reuses current navigation).
 | |
| +    completionHandler(String(), 0);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::didFailProvisionalLoadForFrame(uint64_t navigationID, const WebCore::ResourceError& error)
 | |
| +{
 | |
| +    if (s_observer)
 | |
| +        s_observer->didFailProvisionalLoad(m_page, navigationID, error.localizedDescription());
 | |
| +}
 | |
| +
 | |
|  void WebPageInspectorController::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type)
 | |
|  {
 | |
|      addTarget(InspectorTargetProxy::create(m_page, targetId, type));
 | |
| @@ -169,6 +318,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);
 | |
| +}
 | |
| +
 | |
| +bool WebPageInspectorController::shouldPauseLoading() const
 | |
| +{
 | |
| +    if (!m_frontendRouter->hasFrontends())
 | |
| +        return false;
 | |
| +
 | |
| +    if (!m_page.isPageOpenedByDOMShowingInitialEmptyDocument())
 | |
| +        return false;
 | |
| +
 | |
| +    auto* target = m_targets.get(WebPageInspectorTarget::toTargetID(m_page.webPageID()));
 | |
| +    ASSERT(target);
 | |
| +    return target->isPaused();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorController::setContinueLoadingCallback(WTF::Function<void()>&& callback)
 | |
| +{
 | |
| +    auto* target = m_targets.get(WebPageInspectorTarget::toTargetID(m_page.webPageID()));
 | |
| +    ASSERT(target);
 | |
| +    target->setResumeCallback(WTFMove(callback));
 | |
| +}
 | |
| +
 | |
|  bool WebPageInspectorController::shouldPauseLoading(const ProvisionalPageProxy& provisionalPage) const
 | |
|  {
 | |
|      if (!m_frontendRouter->hasFrontends())
 | |
| @@ -188,7 +364,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)
 | |
| @@ -241,4 +417,20 @@ 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);
 | |
| +
 | |
| +    // 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);
 | |
| +
 | |
| +    // Enable popup debugging.
 | |
| +    // TODO: allow to set preferences over the inspector protocol or find a better place for this.
 | |
| +    m_page.preferences().setJavaScriptCanOpenWindowsAutomatically(true);
 | |
| +}
 | |
| +
 | |
|  } // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
 | |
| index 9ce5ef36b652fd56a843c1d12a4c3c3cf639282c..bb4d6b26bf245aebc2bd0f435a7bb83151331961 100644
 | |
| --- a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
 | |
| +++ b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
 | |
| @@ -26,17 +26,27 @@
 | |
|  #pragma once
 | |
|  
 | |
|  #include "InspectorTargetProxy.h"
 | |
| +#include "ProcessTerminationReason.h"
 | |
|  #include <JavaScriptCore/InspectorAgentRegistry.h>
 | |
|  #include <JavaScriptCore/InspectorTargetAgent.h>
 | |
|  #include <WebCore/PageIdentifier.h>
 | |
|  #include <wtf/Forward.h>
 | |
|  #include <wtf/Noncopyable.h>
 | |
|  #include <wtf/text/WTFString.h>
 | |
| +#include <wtf/URL.h>
 | |
|  
 | |
|  namespace Inspector {
 | |
|  class BackendDispatcher;
 | |
|  class FrontendChannel;
 | |
|  class FrontendRouter;
 | |
| +class InspectorTarget;
 | |
| +}
 | |
| +
 | |
| +namespace WebCore {
 | |
| +class ResourceError;
 | |
| +class ResourceRequest;
 | |
| +enum class PolicyAction : uint8_t;
 | |
| +struct WindowFeatures;
 | |
|  }
 | |
|  
 | |
|  namespace WebKit {
 | |
| @@ -44,6 +54,21 @@ namespace WebKit {
 | |
|  class InspectorBrowserAgent;
 | |
|  struct WebPageAgentContext;
 | |
|  
 | |
| +class WebFrameProxy;
 | |
| +class WebPageInspectorEmulationAgent;
 | |
| +class WebPageInspectorInputAgent;
 | |
| +
 | |
| +class WebPageInspectorControllerObserver {
 | |
| +public:
 | |
| +    virtual void didCreateInspectorController(WebPageProxy&) = 0;
 | |
| +    virtual void willDestroyInspectorController(WebPageProxy&) = 0;
 | |
| +    virtual void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error) = 0;
 | |
| +    virtual void willCreateNewPage(WebPageProxy&, const WebCore::WindowFeatures&, const URL&) = 0;
 | |
| +
 | |
| +protected:
 | |
| +    virtual ~WebPageInspectorControllerObserver() = default;
 | |
| +};
 | |
| +
 | |
|  class WebPageInspectorController {
 | |
|      WTF_MAKE_NONCOPYABLE(WebPageInspectorController);
 | |
|      WTF_MAKE_FAST_ALLOCATED;
 | |
| @@ -51,7 +76,19 @@ public:
 | |
|      WebPageInspectorController(WebPageProxy&);
 | |
|  
 | |
|      void init();
 | |
| +    void didFinishAttachingToWebProcess();
 | |
| +
 | |
| +    static void setObserver(WebPageInspectorControllerObserver*);
 | |
| +
 | |
|      void pageClosed();
 | |
| +    bool pageCrashed(ProcessTerminationReason);
 | |
| +
 | |
| +    void willCreateNewPage(const WebCore::WindowFeatures&, const URL&);
 | |
| +
 | |
| +    void didShowPage();
 | |
| +
 | |
| +    void didProcessAllPendingKeyboardEvents();
 | |
| +    void didProcessAllPendingMouseEvents();
 | |
|  
 | |
|      bool hasLocalFrontend() const;
 | |
|  
 | |
| @@ -65,10 +102,22 @@ public:
 | |
|      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);
 | |
| +
 | |
| +    void didFailProvisionalLoadForFrame(uint64_t navigationID, const WebCore::ResourceError& error);
 | |
| +
 | |
|      void createInspectorTarget(const String& targetId, Inspector::InspectorTargetType);
 | |
|      void destroyInspectorTarget(const String& targetId);
 | |
|      void sendMessageToInspectorFrontend(const String& targetId, const String& message);
 | |
|  
 | |
| +    void setPauseOnStart(bool);
 | |
| +
 | |
| +    bool shouldPauseLoading() const;
 | |
| +    void setContinueLoadingCallback(WTF::Function<void()>&&);
 | |
| +
 | |
|      bool shouldPauseLoading(const ProvisionalPageProxy&) const;
 | |
|      void setContinueLoadingCallback(const ProvisionalPageProxy&, WTF::Function<void()>&&);
 | |
|  
 | |
| @@ -84,6 +133,7 @@ private:
 | |
|      void createLazyAgents();
 | |
|  
 | |
|      void addTarget(std::unique_ptr<InspectorTargetProxy>&&);
 | |
| +    void adjustPageSettings();
 | |
|  
 | |
|      Ref<Inspector::FrontendRouter> m_frontendRouter;
 | |
|      Ref<Inspector::BackendDispatcher> m_backendDispatcher;
 | |
| @@ -92,11 +142,16 @@ private:
 | |
|      WebPageProxy& m_page;
 | |
|  
 | |
|      Inspector::InspectorTargetAgent* m_targetAgent;
 | |
| +    WebPageInspectorEmulationAgent* m_emulationAgent { nullptr };
 | |
| +    WebPageInspectorInputAgent* m_inputAgent { nullptr };
 | |
|      HashMap<String, std::unique_ptr<InspectorTargetProxy>> m_targets;
 | |
|  
 | |
|      InspectorBrowserAgent* m_enabledInspectorBrowserAgent;
 | |
|  
 | |
|      bool m_didCreateLazyAgents { false };
 | |
| +    HashMap<uint64_t, NavigationHandler> m_pendingNavigations;
 | |
| +
 | |
| +    static WebPageInspectorControllerObserver* s_observer;
 | |
|  };
 | |
|  
 | |
|  } // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/Inspector/mac/InspectorScreencastAgentMac.mm b/Source/WebKit/UIProcess/Inspector/mac/InspectorScreencastAgentMac.mm
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..880273f9fc4410b5678ed391670f91ac51d86e37
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/Inspector/mac/InspectorScreencastAgentMac.mm
 | |
| @@ -0,0 +1,72 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "InspectorScreencastAgent.h"
 | |
| +
 | |
| +#if PLATFORM(MAC)
 | |
| +
 | |
| +#include "PageClient.h"
 | |
| +#include <CoreGraphics/CoreGraphics.h>
 | |
| +#include <WebCore/ImageBufferUtilitiesCG.h>
 | |
| +#include <wtf/RetainPtr.h>
 | |
| +#include <wtf/text/WTFString.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +String InspectorScreencastAgent::platformTakeSnapshot()
 | |
| +{
 | |
| +    RetainPtr<CGImageRef> windowSnapshotImage = m_page.pageClient().takeSnapshotForAutomation();
 | |
| +    if (!windowSnapshotImage)
 | |
| +        return String();
 | |
| +
 | |
| +    CFStringRef type;
 | |
| +    switch (m_format) {
 | |
| +    case ImageFormat::Jpeg:
 | |
| +        type = kUTTypeJPEG;
 | |
| +        break;
 | |
| +    case ImageFormat::Png:
 | |
| +        type = kUTTypePNG;
 | |
| +        break;
 | |
| +    };
 | |
| +
 | |
| +    Optional<double> quality;
 | |
| +    if (m_quality)
 | |
| +        quality = *m_quality / 100.0;
 | |
| +
 | |
| +    RetainPtr<NSMutableData> imageData = adoptNS([[NSMutableData alloc] init]);
 | |
| +    if (!WebCore::encodeImage(windowSnapshotImage.get(), type, quality, (CFMutableDataRef)imageData.get())) {
 | |
| +        fprintf(stderr, "Failed to encode image.\n");
 | |
| +        return String();
 | |
| +    }
 | |
| +
 | |
| +    return String([imageData base64EncodedStringWithOptions:0]);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // PLATFORM(MAC)
 | |
| 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"
 | |
| +
 | |
| +#include "APINavigation.h"
 | |
| +#include "APIUIClient.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <JavaScriptCore/InspectorFrontendRouter.h>
 | |
| +
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +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)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +InspectorDialogAgent::~InspectorDialogAgent()
 | |
| +{
 | |
| +    Inspector::ErrorString err;
 | |
| +    disable(err);
 | |
| +}
 | |
| +
 | |
| +void InspectorDialogAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void InspectorDialogAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void InspectorDialogAgent::enable(Inspector::ErrorString& errorString)
 | |
| +{
 | |
| +    if (m_page.inspectorDialogAgent()) {
 | |
| +        errorString = "Dialog domain is already enabled."_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    m_page.setInspectorDialogAgent(this);
 | |
| +}
 | |
| +
 | |
| +void InspectorDialogAgent::disable(Inspector::ErrorString&)
 | |
| +{
 | |
| +    if (m_page.inspectorDialogAgent() != this)
 | |
| +        return;
 | |
| +    m_page.setInspectorDialogAgent(nullptr);
 | |
| +}
 | |
| +
 | |
| +void InspectorDialogAgent::handleJavaScriptDialog(Inspector::ErrorString& errorString, bool accept, const String* value)
 | |
| +{
 | |
| +    m_page.uiClient().handleJavaScriptDialog(m_page, accept, value ? *value : String());
 | |
| +}
 | |
| +
 | |
| +void InspectorDialogAgent::javascriptDialogOpening(const String& type, const String& message, const String* defaultValue) {
 | |
| +    m_frontendDispatcher->javascriptDialogOpening(type, message, defaultValue);
 | |
| +}
 | |
| +
 | |
| +} // 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 @@
 | |
| +/*
 | |
| + * 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
 | |
| +
 | |
| +#include "WebEvent.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 NativeWebKeyboardEvent;
 | |
| +class WebPageProxy;
 | |
| +
 | |
| +class InspectorDialogAgent : public Inspector::InspectorAgentBase, public Inspector::DialogBackendDispatcherHandler {
 | |
| +    WTF_MAKE_NONCOPYABLE(InspectorDialogAgent);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorDialogAgent(Inspector::BackendDispatcher& backendDispatcher, Inspector::FrontendRouter& frontendRouter, WebPageProxy& page);
 | |
| +    ~InspectorDialogAgent() override;
 | |
| +
 | |
| +    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
 | |
| +    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
 | |
| +
 | |
| +    void enable(Inspector::ErrorString&) override;
 | |
| +    void disable(Inspector::ErrorString&) override;
 | |
| +    void handleJavaScriptDialog(Inspector::ErrorString& errorString, bool accept, const String* promptText) override;
 | |
| +
 | |
| +    void javascriptDialogOpening(const String& type, const String& message, const String* defaultValue = nullptr);
 | |
| +
 | |
| +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/InspectorPlaywrightAgent.cpp b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..5e13d6225bb86abd7dd3553a5f690c4e3556d47d
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp
 | |
| @@ -0,0 +1,658 @@
 | |
| +/*
 | |
| + * 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 "InspectorPlaywrightAgent.h"
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include "APIPageConfiguration.h"
 | |
| +#include "FrameInfoData.h"
 | |
| +#include "InspectorPlaywrightAgentClient.h"
 | |
| +#include "InspectorTargetProxy.h"
 | |
| +#include "NetworkProcessMessages.h"
 | |
| +#include "NetworkProcessProxy.h"
 | |
| +#include "PageClient.h"
 | |
| +#include "WebAutomationSession.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/InspectorPageAgent.h>
 | |
| +#include <WebCore/ProcessIdentifier.h>
 | |
| +#include <WebCore/ResourceRequest.h>
 | |
| +#include <WebCore/WindowFeatures.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 {
 | |
| +
 | |
| +static RefPtr<JSON::ArrayOf<String>> getEnabledWindowFeatures(const WebCore::WindowFeatures& features) {
 | |
| +  auto result = JSON::ArrayOf<String>::create();
 | |
| +  if (features.x)
 | |
| +    result->addItem("left=" + String::number(*features.x));
 | |
| +  if (features.y)
 | |
| +    result->addItem("top=" + String::number(*features.y));
 | |
| +  if (features.width)
 | |
| +    result->addItem("width=" + String::number(*features.width));
 | |
| +  if (features.height)
 | |
| +    result->addItem("height=" + String::number(*features.height));
 | |
| +  if (features.menuBarVisible)
 | |
| +    result->addItem("menubar");
 | |
| +  if (features.toolBarVisible)
 | |
| +    result->addItem("toolbar");
 | |
| +  if (features.statusBarVisible)
 | |
| +    result->addItem("status");
 | |
| +  if (features.locationBarVisible)
 | |
| +    result->addItem("location");
 | |
| +  if (features.scrollbarsVisible)
 | |
| +    result->addItem("scrollbars");
 | |
| +  if (features.resizable)
 | |
| +    result->addItem("resizable");
 | |
| +  if (features.fullscreen)
 | |
| +    result->addItem("fullscreen");
 | |
| +  if (features.dialog)
 | |
| +    result->addItem("dialog");
 | |
| +  if (features.noopener)
 | |
| +    result->addItem("noopener");
 | |
| +  if (features.noreferrer)
 | |
| +    result->addItem("noreferrer");
 | |
| +  for (const auto& additionalFeature : features.additionalFeatures)
 | |
| +    result->addItem(additionalFeature);
 | |
| +  return result;
 | |
| +}
 | |
| +
 | |
| +Inspector::Protocol::Playwright::CookieSameSitePolicy cookieSameSitePolicy(WebCore::Cookie::SameSitePolicy policy)
 | |
| +{
 | |
| +    switch (policy) {
 | |
| +    case WebCore::Cookie::SameSitePolicy::None:
 | |
| +        return Inspector::Protocol::Playwright::CookieSameSitePolicy::None;
 | |
| +    case WebCore::Cookie::SameSitePolicy::Lax:
 | |
| +        return Inspector::Protocol::Playwright::CookieSameSitePolicy::Lax;
 | |
| +    case WebCore::Cookie::SameSitePolicy::Strict:
 | |
| +        return Inspector::Protocol::Playwright::CookieSameSitePolicy::Strict;
 | |
| +    }
 | |
| +    ASSERT_NOT_REACHED();
 | |
| +    return Inspector::Protocol::Playwright::CookieSameSitePolicy::None;
 | |
| +}
 | |
| +
 | |
| +Ref<Inspector::Protocol::Playwright::Cookie> buildObjectForCookie(const WebCore::Cookie& cookie)
 | |
| +{
 | |
| +    return Inspector::Protocol::Playwright::Cookie::create()
 | |
| +        .setName(cookie.name)
 | |
| +        .setValue(cookie.value)
 | |
| +        .setDomain(cookie.domain)
 | |
| +        .setPath(cookie.path)
 | |
| +        .setExpires(cookie.expires.valueOr(-1))
 | |
| +        .setHttpOnly(cookie.httpOnly)
 | |
| +        .setSecure(cookie.secure)
 | |
| +        .setSession(cookie.session)
 | |
| +        .setSameSite(cookieSameSitePolicy(cookie.sameSite))
 | |
| +        .release();
 | |
| +}
 | |
| +
 | |
| +Ref<Inspector::Protocol::Playwright::PageProxyInfo> buildPageProxyInfo(const WebPageProxy& page) {
 | |
| +    auto result = Inspector::Protocol::Playwright::PageProxyInfo::create()
 | |
| +        .setPageProxyId(InspectorPlaywrightAgent::toPageProxyIDProtocolString(page))
 | |
| +        .setBrowserContextId(InspectorPlaywrightAgent::toBrowserContextIDProtocolString(page.sessionID()))
 | |
| +        .release();
 | |
| +    auto* opener = page.configuration().relatedPage();
 | |
| +    if (opener)
 | |
| +        result->setOpenerId(InspectorPlaywrightAgent::toPageProxyIDProtocolString(*opener));
 | |
| +    return result;
 | |
| +}
 | |
| +
 | |
| +}  // namespace
 | |
| +
 | |
| +Vector<WebPageProxy*> BrowserContext::pages() const {
 | |
| +    Vector<WebPageProxy*> pages;
 | |
| +    for (auto& process : processPool->processes()) {
 | |
| +        for (auto* page : process->pages())
 | |
| +            pages.append(page);
 | |
| +    }
 | |
| +    return pages;
 | |
| +}
 | |
| +
 | |
| +class InspectorPlaywrightAgent::BrowserContextDeletion {
 | |
| +    WTF_MAKE_NONCOPYABLE(BrowserContextDeletion);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    BrowserContextDeletion(const BrowserContext& context, size_t numberOfPages, Ref<DeleteContextCallback>&& callback)
 | |
| +        : m_browserContext(context)
 | |
| +        , m_numberOfPages(numberOfPages)
 | |
| +        , m_callback(WTFMove(callback)) { }
 | |
| +
 | |
| +    void willDestroyPage(const WebPageProxy& page)
 | |
| +    {
 | |
| +        ASSERT(m_browserContext.dataStore->sessionID() == page.sessionID());
 | |
| +        // Check if new pages have been created during the context destruction and
 | |
| +        // close all of them if necessary.
 | |
| +        if (m_numberOfPages == 1) {
 | |
| +            Vector<WebPageProxy*> pages = m_browserContext.pages();
 | |
| +            size_t numberOfPages = pages.size();
 | |
| +            if (numberOfPages > 1) {
 | |
| +                m_numberOfPages = numberOfPages;
 | |
| +                for (auto* existingPage : pages) {
 | |
| +                    if (existingPage != &page)
 | |
| +                        existingPage->closePage();
 | |
| +                }
 | |
| +            }
 | |
| +        }
 | |
| +        --m_numberOfPages;
 | |
| +        if (m_numberOfPages)
 | |
| +            return;
 | |
| +        m_callback->sendSuccess();
 | |
| +    }
 | |
| +
 | |
| +    bool isFinished() const { return !m_numberOfPages; }
 | |
| +
 | |
| +private:
 | |
| +    BrowserContext m_browserContext;
 | |
| +    size_t m_numberOfPages;
 | |
| +    Ref<DeleteContextCallback> m_callback;
 | |
| +};
 | |
| +
 | |
| +
 | |
| +InspectorPlaywrightAgent::InspectorPlaywrightAgent(Inspector::FrontendRouter& frontendRouter, Inspector::BackendDispatcher& backendDispatcher, InspectorPlaywrightAgentClient* client, PageProxyIDMap& pageProxyIDMap)
 | |
| +    : InspectorAgentBase("Playwright"_s)
 | |
| +    , m_frontendDispatcher(makeUnique<PlaywrightFrontendDispatcher>(frontendRouter))
 | |
| +    , m_backendDispatcher(PlaywrightBackendDispatcher::create(backendDispatcher, this))
 | |
| +    , m_client(client)
 | |
| +    , m_pageProxyIDMap(pageProxyIDMap)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +InspectorPlaywrightAgent::~InspectorPlaywrightAgent() = default;
 | |
| +
 | |
| +void InspectorPlaywrightAgent::didCreateWebPageProxy(const WebPageProxy& page)
 | |
| +{
 | |
| +    if (m_isConnected)
 | |
| +        m_frontendDispatcher->pageProxyCreated(buildPageProxyInfo(page));
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::willDestroyWebPageProxy(const WebPageProxy& page)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +
 | |
| +    m_frontendDispatcher->pageProxyDestroyed(toPageProxyIDProtocolString(page));
 | |
| +
 | |
| +    auto it = m_browserContextDeletions.find(page.sessionID());
 | |
| +    if (it == m_browserContextDeletions.end())
 | |
| +        return;
 | |
| +
 | |
| +    it->value->willDestroyPage(page);
 | |
| +    if (it->value->isFinished())
 | |
| +        m_browserContextDeletions.remove(it);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
 | |
| +{
 | |
| +    m_isConnected = true;
 | |
| +    for (auto& pool : WebProcessPool::allProcessPools()) {
 | |
| +        auto* dataStore = pool->websiteDataStore();
 | |
| +        if (dataStore)
 | |
| +            dataStore->setDownloadInstrumentation(this);
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::didFailProvisionalLoad(WebPageProxy& page, uint64_t navigationID, const String& error)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +
 | |
| +    m_frontendDispatcher->provisionalLoadFailed(toPageProxyIDProtocolString(page), String::number(navigationID), error);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::willCreateNewPage(WebPageProxy& page, const WebCore::WindowFeatures& features, const URL& url)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +
 | |
| +    m_frontendDispatcher->windowOpen(toPageProxyIDProtocolString(page), url.string(), getEnabledWindowFeatures(features));
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::willDestroyFrontendAndBackend(DisconnectReason)
 | |
| +{
 | |
| +    m_isConnected = false;
 | |
| +    for (auto& pool : WebProcessPool::allProcessPools()) {
 | |
| +        auto* dataStore = pool->websiteDataStore();
 | |
| +        if (dataStore) {
 | |
| +            dataStore->setDownloadInstrumentation(nullptr);
 | |
| +            dataStore->setDownloadForAutomation(Optional<bool>(), String());
 | |
| +        }
 | |
| +    }
 | |
| +    for (auto& it : m_browserContexts)
 | |
| +        it.value.dataStore->setDownloadInstrumentation(nullptr);
 | |
| +    m_browserContextDeletions.clear();
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::close(Ref<CloseCallback>&& callback)
 | |
| +{
 | |
| +    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 (!WebProcessPool::allProcessPools().size()) {
 | |
| +        m_client->closeBrowser();
 | |
| +        callback->sendSuccess();
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    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 InspectorPlaywrightAgent::createContext(ErrorString& errorString, String* browserContextID)
 | |
| +{
 | |
| +    BrowserContext browserContext = m_client->createBrowserContext(errorString);
 | |
| +    if (!errorString.isEmpty())
 | |
| +        return;
 | |
| +    browserContext.processPool->setPrimaryDataStore(*browserContext.dataStore);
 | |
| +    browserContext.processPool->ensureNetworkProcess(browserContext.dataStore.get());
 | |
| +    browserContext.dataStore->setDownloadInstrumentation(this);
 | |
| +
 | |
| +    PAL::SessionID sessionID = browserContext.dataStore->sessionID();
 | |
| +    *browserContextID = toBrowserContextIDProtocolString(sessionID);
 | |
| +    m_browserContexts.set(*browserContextID, browserContext);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::deleteContext(const String& browserContextID, Ref<DeleteContextCallback>&& callback)
 | |
| +{
 | |
| +    String errorString;
 | |
| +    BrowserContext browserContext = lookupBrowserContext(errorString, &browserContextID);
 | |
| +    if (!errorString.isEmpty()) {
 | |
| +        callback->sendFailure(errorString);
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    Vector<WebPageProxy*> pages = browserContext.pages();
 | |
| +    PAL::SessionID sessionID = browserContext.dataStore->sessionID();
 | |
| +    m_browserContexts.remove(browserContextID);
 | |
| +    if (pages.isEmpty()) {
 | |
| +        callback->sendSuccess();
 | |
| +    } else {
 | |
| +        m_browserContextDeletions.set(sessionID, makeUnique<BrowserContextDeletion>(browserContext, pages.size(), WTFMove(callback)));
 | |
| +        for (auto* page : pages)
 | |
| +            page->closePage();
 | |
| +    }
 | |
| +    m_client->deleteBrowserContext(errorString, sessionID);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::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;
 | |
| +    *pageProxyID = toPageProxyIDProtocolString(*page);
 | |
| +}
 | |
| +
 | |
| +WebFrameProxy* InspectorPlaywrightAgent::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 InspectorPlaywrightAgent::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 InspectorPlaywrightAgent::setIgnoreCertificateErrors(Inspector::ErrorString& errorString, const String* browserContextID, bool ignore)
 | |
| +{
 | |
| +    BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);
 | |
| +    if (!errorString.isEmpty())
 | |
| +        return;
 | |
| +
 | |
| +    PAL::SessionID sessionID = browserContext.dataStore->sessionID();
 | |
| +    NetworkProcessProxy* networkProcess = browserContext.processPool->networkProcess();
 | |
| +    networkProcess->send(Messages::NetworkProcess::SetIgnoreCertificateErrors(sessionID, ignore), 0);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::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::Playwright::Cookie>::create();
 | |
| +            for (const auto& cookie : allCookies)
 | |
| +                cookies->addItem(buildObjectForCookie(cookie));
 | |
| +            callback->sendSuccess(WTFMove(cookies));
 | |
| +        }, 0);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::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;
 | |
| +        }
 | |
| +
 | |
| +        double expires;
 | |
| +        if (obj->getDouble("expires", expires) && expires != -1)
 | |
| +            cookie.expires = 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 InspectorPlaywrightAgent::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 InspectorPlaywrightAgent::setLanguages(Inspector::ErrorString& errorString, const JSON::Array& languages, const String* browserContextID)
 | |
| +{
 | |
| +    BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);
 | |
| +    if (!errorString.isEmpty())
 | |
| +        return;
 | |
| +
 | |
| +    Vector<String> items;
 | |
| +    for (const auto& value : languages) {
 | |
| +        String language;
 | |
| +        if (!value->asString(language)) {
 | |
| +            errorString = "Language must be a string"_s;
 | |
| +            return;
 | |
| +        }
 | |
| +        items.append(language);
 | |
| +    }
 | |
| +
 | |
| +    browserContext.dataStore->setLanguagesForAutomation(WTFMove(items));
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::setDownloadBehavior(Inspector::ErrorString& errorString, const String* behavior, const String* downloadPath, const String* browserContextID)
 | |
| +{
 | |
| +    BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);
 | |
| +    if (!errorString.isEmpty())
 | |
| +        return;
 | |
| +    Optional<bool> allow;
 | |
| +    if (behavior && *behavior == "allow"_s)
 | |
| +      allow = true;
 | |
| +    if (behavior && *behavior == "deny"_s)
 | |
| +      allow = false;
 | |
| +    browserContext.dataStore->setDownloadForAutomation(allow, downloadPath ? *downloadPath : String());
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::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."_s;
 | |
| +        return;
 | |
| +    }
 | |
| +    if (geolocation) {
 | |
| +        double timestamp = 0;
 | |
| +        double latitude = 0;
 | |
| +        double longitude = 0;
 | |
| +        double accuracy = 0;
 | |
| +        if (!geolocation->getDouble("timestamp"_s, timestamp) ||
 | |
| +            !geolocation->getDouble("latitude"_s, latitude) ||
 | |
| +            !geolocation->getDouble("longitude"_s, longitude) ||
 | |
| +            !geolocation->getDouble("accuracy"_s, 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 InspectorPlaywrightAgent::downloadCreated(const String& uuid, const WebCore::ResourceRequest& request, const FrameInfoData& frameInfoData, WebPageProxy* page)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +    String frameID = WebCore::InspectorPageAgent::makeFrameID(page->process().coreProcessIdentifier(), frameInfoData.frameID ? *frameInfoData.frameID : page->mainFrame()->frameID());
 | |
| +    m_frontendDispatcher->downloadCreated(uuid, request.url().string(),
 | |
| +        InspectorPlaywrightAgent::toPageProxyIDProtocolString(*page),
 | |
| +        InspectorPlaywrightAgent::toBrowserContextIDProtocolString(page->sessionID()),
 | |
| +        frameID);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::downloadFilenameSuggested(const String& uuid, const String& suggestedFilename)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +    m_frontendDispatcher->downloadFilenameSuggested(uuid, suggestedFilename);
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgent::downloadFinished(const String& uuid, const String& error)
 | |
| +{
 | |
| +    if (!m_isConnected)
 | |
| +        return;
 | |
| +    m_frontendDispatcher->downloadFinished(uuid, error);
 | |
| +}
 | |
| +
 | |
| +String InspectorPlaywrightAgent::toBrowserContextIDProtocolString(const PAL::SessionID& sessionID)
 | |
| +{
 | |
| +    StringBuilder builder;
 | |
| +    builder.append(hex(sessionID.toUInt64(), 16));
 | |
| +    return builder.toString();
 | |
| +}
 | |
| +
 | |
| +String InspectorPlaywrightAgent::toPageProxyIDProtocolString(const WebPageProxy& page)
 | |
| +{
 | |
| +    return makeString(page.identifier().toUInt64());
 | |
| +}
 | |
| +
 | |
| +BrowserContext InspectorPlaywrightAgent::lookupBrowserContext(ErrorString& errorString, const String* browserContextID)
 | |
| +{
 | |
| +    if (!browserContextID) {
 | |
| +        BrowserContext context;
 | |
| +        if (!WebProcessPool::allProcessPools().size()) {
 | |
| +            errorString = "Browser started with no default context"_s;
 | |
| +            return context;
 | |
| +        }
 | |
| +        auto* pool = WebProcessPool::allProcessPools().first();
 | |
| +        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/InspectorPlaywrightAgent.h b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..6a371421a504243925aac4ba0e6a0227f1453aea
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.h
 | |
| @@ -0,0 +1,127 @@
 | |
| +/*
 | |
| + * 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 "InspectorPlaywrightAgentClient.h"
 | |
| +#include <JavaScriptCore/InspectorAgentBase.h>
 | |
| +#include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| +#include "WebProcessPool.h"
 | |
| +#include <wtf/HashMap.h>
 | |
| +#include <pal/SessionID.h>
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/Noncopyable.h>
 | |
| +#include <wtf/URL.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class BackendDispatcher;
 | |
| +class FrontendChannel;
 | |
| +class FrontendRouter;
 | |
| +class PlaywrightFrontendDispatcher;
 | |
| +}
 | |
| +
 | |
| +namespace PAL {
 | |
| +class SessionID;
 | |
| +}
 | |
| +
 | |
| +namespace WebCore {
 | |
| +struct WindowFeatures;
 | |
| +}
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class NetworkProcess;
 | |
| +class WebFrameProxy;
 | |
| +
 | |
| +class PageProxyIDMap {
 | |
| +public:
 | |
| +    virtual WebPageProxy* findPageProxy(const String& pageProxyID) = 0;
 | |
| +
 | |
| +protected:
 | |
| +    virtual ~PageProxyIDMap() = default;
 | |
| +};
 | |
| +
 | |
| +class InspectorPlaywrightAgent final
 | |
| +    : public Inspector::InspectorAgentBase
 | |
| +    , public Inspector::PlaywrightBackendDispatcherHandler
 | |
| +    , public DownloadInstrumentation {
 | |
| +    WTF_MAKE_NONCOPYABLE(InspectorPlaywrightAgent);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorPlaywrightAgent(Inspector::FrontendRouter&, Inspector::BackendDispatcher&, InspectorPlaywrightAgentClient*, PageProxyIDMap&);
 | |
| +    ~InspectorPlaywrightAgent() override;
 | |
| +
 | |
| +    void didCreateWebPageProxy(const WebPageProxy&);
 | |
| +    void willDestroyWebPageProxy(const WebPageProxy&);
 | |
| +    void didFailProvisionalLoad(WebPageProxy&, uint64_t navigationID, const String& error);
 | |
| +    void willCreateNewPage(WebPageProxy&, const WebCore::WindowFeatures&, const URL&);
 | |
| +
 | |
| +    // InspectorAgentBase
 | |
| +    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
 | |
| +    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
 | |
| +
 | |
| +    // PlaywrightDispatcherHandler
 | |
| +    void close(Ref<CloseCallback>&&) override;
 | |
| +    void createContext(Inspector::ErrorString&, String* browserContextID) override;
 | |
| +    void deleteContext(const String& browserContextID, Ref<DeleteContextCallback>&& callback) 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 setGeolocationOverride(Inspector::ErrorString&, const String* browserContextID, const JSON::Object* geolocation) override;
 | |
| +    void setLanguages(Inspector::ErrorString&, const JSON::Array& languages, const String* browserContextID) override;
 | |
| +    void setDownloadBehavior(Inspector::ErrorString&, const String* behavior, const String* downloadPath, const String* browserContextID) override;
 | |
| +
 | |
| +    static String toBrowserContextIDProtocolString(const PAL::SessionID&);
 | |
| +    static String toPageProxyIDProtocolString(const WebPageProxy&);
 | |
| +
 | |
| +    // DownloadInstrumentation
 | |
| +    void downloadCreated(const String& uuid, const WebCore::ResourceRequest&, const FrameInfoData& frameInfoData, WebPageProxy* page) override;
 | |
| +    void downloadFilenameSuggested(const String& uuid, const String& suggestedFilename) override;
 | |
| +    void downloadFinished(const String& uuid, const String& error) override;
 | |
| +
 | |
| +private:
 | |
| +    class BrowserContextDeletion;
 | |
| +    BrowserContext lookupBrowserContext(Inspector::ErrorString&, const String* browserContextID);
 | |
| +    WebFrameProxy* frameForID(const String& frameID, String& error);
 | |
| +
 | |
| +    std::unique_ptr<Inspector::PlaywrightFrontendDispatcher> m_frontendDispatcher;
 | |
| +    Ref<Inspector::PlaywrightBackendDispatcher> m_backendDispatcher;
 | |
| +    InspectorPlaywrightAgentClient* m_client;
 | |
| +    PageProxyIDMap& m_pageProxyIDMap;
 | |
| +    HashMap<String, BrowserContext> m_browserContexts;
 | |
| +    HashMap<PAL::SessionID, std::unique_ptr<BrowserContextDeletion>> m_browserContextDeletions;
 | |
| +    bool m_isConnected { false };
 | |
| +};
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h b/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..d2f02082007b41b9e20dc6bb4751743835d60fce
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h
 | |
| @@ -0,0 +1,56 @@
 | |
| +/*
 | |
| + * 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 {
 | |
| +    Vector<WebPageProxy*> pages() const;
 | |
| +    RefPtr<WebsiteDataStore> dataStore;
 | |
| +    RefPtr<WebProcessPool> processPool;
 | |
| +};
 | |
| +
 | |
| +class InspectorPlaywrightAgentClient {
 | |
| +public:
 | |
| +    virtual ~InspectorPlaywrightAgentClient() = 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/Launcher/win/ProcessLauncherWin.cpp b/Source/WebKit/UIProcess/Launcher/win/ProcessLauncherWin.cpp
 | |
| index 7a14cfba15c103a2d4fe263fa49d25af3c396ec2..3ee0e154349661632799057c71f1d1f1551c2d69 100644
 | |
| --- a/Source/WebKit/UIProcess/Launcher/win/ProcessLauncherWin.cpp
 | |
| +++ b/Source/WebKit/UIProcess/Launcher/win/ProcessLauncherWin.cpp
 | |
| @@ -96,8 +96,11 @@ void ProcessLauncher::launchProcess()
 | |
|  
 | |
|      STARTUPINFO startupInfo { };
 | |
|      startupInfo.cb = sizeof(startupInfo);
 | |
| -    startupInfo.dwFlags = STARTF_USESHOWWINDOW;
 | |
| +    startupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
 | |
|      startupInfo.wShowWindow = SW_HIDE;
 | |
| +    startupInfo.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);
 | |
| +    startupInfo.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
 | |
| +    startupInfo.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
 | |
|      PROCESS_INFORMATION processInformation { };
 | |
|      BOOL result = ::CreateProcess(0, commandLine.data(), 0, 0, true, 0, 0, 0, &startupInfo, &processInformation);
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h
 | |
| index 8fc767f7356167fd581602a3f0e8e5ea2021266f..941a50a358450d71df810a1bcaced233216b6b11 100644
 | |
| --- a/Source/WebKit/UIProcess/PageClient.h
 | |
| +++ b/Source/WebKit/UIProcess/PageClient.h
 | |
| @@ -286,6 +286,11 @@ public:
 | |
|      virtual void selectionDidChange() = 0;
 | |
|  #endif
 | |
|  
 | |
| +// Paywright begin
 | |
| +#if PLATFORM(COCOA)
 | |
| +    virtual RetainPtr<CGImageRef> takeSnapshotForAutomation() = 0;
 | |
| +#endif
 | |
| +// Paywright end
 | |
|  #if PLATFORM(COCOA) || PLATFORM(GTK)
 | |
|      virtual RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&) = 0;
 | |
|  #endif
 | |
| diff --git a/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..e842999cf436a92f5279642a4edccd10ede7b3e2
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp
 | |
| @@ -0,0 +1,221 @@
 | |
| +/*
 | |
| + * 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 "RemoteInspectorPipe.h"
 | |
| +
 | |
| +#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
 | |
| +
 | |
| +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
 | |
| +
 | |
| +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;
 | |
| +}
 | |
| +
 | |
| +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;
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +}  // namespace
 | |
| +
 | |
| +class RemoteInspectorPipe::RemoteFrontendChannel : public Inspector::FrontendChannel {
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +
 | |
| +public:
 | |
| +    RemoteFrontendChannel()
 | |
| +        : m_senderQueue(WorkQueue::create("Inspector pipe writer"))
 | |
| +    {
 | |
| +    }
 | |
| +
 | |
| +    ~RemoteFrontendChannel() override = default;
 | |
| +
 | |
| +    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);
 | |
| +        });
 | |
| +    }
 | |
| +
 | |
| +private:
 | |
| +    Ref<WorkQueue> m_senderQueue;
 | |
| +};
 | |
| +
 | |
| +RemoteInspectorPipe::RemoteInspectorPipe(BrowserInspectorController& browserInspectorController)
 | |
| +    : m_browserInspectorController(browserInspectorController)
 | |
| +{
 | |
| +    // Initialize main loop before creating WorkQueue
 | |
| +    WTF::RunLoop::initializeMainRunLoop();
 | |
| +    m_remoteFrontendChannel = makeUnique<RemoteFrontendChannel>();
 | |
| +    start();
 | |
| +}
 | |
| +
 | |
| +RemoteInspectorPipe::~RemoteInspectorPipe()
 | |
| +{
 | |
| +    stop();
 | |
| +}
 | |
| +
 | |
| +bool RemoteInspectorPipe::start()
 | |
| +{
 | |
| +    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 RemoteInspectorPipe::stop()
 | |
| +{
 | |
| +    if (!m_receiverThread)
 | |
| +        return;
 | |
| +
 | |
| +    m_browserInspectorController.disconnectFrontend();
 | |
| +
 | |
| +    m_terminated = true;
 | |
| +    m_receiverThread->waitForCompletion();
 | |
| +    m_receiverThread = nullptr;
 | |
| +}
 | |
| +
 | |
| +void RemoteInspectorPipe::workerRun()
 | |
| +{
 | |
| +    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);
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#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.
 | |
| + */
 | |
| +
 | |
| +#pragma once
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include <wtf/Ref.h>
 | |
| +#include <wtf/RefPtr.h>
 | |
| +#include <wtf/Threading.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class FrontendChannel;
 | |
| +}
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class BrowserInspectorController;
 | |
| +
 | |
| +class RemoteInspectorPipe {
 | |
| +    WTF_MAKE_NONCOPYABLE(RemoteInspectorPipe);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    explicit RemoteInspectorPipe(BrowserInspectorController&);
 | |
| +    ~RemoteInspectorPipe();
 | |
| +
 | |
| +private:
 | |
| +    class RemoteFrontendChannel;
 | |
| +
 | |
| +    bool start();
 | |
| +    void stop();
 | |
| +
 | |
| +    void workerRun();
 | |
| +
 | |
| +    RefPtr<Thread> m_receiverThread;
 | |
| +    std::atomic<bool> m_terminated { false };
 | |
| +    std::unique_ptr<Inspector::FrontendChannel> m_remoteFrontendChannel;
 | |
| +    BrowserInspectorController& m_browserInspectorController;
 | |
| +};
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.h b/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.h
 | |
| index 8270164b6c98497e848c12026a0d0bd6dafbcfe3..976ca69d0af81c45bfaf86275373949db7d6bc4e 100644
 | |
| --- a/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.h
 | |
| +++ b/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.h
 | |
| @@ -32,6 +32,7 @@
 | |
|  #import "APIWebAuthenticationPanelClient.h"
 | |
|  #import <wtf/RetainPtr.h>
 | |
|  #import <wtf/WeakObjCPtr.h>
 | |
| +#import <wtf/WeakPtr.h>
 | |
|  
 | |
|  @class _WKWebAuthenticationPanel;
 | |
|  @protocol _WKWebAuthenticationPanelDelegate;
 | |
| diff --git a/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h b/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h
 | |
| index ff90d3de4349c9a3385c20c059729b8e22ebe2e5..d5c4f2cd715551ddef6f5af93ada65cbe78ad213 100644
 | |
| --- a/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h
 | |
| +++ b/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h
 | |
| @@ -28,6 +28,7 @@
 | |
|  #if ENABLE(WEB_AUTHN)
 | |
|  
 | |
|  #include "LocalConnection.h"
 | |
| +#include <WebCore/AuthenticatorAssertionResponse.h>
 | |
|  #include <WebCore/MockWebAuthenticationConfiguration.h>
 | |
|  
 | |
|  namespace WebKit {
 | |
| diff --git a/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp
 | |
| index 04f3227cd55c992a42cd96a3f25d697aed7965a2..f0d36935f47bab03ea2ec50b705092068ecd3efa 100644
 | |
| --- a/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp
 | |
| +++ b/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp
 | |
| @@ -128,7 +128,8 @@ void WebGeolocationManagerProxy::startUpdating(IPC::Connection& connection, WebP
 | |
|      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/WebPageInspectorEmulationAgent.cpp b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..3983c25682b06bbbf9ae9fde95b5b9c349ae6abe
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cpp
 | |
| @@ -0,0 +1,145 @@
 | |
| +/*
 | |
| + * 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 "WebPageInspectorEmulationAgent.h"
 | |
| +
 | |
| +#include "APIPageConfiguration.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include "WebPreferences.h"
 | |
| +#include "PageClient.h"
 | |
| +#include <JavaScriptCore/InspectorFrontendRouter.h>
 | |
| +#include <WebCore/Credential.h>
 | |
| +
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +WebPageInspectorEmulationAgent::WebPageInspectorEmulationAgent(BackendDispatcher& backendDispatcher, WebPageProxy& page)
 | |
| +    : InspectorAgentBase("Emulation"_s)
 | |
| +    , m_backendDispatcher(EmulationBackendDispatcher::create(backendDispatcher, this))
 | |
| +    , m_page(page)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +WebPageInspectorEmulationAgent::~WebPageInspectorEmulationAgent()
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::willDestroyFrontendAndBackend(DisconnectReason)
 | |
| +{
 | |
| +   m_commandsToRunWhenShown.clear();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::setDeviceMetricsOverride(int width, int height, double deviceScaleFactor, bool fixedlayout, Ref<SetDeviceMetricsOverrideCallback>&& callback)
 | |
| +{
 | |
| +#if PLATFORM(GTK)
 | |
| +    // On gtk, fixed layout doesn't work with compositing enabled
 | |
| +    // FIXME: This turns off compositing forever, even if fixedLayout is disabled.
 | |
| +    if (fixedlayout) {
 | |
| +        auto copy = m_page.preferences().copy();
 | |
| +        copy->setAcceleratedCompositingEnabled(false);
 | |
| +        m_page.setPreferences(copy);
 | |
| +    }
 | |
| +#endif
 | |
| +
 | |
| +    m_page.setCustomDeviceScaleFactor(deviceScaleFactor);
 | |
| +    m_page.setUseFixedLayout(fixedlayout);
 | |
| +    if (!m_page.pageClient().isViewVisible() && m_page.configuration().relatedPage()) {
 | |
| +        m_commandsToRunWhenShown.append([this, width, height, callback = WTFMove(callback)]() mutable {
 | |
| +            setSize(width, height, WTFMove(callback));
 | |
| +        });
 | |
| +    } else {
 | |
| +        setSize(width, height, WTFMove(callback));
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::setSize(int width, int height, Ref<SetDeviceMetricsOverrideCallback>&& callback)
 | |
| +{
 | |
| +    platformSetSize(width, height, [callback = WTFMove(callback)](const String& error) {
 | |
| +        if (error.isEmpty())
 | |
| +            callback->sendSuccess();
 | |
| +        else
 | |
| +            callback->sendFailure(error);
 | |
| +    });
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::setJavaScriptEnabled(ErrorString&, bool enabled)
 | |
| +{
 | |
| +    auto copy = m_page.preferences().copy();
 | |
| +    copy->setJavaScriptEnabled(enabled);
 | |
| +    m_page.setPreferences(copy);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::setAuthCredentials(Inspector::ErrorString&, const String* username, const String* password)
 | |
| +{
 | |
| +    if (username && password)
 | |
| +        m_page.setAuthCredentialsForAutomation(WebCore::Credential(*username, *password, CredentialPersistencePermanent));
 | |
| +    else
 | |
| +        m_page.setAuthCredentialsForAutomation(Optional<WebCore::Credential>());
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::setActiveAndFocused(Inspector::ErrorString&, const bool* active)
 | |
| +{
 | |
| +    Optional<bool> value;
 | |
| +    if (active)
 | |
| +      value = *active;
 | |
| +    m_page.setActiveForAutomation(value);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::grantPermissions(Inspector::ErrorString& errorString, const String& origin, const JSON::Array& values)
 | |
| +{
 | |
| +    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);
 | |
| +    }
 | |
| +    m_permissions.set(origin, WTFMove(set));
 | |
| +    m_page.setPermissionsForAutomation(m_permissions);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::resetPermissions(Inspector::ErrorString&)
 | |
| +{
 | |
| +    m_permissions.clear();
 | |
| +    m_page.setPermissionsForAutomation(m_permissions);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::didShowPage()
 | |
| +{
 | |
| +    for (auto& command : m_commandsToRunWhenShown)
 | |
| +        command();
 | |
| +    m_commandsToRunWhenShown.clear();
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.h b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..5ae0ce152f06b8316dbfbbbb2efd1990a31687d0
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.h
 | |
| @@ -0,0 +1,75 @@
 | |
| +/*
 | |
| + * 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
 | |
| +
 | |
| +#include <JavaScriptCore/InspectorAgentBase.h>
 | |
| +#include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| +
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/Function.h>
 | |
| +#include <wtf/Noncopyable.h>
 | |
| +#include <wtf/Vector.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class BackendDispatcher;
 | |
| +class FrontendChannel;
 | |
| +class FrontendRouter;
 | |
| +}
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class WebPageProxy;
 | |
| +
 | |
| +class WebPageInspectorEmulationAgent : public Inspector::InspectorAgentBase, public Inspector::EmulationBackendDispatcherHandler {
 | |
| +    WTF_MAKE_NONCOPYABLE(WebPageInspectorEmulationAgent);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    WebPageInspectorEmulationAgent(Inspector::BackendDispatcher& backendDispatcher, WebPageProxy& page);
 | |
| +    ~WebPageInspectorEmulationAgent() override;
 | |
| +
 | |
| +    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
 | |
| +    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
 | |
| +
 | |
| +    void setDeviceMetricsOverride(int width, int height, double deviceScaleFactor, bool fixedlayout, Ref<SetDeviceMetricsOverrideCallback>&&) override;
 | |
| +    void setJavaScriptEnabled(Inspector::ErrorString&, bool enabled) override;
 | |
| +    void setAuthCredentials(Inspector::ErrorString&, const String*, const String*) override;
 | |
| +    void setActiveAndFocused(Inspector::ErrorString&, const bool*) override;
 | |
| +    void grantPermissions(Inspector::ErrorString&, const String& origin, const JSON::Array& permissions) override;
 | |
| +    void resetPermissions(Inspector::ErrorString&) override;
 | |
| +
 | |
| +    void didShowPage();
 | |
| +
 | |
| +private:
 | |
| +    void setSize(int width, int height, Ref<SetDeviceMetricsOverrideCallback>&& callback);
 | |
| +    void platformSetSize(int width, int height, Function<void (const String& error)>&&);
 | |
| +
 | |
| +    Ref<Inspector::EmulationBackendDispatcher> m_backendDispatcher;
 | |
| +    WebPageProxy& m_page;
 | |
| +    Vector<Function<void()>> m_commandsToRunWhenShown;
 | |
| +    HashMap<String, HashSet<String>> m_permissions;
 | |
| +};
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/WebPageInspectorInputAgent.cpp b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..5d19607e019489b33318be50ccdc94c2fcfae914
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.cpp
 | |
| @@ -0,0 +1,282 @@
 | |
| +/*
 | |
| + * 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 "WebPageInspectorInputAgent.h"
 | |
| +
 | |
| +#include "NativeWebKeyboardEvent.h"
 | |
| +#include "NativeWebMouseEvent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <wtf/MathExtras.h>
 | |
| +#include <wtf/HexNumber.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +using namespace Inspector;
 | |
| +
 | |
| +namespace {
 | |
| +
 | |
| +template<class T>
 | |
| +class CallbackList {
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    ~CallbackList()
 | |
| +    {
 | |
| +        for (const auto& callback : m_callbacks)
 | |
| +            callback->sendFailure("Page closed");
 | |
| +    }
 | |
| +
 | |
| +    void append(Ref<T>&& callback)
 | |
| +    {
 | |
| +        m_callbacks.append(WTFMove(callback));
 | |
| +    }
 | |
| +
 | |
| +    void sendSuccess()
 | |
| +    {
 | |
| +        for (const auto& callback : m_callbacks)
 | |
| +            callback->sendSuccess();
 | |
| +        m_callbacks.clear();
 | |
| +    }
 | |
| +
 | |
| +private:
 | |
| +    Vector<Ref<T>> m_callbacks;
 | |
| +};
 | |
| +
 | |
| +} // namespace
 | |
| +
 | |
| +class WebPageInspectorInputAgent::KeyboardCallbacks : public CallbackList<Inspector::InputBackendDispatcherHandler::DispatchKeyEventCallback> {
 | |
| +};
 | |
| +
 | |
| +class WebPageInspectorInputAgent::MouseCallbacks : public CallbackList<Inspector::InputBackendDispatcherHandler::DispatchMouseEventCallback> {
 | |
| +};
 | |
| +
 | |
| +WebPageInspectorInputAgent::WebPageInspectorInputAgent(Inspector::BackendDispatcher& backendDispatcher, WebPageProxy& page)
 | |
| +    : InspectorAgentBase("Input"_s)
 | |
| +    , m_backendDispatcher(InputBackendDispatcher::create(backendDispatcher, this))
 | |
| +    , m_page(page)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +WebPageInspectorInputAgent::~WebPageInspectorInputAgent() = default;
 | |
| +
 | |
| +void WebPageInspectorInputAgent::didProcessAllPendingKeyboardEvents()
 | |
| +{
 | |
| +    m_keyboardCallbacks->sendSuccess();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::didProcessAllPendingMouseEvents()
 | |
| +{
 | |
| +    m_mouseCallbacks->sendSuccess();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
 | |
| +{
 | |
| +    m_keyboardCallbacks = makeUnique<KeyboardCallbacks>();
 | |
| +    m_mouseCallbacks = makeUnique<MouseCallbacks>();
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
 | |
| +{
 | |
| +    m_keyboardCallbacks = nullptr;
 | |
| +    m_mouseCallbacks = nullptr;
 | |
| +}
 | |
| +
 | |
| +static String keyIdentifierForKey(const String& key)
 | |
| +{
 | |
| +    if (key.length() == 1)
 | |
| +        return makeString("U+", hex(toASCIIUpper(key.characterAt(0)), 4));
 | |
| +    if (key == "Delete")
 | |
| +        return "U+007F";
 | |
| +    if (key == "Backspace")
 | |
| +        return "U+0008";
 | |
| +    if (key == "ArrowUp")
 | |
| +        return "Up";
 | |
| +    if (key == "ArrowDown")
 | |
| +        return "Down";
 | |
| +    if (key == "ArrowLeft")
 | |
| +        return "Left";
 | |
| +    if (key == "ArrowRight")
 | |
| +        return "Right";
 | |
| +    if (key == "Tab")
 | |
| +        return "U+0009";
 | |
| +    if (key == "Pause")
 | |
| +        return "Pause";
 | |
| +    if (key == "ScrollLock")
 | |
| +        return "Scroll";
 | |
| +    return key;
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::dispatchKeyEvent(const String& type, const int* modifiers, const String* text, const String* unmodifiedText, const String* code, const String* key, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey, const JSON::Array* commands, Ref<Inspector::InputBackendDispatcherHandler::DispatchKeyEventCallback>&& callback)
 | |
| +{
 | |
| +    WebKit::WebEvent::Type eventType;
 | |
| +    if (type == "keyDown") {
 | |
| +        eventType = WebKit::WebEvent::KeyDown;
 | |
| +    } else if (type == "keyUp") {
 | |
| +        eventType = WebKit::WebEvent::KeyUp;
 | |
| +    } else {
 | |
| +        callback->sendFailure("Unsupported event type.");
 | |
| +        return;
 | |
| +    }
 | |
| +    OptionSet<WebEvent::Modifier> eventModifiers;
 | |
| +    if (modifiers)
 | |
| +        eventModifiers = eventModifiers.fromRaw(*modifiers);
 | |
| +    String eventText;
 | |
| +    if (text)
 | |
| +        eventText = *text;
 | |
| +    String eventUnmodifiedText;
 | |
| +    if (unmodifiedText)
 | |
| +        eventUnmodifiedText = *unmodifiedText;
 | |
| +    String eventCode;
 | |
| +    if (code)
 | |
| +        eventCode = *code;
 | |
| +    String eventKey;
 | |
| +    if (key)
 | |
| +        eventKey = *key;
 | |
| +    int eventWindowsVirtualKeyCode = 0;
 | |
| +    if (windowsVirtualKeyCode)
 | |
| +        eventWindowsVirtualKeyCode = *windowsVirtualKeyCode;
 | |
| +    int eventNativeVirtualKeyCode = 0;
 | |
| +    if (nativeVirtualKeyCode)
 | |
| +        eventNativeVirtualKeyCode = *nativeVirtualKeyCode;
 | |
| +    Vector<String> eventCommands;
 | |
| +    if (commands) {
 | |
| +      for (const auto& value : *commands) {
 | |
| +        String command;
 | |
| +        if (!value->asString(command)) {
 | |
| +          callback->sendFailure("Command must be string");
 | |
| +          return;
 | |
| +        }
 | |
| +        eventCommands.append(command);
 | |
| +      }
 | |
| +    }
 | |
| +
 | |
| +    String keyIdentifier = keyIdentifierForKey(eventKey);
 | |
| +
 | |
| +    bool eventIsAutoRepeat = false;
 | |
| +    if (autoRepeat)
 | |
| +        eventIsAutoRepeat = *autoRepeat;
 | |
| +    bool eventIsKeypad = false;
 | |
| +    if (isKeypad)
 | |
| +        eventIsKeypad = *isKeypad;
 | |
| +    bool eventIsSystemKey = false;
 | |
| +    if (isSystemKey)
 | |
| +        eventIsSystemKey = *isSystemKey;
 | |
| +    WallTime timestamp = WallTime::now();
 | |
| +
 | |
| +    m_keyboardCallbacks->append(WTFMove(callback));
 | |
| +    platformDispatchKeyEvent(
 | |
| +        eventType,
 | |
| +        eventText,
 | |
| +        eventUnmodifiedText,
 | |
| +        eventKey,
 | |
| +        eventCode,
 | |
| +        keyIdentifier,
 | |
| +        eventWindowsVirtualKeyCode,
 | |
| +        eventNativeVirtualKeyCode,
 | |
| +        eventIsAutoRepeat,
 | |
| +        eventIsKeypad,
 | |
| +        eventIsSystemKey,
 | |
| +        eventModifiers,
 | |
| +        eventCommands,
 | |
| +        timestamp);
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::dispatchMouseEvent(const String& type, int x, int y, const int* modifiers, const String* button, const int* buttons, const int* clickCount, const int* deltaX, const int* deltaY, Ref<DispatchMouseEventCallback>&& callback)
 | |
| +{
 | |
| +    WebEvent::Type eventType = WebEvent::NoType;
 | |
| +    if (type == "down")
 | |
| +        eventType = WebEvent::MouseDown;
 | |
| +    else if (type == "up")
 | |
| +        eventType = WebEvent::MouseUp;
 | |
| +    else if (type == "move")
 | |
| +        eventType = WebEvent::MouseMove;
 | |
| +    else {
 | |
| +        callback->sendFailure("Unsupported event type");
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    OptionSet<WebEvent::Modifier> eventModifiers;
 | |
| +    if (modifiers)
 | |
| +        eventModifiers = eventModifiers.fromRaw(*modifiers);
 | |
| +
 | |
| +    WebMouseEvent::Button eventButton = WebMouseEvent::NoButton;
 | |
| +    if (button) {
 | |
| +        if (*button == "left")
 | |
| +            eventButton = WebMouseEvent::LeftButton;
 | |
| +        else if (*button == "middle")
 | |
| +            eventButton = WebMouseEvent::MiddleButton;
 | |
| +        else if (*button == "right")
 | |
| +            eventButton = WebMouseEvent::RightButton;
 | |
| +        else if (*button == "none")
 | |
| +            eventButton = WebMouseEvent::NoButton;
 | |
| +        else {
 | |
| +            callback->sendFailure("Unsupported eventButton");
 | |
| +            return;
 | |
| +        }
 | |
| +    }
 | |
| +
 | |
| +    unsigned short eventButtons = 0;
 | |
| +    if (buttons)
 | |
| +        eventButtons = *buttons;
 | |
| +
 | |
| +    int eventClickCount = 0;
 | |
| +    if (clickCount)
 | |
| +        eventClickCount = *clickCount;
 | |
| +    int eventDeltaX = 0;
 | |
| +    if (deltaX)
 | |
| +        eventDeltaX = *deltaX;
 | |
| +    int eventDeltaY = 0;
 | |
| +    if (deltaY)
 | |
| +        eventDeltaY = *deltaY;
 | |
| +    m_mouseCallbacks->append(WTFMove(callback));
 | |
| +
 | |
| +    // Convert css coordinates to view coordinates (dip).
 | |
| +    double totalScale = m_page.pageScaleFactor() * m_page.viewScaleFactor();
 | |
| +    x = clampToInteger(roundf(x * totalScale));
 | |
| +    y = clampToInteger(roundf(y * totalScale));
 | |
| +    eventDeltaX = clampToInteger(roundf(eventDeltaX * totalScale));
 | |
| +    eventDeltaY = clampToInteger(roundf(eventDeltaY * totalScale));
 | |
| +
 | |
| +#if PLATFORM(MAC)
 | |
| +    platformDispatchMouseEvent(type, x, y, modifiers, button, clickCount);
 | |
| +#elif PLATFORM(GTK) || PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +    WallTime timestamp = WallTime::now();
 | |
| +    NativeWebMouseEvent event(
 | |
| +        eventType,
 | |
| +        eventButton,
 | |
| +        eventButtons,
 | |
| +        {x, y},
 | |
| +        WebCore::IntPoint(),
 | |
| +        eventDeltaX,
 | |
| +        eventDeltaY,
 | |
| +        0,
 | |
| +        eventClickCount,
 | |
| +        eventModifiers,
 | |
| +        timestamp);
 | |
| +    m_page.handleMouseEvent(event);
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/WebPageInspectorInputAgent.h b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..20311d530090b0229010957a96fc60f44b4823fe
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.h
 | |
| @@ -0,0 +1,84 @@
 | |
| +/*
 | |
| + * 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
 | |
| +
 | |
| +#include "WebEvent.h"
 | |
| +
 | |
| +#include <JavaScriptCore/InspectorAgentBase.h>
 | |
| +#include <JavaScriptCore/InspectorBackendDispatchers.h>
 | |
| +
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/Noncopyable.h>
 | |
| +
 | |
| +namespace Inspector {
 | |
| +class BackendDispatcher;
 | |
| +class FrontendChannel;
 | |
| +class FrontendRouter;
 | |
| +}
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class NativeWebKeyboardEvent;
 | |
| +class WebPageProxy;
 | |
| +
 | |
| +class WebPageInspectorInputAgent : public Inspector::InspectorAgentBase, public Inspector::InputBackendDispatcherHandler {
 | |
| +    WTF_MAKE_NONCOPYABLE(WebPageInspectorInputAgent);
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    WebPageInspectorInputAgent(Inspector::BackendDispatcher& backendDispatcher, WebPageProxy& page);
 | |
| +    ~WebPageInspectorInputAgent() override;
 | |
| +
 | |
| +    void didProcessAllPendingKeyboardEvents();
 | |
| +    void didProcessAllPendingMouseEvents();
 | |
| +
 | |
| +    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
 | |
| +    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
 | |
| +
 | |
| +    // Protocol handler
 | |
| +    void dispatchKeyEvent(const String& type, const int* modifiers, const String* text, const String* unmodifiedText, const String* code, const String* key, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey, const JSON::Array*, Ref<DispatchKeyEventCallback>&& callback) override;
 | |
| +    void dispatchMouseEvent(const String& type, int x, int y, const int* modifiers, const String* button, const int* buttons, const int* clickCount, const int* deltaX, const int* deltaY, Ref<DispatchMouseEventCallback>&& callback) override;
 | |
| +
 | |
| +private:
 | |
| +    void platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& commands, WallTime timestamp);
 | |
| +#if PLATFORM(WPE)
 | |
| +    void platformDispatchMouseEvent(WebMouseEvent::Type type, int x, int y, WebMouseEvent::Button button, OptionSet<WebEvent::Modifier> modifiers);
 | |
| +#endif
 | |
| +#if PLATFORM(MAC)
 | |
| +    void platformDispatchMouseEvent(const String& type, int x, int y, const int* modifier, const String* button, const int* clickCount);
 | |
| +#endif
 | |
| +
 | |
| +    Ref<Inspector::InputBackendDispatcher> m_backendDispatcher;
 | |
| +    WebPageProxy& m_page;
 | |
| +    // Keep track of currently active modifiers across multiple keystrokes.
 | |
| +    // Most platforms do not track current modifiers from synthesized events.
 | |
| +    unsigned m_currentModifiers { 0 };
 | |
| +    class KeyboardCallbacks;
 | |
| +    std::unique_ptr<KeyboardCallbacks> m_keyboardCallbacks;
 | |
| +    class MouseCallbacks;
 | |
| +    std::unique_ptr<MouseCallbacks> m_mouseCallbacks;
 | |
| +};
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp
 | |
| index 4ffe7e38f2e4139ebc2d30dcc54c783a4675fe05..dadc08aeea4feca8e85c75ecd76b2c32f9527d4f 100644
 | |
| --- a/Source/WebKit/UIProcess/WebPageProxy.cpp
 | |
| +++ b/Source/WebKit/UIProcess/WebPageProxy.cpp
 | |
| @@ -946,6 +946,7 @@ void WebPageProxy::finishAttachingToWebProcess(ProcessLaunchReason reason)
 | |
|      m_pageLoadState.didSwapWebProcesses();
 | |
|      if (reason != ProcessLaunchReason::InitialProcess)
 | |
|          m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
 | |
| +    m_inspectorController->didFinishAttachingToWebProcess();
 | |
|  }
 | |
|  
 | |
|  void WebPageProxy::didAttachToRunningProcess()
 | |
| @@ -1266,6 +1267,21 @@ WebProcessProxy& WebPageProxy::ensureRunningProcess()
 | |
|      return m_process;
 | |
|  }
 | |
|  
 | |
| +RefPtr<API::Navigation> WebPageProxy::loadRequestForInspector(WebCore::ResourceRequest&& request, WebFrameProxy* frame)
 | |
| +{
 | |
| +    if (!frame || frame == mainFrame())
 | |
| +        return loadRequest(WTFMove(request), WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);
 | |
| +
 | |
| +    auto navigation = m_navigationState->createLoadRequestNavigation(ResourceRequest(request), m_backForwardList->currentItem());
 | |
| +    LoadParameters loadParameters;
 | |
| +    loadParameters.navigationID = navigation->navigationID();
 | |
| +    loadParameters.request = WTFMove(request);
 | |
| +    loadParameters.shouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow;
 | |
| +    loadParameters.shouldTreatAsContinuingLoad = false;
 | |
| +    m_process->send(Messages::WebPage::LoadRequestInFrameForInspector(loadParameters, frame->frameID()),  m_webPageID);
 | |
| +    return navigation;
 | |
| +}
 | |
| +
 | |
|  RefPtr<API::Navigation> WebPageProxy::loadRequest(ResourceRequest&& request, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, API::Object* userData)
 | |
|  {
 | |
|      if (m_isClosed)
 | |
| @@ -1731,6 +1747,31 @@ void WebPageProxy::setControlledByAutomation(bool controlled)
 | |
|      m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::SetSessionIsControlledByAutomation(m_websiteDataStore->sessionID(), m_controlledByAutomation));
 | |
|  }
 | |
|  
 | |
| +void WebPageProxy::setAuthCredentialsForAutomation(Optional<WebCore::Credential>&& credentials)
 | |
| +{
 | |
| +    m_credentialsForAutomation = WTFMove(credentials);
 | |
| +}
 | |
| +
 | |
| +void WebPageProxy::setPermissionsForAutomation(const HashMap<String, HashSet<String>>& permissions)
 | |
| +{
 | |
| +    m_permissionsForAutomation = permissions;
 | |
| +}
 | |
| +
 | |
| +void WebPageProxy::setActiveForAutomation(Optional<bool> active) {
 | |
| +    m_activeForAutomation = active;
 | |
| +    OptionSet<ActivityState::Flag> state;
 | |
| +    state.add(ActivityState::IsFocused);
 | |
| +    state.add(ActivityState::WindowIsActive);
 | |
| +    state.add(ActivityState::IsVisible);
 | |
| +    state.add(ActivityState::IsVisibleOrOccluded);
 | |
| +    activityStateDidChange(state);
 | |
| +}
 | |
| +
 | |
| +void WebPageProxy::logToStderr(const String& str)
 | |
| +{
 | |
| +    fprintf(stderr, "RENDERER: %s\n", str.utf8().data());
 | |
| +}
 | |
| +
 | |
|  void WebPageProxy::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type)
 | |
|  {
 | |
|      MESSAGE_CHECK(m_process, !targetId.isEmpty());
 | |
| @@ -1873,6 +1914,25 @@ void WebPageProxy::updateActivityState(OptionSet<ActivityState::Flag> flagsToUpd
 | |
|  {
 | |
|      bool wasVisible = isViewVisible();
 | |
|      m_activityState.remove(flagsToUpdate);
 | |
| +
 | |
| +
 | |
| +    if (m_activeForAutomation) {
 | |
| +        if (*m_activeForAutomation) {
 | |
| +            if (flagsToUpdate & ActivityState::IsFocused)
 | |
| +                m_activityState.add(ActivityState::IsFocused);
 | |
| +            if (flagsToUpdate & ActivityState::WindowIsActive)
 | |
| +                m_activityState.add(ActivityState::WindowIsActive);
 | |
| +            if (flagsToUpdate & ActivityState::IsVisible)
 | |
| +                m_activityState.add(ActivityState::IsVisible);
 | |
| +            if (flagsToUpdate & ActivityState::IsVisibleOrOccluded)
 | |
| +                m_activityState.add(ActivityState::IsVisibleOrOccluded);
 | |
| +        }
 | |
| +        flagsToUpdate.remove(ActivityState::IsFocused);
 | |
| +        flagsToUpdate.remove(ActivityState::WindowIsActive);
 | |
| +        flagsToUpdate.remove(ActivityState::IsVisible);
 | |
| +        flagsToUpdate.remove(ActivityState::IsVisibleOrOccluded);
 | |
| +    }
 | |
| +
 | |
|      if (flagsToUpdate & ActivityState::IsFocused && pageClient().isViewFocused())
 | |
|          m_activityState.add(ActivityState::IsFocused);
 | |
|      if (flagsToUpdate & ActivityState::WindowIsActive && pageClient().isViewWindowActive())
 | |
| @@ -2831,7 +2891,7 @@ static TrackingType mergeTrackingTypes(TrackingType a, TrackingType b)
 | |
|  
 | |
|  void WebPageProxy::updateTouchEventTracking(const WebTouchEvent& touchStartEvent)
 | |
|  {
 | |
| -#if ENABLE(ASYNC_SCROLLING) && PLATFORM(COCOA)
 | |
| +#if ENABLE(ASYNC_SCROLLING) && PLATFORM(IOS_FAMILY)
 | |
|      const EventNames& names = eventNames();
 | |
|      for (auto& touchPoint : touchStartEvent.touchPoints()) {
 | |
|          IntPoint location = touchPoint.location();
 | |
| @@ -2864,7 +2924,7 @@ void WebPageProxy::updateTouchEventTracking(const WebTouchEvent& touchStartEvent
 | |
|      m_touchAndPointerEventTracking.touchStartTracking = TrackingType::Synchronous;
 | |
|      m_touchAndPointerEventTracking.touchMoveTracking = TrackingType::Synchronous;
 | |
|      m_touchAndPointerEventTracking.touchEndTracking = TrackingType::Synchronous;
 | |
| -#endif // ENABLE(ASYNC_SCROLLING)
 | |
| +#endif // ENABLE(ASYNC_SCROLLING) && PLATFORM(IOS_FAMILY)
 | |
|  }
 | |
|  
 | |
|  TrackingType WebPageProxy::touchEventTrackingType(const WebTouchEvent& touchStartEvent) const
 | |
| @@ -3293,6 +3353,7 @@ void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, A
 | |
|  
 | |
|  void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, RefPtr<API::WebsitePolicies>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, Optional<SandboxExtension::Handle> sandboxExtensionHandle, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
 | |
|  {
 | |
| +    m_inspectorController->didReceivePolicyDecision(action, navigation ? navigation->navigationID() : 0);
 | |
|      if (!hasRunningProcess()) {
 | |
|          sender->send(PolicyDecision { sender->identifier(), isNavigatingToAppBoundDomain(), PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt });
 | |
|          return;
 | |
| @@ -3995,6 +4056,11 @@ void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
 | |
|      m_pageScaleFactor = scaleFactor;
 | |
|  }
 | |
|  
 | |
| +void WebPageProxy::viewScaleFactorDidChange(double scaleFactor)
 | |
| +{
 | |
| +    m_viewScaleFactor = scaleFactor;
 | |
| +}
 | |
| +
 | |
|  void WebPageProxy::pluginScaleFactorDidChange(double pluginScaleFactor)
 | |
|  {
 | |
|      m_pluginScaleFactor = pluginScaleFactor;
 | |
| @@ -4414,6 +4480,7 @@ void WebPageProxy::didDestroyNavigation(uint64_t navigationID)
 | |
|  
 | |
|      // FIXME: Message check the navigationID.
 | |
|      m_navigationState->didDestroyNavigation(navigationID);
 | |
| +    m_inspectorController->didDestroyNavigation(navigationID);
 | |
|  }
 | |
|  
 | |
|  void WebPageProxy::didStartProvisionalLoadForFrame(FrameIdentifier frameID, FrameInfoData&& frameInfo, ResourceRequest&& request, uint64_t navigationID, URL&& url, URL&& unreachableURL, const UserData& userData)
 | |
| @@ -4638,6 +4705,8 @@ void WebPageProxy::didFailProvisionalLoadForFrameShared(Ref<WebProcessProxy>&& p
 | |
|  
 | |
|      m_failingProvisionalLoadURL = { };
 | |
|  
 | |
| +    m_inspectorController->didFailProvisionalLoadForFrame(navigationID, error);
 | |
| +
 | |
|      // 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;
 | |
| @@ -5079,7 +5148,14 @@ void WebPageProxy::decidePolicyForNavigationActionAsync(FrameIdentifier frameID,
 | |
|      NavigationActionData&& navigationActionData, FrameInfoData&& originatingFrameInfo, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&& request,
 | |
|      IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, const UserData& userData, uint64_t listenerID)
 | |
|  {
 | |
| -    decidePolicyForNavigationActionAsyncShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, WTFMove(navigationActionData), WTFMove(originatingFrameInfo), originatingPageID, originalRequest, WTFMove(request), WTFMove(requestBody), WTFMove(redirectResponse), userData, listenerID);
 | |
| +    if (m_inspectorController->shouldPauseLoading()) {
 | |
| +        m_inspectorController->setContinueLoadingCallback([this, protectedThis = makeRef(*this), frameID, frameInfo = WTFMove(frameInfo), identifier, navigationID, navigationActionData = WTFMove(navigationActionData),
 | |
| +                originatingFrameInfo = WTFMove(originatingFrameInfo), originatingPageID, originalRequest, request = WTFMove(request), requestBody = WTFMove(requestBody), redirectResponse = WTFMove(redirectResponse), userData, listenerID] () mutable {
 | |
| +            decidePolicyForNavigationActionAsyncShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, WTFMove(navigationActionData), WTFMove(originatingFrameInfo), originatingPageID, originalRequest, WTFMove(request), WTFMove(requestBody), WTFMove(redirectResponse), userData, listenerID);
 | |
| +        });
 | |
| +    } else {
 | |
| +        decidePolicyForNavigationActionAsyncShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, WTFMove(navigationActionData), WTFMove(originatingFrameInfo), originatingPageID, originalRequest, WTFMove(request), WTFMove(requestBody), WTFMove(redirectResponse), userData, listenerID);
 | |
| +    }
 | |
|  }
 | |
|  
 | |
|  void WebPageProxy::decidePolicyForNavigationActionAsyncShared(Ref<WebProcessProxy>&& process, PageIdentifier webPageID, FrameIdentifier frameID, FrameInfoData&& frameInfo,
 | |
| @@ -5584,6 +5660,7 @@ void WebPageProxy::createNewPage(FrameInfoData&& originatingFrameInfoData, Optio
 | |
|      auto* originatingPage = m_process->webPage(*originatingPageID);
 | |
|      auto originatingFrameInfo = API::FrameInfo::create(WTFMove(originatingFrameInfoData), originatingPage);
 | |
|      auto mainFrameURL = m_mainFrame ? m_mainFrame->url() : URL();
 | |
| +    m_inspectorController->willCreateNewPage(windowFeatures, request.url());
 | |
|      auto completionHandler = [this, protectedThis = makeRef(*this), mainFrameURL, request, reply = WTFMove(reply)] (RefPtr<WebPageProxy> newPage) mutable {
 | |
|          if (!newPage) {
 | |
|              reply(WTF::nullopt, WTF::nullopt);
 | |
| @@ -5613,6 +5690,7 @@ void WebPageProxy::createNewPage(FrameInfoData&& originatingFrameInfoData, Optio
 | |
|  void WebPageProxy::showPage()
 | |
|  {
 | |
|      m_uiClient->showPage(this);
 | |
| +    m_inspectorController->didShowPage();
 | |
|  }
 | |
|  
 | |
|  void WebPageProxy::exitFullscreenImmediately()
 | |
| @@ -5667,6 +5745,8 @@ void WebPageProxy::runJavaScriptAlert(FrameIdentifier frameID, FrameInfoData&& f
 | |
|          if (auto* automationSession = process().processPool().automationSession())
 | |
|              automationSession->willShowJavaScriptDialog(*this);
 | |
|      }
 | |
| +    if (m_inspectorDialogAgent)
 | |
| +        m_inspectorDialogAgent->javascriptDialogOpening("alert"_s, message);
 | |
|      m_uiClient->runJavaScriptAlert(*this, message, frame, WTFMove(frameInfo), WTFMove(reply));
 | |
|  }
 | |
|  
 | |
| @@ -5684,6 +5764,8 @@ void WebPageProxy::runJavaScriptConfirm(FrameIdentifier frameID, FrameInfoData&&
 | |
|          if (auto* automationSession = process().processPool().automationSession())
 | |
|              automationSession->willShowJavaScriptDialog(*this);
 | |
|      }
 | |
| +    if (m_inspectorDialogAgent)
 | |
| +        m_inspectorDialogAgent->javascriptDialogOpening("confirm"_s, message);
 | |
|  
 | |
|      m_uiClient->runJavaScriptConfirm(*this, message, frame, WTFMove(frameInfo), WTFMove(reply));
 | |
|  }
 | |
| @@ -5702,6 +5784,8 @@ void WebPageProxy::runJavaScriptPrompt(FrameIdentifier frameID, FrameInfoData&&
 | |
|          if (auto* automationSession = process().processPool().automationSession())
 | |
|              automationSession->willShowJavaScriptDialog(*this);
 | |
|      }
 | |
| +    if (m_inspectorDialogAgent)
 | |
| +        m_inspectorDialogAgent->javascriptDialogOpening("prompt"_s, message, &defaultValue);
 | |
|  
 | |
|      m_uiClient->runJavaScriptPrompt(*this, message, defaultValue, frame, WTFMove(frameInfo), WTFMove(reply));
 | |
|  }
 | |
| @@ -5861,6 +5945,8 @@ void WebPageProxy::runBeforeUnloadConfirmPanel(FrameIdentifier frameID, FrameInf
 | |
|              return;
 | |
|          }
 | |
|      }
 | |
| +    if (m_inspectorDialogAgent)
 | |
| +        m_inspectorDialogAgent->javascriptDialogOpening("beforeunload"_s, message);
 | |
|  
 | |
|      // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer and the tryClose timer.
 | |
|      m_process->stopResponsivenessTimer();
 | |
| @@ -6917,6 +7003,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
 | |
|              if (auto* automationSession = process().processPool().automationSession())
 | |
|                  automationSession->mouseEventsFlushedForPage(*this);
 | |
|              didFinishProcessingAllPendingMouseEvents();
 | |
| +            m_inspectorController->didProcessAllPendingMouseEvents();
 | |
|          }
 | |
|  
 | |
|          break;
 | |
| @@ -6943,7 +7030,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());
 | |
| -
 | |
|          MESSAGE_CHECK(m_process, !m_keyEventQueue.isEmpty());
 | |
|          NativeWebKeyboardEvent event = m_keyEventQueue.takeFirst();
 | |
|  
 | |
| @@ -6963,7 +7049,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);
 | |
| -
 | |
|          pageClient().doneWithKeyEvent(event, handled);
 | |
|          if (!handled)
 | |
|              m_uiClient->didNotHandleKeyEvent(this, event);
 | |
| @@ -6972,6 +7057,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
 | |
|          if (!canProcessMoreKeyEvents) {
 | |
|              if (auto* automationSession = process().processPool().automationSession())
 | |
|                  automationSession->keyboardEventsFlushedForPage(*this);
 | |
| +            m_inspectorController->didProcessAllPendingKeyboardEvents();
 | |
|          }
 | |
|          break;
 | |
|      }
 | |
| @@ -7417,8 +7503,10 @@ static bool shouldReloadAfterProcessTermination(ProcessTerminationReason reason)
 | |
|  void WebPageProxy::dispatchProcessDidTerminate(ProcessTerminationReason reason)
 | |
|  {
 | |
|      RELEASE_LOG_IF_ALLOWED(Loading, "dispatchProcessDidTerminate: reason = %d", reason);
 | |
| +    bool handledByClient = m_inspectorController->pageCrashed(reason);
 | |
| +    if (handledByClient)
 | |
| +        return;
 | |
|  
 | |
| -    bool handledByClient = false;
 | |
|      if (m_loaderClient)
 | |
|          handledByClient = reason != ProcessTerminationReason::RequestedByClient && m_loaderClient->processDidCrash(*this);
 | |
|      else
 | |
| @@ -7708,6 +7796,7 @@ void WebPageProxy::resetStateAfterProcessExited(ProcessTerminationReason termina
 | |
|  
 | |
|  WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& process, DrawingAreaProxy& drawingArea, RefPtr<API::WebsitePolicies>&& websitePolicies)
 | |
|  {
 | |
| +
 | |
|      WebPageCreationParameters parameters;
 | |
|  
 | |
|      parameters.processDisplayName = configuration().processDisplayName();
 | |
| @@ -7852,6 +7941,8 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc
 | |
|      parameters.shouldCaptureDisplayInUIProcess = m_process->processPool().configuration().shouldCaptureDisplayInUIProcess();
 | |
|      parameters.limitsNavigationsToAppBoundDomains = m_limitsNavigationsToAppBoundDomains;
 | |
|  
 | |
| +    parameters.shouldPauseInInspectorWhenShown = m_inspectorController->shouldPauseLoading();
 | |
| +
 | |
|  #if PLATFORM(GTK)
 | |
|      parameters.themeName = pageClient().themeName();
 | |
|  #endif
 | |
| @@ -7923,6 +8014,14 @@ void WebPageProxy::gamepadActivity(const Vector<GamepadData>& gamepadDatas, bool
 | |
|  
 | |
|  void WebPageProxy::didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&& authenticationChallenge, NegotiatedLegacyTLS negotiatedLegacyTLS)
 | |
|  {
 | |
| +    if (m_credentialsForAutomation.hasValue()) {
 | |
| +        if (m_credentialsForAutomation->isEmpty() || authenticationChallenge->core().previousFailureCount()) {
 | |
| +            authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::PerformDefaultHandling);
 | |
| +            return;
 | |
| +        }
 | |
| +        authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::UseCredential, *m_credentialsForAutomation);
 | |
| +        return;
 | |
| +    }
 | |
|      if (negotiatedLegacyTLS == NegotiatedLegacyTLS::Yes) {
 | |
|          m_navigationClient->shouldAllowLegacyTLS(*this, authenticationChallenge.get(), [this, protectedThis = makeRef(*this), authenticationChallenge = authenticationChallenge.copyRef()] (bool shouldAllowLegacyTLS) {
 | |
|              if (shouldAllowLegacyTLS)
 | |
| @@ -8008,7 +8107,8 @@ void WebPageProxy::requestGeolocationPermissionForFrame(GeolocationIdentifier ge
 | |
|      MESSAGE_CHECK(m_process, frame);
 | |
|  
 | |
|      // FIXME: Geolocation should probably be using toString() as its string representation instead of databaseIdentifier().
 | |
| -    auto origin = API::SecurityOrigin::create(frameInfo.securityOrigin.securityOrigin());
 | |
| +    auto securityOrigin = frameInfo.securityOrigin.securityOrigin();
 | |
| +    auto origin = API::SecurityOrigin::create(securityOrigin);
 | |
|      auto request = m_geolocationPermissionRequestManager.createRequest(geolocationID);
 | |
|      Function<void(bool)> completionHandler = [request = WTFMove(request)](bool allowed) {
 | |
|          if (allowed)
 | |
| @@ -8017,6 +8117,14 @@ void WebPageProxy::requestGeolocationPermissionForFrame(GeolocationIdentifier ge
 | |
|              request->deny();
 | |
|      };
 | |
|  
 | |
| +    auto permissions = m_permissionsForAutomation.find(securityOrigin->toString());
 | |
| +    if (permissions == m_permissionsForAutomation.end())
 | |
| +      permissions = m_permissionsForAutomation.find("*");
 | |
| +    if (permissions != m_permissionsForAutomation.end()) {
 | |
| +        completionHandler(permissions->value.contains("geolocation"));
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      // FIXME: Once iOS migrates to the new WKUIDelegate SPI, clean this up
 | |
|      // and make it one UIClient call that calls the completionHandler with false
 | |
|      // if there is no delegate instead of returning the completionHandler
 | |
| diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h
 | |
| index e551ae553338004fe56312d76e24aae7da36f7d6..141b05dd5beb6c3d079f03a300ebb217b84e5881 100644
 | |
| --- a/Source/WebKit/UIProcess/WebPageProxy.h
 | |
| +++ b/Source/WebKit/UIProcess/WebPageProxy.h
 | |
| @@ -37,6 +37,7 @@
 | |
|  #include "GeolocationIdentifier.h"
 | |
|  #include "GeolocationPermissionRequestManagerProxy.h"
 | |
|  #include "HiddenPageThrottlingAutoIncreasesCounter.h"
 | |
| +#include "InspectorDialogAgent.h"
 | |
|  #include "LayerTreeContext.h"
 | |
|  #include "MessageSender.h"
 | |
|  #include "NotificationPermissionRequestManagerProxy.h"
 | |
| @@ -501,6 +502,8 @@ public:
 | |
|      void setControlledByAutomation(bool);
 | |
|  
 | |
|      WebPageInspectorController& inspectorController() { return *m_inspectorController; }
 | |
| +    InspectorDialogAgent* inspectorDialogAgent() { return m_inspectorDialogAgent; }
 | |
| +    void setInspectorDialogAgent(InspectorDialogAgent * dialogAgent) { m_inspectorDialogAgent = dialogAgent; }
 | |
|  
 | |
|  #if PLATFORM(IOS_FAMILY)
 | |
|      void showInspectorIndication();
 | |
| @@ -575,6 +578,11 @@ public:
 | |
|  
 | |
|      void setPageLoadStateObserver(std::unique_ptr<PageLoadState::Observer>&&);
 | |
|  
 | |
| +    void setAuthCredentialsForAutomation(Optional<WebCore::Credential>&&);
 | |
| +    void setPermissionsForAutomation(const HashMap<String, HashSet<String>>&);
 | |
| +    void setActiveForAutomation(Optional<bool> active);
 | |
| +    void logToStderr(const String& str);
 | |
| +
 | |
|      void initializeWebPage();
 | |
|      void setDrawingArea(std::unique_ptr<DrawingAreaProxy>&&);
 | |
|  
 | |
| @@ -600,6 +608,7 @@ public:
 | |
|      void closePage();
 | |
|  
 | |
|      void addPlatformLoadParameters(LoadParameters&);
 | |
| +    RefPtr<API::Navigation> loadRequestForInspector(WebCore::ResourceRequest&&, WebFrameProxy*);
 | |
|      RefPtr<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);
 | |
| @@ -1087,6 +1096,7 @@ public:
 | |
|  #endif
 | |
|  
 | |
|      void pageScaleFactorDidChange(double);
 | |
| +    void viewScaleFactorDidChange(double);
 | |
|      void pluginScaleFactorDidChange(double);
 | |
|      void pluginZoomFactorDidChange(double);
 | |
|  
 | |
| @@ -1404,6 +1414,8 @@ public:
 | |
|  
 | |
|  #if PLATFORM(COCOA) || PLATFORM(GTK)
 | |
|      RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&);
 | |
| +#elif PLATFORM(WPE)
 | |
| +    RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&) { return nullptr; }
 | |
|  #endif
 | |
|  
 | |
|  #if ENABLE(WEB_CRYPTO)
 | |
| @@ -2382,6 +2394,7 @@ private:
 | |
|      String m_overrideContentSecurityPolicy;
 | |
|  
 | |
|      RefPtr<WebInspectorProxy> m_inspector;
 | |
| +    InspectorDialogAgent* m_inspectorDialogAgent { nullptr };
 | |
|  
 | |
|  #if ENABLE(FULLSCREEN_API)
 | |
|      std::unique_ptr<WebFullScreenManagerProxy> m_fullScreenManager;
 | |
| @@ -2810,6 +2823,9 @@ private:
 | |
|          RefPtr<API::Object> messageBody;
 | |
|      };
 | |
|      Vector<InjectedBundleMessage> m_pendingInjectedBundleMessages;
 | |
| +    Optional<WebCore::Credential> m_credentialsForAutomation;
 | |
| +    HashMap<String, HashSet<String>> m_permissionsForAutomation;
 | |
| +    Optional<bool> m_activeForAutomation;
 | |
|          
 | |
|  #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 fc12f7b20ac77c78edeb638011f6af0e93115d5f..710a2609d3c8dc095f881dc60a388c19b2d46583 100644
 | |
| --- a/Source/WebKit/UIProcess/WebPageProxy.messages.in
 | |
| +++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in
 | |
| @@ -29,6 +29,7 @@ messages -> WebPageProxy {
 | |
|      RunJavaScriptConfirm(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, String message) -> (bool result) Synchronous
 | |
|      RunJavaScriptPrompt(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, String message, String defaultValue) -> (String result) Synchronous
 | |
|      MouseDidMoveOverElement(struct WebKit::WebHitTestResultData hitTestResultData, uint32_t modifiers, WebKit::UserData userData)
 | |
| +    LogToStderr(String text)
 | |
|  
 | |
|  #if ENABLE(NETSCAPE_PLUGIN_API)
 | |
|      UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
 | |
| @@ -204,6 +205,7 @@ messages -> WebPageProxy {
 | |
|      FindStringCallback(bool found, WebKit::CallbackID callbackID)
 | |
|  
 | |
|      PageScaleFactorDidChange(double scaleFactor)
 | |
| +    ViewScaleFactorDidChange(double scaleFactor)
 | |
|      PluginScaleFactorDidChange(double zoomFactor)
 | |
|      PluginZoomFactorDidChange(double zoomFactor)
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp
 | |
| index abc8888727c89177b420d253d7547ed14ff78bea..60bc5d92194fa9125efa2060f8ff640e3b4f9337 100644
 | |
| --- a/Source/WebKit/UIProcess/WebProcessPool.cpp
 | |
| +++ b/Source/WebKit/UIProcess/WebProcessPool.cpp
 | |
| @@ -1029,7 +1029,10 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
 | |
|  #endif
 | |
|  
 | |
|      parameters.cacheModel = LegacyGlobalSettings::singleton().cacheModel();
 | |
| -    parameters.languages = configuration().overrideLanguages().isEmpty() ? userPreferredLanguages() : configuration().overrideLanguages();
 | |
| +    if (websiteDataStore && websiteDataStore->languagesForAutomation().size())
 | |
| +        parameters.languages = websiteDataStore->languagesForAutomation();
 | |
| +    else
 | |
| +        parameters.languages = configuration().overrideLanguages().isEmpty() ? userPreferredLanguages() : configuration().overrideLanguages();
 | |
|  
 | |
|      parameters.urlSchemesRegisteredAsEmptyDocument = copyToVector(m_schemesToRegisterAsEmptyDocument);
 | |
|      parameters.urlSchemesRegisteredAsSecure = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsSecure());
 | |
| diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h
 | |
| index c935df2f7d273f9059f638a50dc6f112df6a7dfb..ae529922438a03c1742509a84a04acb28b437bf7 100644
 | |
| --- a/Source/WebKit/UIProcess/WebProcessPool.h
 | |
| +++ b/Source/WebKit/UIProcess/WebProcessPool.h
 | |
| @@ -710,8 +710,8 @@ private:
 | |
|  
 | |
|      HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
 | |
|  
 | |
| -#if USE(SOUP)
 | |
| -    bool m_ignoreTLSErrors { true };
 | |
| +#if USE(SOUP) || PLATFORM(COCOA) || PLATFORM(WIN)
 | |
| +    bool m_ignoreTLSErrors { false };
 | |
|  #endif
 | |
|  
 | |
|      bool m_memoryCacheDisabled { false };
 | |
| diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
 | |
| index 14837bd6364ceaad24fdad7b3fb4295278733119..3bd11862f58581ae87dd2775ef7fa759da7b9f93 100644
 | |
| --- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
 | |
| +++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
 | |
| @@ -185,6 +185,8 @@ void WebsiteDataStore::registerProcess(WebProcessProxy& process)
 | |
|  {
 | |
|      ASSERT(process.pageCount() || process.provisionalPageCount());
 | |
|      m_processes.add(process);
 | |
| +    if (m_languagesForAutomation.size())
 | |
| +        process.send(Messages::WebProcess::UserPreferredLanguagesChanged(m_languagesForAutomation), 0);
 | |
|  }
 | |
|  
 | |
|  void WebsiteDataStore::unregisterProcess(WebProcessProxy& process)
 | |
| @@ -2435,6 +2437,19 @@ void WebsiteDataStore::renameOriginInWebsiteData(URL&& oldName, URL&& newName, O
 | |
|      }
 | |
|  }
 | |
|  
 | |
| +void WebsiteDataStore::setLanguagesForAutomation(Vector<String>&& languages)
 | |
| +{
 | |
| +    m_languagesForAutomation = WTFMove(languages);
 | |
| +    for (auto& process : processes())
 | |
| +        process.send(Messages::WebProcess::UserPreferredLanguagesChanged(languages), 0);
 | |
| +}
 | |
| +
 | |
| +void WebsiteDataStore::setDownloadForAutomation(Optional<bool> allow, const String& downloadPath)
 | |
| +{
 | |
| +    m_allowDownloadForAutomation = allow;
 | |
| +    m_downloadPathForAutomation = downloadPath;
 | |
| +}
 | |
| +
 | |
|  #if PLATFORM(COCOA)
 | |
|  void WebsiteDataStore::forwardAppBoundDomainsToITPIfInitialized(CompletionHandler<void()>&& completionHandler)
 | |
|  {
 | |
| diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
 | |
| index a35b697975a9f15de122291d9bd8da3a23124ad7..1a1cad298c764809ae056d69c9d852534a1b5c29 100644
 | |
| --- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
 | |
| +++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
 | |
| @@ -83,6 +83,7 @@ class WebResourceLoadStatisticsStore;
 | |
|  enum class CacheModel : uint8_t;
 | |
|  enum class WebsiteDataFetchOption;
 | |
|  enum class WebsiteDataType;
 | |
| +struct FrameInfoData;
 | |
|  struct WebsiteDataRecord;
 | |
|  struct WebsiteDataStoreParameters;
 | |
|  
 | |
| @@ -96,6 +97,14 @@ enum class StorageAccessPromptStatus;
 | |
|  struct PluginModuleInfo;
 | |
|  #endif
 | |
|  
 | |
| +class DownloadInstrumentation {
 | |
| +public:
 | |
| +    virtual void downloadCreated(const String& uuid, const WebCore::ResourceRequest&, const FrameInfoData& frameInfoData, WebPageProxy* page) = 0;
 | |
| +    virtual void downloadFilenameSuggested(const String& uuid, const String& suggestedFilename) = 0;
 | |
| +    virtual void downloadFinished(const String& uuid, const String& error) = 0;
 | |
| +    virtual ~DownloadInstrumentation() = default;
 | |
| +};
 | |
| +
 | |
|  class WebsiteDataStore : public API::ObjectImpl<API::Object::Type::WebsiteDataStore>, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore>  {
 | |
|  public:
 | |
|      static Ref<WebsiteDataStore> defaultDataStore();
 | |
| @@ -289,6 +298,14 @@ public:
 | |
|      static WTF::String defaultJavaScriptConfigurationDirectory();
 | |
|      static bool http3Enabled();
 | |
|  
 | |
| +    void setLanguagesForAutomation(Vector<String>&&);
 | |
| +    Vector<String>& languagesForAutomation() { return m_languagesForAutomation; };
 | |
| +    void setDownloadForAutomation(Optional<bool> allow, const String& downloadPath);
 | |
| +    Optional<bool> allowDownloadForAutomation() { return m_allowDownloadForAutomation; };
 | |
| +    String downloadPathForAutomation() { return m_downloadPathForAutomation; };
 | |
| +    void setDownloadInstrumentation(DownloadInstrumentation* instrumentation) { m_downloadInstrumentation = instrumentation; };
 | |
| +    DownloadInstrumentation* downloadInstrumentation() { return m_downloadInstrumentation; };
 | |
| +
 | |
|      void resetQuota(CompletionHandler<void()>&&);
 | |
|      void hasAppBoundSession(CompletionHandler<void(bool)>&&) const;
 | |
|      void clearAppBoundSession(CompletionHandler<void()>&&);
 | |
| @@ -387,6 +404,11 @@ private:
 | |
|  
 | |
|      RefPtr<API::HTTPCookieStore> m_cookieStore;
 | |
|  
 | |
| +    Vector<String> m_languagesForAutomation;
 | |
| +    Optional<bool> m_allowDownloadForAutomation;
 | |
| +    String m_downloadPathForAutomation;
 | |
| +    DownloadInstrumentation* m_downloadInstrumentation { nullptr };
 | |
| +
 | |
|  #if HAVE(APP_SSO)
 | |
|      UniqueRef<SOAuthorizationCoordinator> m_soAuthorizationCoordinator;
 | |
|  #endif
 | |
| diff --git a/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp b/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp
 | |
| index 7ba39332bce6e28f0f4b2f7acf636f835c54f486..7c3d8125df147b6049075491b12cce1dc84bf514 100644
 | |
| --- a/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp
 | |
| +++ b/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp
 | |
| @@ -60,6 +60,8 @@ void GeoclueGeolocationProvider::start(UpdateNotifyFunction&& updateNotifyFuncti
 | |
|      m_isRunning = true;
 | |
|      m_cancellable = adoptGRef(g_cancellable_new());
 | |
|      if (!m_manager) {
 | |
| +        g_cancellable_cancel(m_cancellable_start.get());
 | |
| +        m_cancellable_start = adoptGRef(g_cancellable_new());
 | |
|          g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr,
 | |
|              "org.freedesktop.GeoClue2", "/org/freedesktop/GeoClue2/Manager", "org.freedesktop.GeoClue2.Manager", m_cancellable.get(),
 | |
|              [](GObject*, GAsyncResult* result, gpointer userData) {
 | |
| @@ -91,6 +93,12 @@ void GeoclueGeolocationProvider::stop()
 | |
|      g_cancellable_cancel(m_cancellable.get());
 | |
|      m_cancellable = nullptr;
 | |
|      stopClient();
 | |
| +    g_cancellable_cancel(m_cancellable_start.get());
 | |
| +    m_cancellable_start = nullptr;
 | |
| +    g_cancellable_cancel(m_cancellable_setup.get());
 | |
| +    m_cancellable_setup = nullptr;
 | |
| +    g_cancellable_cancel(m_cancellable_create.get());
 | |
| +    m_cancellable_create = nullptr;
 | |
|      destroyManagerLater();
 | |
|  }
 | |
|  
 | |
| @@ -153,6 +161,8 @@ void GeoclueGeolocationProvider::createClient(const char* clientPath)
 | |
|          return;
 | |
|      }
 | |
|  
 | |
| +    g_cancellable_cancel(m_cancellable_create.get());
 | |
| +    m_cancellable_create = adoptGRef(g_cancellable_new());
 | |
|      g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr,
 | |
|          "org.freedesktop.GeoClue2", clientPath, "org.freedesktop.GeoClue2.Client", m_cancellable.get(),
 | |
|          [](GObject*, GAsyncResult* result, gpointer userData) {
 | |
| diff --git a/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.h b/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.h
 | |
| index 31d29091985f34a65134a2b0e7cb3ace1dae441d..571ceac8a4b291fa6e91eb8b17065c0aba908ac3 100644
 | |
| --- a/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.h
 | |
| +++ b/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.h
 | |
| @@ -71,6 +71,9 @@ private:
 | |
|      GRefPtr<GDBusProxy> m_manager;
 | |
|      GRefPtr<GDBusProxy> m_client;
 | |
|      GRefPtr<GCancellable> m_cancellable;
 | |
| +    GRefPtr<GCancellable> m_cancellable_start;
 | |
| +    GRefPtr<GCancellable> m_cancellable_setup;
 | |
| +    GRefPtr<GCancellable> m_cancellable_create;
 | |
|      UpdateNotifyFunction m_updateNotifyFunction;
 | |
|      RunLoop::Timer<GeoclueGeolocationProvider> m_destroyManagerLaterTimer;
 | |
|  };
 | |
| diff --git a/Source/WebKit/UIProcess/glib/InspectorPlaywrightAgentClientGLib.cpp b/Source/WebKit/UIProcess/glib/InspectorPlaywrightAgentClientGLib.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..c16ef9d7c0ba6b4aca36b0aad68296505dbacb50
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/glib/InspectorPlaywrightAgentClientGLib.cpp
 | |
| @@ -0,0 +1,115 @@
 | |
| +/*
 | |
| + * 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 "InspectorPlaywrightAgentClientGLib.h"
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include "InspectorPlaywrightAgent.h"
 | |
| +#include "WebKitBrowserInspectorPrivate.h"
 | |
| +#include "WebKitWebContextPrivate.h"
 | |
| +#include "WebKitWebsiteDataManagerPrivate.h"
 | |
| +#include "WebKitWebViewPrivate.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <wtf/HashMap.h>
 | |
| +#include <wtf/RefPtr.h>
 | |
| +#include <wtf/text/StringView.h>
 | |
| +#include <wtf/text/WTFString.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +InspectorPlaywrightAgentClientGlib::InspectorPlaywrightAgentClientGlib(GMainLoop* mainLoop)
 | |
| +    : m_mainLoop(mainLoop)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +RefPtr<WebPageProxy> InspectorPlaywrightAgentClientGlib::createPage(WTF::String& error, const BrowserContext& browserContext)
 | |
| +{
 | |
| +    auto sessionID = browserContext.dataStore->sessionID();
 | |
| +    WebKitWebContext* context = m_idToContext.get(sessionID);
 | |
| +    if (!context && !browserContext.dataStore->isPersistent()) {
 | |
| +        ASSERT_NOT_REACHED();
 | |
| +        error = "Context with provided id not found";
 | |
| +        return nullptr;
 | |
| +    }
 | |
| +
 | |
| +    RefPtr<WebPageProxy> page = webkitBrowserInspectorCreateNewPageInContext(context);
 | |
| +    if (page == nullptr) {
 | |
| +        error = "Failed to create new page in the context";
 | |
| +        return nullptr;
 | |
| +    }
 | |
| +
 | |
| +    if (context == nullptr && sessionID != page->sessionID()) {
 | |
| +        ASSERT_NOT_REACHED();
 | |
| +        error = " Failed to create new page in default context";
 | |
| +        return nullptr;
 | |
| +    }
 | |
| +
 | |
| +    return page;
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgentClientGlib::closeBrowser()
 | |
| +{
 | |
| +    m_idToContext.clear();
 | |
| +#if PLATFORM(GTK)
 | |
| +    gtk_main_quit();
 | |
| +#else
 | |
| +    if (m_mainLoop)
 | |
| +        g_main_loop_quit(m_mainLoop);
 | |
| +#endif
 | |
| +}
 | |
| +
 | |
| +static PAL::SessionID sessionIDFromContext(WebKitWebContext* context)
 | |
| +{
 | |
| +    WebKitWebsiteDataManager* data_manager = webkit_web_context_get_website_data_manager(context);
 | |
| +    WebsiteDataStore& websiteDataStore = webkitWebsiteDataManagerGetDataStore(data_manager);
 | |
| +    return websiteDataStore.sessionID();
 | |
| +}
 | |
| +
 | |
| +BrowserContext InspectorPlaywrightAgentClientGlib::createBrowserContext(WTF::String& error)
 | |
| +{
 | |
| +    BrowserContext browserContext;
 | |
| +    GRefPtr<WebKitWebsiteDataManager> data_manager = adoptGRef(webkit_website_data_manager_new_ephemeral());
 | |
| +    GRefPtr<WebKitWebContext> context = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, "website-data-manager", data_manager.get(), "process-swap-on-cross-site-navigation-enabled", true, nullptr)));
 | |
| +    if (!context) {
 | |
| +        error = "Failed to create GLib ephemeral context";
 | |
| +        return browserContext;
 | |
| +    }
 | |
| +    browserContext.processPool = &webkitWebContextGetProcessPool(context.get());
 | |
| +    browserContext.dataStore = &webkitWebsiteDataManagerGetDataStore(data_manager.get());
 | |
| +    PAL::SessionID sessionID = sessionIDFromContext(context.get());
 | |
| +    m_idToContext.set(sessionID, WTFMove(context));
 | |
| +    return browserContext;
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgentClientGlib::deleteBrowserContext(WTF::String& error, PAL::SessionID sessionID)
 | |
| +{
 | |
| +    m_idToContext.remove(sessionID);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/glib/InspectorPlaywrightAgentClientGLib.h b/Source/WebKit/UIProcess/glib/InspectorPlaywrightAgentClientGLib.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..4cba2671042d3517e4b8f66e7b2bb780d57aa402
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/glib/InspectorPlaywrightAgentClientGLib.h
 | |
| @@ -0,0 +1,59 @@
 | |
| +/*
 | |
| + * 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 "InspectorPlaywrightAgentClient.h"
 | |
| +#include "WebKitWebContext.h"
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/HashMap.h>
 | |
| +#include <wtf/glib/GRefPtr.h>
 | |
| +#include <wtf/text/StringHash.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class InspectorPlaywrightAgentClientGlib : public InspectorPlaywrightAgentClient {
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorPlaywrightAgentClientGlib(GMainLoop* mainLoop);
 | |
| +    ~InspectorPlaywrightAgentClientGlib() override = default;
 | |
| +
 | |
| +    RefPtr<WebPageProxy> createPage(WTF::String& error, const BrowserContext&) override;
 | |
| +    void closeBrowser() override;
 | |
| +    BrowserContext createBrowserContext(WTF::String& error) override;
 | |
| +    void deleteBrowserContext(WTF::String& error, PAL::SessionID) override;
 | |
| +
 | |
| +private:
 | |
| +    WebKitWebContext* findContext(WTF::String& error, PAL::SessionID);
 | |
| +
 | |
| +    HashMap<PAL::SessionID, GRefPtr<WebKitWebContext>> m_idToContext;
 | |
| +    GMainLoop* m_mainLoop;
 | |
| +};
 | |
| +
 | |
| +} // namespace API
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/gtk/InspectorTargetProxyGtk.cpp b/Source/WebKit/UIProcess/gtk/InspectorTargetProxyGtk.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..8a86cc348bc210b71bb463dcb3057f575ad7c1d3
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/gtk/InspectorTargetProxyGtk.cpp
 | |
| @@ -0,0 +1,44 @@
 | |
| +/*
 | |
| + * 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 "InspectorTargetProxy.h"
 | |
| +
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <WebCore/GtkUtilities.h>
 | |
| +#include <gtk/gtk.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void InspectorTargetProxy::platformActivate(String& error) const
 | |
| +{
 | |
| +    GtkWidget* parent = gtk_widget_get_toplevel(m_page.viewWidget());
 | |
| +    if (WebCore::widgetIsOnscreenToplevelWindow(parent))
 | |
| +        gtk_window_present(GTK_WINDOW(parent));
 | |
| +    else
 | |
| +        error = "The view is not on screen";
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/gtk/WebPageInspectorEmulationAgentGtk.cpp b/Source/WebKit/UIProcess/gtk/WebPageInspectorEmulationAgentGtk.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..e5e25acebabb76a05a77db02a99f1267bd99a3af
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/gtk/WebPageInspectorEmulationAgentGtk.cpp
 | |
| @@ -0,0 +1,69 @@
 | |
| +/*
 | |
| + * 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 "DrawingAreaProxyCoordinatedGraphics.h"
 | |
| +#include "WebPageInspectorEmulationAgent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <WebCore/IntSize.h>
 | |
| +#include <gtk/gtk.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +void WebPageInspectorEmulationAgent::platformSetSize(int width, int height, Function<void (const String& error)>&& callback)
 | |
| +{
 | |
| +    GtkWidget* viewWidget = m_page.viewWidget();
 | |
| +    GtkWidget* window = gtk_widget_get_toplevel(viewWidget);
 | |
| +    if (!window) {
 | |
| +        callback("Cannot find parent window"_s);
 | |
| +        return;
 | |
| +    }
 | |
| +    if (!GTK_IS_WINDOW(window)) {
 | |
| +        callback("Toplevel is not a window"_s);
 | |
| +        return;
 | |
| +    }
 | |
| +    GtkAllocation viewAllocation;
 | |
| +    gtk_widget_get_allocation(viewWidget, &viewAllocation);
 | |
| +    if (viewAllocation.width == width && viewAllocation.height == height) {
 | |
| +        callback(String());
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    GtkAllocation windowAllocation;
 | |
| +    gtk_widget_get_allocation(window, &windowAllocation);
 | |
| +
 | |
| +    width += windowAllocation.width - viewAllocation.width;
 | |
| +    height += windowAllocation.height - viewAllocation.height;
 | |
| +
 | |
| +    if (auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(m_page.drawingArea())) {
 | |
| +        drawingArea->waitForSizeUpdate([callback = WTFMove(callback)]() {
 | |
| +            callback(String());
 | |
| +        });
 | |
| +    } else {
 | |
| +        callback("No backing store for window"_s);
 | |
| +    }
 | |
| +    gtk_window_resize(GTK_WINDOW(window), width, height);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp b/Source/WebKit/UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..d0f9827544994e450e24e3f7a427c35eeff94d67
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp
 | |
| @@ -0,0 +1,105 @@
 | |
| +/*
 | |
| + * 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 "WebPageInspectorInputAgent.h"
 | |
| +
 | |
| +#include "KeyBindingTranslator.h"
 | |
| +#include "NativeWebKeyboardEvent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <WebCore/PlatformKeyboardEvent.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +static Vector<String> commandsForKeyEvent(GdkEventType type, unsigned keyVal, unsigned state)
 | |
| +{
 | |
| +    ASSERT(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE);
 | |
| +
 | |
| +    GUniquePtr<GdkEvent> event(gdk_event_new(type));
 | |
| +    event->key.keyval = keyVal;
 | |
| +    event->key.time = GDK_CURRENT_TIME;
 | |
| +    event->key.state = state;
 | |
| +    // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+.
 | |
| +    GUniqueOutPtr<GdkKeymapKey> keys;
 | |
| +    int keysCount;
 | |
| +    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), keyVal, &keys.outPtr(), &keysCount) && keysCount)
 | |
| +        event->key.hardware_keycode = keys.get()[0].keycode;
 | |
| +    return KeyBindingTranslator().commandsForKeyEvent(&event->key);
 | |
| +}
 | |
| +
 | |
| +static unsigned modifiersToEventState(OptionSet<WebEvent::Modifier> modifiers)
 | |
| +{
 | |
| +    unsigned state = 0;
 | |
| +    if (modifiers.contains(WebEvent::Modifier::ControlKey))
 | |
| +        state |= GDK_CONTROL_MASK;
 | |
| +    if (modifiers.contains(WebEvent::Modifier::ShiftKey))
 | |
| +        state |= GDK_SHIFT_MASK;
 | |
| +    if (modifiers.contains(WebEvent::Modifier::AltKey))
 | |
| +        state |= GDK_META_MASK;
 | |
| +    if (modifiers.contains(WebEvent::Modifier::CapsLockKey))
 | |
| +        state |= GDK_LOCK_MASK;
 | |
| +    return state;
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
 | |
| +{
 | |
| +    Vector<String> commands;
 | |
| +    const guint keyVal = WebCore::PlatformKeyboardEvent::gdkKeyCodeForWindowsKeyCode(windowsVirtualKeyCode);
 | |
| +    if (keyVal) {
 | |
| +        GdkEventType event = GDK_NOTHING;
 | |
| +        switch (type)
 | |
| +        {
 | |
| +        case WebKeyboardEvent::KeyDown:
 | |
| +            event = GDK_KEY_PRESS;
 | |
| +            break;
 | |
| +        case WebKeyboardEvent::KeyUp:
 | |
| +            event = GDK_KEY_RELEASE;
 | |
| +            break;
 | |
| +        default:
 | |
| +            fprintf(stderr, "Unsupported event type = %d\n", type);
 | |
| +            break;
 | |
| +        }
 | |
| +        unsigned state = modifiersToEventState(modifiers);
 | |
| +        commands = commandsForKeyEvent(event, keyVal, state);
 | |
| +    }
 | |
| +    NativeWebKeyboardEvent event(
 | |
| +        type,
 | |
| +        text,
 | |
| +        unmodifiedText,
 | |
| +        key,
 | |
| +        code,
 | |
| +        keyIdentifier,
 | |
| +        windowsVirtualKeyCode,
 | |
| +        nativeVirtualKeyCode,
 | |
| +        isAutoRepeat,
 | |
| +        isKeypad,
 | |
| +        isSystemKey,
 | |
| +        modifiers,
 | |
| +        timestamp,
 | |
| +        WTFMove(commands));
 | |
| +    m_page.handleKeyboardEvent(event);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
 | |
| index 5c8a3cd2935ec480c01d9c628e0bc3afbd0d1eed..415f2431b6b326ab669374bd2c2c05c2ef700e98 100644
 | |
| --- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
 | |
| +++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
 | |
| @@ -447,6 +447,8 @@ IntRect PageClientImpl::rootViewToAccessibilityScreen(const IntRect& rect)
 | |
|      
 | |
|  void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
 | |
|  {
 | |
| +    if (!event.nativeEvent())
 | |
| +        return;
 | |
|      [m_contentView _didHandleKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.h b/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..b75c2ce5ce9e9da3a33bca41ab548ec7a2f819ed
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.h
 | |
| @@ -0,0 +1,51 @@
 | |
| +/*
 | |
| + * 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
 | |
| +
 | |
| +#include "InspectorPlaywrightAgentClient.h"
 | |
| +#include <wtf/Forward.h>
 | |
| +
 | |
| +OBJC_PROTOCOL(_WKBrowserInspectorDelegate);
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class InspectorPlaywrightAgentClientMac : public InspectorPlaywrightAgentClient {
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorPlaywrightAgentClientMac(_WKBrowserInspectorDelegate* delegate);
 | |
| +    ~InspectorPlaywrightAgentClientMac() override = default;
 | |
| +
 | |
| +    RefPtr<WebPageProxy> createPage(WTF::String& error, const BrowserContext&) override;
 | |
| +    void closeBrowser() override;
 | |
| +    BrowserContext createBrowserContext(WTF::String& error) override;
 | |
| +    void deleteBrowserContext(WTF::String& error, PAL::SessionID) override;
 | |
| +
 | |
| +private:
 | |
| +    _WKBrowserInspectorDelegate* delegate_;
 | |
| +};
 | |
| +
 | |
| +
 | |
| +} // namespace API
 | |
| diff --git a/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.mm b/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.mm
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..5db92c0580fd4f216ac86ede56eaac2eabec27da
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.mm
 | |
| @@ -0,0 +1,77 @@
 | |
| +/*
 | |
| + * 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.
 | |
| + */
 | |
| +
 | |
| +#import "config.h"
 | |
| +#import "InspectorPlaywrightAgentClientMac.h"
 | |
| +
 | |
| +#import <wtf/RefPtr.h>
 | |
| +#import <wtf/text/WTFString.h>
 | |
| +#import "WebPageProxy.h"
 | |
| +#import "WebProcessPool.h"
 | |
| +#import "WebsiteDataStore.h"
 | |
| +#import "_WKBrowserInspector.h"
 | |
| +#import "WKProcessPoolInternal.h"
 | |
| +#import "WKWebsiteDataStoreInternal.h"
 | |
| +#import "WKWebView.h"
 | |
| +#import "WKWebViewInternal.h"
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +InspectorPlaywrightAgentClientMac::InspectorPlaywrightAgentClientMac(_WKBrowserInspectorDelegate* delegate)
 | |
| +  : delegate_(delegate)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +RefPtr<WebPageProxy> InspectorPlaywrightAgentClientMac::createPage(WTF::String& error, const BrowserContext& browserContext)
 | |
| +{
 | |
| +    auto sessionID = browserContext.dataStore->sessionID();
 | |
| +    WKWebView *webView = [delegate_ createNewPage:sessionID.toUInt64()];
 | |
| +    if (!webView) {
 | |
| +        error = "Internal error: can't create page in given context"_s;
 | |
| +        return nil;
 | |
| +    }
 | |
| +    return [webView _page].get();
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgentClientMac::closeBrowser()
 | |
| +{
 | |
| +    [delegate_ quit];
 | |
| +}
 | |
| +
 | |
| +BrowserContext InspectorPlaywrightAgentClientMac::createBrowserContext(WTF::String& error)
 | |
| +{
 | |
| +    _WKBrowserContext* wkBrowserContext = [[delegate_ createBrowserContext] autorelease];
 | |
| +    BrowserContext browserContext;
 | |
| +    browserContext.processPool = &static_cast<WebProcessPool&>([[wkBrowserContext processPool] _apiObject]);
 | |
| +    browserContext.dataStore = &static_cast<WebsiteDataStore&>([[wkBrowserContext dataStore] _apiObject]);
 | |
| +    return browserContext;
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgentClientMac::deleteBrowserContext(WTF::String& error, PAL::SessionID sessionID)
 | |
| +{
 | |
| +    [delegate_ deleteBrowserContext:sessionID.toUInt64()];
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/mac/InspectorTargetProxyMac.mm b/Source/WebKit/UIProcess/mac/InspectorTargetProxyMac.mm
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..721826c8c98fc85b68a4f45deaee69c1219a7254
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/mac/InspectorTargetProxyMac.mm
 | |
| @@ -0,0 +1,42 @@
 | |
| +/*
 | |
| + * 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.
 | |
| + */
 | |
| +
 | |
| +#import "config.h"
 | |
| +#import "InspectorTargetProxy.h"
 | |
| +#import "WebPageProxy.h"
 | |
| +
 | |
| +#if PLATFORM(MAC)
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void InspectorTargetProxy::platformActivate(String& error) const
 | |
| +{
 | |
| +    NSWindow* window = m_page.platformWindow();
 | |
| +    [window makeKeyAndOrderFront:nil];
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif
 | |
| diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.h b/Source/WebKit/UIProcess/mac/PageClientImplMac.h
 | |
| index 7eb36a1ee513da167aa8c88eb3847a652c5439f0..76b39926ddcc9eb5ce2c2596ac06bd822f31fc57 100644
 | |
| --- a/Source/WebKit/UIProcess/mac/PageClientImplMac.h
 | |
| +++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.h
 | |
| @@ -53,6 +53,8 @@ class PageClientImpl final : public PageClientImplCocoa
 | |
|  #endif
 | |
|      {
 | |
|  public:
 | |
| +    static void setHeadless(bool headless);
 | |
| +
 | |
|      PageClientImpl(NSView *, WKWebView *);
 | |
|      virtual ~PageClientImpl();
 | |
|  
 | |
| @@ -154,6 +156,9 @@ private:
 | |
|      void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
 | |
|      void didFirstLayerFlush(const LayerTreeContext&) override;
 | |
|  
 | |
| +// Paywright begin
 | |
| +    RetainPtr<CGImageRef> takeSnapshotForAutomation() override;
 | |
| +// Paywright end
 | |
|      RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&) override;
 | |
|      void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
 | |
|  #if ENABLE(MAC_GESTURE_EVENTS)
 | |
| @@ -201,6 +206,10 @@ private:
 | |
|      void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
 | |
|  #endif
 | |
|  
 | |
| +#if ENABLE(TOUCH_EVENTS)
 | |
| +    void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) override;
 | |
| +#endif
 | |
| +
 | |
|      void navigationGestureDidBegin() override;
 | |
|      void 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 7c5865bcf9da88cf595ceae22e88349265e158dc..0fa0f950bb051addf7e3255f6182ea975f383167 100644
 | |
| --- a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
 | |
| +++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
 | |
| @@ -78,6 +78,7 @@
 | |
|  #import <WebCore/TextUndoInsertionMarkupMac.h>
 | |
|  #import <WebCore/ValidationBubble.h>
 | |
|  #import <WebCore/WebCoreCALayerExtras.h>
 | |
| +#import <WebCore/NotImplemented.h>
 | |
|  #import <wtf/ProcessPrivilege.h>
 | |
|  #import <wtf/RetainPtr.h>
 | |
|  #import <wtf/text/CString.h>
 | |
| @@ -103,6 +104,13 @@ namespace WebKit {
 | |
|  
 | |
|  using namespace WebCore;
 | |
|  
 | |
| +static bool _headless = false;
 | |
| +
 | |
| +// static
 | |
| +void PageClientImpl::setHeadless(bool headless) {
 | |
| +    _headless = true;
 | |
| +}
 | |
| +
 | |
|  PageClientImpl::PageClientImpl(NSView *view, WKWebView *webView)
 | |
|      : PageClientImplCocoa(webView)
 | |
|      , m_view(view)
 | |
| @@ -156,6 +164,9 @@ NSWindow *PageClientImpl::activeWindow() const
 | |
|  
 | |
|  bool PageClientImpl::isViewWindowActive()
 | |
|  {
 | |
| +    if (_headless)
 | |
| +        return true;
 | |
| +
 | |
|      ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
 | |
|      NSWindow *activeViewWindow = activeWindow();
 | |
|      return activeViewWindow.isKeyWindow || [NSApp keyWindow] == activeViewWindow;
 | |
| @@ -163,6 +174,9 @@ bool PageClientImpl::isViewWindowActive()
 | |
|  
 | |
|  bool PageClientImpl::isViewFocused()
 | |
|  {
 | |
| +    if (_headless)
 | |
| +        return true;
 | |
| +
 | |
|      // FIXME: This is called from the WebPageProxy constructor before we have a WebViewImpl.
 | |
|      // Once WebViewImpl and PageClient merge, this won't be a problem.
 | |
|      if (!m_impl)
 | |
| @@ -186,6 +200,9 @@ void PageClientImpl::makeFirstResponder()
 | |
|      
 | |
|  bool PageClientImpl::isViewVisible()
 | |
|  {
 | |
| +    if (_headless)
 | |
| +        return true;
 | |
| +
 | |
|      NSView *activeView = this->activeView();
 | |
|      NSWindow *activeViewWindow = activeWindow();
 | |
|  
 | |
| @@ -269,7 +286,8 @@ void PageClientImpl::didRelaunchProcess()
 | |
|  
 | |
|  void PageClientImpl::preferencesDidChange()
 | |
|  {
 | |
| -    m_impl->preferencesDidChange();
 | |
| +    if (m_impl)
 | |
| +        m_impl->preferencesDidChange();
 | |
|  }
 | |
|  
 | |
|  void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
 | |
| @@ -445,6 +463,8 @@ IntRect PageClientImpl::rootViewToAccessibilityScreen(const IntRect& rect)
 | |
|  
 | |
|  void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
 | |
|  {
 | |
| +    if (!event.nativeEvent())
 | |
| +        return;
 | |
|      m_impl->doneWithKeyEvent(event.nativeEvent(), eventWasHandled);
 | |
|  }
 | |
|  
 | |
| @@ -562,6 +582,12 @@ CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
 | |
|      return m_impl->acceleratedCompositingRootLayer();
 | |
|  }
 | |
|  
 | |
| +// Paywright begin
 | |
| +RetainPtr<CGImageRef> PageClientImpl::takeSnapshotForAutomation() {
 | |
| +    return m_impl->takeSnapshotForAutomation();
 | |
| +}
 | |
| +// Paywright begin
 | |
| +
 | |
|  RefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot(Optional<WebCore::IntRect>&&)
 | |
|  {
 | |
|      return m_impl->takeViewSnapshot();
 | |
| @@ -740,6 +766,13 @@ void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntR
 | |
|  
 | |
|  #endif // ENABLE(FULLSCREEN_API)
 | |
|  
 | |
| +#if ENABLE(TOUCH_EVENTS)
 | |
| +void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +#endif // ENABLE(TOUCH_EVENTS)
 | |
| +
 | |
|  void PageClientImpl::navigationGestureDidBegin()
 | |
|  {
 | |
|      m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
 | |
| @@ -906,6 +939,9 @@ void PageClientImpl::didRestoreScrollPosition()
 | |
|  
 | |
|  bool PageClientImpl::windowIsFrontWindowUnderMouse(const NativeWebMouseEvent& event)
 | |
|  {
 | |
| +    // Simulated event.
 | |
| +    if (!event.nativeEvent())
 | |
| +        return false;
 | |
|      return m_impl->windowIsFrontWindowUnderMouse(event.nativeEvent());
 | |
|  }
 | |
|  
 | |
| diff --git a/Source/WebKit/UIProcess/mac/WebPageInspectorEmulationAgentMac.mm b/Source/WebKit/UIProcess/mac/WebPageInspectorEmulationAgentMac.mm
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..6113f4cd60a5d72b8ead61176cb43200803478ed
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/mac/WebPageInspectorEmulationAgentMac.mm
 | |
| @@ -0,0 +1,44 @@
 | |
| +/*
 | |
| + * 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.
 | |
| + */
 | |
| +
 | |
| +#import "config.h"
 | |
| +#import "WebPageInspectorEmulationAgent.h"
 | |
| +
 | |
| +#import "WebPageProxy.h"
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::platformSetSize(int width, int height, Function<void (const String& error)>&& callback)
 | |
| +{
 | |
| +    NSWindow* window = m_page.platformWindow();
 | |
| +    NSRect windowRect = [window frame];
 | |
| +    NSRect viewRect = window.contentLayoutRect;
 | |
| +    windowRect.size.width += width - viewRect.size.width;
 | |
| +    windowRect.size.height += height - viewRect.size.height;
 | |
| +    [window setFrame:windowRect display:YES animate:NO];
 | |
| +    callback(String());
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/mac/WebPageInspectorInputAgentMac.mm b/Source/WebKit/UIProcess/mac/WebPageInspectorInputAgentMac.mm
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..832e52038cf42ea73246e036a66ad9e1fc87fa78
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/mac/WebPageInspectorInputAgentMac.mm
 | |
| @@ -0,0 +1,122 @@
 | |
| +/*
 | |
| + * 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.
 | |
| + */
 | |
| +
 | |
| +#import "config.h"
 | |
| +#import "NativeWebMouseEvent.h"
 | |
| +#import "WebPageInspectorInputAgent.h"
 | |
| +#import "WebPageProxy.h"
 | |
| +#import <WebCore/IntPoint.h>
 | |
| +#import <WebCore/IntSize.h>
 | |
| +#import "NativeWebKeyboardEvent.h"
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +using namespace WebCore;
 | |
| +
 | |
| +void WebPageInspectorInputAgent::platformDispatchMouseEvent(const String& type, int x, int y, const int* optionalModifiers, const String* button, const int* optionalClickCount) {
 | |
| +    IntPoint locationInWindow(x, y);
 | |
| +
 | |
| +    NSEventModifierFlags modifiers = 0;
 | |
| +    if (optionalModifiers) {
 | |
| +        int inputModifiers = *optionalModifiers;
 | |
| +        if (inputModifiers & 1)
 | |
| +            modifiers |= NSEventModifierFlagShift;
 | |
| +        if (inputModifiers & 2)
 | |
| +            modifiers |= NSEventModifierFlagControl;
 | |
| +        if (inputModifiers & 4)
 | |
| +            modifiers |= NSEventModifierFlagOption;
 | |
| +        if (inputModifiers & 8)
 | |
| +            modifiers |= NSEventModifierFlagCommand;
 | |
| +    }
 | |
| +    int clickCount = optionalClickCount ? *optionalClickCount : 0;
 | |
| +
 | |
| +    NSTimeInterval timestamp = [NSDate timeIntervalSinceReferenceDate];
 | |
| +    NSWindow *window = m_page.platformWindow();
 | |
| +    NSInteger windowNumber = window.windowNumber;
 | |
| +
 | |
| +    NSEventType downEventType = (NSEventType)0;
 | |
| +    NSEventType dragEventType = (NSEventType)0;
 | |
| +    NSEventType upEventType = (NSEventType)0;
 | |
| +
 | |
| +    if (!button || *button == "none") {
 | |
| +        downEventType = NSEventTypeMouseMoved;
 | |
| +        dragEventType = NSEventTypeMouseMoved;
 | |
| +        upEventType = NSEventTypeMouseMoved;
 | |
| +    } else if (*button == "left") {
 | |
| +        downEventType = NSEventTypeLeftMouseDown;
 | |
| +        dragEventType = NSEventTypeLeftMouseDragged;
 | |
| +        upEventType = NSEventTypeLeftMouseUp;
 | |
| +    } else if (*button == "middle") {
 | |
| +        downEventType = NSEventTypeOtherMouseDown;
 | |
| +        dragEventType = NSEventTypeLeftMouseDragged;
 | |
| +        upEventType = NSEventTypeOtherMouseUp;
 | |
| +    } else if (*button == "right") {
 | |
| +        downEventType = NSEventTypeRightMouseDown;
 | |
| +        upEventType = NSEventTypeRightMouseUp;
 | |
| +    }
 | |
| +
 | |
| +    NSInteger eventNumber = 0;
 | |
| +
 | |
| +    NSEvent* event = nil;
 | |
| +    if (type == "move") {
 | |
| +        event = [NSEvent mouseEventWithType:dragEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:clickCount pressure:0.0f];
 | |
| +    } else if (type == "down") {
 | |
| +        event = [NSEvent mouseEventWithType:downEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:clickCount pressure:WebCore::ForceAtClick];
 | |
| +    } else if (type == "up") {
 | |
| +        event = [NSEvent mouseEventWithType:upEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:clickCount pressure:0.0f];
 | |
| +    }
 | |
| +
 | |
| +    if (event) {
 | |
| +        NativeWebMouseEvent nativeEvent(event, nil, [window contentView]);
 | |
| +        m_page.handleMouseEvent(nativeEvent);
 | |
| +    }
 | |
| +}
 | |
| +
 | |
| +void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& commands, WallTime timestamp)
 | |
| +{
 | |
| +    Vector<WebCore::KeypressCommand> macCommands;
 | |
| +    for (const String& command : commands)
 | |
| +      macCommands.append(WebCore::KeypressCommand(command.utf8().data()));
 | |
| +    if (text.length() > 0 && macCommands.size() == 0)
 | |
| +      macCommands.append(WebCore::KeypressCommand("insertText:", text));
 | |
| +    NativeWebKeyboardEvent event(
 | |
| +        type,
 | |
| +        text,
 | |
| +        unmodifiedText,
 | |
| +        key,
 | |
| +        code,
 | |
| +        keyIdentifier,
 | |
| +        windowsVirtualKeyCode,
 | |
| +        nativeVirtualKeyCode,
 | |
| +        isAutoRepeat,
 | |
| +        isKeypad,
 | |
| +        isSystemKey,
 | |
| +        modifiers,
 | |
| +        timestamp,
 | |
| +        WTFMove(macCommands));
 | |
| +    m_page.handleKeyboardEvent(event);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..9ea75b043513fe4c56b3af33d2082375971a75f7
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
 | |
| @@ -0,0 +1,82 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "InspectorPlaywrightAgentClientWin.h"
 | |
| +
 | |
| +#if ENABLE(REMOTE_INSPECTOR)
 | |
| +
 | |
| +#include "APIPageConfiguration.h"
 | |
| +#include "APIProcessPoolConfiguration.h"
 | |
| +#include "InspectorPlaywrightAgent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include "WebsiteDataStore.h"
 | |
| +#include "WebPreferences.h"
 | |
| +#include "WebProcessPool.h"
 | |
| +#include "WebView.h"
 | |
| +#include "WKAPICast.h"
 | |
| +#include <wtf/HashMap.h>
 | |
| +#include <wtf/RefPtr.h>
 | |
| +#include <wtf/text/StringView.h>
 | |
| +#include <wtf/text/WTFString.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +InspectorPlaywrightAgentClientWin::InspectorPlaywrightAgentClientWin(CreatePageCallback createPage, QuitCallback quit)
 | |
| +    : m_createPage(createPage)
 | |
| +    , m_quit(quit)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +RefPtr<WebPageProxy> InspectorPlaywrightAgentClientWin::createPage(WTF::String& error, const BrowserContext& context)
 | |
| +{
 | |
| +    auto conf = API::PageConfiguration::create();
 | |
| +    conf->setProcessPool(context.processPool.get());
 | |
| +    conf->setWebsiteDataStore(context.dataStore.get());
 | |
| +    return toImpl(m_createPage(toAPI(&conf.get())));
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgentClientWin::closeBrowser()
 | |
| +{
 | |
| +    m_quit();
 | |
| +}
 | |
| +
 | |
| +BrowserContext InspectorPlaywrightAgentClientWin::createBrowserContext(WTF::String& error)
 | |
| +{
 | |
| +    auto config = API::ProcessPoolConfiguration::create();
 | |
| +    BrowserContext browserContext;
 | |
| +    browserContext.processPool = WebKit::WebProcessPool::create(config);
 | |
| +    browserContext.dataStore = WebKit::WebsiteDataStore::createNonPersistent();
 | |
| +    PAL::SessionID sessionID = browserContext.dataStore->sessionID();
 | |
| +    return browserContext;
 | |
| +}
 | |
| +
 | |
| +void InspectorPlaywrightAgentClientWin::deleteBrowserContext(WTF::String& error, PAL::SessionID sessionID)
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.h b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..2536fe399ef9a5916803954e1f4971a24b7ca4ec
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.h
 | |
| @@ -0,0 +1,58 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "InspectorPlaywrightAgentClient.h"
 | |
| +#include <WebKit/WKInspector.h>
 | |
| +#include <wtf/Forward.h>
 | |
| +#include <wtf/text/StringHash.h>
 | |
| +
 | |
| +typedef WKPageRef (*CreatePageCallback)(WKPageConfigurationRef configuration);
 | |
| +typedef void (*QuitCallback)();
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +class InspectorPlaywrightAgentClientWin : public InspectorPlaywrightAgentClient {
 | |
| +    WTF_MAKE_FAST_ALLOCATED;
 | |
| +public:
 | |
| +    InspectorPlaywrightAgentClientWin(CreatePageCallback, QuitCallback);
 | |
| +    ~InspectorPlaywrightAgentClientWin() override = default;
 | |
| +
 | |
| +    RefPtr<WebPageProxy> createPage(WTF::String& error, const BrowserContext&) override;
 | |
| +    void closeBrowser() override;
 | |
| +    BrowserContext createBrowserContext(WTF::String& error) override;
 | |
| +    void deleteBrowserContext(WTF::String& error, PAL::SessionID) override;
 | |
| +
 | |
| +private:
 | |
| +    CreatePageCallback m_createPage;
 | |
| +    QuitCallback m_quit;
 | |
| +};
 | |
| +
 | |
| +} // namespace API
 | |
| +
 | |
| +#endif // ENABLE(REMOTE_INSPECTOR)
 | |
| diff --git a/Source/WebKit/UIProcess/win/InspectorTargetProxyWin.cpp b/Source/WebKit/UIProcess/win/InspectorTargetProxyWin.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..135a60361fa8fbf907382625e7c8dd4ea64ceb94
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/win/InspectorTargetProxyWin.cpp
 | |
| @@ -0,0 +1,36 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "InspectorTargetProxy.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void InspectorTargetProxy::platformActivate(String& error) const
 | |
| +{
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/win/WebPageInspectorEmulationAgentWin.cpp b/Source/WebKit/UIProcess/win/WebPageInspectorEmulationAgentWin.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..62b841fe1d0de2296e1c61e328cff564f5aa1c0f
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/win/WebPageInspectorEmulationAgentWin.cpp
 | |
| @@ -0,0 +1,58 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "WebPageInspectorEmulationAgent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::platformSetSize(int width, int height, Function<void (const String& error)>&& callback)
 | |
| +{
 | |
| +    HWND viewHwnd = m_page.viewWidget();
 | |
| +    HWND windowHwnd = GetAncestor(viewHwnd, GA_ROOT);
 | |
| +    RECT viewRect;
 | |
| +    RECT windowRect;
 | |
| +
 | |
| +    if (!windowHwnd || !GetWindowRect(windowHwnd, &windowRect)) {
 | |
| +        callback("Could not retrieve window size");
 | |
| +        return;
 | |
| +    }
 | |
| +    if (!GetWindowRect(viewHwnd, &viewRect)) {
 | |
| +        callback("Could retrieve view size");
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    width += windowRect.right - windowRect.left - viewRect.right + viewRect.left;
 | |
| +    height += windowRect.bottom - windowRect.top - viewRect.bottom + viewRect.top;
 | |
| +
 | |
| +    if (!SetWindowPos(windowHwnd, 0, 0, 0, width, height, SWP_NOCOPYBITS | SWP_NOSENDCHANGING | SWP_NOMOVE)) {
 | |
| +        callback("Could not resize window");
 | |
| +        return;
 | |
| +    }
 | |
| +    callback(String());
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/win/WebPageInspectorInputAgentWin.cpp b/Source/WebKit/UIProcess/win/WebPageInspectorInputAgentWin.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..5cf8a010e9809e6a95741cdb7c2cbeb445ab638b
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/win/WebPageInspectorInputAgentWin.cpp
 | |
| @@ -0,0 +1,55 @@
 | |
| +/*
 | |
| + * Copyright (C) 2020 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 "WebPageInspectorInputAgent.h"
 | |
| +
 | |
| +#include "NativeWebKeyboardEvent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <WebCore/PlatformKeyboardEvent.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
 | |
| +{
 | |
| +    NativeWebKeyboardEvent event(
 | |
| +        type,
 | |
| +        text,
 | |
| +        unmodifiedText,
 | |
| +        key,
 | |
| +        code,
 | |
| +        keyIdentifier,
 | |
| +        windowsVirtualKeyCode,
 | |
| +        nativeVirtualKeyCode,
 | |
| +        isAutoRepeat,
 | |
| +        isKeypad,
 | |
| +        isSystemKey,
 | |
| +        modifiers,
 | |
| +        timestamp);
 | |
| +    m_page.handleKeyboardEvent(event);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/wpe/InspectorTargetProxyWPE.cpp b/Source/WebKit/UIProcess/wpe/InspectorTargetProxyWPE.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..7453194ca6f032ba86a4c67f5bf12688ab6ec1be
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/wpe/InspectorTargetProxyWPE.cpp
 | |
| @@ -0,0 +1,40 @@
 | |
| +/*
 | |
| + * 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 "InspectorTargetProxy.h"
 | |
| +
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <wpe/wpe.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void InspectorTargetProxy::platformActivate(String& error) const
 | |
| +{
 | |
| +    struct wpe_view_backend* backend = m_page.viewBackend();
 | |
| +    wpe_view_backend_add_activity_state(backend, wpe_view_activity_state_visible | wpe_view_activity_state_focused | wpe_view_activity_state_in_window);
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cpp b/Source/WebKit/UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..5dc76aa302cb574307059e66a1b73730efe920da
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cpp
 | |
| @@ -0,0 +1,41 @@
 | |
| +/*
 | |
| + * 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 "WebPageInspectorEmulationAgent.h"
 | |
| +
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <wpe/wpe.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void WebPageInspectorEmulationAgent::platformSetSize(int width, int height, Function<void (const String& error)>&& callback)
 | |
| +{
 | |
| +    struct wpe_view_backend* backend = m_page.viewBackend();
 | |
| +    wpe_view_backend_dispatch_set_size(backend, width, height);
 | |
| +    callback(String());
 | |
| +}
 | |
| +
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp b/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..c3d7cacea987ba2b094d5022c670705ef6ced129
 | |
| --- /dev/null
 | |
| +++ b/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp
 | |
| @@ -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.
 | |
| + */
 | |
| +
 | |
| +#include "config.h"
 | |
| +#include "WebPageInspectorInputAgent.h"
 | |
| +
 | |
| +#include "NativeWebKeyboardEvent.h"
 | |
| +#include "WebPageProxy.h"
 | |
| +#include <WebCore/PlatformKeyboardEvent.h>
 | |
| +#include <wpe/wpe.h>
 | |
| +
 | |
| +namespace WebKit {
 | |
| +
 | |
| +void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
 | |
| +{
 | |
| +    NativeWebKeyboardEvent event(
 | |
| +        type,
 | |
| +        text,
 | |
| +        unmodifiedText,
 | |
| +        key,
 | |
| +        code,
 | |
| +        keyIdentifier,
 | |
| +        windowsVirtualKeyCode,
 | |
| +        nativeVirtualKeyCode,
 | |
| +        isAutoRepeat,
 | |
| +        isKeypad,
 | |
| +        isSystemKey,
 | |
| +        modifiers,
 | |
| +        timestamp);
 | |
| +    m_page.handleKeyboardEvent(event);
 | |
| +}
 | |
| + 
 | |
| +} // namespace WebKit
 | |
| diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj
 | |
| index 2b7069a13d8c04f5df8c838e6bb26563ce6fe766..5a269fa4fbb1a8c0798a34099a8777b7aa6c762b 100644
 | |
| --- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj
 | |
| +++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj
 | |
| @@ -1777,6 +1777,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 */; };
 | |
| +		D71A94322370E025002C4D9E /* InspectorPlaywrightAgentClientMac.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A94302370E025002C4D9E /* InspectorPlaywrightAgentClientMac.h */; };
 | |
| +		D71A94342370E07A002C4D9E /* InspectorPlaywrightAgentClient.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A94332370E07A002C4D9E /* InspectorPlaywrightAgentClient.h */; };
 | |
| +		D71A94382370F032002C4D9E /* BrowserInspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A94372370F032002C4D9E /* BrowserInspectorController.h */; };
 | |
| +		D71A943A2370F061002C4D9E /* RemoteInspectorPipe.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A94392370F060002C4D9E /* RemoteInspectorPipe.h */; };
 | |
| +		D71A94422371F67E002C4D9E /* WebPageInspectorEmulationAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A943F2371F67E002C4D9E /* WebPageInspectorEmulationAgent.h */; };
 | |
| +		D71A94432371F67E002C4D9E /* WebPageInspectorInputAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A94402371F67E002C4D9E /* WebPageInspectorInputAgent.h */; };
 | |
| +		D71A944A2372290B002C4D9E /* _WKBrowserInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A94492372290B002C4D9E /* _WKBrowserInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
| +		D71A944C237239FB002C4D9E /* BrowserInspectorPipe.h in Headers */ = {isa = PBXBuildFile; fileRef = D71A944B237239FB002C4D9E /* BrowserInspectorPipe.h */; };
 | |
| +		D76D6888238DBD81008D314B /* InspectorDialogAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = D76D6887238DBD80008D314B /* InspectorDialogAgent.h */; };
 | |
| +		D79902B1236E9404005D6F7E /* WebPageInspectorEmulationAgentMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = D79902AE236E9404005D6F7E /* WebPageInspectorEmulationAgentMac.mm */; };
 | |
| +		D79902B2236E9404005D6F7E /* InspectorTargetProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = D79902AF236E9404005D6F7E /* InspectorTargetProxyMac.mm */; };
 | |
| +		D79902B3236E9404005D6F7E /* WebPageInspectorInputAgentMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = D79902B0236E9404005D6F7E /* WebPageInspectorInputAgentMac.mm */; };
 | |
| +		D7EB04E72372A73B00F744CE /* InspectorPlaywrightAgentClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = D7EB04E62372A73B00F744CE /* InspectorPlaywrightAgentClientMac.mm */; };
 | |
|  		DF462E0F23F22F5500EFF35F /* WKHTTPCookieStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = DF462E0E23F22F5300EFF35F /* WKHTTPCookieStorePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
|  		DF462E1223F338BE00EFF35F /* WKContentWorldPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = DF462E1123F338AD00EFF35F /* WKContentWorldPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
|  		E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E105FE5318D7B9DE008F57A8 /* EditingRange.h */; };
 | |
| @@ -1830,6 +1843,7 @@
 | |
|  		E5CB07DC20E1678F0022C183 /* WKFormColorControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E5CB07DA20E1678F0022C183 /* WKFormColorControl.h */; };
 | |
|  		ECA680D81E690E2500731D20 /* WebProcessCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = ECA680D71E690DF800731D20 /* WebProcessCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
|  		ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A22F0FF1289FCD90085E74F /* WKBundlePageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
| +		F3867F0A24607D4E008F0F31 /* InspectorScreencastAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = F3867F0424607D2B008F0F31 /* InspectorScreencastAgent.h */; };
 | |
|  		F409BA181E6E64BC009DA28E /* WKDragDestinationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
 | |
|  		F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */ = {isa = PBXBuildFile; fileRef = F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */; };
 | |
|  		F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */; };
 | |
| @@ -5246,6 +5260,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>"; };
 | |
| +		D71A942C2370DF81002C4D9E /* WKBrowserInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowserInspector.h; sourceTree = "<group>"; };
 | |
| +		D71A94302370E025002C4D9E /* InspectorPlaywrightAgentClientMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorPlaywrightAgentClientMac.h; sourceTree = "<group>"; };
 | |
| +		D71A94332370E07A002C4D9E /* InspectorPlaywrightAgentClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorPlaywrightAgentClient.h; sourceTree = "<group>"; };
 | |
| +		D71A94372370F032002C4D9E /* BrowserInspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowserInspectorController.h; sourceTree = "<group>"; };
 | |
| +		D71A94392370F060002C4D9E /* RemoteInspectorPipe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectorPipe.h; sourceTree = "<group>"; };
 | |
| +		D71A943F2371F67E002C4D9E /* WebPageInspectorEmulationAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageInspectorEmulationAgent.h; sourceTree = "<group>"; };
 | |
| +		D71A94402371F67E002C4D9E /* WebPageInspectorInputAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageInspectorInputAgent.h; sourceTree = "<group>"; };
 | |
| +		D71A94492372290B002C4D9E /* _WKBrowserInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKBrowserInspector.h; sourceTree = "<group>"; };
 | |
| +		D71A944B237239FB002C4D9E /* BrowserInspectorPipe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowserInspectorPipe.h; sourceTree = "<group>"; };
 | |
| +		D76D6887238DBD80008D314B /* InspectorDialogAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDialogAgent.h; sourceTree = "<group>"; };
 | |
| +		D79902AE236E9404005D6F7E /* WebPageInspectorEmulationAgentMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPageInspectorEmulationAgentMac.mm; sourceTree = "<group>"; };
 | |
| +		D79902AF236E9404005D6F7E /* InspectorTargetProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorTargetProxyMac.mm; sourceTree = "<group>"; };
 | |
| +		D79902B0236E9404005D6F7E /* WebPageInspectorInputAgentMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPageInspectorInputAgentMac.mm; sourceTree = "<group>"; };
 | |
| +		D7EB04E62372A73B00F744CE /* InspectorPlaywrightAgentClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorPlaywrightAgentClientMac.mm; sourceTree = "<group>"; };
 | |
|  		DF462E0E23F22F5300EFF35F /* WKHTTPCookieStorePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHTTPCookieStorePrivate.h; sourceTree = "<group>"; };
 | |
|  		DF462E1123F338AD00EFF35F /* WKContentWorldPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentWorldPrivate.h; sourceTree = "<group>"; };
 | |
|  		DF58C6311371AC5800F9A37C /* NativeWebWheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebWheelEvent.h; sourceTree = "<group>"; };
 | |
| @@ -5350,6 +5378,9 @@
 | |
|  		ECA680D71E690DF800731D20 /* WebProcessCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebProcessCocoa.h; sourceTree = "<group>"; };
 | |
|  		ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtraPublicSymbolsForTAPI.h; sourceTree = "<group>"; };
 | |
|  		F036978715F4BF0500C3A80E /* WebColorPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebColorPicker.cpp; sourceTree = "<group>"; };
 | |
| +		F3867F0324607D2B008F0F31 /* InspectorScreencastAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorScreencastAgent.cpp; sourceTree = "<group>"; };
 | |
| +		F3867F0424607D2B008F0F31 /* InspectorScreencastAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorScreencastAgent.h; sourceTree = "<group>"; };
 | |
| +		F3A1D2F72460E68400AA3AB8 /* InspectorScreencastAgentMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorScreencastAgentMac.mm; sourceTree = "<group>"; };
 | |
|  		F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDragDestinationAction.h; sourceTree = "<group>"; };
 | |
|  		F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionContext.h; path = ios/WebAutocorrectionContext.h; sourceTree = "<group>"; };
 | |
|  		F41056612130699A0092281D /* APIAttachmentCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = APIAttachmentCocoa.mm; sourceTree = "<group>"; };
 | |
| @@ -7193,6 +7224,7 @@
 | |
|  		37C4C08318149C2A003688B9 /* Cocoa */ = {
 | |
|  			isa = PBXGroup;
 | |
|  			children = (
 | |
| +				D71A94492372290B002C4D9E /* _WKBrowserInspector.h */,
 | |
|  				1A43E826188F38E2009E4D30 /* Deprecated */,
 | |
|  				37A5E01218BBF937000A081E /* _WKActivatedElementInfo.h */,
 | |
|  				37A5E01118BBF937000A081E /* _WKActivatedElementInfo.mm */,
 | |
| @@ -8489,6 +8521,8 @@
 | |
|  			children = (
 | |
|  				9197940423DBC4BB00257892 /* InspectorBrowserAgent.cpp */,
 | |
|  				9197940323DBC4BB00257892 /* InspectorBrowserAgent.h */,
 | |
| +				F3867F0324607D2B008F0F31 /* InspectorScreencastAgent.cpp */,
 | |
| +				F3867F0424607D2B008F0F31 /* InspectorScreencastAgent.h */,
 | |
|  			);
 | |
|  			path = Agents;
 | |
|  			sourceTree = "<group>";
 | |
| @@ -8496,6 +8530,7 @@
 | |
|  		91D970D623DA6D550057DBC3 /* mac */ = {
 | |
|  			isa = PBXGroup;
 | |
|  			children = (
 | |
| +				F3A1D2F72460E68400AA3AB8 /* InspectorScreencastAgentMac.mm */,
 | |
|  				A5D3504D1D78F0D2005124A9 /* RemoteWebInspectorProxyMac.mm */,
 | |
|  				1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */,
 | |
|  				994BADF11F7D77EA00B571E7 /* WKInspectorViewController.h */,
 | |
| @@ -8913,6 +8948,13 @@
 | |
|  		BC032DC310F438260058C15A /* UIProcess */ = {
 | |
|  			isa = PBXGroup;
 | |
|  			children = (
 | |
| +				D76D6887238DBD80008D314B /* InspectorDialogAgent.h */,
 | |
| +				D71A944B237239FB002C4D9E /* BrowserInspectorPipe.h */,
 | |
| +				D71A943F2371F67E002C4D9E /* WebPageInspectorEmulationAgent.h */,
 | |
| +				D71A94402371F67E002C4D9E /* WebPageInspectorInputAgent.h */,
 | |
| +				D71A94392370F060002C4D9E /* RemoteInspectorPipe.h */,
 | |
| +				D71A94372370F032002C4D9E /* BrowserInspectorController.h */,
 | |
| +				D71A94332370E07A002C4D9E /* InspectorPlaywrightAgentClient.h */,
 | |
|  				BC032DC410F4387C0058C15A /* API */,
 | |
|  				512F588D12A8836F00629530 /* Authentication */,
 | |
|  				9955A6E81C79809000EB6A93 /* Automation */,
 | |
| @@ -9197,6 +9239,7 @@
 | |
|  		BC0C376610F807660076D7CB /* C */ = {
 | |
|  			isa = PBXGroup;
 | |
|  			children = (
 | |
| +				D71A942C2370DF81002C4D9E /* WKBrowserInspector.h */,
 | |
|  				5123CF18133D25E60056F800 /* cg */,
 | |
|  				6EE849C41368D9040038D481 /* mac */,
 | |
|  				BCB63477116BF10600603215 /* WebKit2_C.h */,
 | |
| @@ -9797,6 +9840,11 @@
 | |
|  		BCCF085C113F3B7500C650C5 /* mac */ = {
 | |
|  			isa = PBXGroup;
 | |
|  			children = (
 | |
| +				D7EB04E62372A73B00F744CE /* InspectorPlaywrightAgentClientMac.mm */,
 | |
| +				D71A94302370E025002C4D9E /* InspectorPlaywrightAgentClientMac.h */,
 | |
| +				D79902AE236E9404005D6F7E /* WebPageInspectorEmulationAgentMac.mm */,
 | |
| +				D79902B0236E9404005D6F7E /* WebPageInspectorInputAgentMac.mm */,
 | |
| +				D79902AF236E9404005D6F7E /* InspectorTargetProxyMac.mm */,
 | |
|  				B878B613133428DC006888E9 /* CorrectionPanel.h */,
 | |
|  				B878B614133428DC006888E9 /* CorrectionPanel.mm */,
 | |
|  				C1817362205844A900DFDA65 /* DisplayLink.cpp */,
 | |
| @@ -10573,6 +10621,7 @@
 | |
|  				991F492F23A812C60054642B /* _WKInspectorDebuggableInfo.h in Headers */,
 | |
|  				99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */,
 | |
|  				9197940C23DBC50300257892 /* _WKInspectorDelegate.h in Headers */,
 | |
| +				D71A944A2372290B002C4D9E /* _WKBrowserInspector.h in Headers */,
 | |
|  				5CAFDE472130846A00B1F7E1 /* _WKInspectorInternal.h in Headers */,
 | |
|  				9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */,
 | |
|  				A5C0F0AB2000658200536536 /* _WKInspectorWindow.h in Headers */,
 | |
| @@ -10697,6 +10746,7 @@
 | |
|  				7C89D2981A6753B2003A5FDE /* APIPageConfiguration.h in Headers */,
 | |
|  				1AC1336C18565C7A00F3EC05 /* APIPageHandle.h in Headers */,
 | |
|  				1AFDD3151891B54000153970 /* APIPolicyClient.h in Headers */,
 | |
| +				D71A94382370F032002C4D9E /* BrowserInspectorController.h in Headers */,
 | |
|  				7CE4D2201A4914CA00C7F152 /* APIProcessPoolConfiguration.h in Headers */,
 | |
|  				49BCA19223A177660028A836 /* APIResourceLoadStatisticsFirstParty.h in Headers */,
 | |
|  				49BCA19723A1930D0028A836 /* APIResourceLoadStatisticsThirdParty.h in Headers */,
 | |
| @@ -10824,6 +10874,7 @@
 | |
|  				BC06F43A12DBCCFB002D78DE /* GeolocationPermissionRequestProxy.h in Headers */,
 | |
|  				2DA944A41884E4F000ED86DB /* GestureTypes.h in Headers */,
 | |
|  				2DA049B8180CCD0A00AAFA9E /* GraphicsLayerCARemote.h in Headers */,
 | |
| +				D71A94342370E07A002C4D9E /* InspectorPlaywrightAgentClient.h in Headers */,
 | |
|  				C0CE72AD1247E78D00BC0EC4 /* HandleMessage.h in Headers */,
 | |
|  				1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */,
 | |
|  				57AC8F50217FEED90055438C /* HidConnection.h in Headers */,
 | |
| @@ -10952,8 +11003,10 @@
 | |
|  				41DC45961E3D6E2200B11F51 /* NetworkRTCProvider.h in Headers */,
 | |
|  				413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */,
 | |
|  				5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */,
 | |
| +				D71A94422371F67E002C4D9E /* WebPageInspectorEmulationAgent.h in Headers */,
 | |
|  				532159551DBAE7290054AA3C /* NetworkSessionCocoa.h in Headers */,
 | |
|  				417915B92257046F00D6F97E /* NetworkSocketChannel.h in Headers */,
 | |
| +				D71A943A2370F061002C4D9E /* RemoteInspectorPipe.h in Headers */,
 | |
|  				570DAAC22303730300E8FC04 /* NfcConnection.h in Headers */,
 | |
|  				570DAAAE23026F5C00E8FC04 /* NfcService.h in Headers */,
 | |
|  				31A2EC5614899C0900810D71 /* NotificationPermissionRequest.h in Headers */,
 | |
| @@ -11037,6 +11090,7 @@
 | |
|  				CD2865EE2255562000606AC7 /* ProcessTaskStateObserver.h in Headers */,
 | |
|  				463FD4821EB94EC000A2982C /* ProcessTerminationReason.h in Headers */,
 | |
|  				86E67A251910B9D100004AB7 /* ProcessThrottler.h in Headers */,
 | |
| +				D71A944C237239FB002C4D9E /* BrowserInspectorPipe.h in Headers */,
 | |
|  				83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */,
 | |
|  				A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */,
 | |
|  				1A0C227E2451130A00ED614D /* QuickLookThumbnailingSoftLink.h in Headers */,
 | |
| @@ -11334,6 +11388,7 @@
 | |
|  				A543E30D215C8A9000279CD9 /* WebPageInspectorTargetController.h in Headers */,
 | |
|  				A543E307215AD13700279CD9 /* WebPageInspectorTargetFrontendChannel.h in Headers */,
 | |
|  				C0CE72A11247E71D00BC0EC4 /* WebPageMessages.h in Headers */,
 | |
| +				F3867F0A24607D4E008F0F31 /* InspectorScreencastAgent.h in Headers */,
 | |
|  				2D5C9D0619C81D8F00B3C5C1 /* WebPageOverlay.h in Headers */,
 | |
|  				46C392292316EC4D008EED9B /* WebPageProxyIdentifier.h in Headers */,
 | |
|  				BCBD3915125BB1A800D2C29F /* WebPageProxyMessages.h in Headers */,
 | |
| @@ -11464,6 +11519,7 @@
 | |
|  				BCD25F1711D6BDE100169B0E /* WKBundleFrame.h in Headers */,
 | |
|  				BCF049E611FE20F600F86A58 /* WKBundleFramePrivate.h in Headers */,
 | |
|  				BC49862F124D18C100D834E1 /* WKBundleHitTestResult.h in Headers */,
 | |
| +				D71A94432371F67E002C4D9E /* WebPageInspectorInputAgent.h in Headers */,
 | |
|  				BC204EF211C83EC8008F3375 /* WKBundleInitialize.h in Headers */,
 | |
|  				65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */,
 | |
|  				1A8B66B41BC45B010082DF77 /* WKBundleMac.h in Headers */,
 | |
| @@ -11516,6 +11572,7 @@
 | |
|  				5C795D71229F3757003FF1C4 /* WKContextMenuElementInfoPrivate.h in Headers */,
 | |
|  				51A555F6128C6C47009ABCEC /* WKContextMenuItem.h in Headers */,
 | |
|  				51A55601128C6D92009ABCEC /* WKContextMenuItemTypes.h in Headers */,
 | |
| +				D76D6888238DBD81008D314B /* InspectorDialogAgent.h in Headers */,
 | |
|  				A1EA02381DABFF7E0096021F /* WKContextMenuListener.h in Headers */,
 | |
|  				BCC938E11180DE440085E5FE /* WKContextPrivate.h in Headers */,
 | |
|  				9FB5F395169E6A80002C25BF /* WKContextPrivateMac.h in Headers */,
 | |
| @@ -11666,6 +11723,7 @@
 | |
|  				1AB8A1F818400BB800E9AE69 /* WKPageContextMenuClient.h in Headers */,
 | |
|  				8372DB251A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h in Headers */,
 | |
|  				1AB8A1F418400B8F00E9AE69 /* WKPageFindClient.h in Headers */,
 | |
| +				D71A94322370E025002C4D9E /* InspectorPlaywrightAgentClientMac.h in Headers */,
 | |
|  				1AB8A1F618400B9D00E9AE69 /* WKPageFindMatchesClient.h in Headers */,
 | |
|  				1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,
 | |
|  				BC7B633712A45ABA00D174A4 /* WKPageGroup.h in Headers */,
 | |
| @@ -12720,6 +12778,7 @@
 | |
|  				CDA93DB122F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp in Sources */,
 | |
|  				2749F6442146561B008380BF /* InjectedBundleNodeHandle.cpp in Sources */,
 | |
|  				2749F6452146561E008380BF /* InjectedBundleRangeHandle.cpp in Sources */,
 | |
| +				D79902B2236E9404005D6F7E /* InspectorTargetProxyMac.mm in Sources */,
 | |
|  				2D913441212CF9F000128AFD /* JSNPMethod.cpp in Sources */,
 | |
|  				2D913442212CF9F000128AFD /* JSNPObject.cpp in Sources */,
 | |
|  				2984F588164BA095004BC0C6 /* LegacyCustomProtocolManagerMessageReceiver.cpp in Sources */,
 | |
| @@ -12731,6 +12790,7 @@
 | |
|  				2D92A781212B6A7100F493FD /* MessageReceiverMap.cpp in Sources */,
 | |
|  				2D92A782212B6A7100F493FD /* MessageSender.cpp in Sources */,
 | |
|  				2D92A77A212B6A6100F493FD /* Module.cpp in Sources */,
 | |
| +				D79902B1236E9404005D6F7E /* WebPageInspectorEmulationAgentMac.mm in Sources */,
 | |
|  				57B826452304F14000B72EB0 /* NearFieldSoftLink.mm in Sources */,
 | |
|  				2D913443212CF9F000128AFD /* NetscapeBrowserFuncs.cpp in Sources */,
 | |
|  				2D913444212CF9F000128AFD /* NetscapePlugin.cpp in Sources */,
 | |
| @@ -12755,6 +12815,7 @@
 | |
|  				1A2D8439127F65D5001EB962 /* NPObjectMessageReceiverMessageReceiver.cpp in Sources */,
 | |
|  				2D92A792212B6AD400F493FD /* NPObjectProxy.cpp in Sources */,
 | |
|  				2D92A793212B6AD400F493FD /* NPRemoteObjectMap.cpp in Sources */,
 | |
| +				D7EB04E72372A73B00F744CE /* InspectorPlaywrightAgentClientMac.mm in Sources */,
 | |
|  				2D913447212CF9F000128AFD /* NPRuntimeObjectMap.cpp in Sources */,
 | |
|  				2D913448212CF9F000128AFD /* NPRuntimeUtilities.cpp in Sources */,
 | |
|  				2D92A794212B6AD400F493FD /* NPVariantData.cpp in Sources */,
 | |
| @@ -13038,6 +13099,7 @@
 | |
|  				2D92A78C212B6AB100F493FD /* WebMouseEvent.cpp in Sources */,
 | |
|  				31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */,
 | |
|  				2DF6FE52212E110900469030 /* WebPage.cpp in Sources */,
 | |
| +				D79902B3236E9404005D6F7E /* WebPageInspectorInputAgentMac.mm in Sources */,
 | |
|  				C0CE72A01247E71D00BC0EC4 /* WebPageMessageReceiver.cpp in Sources */,
 | |
|  				BCBD3914125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp in Sources */,
 | |
|  				7CE9CE101FA0767A000177DE /* WebPageUpdatePreferences.cpp in Sources */,
 | |
| diff --git a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
 | |
| index b8dccad2c2cf8d0001400407caca6e27b1f88249..dcd9395244e718872448300dbcac9c38809cb4fa 100644
 | |
| --- a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
 | |
| +++ b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
 | |
| @@ -58,6 +58,7 @@
 | |
|  #include <WebCore/Frame.h>
 | |
|  #include <WebCore/FrameLoader.h>
 | |
|  #include <WebCore/HTMLFrameOwnerElement.h>
 | |
| +#include <WebCore/InspectorInstrumentationWebKit.h>
 | |
|  #include <WebCore/NetscapePlugInStreamLoader.h>
 | |
|  #include <WebCore/NetworkLoadInformation.h>
 | |
|  #include <WebCore/PlatformStrategies.h>
 | |
| @@ -228,8 +229,24 @@ void WebLoaderStrategy::scheduleLoad(ResourceLoader& resourceLoader, CachedResou
 | |
|      }
 | |
|  #endif
 | |
|  
 | |
| +    if (m_emulateOfflineState) {
 | |
| +        scheduleInternallyFailedLoad(resourceLoader);
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      if (!tryLoadingUsingURLSchemeHandler(resourceLoader, trackingParameters)) {
 | |
|          WEBLOADERSTRATEGY_RELEASE_LOG_IF_ALLOWED("scheduleLoad: URL will be scheduled with the NetworkProcess");
 | |
| +
 | |
| +        RefPtr<ResourceLoader> coreLoader = &resourceLoader;
 | |
| +        if (!resourceLoader.options().serviceWorkerRegistrationIdentifier) {
 | |
| +            if (InspectorInstrumentationWebKit::interceptRequest(resourceLoader, [this, coreLoader, trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, resource](bool handled) mutable {
 | |
| +                    if (!handled)
 | |
| +                        scheduleLoadFromNetworkProcess(*coreLoader, coreLoader->request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
 | |
| +                    })) {
 | |
| +                return;
 | |
| +            }
 | |
| +        }
 | |
| +
 | |
|          scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
 | |
|          return;
 | |
|      }
 | |
| @@ -758,7 +775,7 @@ void WebLoaderStrategy::didFinishPreconnection(uint64_t preconnectionIdentifier,
 | |
|  
 | |
|  bool WebLoaderStrategy::isOnLine() const
 | |
|  {
 | |
| -    return m_isOnLine;
 | |
| +    return m_emulateOfflineState ? false : m_isOnLine;
 | |
|  }
 | |
|  
 | |
|  void WebLoaderStrategy::addOnlineStateChangeListener(Function<void(bool)>&& listener)
 | |
| @@ -769,6 +786,11 @@ void WebLoaderStrategy::addOnlineStateChangeListener(Function<void(bool)>&& list
 | |
|  
 | |
|  void WebLoaderStrategy::setOnLineState(bool isOnLine)
 | |
|  {
 | |
| +    if (m_emulateOfflineState) {
 | |
| +        m_isOnLine = isOnLine;
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
|      if (m_isOnLine == isOnLine)
 | |
|          return;
 | |
|  
 | |
| @@ -777,6 +799,12 @@ void WebLoaderStrategy::setOnLineState(bool isOnLine)
 | |
|          listener(isOnLine);
 | |
|  }
 | |
|  
 | |
| +void WebLoaderStrategy::setEmulateOfflineState(bool offline) {
 | |
| +    m_emulateOfflineState = offline;
 | |
| +    for (auto& listener : m_onlineStateChangeListeners)
 | |
| +        listener(offline ? false : m_isOnLine);
 | |
| +}
 | |
| +
 | |
|  void WebLoaderStrategy::setCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
 | |
|  {
 | |
|      WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::SetCaptureExtraNetworkLoadMetricsEnabled(enabled), 0);
 | |
| diff --git a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
 | |
| index 283afab34d2d73235219f9aad80f6028a9b6faef..bbe4f258383dc21574cc3b5769deae721d5f427d 100644
 | |
| --- a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
 | |
| +++ b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
 | |
| @@ -88,6 +88,7 @@ public:
 | |
|      bool isOnLine() const final;
 | |
|      void addOnlineStateChangeListener(Function<void(bool)>&&) final;
 | |
|      void setOnLineState(bool);
 | |
| +    void setEmulateOfflineState(bool) final;
 | |
|  
 | |
|  private:
 | |
|      void scheduleLoad(WebCore::ResourceLoader&, WebCore::CachedResource*, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
 | |
| @@ -126,6 +127,7 @@ private:
 | |
|      HashMap<unsigned long, PreconnectCompletionHandler> m_preconnectCompletionHandlers;
 | |
|      Vector<Function<void(bool)>> m_onlineStateChangeListeners;
 | |
|      bool m_isOnLine { true };
 | |
| +    bool m_emulateOfflineState { false };
 | |
|  };
 | |
|  
 | |
|  } // namespace WebKit
 | |
| diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
 | |
| index 966787f5cf9005c23079195379add2771b50308f..dff4d9b6b2a95e05505644e60d1403822826652f 100644
 | |
| --- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
 | |
| +++ b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
 | |
| @@ -385,6 +385,8 @@ void WebChromeClient::setResizable(bool resizable)
 | |
|  
 | |
|  void WebChromeClient::addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID)
 | |
|  {
 | |
| +    if (level == MessageLevel::Error)
 | |
| +        m_page.send(Messages::WebPageProxy::LogToStderr(message));
 | |
|      // Notify the bundle client.
 | |
|      m_page.injectedBundleUIClient().willAddMessageToConsole(&m_page, source, level, message, lineNumber, columnNumber, sourceID);
 | |
|  }
 | |
| @@ -775,6 +777,13 @@ bool WebChromeClient::canShowDataListSuggestionLabels() const
 | |
|  
 | |
|  #endif
 | |
|  
 | |
| +#if ENABLE(ORIENTATION_EVENTS) && !PLATFORM(IOS_FAMILY)
 | |
| +int WebChromeClient::deviceOrientation() const {
 | |
| +    // Only overrides are supported for non-iOS platforms.
 | |
| +    return 0;
 | |
| +}
 | |
| +#endif
 | |
| +
 | |
|  void WebChromeClient::runOpenPanel(Frame& frame, FileChooser& fileChooser)
 | |
|  {
 | |
|      if (m_page.activeOpenPanelResultListener())
 | |
| diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
 | |
| index 28189c82da62d9e0d9f516f1a69d4a8614dbd1d6..eeb699cd93357a271ae05c5873c9ebba43c6460b 100644
 | |
| --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
 | |
| +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
 | |
| @@ -37,6 +37,7 @@
 | |
|  #include "WebPreferencesKeys.h"
 | |
|  #include <WebCore/Frame.h>
 | |
|  #include <WebCore/GraphicsContext.h>
 | |
| +#include <WebCore/InspectorController.h>
 | |
|  #include <WebCore/Page.h>
 | |
|  #include <WebCore/PageOverlayController.h>
 | |
|  #include <WebCore/Settings.h>
 | |
| @@ -244,12 +245,20 @@ void DrawingAreaCoordinatedGraphics::updatePreferences(const WebPreferencesStore
 | |
|          settings.setAcceleratedCompositingEnabled(false);
 | |
|      }
 | |
|  #endif
 | |
| +
 | |
| +#if USE(LIBWPE)
 | |
| +    settings.setAcceleratedCompositingEnabled(false);
 | |
| +    settings.setForceCompositingMode(false);
 | |
| +    settings.setAcceleratedCompositingForFixedPositionEnabled(false);
 | |
| +    m_alwaysUseCompositing = false;
 | |
| +#else
 | |
|      settings.setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()));
 | |
|      // Fixed position elements need to be composited and create stacking contexts
 | |
|      // in order to be scrolled by the ScrollingCoordinator.
 | |
|      settings.setAcceleratedCompositingForFixedPositionEnabled(settings.acceleratedCompositingEnabled());
 | |
|  
 | |
|      m_alwaysUseCompositing = settings.acceleratedCompositingEnabled() && settings.forceCompositingMode();
 | |
| +#endif
 | |
|  
 | |
|      // If async scrolling is disabled, we have to force-disable async frame and overflow scrolling
 | |
|      // to keep the non-async scrolling on those elements working.
 | |
| @@ -713,6 +722,11 @@ void DrawingAreaCoordinatedGraphics::display()
 | |
|          return;
 | |
|      }
 | |
|  
 | |
| +// Playwright begin
 | |
| +#if PLATFORM(WPE) || PLATFORM(WIN)
 | |
| +    m_webPage.corePage()->inspectorController().willDisplay();
 | |
| +#endif
 | |
| +// Playwright end
 | |
|      send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
 | |
|      m_isWaitingForDidUpdate = true;
 | |
|  }
 | |
| diff --git a/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp b/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp
 | |
| index b2d54a627b94583bda3518c4e7c3364481b605a4..d407e32b6a7b8b27925c49391e86d42c9b3dfa8b 100644
 | |
| --- a/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp
 | |
| +++ b/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp
 | |
| @@ -47,6 +47,14 @@ void WebDocumentLoader::detachFromFrame()
 | |
|      DocumentLoader::detachFromFrame();
 | |
|  }
 | |
|  
 | |
| +void WebDocumentLoader::replacedByFragmentNavigation(Frame& frame)
 | |
| +{
 | |
| +    ASSERT(!this->frame());
 | |
| +    // Notify WebPageProxy that the navigation has been converted into same page navigation.
 | |
| +    if (m_navigationID)
 | |
| +        WebFrame::fromCoreFrame(frame)->documentLoaderDetached(m_navigationID);
 | |
| +}
 | |
| +
 | |
|  void WebDocumentLoader::setNavigationID(uint64_t navigationID)
 | |
|  {
 | |
|      ASSERT(navigationID);
 | |
| diff --git a/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.h b/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.h
 | |
| index f127d64d005ab7b93875591b94a5899205e91579..df0de26e4dc449a0fbf93e7037444df4e5365822 100644
 | |
| --- a/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.h
 | |
| +++ b/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.h
 | |
| @@ -43,7 +43,10 @@ public:
 | |
|  private:
 | |
|      WebDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
 | |
|  
 | |
| +    uint64_t loaderIDForInspector() override { return navigationID(); }
 | |
| +
 | |
|      void detachFromFrame() override;
 | |
| +    void replacedByFragmentNavigation(WebCore::Frame&) override;
 | |
|  
 | |
|      uint64_t m_navigationID;
 | |
|  };
 | |
| diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
 | |
| index 8ba9342bc0fd7cbc53bf809f7fc76d3a3eed22a5..fe2c4cda9dcaa60adf4338ff874a484aa361e91d 100644
 | |
| --- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp
 | |
| +++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
 | |
| @@ -765,6 +765,9 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
 | |
|      send(Messages::WebPageProxy::DidCreateContextForVisibilityPropagation(m_contextForVisibilityPropagation->contextID()));
 | |
|  #endif
 | |
|  
 | |
| +    if (parameters.shouldPauseInInspectorWhenShown)
 | |
| +        m_page->inspectorController().pauseWhenShown();
 | |
| +
 | |
|      updateThrottleState();
 | |
|  }
 | |
|  
 | |
| @@ -1524,6 +1527,22 @@ void WebPage::platformDidReceiveLoadParameters(const LoadParameters& loadParamet
 | |
|  }
 | |
|  #endif
 | |
|  
 | |
| +void WebPage::loadRequestInFrameForInspector(LoadParameters&& loadParameters, WebCore::FrameIdentifier frameID)
 | |
| +{
 | |
| +    WebFrame* frame = WebProcess::singleton().webFrame(frameID);
 | |
| +    if (!frame) {
 | |
| +        send(Messages::WebPageProxy::DidDestroyNavigation(loadParameters.navigationID));
 | |
| +        return;
 | |
| +    }
 | |
| +
 | |
| +    // FIXME: use m_pendingNavigationID instead?
 | |
| +    m_pendingFrameNavigationID = loadParameters.navigationID;
 | |
| +
 | |
| +    FrameLoadRequest frameLoadRequest { *frame->coreFrame(), loadParameters.request };
 | |
| +    frame->coreFrame()->loader().load(WTFMove(frameLoadRequest));
 | |
| +    ASSERT(!m_pendingFrameNavigationID);
 | |
| +}
 | |
| +
 | |
|  void WebPage::loadRequest(LoadParameters&& loadParameters)
 | |
|  {
 | |
|      setIsNavigatingToAppBoundDomain(loadParameters.isNavigatingToAppBoundDomain);
 | |
| @@ -1730,17 +1749,13 @@ void WebPage::setSize(const WebCore::IntSize& viewSize)
 | |
|      view->resize(viewSize);
 | |
|      m_drawingArea->setNeedsDisplay();
 | |
|  
 | |
| -#if USE(COORDINATED_GRAPHICS)
 | |
|      if (view->useFixedLayout())
 | |
|          sendViewportAttributesChanged(m_page->viewportArguments());
 | |
| -#endif
 | |
|  }
 | |
|  
 | |
| -#if USE(COORDINATED_GRAPHICS)
 | |
|  void WebPage::sendViewportAttributesChanged(const ViewportArguments& viewportArguments)
 | |
|  {
 | |
| -    FrameView* view = m_page->mainFrame().view();
 | |
| -    ASSERT(view && view->useFixedLayout());
 | |
| +    ASSERT(m_page->mainFrame().view() && m_page->mainFrame().view()->useFixedLayout());
 | |
|  
 | |
|      // Viewport properties have no impact on zero sized fixed viewports.
 | |
|      if (m_viewSize.isEmpty())
 | |
| @@ -1757,20 +1772,18 @@ void WebPage::sendViewportAttributesChanged(const ViewportArguments& viewportArg
 | |
|  
 | |
|      ViewportAttributes attr = computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, deviceWidth, deviceHeight, 1, m_viewSize);
 | |
|  
 | |
| -    // If no layout was done yet set contentFixedOrigin to (0,0).
 | |
| -    IntPoint contentFixedOrigin = view->didFirstLayout() ? view->fixedVisibleContentRect().location() : IntPoint();
 | |
| -
 | |
| -    // Put the width and height to the viewport width and height. In css units however.
 | |
| -    // Use FloatSize to avoid truncated values during scale.
 | |
| -    FloatSize contentFixedSize = m_viewSize;
 | |
| -
 | |
| -    contentFixedSize.scale(1 / attr.initialScale);
 | |
| -    view->setFixedVisibleContentRect(IntRect(contentFixedOrigin, roundedIntSize(contentFixedSize)));
 | |
| +#if ENABLE(CSS_DEVICE_ADAPTATION)
 | |
| +    FrameView* view = m_page->mainFrame().view();
 | |
| +    // CSS viewport descriptors might be applied to already affected viewport size
 | |
| +    // if the page enables/disables stylesheets, so need to keep initial viewport size.
 | |
| +    view->setInitialViewportSize(roundedIntSize(m_viewSize));
 | |
| +#endif
 | |
|  
 | |
|      attr.initialScale = m_page->viewportArguments().zoom; // Resets auto (-1) if no value was set by user.
 | |
|  
 | |
|      // This also takes care of the relayout.
 | |
|      setFixedLayoutSize(roundedIntSize(attr.layoutSize));
 | |
| +    scaleView(deviceWidth / attr.layoutSize.width());
 | |
|  
 | |
|  #if USE(COORDINATED_GRAPHICS)
 | |
|      m_drawingArea->didChangeViewportAttributes(WTFMove(attr));
 | |
| @@ -1778,7 +1791,6 @@ void WebPage::sendViewportAttributesChanged(const ViewportArguments& viewportArg
 | |
|      send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
 | |
|  #endif
 | |
|  }
 | |
| -#endif
 | |
|  
 | |
|  void WebPage::scrollMainFrameIfNotAtMaxScrollPosition(const IntSize& scrollOffset)
 | |
|  {
 | |
| @@ -2077,6 +2089,7 @@ void WebPage::scaleView(double scale)
 | |
|      }
 | |
|  
 | |
|      m_page->setViewScaleFactor(scale);
 | |
| +    send(Messages::WebPageProxy::ViewScaleFactorDidChange(scale));
 | |
|      scalePage(pageScale, scrollPositionAtNewScale);
 | |
|  }
 | |
|  
 | |
| @@ -2181,17 +2194,13 @@ void WebPage::viewportPropertiesDidChange(const ViewportArguments& viewportArgum
 | |
|          viewportConfigurationChanged();
 | |
|  #endif
 | |
|  
 | |
| -#if USE(COORDINATED_GRAPHICS)
 | |
|      FrameView* view = m_page->mainFrame().view();
 | |
|      if (view && view->useFixedLayout())
 | |
|          sendViewportAttributesChanged(viewportArguments);
 | |
| +#if USE(COORDINATED_GRAPHICS)
 | |
|      else
 | |
|          m_drawingArea->didChangeViewportAttributes(ViewportAttributes());
 | |
|  #endif
 | |
| -
 | |
| -#if !PLATFORM(IOS_FAMILY) && !USE(COORDINATED_GRAPHICS)
 | |
| -    UNUSED_PARAM(viewportArguments);
 | |
| -#endif
 | |
|  }
 | |
|  
 | |
|  void WebPage::listenForLayoutMilestones(OptionSet<WebCore::LayoutMilestone> milestones)
 | |
| @@ -3076,6 +3085,11 @@ void WebPage::sendMessageToTargetBackend(const String& targetId, const String& m
 | |
|      m_inspectorTargetController->sendMessageToTargetBackend(targetId, message);
 | |
|  }
 | |
|  
 | |
| +void WebPage::resumeInspectorIfPausedInNewWindow()
 | |
| +{
 | |
| +    m_page->inspectorController().resumeIfPausedInNewWindow();
 | |
| +}
 | |
| +
 | |
|  void WebPage::insertNewlineInQuotedContent()
 | |
|  {
 | |
|      Frame& frame = m_page->focusController().focusedOrMainFrame();
 | |
| @@ -3316,6 +3330,7 @@ void WebPage::didCompletePageTransition()
 | |
|  void WebPage::show()
 | |
|  {
 | |
|      send(Messages::WebPageProxy::ShowPage());
 | |
| +    m_page->inspectorController().didShowNewWindow();
 | |
|  }
 | |
|  
 | |
|  void WebPage::setShouldFireEvents(bool shouldFireEvents)
 | |
| @@ -6407,6 +6422,9 @@ Ref<DocumentLoader> WebPage::createDocumentLoader(Frame& frame, const ResourceRe
 | |
|              WebsitePoliciesData::applyToDocumentLoader(WTFMove(*m_pendingWebsitePolicies), documentLoader);
 | |
|              m_pendingWebsitePolicies = WTF::nullopt;
 | |
|          }
 | |
| +    } else if (m_pendingFrameNavigationID) {
 | |
| +        documentLoader->setNavigationID(m_pendingFrameNavigationID);
 | |
| +        m_pendingFrameNavigationID = 0;
 | |
|      }
 | |
|  
 | |
|      return documentLoader;
 | |
| diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h
 | |
| index 15f28cf26735b9026f86dc15525382b18ea0a58d..081cafc5aa1908561fd342debb4fb3377007b24f 100644
 | |
| --- a/Source/WebKit/WebProcess/WebPage/WebPage.h
 | |
| +++ b/Source/WebKit/WebProcess/WebPage/WebPage.h
 | |
| @@ -1160,6 +1160,7 @@ public:
 | |
|      void connectInspector(const String& targetId, Inspector::FrontendChannel::ConnectionType);
 | |
|      void disconnectInspector(const String& targetId);
 | |
|      void sendMessageToTargetBackend(const String& targetId, const String& message);
 | |
| +    void resumeInspectorIfPausedInNewWindow();
 | |
|  
 | |
|      void insertNewlineInQuotedContent();
 | |
|  
 | |
| @@ -1423,6 +1424,7 @@ private:
 | |
|      // Actions
 | |
|      void tryClose(CompletionHandler<void(bool)>&&);
 | |
|      void platformDidReceiveLoadParameters(const LoadParameters&);
 | |
| +    void loadRequestInFrameForInspector(LoadParameters&&, WebCore::FrameIdentifier);
 | |
|      void loadRequest(LoadParameters&&);
 | |
|      NO_RETURN void loadRequestWaitingForProcessLaunch(LoadParameters&&, URL&&, WebPageProxyIdentifier, bool);
 | |
|      void loadData(LoadParameters&&);
 | |
| @@ -1571,9 +1573,7 @@ private:
 | |
|      void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
 | |
|      void replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly, CallbackID);
 | |
|  
 | |
| -#if USE(COORDINATED_GRAPHICS)
 | |
|      void sendViewportAttributesChanged(const WebCore::ViewportArguments&);
 | |
| -#endif
 | |
|  
 | |
|      void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
 | |
|      void setTextForActivePopupMenu(int32_t index);
 | |
| @@ -2035,6 +2035,7 @@ private:
 | |
|      UserActivity m_userActivity;
 | |
|  
 | |
|      uint64_t m_pendingNavigationID { 0 };
 | |
| +    uint64_t m_pendingFrameNavigationID { 0 };
 | |
|      Optional<WebsitePoliciesData> m_pendingWebsitePolicies;
 | |
|  
 | |
|      bool m_mainFrameProgressCompleted { false };
 | |
| diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
 | |
| index c8c162b4a6ea00fc509335a61d9b3223a7333e1a..e8611c967eb09e9af80806a19a2c8edf60445f2d 100644
 | |
| --- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
 | |
| +++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
 | |
| @@ -131,6 +131,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
 | |
|      ConnectInspector(String targetId, Inspector::FrontendChannel::ConnectionType connectionType)
 | |
|      DisconnectInspector(String targetId)
 | |
|      SendMessageToTargetBackend(String targetId, String message)
 | |
| +    ResumeInspectorIfPausedInNewWindow();
 | |
|  
 | |
|  #if ENABLE(REMOTE_INSPECTOR)
 | |
|      SetIndicating(bool indicating);
 | |
| @@ -171,6 +172,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
 | |
|      LoadURLInFrame(URL url, String referrer, WebCore::FrameIdentifier frameID)
 | |
|      LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, WebCore::FrameIdentifier frameID)
 | |
|      LoadRequest(struct WebKit::LoadParameters loadParameters)
 | |
| +    LoadRequestInFrameForInspector(struct WebKit::LoadParameters loadParameters, WebCore::FrameIdentifier frameID)
 | |
|      LoadRequestWaitingForProcessLaunch(struct WebKit::LoadParameters loadParameters, URL resourceDirectoryURL, WebKit::WebPageProxyIdentifier pageID, bool checkAssumedReadAccessToResourceURL)
 | |
|      LoadData(struct WebKit::LoadParameters loadParameters)
 | |
|      LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)
 | |
| diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp
 | |
| index 7ed17b898cb6c2cac74c3de29476f12322bb8641..1631fdc3d591761b754a89035da4d5e88698852b 100644
 | |
| --- a/Source/WebKit/WebProcess/WebProcess.cpp
 | |
| +++ b/Source/WebKit/WebProcess/WebProcess.cpp
 | |
| @@ -81,6 +81,7 @@
 | |
|  #include "WebsiteData.h"
 | |
|  #include "WebsiteDataStoreParameters.h"
 | |
|  #include "WebsiteDataType.h"
 | |
| +#include <JavaScriptCore/IdentifiersFactory.h>
 | |
|  #include <JavaScriptCore/JSLock.h>
 | |
|  #include <JavaScriptCore/MemoryStatistics.h>
 | |
|  #include <WebCore/AXObjectCache.h>
 | |
| @@ -275,6 +276,8 @@ void WebProcess::initializeProcess(const AuxiliaryProcessInitializationParameter
 | |
|      
 | |
|      platformInitializeProcess(parameters);
 | |
|      updateCPULimit();
 | |
| +
 | |
| +    Inspector::IdentifiersFactory::initializeWithProcessID(parameters.processIdentifier->toUInt64());
 | |
|  }
 | |
|  
 | |
|  void WebProcess::initializeConnection(IPC::Connection* connection)
 | |
| diff --git a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
 | |
| index 039b7f464a3e49886f57e68bf3430775f510f5ed..5d43d1415bde4fff315882e5a1787bcd17f94770 100644
 | |
| --- a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
 | |
| +++ b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
 | |
| @@ -4213,7 +4213,7 @@ static BOOL currentScrollIsBlit(NSView *clipView)
 | |
|      _private->handlingMouseDownEvent = NO;
 | |
|  }
 | |
|  
 | |
| -#if ENABLE(TOUCH_EVENTS)
 | |
| +#if ENABLE(IOS_TOUCH_EVENTS)
 | |
|  
 | |
|  - (void)touch:(WebEvent *)event
 | |
|  {
 | |
| diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm
 | |
| index ad9bfdd5321d17b108e414ac96e0222fdeae97cc..9fc34ccd13b6001b4b1c423dc48cadeef25f17d0 100644
 | |
| --- a/Source/WebKitLegacy/mac/WebView/WebView.mm
 | |
| +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm
 | |
| @@ -4353,7 +4353,7 @@ IGNORE_WARNINGS_END
 | |
|  }
 | |
|  #endif // PLATFORM(IOS_FAMILY)
 | |
|  
 | |
| -#if ENABLE(TOUCH_EVENTS)
 | |
| +#if ENABLE(IOS_TOUCH_EVENTS)
 | |
|  
 | |
|  - (NSArray *)_touchEventRegions
 | |
|  {
 | |
| @@ -4395,7 +4395,7 @@ IGNORE_WARNINGS_END
 | |
|      }).autorelease();
 | |
|  }
 | |
|  
 | |
| -#endif // ENABLE(TOUCH_EVENTS)
 | |
| +#endif // ENABLE(IOS_TOUCH_EVENTS)
 | |
|  
 | |
|  // 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 b1ac2660496e0e250a58063be5f970cf38c7ea7a..9aa2e9d07abeb3c3851fe731efbca2307152aa71 100644
 | |
| --- a/Source/cmake/OptionsGTK.cmake
 | |
| +++ b/Source/cmake/OptionsGTK.cmake
 | |
| @@ -5,6 +5,7 @@ WEBKIT_OPTION_BEGIN()
 | |
|  WEBKIT_OPTION_DEFINE(USE_GTK4 "Whether to enable usage of GTK4 instead of GTK3." PUBLIC OFF)
 | |
|  
 | |
|  SET_PROJECT_VERSION(2 29 0)
 | |
| +set(ENABLE_WEBKIT_LEGACY OFF)
 | |
|  
 | |
|  if (USE_GTK4)
 | |
|      set(WEBKITGTK_API_VERSION 5.0)
 | |
| @@ -197,6 +198,13 @@ if (USE_GTK4)
 | |
|  WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF)
 | |
|  endif ()
 | |
|  
 | |
| +# Playwright
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_APPLICATION_MANIFEST PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TRAILING_WORD PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CURSOR_VISIBILITY PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_CSS_VENDOR_PREFIXES PRIVATE ON)
 | |
| +
 | |
|  include(GStreamerDependencies)
 | |
|  
 | |
|  # Finalize the value for all options. Do not attempt to use an option before
 | |
| diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake
 | |
| index 1e32f16e9d2cb73f267ceb19c6aed46236b81587..2d1440b013ff6d7ada5bb76b7063da8d5d925214 100644
 | |
| --- a/Source/cmake/OptionsWPE.cmake
 | |
| +++ b/Source/cmake/OptionsWPE.cmake
 | |
| @@ -3,6 +3,7 @@ include(VersioningUtils)
 | |
|  
 | |
|  SET_PROJECT_VERSION(2 27 4)
 | |
|  set(WPE_API_VERSION 1.0)
 | |
| +set(ENABLE_WEBKIT_LEGACY OFF)
 | |
|  
 | |
|  CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT 12 0 9)
 | |
|  
 | |
| @@ -76,13 +77,21 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL2 PRIVATE OFF)
 | |
|  WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_RTC PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 | |
|  WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBXR PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 | |
|  
 | |
| +# Playwright
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_APPLICATION_MANIFEST PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TRAILING_WORD PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CURSOR_VISIBILITY PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DARK_MODE_CSS PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE PRIVATE ON)
 | |
| +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_CSS_VENDOR_PREFIXES PRIVATE ON)
 | |
| +
 | |
|  # Public options specific to the WPE port. Do not add any options here unless
 | |
|  # there is a strong reason we should support changing the value of the option,
 | |
|  # and the option is not relevant to any other WebKit ports.
 | |
|  WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBLIC OFF)
 | |
|  WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
 | |
|  WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
 | |
| -WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC ${DEVELOPER_MODE})
 | |
| +WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC OFF)
 | |
|  WEBKIT_OPTION_DEFINE(USE_SYSTEMD "Whether to enable journald logging" PUBLIC ON)
 | |
|  
 | |
|  # Private options specific to the WPE port.
 | |
| diff --git a/Source/cmake/OptionsWin.cmake b/Source/cmake/OptionsWin.cmake
 | |
| index f9fa3cf162bf2fa39d6f87626473ad00f62c1852..c143801ca8347009c160bcedcd7ff0b0a1685abf 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)
 | |
|  add_definitions(-DNOMINMAX)
 | |
|  add_definitions(-DUNICODE -D_UNICODE)
 | |
|  
 | |
| +set(ENABLE_WEBKIT_LEGACY OFF)
 | |
| +
 | |
|  if ((NOT DEFINED ENABLE_WEBKIT_LEGACY) OR ENABLE_WEBKIT_LEGACY)
 | |
| -    set(ENABLE_WEBKIT_LEGACY ON)
 | |
|      set(ENABLE_WEBKIT OFF)
 | |
|  endif ()
 | |
|  
 | |
| @@ -92,6 +93,13 @@ if (${WTF_PLATFORM_WIN_CAIRO})
 | |
|      WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBDRIVER PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 | |
|      WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_CRYPTO PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 | |
|  
 | |
| +    # Playwright
 | |
| +    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_CONIC_GRADIENTS PRIVATE ON)
 | |
| +    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TRAILING_WORD PRIVATE ON)
 | |
| +    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DARK_MODE_CSS PRIVATE ON)
 | |
| +    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE PRIVATE ON)
 | |
| +    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS PRIVATE ON)
 | |
| +
 | |
|      # FIXME: Implement plugin process on Modern WebKit. https://bugs.webkit.org/show_bug.cgi?id=185313
 | |
|      WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF)
 | |
|  else ()
 | |
| diff --git a/Tools/MiniBrowser/gtk/BrowserTab.c b/Tools/MiniBrowser/gtk/BrowserTab.c
 | |
| index b221685ad55706b6ffa40e3a2eba71b5de3450c8..da2dadca590a16c2545c91c6c382b3d9aced3e12 100644
 | |
| --- a/Tools/MiniBrowser/gtk/BrowserTab.c
 | |
| +++ b/Tools/MiniBrowser/gtk/BrowserTab.c
 | |
| @@ -149,6 +149,11 @@ static void loadChanged(WebKitWebView *webView, WebKitLoadEvent loadEvent, Brows
 | |
|      gtk_container_foreach(GTK_CONTAINER(tab), (GtkCallback)removeChildIfInfoBar, tab);
 | |
|  }
 | |
|  
 | |
| +static gboolean loadFailed()
 | |
| +{
 | |
| +    return TRUE;
 | |
| +}
 | |
| +
 | |
|  static GtkWidget *createInfoBarQuestionMessage(const char *title, const char *text)
 | |
|  {
 | |
|      GtkWidget *dialog = gtk_info_bar_new_with_buttons("No", GTK_RESPONSE_NO, "Yes", GTK_RESPONSE_YES, NULL);
 | |
| @@ -475,6 +480,7 @@ static void browserTabConstructed(GObject *gObject)
 | |
|      g_signal_connect(tab->webView, "notify::is-loading", G_CALLBACK(isLoadingChanged), tab);
 | |
|      g_signal_connect(tab->webView, "decide-policy", G_CALLBACK(decidePolicy), tab);
 | |
|      g_signal_connect(tab->webView, "load-changed", G_CALLBACK(loadChanged), tab);
 | |
| +    g_signal_connect(tab->webView, "load-failed", G_CALLBACK(loadFailed), tab);
 | |
|      g_signal_connect(tab->webView, "load-failed-with-tls-errors", G_CALLBACK(loadFailedWithTLSerrors), tab);
 | |
|      g_signal_connect(tab->webView, "permission-request", G_CALLBACK(decidePermissionRequest), tab);
 | |
|      g_signal_connect(tab->webView, "run-color-chooser", G_CALLBACK(runColorChooserCallback), tab);
 | |
| diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.c b/Tools/MiniBrowser/gtk/BrowserWindow.c
 | |
| index 22b8251b1803de631c541963969e4ed675ce2722..b07e53354465728abc8758adbe3819900f154155 100644
 | |
| --- a/Tools/MiniBrowser/gtk/BrowserWindow.c
 | |
| +++ b/Tools/MiniBrowser/gtk/BrowserWindow.c
 | |
| @@ -86,6 +86,8 @@ static const gdouble defaultZoomLevel = 1;
 | |
|  static const gdouble zoomStep = 1.2;
 | |
|  static GList *windowList;
 | |
|  
 | |
| +static gboolean no_quit = false;
 | |
| +
 | |
|  G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW)
 | |
|  
 | |
|  static char *getExternalURI(const char *uri)
 | |
| @@ -761,7 +763,7 @@ static void browserWindowFinalize(GObject *gObject)
 | |
|  
 | |
|      G_OBJECT_CLASS(browser_window_parent_class)->finalize(gObject);
 | |
|  
 | |
| -    if (!windowList)
 | |
| +    if (!windowList && !no_quit)
 | |
|          browser_main_quit();
 | |
|  }
 | |
|  
 | |
| @@ -1277,6 +1279,11 @@ void browser_window_set_background_color(BrowserWindow *window, GdkRGBA *rgba)
 | |
|  #endif
 | |
|  }
 | |
|  
 | |
| +void browser_window_no_quit(void)
 | |
| +{
 | |
| +    no_quit = true;
 | |
| +}
 | |
| +
 | |
|  static BrowserWindow *findActiveWindow(void)
 | |
|  {
 | |
|      GList *l;
 | |
| diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.h b/Tools/MiniBrowser/gtk/BrowserWindow.h
 | |
| index 1570d65effb5d601ee3c44a2a7461436f4691c2c..65e62adad0c3684e5cec2f6bc8e7f5281e1f77eb 100644
 | |
| --- a/Tools/MiniBrowser/gtk/BrowserWindow.h
 | |
| +++ b/Tools/MiniBrowser/gtk/BrowserWindow.h
 | |
| @@ -37,7 +37,7 @@ G_BEGIN_DECLS
 | |
|  #define BROWSER_IS_WINDOW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), BROWSER_TYPE_WINDOW))
 | |
|  #define BROWSER_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  BROWSER_TYPE_WINDOW))
 | |
|  #define BROWSER_WINDOW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  BROWSER_TYPE_WINDOW, BrowserWindowClass))
 | |
| -#define BROWSER_DEFAULT_URL            "http://www.webkitgtk.org/"
 | |
| +#define BROWSER_DEFAULT_URL            "about:blank"
 | |
|  #define BROWSER_ABOUT_SCHEME           "minibrowser-about"
 | |
|  
 | |
|  typedef struct _BrowserWindow        BrowserWindow;
 | |
| @@ -53,7 +53,7 @@ void browser_window_load_session(BrowserWindow *, const char *sessionFile);
 | |
|  void browser_window_set_background_color(BrowserWindow*, GdkRGBA*);
 | |
|  WebKitWebView* browser_window_get_or_create_web_view_for_automation(void);
 | |
|  WebKitWebView *browser_window_create_web_view_in_new_tab_for_automation(void);
 | |
| -
 | |
| +void browser_window_no_quit(void);
 | |
|  G_END_DECLS
 | |
|  
 | |
|  #endif
 | |
| diff --git a/Tools/MiniBrowser/gtk/main.c b/Tools/MiniBrowser/gtk/main.c
 | |
| index 2ff45b938cffabe95fe17137393b8b6c506d4993..bd28310341f4f47612dbbea350e83a6d182953c3 100644
 | |
| --- a/Tools/MiniBrowser/gtk/main.c
 | |
| +++ b/Tools/MiniBrowser/gtk/main.c
 | |
| @@ -54,6 +54,10 @@ static const char *cookiesFile;
 | |
|  static const char *cookiesPolicy;
 | |
|  static const char *proxy;
 | |
|  static gboolean darkMode;
 | |
| +static gboolean inspectorPipe;
 | |
| +static gboolean headless;
 | |
| +static gboolean noStartupWindow;
 | |
| +static const char *userDataDir;
 | |
|  static gboolean printVersion;
 | |
|  
 | |
|  typedef enum {
 | |
| @@ -122,6 +126,10 @@ static const GOptionEntry commandLineOptions[] =
 | |
|      { "ignore-tls-errors", 0, 0, G_OPTION_ARG_NONE, &ignoreTLSErrors, "Ignore TLS errors", NULL },
 | |
|      { "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },
 | |
|      { "version", 'v', 0, G_OPTION_ARG_NONE, &printVersion, "Print the WebKitGTK version", NULL },
 | |
| +    { "inspector-pipe", 0, 0, G_OPTION_ARG_NONE, &inspectorPipe, "Open pipe connection to the remote inspector", NULL },
 | |
| +    { "user-data-dir", 0, 0, G_OPTION_ARG_STRING, &userDataDir, "Default profile persistence folder location", NULL },
 | |
| +    { "headless", 0, 0, G_OPTION_ARG_NONE, &headless, "Noop headless operation", NULL },
 | |
| +    { "no-startup-window", 0, 0, G_OPTION_ARG_NONE, &noStartupWindow, "Do not open default page", NULL },
 | |
|      { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URL…]" },
 | |
|      { 0, 0, 0, 0, 0, 0, 0 }
 | |
|  };
 | |
| @@ -499,6 +507,34 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul
 | |
|      g_main_loop_quit(data->mainLoop);
 | |
|  }
 | |
|  
 | |
| +static WebKitWebContext *persistentWebContext = NULL;
 | |
| +
 | |
| +static WebKitWebView *createNewPage(WebKitBrowserInspector *browser_inspector, WebKitWebContext *context)
 | |
| +{
 | |
| +    if (context == NULL)
 | |
| +        context = persistentWebContext;
 | |
| +
 | |
| +    WebKitWebView *newWebView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
 | |
| +        "web-context", context,
 | |
| +        "is-ephemeral", webkit_web_context_is_ephemeral(context),
 | |
| +        "is-controlled-by-automation", TRUE,
 | |
| +        NULL));
 | |
| +    GtkWidget *newWindow = browser_window_new(NULL, context);
 | |
| +    browser_window_append_view(BROWSER_WINDOW(newWindow), newWebView);
 | |
| +    gtk_widget_grab_focus(GTK_WIDGET(newWebView));
 | |
| +    gtk_widget_show(GTK_WIDGET(newWindow));
 | |
| +    webkit_web_view_load_uri(newWebView, "about:blank");
 | |
| +    return newWebView;
 | |
| +}
 | |
| +
 | |
| +static void configureBrowserInspectorPipe()
 | |
| +{
 | |
| +    WebKitBrowserInspector* browserInspector = webkit_browser_inspector_get_default();
 | |
| +    g_signal_connect(browserInspector, "create-new-page", G_CALLBACK(createNewPage), NULL);
 | |
| +
 | |
| +    webkit_browser_inspector_initialize_pipe(NULL);
 | |
| +}
 | |
| +
 | |
|  int main(int argc, char *argv[])
 | |
|  {
 | |
|  #if ENABLE_DEVELOPER_MODE
 | |
| @@ -548,12 +584,32 @@ int main(int argc, char *argv[])
 | |
|          return 0;
 | |
|      }
 | |
|  
 | |
| -    WebKitWebsiteDataManager *manager = (privateMode || automationMode) ? webkit_website_data_manager_new_ephemeral() : webkit_website_data_manager_new(NULL);
 | |
| +    if (inspectorPipe)
 | |
| +        configureBrowserInspectorPipe();
 | |
| +
 | |
| +    if (noStartupWindow) {
 | |
| +        browser_window_no_quit();
 | |
| +        gtk_main();
 | |
| +        g_clear_object(&webkitSettings);
 | |
| +        return 0;
 | |
| +    }
 | |
| +
 | |
| +    WebKitWebsiteDataManager *manager;
 | |
| +    if (userDataDir) {
 | |
| +        manager = webkit_website_data_manager_new("base-data-directory", userDataDir, "base-cache-directory", userDataDir, NULL);
 | |
| +        cookiesFile = g_build_filename(userDataDir, "cookies.txt", NULL);
 | |
| +    } else if (inspectorPipe || privateMode || automationMode) {
 | |
| +        manager = webkit_website_data_manager_new_ephemeral();
 | |
| +    } else {
 | |
| +        manager = webkit_website_data_manager_new(NULL);
 | |
| +    }
 | |
| +
 | |
|      WebKitWebContext *webContext = g_object_new(WEBKIT_TYPE_WEB_CONTEXT, "website-data-manager", manager, "process-swap-on-cross-site-navigation-enabled", TRUE,
 | |
|  #if !GTK_CHECK_VERSION(3, 98, 0)
 | |
|          "use-system-appearance-for-scrollbars", FALSE,
 | |
|  #endif
 | |
|          NULL);
 | |
| +    persistentWebContext = webContext;
 | |
|      g_object_unref(manager);
 | |
|  
 | |
|      if (cookiesPolicy) {
 | |
| @@ -633,9 +689,7 @@ int main(int argc, char *argv[])
 | |
|              WebKitWebView *webView = createBrowserTab(mainWindow, webkitSettings, userContentManager);
 | |
|              if (!i)
 | |
|                  firstTab = GTK_WIDGET(webView);
 | |
| -            gchar *url = argumentToURL(uriArguments[i]);
 | |
| -            webkit_web_view_load_uri(webView, url);
 | |
| -            g_free(url);
 | |
| +            webkit_web_view_load_uri(webView, uriArguments[i]);
 | |
|          }
 | |
|      } else {
 | |
|          WebKitWebView *webView = createBrowserTab(mainWindow, webkitSettings, userContentManager);
 | |
| @@ -657,8 +711,7 @@ int main(int argc, char *argv[])
 | |
|  
 | |
|      browser_main();
 | |
|  
 | |
| -    if (privateMode)
 | |
| -        g_object_unref(webContext);
 | |
| +    g_object_unref(webContext);
 | |
|  
 | |
|      return 0;
 | |
|  }
 | |
| diff --git a/Tools/MiniBrowser/wpe/main.cpp b/Tools/MiniBrowser/wpe/main.cpp
 | |
| index a8cccb6c1d567823fe8e6503f1a137856b0a9975..afded3b4c108dbc48397bcb7653795c432877057 100644
 | |
| --- a/Tools/MiniBrowser/wpe/main.cpp
 | |
| +++ b/Tools/MiniBrowser/wpe/main.cpp
 | |
| @@ -25,7 +25,7 @@
 | |
|  
 | |
|  #include "cmakeconfig.h"
 | |
|  
 | |
| -#include "HeadlessViewBackend.h"
 | |
| +#include "NullViewBackend.h"
 | |
|  #include "WindowViewBackend.h"
 | |
|  #if ENABLE_WEB_AUDIO || ENABLE_VIDEO
 | |
|  #include <gst/gst.h>
 | |
| @@ -43,6 +43,9 @@ static gboolean headlessMode;
 | |
|  static gboolean privateMode;
 | |
|  static gboolean automationMode;
 | |
|  static gboolean ignoreTLSErrors;
 | |
| +static gboolean inspectorPipe;
 | |
| +static gboolean noStartupWindow;
 | |
| +static const char* userDataDir;
 | |
|  static const char* contentFilter;
 | |
|  static const char* cookiesFile;
 | |
|  static const char* cookiesPolicy;
 | |
| @@ -64,6 +67,9 @@ static const GOptionEntry commandLineOptions[] =
 | |
|      { "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },
 | |
|      { "bg-color", 0, 0, G_OPTION_ARG_STRING, &bgColor, "Window background color. Default: white", "COLOR" },
 | |
|      { "version", 'v', 0, G_OPTION_ARG_NONE, &printVersion, "Print the WPE version", nullptr },
 | |
| +    { "inspector-pipe", 'v', 0, G_OPTION_ARG_NONE, &inspectorPipe, "Expose remote debugging protocol over pipe", nullptr },
 | |
| +    { "user-data-dir", 0, 0, G_OPTION_ARG_STRING, &userDataDir, "Default profile persistence folder location", "FILE" },
 | |
| +    { "no-startup-window", 0, 0, G_OPTION_ARG_NONE, &noStartupWindow, "Do not open default page", nullptr },
 | |
|      { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, nullptr, "[URL]" },
 | |
|      { nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
 | |
|  };
 | |
| @@ -132,7 +138,7 @@ static gboolean decidePermissionRequest(WebKitWebView *, WebKitPermissionRequest
 | |
|  static std::unique_ptr<WPEToolingBackends::ViewBackend> createViewBackend(uint32_t width, uint32_t height)
 | |
|  {
 | |
|      if (headlessMode)
 | |
| -        return std::make_unique<WPEToolingBackends::HeadlessViewBackend>(width, height);
 | |
| +        return std::make_unique<WPEToolingBackends::NullViewBackend>();
 | |
|      return std::make_unique<WPEToolingBackends::WindowViewBackend>(width, height);
 | |
|  }
 | |
|  
 | |
| @@ -148,13 +154,34 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul
 | |
|      g_main_loop_quit(data->mainLoop);
 | |
|  }
 | |
|  
 | |
| +static gboolean webViewLoadFailed()
 | |
| +{
 | |
| +    return TRUE;
 | |
| +}
 | |
| +
 | |
|  static void webViewClose(WebKitWebView* webView, gpointer)
 | |
|  {
 | |
|      // Hash table key delete func takes care of unref'ing the view
 | |
|      g_hash_table_remove(openViews, webView);
 | |
|  }
 | |
|  
 | |
| -static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationAction*, gpointer)
 | |
| +static gboolean scriptDialog(WebKitWebView*, WebKitScriptDialog* dialog, gpointer)
 | |
| +{
 | |
| +    if (inspectorPipe)
 | |
| +        webkit_script_dialog_ref(dialog);
 | |
| +    return TRUE;
 | |
| +}
 | |
| +
 | |
| +static gboolean scriptDialogHandled(WebKitWebView*, WebKitScriptDialog* dialog, gpointer)
 | |
| +{
 | |
| +    if (inspectorPipe)
 | |
| +        webkit_script_dialog_unref(dialog);
 | |
| +    return TRUE;
 | |
| +}
 | |
| +
 | |
| +static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationAction*, gpointer);
 | |
| +
 | |
| +static WebKitWebView* createWebViewImpl(WebKitWebView* webView, WebKitWebContext *webContext)
 | |
|  {
 | |
|      auto backend = createViewBackend(1280, 720);
 | |
|      struct wpe_view_backend* wpeBackend = backend->backend();
 | |
| @@ -166,16 +193,50 @@ static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationActi
 | |
|              delete static_cast<WPEToolingBackends::ViewBackend*>(data);
 | |
|          }, backend.release());
 | |
|  
 | |
| -    auto* newWebView = webkit_web_view_new_with_related_view(viewBackend, webView);
 | |
| -    webkit_web_view_set_settings(newWebView, webkit_web_view_get_settings(webView));
 | |
| +    WebKitWebView* newWebView;
 | |
| +    if (webView) {
 | |
| +        newWebView = webkit_web_view_new_with_related_view(viewBackend, webView);
 | |
| +    } else {
 | |
| +        newWebView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
 | |
| +            "backend", viewBackend,
 | |
| +            "web-context", webContext,
 | |
| +            nullptr));
 | |
| +    }
 | |
|  
 | |
|      g_signal_connect(newWebView, "close", G_CALLBACK(webViewClose), nullptr);
 | |
|  
 | |
|      g_hash_table_add(openViews, newWebView);
 | |
|  
 | |
| +    g_signal_connect(newWebView, "load-failed", G_CALLBACK(webViewLoadFailed), nullptr);
 | |
| +    g_signal_connect(newWebView, "script-dialog", G_CALLBACK(scriptDialog), nullptr);
 | |
| +    g_signal_connect(newWebView, "script-dialog-handled", G_CALLBACK(scriptDialogHandled), nullptr);
 | |
| +    g_signal_connect(newWebView, "create", G_CALLBACK(createWebView), nullptr);
 | |
|      return newWebView;
 | |
|  }
 | |
|  
 | |
| +static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationAction*, gpointer)
 | |
| +{
 | |
| +    return createWebViewImpl(webView, nullptr);
 | |
| +}
 | |
| +
 | |
| +static WebKitWebContext *persistentWebContext = NULL;
 | |
| +
 | |
| +static WebKitWebView* createNewPage(WebKitBrowserInspector*, WebKitWebContext *webContext)
 | |
| +{
 | |
| +    if (!webContext)
 | |
| +        webContext = persistentWebContext;
 | |
| +    WebKitWebView* webView = createWebViewImpl(nullptr, webContext);
 | |
| +    webkit_web_view_load_uri(webView, "about:blank");
 | |
| +    return webView;
 | |
| +}
 | |
| +
 | |
| +static void configureBrowserInspector(GMainLoop* mainLoop)
 | |
| +{
 | |
| +    WebKitBrowserInspector* browserInspector = webkit_browser_inspector_get_default();
 | |
| +    g_signal_connect(browserInspector, "create-new-page", G_CALLBACK(createNewPage), NULL);
 | |
| +    webkit_browser_inspector_initialize_pipe(mainLoop);
 | |
| +}
 | |
| +
 | |
|  int main(int argc, char *argv[])
 | |
|  {
 | |
|  #if ENABLE_DEVELOPER_MODE
 | |
| @@ -210,6 +271,16 @@ int main(int argc, char *argv[])
 | |
|      }
 | |
|  
 | |
|      auto* loop = g_main_loop_new(nullptr, FALSE);
 | |
| +    if (inspectorPipe)
 | |
| +        configureBrowserInspector(loop);
 | |
| +
 | |
| +    openViews = g_hash_table_new_full(nullptr, nullptr, g_object_unref, nullptr);
 | |
| +
 | |
| +    if (noStartupWindow) {
 | |
| +        g_main_loop_run(loop);
 | |
| +        g_main_loop_unref(loop);
 | |
| +        return 0;
 | |
| +    }
 | |
|  
 | |
|      auto backend = createViewBackend(1280, 720);
 | |
|      struct wpe_view_backend* wpeBackend = backend->backend();
 | |
| @@ -219,7 +290,19 @@ int main(int argc, char *argv[])
 | |
|          return 1;
 | |
|      }
 | |
|  
 | |
| -    auto* webContext = (privateMode || automationMode) ? webkit_web_context_new_ephemeral() : webkit_web_context_get_default();
 | |
| +    WebKitWebsiteDataManager *manager;
 | |
| +    if (userDataDir) {
 | |
| +        manager = webkit_website_data_manager_new("base-data-directory", userDataDir, "base-cache-directory", userDataDir, NULL);
 | |
| +        cookiesFile = g_build_filename(userDataDir, "cookies.txt", NULL);
 | |
| +    } else if (inspectorPipe || privateMode || automationMode) {
 | |
| +        manager = webkit_website_data_manager_new_ephemeral();
 | |
| +    } else {
 | |
| +        manager = webkit_website_data_manager_new(NULL);
 | |
| +    }
 | |
| +
 | |
| +    WebKitWebContext *webContext = WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, "website-data-manager", manager, "process-swap-on-cross-site-navigation-enabled", TRUE, NULL));
 | |
| +    persistentWebContext = webContext;
 | |
| +    g_object_unref(manager);
 | |
|  
 | |
|      if (cookiesPolicy) {
 | |
|          auto* cookieManager = webkit_web_context_get_cookie_manager(webContext);
 | |
| @@ -300,8 +383,6 @@ int main(int argc, char *argv[])
 | |
|          backendPtr->setAccessibleChild(ATK_OBJECT(accessible));
 | |
|  #endif
 | |
|  
 | |
| -    openViews = g_hash_table_new_full(nullptr, nullptr, g_object_unref, nullptr);
 | |
| -
 | |
|      webkit_web_context_set_automation_allowed(webContext, automationMode);
 | |
|      g_signal_connect(webContext, "automation-started", G_CALLBACK(automationStartedCallback), webView);
 | |
|      g_signal_connect(webView, "permission-request", G_CALLBACK(decidePermissionRequest), nullptr);
 | |
| @@ -317,16 +398,9 @@ int main(int argc, char *argv[])
 | |
|          webkit_web_view_set_background_color(webView, &color);
 | |
|  
 | |
|      if (uriArguments) {
 | |
| -        const char* uri = uriArguments[0];
 | |
| -        if (g_str_equal(uri, "about:gpu"))
 | |
| -            uri = "webkit://gpu";
 | |
| -
 | |
| -        GFile* file = g_file_new_for_commandline_arg(uri);
 | |
| -        char* url = g_file_get_uri(file);
 | |
| -        g_object_unref(file);
 | |
| -        webkit_web_view_load_uri(webView, url);
 | |
| -        g_free(url);
 | |
| -    } else if (automationMode)
 | |
| +        // Playwright: avoid weird url transformation like http://trac.webkit.org/r240840
 | |
| +        webkit_web_view_load_uri(webView, uriArguments[0]);
 | |
| +    } else if (automationMode || inspectorPipe)
 | |
|          webkit_web_view_load_uri(webView, "about:blank");
 | |
|      else
 | |
|          webkit_web_view_load_uri(webView, "https://wpewebkit.org");
 | |
| @@ -336,8 +410,7 @@ int main(int argc, char *argv[])
 | |
|      g_hash_table_destroy(openViews);
 | |
|  
 | |
|  
 | |
| -    if (privateMode || automationMode)
 | |
| -        g_object_unref(webContext);
 | |
| +    g_object_unref(webContext);
 | |
|      g_main_loop_unref(loop);
 | |
|  
 | |
|      return 0;
 | |
| diff --git a/Tools/PlatformWin.cmake b/Tools/PlatformWin.cmake
 | |
| index 44301d5fef9c977dc0228b9de1ae75263efd9014..0c8c7e176a6e02ca04872cdd362d0a8927728557 100644
 | |
| --- a/Tools/PlatformWin.cmake
 | |
| +++ b/Tools/PlatformWin.cmake
 | |
| @@ -10,4 +10,5 @@ endif ()
 | |
|  
 | |
|  if (ENABLE_WEBKIT)
 | |
|      add_subdirectory(WebKitTestRunner)
 | |
| +    add_subdirectory(Playwright/win)
 | |
|  endif ()
 | |
| diff --git a/Tools/Scripts/build-webkit b/Tools/Scripts/build-webkit
 | |
| index 099d33a4b9b9cdf432cd1026ea6aae0cb9257a77..0d771ef83c5e53e3d1525b19aa6ccb8687e01c76 100755
 | |
| --- a/Tools/Scripts/build-webkit
 | |
| +++ b/Tools/Scripts/build-webkit
 | |
| @@ -246,7 +246,7 @@ if (isAppleCocoaWebKit()) {
 | |
|      push @projects, ("Source/WebKit");
 | |
|  
 | |
|      if (!isIOSWebKit()) {
 | |
| -        push @projects, ("Tools/MiniBrowser");
 | |
| +        push @projects, ("Tools/Playwright");
 | |
|  
 | |
|          # WebInspectorUI must come after JavaScriptCore and WebCore but before WebKit and WebKit2
 | |
|          my $webKitIndex = first { $projects[$_] eq "Source/WebKitLegacy" } 0..$#projects;
 | |
| diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp
 | |
| index 47460322c6f0cb514756faf533508925d3607149..f7a402e53cc0fff527d8b9f9abf3198906632a09 100644
 | |
| --- a/Tools/WebKitTestRunner/TestController.cpp
 | |
| +++ b/Tools/WebKitTestRunner/TestController.cpp
 | |
| @@ -730,7 +730,8 @@ void TestController::createWebViewWithOptions(const TestOptions& options)
 | |
|          0, // didResignInputElementStrongPasswordAppearance
 | |
|          0, // requestStorageAccessConfirm
 | |
|          shouldAllowDeviceOrientationAndMotionAccess,
 | |
| -        runWebAuthenticationPanel
 | |
| +        runWebAuthenticationPanel,
 | |
| +        0 // handleJavaScriptDialog
 | |
|      };
 | |
|      WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
 | |
|  
 | |
| diff --git a/Tools/WebKitTestRunner/win/EventSenderProxyWin.cpp b/Tools/WebKitTestRunner/win/EventSenderProxyWin.cpp
 | |
| index 06f19261b387ce02a44c319bd7016e824847ad24..c4e2f8f8816b06a105c18872e735ae4dbca6fe68 100644
 | |
| --- a/Tools/WebKitTestRunner/win/EventSenderProxyWin.cpp
 | |
| +++ b/Tools/WebKitTestRunner/win/EventSenderProxyWin.cpp
 | |
| @@ -312,4 +312,59 @@ void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers,
 | |
|          SetKeyboardState(keyState);
 | |
|  }
 | |
|  
 | |
| +void EventSenderProxy::addTouchPoint(int, int)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::updateTouchPoint(int, int, int)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::setTouchModifier(WKEventModifiers, bool)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::setTouchPointRadius(int, int)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::touchStart()
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::touchMove()
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::touchEnd()
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::touchCancel()
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::clearTouchPoints()
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::releaseTouchPoint(int)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
| +void EventSenderProxy::cancelTouchPoint(int)
 | |
| +{
 | |
| +    notImplemented();
 | |
| +}
 | |
| +
 | |
|  } // namespace WTR
 | |
| diff --git a/Tools/wpe/backends/CMakeLists.txt b/Tools/wpe/backends/CMakeLists.txt
 | |
| index f0f80b35cd5e72dcf763425bfdef99585ab4226a..e3f82f9a9d5d0abf27ebe5a71ee386851724f1bc 100644
 | |
| --- a/Tools/wpe/backends/CMakeLists.txt
 | |
| +++ b/Tools/wpe/backends/CMakeLists.txt
 | |
| @@ -10,6 +10,7 @@ file(MAKE_DIRECTORY ${DERIVED_SOURCES_WPETOOLINGBACKENDS_DIR})
 | |
|  set(WPEToolingBackends_SOURCES
 | |
|      ${DERIVED_SOURCES_WPETOOLINGBACKENDS_DIR}/xdg-shell-unstable-v6-protocol.c
 | |
|      ${TOOLS_DIR}/wpe/backends/HeadlessViewBackend.cpp
 | |
| +    ${TOOLS_DIR}/wpe/backends/NullViewBackend.cpp
 | |
|      ${TOOLS_DIR}/wpe/backends/ViewBackend.cpp
 | |
|      ${TOOLS_DIR}/wpe/backends/WebKitAccessibleApplication.cpp
 | |
|      ${TOOLS_DIR}/wpe/backends/WindowViewBackend.cpp
 | |
| diff --git a/Tools/wpe/backends/NullViewBackend.cpp b/Tools/wpe/backends/NullViewBackend.cpp
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..033ff802d3971a455667cd64c0e68dd10f448aa7
 | |
| --- /dev/null
 | |
| +++ b/Tools/wpe/backends/NullViewBackend.cpp
 | |
| @@ -0,0 +1,41 @@
 | |
| +/*
 | |
| + * Copyright (C) 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 APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 | |
| + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 | |
| + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | |
| + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 | |
| + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 | |
| + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 | |
| + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 | |
| + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 | |
| + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | |
| + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 | |
| + * THE POSSIBILITY OF SUCH DAMAGE.
 | |
| + */
 | |
| +
 | |
| +#include "NullViewBackend.h"
 | |
| +
 | |
| +#include <wpe/fdo-egl.h>
 | |
| +
 | |
| +namespace WPEToolingBackends {
 | |
| +
 | |
| +NullViewBackend::NullViewBackend()
 | |
| +    : ViewBackend(1, 1)
 | |
| +{
 | |
| +    static struct wpe_view_backend_exportable_fdo_egl_client exportableClient = { nullptr, nullptr, nullptr, nullptr, nullptr };
 | |
| +    m_exportable = wpe_view_backend_exportable_fdo_egl_create(&exportableClient, this, 1, 1);
 | |
| +    initializeAccessibility();
 | |
| +    addActivityState(wpe_view_activity_state_visible | wpe_view_activity_state_focused | wpe_view_activity_state_in_window);
 | |
| +}
 | |
| +
 | |
| +} // namespace WPEToolingBackends
 | |
| diff --git a/Tools/wpe/backends/NullViewBackend.h b/Tools/wpe/backends/NullViewBackend.h
 | |
| new file mode 100644
 | |
| index 0000000000000000000000000000000000000000..c4489294acfe73adcb3593f2d54a3be625307f28
 | |
| --- /dev/null
 | |
| +++ b/Tools/wpe/backends/NullViewBackend.h
 | |
| @@ -0,0 +1,46 @@
 | |
| +/*
 | |
| + * Copyright (C) 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 APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 | |
| + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 | |
| + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | |
| + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 | |
| + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 | |
| + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 | |
| + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 | |
| + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 | |
| + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | |
| + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 | |
| + * THE POSSIBILITY OF SUCH DAMAGE.
 | |
| + */
 | |
| +
 | |
| +#pragma once
 | |
| +
 | |
| +#include "ViewBackend.h"
 | |
| +#include <cairo.h>
 | |
| +#include <glib.h>
 | |
| +#include <unordered_map>
 | |
| +
 | |
| +namespace WPEToolingBackends {
 | |
| +
 | |
| +class NullViewBackend final : public ViewBackend {
 | |
| +public:
 | |
| +    NullViewBackend();
 | |
| +    virtual ~NullViewBackend() = default;
 | |
| +private:
 | |
| +    void displayBuffer(struct wpe_fdo_egl_exported_image*) override { };
 | |
| +#if WPE_FDO_CHECK_VERSION(1, 5, 0)
 | |
| +    void displayBuffer(struct wpe_fdo_shm_exported_buffer*) override { };
 | |
| +#endif
 | |
| +};
 | |
| +
 | |
| +} // namespace WPEToolingBackends
 |