|
5 | 5 | <script src=/feature-policy/resources/featurepolicy.js></script>
|
6 | 6 | <script>
|
7 | 7 | 'use strict';
|
8 |
| -var relative_path = '/feature-policy/resources/feature-policy-usb.html'; |
9 |
| -var base_src = '/feature-policy/resources/redirect-on-load.html#'; |
10 |
| -var same_origin_src = base_src + relative_path; |
11 |
| -var cross_origin_src = base_src + 'https://{{domains[www]}}:{{ports[https][0]}}' + |
12 |
| - relative_path; |
13 |
| -var header = 'Feature-Policy allow="usb"'; |
| 8 | +const relative_path = '/feature-policy/resources/feature-policy-usb.html'; |
| 9 | +const base_src = '/feature-policy/resources/redirect-on-load.html#'; |
| 10 | +const relative_worker_frame_path = |
| 11 | + '/feature-policy/resources/feature-policy-usb-worker.html'; |
| 12 | +const sub = 'https://{{domains[www]}}:{{ports[https][0]}}'; |
| 13 | +const same_origin_src = base_src + relative_path; |
| 14 | +const cross_origin_src = base_src + sub + relative_path; |
| 15 | +const same_origin_worker_frame_src = base_src + relative_worker_frame_path; |
| 16 | +const cross_origin_worker_frame_src = base_src + sub + |
| 17 | + relative_worker_frame_path; |
| 18 | +const header = 'Feature-Policy allow="usb"'; |
14 | 19 |
|
15 | 20 | async_test(t => {
|
16 | 21 | test_feature_availability(
|
17 | 22 | 'usb.getDevices()', t, same_origin_src,
|
18 | 23 | expect_feature_available_default, 'usb');
|
19 | 24 | }, header + ' allows same-origin relocation.');
|
20 | 25 |
|
| 26 | +async_test(t => { |
| 27 | + test_feature_availability( |
| 28 | + 'usb.getDevices()', t, same_origin_worker_frame_src, |
| 29 | + expect_feature_available_default, 'usb'); |
| 30 | +}, header + ' allows workers in same-origin relocation.'); |
| 31 | + |
21 | 32 | async_test(t => {
|
22 | 33 | test_feature_availability(
|
23 | 34 | 'usb.getDevices()', t, cross_origin_src,
|
24 | 35 | expect_feature_unavailable_default, 'usb');
|
25 | 36 | }, header + ' disallows cross-origin relocation.');
|
| 37 | + |
| 38 | +async_test(t => { |
| 39 | + test_feature_availability( |
| 40 | + 'usb.getDevices()', t, cross_origin_worker_frame_src, |
| 41 | + expect_feature_unavailable_default, 'usb'); |
| 42 | +}, header + ' disallows workers in cross-origin relocation.'); |
26 | 43 | </script>
|
27 | 44 | </body>
|
0 commit comments