summaryrefslogtreecommitdiffstats
path: root/chrome/browser/custom_handlers
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 16:59:56 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 16:59:56 +0000
commit3cfa2facc0fc69dda97d470e08a83ffa5a183f9a (patch)
tree760f7a280888360af661ecf93d89b9d076695a54 /chrome/browser/custom_handlers
parent5208144733d893b2411757a14c4599184e021c7e (diff)
downloadchromium_src-3cfa2facc0fc69dda97d470e08a83ffa5a183f9a.zip
chromium_src-3cfa2facc0fc69dda97d470e08a83ffa5a183f9a.tar.gz
chromium_src-3cfa2facc0fc69dda97d470e08a83ffa5a183f9a.tar.bz2
Renable the ProtocolHandlerRegistry tests on Windows. I tracked down the dcheck (not finding an installer string in browser_tests binary) to the fact that we were registering the protocol handler with the OS. It happened on the bots but not locally because it needs Chrome to be running as an admin. I have no idea why this only crashes on my new test but not the existing one on the bots, since locally they both hit the assert when running as an admin.
Review URL: https://chromiumcodereview.appspot.com/9998002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/custom_handlers')
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.h1
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc44
2 files changed, 26 insertions, 19 deletions
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h
index 03c633b..edfb7ab 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.h
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -283,6 +283,7 @@ class ProtocolHandlerRegistry
ProtocolHandlerMap default_handlers_io_;
friend class ProtocolHandlerRegistryTest;
+ friend class RegisterProtocolHandlerBrowserTest;
DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry);
};
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
index 4a082a4..8dd508d 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
@@ -62,6 +62,23 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest {
menu->Init();
return menu;
}
+
+ void AddProtocolHandler(const std::string& protocol,
+ const GURL& url,
+ const string16& title) {
+ ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(
+ protocol, url, title);
+ ProtocolHandlerRegistry* registry =
+ browser()->profile()->GetProtocolHandlerRegistry();
+ // Fake that this registration is happening on profile startup. Otherwise
+ // it'll try to register with the OS, which causes DCHECKs on Windows when
+ // running as admin on Windows 7.
+ registry->is_loading_ = true;
+ registry->OnAcceptRegisterProtocolHandler(handler);
+ registry->is_loading_ = false;
+ ASSERT_TRUE(registry->IsHandledProtocol(protocol));
+ }
+
};
IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest,
@@ -70,35 +87,24 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest,
CreateContextMenu(GURL("http://www.google.com/")));
ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH));
- ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(
- std::string("web+search"),
- GURL("http://www.google.com/%s"),
- UTF8ToUTF16(std::string("Test handler")));
- ProtocolHandlerRegistry* registry =
- browser()->profile()->GetProtocolHandlerRegistry();
- registry->OnAcceptRegisterProtocolHandler(handler);
- ASSERT_TRUE(registry->IsHandledProtocol("web+search"));
-
+ AddProtocolHandler(std::string("web+search"),
+ GURL("http://www.google.com/%s"),
+ UTF8ToUTF16(std::string("Test handler")));
GURL url("web+search:testing");
- ASSERT_EQ(registry->GetHandlersFor(url.scheme()).size(), (size_t) 1);
+ ASSERT_EQ(1u,
+ browser()->profile()->GetProtocolHandlerRegistry()->GetHandlersFor(
+ url.scheme()).size());
menu.reset(CreateContextMenu(url));
ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH));
}
-#if !defined(OS_WIN)
-// TODO(jam): investigate why this crashes on bots sometimes with
-// FATAL:l10n_string_util.cc(39)] Check failed: false. Unable to find resource id 2617
IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, CustomHandler) {
ASSERT_TRUE(test_server()->Start());
GURL handler_url = test_server()->GetURL("files/custom_handler_foo.html");
- ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(
- std::string("foo"), handler_url,
- UTF8ToUTF16(std::string("Test foo Handler")));
- browser()->profile()->GetProtocolHandlerRegistry()->
- OnAcceptRegisterProtocolHandler(handler);
+ AddProtocolHandler("foo", handler_url,
+ UTF8ToUTF16(std::string("Test foo Handler")));
ui_test_utils::NavigateToURL(browser(), GURL("foo:test"));
ASSERT_EQ(handler_url, browser()->GetSelectedWebContents()->GetURL());
}
-#endif