OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
4 <iframe src="about:blank" allow="fullscreen"></iframe> | |
5 <iframe src="about:blank" allow="fullscreen" allowfullscreen></iframe> | |
6 <iframe src="about:blank" allowfullscreen></iframe> | |
4 <script> | 7 <script> |
5 if (window.testRunner) { | 8 var srcs = [ |
6 testRunner.dumpAsText(); | 9 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html ", |
7 testRunner.dumpAsText(); | 10 "resources/feature-policy-fullscreen-relocate.html" |
8 } | 11 ]; |
9 </script> | 12 |
10 <iframe id="f1" src="about:blank" allow="fullscreen"></iframe> | 13 function loadFrame(iframe, src) { |
11 <iframe id="f2" src="about:blank" allow="fullscreen" allowfullscreen></iframe> | 14 var allowfullscreen = iframe.allowFullscreen; |
iclelland
2017/05/18 19:56:59
allowfullscreen => allowFullscreen
| |
12 <iframe id="f3" src="about:blank" allowfullscreen></iframe> | 15 var allow = iframe.hasAttribute('allow'); |
13 <iframe id="f4" src="about:blank" allow="fullscreen"></iframe> | 16 // fullscreen is enabled if: |
14 <iframe id="f5" src="about:blank" allow="fullscreen" allowfullscreen></iframe> | 17 // a. relocating within the same origin; or |
15 <iframe id="f6" src="about:blank" allowfullscreen></iframe> | 18 // b. relocating across origin, with allowfullscreen not overriden by |
16 <script> | 19 // container policy. |
17 function loadFrame(id, src, is_feature_enabled) { | 20 var enabled = |
iclelland
2017/05/18 19:56:58
I think we should call this something like "expect
lunalu1
2017/05/19 20:54:08
Done
| |
18 var iframe = document.getElementById(id); | 21 (src === srcs[0]) || (src === srcs[1] && iframe.allowFullscreen && !allow) |
19 promise_test(function(t) { | 22 promise_test(function() { |
20 iframe.src = src; | 23 iframe.src = src; |
21 return new Promise(function(resolve, reject) { | 24 return new Promise(function(resolve, reject) { |
22 window.addEventListener('message', function(e) { | 25 window.addEventListener('message', function(e) { |
23 if (e.data.type === 'change' || e.data.type === 'error') { | |
24 resolve(e.data); | 26 resolve(e.data); |
25 } | 27 }, { once: true }); |
26 }); | |
27 }).then(function(data) { | 28 }).then(function(data) { |
28 if (is_feature_enabled) { | 29 if (enabled) { |
29 assert_true(data.enabled, 'Document.fullscreenEnabled:'); | 30 assert_true(data.enabled, 'Document.fullscreenEnabled:'); |
30 assert_equals(data.type, 'change', 'Document.requestFullscreen():'); | 31 assert_equals(data.type, 'change', 'Document.requestFullscreen():'); |
31 } else { | 32 } else { |
32 assert_false(data.enabled, 'Document.fullscreenEnabled:'); | 33 assert_false(data.enabled, 'Document.fullscreenEnabled:'); |
33 assert_equals(data.type, 'error', 'Document.requestFullscreen():'); | 34 assert_equals(data.type, 'error', 'Document.requestFullscreen():'); |
34 } | 35 } |
35 }); | 36 }); |
36 }, 'iframe ' + id + ' relocated to URL: ' + src + ' with allowfullscreen = ' + iframe.allowFullscreen + ' is ' + (is_feature_enabled ? 'enabled' : 'disabled') + ' by container policy.'); | 37 }, 'iframe relocated to URL: ' + src + ' with allowpaymentrequest = ' + |
38 allowfullscreen + ' allow = ' + (allow ? 'fullscreen' : 'undefined') + | |
39 ' is ' + (enabled ? 'enabled' : 'disabled') + ' by container policy.'); | |
37 } | 40 } |
38 loadFrame("f1", "http://localhost:8000/feature-policy/resources/feature-policy-f ullscreen.html", true); | 41 |
39 loadFrame("f2", "http://localhost:8000/feature-policy/resources/feature-policy-f ullscreen.html", true); | 42 window.onload = function() { |
40 loadFrame("f3", "http://localhost:8000/feature-policy/resources/feature-policy-f ullscreen.html", true); | 43 var iframes = document.getElementsByTagName('iframe'); |
41 loadFrame("f4", "resources/feature-policy-fullscreen-relocate.html", false); | 44 for (var src of srcs) { |
42 loadFrame("f5", "resources/feature-policy-fullscreen-relocate.html", false); | 45 for (var iframe of iframes) { |
43 loadFrame("f6", "resources/feature-policy-fullscreen-relocate.html", true); | 46 loadFrame(iframe, src); |
47 } | |
48 } | |
49 } | |
44 </script> | 50 </script> |
OLD | NEW |