Truly independent web browser
LibWeb: Implement the one permitted sandboxed navigator
Andreas Kling6cd220559a9b
diff --git a/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Libraries/LibWeb/HTML/BrowsingContext.cppindex e6efb31e042..69239537b0c 100644--- a/Libraries/LibWeb/HTML/BrowsingContext.cpp+++ b/Libraries/LibWeb/HTML/BrowsingContext.cpp@@ -336,6 +336,7 @@ void BrowsingContext::visit_edges(Cell::Visitor& visitor)visitor.visit(m_window_proxy);visitor.visit(m_active_document);visitor.visit(m_opener_browsing_context_window_proxy);+ visitor.visit(m_the_one_permitted_sandboxed_navigator);}// https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-contextdiff --git a/Libraries/LibWeb/HTML/BrowsingContext.h b/Libraries/LibWeb/HTML/BrowsingContext.hindex 3834c43dc45..af68d7c5231 100644--- a/Libraries/LibWeb/HTML/BrowsingContext.h+++ b/Libraries/LibWeb/HTML/BrowsingContext.h@@ -63,10 +63,9 @@ public:Optional<u64> browsing_context_group_id() const { return m_browsing_context_group_id; }void set_browsing_context_group_id(Optional<u64> id) { m_browsing_context_group_id = id; }- void set_the_one_permitted_sandboxed_navigator(BrowsingContext const*)- {- // FIXME: Implement this- }+ // https://html.spec.whatwg.org/multipage/browsers.html#one-permitted-sandboxed-navigator+ GC::Ptr<BrowsingContext const> the_one_permitted_sandboxed_navigator() const { return m_the_one_permitted_sandboxed_navigator; }+ void set_the_one_permitted_sandboxed_navigator(BrowsingContext const* browsing_context) { m_the_one_permitted_sandboxed_navigator = browsing_context; }bool has_navigable_been_destroyed() const;@@ -112,6 +111,9 @@ private:// NB: Held as its WindowProxy, which also stands for a browsing context another process holds.GC::Ptr<WindowProxy> m_opener_browsing_context_window_proxy;+ // https://html.spec.whatwg.org/multipage/browsers.html#one-permitted-sandboxed-navigator+ GC::Ptr<BrowsingContext const> m_the_one_permitted_sandboxed_navigator;+// https://html.spec.whatwg.org/multipage/browsers.html#is-popupTokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No };diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cppindex aea3834183c..57e4acca5f9 100644--- a/Libraries/LibWeb/HTML/Navigable.cpp+++ b/Libraries/LibWeb/HTML/Navigable.cpp@@ -5,6 +5,7 @@*/#include <LibWeb/DOM/Document.h>+#include <LibWeb/HTML/BrowsingContext.h>#include <LibWeb/HTML/LocalNavigable.h>#include <LibWeb/HTML/Navigable.h>#include <LibWeb/HTML/NavigableContainer.h>@@ -284,7 +285,16 @@ bool Navigable::allowed_by_sandboxing_to_navigate(Navigable const& target, Sourc// 4. If target is a top-level traversable:if (target.is_top_level_traversable()) {- // FIXME: 1. If source is the one permitted sandboxed navigator of target, then return true.+ // 1. If source is the one permitted sandboxed navigator of target, then return true.+ // NB: The one permitted sandboxed navigator is a browsing context, so we compare the active browsing contexts.+ auto const* local_source = as_if<LocalNavigable>(source);+ auto const* local_target = as_if<LocalNavigable>(target);+ if (local_source && local_target) {+ auto source_browsing_context = const_cast<LocalNavigable&>(*local_source).active_browsing_context();+ auto target_browsing_context = const_cast<LocalNavigable&>(*local_target).active_browsing_context();+ if (source_browsing_context && target_browsing_context && target_browsing_context->the_one_permitted_sandboxed_navigator() == source_browsing_context)+ return true;+ }// 2. If sourceSnapshotParams's sandboxing flags's sandboxed navigation browsing context flag is set, then return false.if (has_flag(source_snapshot_params.sandboxing_flags, SandboxingFlagSet::SandboxedNavigation))diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex 635e209e859..ad032527b2e 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -158,6 +158,9 @@ Text/input/wpt-import/html/browsers/history/the-location-interface/location-encoText/input/wpt-import/html/webappapis/user-prompts/print-during-beforeunload.htmlText/input/wpt-import/html/webappapis/user-prompts/print-during-unload.html+; Opens a popup by a root-relative URL, which needs an HTTP origin.+Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.html+; Calls reload() on a child window's Location, which requires a shared tuple origin.Text/input/wpt-import/html/browsers/history/the-location-interface/reload_document_write.html@@ -1096,6 +1099,9 @@ Text/input/wpt-import/html/webappapis/dynamic-markup-insertion/opening-the-inputText/input/wpt-import/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/016-1.htmlText/input/wpt-import/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.htmlText/input/wpt-import/html/browsers/origin/cross-origin-objects/frame.html+Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.html+Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html+Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html; See: https://github.com/LadybirdBrowser/ladybird/issues/7931Text/input/HTML/Navigation-object-properties.htmldiff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.txtnew file mode 100644index 00000000000..0402f88361f--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Check that popups from a sandboxed iframe escape the sandbox if+ allow-popups-to-escape-sandbox is used\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.txtnew file mode 100644index 00000000000..0402f88361f--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Check that popups from a sandboxed iframe escape the sandbox if+ allow-popups-to-escape-sandbox is used\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.txtnew file mode 100644index 00000000000..0402f88361f--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Check that popups from a sandboxed iframe escape the sandbox if+ allow-popups-to-escape-sandbox is used\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.txtnew file mode 100644index 00000000000..dd5e93d225d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Check that popups from a sandboxed iframe do not escape the sandbox\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.txtnew file mode 100644index 00000000000..dd5e93d225d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Check that popups from a sandboxed iframe do not escape the sandbox\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.txtnew file mode 100644index 00000000000..dd5e93d225d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Check that popups from a sandboxed iframe do not escape the sandbox\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.txtnew file mode 100644index 00000000000..d29f4e39f31--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Popup do not inherit sandbox, because of 'allow-popups-to-escape-sandbox'. The document isn't sandboxed.\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.htmlnew file mode 100644index 00000000000..07fe2457d52--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html@@ -0,0 +1,25 @@+<!doctype html>+<meta charset=utf-8>+<title>Check that popups from a sandboxed iframe escape the sandbox if+ allow-popups-to-escape-sandbox is used</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox">+</iframe>+<script>+ var t = async_test();+ var ourOrigin;+ onmessage = t.step_func(function(e) {+ assert_equals(e.data, "hello", "This is our origin getter message");+ ourOrigin = e.origin;++ onmessage = t.step_func_done(function(e) {+ assert_equals(e.origin, "null", "It came from a sandboxed iframe");+ assert_equals(e.data.data, undefined, "Should have the right message");+ assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox");+ });++ document.querySelector("iframe").src = "iframe_sandbox_popups_helper-1.html";+ });+ postMessage("hello", "*");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.htmlnew file mode 100644index 00000000000..c61266b9179--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html@@ -0,0 +1,31 @@+<!doctype html>+<meta charset=utf-8>+<title>Check that popups from a sandboxed iframe escape the sandbox if+ allow-popups-to-escape-sandbox is used</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox">+</iframe>+<script>+ var t = async_test();+ var ourOrigin;+ onmessage = t.step_func(function(e) {+ assert_equals(e.data, "hello", "This is our origin getter message");+ ourOrigin = e.origin;++ onmessage = t.step_func_done(function(e) {+ assert_equals(e.origin, "null", "It came from a sandboxed iframe");+ assert_equals(e.data.data, undefined, "Should have the right message");+ assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox");+ });++ var iframe = document.querySelector("iframe");+ iframe.onload = function() {+ frames[0].postMessage("start", "*");+ }+ iframe.src = "iframe_sandbox_popups_helper-2.html";+ });+ addEventListener("load", function() {+ postMessage("hello", "*");+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.htmlnew file mode 100644index 00000000000..71c1323220e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html@@ -0,0 +1,25 @@+<!doctype html>+<meta charset=utf-8>+<title>Check that popups from a sandboxed iframe escape the sandbox if+ allow-popups-to-escape-sandbox is used</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox">+</iframe>+<script>+ var t = async_test();+ var ourOrigin;+ onmessage = t.step_func(function(e) {+ assert_equals(e.data, "hello", "This is our origin getter message");+ ourOrigin = e.origin;++ onmessage = t.step_func_done(function(e) {+ assert_equals(e.origin, "null", "It came from a sandboxed iframe");+ assert_equals(e.data.data, undefined, "Should have the right message");+ assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox");+ });++ document.querySelector("iframe").src = "iframe_sandbox_popups_helper-3.html";+ });+ postMessage("hello", "*");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.htmlnew file mode 100644index 00000000000..6b120f15d0d--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<script>+ if (opener) {+ // We're the popup. Send back our state. What we really want to send is+ // our origin, but that will come automatically.+ opener.postMessage(undefined, "*");+ self.close();+ } else {+ // We're the child. Start listening for messages and open ourselves as the+ // popup.+ onmessage = function (e) {+ parent.postMessage({ data: e.data, origin: e.origin }, "*");+ };+ popupWin = window.open(location.href);+ }+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.htmlnew file mode 100644index 00000000000..ea28cf53754--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<body>+<script>+ if (opener) {+ // We're the popup. Send back our state. What we really want to send is+ // our origin, but that will come automatically.+ opener.postMessage(undefined, "*");+ self.close();+ } else {+ // We're the child. Start listening for messages from our parent and open+ // ourselves as the popup when we get the "start" message.+ onmessage = function (e) {+ if (e.data == "start") {+ // Now listen for messages from the thing we plan to open.+ onmessage = function(e) {+ parent.postMessage({ data: e.data, origin: e.origin }, "*");+ }++ var a = document.createElement("a");+ a.href = location.href;+ a.target = "_blank";+ a.rel = "opener";+ document.body.appendChild(a);+ a.click();+ }+ };+ }+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.htmlnew file mode 100644index 00000000000..ef3e59037f4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html@@ -0,0 +1,17 @@+<!DOCTYPE html>+<script>+ if (opener) {+ // We're the popup. Send back our state. What we really want to send is+ // our origin, but that will come automatically.+ opener.postMessage(undefined, "*");+ self.close();+ } else {+ // We're the child. Start listening for messages and open ourselves as the+ // popup.+ onmessage = function (e) {+ parent.postMessage({ data: e.data, origin: e.origin }, "*");+ };+ var popupWin = window.open();+ popupWin.location.href = location.href;+ }+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.htmlnew file mode 100644index 00000000000..09f20f84f1c--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>+<title>Check that popups from a sandboxed iframe do not escape the sandbox</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<script>+ var t = async_test();+ onmessage = t.step_func_done(function(e) {+ assert_equals(e.origin, "null", "It came from a sandboxed iframe");+ assert_equals(e.data.data, undefined, "Should have the right message");+ assert_equals(e.data.origin, "null", "Should not have escaped the sandbox");+ });+</script>+<iframe sandbox="allow-scripts allow-popups"+ src="iframe_sandbox_popups_helper-1.html"></iframe>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.htmlnew file mode 100644index 00000000000..ab796a458fa--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html@@ -0,0 +1,18 @@+<!doctype html>+<meta charset=utf-8>+<title>Check that popups from a sandboxed iframe do not escape the sandbox</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<script>+ var t = async_test();+ onmessage = t.step_func_done(function(e) {+ assert_equals(e.origin, "null", "It came from a sandboxed iframe");+ assert_equals(e.data.data, undefined, "Should have the right message");+ assert_equals(e.data.origin, "null", "Should not have escaped the sandbox");+ });+ addEventListener("load", function() {+ frames[0].postMessage("start", "*");+ });+</script>+<iframe sandbox="allow-scripts allow-popups"+ src="iframe_sandbox_popups_helper-2.html"></iframe>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.htmlnew file mode 100644index 00000000000..36108f3cec5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>+<title>Check that popups from a sandboxed iframe do not escape the sandbox</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<script>+ var t = async_test();+ onmessage = t.step_func_done(function(e) {+ assert_equals(e.origin, "null", "It came from a sandboxed iframe");+ assert_equals(e.data.data, undefined, "Should have the right message");+ assert_equals(e.data.origin, "null", "Should not have escaped the sandbox");+ });+</script>+<iframe sandbox="allow-scripts allow-popups"+ src="iframe_sandbox_popups_helper-3.html"></iframe>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.htmlnew file mode 100644index 00000000000..f9da9cc9e54--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.html@@ -0,0 +1,87 @@+<!DOCTYPE html>+<html>+<head>+ <script src="../../../../resources/testharness.js"></script>+ <script src="../../../../resources/testharnessreport.js"></script>+</head>+<body>+<script>+ // Sandbox flags are inherited from a document toward every frame it creates,+ // which then is inherited to every new document created in this frame.+ //+ // Using the flag 'allow-popups-to-escape-sandbox' inhibits this inheritance+ // mechanism when the new frame is a popup.+ //+ // Sandbox flags are not inherited from the initiator/creator when loading a+ // local scheme document unlike CSP (tested in+ // ./sandbox-inherit-to-blank-document-unsandboxed.html)+ //+ // This tests in particular the initial empty document and the first+ // about:blank navigation and verifies that no sandbox is applied on the+ // popups.+ promise_test(async test => {+ const msg = await new Promise(r => window.addEventListener("message", r));+ assert_false(msg.data.access_initial_navigation_to_about_blank_throws,+ "Failed to access initial about:blank popup, it is probably sandboxed"+ );+ assert_false(msg.data.access_first_navigation_to_about_blank_throws,+ "Failed to access navigation to about:blank, it is probably sandboxed"+ );+ assert_false(msg.data.access_after_delay_initial_navigation_to_about_blank_throws,+ "Failed to access navigation to about:blank, it is probably sandboxed"+ );+ assert_false(msg.data.access_after_delay_first_navigation_to_about_blank_throws,+ "Failed to access navigation to about:blank, it is probably sandboxed"+ );+ }, "Popup do not inherit sandbox, because of " ++ "'allow-popups-to-escape-sandbox'. The document isn't sandboxed.")++</script>+<iframe+ sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"+ srcdoc="+ <script>+ let access_initial_navigation_to_about_blank_throws = false;+ let access_first_navigation_to_about_blank_throws = false;+ let access_after_delay_initial_navigation_to_about_blank_throws = false;+ let access_after_delay_first_navigation_to_about_blank_throws = false;+ const initial_about_blank_window =+ window.open('/common/blank.html?pipe=status(204)');+ try {+ initial_about_blank_window.origin;+ } catch(e) {+ access_initial_navigation_to_about_blank_throws = true;+ }+ const renavigated_about_blank_window = window.open('about:blank');+ try {+ renavigated_about_blank_window.origin;+ } catch(e) {+ access_first_navigation_to_about_blank_throws = true;+ }+ setTimeout(() => {+ try {+ initial_about_blank_window.origin;+ } catch(e) {+ access_after_delay_initial_navigation_to_about_blank_throws = true;+ }+ try {+ renavigated_about_blank_window.origin;+ } catch(e) {+ access_after_delay_first_navigation_to_about_blank_throws = true;+ }+ top.postMessage({+ 'access_initial_navigation_to_about_blank_throws':+ access_initial_navigation_to_about_blank_throws,+ 'access_first_navigation_to_about_blank_throws':+ access_first_navigation_to_about_blank_throws,+ 'access_after_delay_initial_navigation_to_about_blank_throws':+ access_after_delay_initial_navigation_to_about_blank_throws,+ 'access_after_delay_first_navigation_to_about_blank_throws':+ access_after_delay_first_navigation_to_about_blank_throws+ }, '*');+ }, 500);+ </script>"+>+</iframe>+</body>+</html>