summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-13 12:16:06 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-13 12:16:06 +0000
commitd5cc9adad67041911e0230de8ef8033464ae3597 (patch)
tree5f63a52018972660ad946baa62f0c2e5047de5ea
parent534a4ecd47a7d0000158241f2d2d28218974e73e (diff)
downloadchromium_src-d5cc9adad67041911e0230de8ef8033464ae3597.zip
chromium_src-d5cc9adad67041911e0230de8ef8033464ae3597.tar.gz
chromium_src-d5cc9adad67041911e0230de8ef8033464ae3597.tar.bz2
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
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc34
-rw-r--r--chrome/test/data/geolocation/invalid_request_url.html18
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>
+