summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-17 10:25:10 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-17 10:25:10 +0000
commita0df54f9b6c13c1dbf03dcc1561caafd3957c106 (patch)
tree7caaedd38c576b712e5bce3d502c0312340c38b8 /chrome
parentf7164f94431fe875f2845c7517b95a3f742b6c1e (diff)
downloadchromium_src-a0df54f9b6c13c1dbf03dcc1561caafd3957c106.zip
chromium_src-a0df54f9b6c13c1dbf03dcc1561caafd3957c106.tar.gz
chromium_src-a0df54f9b6c13c1dbf03dcc1561caafd3957c106.tar.bz2
Adds tests to ensure Geolocation requests permission happens at the right time.
It needs to be after calling navigator.geolocation.getCurrentPosition()/watchPosition() rather than just accessing navigator.geolocation. Depends on https://bugs.webkit.org/show_bug.cgi?id=38323. BUG=42789 TEST=GeolocationBrowserTest.NoInfoBarBeforeStart Review URL: http://codereview.chromium.org/1950001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc32
-rw-r--r--chrome/test/data/geolocation/simple.html3
2 files changed, 35 insertions, 0 deletions
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index 146f955..229c36a 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -610,3 +610,35 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
CheckStringValueFromJavascript("1", "requestGeolocationFromInvalidUrl()");
CheckStringValueFromJavascriptForTab("1", "isAlive()", original_tab);
}
+
+#if defined(OS_MACOSX)
+// TODO(bulach): investigate why this fails on mac. It may be related to:
+// http://crbug.com/29424
+#define MAYBE_NoInfoBarBeforeStart DISABLED_NoInfoBarBeforeStart
+#else
+// TODO(bulach): enable after https://bugs.webkit.org/show_bug.cgi?id=38323
+#define MAYBE_NoInfoBarBeforeStart NoInfoBarBeforeStart
+#endif
+
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfoBarBeforeStart) {
+ // See http://crbug.com/42789
+ html_for_tests_ = "files/geolocation/iframes_different_origin.html";
+ ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES));
+ LOG(WARNING) << "frames loaded";
+
+ // Access navigator.geolocation, but ensure it won't request permission.
+ iframe_xpath_ = L"//iframe[@id='iframe_1']";
+ CheckStringValueFromJavascript("object", "geoAccessNavigatorGeolocation()");
+
+ iframe_xpath_ = L"//iframe[@id='iframe_0']";
+ AddGeolocationWatch(true);
+ SetInfobarResponse(iframe0_url_, true);
+ CheckGeoposition(MockLocationProvider::instance_->position_);
+ CheckStringValueFromJavascript("false", "geoEnableAlerts(false)");
+
+ // Permission should be requested after adding a watch.
+ iframe_xpath_ = L"//iframe[@id='iframe_1']";
+ AddGeolocationWatch(true);
+ SetInfobarResponse(iframe1_url_, true);
+ CheckGeoposition(MockLocationProvider::instance_->position_);
+}
diff --git a/chrome/test/data/geolocation/simple.html b/chrome/test/data/geolocation/simple.html
index a5d7848..4fda2ff 100644
--- a/chrome/test/data/geolocation/simple.html
+++ b/chrome/test/data/geolocation/simple.html
@@ -34,6 +34,9 @@
display_alert = enabled;
return "" + display_alert;
}
+ function geoAccessNavigatorGeolocation() {
+ return "" + typeof(navigator.geolocation);
+ }
</script>
</head>
<body>