OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <iframe src="about:blank" allow="payment"></iframe> |
| 5 <iframe src="about:blank" allowpaymentrequest allow="payment"></iframe> |
| 6 <iframe src="about:blank" allowpaymentrequest></iframe> |
4 <script> | 7 <script> |
5 if (window.testRunner) { | 8 var srcs = [ |
6 testRunner.dumpAsText(); | 9 "http://localhost:8000/feature-policy/resources/feature-policy-payment.html", |
7 testRunner.dumpChildFramesAsText(); | 10 "resources/feature-policy-payment-relocate.html" |
| 11 ]; |
| 12 |
| 13 function loadFrame(iframe, src) { |
| 14 var allowpaymentrequest = iframe.hasAttribute('allowpaymentrequest'); |
| 15 var allow = iframe.hasAttribute('allow'); |
| 16 // paymentrequest is enabled if: |
| 17 // a. relocating within the same origin; or |
| 18 // b. relocating across origin, with allowpaymentrequest not overriden by |
| 19 // container policy. |
| 20 var enabled = |
| 21 (src === srcs[0]) || (src === srcs[1] && allowpaymentrequest && !allow) |
| 22 promise_test(function() { |
| 23 iframe.src = src; |
| 24 return new Promise(function(resolve, reject) { |
| 25 window.addEventListener('message', function(e) { |
| 26 resolve(e.data); |
| 27 }, { once: true }); |
| 28 }).then(function(data) { |
| 29 if (enabled) { |
| 30 assert_true(data.enabled, 'Paymentrequest():'); |
| 31 } else { |
| 32 assert_false(data.enabled, 'Paymentrequest():'); |
| 33 assert_equals(data.name, 'SecurityError', 'Exception Name:'); |
| 34 assert_equals(data.message, "Failed to construct 'PaymentRequest': " + |
| 35 "Must be in a top-level browsing context or an iframe needs to " + |
| 36 "specify 'allowpaymentrequest' explicitly", 'Error Message:'); |
| 37 } |
| 38 }); |
| 39 }, 'iframe relocated to URL: ' + src + ' with allowpaymentrequest = ' + |
| 40 allowpaymentrequest + ' allow = ' + (allow ? 'payment' : 'undefined') + |
| 41 ' is ' + (enabled ? 'enabled' : 'disabled') + ' by container policy.'); |
| 42 } |
| 43 |
| 44 window.onload = function() { |
| 45 var iframes = document.getElementsByTagName('iframe'); |
| 46 for (var src of srcs) { |
| 47 for (var iframe of iframes) { |
| 48 loadFrame(iframe, src); |
| 49 } |
8 } | 50 } |
| 51 } |
9 </script> | 52 </script> |
10 <iframe id="f1" src="about:blank" allow="payment"></iframe> | |
11 <iframe id="f2" src="about:blank" allowpaymentrequest allow="payment"></iframe> | |
12 <iframe id="f3" src="about:blank" allowpaymentrequest></iframe> | |
13 <iframe id="f4" src="resources/feature-policy-payment-relocate-disabled.html" al
low="payment"></iframe> | |
14 <iframe id="f5" src="resources/feature-policy-payment-relocate-disabled.html" al
lowpaymentrequest allow="payment"></iframe> | |
15 <iframe id="f6" src="resources/feature-policy-payment-relocate-enabled.html" all
owpaymentrequest></iframe> | |
16 <script> | |
17 document.getElementById("f1").src = "http://localhost:8000/feature-policy/resour
ces/feature-policy-payment-enabled.html"; | |
18 document.getElementById("f2").src = "http://localhost:8000/feature-policy/resour
ces/feature-policy-payment-enabled.html"; | |
19 document.getElementById("f3").src = "http://localhost:8000/feature-policy/resour
ces/feature-policy-payment-enabled.html"; | |
20 </script> | |
OLD | NEW |