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

Unified Diff: ios/chrome/browser/web/chrome_web_client_unittest.mm

Issue 2949583002: [Payment Request] window.PaymentRequest must be undefined if PR is disabled (Closed)
Patch Set: Addressed comment Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/web/chrome_web_client.mm ('k') | ios/chrome/browser/web/resources/chrome_bundle.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/chrome_web_client_unittest.mm
diff --git a/ios/chrome/browser/web/chrome_web_client_unittest.mm b/ios/chrome/browser/web/chrome_web_client_unittest.mm
index 12ad6b825fcbe2f75367507df531108d877dcfd4..c271de672045c7294ada933a2134cf58a47826d0 100644
--- a/ios/chrome/browser/web/chrome_web_client_unittest.mm
+++ b/ios/chrome/browser/web/chrome_web_client_unittest.mm
@@ -8,9 +8,12 @@
#include <memory>
+#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_split.h"
#include "base/strings/sys_string_conversions.h"
+#include "ios/chrome/browser/chrome_switches.h"
+#include "ios/chrome/browser/experimental_flags.h"
#include "ios/web/public/test/fakes/test_browser_state.h"
#import "ios/web/public/test/js_test_util.h"
#include "ios/web/public/test/scoped_testing_web_client.h"
@@ -70,9 +73,8 @@ TEST_F(ChromeWebClientTest, UserAgent) {
EXPECT_EQ(0u, product_str.find("CriOS/"));
}
-// Tests that ChromeWebClient provides print script and does not provide
-// windowOpenFix script for WKWebView.
-TEST_F(ChromeWebClientTest, WKWebViewEarlyPageScript) {
+// Tests that ChromeWebClient provides print script for WKWebView.
+TEST_F(ChromeWebClientTest, WKWebViewEarlyPageScriptPrint) {
// Chrome scripts rely on __gCrWeb object presence.
web::TestBrowserState browser_state;
WKWebView* web_view = web::BuildWKWebView(CGRectZero, &browser_state);
@@ -83,6 +85,26 @@ TEST_F(ChromeWebClientTest, WKWebViewEarlyPageScript) {
web::ExecuteJavaScript(web_view, script);
EXPECT_NSEQ(@"object",
web::ExecuteJavaScript(web_view, @"typeof __gCrWeb.print"));
+}
+
+// Tests that ChromeWebClient does not provide payment request script for
+// WKWebView unless the feature is enabled.
+TEST_F(ChromeWebClientTest, WKWebViewEarlyPageScriptPaymentRequest) {
+ // Chrome scripts rely on __gCrWeb object presence.
+ web::TestBrowserState browser_state;
+ WKWebView* web_view = web::BuildWKWebView(CGRectZero, &browser_state);
+ web::ExecuteJavaScript(web_view, @"__gCrWeb = {};");
+
+ web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>());
+ NSString* script = web_client.Get()->GetEarlyPageScript(&browser_state);
+ web::ExecuteJavaScript(web_view, script);
+ EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript(
+ web_view, @"typeof window.PaymentRequest"));
+
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kEnablePaymentRequest, std::string());
+ script = web_client.Get()->GetEarlyPageScript(&browser_state);
+ web::ExecuteJavaScript(web_view, script);
EXPECT_NSEQ(@"function", web::ExecuteJavaScript(
web_view, @"typeof window.PaymentRequest"));
}
« no previous file with comments | « ios/chrome/browser/web/chrome_web_client.mm ('k') | ios/chrome/browser/web/resources/chrome_bundle.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698