Bug 1460913 [wpt PR 10966] - Update Web Platform Tests for Feature Policy integration into HTML spec., a=testonly
authorIan Clelland <iclelland@chromium.org>
Fri, 06 Jul 2018 22:05:30 +0000
changeset 426020 23bb787a27bbdcc0ff40bf08c13f13e3ea337423
parent 426019 229c1b848822f2e628b764be618dab5ff5e33065
child 426021 6e735175b92d02a0b87ae8cc15ea49516adc2719
push id34267
push userrgurzau@mozilla.com
push dateWed, 11 Jul 2018 22:05:21 +0000
treeherdermozilla-central@3aca103e4915 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1460913, 10966, 1053106, 569778
milestone63.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 1460913 [wpt PR 10966] - Update Web Platform Tests for Feature Policy integration into HTML spec., a=testonly Automatic update from web-platform-testsUpdate Web Platform Tests for Feature Policy integration into HTML spec. Change-Id: Ibfcc3e8bc217aff8782d2aec4c1b73bb4a193e1e Reviewed-on: https://chromium-review.googlesource.com/1053106 Commit-Queue: Ian Clelland <iclelland@chromium.org> Reviewed-by: Philip J├Ągenstedt <foolip@chromium.org> Cr-Commit-Position: refs/heads/master@{#569778} -- wpt-commits: a5facbd6fb610d896eabffbebb45da59edfbff13 wpt-pr: 10966
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allow.html
testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -346770,16 +346770,22 @@
     ]
    ],
    "html/semantics/embedded-content/the-iframe-element/historical.html": [
     [
      "/html/semantics/embedded-content/the-iframe-element/historical.html",
      {}
     ]
    ],
+   "html/semantics/embedded-content/the-iframe-element/iframe-allow.html": [
+    [
+     "/html/semantics/embedded-content/the-iframe-element/iframe-allow.html",
+     {}
+    ]
+   ],
    "html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html": [
     [
      "/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html",
      {}
     ]
    ],
    "html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html": [
     [
@@ -585541,18 +585547,22 @@
   "html/semantics/embedded-content/the-iframe-element/document-getters-return-null-for-cross-origin.html": [
    "87392a410d9ce76febe6ea3f5b2e15568e457b1a",
    "testharness"
   ],
   "html/semantics/embedded-content/the-iframe-element/historical.html": [
    "cf6e961b764d5c6e7e1289f3db988fe94efaf030",
    "testharness"
   ],
+  "html/semantics/embedded-content/the-iframe-element/iframe-allow.html": [
+   "5355ec5b17bfdd57d961c6827b0a590ecca233fc",
+   "testharness"
+  ],
   "html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html": [
-   "70a1607f74e1550681a4b7b589f7a41db9174e7a",
+   "42d4ae046daa9080bd945de796e769c37ffe335c",
    "testharness"
   ],
   "html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html": [
    "a732337b181e924195a53b586a1cae849dc504ef",
    "testharness"
   ],
   "html/semantics/embedded-content/the-iframe-element/iframe-load-event.html": [
    "d45f7b847e30fe8e3c2e03ef838b55d11ef4592f",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allow.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Check processing of allow attribute in nested browsing context</title>
+<link rel="author" title="Google" href="https://www.google.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-allow">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#initialise-the-document-object">
+<link rel="help" href="https://fullscreen.spec.whatwg.org/#fullscreen-enabled-flag">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+<script>
+  // This returns a data URL (cross-origin with the containing document) which
+  // advances a counter, and reports the counter value together with the
+  // document's fullscreenEnabled state, every time it receives a postMessage.
+  // Fullscreen itself is not important for this test, but the flag is a useful
+  // indicator of whether a policy-controlled-feature is allowed or denied.
+  function getSourceForCrossOriginPage(initial_count) {
+    var page_contents = "<html><body><script>var count="+initial_count+";window.addEventListener('message',function(){parent.postMessage({'count':count++,'fullscreenEnabled':document.fullscreenEnabled},'*');});</scr"+"ipt></body></html>";
+    return "data:text/html;base64,"+btoa(page_contents);
+  }
+
+  async_test(function(t) {
+    var iframe = document.createElement("iframe");
+    iframe.src = getSourceForCrossOriginPage(0);
+
+    iframe.addEventListener('load', function() {
+      // Request the fullscreenEnabled state whenever the frame loads
+      iframe.contentWindow.postMessage(true,"*");
+    });
+
+    window.addEventListener('message', this.step_func(function(msg) {
+      if (msg.data.count == 0) {
+        assert_false(msg.data.fullscreenEnabled, "Document inside cross-origin iframe without allow attribute should not have feature enabled");
+        iframe.setAttribute("allow", "fullscreen");
+        iframe.contentWindow.postMessage(true,"*"); // Request state again
+      } else if (msg.data.count == 1) {
+        assert_false(msg.data.fullscreenEnabled, "Feature should be denied when correct allow attribute is added, before reload");
+        iframe.src = getSourceForCrossOriginPage(2); // Reload the frame
+      } else if (msg.data.count == 2) {
+        assert_true(msg.data.fullscreenEnabled, "Feature should be allowed when correct allow attribute is added, after reload");
+        iframe.removeAttribute("allow");
+        iframe.contentWindow.postMessage(true,"*"); // Request state again
+      } else if (msg.data.count == 3) {
+        assert_true(msg.data.fullscreenEnabled, "Feature should be allowed when allow attribute is removed, before reload");
+        iframe.src = getSourceForCrossOriginPage(4); // Reload the frame
+      } else if (msg.data.count == 4) {
+        assert_false(msg.data.fullscreenEnabled, "Feature should be denied when allow attribute is removed, after reload");
+        iframe.setAttribute("allow", "payment");  // Set allow to an unrelated feature
+        iframe.src = getSourceForCrossOriginPage(5); // Reload the frame
+      } else if (msg.data.count == 5) {
+        assert_false(msg.data.fullscreenEnabled, "Feature should be denied with incorrect allow attribute");
+        iframe.setAttribute("allow", "payment;fullscreen");  // Include fullscreen again
+        iframe.src = getSourceForCrossOriginPage(6); // Reload the frame
+      } else if (msg.data.count == 6) {
+        assert_true(msg.data.fullscreenEnabled, "Feature should be allowed with complex allow attribute");
+        t.done();
+      } else {
+        assert_unreached();
+      }
+    }));
+
+    document.body.appendChild(iframe);
+  }, "iframe-cross-origin-allow");
+
+</script>
--- a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html
@@ -1,52 +1,92 @@
 <!doctype html>
 <meta charset=utf-8>
 <title>Check how allowfullscreen affects fullscreen enabled flag</title>
 <link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
 <link rel="author" title="Mozilla" href="https://www.mozilla.org">
-<link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#initialise-the-document-object">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#initialise-the-document-object">
 <link rel="help" href="https://fullscreen.spec.whatwg.org/#fullscreen-enabled-flag">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 <script>
+  // This returns a data URL (cross-origin with the containing document) which
+  // advances a counter, and reports the counter value together with the
+  // document's fullscreenEnabled state, every time it receives a postMessage.
+  function getSourceForCrossOriginPage(initial_count) {
+    var page_contents = "<html><body><script>var count="+initial_count+";window.addEventListener('message',function(){parent.postMessage({'count':count++,'fullscreenEnabled':document.fullscreenEnabled},'*');});</scr"+"ipt></body></html>";
+    return "data:text/html;base64,"+btoa(page_contents);
+  }
+
   async_test(function(t) {
     var iframe = document.createElement("iframe");
     iframe.src = "support/blank.htm";
     var eventWatcher = new EventWatcher(t, iframe, "load");
     document.body.appendChild(iframe);
     t.add_cleanup(function() {
       document.body.removeChild(iframe);
     });
 
     assert_true(document.fullscreenEnabled, "Top level document has fullscreen enabled flag set");
     eventWatcher.wait_for("load").then(t.step_func_done(function() {
-      assert_false(iframe.contentDocument.fullscreenEnabled, "Document inside iframe without allowfullscreen attribute should not have fullscreen enabled flag set");
-      iframe.setAttribute("allowfullscreen", true);
-      assert_true(iframe.contentDocument.fullscreenEnabled, "Fullscreen should be allowed when allowfullscreen attribute is set");
-      iframe.removeAttribute("allowfullscreen");
-      assert_false(iframe.contentDocument.fullscreenEnabled, "Fullscreen should be denied when allowfullscreen attribute is removed");
+      assert_true(iframe.contentDocument.fullscreenEnabled, "Document inside same-origin iframe without allowfullscreen attribute should still have fullscreen enabled flag set");
     }));
-  }, "iframe-allowfullscreen");
+  }, "iframe-same-origin-allowfullscreen");
+
+  async_test(function(t) {
+    var iframe = document.createElement("iframe");
+    iframe.src = getSourceForCrossOriginPage(0);
+
+    iframe.addEventListener('load', function() {
+      // Request the fullscreenEnabled state whenever the frame loads
+      iframe.contentWindow.postMessage(true,"*");
+    });
+
+    window.addEventListener('message', this.step_func(function(msg) {
+      if (msg.data.count == 0) {
+        assert_false(msg.data.fullscreenEnabled, "Document inside cross-origin iframe without allowfullscreen attribute should not have fullscreen enabled flag set");
+        iframe.setAttribute("allowfullscreen", "");
+        iframe.contentWindow.postMessage(true,"*"); // Request state again
+      } else if (msg.data.count == 1) {
+        assert_false(msg.data.fullscreenEnabled, "Fullscreen should be denied when allowfullscreen attribute is added, before reload");
+        iframe.src = getSourceForCrossOriginPage(2); // Reload the frame
+      } else if (msg.data.count == 2) {
+        assert_true(msg.data.fullscreenEnabled, "Fullscreen should be allowed when allowfullscreen attribute is added, after reload");
+        iframe.removeAttribute("allowfullscreen");
+        iframe.contentWindow.postMessage(true,"*"); // Request state again
+      } else if (msg.data.count == 3) {
+        assert_true(msg.data.fullscreenEnabled, "Fullscreen should be allowed when allowfullscreen attribute is removed, before reload");
+        iframe.src = getSourceForCrossOriginPage(4); // Reload the frame
+      } else if (msg.data.count == 4) {
+        assert_false(msg.data.fullscreenEnabled, "Fullscreen should be denied when allowfullscreen attribute is removed, after reload");
+        t.done();
+      }
+    }));
+
+    document.body.appendChild(iframe);
+    t.add_cleanup(function() {
+      document.body.removeChild(iframe);
+    });
+  }, "iframe-cross-origin-allowfullscreen");
 
   /* Fullscreen enabled flag with about:blank */
 
   function test_allowfullscreen_noload(setup_iframe, check) {
     var iframe = document.createElement("iframe");
     setup_iframe(iframe);
     document.body.appendChild(iframe);
     check(iframe.contentDocument);
     document.body.removeChild(iframe);
   }
 
   test(function() {
     test_allowfullscreen_noload(function() {}, function(doc) {
-      assert_false(doc.fullscreenEnabled, "Fullscreen should not be enabled without allowfullscreen attribute");
+      assert_true(doc.fullscreenEnabled, "Fullscreen should still be enabled in same-origin document without allowfullscreen attribute");
     });
   }, "iframe-noload-noallowfullscreen");
 
   test(function() {
     test_allowfullscreen_noload(function(iframe) {
       iframe.setAttribute("allowfullscreen", true);
     }, function(doc) {
       assert_true(doc.fullscreenEnabled, "Fullscreen should be enabled with allowfullscreen attribute");