diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-06 12:48:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:33:43 +0000 |
commit | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (patch) | |
tree | fa14ba0ca8d2683ba2efdabd246dc9b18a1229c6 /chromium/third_party/blink/renderer/core/html/portal | |
parent | 79b4f909db1049fca459c07cca55af56a9b54fe3 (diff) | |
download | qtwebengine-chromium-7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3.tar.gz |
BASELINE: Update Chromium to 84.0.4147.141
Change-Id: Ib85eb4cfa1cbe2b2b81e5022c8cad5c493969535
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/portal')
7 files changed, 42 insertions, 7 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h index 42fe448d85a..1ec5984927d 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h +++ b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h @@ -63,8 +63,8 @@ class CORE_EXPORT HTMLPortalElement : public HTMLFrameOwnerElement { const base::UnguessableToken& GetToken() const; - FrameOwnerElementType OwnerType() const override { - return FrameOwnerElementType::kPortal; + mojom::blink::FrameOwnerElementType OwnerType() const override { + return mojom::blink::FrameOwnerElementType::kPortal; } // Consumes the portal interface. When a Portal is activated, or if the diff --git a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.idl b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.idl index 088c7ff25d7..2a0d7a796b8 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.idl +++ b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.idl @@ -10,7 +10,7 @@ interface HTMLPortalElement : HTMLElement { [CEReactions, Reflect, ReflectOnly=("","no-referrer","origin","no-referrer-when-downgrade","origin-when-cross-origin","unsafe-url"), ReflectMissing="", ReflectInvalid=""] attribute DOMString referrerPolicy; [CallWith=ScriptState, RaisesException, Measure] Promise<void> activate(optional PortalActivateOptions options = {}); - [CallWith=ScriptState, RaisesException, Measure] void postMessage(any message, DOMString targetOrigin, + [CallWith=ScriptState, RaisesException, Measure] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []); [CallWith=ScriptState, RaisesException, Measure] void postMessage(any message, optional WindowPostMessageOptions options = {}); diff --git a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element_test.cc b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element_test.cc index 7cbf44baa53..c7904de4aaf 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element_test.cc +++ b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element_test.cc @@ -4,10 +4,15 @@ #include "third_party/blink/renderer/core/html/portal/html_portal_element.h" +#include "base/unguessable_token.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" +#include "mojo/public/cpp/bindings/pending_associated_remote.h" +#include "third_party/blink/public/mojom/portal/portal.mojom-blink.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" #include "third_party/blink/renderer/bindings/core/v8/v8_portal_activate_options.h" #include "third_party/blink/renderer/bindings/core/v8/v8_window_post_message_options.h" #include "third_party/blink/renderer/core/dom/document.h" +#include "third_party/blink/renderer/core/html/portal/portal_activate_event.h" #include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/inspector/console_message_storage.h" @@ -36,7 +41,8 @@ TEST_F(HTMLPortalElementTest, PortalsDisabledInDocument) { ScriptState* script_state = ToScriptStateForMainWorld(&GetFrame()); const auto& console_messages = GetPage().GetConsoleMessageStorage(); - portal->activate(script_state, MakeGarbageCollected<PortalActivateOptions>(), + portal->activate(script_state, + PortalActivateOptions::Create(script_state->GetIsolate()), exception_state); EXPECT_TRUE(exception_state.HadException()); EXPECT_EQ(DOMExceptionCode::kNotSupportedError, @@ -65,6 +71,23 @@ TEST_F(HTMLPortalElementTest, PortalsDisabledInDocument) { EXPECT_TRUE(console_messages.at(next_console_message) ->Message() .Contains("was moved to a document")); + + mojo::PendingAssociatedRemote<mojom::blink::Portal> portal_remote; + mojo::PendingAssociatedReceiver<mojom::blink::Portal> portal_receiver = + portal_remote.InitWithNewEndpointAndPassReceiver(); + + mojo::PendingAssociatedRemote<mojom::blink::PortalClient> client_remote; + mojo::PendingAssociatedReceiver<mojom::blink::PortalClient> client_receiver = + client_remote.InitWithNewEndpointAndPassReceiver(); + + auto* activate_event = PortalActivateEvent::Create( + &GetFrame(), base::UnguessableToken::Create(), std::move(portal_remote), + std::move(client_receiver), nullptr, nullptr, base::NullCallback()); + activate_event->adoptPredecessor(exception_state); + EXPECT_TRUE(exception_state.HadException()); + EXPECT_EQ(DOMExceptionCode::kNotSupportedError, + exception_state.CodeAs<DOMExceptionCode>()); + exception_state.ClearException(); } } // namespace diff --git a/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event.cc b/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event.cc index 17116bee848..2e685353655 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event.cc +++ b/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event.cc @@ -121,6 +121,13 @@ const AtomicString& PortalActivateEvent::InterfaceName() const { HTMLPortalElement* PortalActivateEvent::adoptPredecessor( ExceptionState& exception_state) { + if (!RuntimeEnabledFeatures::PortalsEnabled(document_)) { + exception_state.ThrowDOMException( + DOMExceptionCode::kNotSupportedError, + "Portals is not enabled in this document."); + return nullptr; + } + if (!predecessor_portal_) { exception_state.ThrowDOMException( DOMExceptionCode::kInvalidStateError, diff --git a/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event_init.idl b/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event_init.idl index 8aeb9a7f91a..2927f2621d4 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event_init.idl +++ b/chromium/third_party/blink/renderer/core/html/portal/portal_activate_event_init.idl @@ -5,5 +5,5 @@ // https://wicg.github.io/portals/#the-portalactivateevent-interface dictionary PortalActivateEventInit : EventInit { - any data; + any data = null; }; diff --git a/chromium/third_party/blink/renderer/core/html/portal/portal_contents.cc b/chromium/third_party/blink/renderer/core/html/portal/portal_contents.cc index 3c6dba14fce..80f1404bc48 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/portal_contents.cc +++ b/chromium/third_party/blink/renderer/core/html/portal/portal_contents.cc @@ -91,7 +91,8 @@ void PortalContents::OnActivateResponse( bool should_destroy_contents = false; switch (result) { case mojom::blink::PortalActivateResult::kPredecessorWasAdopted: - GetDocument().GetPage()->SetInsidePortal(true); + if (!GetDocument().IsContextDestroyed()) + GetDocument().GetPage()->SetInsidePortal(true); FALLTHROUGH; case mojom::blink::PortalActivateResult::kPredecessorWillUnload: activate_resolver_->Resolve(); @@ -107,6 +108,10 @@ void PortalContents::OnActivateResponse( reject(DOMExceptionCode::kInvalidStateError, "The portal was not yet ready or was blocked."); break; + case mojom::blink::PortalActivateResult::kRejectedDueToErrorInPortal: + reject(DOMExceptionCode::kInvalidStateError, + "The portal is in an error state."); + break; case mojom::blink::PortalActivateResult::kDisconnected: // Only called when |remote_portal_| is disconnected. This usually happens // when the browser/test runner is being shut down. diff --git a/chromium/third_party/blink/renderer/core/html/portal/portal_host.idl b/chromium/third_party/blink/renderer/core/html/portal/portal_host.idl index 4e2ea0c214c..df5205486cd 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/portal_host.idl +++ b/chromium/third_party/blink/renderer/core/html/portal/portal_host.idl @@ -6,7 +6,7 @@ [Exposed=Window, RuntimeEnabled=Portals] interface PortalHost : EventTarget { - [RaisesException, CallWith=ScriptState, Measure] void postMessage(any message, DOMString targetOrigin, + [RaisesException, CallWith=ScriptState, Measure] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []); [RaisesException, CallWith=ScriptState, Measure] void postMessage(any message, optional WindowPostMessageOptions options = {}); |