Index: chrome/browser/geolocation/geolocation_browsertest.cc |
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc |
index 3c3b738d70ddf0215f60fb419b03eecf15b164ea..1cb66dec3645df4cc0b346a41d39858c65f1e459 100644 |
--- a/chrome/browser/geolocation/geolocation_browsertest.cc |
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc |
@@ -19,6 +19,7 @@ |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
+#include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/content_settings_pattern.h" |
#include "chrome/test/base/in_process_browser_test.h" |
@@ -121,14 +122,75 @@ void IFrameLoader::Observe(int type, |
base::MessageLoopForUI::current()->Quit(); |
} |
+class MockView : public PermissionBubbleView { |
+ public: |
+ MockView() : shown_(false), can_accept_updates_(true), delegate_(NULL) {} |
+ virtual ~MockView() {} |
+ |
+ void Clear() { |
+ shown_ = false; |
+ can_accept_updates_ = true; |
+ delegate_ = NULL; |
+ permission_requests_.clear(); |
+ permission_states_.clear(); |
+ } |
+ |
+ // PermissionBubbleView: |
+ virtual void SetDelegate(Delegate* delegate) OVERRIDE { |
+ delegate_ = delegate; |
+ } |
+ |
+ virtual void Show( |
+ const std::vector<PermissionBubbleRequest*>& requests, |
+ const std::vector<bool>& accept_state, |
+ bool customization_state_) OVERRIDE { |
+LOG(INFO) << "Mock view shown"; |
+ shown_ = true; |
+ permission_requests_ = requests; |
+ permission_states_ = accept_state; |
+ base::MessageLoopForUI::current()->Quit(); |
+ } |
+ |
+ virtual void Hide() OVERRIDE { |
+ shown_ = false; |
+ } |
+ |
+ virtual bool IsVisible() OVERRIDE { |
+ return shown_; |
+ } |
+ |
+ virtual bool CanAcceptRequestUpdate() OVERRIDE { |
+ return can_accept_updates_; |
+ } |
+ |
+ void Accept() { |
+ delegate_->Accept(); |
+ } |
+ |
+ void Deny() { |
+ delegate_->Deny(); |
+ } |
+ |
+ void Close() { |
+ delegate_->Closing(); |
+ } |
+ |
+ bool shown_; |
+ bool can_accept_updates_; |
+ Delegate* delegate_; |
+ std::vector<PermissionBubbleRequest*> permission_requests_; |
+ std::vector<bool> permission_states_; |
+}; |
+ |
// GeolocationNotificationObserver -------------------------------------------- |
class GeolocationNotificationObserver : public content::NotificationObserver { |
public: |
- // If |wait_for_infobar| is true, AddWatchAndWaitForNotification will block |
- // until the infobar has been displayed; otherwise it will block until the |
+ // If |wait_for_prompt| is true, AddWatchAndWaitForNotification will block |
+ // until the prompt has been displayed; otherwise it will block until the |
// navigation is completed. |
- explicit GeolocationNotificationObserver(bool wait_for_infobar); |
+ explicit GeolocationNotificationObserver(bool wait_for_prompt, |
+ MockView* view); |
virtual ~GeolocationNotificationObserver(); |
// content::NotificationObserver: |
@@ -136,6 +198,7 @@ class GeolocationNotificationObserver : public content::NotificationObserver { |
const content::NotificationSource& source, |
const content::NotificationDetails& details) OVERRIDE; |
+ // Note: also runs the 'geoStart' method in the test JS script. |
void AddWatchAndWaitForNotification( |
content::RenderFrameHost* render_frame_host); |
@@ -144,26 +207,31 @@ class GeolocationNotificationObserver : public content::NotificationObserver { |
private: |
content::NotificationRegistrar registrar_; |
- bool wait_for_infobar_; |
+ bool wait_for_prompt_; |
infobars::InfoBar* infobar_; |
bool navigation_started_; |
bool navigation_completed_; |
std::string javascript_response_; |
+ MockView* mock_view_; |
DISALLOW_COPY_AND_ASSIGN(GeolocationNotificationObserver); |
}; |
GeolocationNotificationObserver::GeolocationNotificationObserver( |
- bool wait_for_infobar) |
- : wait_for_infobar_(wait_for_infobar), |
+ bool wait_for_prompt, |
+ MockView* view) |
+ : wait_for_prompt_(wait_for_prompt), |
infobar_(NULL), |
navigation_started_(false), |
- navigation_completed_(false) { |
+ navigation_completed_(false), |
+ mock_view_(view) { |
registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, |
content::NotificationService::AllSources()); |
- if (wait_for_infobar) { |
- registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
- content::NotificationService::AllSources()); |
+ if (wait_for_prompt) { |
+ if (!PermissionBubbleManager::Enabled()) { |
+ registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
+ content::NotificationService::AllSources()); |
+ } |
} else { |
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
content::NotificationService::AllSources()); |
@@ -189,6 +257,8 @@ void GeolocationNotificationObserver::Observe( |
content::Details<DomOperationNotificationDetails> dom_op_details(details); |
javascript_response_ = dom_op_details->json; |
LOG(WARNING) << "javascript_response " << javascript_response_; |
+ if (wait_for_prompt_ && PermissionBubbleManager::Enabled()) |
+ base::MessageLoopForUI::current()->Quit(); |
} else if ((type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) || |
(type == content::NOTIFICATION_LOAD_START)) { |
navigation_started_ = true; |
@@ -199,23 +269,38 @@ void GeolocationNotificationObserver::Observe( |
// We're either waiting for just the infobar, or for both a javascript |
// prompt and response. |
- if ((wait_for_infobar_ && infobar_) || |
- (navigation_completed_ && !javascript_response_.empty())) |
+ if ((wait_for_prompt_ && infobar_ && !PermissionBubbleManager::Enabled()) || |
+ (navigation_completed_ && !javascript_response_.empty())) { |
base::MessageLoopForUI::current()->Quit(); |
+ } |
} |
void GeolocationNotificationObserver::AddWatchAndWaitForNotification( |
content::RenderFrameHost* render_frame_host) { |
- LOG(WARNING) << "will add geolocation watch"; |
- std::string script( |
- "window.domAutomationController.setAutomationId(0);" |
- "window.domAutomationController.send(geoStart());"); |
- render_frame_host->ExecuteJavaScript(base::UTF8ToUTF16(script)); |
- content::RunMessageLoop(); |
- registrar_.RemoveAll(); |
- LOG(WARNING) << "got geolocation watch" << javascript_response_; |
- EXPECT_NE("\"0\"", javascript_response_); |
- EXPECT_TRUE(wait_for_infobar_ ? (infobar_ != NULL) : navigation_completed_); |
+ if (!PermissionBubbleManager::Enabled()) { |
+ LOG(WARNING) << "will add geolocation watch"; |
+ std::string script( |
+ "window.domAutomationController.setAutomationId(0);" |
+ "window.domAutomationController.send(geoStart());"); |
+ render_frame_host->ExecuteJavaScript(base::UTF8ToUTF16(script)); |
+ content::RunMessageLoop(); |
+ registrar_.RemoveAll(); |
+ LOG(WARNING) << "got geolocation watch" << javascript_response_; |
+ EXPECT_NE("\"0\"", javascript_response_); |
+ EXPECT_TRUE(wait_for_prompt_ ? (infobar_ != NULL) : navigation_completed_); |
+ } else { |
+ LOG(WARNING) << "will add geolocation watch for bubble"; |
+ std::string script( |
+ "window.domAutomationController.setAutomationId(0);" |
+ "window.domAutomationController.send(geoStart());"); |
+ render_frame_host->ExecuteJavaScript(base::UTF8ToUTF16(script)); |
+LOG(INFO) << "run..."; |
+ (new content::MessageLoopRunner())->Run(); |
+ while (wait_for_prompt_ && !mock_view_->shown_) { |
+ (new content::MessageLoopRunner())->Run(); |
+ } |
+LOG(INFO) << "Watch done"; |
+ } |
} |
} // namespace |
@@ -225,10 +310,10 @@ void GeolocationNotificationObserver::AddWatchAndWaitForNotification( |
// This is a browser test for Geolocation. |
// It exercises various integration points from javascript <-> browser: |
-// 1. Infobar is displayed when a geolocation is requested from an unauthorized |
+// 1. Prompt is displayed when a geolocation is requested from an unauthorized |
// origin. |
-// 2. Denying the infobar triggers the correct error callback. |
-// 3. Allowing the infobar does not trigger an error, and allow a geoposition to |
+// 2. Denying the request triggers the correct error callback. |
+// 3. Allowing the request does not trigger an error, and allow a geoposition to |
// be passed to javascript. |
// 4. Permissions persisted in disk are respected. |
// 5. Incognito profiles don't use saved permissions. |
@@ -267,19 +352,19 @@ class GeolocationBrowserTest : public InProcessBrowserTest { |
// Specifies which frame is to be used for JavaScript calls. |
void SetFrameHost(const std::string& frame_name); |
- // Start watching for geolocation notifications. If |wait_for_infobar| is |
- // true, wait for the infobar to be displayed. Otherwise wait for a javascript |
- // response. |
- void AddGeolocationWatch(bool wait_for_infobar); |
+ // Start watching for geolocation notifications. If |wait_for_prompt| is |
+ // true, wait for the prompt (infobar or bubble) to be displayed. |
+ // Otherwise wait for a javascript response. |
+ void AddGeolocationWatch(bool wait_for_prompt); |
// Checks that no errors have been received in javascript, and checks that the |
// position most recently received in javascript matches |latitude| and |
// |longitude|. |
void CheckGeoposition(double latitude, double longitude); |
- // For |requesting_url| if |allowed| is true accept the infobar. Otherwise |
- // cancel it. |
- void SetInfoBarResponse(const GURL& requesting_url, bool allowed); |
+ // For |requesting_url| if |allowed| is true accept the geolocation request. |
+ // Otherwise cancel it. |
+ void SetPromptResponse(const GURL& requesting_url, bool allowed); |
// Executes |function| in |render_frame_host| and checks that the return value |
// matches |expected|. |
@@ -309,6 +394,8 @@ class GeolocationBrowserTest : public InProcessBrowserTest { |
double fake_latitude_; |
double fake_longitude_; |
+ MockView mock_bubble_view_; |
+ |
DISALLOW_COPY_AND_ASSIGN(GeolocationBrowserTest); |
}; |
@@ -344,10 +431,18 @@ bool GeolocationBrowserTest::Initialize(InitializationOptions options) { |
if (options == INITIALIZATION_OFFTHERECORD) { |
current_browser_ = ui_test_utils::OpenURLOffTheRecord( |
browser()->profile(), current_url_); |
+ WebContents* web_contents = |
+ current_browser_->tab_strip_model()->GetActiveWebContents(); |
+ PermissionBubbleManager::FromWebContents(web_contents)->SetView( |
+ &mock_bubble_view_); |
} else { |
current_browser_ = browser(); |
if (options == INITIALIZATION_NEWTAB) |
chrome::NewTab(current_browser_); |
+ WebContents* web_contents = |
+ current_browser_->tab_strip_model()->GetActiveWebContents(); |
+ PermissionBubbleManager::FromWebContents(web_contents)->SetView( |
+ &mock_bubble_view_); |
ui_test_utils::NavigateToURL(current_browser_, current_url_); |
} |
LOG(WARNING) << "after navigate"; |
@@ -381,12 +476,16 @@ void GeolocationBrowserTest::SetFrameHost(const std::string& frame_name) { |
DCHECK(render_frame_host_); |
} |
-void GeolocationBrowserTest::AddGeolocationWatch(bool wait_for_infobar) { |
- GeolocationNotificationObserver notification_observer(wait_for_infobar); |
+void GeolocationBrowserTest::AddGeolocationWatch(bool wait_for_prompt) { |
+LOG(INFO) << "Adding geo watch"; |
+ GeolocationNotificationObserver notification_observer( |
+ wait_for_prompt, &mock_bubble_view_); |
notification_observer.AddWatchAndWaitForNotification(render_frame_host_); |
- if (wait_for_infobar) { |
+ if (wait_for_prompt && !PermissionBubbleManager::Enabled()) { |
EXPECT_TRUE(notification_observer.has_infobar()); |
infobar_ = notification_observer.infobar(); |
+ } else if (wait_for_prompt && PermissionBubbleManager::Enabled()) { |
+ // TODO(gbillock): something. |
} |
} |
@@ -400,40 +499,65 @@ void GeolocationBrowserTest::CheckGeoposition(double latitude, |
"geoGetLastPositionLongitude()"); |
} |
-void GeolocationBrowserTest::SetInfoBarResponse(const GURL& requesting_url, |
- bool allowed) { |
- WebContents* web_contents = |
- current_browser_->tab_strip_model()->GetActiveWebContents(); |
- TabSpecificContentSettings* content_settings = |
- TabSpecificContentSettings::FromWebContents(web_contents); |
- const ContentSettingsUsagesState& usages_state = |
- content_settings->geolocation_usages_state(); |
- size_t state_map_size = usages_state.state_map().size(); |
- ASSERT_TRUE(infobar_); |
- LOG(WARNING) << "will set infobar response"; |
- { |
- content::WindowedNotificationObserver observer( |
- content::NOTIFICATION_LOAD_STOP, |
- content::Source<NavigationController>(&web_contents->GetController())); |
+void GeolocationBrowserTest::SetPromptResponse(const GURL& requesting_url, |
+ bool allowed) { |
+ if (!PermissionBubbleManager::Enabled()) { |
+ WebContents* web_contents = |
+ current_browser_->tab_strip_model()->GetActiveWebContents(); |
+ TabSpecificContentSettings* content_settings = |
+ TabSpecificContentSettings::FromWebContents(web_contents); |
+ const ContentSettingsUsagesState& usages_state = |
+ content_settings->geolocation_usages_state(); |
+ size_t state_map_size = usages_state.state_map().size(); |
+ ASSERT_TRUE(infobar_); |
+ LOG(WARNING) << "will set infobar response"; |
+ { |
+ content::WindowedNotificationObserver observer( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<NavigationController>( |
+ &web_contents->GetController())); |
+ if (allowed) |
+ infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); |
+ else |
+ infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); |
+ observer.Wait(); |
+ } |
+ |
+ InfoBarService* infobar_service = |
+ InfoBarService::FromWebContents(web_contents); |
+ infobar_service->RemoveInfoBar(infobar_); |
+ LOG(WARNING) << "infobar response set"; |
+ infobar_ = NULL; |
+ EXPECT_GT(usages_state.state_map().size(), state_map_size); |
+ GURL requesting_origin(requesting_url.GetOrigin()); |
+ EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); |
+ ContentSetting expected_setting = |
+ allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
+ EXPECT_EQ(expected_setting, |
+ usages_state.state_map().find(requesting_origin)->second); |
+ } else { |
+ LOG(INFO) << "Set allow " << allowed; |
+ WebContents* web_contents = |
+ current_browser_->tab_strip_model()->GetActiveWebContents(); |
+ TabSpecificContentSettings* content_settings = |
+ TabSpecificContentSettings::FromWebContents(web_contents); |
+ const ContentSettingsUsagesState& usages_state = |
+ content_settings->geolocation_usages_state(); |
+ size_t state_map_size = usages_state.state_map().size(); |
+ |
if (allowed) |
- infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); |
+ mock_bubble_view_.Accept(); |
else |
- infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); |
- observer.Wait(); |
+ mock_bubble_view_.Deny(); |
+ |
+ EXPECT_GT(usages_state.state_map().size(), state_map_size); |
+ GURL requesting_origin(requesting_url.GetOrigin()); |
+ EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); |
+ ContentSetting expected_setting = |
+ allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
+ EXPECT_EQ(expected_setting, |
+ usages_state.state_map().find(requesting_origin)->second); |
} |
- |
- InfoBarService* infobar_service = |
- InfoBarService::FromWebContents(web_contents); |
- infobar_service->RemoveInfoBar(infobar_); |
- LOG(WARNING) << "infobar response set"; |
- infobar_ = NULL; |
- EXPECT_GT(usages_state.state_map().size(), state_map_size); |
- GURL requesting_origin(requesting_url.GetOrigin()); |
- EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); |
- ContentSetting expected_setting = |
- allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
- EXPECT_EQ(expected_setting, |
- usages_state.state_map().find(requesting_origin)->second); |
} |
void GeolocationBrowserTest::CheckStringValueFromJavascriptForFrame( |
@@ -445,6 +569,7 @@ void GeolocationBrowserTest::CheckStringValueFromJavascriptForFrame( |
std::string result; |
ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
render_frame_host, script, &result)); |
+LOG(INFO) << "GOT JS RESULT " << result; |
EXPECT_EQ(expected, result); |
} |
@@ -466,7 +591,7 @@ void GeolocationBrowserTest::NotifyGeoposition(double latitude, |
// Tests ---------------------------------------------------------------------- |
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DisplaysPermissionBar) { |
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DisplaysPrompt) { |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
@@ -476,7 +601,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, Geoposition) { |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(current_url(), true); |
+ SetPromptResponse(current_url(), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
} |
@@ -485,28 +610,30 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
- // Infobar was displayed, deny access and check for error code. |
- SetInfoBarResponse(current_url(), false); |
+ // Prompt was displayed, deny access and check for error code. |
+ SetPromptResponse(current_url(), false); |
+ if (PermissionBubbleManager::Enabled()) |
+ content::RunAllPendingInMessageLoop(); |
CheckStringValueFromJavascript("1", "geoGetLastError()"); |
} |
// See http://crbug.com/308358 |
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoInfobarForSecondTab) { |
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoPromptForSecondTab) { |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(current_url(), true); |
+ SetPromptResponse(current_url(), true); |
// Disables further prompts from this tab. |
CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
- // Checks infobar will not be created in a second tab. |
+ // Checks prompt will not be created in a second tab. |
ASSERT_TRUE(Initialize(INITIALIZATION_NEWTAB)); |
SetFrameHost(""); |
AddGeolocationWatch(false); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
} |
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForDeniedOrigin) { |
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoPromptForDeniedOrigin) { |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
current_browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
ContentSettingsPattern::FromURLNoWildcard(current_url()), |
@@ -516,36 +643,36 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForDeniedOrigin) { |
AddGeolocationWatch(false); |
// Checks we have an error for this denied origin. |
CheckStringValueFromJavascript("1", "geoGetLastError()"); |
- // Checks infobar will not be created a second tab. |
+ // Checks prompt will not be created a second tab. |
ASSERT_TRUE(Initialize(INITIALIZATION_NEWTAB)); |
SetFrameHost(""); |
AddGeolocationWatch(false); |
CheckStringValueFromJavascript("1", "geoGetLastError()"); |
} |
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForAllowedOrigin) { |
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoPromptForAllowedOrigin) { |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
current_browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
ContentSettingsPattern::FromURLNoWildcard(current_url()), |
ContentSettingsPattern::FromURLNoWildcard(current_url()), |
CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(), CONTENT_SETTING_ALLOW); |
- // Checks no infobar will be created and there's no error callback. |
+ // Checks no prompt will be created and there's no error callback. |
SetFrameHost(""); |
AddGeolocationWatch(false); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
} |
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForOffTheRecord) { |
- // First, check infobar will be created for regular profile |
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoPromptForOffTheRecord) { |
+ // First, check prompt will be created for regular profile |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
// Response will be persisted. |
- SetInfoBarResponse(current_url(), true); |
+ SetPromptResponse(current_url(), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
// Disables further prompts from this tab. |
CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
- // Go incognito, and checks no infobar will be created. |
+ // Go incognito, and checks no prompt will be created. |
ASSERT_TRUE(Initialize(INITIALIZATION_OFFTHERECORD)); |
SetFrameHost(""); |
AddGeolocationWatch(false); |
@@ -553,20 +680,23 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForOffTheRecord) { |
} |
IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoLeakFromOffTheRecord) { |
- // First, check infobar will be created for incognito profile. |
+ // First, check prompt will be created for incognito profile. |
ASSERT_TRUE(Initialize(INITIALIZATION_OFFTHERECORD)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
// Response won't be persisted. |
- SetInfoBarResponse(current_url(), true); |
+ SetPromptResponse(current_url(), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
// Disables further prompts from this tab. |
CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
- // Go to the regular profile, infobar will be created. |
+ // Go to the regular profile, prompt will be created. |
ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
SetFrameHost(""); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(current_url(), false); |
+LOG(INFO) << "---- Setting respons to false"; |
+ SetPromptResponse(current_url(), false); |
+ if (PermissionBubbleManager::Enabled()) |
+ content::RunAllPendingInMessageLoop(); |
CheckStringValueFromJavascript("1", "geoGetLastError()"); |
} |
@@ -578,13 +708,13 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, IFramesWithFreshPosition) { |
SetFrameHost("iframe_0"); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(iframe_url(0), true); |
+ SetPromptResponse(iframe_url(0), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
// Disables further prompts from this iframe. |
CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
// Test second iframe from a different origin with a cached geoposition will |
- // create the infobar. |
+ // create the prompt. |
SetFrameHost("iframe_1"); |
AddGeolocationWatch(true); |
@@ -607,8 +737,8 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, IFramesWithFreshPosition) { |
// Now go ahead an authorize the second frame. |
SetFrameHost("iframe_1"); |
- // Infobar was displayed, allow access and check there's no error code. |
- SetInfoBarResponse(iframe_url(1), true); |
+ // Prompt was displayed, allow access and check there's no error code. |
+ SetPromptResponse(iframe_url(1), true); |
LOG(WARNING) << "Checking position..."; |
CheckGeoposition(fresh_position_latitude, fresh_position_longitude); |
LOG(WARNING) << "...done."; |
@@ -622,7 +752,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, |
SetFrameHost("iframe_0"); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(iframe_url(0), true); |
+ SetPromptResponse(iframe_url(0), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
// Refresh geoposition, but let's not yet create the watch on the second frame |
@@ -648,7 +778,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, |
// afterwards. We're only interested in the first navigation for the success |
// callback from the cached position. |
CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); |
- SetInfoBarResponse(iframe_url(1), true); |
+ SetPromptResponse(iframe_url(1), true); |
CheckGeoposition(cached_position_latitude, cached_position_lognitude); |
} |
@@ -660,23 +790,27 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, CancelPermissionForFrame) { |
SetFrameHost("iframe_0"); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(iframe_url(0), true); |
+ SetPromptResponse(iframe_url(0), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
// Disables further prompts from this iframe. |
CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
// Test second iframe from a different origin with a cached geoposition will |
- // create the infobar. |
+ // create the prompt. |
SetFrameHost("iframe_1"); |
AddGeolocationWatch(true); |
- InfoBarService* infobar_service = InfoBarService::FromWebContents( |
- current_browser()->tab_strip_model()->GetActiveWebContents()); |
- size_t num_infobars_before_cancel = infobar_service->infobar_count(); |
- // Change the iframe, and ensure the infobar is gone. |
- IFrameLoader change_iframe_1(current_browser(), 1, current_url()); |
- size_t num_infobars_after_cancel = infobar_service->infobar_count(); |
- EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); |
+ if (!PermissionBubbleManager::Enabled()) { |
+ InfoBarService* infobar_service = InfoBarService::FromWebContents( |
+ current_browser()->tab_strip_model()->GetActiveWebContents()); |
+ size_t num_infobars_before_cancel = infobar_service->infobar_count(); |
+ // Change the iframe, and ensure the infobar is gone. |
+ IFrameLoader change_iframe_1(current_browser(), 1, current_url()); |
+ size_t num_infobars_after_cancel = infobar_service->infobar_count(); |
+ EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); |
+ } else { |
+ // TODO(gbillock): something with the queue size? |
+ } |
} |
IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { |
@@ -693,7 +827,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { |
original_tab->GetMainFrame()); |
} |
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfoBarBeforeStart) { |
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoPromptBeforeStart) { |
// See http://crbug.com/42789 |
set_html_for_tests("/geolocation/iframes_different_origin.html"); |
ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); |
@@ -706,14 +840,14 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfoBarBeforeStart) { |
SetFrameHost("iframe_0"); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(iframe_url(0), true); |
+ SetPromptResponse(iframe_url(0), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
// Permission should be requested after adding a watch. |
SetFrameHost("iframe_1"); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(iframe_url(1), true); |
+ SetPromptResponse(iframe_url(1), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
} |
@@ -736,7 +870,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TwoWatchesInOneFrame) { |
// Send a position which both geolocation watches will receive. |
SetFrameHost(""); |
AddGeolocationWatch(true); |
- SetInfoBarResponse(current_url(), true); |
+ SetPromptResponse(current_url(), true); |
CheckGeoposition(fake_latitude(), fake_longitude()); |
// The second watch will now have cancelled. Ensure an update still makes |