Bug 1498667 [wpt PR 13484] - [Picture-in-Picture] Bail early for feature policy tests, a=testonly
authorFrançois Beaufort <beaufort.francois@gmail.com>
Tue, 16 Oct 2018 09:58:35 +0000
changeset 500228 2d2ea440e7749a33485f0c3d4a43c21609a5d087
parent 500227 a014420e5071871c7537c3b4fe56b555702552ce
child 500229 6a1c2ae13ec5607eec77be4260e58f99f042fc2c
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1498667, 13484, 1278786, 599253
milestone64.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 1498667 [wpt PR 13484] - [Picture-in-Picture] Bail early for feature policy tests, a=testonly Automatic update from web-platform-tests[Picture-in-Picture] Bail early for feature policy tests Change-Id: I0186fd20fc1d1e763208f5488917b65d24fa3e00 Reviewed-on: https://chromium-review.googlesource.com/c/1278786 Reviewed-by: Mounir Lamouri <mlamouri@chromium.org> Commit-Queue: Fran├žois Beaufort <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/master@{#599253} -- wpt-commits: 433fc8986e3dbad91f7d3e3fe0271488ba146504 wpt-pr: 13484
testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html
testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy-attribute.https.sub.html
testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy.https.sub.html
testing/web-platform/tests/feature-policy/picture-in-picture-default-feature-policy.https.sub.html
testing/web-platform/tests/feature-policy/picture-in-picture-disabled-by-feature-policy.https.sub.html
testing/web-platform/tests/feature-policy/reporting/picture-in-picture-reporting.html
testing/web-platform/tests/feature-policy/resources/picture-in-picture.js
--- a/testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html
@@ -11,21 +11,21 @@
   'use strict';
   const relative_path = '/feature-policy/resources/feature-policy-picture-in-picture.html';
   const base_src = '/feature-policy/resources/redirect-on-load.html#';
   const same_origin_src = base_src + relative_path;
   const cross_origin_src = base_src + 'https://{{domains[www]}}:{{ports[https][0]}}' +
     relative_path;
   const header = 'Feature-Policy allow="picture-in-picture"';
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability(
         'picture-in-picture', t, same_origin_src,
         expect_feature_available_default, 'picture-in-picture');
   }, header + ' allows same-origin navigation in an iframe.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability(
         'picture-in-picture', t, cross_origin_src,
         expect_feature_unavailable_default, 'picture-in-picture');
   }, header + ' disallows cross-origin navigation in an iframe.');
   </script>
 </body>
--- a/testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy-attribute.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy-attribute.https.sub.html
@@ -10,21 +10,21 @@
   <script>
   'use strict';
   const same_origin_src = '/feature-policy/resources/feature-policy-picture-in-picture.html';
   const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
     same_origin_src;
   const feature_name = 'Feature policy "picture-in-picture"';
   const header = 'allow="picture-in-picture" attribute';
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability(
         'picture-in-picture', t, same_origin_src,
         expect_feature_available_default, 'picture-in-picture');
   }, feature_name + ' can be enabled in same-origin iframe using ' + header);
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability(
         'picture-in-picture', t, cross_origin_src,
         expect_feature_available_default, 'picture-in-picture');
   }, feature_name + ' can be enabled in cross-origin iframe using ' + header);
   </script>
 </body>
--- a/testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/picture-in-picture-allowed-by-feature-policy.https.sub.html
@@ -9,25 +9,25 @@
   <script src=/feature-policy/resources/picture-in-picture.js></script>
   <script>
   'use strict';
   const same_origin_src = '/feature-policy/resources/feature-policy-picture-in-picture.html';
   const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
     same_origin_src;
   const header = 'Feature-Policy header: picture-in-picture *';
 
-  async_test(t => {
+  async_pip_test(t => {
     isPictureInPictureAllowed().then(t.step_func_done((result) => {
       assert_true(result);
     }));
   }, header + ' allows the top-level document.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability('picture-in-picture', t, same_origin_src,
         expect_feature_available_default);
   }, header + ' allows same-origin iframes.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability('picture-in-picture', t, cross_origin_src,
         expect_feature_available_default);
   }, header + ' allows cross-origin iframes.');
   </script>
 </body>
--- a/testing/web-platform/tests/feature-policy/picture-in-picture-default-feature-policy.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/picture-in-picture-default-feature-policy.https.sub.html
@@ -9,26 +9,26 @@
   <script src=/feature-policy/resources/picture-in-picture.js></script>
   <script>
   'use strict';
   const same_origin_src = '/feature-policy/resources/feature-policy-picture-in-picture.html';
   const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
     same_origin_src;
   const header = 'Default "picture-in-picture" feature policy [*]';
 
-  async_test(t => {
+  async_pip_test(t => {
     isPictureInPictureAllowed().then(t.step_func_done((result) => {
       assert_true(result);
     }));
   }, header + ' allows the top-level document.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability('picture-in-picture', t, same_origin_src,
         expect_feature_available_default);
   }, header + ' allows same-origin iframes.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability('picture-in-picture', t, cross_origin_src,
         expect_feature_available_default);
   }, header + ' allows cross-origin iframes.');
 
   </script>
 </body>
--- a/testing/web-platform/tests/feature-policy/picture-in-picture-disabled-by-feature-policy.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/picture-in-picture-disabled-by-feature-policy.https.sub.html
@@ -9,25 +9,25 @@
   <script src=/feature-policy/resources/picture-in-picture.js></script>
   <script>
   'use strict';
   const same_origin_src = '/feature-policy/resources/feature-policy-picture-in-picture.html';
   const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
     same_origin_src;
   const header = 'Feature-Policy header: picture-in-picture "none"';
 
-  async_test(t => {
+  async_pip_test(t => {
     isPictureInPictureAllowed().then(t.step_func_done((result) => {
       assert_false(result);
     }));
   }, header + ' disallows the top-level document.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability('picture-in-picture', t, same_origin_src,
         expect_feature_unavailable_default);
   }, header + ' disallows same-origin iframes.');
 
-  async_test(t => {
+  async_pip_test(t => {
     test_feature_availability('picture-in-picture', t, cross_origin_src,
         expect_feature_unavailable_default);
   }, header + ' disallows cross-origin iframes.');
   </script>
 </body>
--- a/testing/web-platform/tests/feature-policy/reporting/picture-in-picture-reporting.html
+++ b/testing/web-platform/tests/feature-policy/reporting/picture-in-picture-reporting.html
@@ -1,16 +1,17 @@
 <!DOCTYPE html>
 <html>
   <head>
     <script src='/common/media.js'></script>
     <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 src='../resources/picture-in-picture.js'></script>
   </head>
   <body>
     <script>
 const check_report_format = (reports, observer) => {
   const report = reports[0];
   assert_equals(report.type, "feature-policy");
   assert_equals(report.url, document.location.href);
   assert_equals(report.body.feature, "picture-in-picture");
@@ -23,17 +24,17 @@ const check_report_format = (reports, ob
 const loadVideo = () => new Promise(resolve => {
     const video = document.createElement('video');
     video.src = getVideoURI('/media/movie_5');
     video.addEventListener('loadedmetadata', () => {
       resolve(video);
     }, { once: true });
 });
 
-promise_test(async (t) => {
+promise_pip_test(async (t) => {
   const report = new Promise(resolve => {
     new ReportingObserver((reports, observer) => resolve([reports, observer]),
                           {types: ['feature-policy']}).observe();
   });
   const videoElement = await loadVideo();
   await test_driver.bless('picture-in-picture');
   await promise_rejects(t, 'SecurityError', videoElement.requestPictureInPicture(),
                         "Picture-in-Picture should not be allowed in this document.");
--- a/testing/web-platform/tests/feature-policy/resources/picture-in-picture.js
+++ b/testing/web-platform/tests/feature-policy/resources/picture-in-picture.js
@@ -1,12 +1,23 @@
+function async_pip_test(func, name) {
+  async_test(t => {
+    assert_true('pictureInPictureEnabled' in document, 'Picture-in-Picture API is available');
+    func(t);
+  }, name);
+}
+
+function promise_pip_test(func, name) {
+  promise_test(async t => {
+    assert_true('pictureInPictureEnabled' in document, 'Picture-in-Picture API is available');
+    return func(t);
+  }, name);
+}
+
 function isPictureInPictureAllowed() {
-  if (!('pictureInPictureEnabled' in document))
-    return Promise.resolve(false);
-
   return new Promise(resolve => {
     let video = document.createElement('video');
     video.src = getVideoURI('/media/movie_5');
     video.onloadedmetadata = () => {
       video.requestPictureInPicture()
       .then(() => resolve(document.pictureInPictureEnabled))
       .catch(e => {
         if (e.name == 'NotAllowedError')