| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | |
| 6 | |
| 7 #include <set> | 5 #include <set> |
| 8 | 6 |
| 9 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| 11 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
| 15 #include "chrome/test/testing_profile.h" | 14 #include "chrome/test/testing_profile.h" |
| 16 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 17 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h
" | 16 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h
" |
| 18 #include "content/browser/geolocation/location_arbitrator.h" | 17 #include "content/browser/geolocation/location_arbitrator.h" |
| 19 #include "content/browser/geolocation/location_provider.h" | 18 #include "content/browser/geolocation/location_provider.h" |
| 20 #include "content/browser/geolocation/mock_location_provider.h" | 19 #include "content/browser/geolocation/mock_location_provider.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 204 |
| 206 | 205 |
| 207 // Tests ---------------------------------------------------------------------- | 206 // Tests ---------------------------------------------------------------------- |
| 208 | 207 |
| 209 TEST_F(GeolocationPermissionContextTests, SinglePermission) { | 208 TEST_F(GeolocationPermissionContextTests, SinglePermission) { |
| 210 GURL requesting_frame("http://www.example.com/geolocation"); | 209 GURL requesting_frame("http://www.example.com/geolocation"); |
| 211 NavigateAndCommit(requesting_frame); | 210 NavigateAndCommit(requesting_frame); |
| 212 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 211 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 213 geolocation_permission_context_->RequestGeolocationPermission( | 212 geolocation_permission_context_->RequestGeolocationPermission( |
| 214 process_id(), render_id(), bridge_id(), requesting_frame); | 213 process_id(), render_id(), bridge_id(), requesting_frame); |
| 215 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 214 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 215 ConfirmInfoBarDelegate* infobar_0 = |
| 216 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 217 infobar_0->Cancel(); |
| 218 contents_wrapper()->RemoveInfoBar(infobar_0); |
| 219 EXPECT_EQ(1U, closed_delegate_tracker_.size()); |
| 220 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); |
| 221 infobar_0->InfoBarClosed(); |
| 216 } | 222 } |
| 217 | 223 |
| 218 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { | 224 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { |
| 219 GURL requesting_frame_0("http://www.example.com/geolocation"); | 225 GURL requesting_frame_0("http://www.example.com/geolocation"); |
| 220 GURL requesting_frame_1("http://www.example-2.com/geolocation"); | 226 GURL requesting_frame_1("http://www.example-2.com/geolocation"); |
| 221 EXPECT_EQ(CONTENT_SETTING_ASK, | 227 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 222 profile()->GetGeolocationContentSettingsMap()->GetContentSetting( | 228 profile()->GetGeolocationContentSettingsMap()->GetContentSetting( |
| 223 requesting_frame_0, requesting_frame_0)); | 229 requesting_frame_0, requesting_frame_0)); |
| 224 EXPECT_EQ(CONTENT_SETTING_ASK, | 230 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 225 profile()->GetGeolocationContentSettingsMap()->GetContentSetting( | 231 profile()->GetGeolocationContentSettingsMap()->GetContentSetting( |
| 226 requesting_frame_1, requesting_frame_0)); | 232 requesting_frame_1, requesting_frame_0)); |
| 227 | 233 |
| 228 NavigateAndCommit(requesting_frame_0); | 234 NavigateAndCommit(requesting_frame_0); |
| 229 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 235 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 230 // Request permission for two frames. | 236 // Request permission for two frames. |
| 231 geolocation_permission_context_->RequestGeolocationPermission( | 237 geolocation_permission_context_->RequestGeolocationPermission( |
| 232 process_id(), render_id(), bridge_id(), requesting_frame_0); | 238 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 233 geolocation_permission_context_->RequestGeolocationPermission( | 239 geolocation_permission_context_->RequestGeolocationPermission( |
| 234 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); | 240 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); |
| 235 // Ensure only one infobar is created. | 241 // Ensure only one infobar is created. |
| 236 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 242 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 237 ConfirmInfoBarDelegate* infobar_0 = | 243 ConfirmInfoBarDelegate* infobar_0 = |
| 238 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 244 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 239 ASSERT_TRUE(infobar_0); | 245 ASSERT_TRUE(infobar_0); |
| 240 string16 text_0 = infobar_0->GetMessageText(); | 246 string16 text_0 = infobar_0->GetMessageText(); |
| 241 | 247 |
| 242 // Accept the first frame. | 248 // Accept the first frame. |
| 243 infobar_0->Accept(); | 249 infobar_0->Accept(); |
| 244 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); | 250 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); |
| 245 CheckPermissionMessageSent(bridge_id(), true); | 251 CheckPermissionMessageSent(bridge_id(), true); |
| 246 | 252 |
| 247 contents_wrapper()->RemoveInfoBar(infobar_0); | 253 contents_wrapper()->RemoveInfoBar(infobar_0); |
| 248 EXPECT_EQ(1U, closed_delegate_tracker_.size()); | 254 EXPECT_EQ(1U, closed_delegate_tracker_.size()); |
| 249 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); | 255 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); |
| 250 closed_delegate_tracker_.Clear(); | 256 closed_delegate_tracker_.Clear(); |
| 251 infobar_0->InfoBarClosed(); | 257 infobar_0->InfoBarClosed(); |
| 252 // Now we should have a new infobar for the second frame. | 258 // Now we should have a new infobar for the second frame. |
| 253 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 259 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 254 | 260 |
| 255 ConfirmInfoBarDelegate* infobar_1 = | 261 ConfirmInfoBarDelegate* infobar_1 = |
| 256 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 262 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 257 ASSERT_TRUE(infobar_1); | 263 ASSERT_TRUE(infobar_1); |
| 258 string16 text_1 = infobar_1->GetMessageText(); | 264 string16 text_1 = infobar_1->GetMessageText(); |
| 259 EXPECT_NE(text_0, text_1); | 265 EXPECT_NE(text_0, text_1); |
| 260 | 266 |
| 261 // Cancel (block) this frame. | 267 // Cancel (block) this frame. |
| 262 infobar_1->Cancel(); | 268 infobar_1->Cancel(); |
| 263 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); | 269 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 286 profile()->GetGeolocationContentSettingsMap()->GetContentSetting( | 292 profile()->GetGeolocationContentSettingsMap()->GetContentSetting( |
| 287 requesting_frame_1, requesting_frame_0)); | 293 requesting_frame_1, requesting_frame_0)); |
| 288 | 294 |
| 289 NavigateAndCommit(requesting_frame_0); | 295 NavigateAndCommit(requesting_frame_0); |
| 290 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 296 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 291 // Request permission for two frames. | 297 // Request permission for two frames. |
| 292 geolocation_permission_context_->RequestGeolocationPermission( | 298 geolocation_permission_context_->RequestGeolocationPermission( |
| 293 process_id(), render_id(), bridge_id(), requesting_frame_0); | 299 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 294 geolocation_permission_context_->RequestGeolocationPermission( | 300 geolocation_permission_context_->RequestGeolocationPermission( |
| 295 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); | 301 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); |
| 296 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 302 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 297 | 303 |
| 298 ConfirmInfoBarDelegate* infobar_0 = | 304 ConfirmInfoBarDelegate* infobar_0 = |
| 299 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 305 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 300 ASSERT_TRUE(infobar_0); | 306 ASSERT_TRUE(infobar_0); |
| 301 string16 text_0 = infobar_0->GetMessageText(); | 307 string16 text_0 = infobar_0->GetMessageText(); |
| 302 | 308 |
| 303 // Simulate the frame going away, ensure the infobar for this frame | 309 // Simulate the frame going away, ensure the infobar for this frame |
| 304 // is removed and the next pending infobar is created. | 310 // is removed and the next pending infobar is created. |
| 305 geolocation_permission_context_->CancelGeolocationPermissionRequest( | 311 geolocation_permission_context_->CancelGeolocationPermissionRequest( |
| 306 process_id(), render_id(), bridge_id(), requesting_frame_0); | 312 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 307 EXPECT_EQ(1U, closed_delegate_tracker_.size()); | 313 EXPECT_EQ(1U, closed_delegate_tracker_.size()); |
| 308 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); | 314 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); |
| 309 closed_delegate_tracker_.Clear(); | 315 closed_delegate_tracker_.Clear(); |
| 310 infobar_0->InfoBarClosed(); | 316 infobar_0->InfoBarClosed(); |
| 311 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 317 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 312 | 318 |
| 313 ConfirmInfoBarDelegate* infobar_1 = | 319 ConfirmInfoBarDelegate* infobar_1 = |
| 314 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 320 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 315 ASSERT_TRUE(infobar_1); | 321 ASSERT_TRUE(infobar_1); |
| 316 string16 text_1 = infobar_1->GetMessageText(); | 322 string16 text_1 = infobar_1->GetMessageText(); |
| 317 EXPECT_NE(text_0, text_1); | 323 EXPECT_NE(text_0, text_1); |
| 318 | 324 |
| 319 // Allow this frame. | 325 // Allow this frame. |
| 320 infobar_1->Accept(); | 326 infobar_1->Accept(); |
| 321 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); | 327 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 348 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { | 354 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { |
| 349 GURL url_a("http://www.example.com/geolocation"); | 355 GURL url_a("http://www.example.com/geolocation"); |
| 350 GURL url_b("http://www.example-2.com/geolocation"); | 356 GURL url_b("http://www.example-2.com/geolocation"); |
| 351 NavigateAndCommit(url_a); | 357 NavigateAndCommit(url_a); |
| 352 AddNewTab(url_b); | 358 AddNewTab(url_b); |
| 353 AddNewTab(url_a); | 359 AddNewTab(url_a); |
| 354 | 360 |
| 355 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 361 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 356 geolocation_permission_context_->RequestGeolocationPermission( | 362 geolocation_permission_context_->RequestGeolocationPermission( |
| 357 process_id(), render_id(), bridge_id(), url_a); | 363 process_id(), render_id(), bridge_id(), url_a); |
| 358 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 364 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 359 | 365 |
| 360 geolocation_permission_context_->RequestGeolocationPermission( | 366 geolocation_permission_context_->RequestGeolocationPermission( |
| 361 process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_b); | 367 process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_b); |
| 362 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); | 368 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); |
| 363 | 369 |
| 364 geolocation_permission_context_->RequestGeolocationPermission( | 370 geolocation_permission_context_->RequestGeolocationPermission( |
| 365 process_id_for_tab(1), render_id_for_tab(1), bridge_id(), url_a); | 371 process_id_for_tab(1), render_id_for_tab(1), bridge_id(), url_a); |
| 366 EXPECT_EQ(1U, extra_tabs_[1]->infobar_count()); | 372 ASSERT_EQ(1U, extra_tabs_[1]->infobar_count()); |
| 367 | 373 |
| 368 ConfirmInfoBarDelegate* removed_infobar = | 374 ConfirmInfoBarDelegate* removed_infobar = |
| 369 extra_tabs_[1]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 375 extra_tabs_[1]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 370 | 376 |
| 371 // Accept the first tab. | 377 // Accept the first tab. |
| 372 ConfirmInfoBarDelegate* infobar_0 = | 378 ConfirmInfoBarDelegate* infobar_0 = |
| 373 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 379 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 374 ASSERT_TRUE(infobar_0); | 380 ASSERT_TRUE(infobar_0); |
| 375 infobar_0->Accept(); | 381 infobar_0->Accept(); |
| 376 CheckPermissionMessageSent(bridge_id(), true); | 382 CheckPermissionMessageSent(bridge_id(), true); |
| 377 contents_wrapper()->RemoveInfoBar(infobar_0); | 383 contents_wrapper()->RemoveInfoBar(infobar_0); |
| 378 EXPECT_EQ(2U, closed_delegate_tracker_.size()); | 384 EXPECT_EQ(2U, closed_delegate_tracker_.size()); |
| 379 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); | 385 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); |
| 380 infobar_0->InfoBarClosed(); | 386 infobar_0->InfoBarClosed(); |
| 381 // Now the infobar for the tab with the same origin should have gone. | 387 // Now the infobar for the tab with the same origin should have gone. |
| 382 EXPECT_EQ(0U, extra_tabs_[1]->infobar_count()); | 388 EXPECT_EQ(0U, extra_tabs_[1]->infobar_count()); |
| 383 CheckPermissionMessageSentForTab(1, bridge_id(), true); | 389 CheckPermissionMessageSentForTab(1, bridge_id(), true); |
| 384 EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); | 390 EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); |
| 391 closed_delegate_tracker_.Clear(); |
| 385 // Destroy the infobar that has just been removed. | 392 // Destroy the infobar that has just been removed. |
| 386 removed_infobar->InfoBarClosed(); | 393 removed_infobar->InfoBarClosed(); |
| 387 | 394 |
| 388 // But the other tab should still have the info bar... | 395 // But the other tab should still have the info bar... |
| 389 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); | 396 ASSERT_EQ(1U, extra_tabs_[0]->infobar_count()); |
| 397 ConfirmInfoBarDelegate* infobar_1 = |
| 398 extra_tabs_[0]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 399 infobar_1->Cancel(); |
| 400 extra_tabs_[0]->RemoveInfoBar(infobar_1); |
| 401 EXPECT_EQ(1U, closed_delegate_tracker_.size()); |
| 402 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); |
| 403 infobar_1->InfoBarClosed(); |
| 404 |
| 390 extra_tabs_.reset(); | 405 extra_tabs_.reset(); |
| 391 } | 406 } |
| 392 | 407 |
| 393 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { | 408 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { |
| 394 GURL url_a("http://www.example.com/geolocation"); | 409 GURL url_a("http://www.example.com/geolocation"); |
| 395 GURL url_b("http://www.example-2.com/geolocation"); | 410 GURL url_b("http://www.example-2.com/geolocation"); |
| 396 NavigateAndCommit(url_a); | 411 NavigateAndCommit(url_a); |
| 397 AddNewTab(url_a); | 412 AddNewTab(url_a); |
| 398 | 413 |
| 399 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 414 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 400 geolocation_permission_context_->RequestGeolocationPermission( | 415 geolocation_permission_context_->RequestGeolocationPermission( |
| 401 process_id(), render_id(), bridge_id(), url_a); | 416 process_id(), render_id(), bridge_id(), url_a); |
| 402 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 417 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 403 | 418 |
| 404 geolocation_permission_context_->RequestGeolocationPermission( | 419 geolocation_permission_context_->RequestGeolocationPermission( |
| 405 process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_a); | 420 process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_a); |
| 406 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); | 421 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); |
| 407 | 422 |
| 408 geolocation_permission_context_->RequestGeolocationPermission( | 423 geolocation_permission_context_->RequestGeolocationPermission( |
| 409 process_id_for_tab(0), render_id_for_tab(0), bridge_id() + 1, url_b); | 424 process_id_for_tab(0), render_id_for_tab(0), bridge_id() + 1, url_b); |
| 410 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); | 425 ASSERT_EQ(1U, extra_tabs_[0]->infobar_count()); |
| 411 | 426 |
| 412 ConfirmInfoBarDelegate* removed_infobar = | 427 ConfirmInfoBarDelegate* removed_infobar = |
| 413 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 428 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 414 | 429 |
| 415 // Accept the second tab. | 430 // Accept the second tab. |
| 416 ConfirmInfoBarDelegate* infobar_0 = | 431 ConfirmInfoBarDelegate* infobar_0 = |
| 417 extra_tabs_[0]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 432 extra_tabs_[0]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 418 ASSERT_TRUE(infobar_0); | 433 ASSERT_TRUE(infobar_0); |
| 419 infobar_0->Accept(); | 434 infobar_0->Accept(); |
| 420 CheckPermissionMessageSentForTab(0, bridge_id(), true); | 435 CheckPermissionMessageSentForTab(0, bridge_id(), true); |
| 421 extra_tabs_[0]->RemoveInfoBar(infobar_0); | 436 extra_tabs_[0]->RemoveInfoBar(infobar_0); |
| 422 EXPECT_EQ(2U, closed_delegate_tracker_.size()); | 437 EXPECT_EQ(2U, closed_delegate_tracker_.size()); |
| 423 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); | 438 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); |
| 424 infobar_0->InfoBarClosed(); | 439 infobar_0->InfoBarClosed(); |
| 425 // Now the infobar for the tab with the same origin should have gone. | 440 // Now the infobar for the tab with the same origin should have gone. |
| 426 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 441 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 427 CheckPermissionMessageSent(bridge_id(), true); | 442 CheckPermissionMessageSent(bridge_id(), true); |
| 428 EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); | 443 EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); |
| 429 closed_delegate_tracker_.Clear(); | 444 closed_delegate_tracker_.Clear(); |
| 430 // Destroy the infobar that has just been removed. | 445 // Destroy the infobar that has just been removed. |
| 431 removed_infobar->InfoBarClosed(); | 446 removed_infobar->InfoBarClosed(); |
| 432 | 447 |
| 433 // And we should have the queued infobar displayed now. | 448 // And we should have the queued infobar displayed now. |
| 434 EXPECT_EQ(1U, extra_tabs_[0]->infobar_count()); | 449 ASSERT_EQ(1U, extra_tabs_[0]->infobar_count()); |
| 435 | 450 |
| 436 // Accept the second infobar. | 451 // Accept the second infobar. |
| 437 ConfirmInfoBarDelegate* infobar_1 = | 452 ConfirmInfoBarDelegate* infobar_1 = |
| 438 extra_tabs_[0]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 453 extra_tabs_[0]->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 439 ASSERT_TRUE(infobar_1); | 454 ASSERT_TRUE(infobar_1); |
| 440 infobar_1->Accept(); | 455 infobar_1->Accept(); |
| 441 CheckPermissionMessageSentForTab(0, bridge_id() + 1, true); | 456 CheckPermissionMessageSentForTab(0, bridge_id() + 1, true); |
| 442 extra_tabs_[0]->RemoveInfoBar(infobar_1); | 457 extra_tabs_[0]->RemoveInfoBar(infobar_1); |
| 443 EXPECT_EQ(1U, closed_delegate_tracker_.size()); | 458 EXPECT_EQ(1U, closed_delegate_tracker_.size()); |
| 444 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); | 459 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 460 requesting_frame_1, requesting_frame_0)); | 475 requesting_frame_1, requesting_frame_0)); |
| 461 | 476 |
| 462 NavigateAndCommit(requesting_frame_0); | 477 NavigateAndCommit(requesting_frame_0); |
| 463 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); | 478 EXPECT_EQ(0U, contents_wrapper()->infobar_count()); |
| 464 // Request permission for two frames. | 479 // Request permission for two frames. |
| 465 geolocation_permission_context_->RequestGeolocationPermission( | 480 geolocation_permission_context_->RequestGeolocationPermission( |
| 466 process_id(), render_id(), bridge_id(), requesting_frame_0); | 481 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 467 geolocation_permission_context_->RequestGeolocationPermission( | 482 geolocation_permission_context_->RequestGeolocationPermission( |
| 468 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); | 483 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); |
| 469 // Ensure only one infobar is created. | 484 // Ensure only one infobar is created. |
| 470 EXPECT_EQ(1U, contents_wrapper()->infobar_count()); | 485 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
| 471 ConfirmInfoBarDelegate* infobar_0 = | 486 ConfirmInfoBarDelegate* infobar_0 = |
| 472 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 487 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 473 ASSERT_TRUE(infobar_0); | 488 ASSERT_TRUE(infobar_0); |
| 474 string16 text_0 = infobar_0->GetMessageText(); | |
| 475 | 489 |
| 476 // Delete the tab contents. | 490 // Delete the tab contents. |
| 477 DeleteContents(); | 491 DeleteContents(); |
| 492 infobar_0->InfoBarClosed(); |
| 478 } | 493 } |
| OLD | NEW |