Bug 1735858 [wpt PR 31247] - App history: make it mostly nonfunctional for opaque...
[gecko.git] / testing / web-platform / tests / serial / serial-disabled-by-feature-policy.https.sub.html
blobcddf157e8ae5a9dc53ce2b5ad9bf499c61b0db04
1 <!DOCTYPE html>
2 <body>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="/feature-policy/resources/featurepolicy.js"></script>
6 <script>
7 'use strict';
8 const sub = 'https://{{domains[www]}}:{{ports[https][0]}}';
9 const same_origin_src = '/feature-policy/resources/feature-policy-serial.html';
10 const cross_origin_src = sub + same_origin_src;
11 const same_origin_worker_frame_src =
12 '/feature-policy/resources/feature-policy-serial-worker.html';
13 const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;
14 const header = 'Feature-Policy header {"serial" : []}';
16 promise_test(() => {
17 return navigator.serial.getPorts().then(() => {
18 assert_unreached('expected promise to reject with SecurityError');
19 }, error => {
20 assert_equals(error.name, 'SecurityError');
21 });
22 }, header + ' disallows getPorts in the top-level document.');
24 async_test(t => {
25 test_feature_availability('serial.getPorts()', t, same_origin_src,
26 expect_feature_unavailable_default);
27 }, header + ' disallows same-origin iframes.');
29 async_test(t => {
30 test_feature_availability('serial.getPorts()', t, same_origin_worker_frame_src,
31 expect_feature_unavailable_default);
32 }, header + ' disallows workers in same-origin iframes.');
34 async_test(t => {
35 test_feature_availability('serial.getPorts()', t, cross_origin_src,
36 expect_feature_unavailable_default);
37 }, header + ' disallows cross-origin iframes.');
39 async_test(t => {
40 test_feature_availability('serial.getPorts()', t,
41 cross_origin_worker_frame_src,
42 expect_feature_unavailable_default);
43 }, header + ' disallows workers in cross-origin iframes.');
45 fetch_tests_from_worker(new Worker(
46 'resources/serial-disabled-by-feature-policy-worker.js'));
47 </script>
48 </body>