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 self only works | 6 // This test ensures that fullscreen feature when enabled for self only works |
7 // in the same orgin but not cross origins when allowfullscreen is set. No | 7 // in the same orgin but not cross origins when allowfullscreen is set. No |
8 // iframe may call it when allowfullscreen is not set. | 8 // iframe may call it when allowfullscreen is not set. |
9 | 9 |
10 Header("Feature-Policy: {\"fullscreen\": [\"self\"]}"); | 10 Header("Feature-Policy: {\"fullscreen\": [\"self\"]}"); |
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 <script src="resources/helper.js"></script> |
17 <iframe id="f2" allowfullscreen></iframe> | 17 <iframe></iframe> |
| 18 <iframe allowfullscreen></iframe> |
18 <script> | 19 <script> |
19 var srcs = [ | 20 var srcs = [ |
20 "resources/feature-policy-fullscreen.html", | 21 "resources/feature-policy-fullscreen.html", |
21 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html
" | 22 "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html
" |
22 ]; | 23 ]; |
23 var f1 = document.getElementById('f1'); | |
24 var f2 = document.getElementById('f2'); | |
25 | 24 |
26 function loadFrames(iframe) { | 25 function loadFrame(iframe, src) { |
27 for (var src of srcs) { | 26 var allowfullscreen = iframe.allowFullscreen; |
28 promise_test(function(t) { | 27 promise_test(function() { |
29 iframe.src = src; | 28 iframe.src = src; |
30 return new Promise(function(resolve, reject) { | 29 return new Promise(function(resolve, reject) { |
31 window.addEventListener('message', function(e) { | 30 window.addEventListener('message', function(e) { |
32 resolve(e.data); | 31 resolve(e.data); |
33 }, { once: true }); | 32 }, { once: true }); |
34 }).then(function(data) { | 33 }).then(function(data) { |
35 if (src === srcs[0] || iframe.id === "f2") { | 34 // fullscreen is enabled if: |
36 assert_true(data.enabled, 'Document.fullscreenEnabled:'); | 35 // a. same origin; or |
37 assert_equals(data.type, 'change', 'Document.requestFullscreen():'); | 36 // b. enabled by allowfullscreen. |
38 } else { | 37 if (src === srcs[0] || allowfullscreen) { |
39 assert_false(data.enabled, 'Document.fullscreenEnabled:'); | 38 assert_true(data.enabled, 'Document.fullscreenEnabled:'); |
40 assert_equals(data.type, 'error', 'Document.requestFullscreen():'); | 39 assert_equals(data.type, 'change', 'Document.requestFullscreen():'); |
41 } | 40 } else { |
42 }); | 41 assert_false(data.enabled, 'Document.fullscreenEnabled:'); |
43 }, 'Fullscreen enabled for self on URL: ' + src + ' with allowfullscreen = '
+ iframe.allowFullscreen); | 42 assert_equals(data.type, 'error', 'Document.requestFullscreen():'); |
44 } | 43 } |
| 44 }); |
| 45 }, 'Fullscreen enabled for self on URL: ' + src + ' with allowfullscreen = ' + |
| 46 allowfullscreen); |
45 } | 47 } |
46 | 48 |
47 loadFrames(f1); | 49 window.onload = function() { |
48 loadFrames(f2); | 50 loadIframes(srcs); |
| 51 } |
49 </script> | 52 </script> |
OLD | NEW |