From d5cc9adad67041911e0230de8ef8033464ae3597 Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Tue, 13 Apr 2010 12:16:06 +0000 Subject: Adds a browser test to exercise WebKit::WebGeolocationServiceBridgeImpl::stopUpdating(). (depends on the fix provided by http://trac.webkit.org/changeset/57335). BUG=40660,40478 TEST=GeolocationBrowserTest.InvalidUrlRequest Review URL: http://codereview.chromium.org/1626011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44346 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/geolocation/geolocation_browsertest.cc | 34 +++++++++++++++++++--- .../test/data/geolocation/invalid_request_url.html | 18 ++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 chrome/test/data/geolocation/invalid_request_url.html 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 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 @@ + + + + + + + -- cgit v1.1