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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/feature-policy/payment-enabledforself.php

Issue 2855133004: Re-enable feature policy layout tests after bug fix. (Closed)
Patch Set: Rebased FlagExpectations/site-per-process Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 enabled for self works in 6 // This test ensures that payment feature when enabled for self works in
7 // the same origin or when allowpaymentrequest is set. No cross-origin iframe 7 // the same origin or when allowpaymentrequest is set. No cross-origin iframe
8 // may call it when allowpaymentrequest is not set. 8 // may call it when allowpaymentrequest is not set.
9 9
10 Header("Feature-Policy: {\"payment\": [\"self\"]}"); 10 Header("Feature-Policy: {\"payment\": [\"self\"]}");
11 ?> 11 ?>
12 12
13 <!DOCTYPE html> 13 <!DOCTYPE html>
14 <script src="../../resources/testharness.js"></script> 14 <script src="../../resources/testharness.js"></script>
15 <script src="../../resources/testharnessreport.js"></script> 15 <script src="../../resources/testharnessreport.js"></script>
16 <iframe></iframe>
17 <iframe allowpaymentrequest></iframe>
16 <script> 18 <script>
17 if (window.testRunner) { 19 var srcs = [
18 testRunner.dumpAsText(); 20 "resources/feature-policy-payment.html",
19 testRunner.dumpChildFramesAsText(); 21 "http://localhost:8000/feature-policy/resources/feature-policy-payment.html"
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 // paymentrequest is enabled if:
34 // a. same origin; or
35 // b. enabled by allowpaymentrequest.
36 if (src === srcs[0] || allowpaymentrequest) {
37 assert_true(data.enabled, 'Paymentrequest():');
38 } else {
39 assert_false(data.enabled, 'Paymentrequest():');
40 assert_equals(data.name, 'SecurityError', 'Exception Name:');
41 assert_equals(data.message, "Failed to construct 'PaymentRequest': " +
42 "Must be in a top-level browsing context or an iframe needs to " +
43 "specify 'allowpaymentrequest' explicitly", 'Error Message:');
44 }
45 });
46 }, 'Paymentrequest enabled for self on URL: ' + src + ' with '+
47 'allowpaymentrequest = ' + allowpaymentrequest);
48 }
49
50 window.onload = function() {
51 var iframes = document.getElementsByTagName('iframe');
52 for (var iframe of iframes) {
53 for (var src of srcs) {
54 loadFrame(iframe, src);
55 }
20 } 56 }
57 }
21 </script> 58 </script>
22 <iframe id="f1" src="resources/feature-policy-payment-enabled.html"></iframe>
23 <iframe id="f2" src="http://localhost:8000/feature-policy/resources/feature-poli cy-payment-disabled.html"></iframe>
24 <iframe id="f3" src="resources/feature-policy-payment-enabled.html" allowpayment request></iframe>
25 <iframe id="f4" src="http://localhost:8000/feature-policy/resources/feature-poli cy-payment-enabled.html" allowpaymentrequest></iframe>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698