Index: third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-allowed-by-container-policy-relocate.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-allowed-by-container-policy-relocate.html b/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-allowed-by-container-policy-relocate.html |
index 0fb8d85dba713e5c80a75a4fd205e859cef5ac67..eae99a40623c6cdb693d892d3ef35e8f740d5bd2 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-allowed-by-container-policy-relocate.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/feature-policy/fullscreen-allowed-by-container-policy-relocate.html |
@@ -1,31 +1,33 @@ |
<!DOCTYPE html> |
<script src="../../resources/testharness.js"></script> |
<script src="../../resources/testharnessreport.js"></script> |
+<script src="resources/helper.js"></script> |
+<iframe src="about:blank" allow="fullscreen"></iframe> |
+<iframe src="about:blank" allow="fullscreen" allowfullscreen></iframe> |
+<iframe src="about:blank" allowfullscreen></iframe> |
<script> |
- if (window.testRunner) { |
- testRunner.dumpAsText(); |
- testRunner.dumpAsText(); |
- } |
-</script> |
-<iframe id="f1" src="about:blank" allow="fullscreen"></iframe> |
-<iframe id="f2" src="about:blank" allow="fullscreen" allowfullscreen></iframe> |
-<iframe id="f3" src="about:blank" allowfullscreen></iframe> |
-<iframe id="f4" src="about:blank" allow="fullscreen"></iframe> |
-<iframe id="f5" src="about:blank" allow="fullscreen" allowfullscreen></iframe> |
-<iframe id="f6" src="about:blank" allowfullscreen></iframe> |
-<script> |
-function loadFrame(id, src, is_feature_enabled) { |
- var iframe = document.getElementById(id); |
- promise_test(function(t) { |
+var srcs = [ |
+ "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html", |
+ "resources/feature-policy-fullscreen-relocate.html" |
+]; |
+ |
+function loadFrame(iframe, src) { |
+ var allowFullscreen = iframe.allowFullscreen; |
+ var allow = iframe.hasAttribute('allow'); |
+ // fullscreen is enabled if: |
+ // a. relocating within the same origin; or |
+ // b. relocating across origin, with allowfullscreen not overriden by |
+ // container policy. |
+ var expectedEnabled = |
+ (src === srcs[0]) || (src === srcs[1] && iframe.allowFullscreen && !allow) |
+ promise_test(function() { |
iframe.src = src; |
return new Promise(function(resolve, reject) { |
window.addEventListener('message', function(e) { |
- if (e.data.type === 'change' || e.data.type === 'error') { |
resolve(e.data); |
- } |
- }); |
+ }, { once: true }); |
}).then(function(data) { |
- if (is_feature_enabled) { |
+ if (expectedEnabled) { |
assert_true(data.enabled, 'Document.fullscreenEnabled:'); |
assert_equals(data.type, 'change', 'Document.requestFullscreen():'); |
} else { |
@@ -33,12 +35,13 @@ function loadFrame(id, src, is_feature_enabled) { |
assert_equals(data.type, 'error', 'Document.requestFullscreen():'); |
} |
}); |
- }, 'iframe ' + id + ' relocated to URL: ' + src + ' with allowfullscreen = ' + iframe.allowFullscreen + ' is ' + (is_feature_enabled ? 'enabled' : 'disabled') + ' by container policy.'); |
+ }, 'Iframe src set to ' + src + ', allowpaymentrequest = ' + |
+ allowFullscreen + ', allow = ' + (allow ? 'fullscreen' : 'undefined') + |
+ ', fullscreen is ' + (expectedEnabled ? 'enabled' : 'disabled') + |
+ ' by container policy.'); |
+} |
+ |
+window.onload = function() { |
+ loadIframes(srcs); |
} |
-loadFrame("f1", "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html", true); |
-loadFrame("f2", "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html", true); |
-loadFrame("f3", "http://localhost:8000/feature-policy/resources/feature-policy-fullscreen.html", true); |
-loadFrame("f4", "resources/feature-policy-fullscreen-relocate.html", false); |
-loadFrame("f5", "resources/feature-policy-fullscreen-relocate.html", false); |
-loadFrame("f6", "resources/feature-policy-fullscreen-relocate.html", true); |
</script> |