diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-01 19:13:15 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-01 19:13:15 +0000 |
commit | a7b7e53c1daeaa5fade446e3f77c1994d5465345 (patch) | |
tree | 3284fec9d6ab04a472f979327ebb6d99f9c1ff02 /chrome/browser/geolocation/geolocation_browsertest.cc | |
parent | 9371970ee8ebd1ed597c1b4cb60da676bc36563c (diff) | |
download | chromium_src-a7b7e53c1daeaa5fade446e3f77c1994d5465345.zip chromium_src-a7b7e53c1daeaa5fade446e3f77c1994d5465345.tar.gz chromium_src-a7b7e53c1daeaa5fade446e3f77c1994d5465345.tar.bz2 |
Follow-up on https://bugs.webkit.org/show_bug.cgi?id=35031:
Implements cancelGeolocationPermissionRequestForFrame()
Queues infobars.
BUG=39686,39804
TEST=geolocation_browsertest.cc
Review URL: http://codereview.chromium.org/1573002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation/geolocation_browsertest.cc')
-rw-r--r-- | chrome/browser/geolocation/geolocation_browsertest.cc | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 64ae282..84100e0 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -32,7 +32,7 @@ // load and wait one single frame here by calling a javascript function. class IFrameLoader : public NotificationObserver { public: - IFrameLoader(Browser* browser, int iframe_id) + IFrameLoader(Browser* browser, int iframe_id, const GURL& url) : navigation_completed_(false), javascript_completed_(false) { NavigationController* controller = @@ -43,8 +43,9 @@ class IFrameLoader : public NotificationObserver { NotificationService::AllSources()); std::string script = StringPrintf( "window.domAutomationController.setAutomationId(0);" - "window.domAutomationController.send(addIFrame(%d));", - iframe_id); + "window.domAutomationController.send(addIFrame(%d, \"%s\"));", + iframe_id, + url.spec().c_str()); browser->GetSelectedTabContents()->render_view_host()-> ExecuteJavascriptInWebFrame(L"", UTF8ToWide(script)); ui_test_utils::RunMessageLoop(); @@ -217,10 +218,10 @@ class GeolocationBrowserTest : public InProcessBrowserTest { } else if (options == INITIALIZATION_IFRAMES) { current_browser_ = browser(); ui_test_utils::NavigateToURL(current_browser_, current_url_); - IFrameLoader iframe0(current_browser_, 0); + IFrameLoader iframe0(current_browser_, 0, GURL()); iframe0_url_ = iframe0.iframe_url(); - IFrameLoader iframe1(current_browser_, 1); + IFrameLoader iframe1(current_browser_, 1, GURL()); iframe1_url_ = iframe1.iframe_url(); } else { current_browser_ = browser(); @@ -275,6 +276,7 @@ class GeolocationBrowserTest : public InProcessBrowserTest { else infobar_->AsConfirmInfoBarDelegate()->Cancel(); WaitForJSPrompt(); + tab_contents->RemoveInfoBar(infobar_); LOG(WARNING) << "infobar response set"; infobar_ = NULL; content_settings = tab_contents->geolocation_content_settings(); @@ -537,3 +539,39 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, SetInfobarResponse(iframe1_url_, true); CheckGeoposition(cached_position); } + + +#if defined(OS_MACOSX) +// TODO(bulach): investigate why this fails on mac. It may be related to: +// http://crbug.com/29424 +#define MAYBE_CancelPermissionForFrame DISABLED_CancelPermissionForFrame +#else +#define MAYBE_CancelPermissionForFrame CancelPermissionForFrame +#endif + +IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, + MAYBE_CancelPermissionForFrame) { + html_for_tests_ = "files/geolocation/iframes_different_origin.html"; + Initialize(INITIALIZATION_IFRAMES); + LOG(WARNING) << "frames loaded"; + + iframe_xpath_ = L"//iframe[@id='iframe_0']"; + AddGeolocationWatch(true); + SetInfobarResponse(iframe0_url_, true); + CheckGeoposition(MockLocationProvider::instance_->position_); + // Disables further prompts from this iframe. + CheckStringValueFromJavascript("false", "geoEnableAlerts(false)"); + + // Test second iframe from a different origin with a cached geoposition will + // create the infobar. + iframe_xpath_ = L"//iframe[@id='iframe_1']"; + AddGeolocationWatch(true); + + int num_infobars_before_cancel = + current_browser_->GetSelectedTabContents()->infobar_delegate_count(); + // Change the iframe, and ensure the infobar is gone. + IFrameLoader change_iframe_1(current_browser_, 1, current_url_); + int num_infobars_after_cancel = + current_browser_->GetSelectedTabContents()->infobar_delegate_count(); + EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); +} |