diff options
-rw-r--r-- | chrome/browser/geolocation/geolocation_browsertest.cc | 34 | ||||
-rw-r--r-- | chrome/test/data/geolocation/invalid_request_url.html | 18 |
2 files changed, 48 insertions, 4 deletions
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 84100e0..c238ba4 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -297,15 +297,22 @@ class GeolocationBrowserTest : public InProcessBrowserTest { LOG(WARNING) << "closed JS prompt"; } - void CheckStringValueFromJavascript( - const std::string& expected, const std::string& function) { + void CheckStringValueFromJavascriptForTab( + const std::string& expected, const std::string& function, + TabContents* tab_contents) { std::string script = StringPrintf( "window.domAutomationController.send(%s)", function.c_str()); std::string result; ui_test_utils::ExecuteJavaScriptAndExtractString( - current_browser_->GetSelectedTabContents()->render_view_host(), + tab_contents->render_view_host(), iframe_xpath_, UTF8ToWide(script), &result); - EXPECT_EQ(expected.c_str(), result); + EXPECT_EQ(expected, result); + } + + void CheckStringValueFromJavascript( + const std::string& expected, const std::string& function) { + CheckStringValueFromJavascriptForTab( + expected, function, current_browser_->GetSelectedTabContents()); } scoped_refptr<HTTPTestServer> server_; @@ -575,3 +582,22 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, current_browser_->GetSelectedTabContents()->infobar_delegate_count(); EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); } + +#if defined(OS_MACOSX) +// TODO(bulach): investigate why this fails on mac. It may be related to: +// http://crbug.com/29424 +#define MAYBE_InvalidUrlRequest DISABLED_InvalidUrlRequest +#else +#define MAYBE_InvalidUrlRequest InvalidUrlRequest +#endif + +IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, + MAYBE_InvalidUrlRequest) { + // Tests that an invalid URL (e.g. from a popup window) is rejected + // correctly. Also acts as a regression test for http://crbug.com/40478 + html_for_tests_ = "files/geolocation/invalid_request_url.html"; + Initialize(INITIALIZATION_NONE); + TabContents* original_tab = current_browser_->GetSelectedTabContents(); + CheckStringValueFromJavascript("1", "requestGeolocationFromInvalidUrl()"); + CheckStringValueFromJavascriptForTab("1", "isAlive()", original_tab); +} diff --git a/chrome/test/data/geolocation/invalid_request_url.html b/chrome/test/data/geolocation/invalid_request_url.html new file mode 100644 index 0000000..2897a8b --- /dev/null +++ b/chrome/test/data/geolocation/invalid_request_url.html @@ -0,0 +1,18 @@ +<html> +<head> +<script> +function requestGeolocationFromInvalidUrl() { + var o = window.open(); + o.navigator.geolocation; + o.close(); + delete o; + return "1"; +} +function isAlive() { + return "1"; +} +</script> +</head> +<body></body> +</html> + |