OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
| 6 #include "content/public/test/browser_test.h" |
| 7 #include "content/public/test/browser_test_utils.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace payments { |
| 11 |
| 12 class PaymentRequestDataUrlTest : public PaymentRequestBrowserTestBase { |
| 13 protected: |
| 14 PaymentRequestDataUrlTest() |
| 15 : PaymentRequestBrowserTestBase( |
| 16 "data:text/html,<html><head><meta name=\"viewport\" " |
| 17 "content=\"width=device-width, initial-scale=1, " |
| 18 "maximum-scale=1\"></head><body><button id=\"buy\" onclick=\"try { " |
| 19 "(new PaymentRequest([{supportedMethods: ['basic-card']}], {total: " |
| 20 "{label: 'Total', amount: {currency: 'USD', value: " |
| 21 "'1.00'}}})).show(); } catch(e) { " |
| 22 "document.getElementById('result').innerHTML = e; }\">Data URL " |
| 23 "Test</button><div id='result'></div></body></html>") {} |
| 24 }; |
| 25 |
| 26 IN_PROC_BROWSER_TEST_F(PaymentRequestDataUrlTest, SecurityError) { |
| 27 ASSERT_TRUE(content::ExecuteScript( |
| 28 GetActiveWebContents(), |
| 29 "(function() { document.getElementById('buy').click(); })();")); |
| 30 ExpectBodyContains( |
| 31 {"SecurityError: Failed to construct 'PaymentRequest': Must be in a " |
| 32 "secure context"}); |
| 33 } |
| 34 |
| 35 } // namespace payments |
OLD | NEW |