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 payment feature when disabled may not be called by | 6 // This test ensures that payment feature when disabled may not be called by |
7 // any iframe even when allowpaymentrequest is set. | 7 // any iframe even when allowpaymentrequest is set. |
8 | 8 |
9 Header("Feature-Policy: {\"payment\": []}"); | 9 Header("Feature-Policy: {\"payment\": []}"); |
10 ?> | 10 ?> |
11 | 11 |
12 <!DOCTYPE html> | 12 <!DOCTYPE html> |
13 <script src="../../resources/testharness.js"></script> | 13 <script src="../../resources/testharness.js"></script> |
14 <script src="../../resources/testharnessreport.js"></script> | 14 <script src="../../resources/testharnessreport.js"></script> |
| 15 <script src="resources/helper.js"></script> |
| 16 <iframe></iframe> |
| 17 <iframe allowpaymentrequest></iframe> |
15 <script> | 18 <script> |
16 if (window.testRunner) { | 19 var srcs = [ |
17 testRunner.dumpAsText(); | 20 "resources/feature-policy-payment.html", |
18 testRunner.dumpChildFramesAsText(); | 21 "http://localhost:8000/feature-policy/resources/feature-policy-payment.html" |
19 } | 22 ]; |
| 23 |
| 24 function loadFrame(iframe, src) { |
| 25 var allowpaymentrequest = iframe.hasAttribute('allowpaymentrequest'); |
| 26 promise_test(function() { |
| 27 iframe.src = src; |
| 28 return new Promise(function(resolve, reject) { |
| 29 window.addEventListener('message', function(e) { |
| 30 resolve(e.data); |
| 31 }, { once: true }); |
| 32 }).then(function(data) { |
| 33 assert_false(data.enabled, 'Paymentrequest():'); |
| 34 assert_equals(data.name, 'SecurityError', 'Exception Name:'); |
| 35 assert_equals(data.message, "Failed to construct 'PaymentRequest': " + |
| 36 "Must be in a top-level browsing context or an iframe needs to " + |
| 37 "specify 'allowpaymentrequest' explicitly", 'Error Message:'); |
| 38 }); |
| 39 }, 'Paymentrequest disabled on URL: ' + src + ' with allowpaymentrequest = ' + |
| 40 allowpaymentrequest); |
| 41 } |
| 42 |
| 43 window.onload = function() { |
| 44 loadIframes(srcs); |
| 45 } |
20 </script> | 46 </script> |
21 <iframe id="f1" src="resources/feature-policy-payment-disabled.html"></iframe> | |
22 <iframe id="f2" src="http://localhost:8000/feature-policy/resources/feature-poli
cy-payment-disabled.html"></iframe> | |
23 <iframe id="f3" src="resources/feature-policy-payment-disabled.html" allowpaymen
trequest></iframe> | |
24 <iframe id="f4" src="http://localhost:8000/feature-policy/resources/feature-poli
cy-payment-disabled.html" allowpaymentrequest></iframe> | |
OLD | NEW |