Bug 1577055 [wpt PR 18714] - [revert] Allow about:srcdoc{#foo,?bar}, a=testonly
authorarthursonzogni <arthursonzogni@chromium.org>
Mon, 02 Sep 2019 12:31:24 +0000
changeset 491499 857c2cbc8f3d78eda59ff65928d96f834c144a6c
parent 491498 0d7b80677817bf54e623b0862823eca2cf770f11
child 491500 76ce92753ee9a15ba12b454f91825d45f06e3635
push id36529
push useraiakab@mozilla.com
push dateTue, 03 Sep 2019 21:56:23 +0000
treeherdermozilla-central@fd891e83a7cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1577055, 18714, 1663421, 996044, 996725, 1773263, 691275
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1577055 [wpt PR 18714] - [revert] Allow about:srcdoc{#foo,?bar}, a=testonly Automatic update from web-platform-tests [revert] Allow about:srcdoc{#foo,?bar} As a defensive measure, navigation to about:srcdoc#foo and about:srcdoc? were disallowed by: https://chromium-review.googlesource.com/c/chromium/src/+/1663421 The assumption were wrong. It is totally possible to make a same-document navigation into about:srcdoc. This CL reverts parts of the previous CL. Bug: 996044, 996725 Change-Id: I53ac8efa9ec7f0adb4cecc85163b8d037497c0e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773263 Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org> Reviewed-by: Nasko Oskov <nasko@chromium.org> Cr-Commit-Position: refs/heads/master@{#691275} -- wpt-commits: 5203de17db18ce59f48dec42a45b7854e63267e2 wpt-pr: 18714
testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc_change_hash.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc_change_hash.html
@@ -0,0 +1,73 @@
+<!--
+  Test same-document navigation inside an srcdoc iframe using location.hash
+-->
+<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>
+  async function test() {
+    // Wait until 'document' is available.
+    await new Promise(resolve => window.addEventListener('load', resolve));
+
+    // Create an iframe, wait until is is loaded.
+    let iframe = document.createElement('iframe');
+    await new Promise(resolve => {
+      iframe.srcdoc = "srcdoc document";
+      iframe.onload = resolve;
+      document.body.appendChild(iframe);
+    });
+
+    assert_equals(iframe.contentDocument.body.innerText, "srcdoc document");
+    assert_equals(iframe.contentWindow.location.href, "about:srcdoc");
+
+    function iframeHashChanged() {
+      return new Promise(resolve => {
+        iframe.contentWindow.onhashchange = resolve;
+      })
+    }
+
+    // 1) hash = "1".
+    {
+      let hash_changed = iframeHashChanged();
+      await test_driver.bless("hash = '1'", () => {
+        iframe.contentWindow.location.hash = "1";
+      });
+      await hash_changed;
+      assert_equals(iframe.contentWindow.location.href, "about:srcdoc#1");
+    }
+
+    // 2) hash = "2".
+    {
+      let hash_changed = iframeHashChanged();
+      await test_driver.bless("hash = '2'", () => {
+        iframe.contentWindow.location.hash = "2";
+      });
+      await hash_changed;
+      assert_equals(iframe.contentWindow.location.href, "about:srcdoc#2");
+    }
+
+    // 3) history.back().
+    {
+      let hash_changed = iframeHashChanged();
+      await test_driver.bless("history.back()", () => {
+        history.back();
+      });
+      await hash_changed;
+      assert_equals(iframe.contentWindow.location.href, "about:srcdoc#1");
+    }
+
+    // 4) history.forward().
+    {
+      let hash_changed = iframeHashChanged();
+      await test_driver.bless("history.forward()", () => {
+        history.forward();
+      });
+      await hash_changed;
+      assert_equals(iframe.contentWindow.location.href, "about:srcdoc#2");
+    }
+
+    done();
+  }
+  test();
+</script>