summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.js')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.js
new file mode 100644
index 0000000000..58b73494e1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.js
@@ -0,0 +1,52 @@
+// META: title=Navigation to about:srcdoc, not via srcdoc="", must be blocked
+// META: script=../resources/helpers.js
+
+promise_test(async t => {
+ const iframe = await addSrcdocIframe();
+
+ iframe.contentWindow.location = "/common/blank.html";
+ await waitForIframeLoad(iframe);
+
+ iframe.contentWindow.location = "about:srcdoc";
+
+ // Fetching "about:srcdoc" should result in a network error, and navigating
+ // to a network error should produce an opaque-origin page. In particular,
+ // since the error page should end up being cross-origin to the parent
+ // frame, `contentDocument` should return `null`.
+ //
+ // If instead this results in a message because we re-loaded a srcdoc document
+ // from the contents of the srcdoc="" attribute, immediately fail.
+ await Promise.race([
+ t.step_wait(() => iframe.contentDocument === null),
+ failOnMessage(iframe.contentWindow)
+ ]);
+}, "Navigations to about:srcdoc via window.location must be blocked");
+
+promise_test(async t => {
+ const iframe = await addSrcdocIframe();
+
+ iframe.contentWindow.location = "about:srcdoc?query";
+
+ // See the documentation in the above test.
+ await Promise.race([
+ t.step_wait(() => iframe.contentDocument === null),
+ failOnMessage(iframe.contentWindow)
+ ]);
+}, "Navigations to about:srcdoc?query via window.location within an " +
+ "about:srcdoc document must be blocked");
+
+promise_test(async t => {
+ const iframe = await addSrcdocIframe();
+ iframe.contentWindow.name = "test_frame";
+
+ iframe.contentWindow.location = "/common/blank.html";
+ await waitForIframeLoad(iframe);
+
+ window.open("about:srcdoc", "test_frame");
+
+ // See the documentation in the above test.
+ await Promise.race([
+ t.step_wait(() => iframe.contentDocument === null),
+ failOnMessage(iframe.contentWindow)
+ ]);
+}, "Navigations to about:srcdoc via window.open() must be blocked");