summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramistry <amistry@chromium.org>2015-06-18 15:47:05 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-18 22:48:20 +0000
commit6486f0ebe0b5a50c9ba9fc93639c53ff40c21182 (patch)
treec91a6929cc27eca3342884ec430b7eb1126daab9
parent153da16b4567bcd2220fff0b16e02735df902c3f (diff)
downloadchromium_src-6486f0ebe0b5a50c9ba9fc93639c53ff40c21182.zip
chromium_src-6486f0ebe0b5a50c9ba9fc93639c53ff40c21182.tar.gz
chromium_src-6486f0ebe0b5a50c9ba9fc93639c53ff40c21182.tar.bz2
Resurrect SearchProviderTest.TestIsSearchProviderInstalled.
BUG=359727 Review URL: https://codereview.chromium.org/1182603003 Cr-Commit-Position: refs/heads/master@{#335152}
-rw-r--r--chrome/browser/external_extension_browsertest.cc30
-rw-r--r--chrome/common/render_messages.h5
-rw-r--r--chrome/test/data/is_search_provider_installed.html85
3 files changed, 68 insertions, 52 deletions
diff --git a/chrome/browser/external_extension_browsertest.cc b/chrome/browser/external_extension_browsertest.cc
index a2f18de..8b05ec5 100644
--- a/chrome/browser/external_extension_browsertest.cc
+++ b/chrome/browser/external_extension_browsertest.cc
@@ -3,13 +3,17 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/google/core/browser/google_switches.h"
+#include "components/search_engines/search_engines_pref_names.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
@@ -28,7 +32,7 @@ struct IsSearchProviderTestData {
GURL test_url;
};
-}
+} // namespace
class SearchProviderTest : public InProcessBrowserTest {
protected:
@@ -45,11 +49,23 @@ class SearchProviderTest : public InProcessBrowserTest {
// proxy configured.
command_line->AppendSwitch(switches::kNoProxyServer);
+ // Always point google search to a known, non-secure URL. Normally, this
+ // varies based on locale and is a HTTPS host.
+ command_line->AppendSwitchASCII(
+ switches::kGoogleBaseURL, "http://www.google.com");
+
// Get the url for the test page.
search_provider_test_url_ =
test_server()->GetURL("files/is_search_provider_installed.html");
}
+ void SetUpOnMainThread() override {
+ // Force the country to Canada, which has an installed search provider
+ // that's HTTP.
+ browser()->profile()->GetPrefs()->SetInteger(
+ prefs::kCountryIDAtInstall, ('C' << 8) | 'A');
+ }
+
IsSearchProviderTestData StartIsSearchProviderInstalledTest(
Browser* browser,
const char* host,
@@ -83,11 +99,7 @@ class SearchProviderTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(SearchProviderTest);
};
-#if 1
-// Disabled - http://crbug.com/359727 (js has syntax errors which v8 hates)
-#define MAYBE_TestIsSearchProviderInstalled \
- DISABLED_TestIsSearchProviderInstalled
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
// This is flaking on XP. See http://crbug.com/159530
#define MAYBE_TestIsSearchProviderInstalled \
DISABLED_TestIsSearchProviderInstalled
@@ -97,11 +109,9 @@ class SearchProviderTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(SearchProviderTest,
MAYBE_TestIsSearchProviderInstalled) {
// Use the default search provider, other installed search provider, and
- // one not installed as well. (Note that yahoo isn't tested because the
- // its host name varies a lot for different locales unlike Google and Bing,
- // which would make the test fail depending on the machine's locale.)
+ // one not installed as well. Note, Ask is used here because it's a HTTP host.
const char* test_hosts[] = { "www.google.com",
- "www.bing.com",
+ "www.ask.com",
"localhost" };
const char* expected_results[] = { "2",
"1",
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 41eff81..416c3c9 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -80,8 +80,9 @@ IPC_ENUM_TRAITS_MAX_VALUE(OmniboxFocusChangeReason,
IPC_ENUM_TRAITS_MAX_VALUE(OmniboxFocusState, OMNIBOX_FOCUS_STATE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(search_provider::OSDDType,
search_provider::OSDD_TYPE_LAST)
-IPC_ENUM_TRAITS_MAX_VALUE(search_provider::InstallState,
- search_provider::INSTALLED_STATE_LAST)
+IPC_ENUM_TRAITS_MIN_MAX_VALUE(search_provider::InstallState,
+ search_provider::DENIED,
+ search_provider::INSTALLED_STATE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(ThemeBackgroundImageAlignment,
THEME_BKGRND_IMAGE_ALIGN_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(ThemeBackgroundImageTiling, THEME_BKGRND_IMAGE_LAST)
diff --git a/chrome/test/data/is_search_provider_installed.html b/chrome/test/data/is_search_provider_installed.html
index 23b64f1..f23a14e 100644
--- a/chrome/test/data/is_search_provider_installed.html
+++ b/chrome/test/data/is_search_provider_installed.html
@@ -39,53 +39,58 @@ function writeResult() {
}
}
-try {
- var differentProtocol =
- document.location.protocol == "http:" ? "https:" : "http:";
- var differentPort =
- (!document.location.port || document.location.port == "80") ? ":81" : ":80";
+function main() {
+ try {
+ var differentProtocol =
+ document.location.protocol == "http:" ? "https:" : "http:";
+ var differentPort =
+ (!document.location.port || document.location.port == "80") ? ":81" : ":80";
- var origin = document.location.protocol + "//" + document.location.host + "/";
- var originWithDifferentProtocol = differentProtocol + "//" +
- document.location.host + "/";
- var originWithDifferentPort = document.location.protocol + "//" +
- document.location.hostname + differentPort + "/";
+ var origin =
+ document.location.protocol + "//" + document.location.host + "/";
+ var originWithDifferentProtocol = differentProtocol + "//" +
+ document.location.host + "/";
+ var originWithDifferentPort = document.location.protocol + "//" +
+ document.location.hostname + differentPort + "/";
- // Verify existence of the api.
- var foundApi = false;
- try {
- if (window.external.IsSearchProviderInstalled)
- foundApi = true;
- } catch (e) {
- }
+ // Verify existence of the api.
+ var foundApi = false;
+ try {
+ if (window.external.IsSearchProviderInstalled)
+ foundApi = true;
+ } catch (e) {}
- if (foundApi)
- logPassed("IsSearchProvider api exists.");
- else {
- logFailed("IsSearchProvider api doesn't exist.");
- writeResult();
- return;
- }
+ if (foundApi) {
+ logPassed("IsSearchProvider api exists.");
+ } else {
+ logFailed("IsSearchProvider api doesn't exist.");
+ writeResult();
+ return;
+ }
- // Verify the search provider state for the current page.
- var installed = window.external.IsSearchProviderInstalled(origin)
- var installedMessage = "Search provider ("+ origin +"): " + installed + ".";
- if (installed == document.location.hash.substring(1))
- logPassed(installedMessage);
- else
- logFailed(installedMessage + " The expected result is passed as the hash.");
+ // Verify the search provider state for the current page.
+ var installed = window.external.IsSearchProviderInstalled(origin)
+ var installedMessage = "Search provider ("+ origin +"): " + installed + ".";
+ if (installed == document.location.hash.substring(1)) {
+ logPassed(installedMessage);
+ } else {
+ logFailed(installedMessage +
+ " The expected result is passed as the hash.");
+ }
- // Verify that cases that should result in exceptions.
- verifyExceptionFor("different host", "http://example.org/");
- verifyExceptionFor("different protocol", originWithDifferentProtocol);
- verifyExceptionFor("different port", originWithDifferentPort);
+ // Verify that cases that should result in exceptions.
+ verifyExceptionFor("different host", "http://example.org/");
+ verifyExceptionFor("different protocol", originWithDifferentProtocol);
+ verifyExceptionFor("different port", originWithDifferentPort);
- writeResult();
-} catch (e) {
- logFailed("An exception occurred. Name: " + e.name + " Message: " +
- e.message);
- writeResult();
+ writeResult();
+ } catch (e) {
+ logFailed("An exception occurred. Name: " + e.name + " Message: " +
+ e.message);
+ writeResult();
+ }
}
+main();
</script>
</body>
</html>