Index: third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-enabledforself.php |
diff --git a/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-enabledforself.php b/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-enabledforself.php |
index 422961320880aca98568ca6cfd8f5625acd88637..badaab047b3ee1da88ca2dd766c105a5cf6f4ce2 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-enabledforself.php |
+++ b/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-enabledforself.php |
@@ -13,37 +13,40 @@ Header("Feature-Policy: {\"fullscreen\": [\"self\"]}"); |
<!DOCTYPE html> |
<script src="../../resources/testharness.js"></script> |
<script src="../../resources/testharnessreport.js"></script> |
-<iframe id="f1"></iframe> |
-<iframe id="f2" allowfullscreen></iframe> |
+<script src="resources/helper.js"></script> |
+<iframe></iframe> |
+<iframe allowfullscreen></iframe> |
<script> |
var srcs = [ |
"resources/feature-policy-fullscreen.html", |
"http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html" |
]; |
-var f1 = document.getElementById('f1'); |
-var f2 = document.getElementById('f2'); |
-function loadFrames(iframe) { |
- for (var src of srcs) { |
- promise_test(function(t) { |
- iframe.src = src; |
- return new Promise(function(resolve, reject) { |
- window.addEventListener('message', function(e) { |
- resolve(e.data); |
- }, { once: true }); |
- }).then(function(data) { |
- if (src === srcs[0] || iframe.id === "f2") { |
- assert_true(data.enabled, 'Document.fullscreenEnabled:'); |
- assert_equals(data.type, 'change', 'Document.requestFullscreen():'); |
- } else { |
- assert_false(data.enabled, 'Document.fullscreenEnabled:'); |
- assert_equals(data.type, 'error', 'Document.requestFullscreen():'); |
- } |
- }); |
- }, 'Fullscreen enabled for self on URL: ' + src + ' with allowfullscreen = ' + iframe.allowFullscreen); |
- } |
+function loadFrame(iframe, src) { |
+ var allowfullscreen = iframe.allowFullscreen; |
+ promise_test(function() { |
+ iframe.src = src; |
+ return new Promise(function(resolve, reject) { |
+ window.addEventListener('message', function(e) { |
+ resolve(e.data); |
+ }, { once: true }); |
+ }).then(function(data) { |
+ // fullscreen is enabled if: |
+ // a. same origin; or |
+ // b. enabled by allowfullscreen. |
+ if (src === srcs[0] || allowfullscreen) { |
+ assert_true(data.enabled, 'Document.fullscreenEnabled:'); |
+ assert_equals(data.type, 'change', 'Document.requestFullscreen():'); |
+ } else { |
+ assert_false(data.enabled, 'Document.fullscreenEnabled:'); |
+ assert_equals(data.type, 'error', 'Document.requestFullscreen():'); |
+ } |
+ }); |
+ }, 'Fullscreen enabled for self on URL: ' + src + ' with allowfullscreen = ' + |
+ allowfullscreen); |
} |
-loadFrames(f1); |
-loadFrames(f2); |
+window.onload = function() { |
+ loadIframes(srcs); |
+} |
</script> |