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

Side by Side Diff: chrome/browser/extensions/webstore_installer_test.cc

Issue 908063002: Prevent inline CRX installs in popup windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open the popup from the test file rather than using browser navigation Created 5 years, 10 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/extensions/tab_helper.h" 10 #include "chrome/browser/extensions/tab_helper.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 GURL page_url = test_server()->GetURL( 92 GURL page_url = test_server()->GetURL(
93 base::StringPrintf("files/%s/%s", 93 base::StringPrintf("files/%s/%s",
94 test_data_path_.c_str(), 94 test_data_path_.c_str(),
95 page_filename.c_str())); 95 page_filename.c_str()));
96 96
97 GURL::Replacements replace_host; 97 GURL::Replacements replace_host;
98 replace_host.SetHostStr(domain); 98 replace_host.SetHostStr(domain);
99 return page_url.ReplaceComponents(replace_host); 99 return page_url.ReplaceComponents(replace_host);
100 } 100 }
101 101
102 void WebstoreInstallerTest::RunTest(const std::string& test_function_name) { 102 void WebstoreInstallerTest::RunTest(WebContents* web_contents,
103 const std::string& test_function_name) {
103 bool result = false; 104 bool result = false;
104 std::string script = base::StringPrintf( 105 std::string script = base::StringPrintf(
105 "%s('%s')", test_function_name.c_str(), 106 "%s('%s')", test_function_name.c_str(),
106 test_gallery_url_.c_str()); 107 test_gallery_url_.c_str());
107 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 108 ASSERT_TRUE(
108 browser()->tab_strip_model()->GetActiveWebContents(), 109 content::ExecuteScriptAndExtractBool(web_contents, script, &result));
109 script,
110 &result));
111 EXPECT_TRUE(result); 110 EXPECT_TRUE(result);
112 } 111 }
113 112
113 void WebstoreInstallerTest::RunTest(const std::string& test_function_name) {
114 RunTest(browser()->tab_strip_model()->GetActiveWebContents(),
115 test_function_name);
116 }
117
114 bool WebstoreInstallerTest::RunIndexedTest( 118 bool WebstoreInstallerTest::RunIndexedTest(
115 const std::string& test_function_name, 119 const std::string& test_function_name,
116 int i) { 120 int i) {
117 std::string result = "FAILED"; 121 std::string result = "FAILED";
118 std::string script = base::StringPrintf("%s('%s', %d)", 122 std::string script = base::StringPrintf("%s('%s', %d)",
119 test_function_name.c_str(), test_gallery_url_.c_str(), i); 123 test_function_name.c_str(), test_gallery_url_.c_str(), i);
120 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 124 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
121 browser()->tab_strip_model()->GetActiveWebContents(), 125 browser()->tab_strip_model()->GetActiveWebContents(),
122 script, 126 script,
123 &result)); 127 &result));
(...skipping 11 matching lines...) Expand all
135 139
136 void WebstoreInstallerTest::AutoAcceptInstall() { 140 void WebstoreInstallerTest::AutoAcceptInstall() {
137 ExtensionInstallPrompt::g_auto_confirm_for_tests = 141 ExtensionInstallPrompt::g_auto_confirm_for_tests =
138 ExtensionInstallPrompt::ACCEPT; 142 ExtensionInstallPrompt::ACCEPT;
139 } 143 }
140 144
141 void WebstoreInstallerTest::AutoCancelInstall() { 145 void WebstoreInstallerTest::AutoCancelInstall() {
142 ExtensionInstallPrompt::g_auto_confirm_for_tests = 146 ExtensionInstallPrompt::g_auto_confirm_for_tests =
143 ExtensionInstallPrompt::CANCEL; 147 ExtensionInstallPrompt::CANCEL;
144 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698