OLD | NEW |
1 <?php | 1 <?php |
2 // Copyright 2016 The Chromium Authors. All rights reserved. | 2 // Copyright 2016 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 // This test ensures that fullscreen feature when enabled for all works across | 6 // This test ensures that fullscreen feature when enabled for all works across |
7 // origins regardless of whether allowfullscreen is set. (Feature policy header | 7 // origins regardless of whether allowfullscreen is set. (Feature policy header |
8 // takes precedence over the absence of allowfullscreen.) | 8 // takes precedence over the absence of allowfullscreen.) |
9 | 9 |
10 Header("Feature-Policy: {\"fullscreen\": [\"*\"]}"); | 10 Header("Feature-Policy: {\"fullscreen\": [\"*\"]}"); |
11 ?> | 11 ?> |
12 | 12 |
13 <!DOCTYPE html> | 13 <!DOCTYPE html> |
14 <script src="../../resources/testharness.js"></script> | 14 <script src="../../resources/testharness.js"></script> |
15 <script src="../../resources/testharnessreport.js"></script> | 15 <script src="../../resources/testharnessreport.js"></script> |
16 <iframe id="f1"></iframe> | 16 <iframe></iframe> |
17 <iframe id="f2" allowfullscreen></iframe> | 17 <iframe allowfullscreen></iframe> |
18 <script> | 18 <script> |
19 var srcs = [ | 19 var srcs = [ |
20 "resources/feature-policy-fullscreen.html", | 20 "resources/feature-policy-fullscreen.html", |
21 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html
" | 21 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html
" |
22 ]; | 22 ]; |
23 var f1 = document.getElementById('f1'); | |
24 var f2 = document.getElementById('f2'); | |
25 | 23 |
26 function loadFrames(iframe) { | 24 function loadFrame(iframe, src) { |
27 for (var src of srcs) { | 25 var allowfullscreen = iframe.allowFullscreen; |
28 promise_test(function(t) { | 26 promise_test(function() { |
29 iframe.src = src; | 27 iframe.src = src; |
30 return new Promise(function(resolve, reject) { | 28 return new Promise(function(resolve, reject) { |
31 window.addEventListener('message', function(e) { | 29 window.addEventListener('message', function(e) { |
32 resolve(e.data); | 30 resolve(e.data); |
33 }, { once: true }); | 31 }, { once: true }); |
34 }).then(function(data) { | 32 }).then(function(data) { |
35 assert_true(data.enabled, 'Document.fullscreenEnabled:'); | 33 assert_true(data.enabled, 'Document.fullscreenEnabled:'); |
36 assert_equals(data.type, 'change', 'Document.requestFullscreen():'); | 34 assert_equals(data.type, 'change', 'Document.requestFullscreen():'); |
37 }); | 35 }); |
38 }, 'Fullscreen enabled for all on URL: ' + src + ' with allowfullscreen = '
+ iframe.allowFullscreen); | 36 }, 'Fullscreen enabled for all on URL: ' + src + ' with allowfullscreen = ' + |
| 37 allowfullscreen); |
| 38 } |
| 39 |
| 40 window.onload = function() { |
| 41 var iframes = document.getElementsByTagName('iframe'); |
| 42 for (var iframe of iframes) { |
| 43 for (var src of srcs) { |
| 44 loadFrame(iframe, src); |
| 45 } |
39 } | 46 } |
40 } | 47 } |
41 | |
42 loadFrames(f1); | |
43 loadFrames(f2); | |
44 </script> | 48 </script> |
OLD | NEW |