Truly independent web browser
LibWeb+LibWebView: Activate ancestor and same-origin descendant frames
sideshowbarker6b0cdf21cd06
diff --git a/Libraries/LibWeb/DOM/EventTarget.cpp b/Libraries/LibWeb/DOM/EventTarget.cppindex ba981439966..6ea18182c73 100644--- a/Libraries/LibWeb/DOM/EventTarget.cpp+++ b/Libraries/LibWeb/DOM/EventTarget.cpp@@ -1149,33 +1149,17 @@ bool EventTarget::dispatch_event(Event& event)// https://html.spec.whatwg.org/multipage/interaction.html#user-activation-processing-model// When a user interaction causes firing of an activation triggering input event in a Document document,// the user agent must perform the following activation notification steps before dispatching the event:-- // FIXME: 1. Assert: document is fully active.- // FIXME: 2. Let windows be « document's relevant global object ».- // FIXME: 3. Extend windows with the active window of each of document's ancestor navigables.- // FIXME: 4. Extend windows with the active window of each of document's descendant navigables,- // filtered to include only those navigables whose active document's origin is same origin with document's origin.- // FIXME: 5. For each window in windows:- // FIXME: 5.1 Set window's last activation timestamp to the current high resolution time.- // FIXME: 5.2 Notify the close watcher manager about user activation given window.-- // FIXME: This is ad-hoc, but works for now.if (is_activation_triggering_input_event()) {- GC::Ptr<HTML::Window> window = [&]() {- if (is<HTML::Window>(this))- return GC::Ptr { static_cast<HTML::Window*>(this) };-- if (is<DOM::Element>(this))- return static_cast<DOM::Element const*>(this)->document().window();-- if (is<DOM::Document>(this))- return static_cast<DOM::Document const*>(this)->window();-- return GC::Ptr<HTML::Window> { nullptr };+ GC::Ptr<Document> document = [&]() -> GC::Ptr<Document> {+ if (auto* window = as_if<HTML::Window>(*this))+ return window->associated_document();+ if (auto* node = as_if<Node>(*this))+ return node->document();+ return nullptr;}();- if (window)- window->notify_about_user_activation();+ if (document)+ HTML::Window::run_activation_notification_steps(*document);}return EventDispatcher::dispatch(*this, event);diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cppindex bd92b8eaafb..b89bf458cbe 100644--- a/Libraries/LibWeb/HTML/Window.cpp+++ b/Libraries/LibWeb/HTML/Window.cpp@@ -919,6 +919,55 @@ void Window::notify_about_user_activation()close_watcher_manager()->notify_about_user_activation();}+// https://html.spec.whatwg.org/multipage/interaction.html#activation-notification+void Window::run_activation_notification_steps(DOM::Document& document)+{+ // 1. Assert: document is fully active.+ // AD-HOC: The spec asserts this, but we return instead — so input reaching a document as it's being torn down+ // can't crash.+ if (!document.is_fully_active())+ return;++ // 2. Let windows be « document's relevant global object ».+ // NB: That's the window of a fully active document.+ GC::RootVector<GC::Ref<Window>> windows;+ windows.append(*document.window());++ // NB: Only the windows of the navigables this page hosts are notified here, and the UI process notifies those that+ // other pages host.+ auto reaches_navigables_other_pages_host = false;+ auto active_window_of_hosted_navigable = [&](HTML::Navigable& navigable) -> GC::Ptr<Window> {+ if (auto* local_navigable = as_if<LocalNavigable>(navigable))+ return local_navigable->active_window();+ reaches_navigables_other_pages_host = true;+ return nullptr;+ };++ // 3. Extend windows with the active window of each of document's ancestor navigables.+ for (auto& ancestor : document.ancestor_navigables()) {+ if (auto window = active_window_of_hosted_navigable(ancestor))+ windows.append(*window);+ }++ // 4. Extend windows with the active window of each of document's descendant navigables, filtered to include only+ // those navigables whose active document's origin is same origin with document's origin.+ for (auto& descendant : document.descendant_navigables()) {+ auto window = active_window_of_hosted_navigable(*descendant);+ if (window && window->associated_document().origin().is_same_origin(document.origin()))+ windows.append(*window);+ }++ // 5. For each window in windows:+ for (auto& window : windows) {+ // 1. Set window's last activation timestamp to the current high resolution time.+ // 2. Notify the close watcher manager about user activation given window.+ window->notify_about_user_activation();+ }++ if (reaches_navigables_other_pages_host)+ document.page().client().page_did_notify_about_user_activation(document.id());+}+// https://html.spec.whatwg.org/multipage/interaction.html#consume-user-activationvoid Window::consume_user_activation(){diff --git a/Libraries/LibWeb/HTML/Window.h b/Libraries/LibWeb/HTML/Window.hindex 8fb64425b5b..786644ae319 100644--- a/Libraries/LibWeb/HTML/Window.h+++ b/Libraries/LibWeb/HTML/Window.h@@ -287,6 +287,7 @@ public:void set_last_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_activation_timestamp = timestamp; }void notify_about_user_activation();+ static void run_activation_notification_steps(DOM::Document&);void consume_user_activation();HighResolutionTime::DOMHighResTimeStamp last_history_action_activation_timestamp() const { return m_last_history_action_activation_timestamp; }diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.hindex b06f90a2d78..39edec0d4d9 100644--- a/Libraries/LibWeb/Page/Page.h+++ b/Libraries/LibWeb/Page/Page.h@@ -932,6 +932,7 @@ public:virtual void page_did_request_unload_check(HTML::CrossProcessId, GC::Ref<GC::Function<void(HTML::CheckIfUnloadingIsCanceledResult)>>) { VERIFY_NOT_REACHED(); }virtual void page_did_change_needs_beforeunload_check([[maybe_unused]] bool needs_beforeunload_check) { }virtual void page_did_consume_user_activation([[maybe_unused]] HTML::UserActivationConsumption consumption) { }+ virtual void page_did_notify_about_user_activation([[maybe_unused]] HTML::CrossProcessId document_id) { }virtual void request_file(FileRequest) = 0;diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cppindex d023125b241..acebd272a88 100644--- a/Libraries/LibWebView/WebContentPage.cpp+++ b/Libraries/LibWebView/WebContentPage.cpp@@ -1439,6 +1439,33 @@ void WebContentPage::did_consume_user_activation(Web::HTML::UserActivationConsum});}+// https://html.spec.whatwg.org/multipage/interaction.html#activation-notification+// NB: The renderer ran the steps for input in the document with the given ID, and notified the windows this page hosts.+// The windows of the steps that other pages host are notified here.+void WebContentPage::did_notify_about_user_activation(Web::HTML::CrossProcessId document_id)+{+ // NB: The renderer runs the steps for input the view is delivering to it, and it sends this before it reports that+ // it finished handling that input. So any other claim is a renderer handing out activation for input it never+ // got, unless automation lets it synthesize input.+ if (!WebContentClient::renderers_may_synthesize_input()) {+ auto view = traversable().view();+ if (!view.has_value() || !view->is_delivering_user_activation_to(*this))+ return;+ }++ HashTable<Web::HTML::CrossProcessId> notified_document_ids;+ CanonicalNavigable const* navigable = nullptr;+ for_each_navigable_with_a_hosted_active_document([&](CanonicalNavigable const& hosted_navigable) {+ auto hosted_document_id = hosted_navigable.active_document().id();+ notified_document_ids.set(hosted_document_id);+ if (hosted_document_id == document_id)+ navigable = &hosted_navigable;+ return IterationDecision::Continue;+ });+ if (navigable)+ navigable->run_activation_notification_steps_for_active_document(notified_document_ids);+}+void WebContentPage::webdriver_user_prompt_handling_complete(u64 request_id, Web::WebDriver::Response response){if (displays_tab())diff --git a/Libraries/LibWebView/WebContentPage.h b/Libraries/LibWebView/WebContentPage.hindex 34cb8fa1203..4cfee8c6c42 100644--- a/Libraries/LibWebView/WebContentPage.h+++ b/Libraries/LibWebView/WebContentPage.h@@ -259,6 +259,7 @@ private:Messages::WebContentClient::ConnectToStorageAreaResponse connect_to_storage_area(Web::StorageAPI::StorageEndpointType storage_endpoint, Web::HTML::EnvironmentId environment_id);virtual void did_change_needs_beforeunload_check(bool needs_beforeunload_check) override;virtual void did_consume_user_activation(Web::HTML::UserActivationConsumption consumption) override;+ virtual void did_notify_about_user_activation(Web::HTML::CrossProcessId document_id) override;virtual void webdriver_user_prompt_handling_complete(u64 request_id, Web::WebDriver::Response response) override;virtual void webdriver_did_set_current_browsing_context(u64 command_id, Web::HTML::CrossProcessId navigable_id) override;virtual void webdriver_command_complete(u64 command_id, Web::WebDriver::Response response) override;diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cppindex 88e82f01f66..21d746ee677 100644--- a/Services/WebContent/PageClient.cpp+++ b/Services/WebContent/PageClient.cpp@@ -1797,6 +1797,11 @@ void PageClient::page_did_consume_user_activation(Web::HTML::UserActivationConsuclient().async_did_consume_user_activation(m_id, consumption);}+void PageClient::page_did_notify_about_user_activation(Web::HTML::CrossProcessId document_id)+{+ client().async_did_notify_about_user_activation(m_id, document_id);+}+void PageClient::send_current_needs_beforeunload_check(){client().async_did_change_needs_beforeunload_check(m_id, page().needs_beforeunload_check());diff --git a/Services/WebContent/PageClient.h b/Services/WebContent/PageClient.hindex a6371371b1f..5a6108ae341 100644--- a/Services/WebContent/PageClient.h+++ b/Services/WebContent/PageClient.h@@ -321,6 +321,7 @@ private:virtual void page_did_close() override;virtual void page_did_change_needs_beforeunload_check(bool needs_beforeunload_check) override;virtual void page_did_consume_user_activation(Web::HTML::UserActivationConsumption) override;+ virtual void page_did_notify_about_user_activation(Web::HTML::CrossProcessId document_id) override;virtual void page_did_update_session_history_entry_navigation_api_state(Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity const& entry_identity, Web::HTML::StorageSerializationRecord const& navigation_api_state) override;virtual void page_did_update_session_history_entry_scroll_restoration_mode(Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity const& entry_identity, Web::HTML::ScrollRestorationMode scroll_restoration_mode) override;virtual void page_did_update_session_history_entry_document_state_navigable_target_name(Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity const& entry_identity, Utf16String const& navigable_target_name) override;diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipcindex a0403a7aa74..8abed7cd4a6 100644--- a/Services/WebContent/WebContentClient.ipc+++ b/Services/WebContent/WebContentClient.ipc@@ -220,6 +220,7 @@ endpoint WebContentClient routed by Web::PageId page_iddid_complete_close_preflight(Web::PageId page_id, u64 request_id, bool approved) =|did_change_needs_beforeunload_check(Web::PageId page_id, bool needs_beforeunload_check) =|did_consume_user_activation(Web::PageId page_id, Web::HTML::UserActivationConsumption consumption) =|+ did_notify_about_user_activation(Web::PageId page_id, Web::HTML::CrossProcessId document_id) =|webdriver_user_prompt_handling_complete(Web::PageId page_id, u64 request_id, Web::WebDriver::Response response) =|webdriver_did_set_current_browsing_context(Web::PageId page_id, u64 command_id, Web::HTML::CrossProcessId navigable_id) =|webdriver_command_complete(Web::PageId page_id, u64 command_id, Web::WebDriver::Response response) =|diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex c1ce7a9ae29..a95baa18ae1 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -31,6 +31,8 @@ Text/input/notifications/Text/input/wpt-import/notifications/; Their harness scripts are served from the WPT root, which a file: page cannot reach.Crash/wpt-import/permissions/+; Activation reaches same-origin descendant frames, and the files of a file: page are each an origin of their own.+Text/input/wpt-import/html/user-activation/propagation-sameorigin.html; Render-blocking tests need delayed HTTP responses and module imports.Text/input/HTML/render-blocking-resource-cancellation.htmlText/input/HTML/render-blocking-resource-load-replacement.htmldiff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/click-in-isolated-iframe-activates-its-ancestors.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/click-in-isolated-iframe-activates-its-ancestors.txtnew file mode 100644index 00000000000..3b5a9a9f00e--- /dev/null+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/click-in-isolated-iframe-activates-its-ancestors.txt@@ -0,0 +1,7 @@+Top-level document has been active before the click: false+Clicking iframe has transient activation after its click: true+Top-level document has transient activation after the iframe's click: true+Cross-site sibling iframe has been active after the iframe's click: false+WebContent#0+ iframe#0: remote WebContent#1+ iframe#1: remote WebContent#2diff --git a/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-allowed.txt b/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-allowed.txtindex bf2ddaf4366..d58a9c5d635 100644--- a/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-allowed.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-allowed.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Element ready check with enabled flag not set\ No newline at end of file+1 Pass+Pass Element ready check with enabled flag not set\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-check-fullscreen-iframe-child.txt b/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-check-fullscreen-iframe-child.txtindex f534fca107c..df066f56b9b 100644--- a/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-check-fullscreen-iframe-child.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/fullscreen/api/element-ready-check-fullscreen-iframe-child.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Element ready check for child of a fullscreen iframe\ No newline at end of file+1 Pass+Pass Element ready check for child of a fullscreen iframe\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/user-activation/propagation-sameorigin.txt b/Tests/LibWeb/Text/expected/wpt-import/html/user-activation/propagation-sameorigin.txtnew file mode 100644index 00000000000..511e75d8001--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/user-activation/propagation-sameorigin.txt@@ -0,0 +1,14 @@+Harness status: OK++Found 9 tests++9 Pass+Pass Propagation test+Pass Child1 frame initial state+Pass Child2 frame initial state+Pass Grandchild frame initial state+Pass Parent frame initial state+Pass Child2 frame final state+Pass Child1 frame final state+Pass Grand child frame final state+Pass Parent frame final state\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/click-in-isolated-iframe-activates-its-ancestors.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/click-in-isolated-iframe-activates-its-ancestors.htmlnew file mode 100644index 00000000000..28ce1933785--- /dev/null+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/click-in-isolated-iframe-activates-its-ancestors.html@@ -0,0 +1,69 @@+<!DOCTYPE html>+<script src="../../include.js"></script>+<script>+ // A click in an isolated iframe gives activation to the windows of its ancestors, which another process hosts, but+ // not to those of its cross-site siblings.+ promiseTest(async () => {+ const isolatedIframeUrl = async (name, body) => {+ const url = new URL(+ await httpTestServer().createEcho("GET", `/${name}`, {+ status: 200,+ headers: { "Content-Type": "text/html" },+ body,+ })+ );+ url.hostname = uniqueLocalhostHostname(name);+ return url;+ };++ const nextMessage = () => new Promise(resolve => window.addEventListener("message", event => resolve(event.data), { once: true }));++ const addIframe = async url => {+ const ready = nextMessage();+ const iframe = document.createElement("iframe");+ iframe.src = url;+ document.body.appendChild(iframe);+ await ready;+ return iframe;+ };++ const askIframe = async (iframe, message) => {+ const reply = nextMessage();+ iframe.contentWindow.postMessage(message, "*");+ return await reply;+ };++ const clickingIframe = await addIframe(+ await isolatedIframeUrl(+ "clicking-iframe",+ `<!DOCTYPE html><body style="margin: 0; height: 100vh"><script>+ addEventListener("click", () => parent.postMessage(navigator.userActivation.isActive, "*"));+ parent.postMessage("ready", "*");+ <\/script>`+ )+ );+ const passiveIframe = await addIframe(+ await isolatedIframeUrl(+ "passive-iframe",+ `<!DOCTYPE html><script>+ addEventListener("message", () => parent.postMessage(navigator.userActivation.hasBeenActive, "*"));+ parent.postMessage("ready", "*");+ <\/script>`+ )+ );++ println(`Top-level document has been active before the click: ${navigator.userActivation.hasBeenActive}`);+ const rect = clickingIframe.getBoundingClientRect();+ const click = nextMessage();+ internals.clickThroughUIProcess(rect.left + 10, rect.top + 10);+ println(`Clicking iframe has transient activation after its click: ${await click}`);++ // The activation reaches this process after the click, by way of the UI process.+ for (let attempts = 0; attempts < 600 && !navigator.userActivation.hasBeenActive; ++attempts)+ await new Promise(resolve => setTimeout(resolve, 25));+ println(`Top-level document has transient activation after the iframe's click: ${navigator.userActivation.isActive}`);+ println(`Cross-site sibling iframe has been active after the iframe's click: ${await askIframe(passiveIframe, "query")}`);++ println(internals.dumpSiteIsolationProcessTree().trimEnd());+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/user-activation/propagation-sameorigin.html b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/propagation-sameorigin.htmlnew file mode 100644index 00000000000..bc86d0d705c--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/propagation-sameorigin.html@@ -0,0 +1,120 @@+<!DOCTYPE html>+<html>+<head>+ <script src="../../resources/testharness.js"></script>+ <script src="../../resources/testharnessreport.js"></script>+ <script src="../../resources/testdriver.js"></script>+ <script src="../../resources/testdriver-vendor.js"></script>+ <script>+ // Frame layout:+ // top=this-file [+ // child1=child-one.html,+ // child-so=propagation-sameorigin-child.html [+ // gchild=child-two.html+ // ]+ // ]+ let propagation_test = async_test("Propagation test");++ let num_children_to_load = 3;+ let num_children_to_report = 3;++ function finishLoadPhase() {+ assert_equals(num_children_to_load, 0);++ test(() => {+ assert_false(navigator.userActivation.isActive);+ assert_false(navigator.userActivation.hasBeenActive);+ }, "Parent frame initial state");++ test_driver.click(document.getElementById("child-so"));+ }++ function finishReportPhase() {+ assert_equals(num_children_to_report, 0);++ test(() => {+ assert_true(navigator.userActivation.isActive);+ assert_true(navigator.userActivation.hasBeenActive);+ }, "Parent frame final state");++ propagation_test.done();+ }++ window.addEventListener("message", event => {+ // Test driver can send messages too...+ if (typeof event.data !== "string") return;++ var msg = JSON.parse(event.data);++ if (msg.type == 'child-one-loaded') {+ test(() => {+ assert_false(msg.isActive);+ assert_false(msg.hasBeenActive);+ }, "Child1 frame initial state");+ } else if (msg.type == 'child-sameorigin-loaded') {+ test(() => {+ assert_false(msg.isActive);+ assert_false(msg.hasBeenActive);+ }, "Child2 frame initial state");+ } else if (msg.type == 'child-two-loaded') {+ test(() => {+ assert_false(msg.isActive);+ assert_false(msg.hasBeenActive);+ }, "Grandchild frame initial state");+ } else if (msg.type == 'child-one-report') {+ // Siblings (same or cross origin) should not be activated per spec+ // Spec issue discussing: https://github.com/whatwg/html/issues/9831+ test(() => {+ assert_false(msg.isActive);+ assert_false(msg.hasBeenActive);+ }, "Child1 frame final state");+ } else if (msg.type == 'child-sameorigin-report') {+ // This msg was triggered by a user click.+ test(() => {+ assert_true(msg.isActive);+ assert_true(msg.hasBeenActive);+ }, "Child2 frame final state");++ // Ask remaining frames to report states.+ let ask_report = JSON.stringify({"type": "report"});+ frames[0].postMessage(ask_report, "*");+ frames[1].frames[0].postMessage(ask_report, "*");+ } else if (msg.type == 'child-two-report') {+ test(() => {+ assert_true(msg.isActive);+ assert_true(msg.hasBeenActive);+ }, "Grand child frame final state");+ }++ // Phase switching.+ if (msg.type.endsWith("-loaded")) {+ if (--num_children_to_load == 0)+ finishLoadPhase();+ } else if (msg.type.endsWith("-report")) {+ if (--num_children_to_report == 0)+ finishReportPhase();+ }+ });+ async function createIframes() {+ const child1 = document.createElement("iframe");+ child1.src = "resources/child-one.html";+ child1.id = "child1";+ await new Promise((resolve) => {+ child1.onload = resolve;+ document.body.appendChild(child1);+ });+ const childSO = document.createElement("iframe");+ childSO.id = "child-so";+ childSO.src = "resources/propagation-sameorigin-child.html";+ document.body.appendChild(childSO);+ }+ </script>+</head>+<body onload="createIframes()">+ <h1>User activation propagation across same-origin frame boundary</h1>+ <p>Tests that user activation propagates across same-origin frame boundary.</p>+ <ol id="instructions">+ <li>Click anywhere on the green area (child frame).+ </ol>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/child-one.html b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/child-one.htmlnew file mode 100644index 00000000000..96683726206--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/child-one.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<body style="background: yellow;">+ <script>+ window.top.postMessage(JSON.stringify({+ "type": "child-one-loaded",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");++ window.addEventListener("click", event => {+ window.top.postMessage(JSON.stringify({+ "type": "child-one-clicked",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");+ });++ window.addEventListener("message", event => {+ var msg = JSON.parse(event.data);+ if (msg.type == "report") {+ window.top.postMessage(JSON.stringify({+ "type": "child-one-report",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");+ }+ });+ </script>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/child-two.html b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/child-two.htmlnew file mode 100644index 00000000000..9fb68dbd515--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/child-two.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<body style="background: lightgrey;">+ <script>+ window.top.postMessage(JSON.stringify({+ "type": "child-two-loaded",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");++ window.addEventListener("click", event => {+ window.top.postMessage(JSON.stringify({+ "type": "child-two-clicked",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");+ });++ window.addEventListener("message", event => {+ var msg = JSON.parse(event.data);+ if (msg.type == "report") {+ window.top.postMessage(JSON.stringify({+ "type": "child-two-report",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");+ }+ });+ </script>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/propagation-sameorigin-child.html b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/propagation-sameorigin-child.htmlnew file mode 100644index 00000000000..69ad50cb717--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/user-activation/resources/propagation-sameorigin-child.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html>+<head>+ <script>+ window.top.postMessage(JSON.stringify({+ "type": "child-sameorigin-loaded",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");++ window.addEventListener("click", event => {+ window.top.postMessage(JSON.stringify({+ "type": "child-sameorigin-report",+ "isActive": navigator.userActivation.isActive,+ "hasBeenActive": navigator.userActivation.hasBeenActive+ }), "*");+ });+ </script>+</head>+<body style="background: lightgreen;">+ <!-- The midpoint of this frame should be outside the grandchild frame. -->+ <div style="height: 75px;">Same-origin child frame</div>+ <iframe id="child2" width="270px" height="30px"+ src="child-two.html">+ </iframe>+</body>+</html>