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 disabled may not be called by | 6 // This test ensures that fullscreen feature when disabled may not be called by |
7 // any iframe even when allowfullscreen is set. | 7 // any iframe even when allowfullscreen is set. |
8 | 8 |
9 Header("Feature-Policy: {\"fullscreen\": []}"); | 9 Header("Feature-Policy: {\"fullscreen\": []}"); |
10 ?> | 10 ?> |
11 | 11 |
12 <!DOCTYPE html> | 12 <!DOCTYPE html> |
13 <script src="../../resources/testharness.js"></script> | 13 <script src="../../resources/testharness.js"></script> |
14 <script src="../../resources/testharnessreport.js"></script> | 14 <script src="../../resources/testharnessreport.js"></script> |
15 <iframe id="f1"></iframe> | 15 <iframe></iframe> |
16 <iframe id="f2" allowfullscreen></iframe> | 16 <iframe allowfullscreen></iframe> |
17 <script> | 17 <script> |
18 var srcs = [ | 18 var srcs = [ |
19 "resources/feature-policy-fullscreen.html", | 19 "resources/feature-policy-fullscreen.html", |
20 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html
" | 20 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html
" |
21 ]; | 21 ]; |
22 var f1 = document.getElementById('f1'); | |
23 var f2 = document.getElementById('f2'); | |
24 | 22 |
25 function loadFrames(iframe) { | 23 function loadFrame(iframe, src) { |
26 for (var src of srcs) { | 24 var allowfullscreen = iframe.allowFullscreen; |
27 promise_test(function() { | 25 promise_test(function() { |
28 iframe.src = src; | 26 iframe.src = src; |
29 return new Promise(function(resolve, reject) { | 27 return new Promise(function(resolve, reject) { |
30 window.addEventListener('message', function(e) { | 28 window.addEventListener('message', function(e) { |
31 resolve(e.data); | 29 resolve(e.data); |
32 }, { once: true }); | 30 }, { once: true }); |
33 }).then(function(data) { | 31 }).then(function(data) { |
34 assert_false(data.enabled, 'Document.fullscreenEnabled:'); | 32 assert_false(data.enabled, 'Document.fullscreenEnabled:'); |
35 assert_equals(data.type, 'error', 'Document.requestFullscreen():'); | 33 assert_equals(data.type, 'error', 'Document.requestFullscreen():'); |
36 }); | 34 }); |
37 }, 'Fullscreen disabled on URL: ' + src + ' with allowfullscreen = ' + ifram
e.allowFullscreen); | 35 }, 'Fullscreen disabled on URL: ' + src + ' with allowfullscreen = ' + |
| 36 allowfullscreen); |
| 37 } |
| 38 |
| 39 window.onload = function() { |
| 40 var iframes = document.getElementsByTagName('iframe'); |
| 41 for (var iframe of iframes) { |
| 42 for (var src of srcs) { |
| 43 loadFrame(iframe, src); |
| 44 } |
38 } | 45 } |
39 } | 46 } |
40 | |
41 loadFrames(f1); | |
42 loadFrames(f2); | |
43 </script> | 47 </script> |
OLD | NEW |