| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/web/chrome_web_client.h" | 5 #include "ios/chrome/browser/web/chrome_web_client.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "ios/chrome/browser/chrome_switches.h" | 15 #include "base/test/scoped_feature_list.h" |
| 16 #include "ios/chrome/browser/experimental_flags.h" | 16 #include "components/payments/core/features.h" |
| 17 #include "ios/web/public/test/fakes/test_browser_state.h" | 17 #include "ios/web/public/test/fakes/test_browser_state.h" |
| 18 #import "ios/web/public/test/js_test_util.h" | 18 #import "ios/web/public/test/js_test_util.h" |
| 19 #include "ios/web/public/test/scoped_testing_web_client.h" | 19 #include "ios/web/public/test/scoped_testing_web_client.h" |
| 20 #include "ios/web/public/test/web_test.h" | 20 #include "ios/web/public/test/web_test.h" |
| 21 #import "ios/web/public/web_view_creation_util.h" | 21 #import "ios/web/public/web_view_creation_util.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "testing/gtest_mac.h" | 23 #include "testing/gtest_mac.h" |
| 24 | 24 |
| 25 #if !defined(__has_feature) || !__has_feature(objc_arc) | 25 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 26 #error "This file requires ARC support." | 26 #error "This file requires ARC support." |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 web::TestBrowserState browser_state; | 94 web::TestBrowserState browser_state; |
| 95 WKWebView* web_view = web::BuildWKWebView(CGRectZero, &browser_state); | 95 WKWebView* web_view = web::BuildWKWebView(CGRectZero, &browser_state); |
| 96 web::ExecuteJavaScript(web_view, @"__gCrWeb = {};"); | 96 web::ExecuteJavaScript(web_view, @"__gCrWeb = {};"); |
| 97 | 97 |
| 98 web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>()); | 98 web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>()); |
| 99 NSString* script = web_client.Get()->GetEarlyPageScript(&browser_state); | 99 NSString* script = web_client.Get()->GetEarlyPageScript(&browser_state); |
| 100 web::ExecuteJavaScript(web_view, script); | 100 web::ExecuteJavaScript(web_view, script); |
| 101 EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript( | 101 EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript( |
| 102 web_view, @"typeof window.PaymentRequest")); | 102 web_view, @"typeof window.PaymentRequest")); |
| 103 | 103 |
| 104 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 104 base::test::ScopedFeatureList feature_list; |
| 105 switches::kEnablePaymentRequest, std::string()); | 105 feature_list.InitAndEnableFeature(payments::features::kWebPayments); |
| 106 script = web_client.Get()->GetEarlyPageScript(&browser_state); | 106 script = web_client.Get()->GetEarlyPageScript(&browser_state); |
| 107 web::ExecuteJavaScript(web_view, script); | 107 web::ExecuteJavaScript(web_view, script); |
| 108 EXPECT_NSEQ(@"function", web::ExecuteJavaScript( | 108 EXPECT_NSEQ(@"function", web::ExecuteJavaScript( |
| 109 web_view, @"typeof window.PaymentRequest")); | 109 web_view, @"typeof window.PaymentRequest")); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| OLD | NEW |