Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html

Issue 2855133004: Re-enable feature policy layout tests after bug fix. (Closed)
Patch Set: Rebased FlagExpectations/site-per-process Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html b/third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html
index 7a07fad59dbe5e2aa36a07e456395db5171694fa..4cc3d4698487fe33be9b36ec62a678015ac55103 100644
--- a/third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html
+++ b/third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html
@@ -1,20 +1,52 @@
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
+<iframe src="about:blank" allow="payment"></iframe>
+<iframe src="about:blank" allowpaymentrequest allow="payment"></iframe>
+<iframe src="about:blank" allowpaymentrequest></iframe>
<script>
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.dumpChildFramesAsText();
+var srcs = [
+ "http://localhost:8000/feature-policy/resources/feature-policy-payment.html",
+ "resources/feature-policy-payment-relocate.html"
+];
+
+function loadFrame(iframe, src) {
+ var allowpaymentrequest = iframe.hasAttribute('allowpaymentrequest');
+ var allow = iframe.hasAttribute('allow');
+ // paymentrequest is enabled if:
+ // a. relocating within the same origin; or
+ // b. relocating across origin, with allowpaymentrequest not overriden by
+ // container policy.
+ var enabled =
+ (src === srcs[0]) || (src === srcs[1] && allowpaymentrequest && !allow)
+ 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) {
+ if (enabled) {
+ assert_true(data.enabled, 'Paymentrequest():');
+ } else {
+ assert_false(data.enabled, 'Paymentrequest():');
+ assert_equals(data.name, 'SecurityError', 'Exception Name:');
+ assert_equals(data.message, "Failed to construct 'PaymentRequest': " +
+ "Must be in a top-level browsing context or an iframe needs to " +
+ "specify 'allowpaymentrequest' explicitly", 'Error Message:');
+ }
+ });
+ }, 'iframe relocated to URL: ' + src + ' with allowpaymentrequest = ' +
+ allowpaymentrequest + ' allow = ' + (allow ? 'payment' : 'undefined') +
+ ' is ' + (enabled ? 'enabled' : 'disabled') + ' by container policy.');
+}
+
+window.onload = function() {
+ var iframes = document.getElementsByTagName('iframe');
+ for (var src of srcs) {
+ for (var iframe of iframes) {
+ loadFrame(iframe, src);
+ }
}
-</script>
-<iframe id="f1" src="about:blank" allow="payment"></iframe>
-<iframe id="f2" src="about:blank" allowpaymentrequest allow="payment"></iframe>
-<iframe id="f3" src="about:blank" allowpaymentrequest></iframe>
-<iframe id="f4" src="resources/feature-policy-payment-relocate-disabled.html" allow="payment"></iframe>
-<iframe id="f5" src="resources/feature-policy-payment-relocate-disabled.html" allowpaymentrequest allow="payment"></iframe>
-<iframe id="f6" src="resources/feature-policy-payment-relocate-enabled.html" allowpaymentrequest></iframe>
-<script>
-document.getElementById("f1").src = "http://localhost:8000/feature-policy/resources/feature-policy-payment-enabled.html";
-document.getElementById("f2").src = "http://localhost:8000/feature-policy/resources/feature-policy-payment-enabled.html";
-document.getElementById("f3").src = "http://localhost:8000/feature-policy/resources/feature-policy-payment-enabled.html";
+}
</script>

Powered by Google App Engine
This is Rietveld 408576698