| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 void SetInfobarResponse(const GURL& requesting_url, bool allowed) { | 291 void SetInfobarResponse(const GURL& requesting_url, bool allowed) { |
| 292 TabContents* tab_contents = chrome::GetActiveTabContents(current_browser_); | 292 TabContents* tab_contents = chrome::GetActiveTabContents(current_browser_); |
| 293 TabSpecificContentSettings* content_settings = | 293 TabSpecificContentSettings* content_settings = |
| 294 tab_contents->content_settings(); | 294 tab_contents->content_settings(); |
| 295 const GeolocationSettingsState& settings_state = | 295 const GeolocationSettingsState& settings_state = |
| 296 content_settings->geolocation_settings_state(); | 296 content_settings->geolocation_settings_state(); |
| 297 size_t state_map_size = settings_state.state_map().size(); | 297 size_t state_map_size = settings_state.state_map().size(); |
| 298 ASSERT_TRUE(infobar_); | 298 ASSERT_TRUE(infobar_); |
| 299 LOG(WARNING) << "will set infobar response"; | 299 LOG(WARNING) << "will set infobar response"; |
| 300 { | 300 { |
| 301 ui_test_utils::WindowedNotificationObserver observer( | 301 content::WindowedNotificationObserver observer( |
| 302 content::NOTIFICATION_LOAD_STOP, | 302 content::NOTIFICATION_LOAD_STOP, |
| 303 content::Source<NavigationController>( | 303 content::Source<NavigationController>( |
| 304 &tab_contents->web_contents()->GetController())); | 304 &tab_contents->web_contents()->GetController())); |
| 305 if (allowed) | 305 if (allowed) |
| 306 infobar_->AsConfirmInfoBarDelegate()->Accept(); | 306 infobar_->AsConfirmInfoBarDelegate()->Accept(); |
| 307 else | 307 else |
| 308 infobar_->AsConfirmInfoBarDelegate()->Cancel(); | 308 infobar_->AsConfirmInfoBarDelegate()->Cancel(); |
| 309 observer.Wait(); | 309 observer.Wait(); |
| 310 } | 310 } |
| 311 | 311 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 // Test second iframe from a different origin with a cached geoposition will | 480 // Test second iframe from a different origin with a cached geoposition will |
| 481 // create the infobar. | 481 // create the infobar. |
| 482 iframe_xpath_ = L"//iframe[@id='iframe_1']"; | 482 iframe_xpath_ = L"//iframe[@id='iframe_1']"; |
| 483 AddGeolocationWatch(true); | 483 AddGeolocationWatch(true); |
| 484 | 484 |
| 485 // Back to the first frame, enable navigation and refresh geoposition. | 485 // Back to the first frame, enable navigation and refresh geoposition. |
| 486 iframe_xpath_ = L"//iframe[@id='iframe_0']"; | 486 iframe_xpath_ = L"//iframe[@id='iframe_0']"; |
| 487 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); | 487 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); |
| 488 double fresh_position_latitude = 3.17; | 488 double fresh_position_latitude = 3.17; |
| 489 double fresh_position_longitude = 4.23; | 489 double fresh_position_longitude = 4.23; |
| 490 ui_test_utils::WindowedNotificationObserver observer( | 490 content::WindowedNotificationObserver observer( |
| 491 content::NOTIFICATION_LOAD_STOP, | 491 content::NOTIFICATION_LOAD_STOP, |
| 492 content::Source<NavigationController>( | 492 content::Source<NavigationController>( |
| 493 &chrome::GetActiveWebContents(current_browser_)->GetController())); | 493 &chrome::GetActiveWebContents(current_browser_)->GetController())); |
| 494 NotifyGeoposition(fresh_position_latitude, fresh_position_longitude); | 494 NotifyGeoposition(fresh_position_latitude, fresh_position_longitude); |
| 495 observer.Wait(); | 495 observer.Wait(); |
| 496 CheckGeoposition(fresh_position_latitude, fresh_position_longitude); | 496 CheckGeoposition(fresh_position_latitude, fresh_position_longitude); |
| 497 | 497 |
| 498 // Disable navigation for this frame. | 498 // Disable navigation for this frame. |
| 499 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 499 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
| 500 | 500 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 516 | 516 |
| 517 iframe_xpath_ = L"//iframe[@id='iframe_0']"; | 517 iframe_xpath_ = L"//iframe[@id='iframe_0']"; |
| 518 AddGeolocationWatch(true); | 518 AddGeolocationWatch(true); |
| 519 SetInfobarResponse(iframe_urls_[0], true); | 519 SetInfobarResponse(iframe_urls_[0], true); |
| 520 CheckGeoposition(fake_latitude_, fake_longitude_); | 520 CheckGeoposition(fake_latitude_, fake_longitude_); |
| 521 | 521 |
| 522 // Refresh geoposition, but let's not yet create the watch on the second frame | 522 // Refresh geoposition, but let's not yet create the watch on the second frame |
| 523 // so that it'll fetch from cache. | 523 // so that it'll fetch from cache. |
| 524 double cached_position_latitude = 5.67; | 524 double cached_position_latitude = 5.67; |
| 525 double cached_position_lognitude = 8.09; | 525 double cached_position_lognitude = 8.09; |
| 526 ui_test_utils::WindowedNotificationObserver observer( | 526 content::WindowedNotificationObserver observer( |
| 527 content::NOTIFICATION_LOAD_STOP, | 527 content::NOTIFICATION_LOAD_STOP, |
| 528 content::Source<NavigationController>( | 528 content::Source<NavigationController>( |
| 529 &chrome::GetActiveWebContents(current_browser_)->GetController())); | 529 &chrome::GetActiveWebContents(current_browser_)->GetController())); |
| 530 NotifyGeoposition(cached_position_latitude, cached_position_lognitude); | 530 NotifyGeoposition(cached_position_latitude, cached_position_lognitude); |
| 531 observer.Wait(); | 531 observer.Wait(); |
| 532 CheckGeoposition(cached_position_latitude, cached_position_lognitude); | 532 CheckGeoposition(cached_position_latitude, cached_position_lognitude); |
| 533 | 533 |
| 534 // Disable navigation for this frame. | 534 // Disable navigation for this frame. |
| 535 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 535 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
| 536 | 536 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 L"", UTF8ToWide(script), &js_result)); | 625 L"", UTF8ToWide(script), &js_result)); |
| 626 EXPECT_EQ(js_result, "ok"); | 626 EXPECT_EQ(js_result, "ok"); |
| 627 | 627 |
| 628 // Send a position which both geolocation watches will receive. | 628 // Send a position which both geolocation watches will receive. |
| 629 AddGeolocationWatch(true); | 629 AddGeolocationWatch(true); |
| 630 SetInfobarResponse(current_url_, true); | 630 SetInfobarResponse(current_url_, true); |
| 631 CheckGeoposition(fake_latitude_, fake_longitude_); | 631 CheckGeoposition(fake_latitude_, fake_longitude_); |
| 632 | 632 |
| 633 // The second watch will now have cancelled. Ensure an update still makes | 633 // The second watch will now have cancelled. Ensure an update still makes |
| 634 // its way through to the first watcher. | 634 // its way through to the first watcher. |
| 635 ui_test_utils::WindowedNotificationObserver observer( | 635 content::WindowedNotificationObserver observer( |
| 636 content::NOTIFICATION_LOAD_STOP, | 636 content::NOTIFICATION_LOAD_STOP, |
| 637 content::Source<NavigationController>( | 637 content::Source<NavigationController>( |
| 638 &chrome::GetActiveWebContents(current_browser_)->GetController())); | 638 &chrome::GetActiveWebContents(current_browser_)->GetController())); |
| 639 NotifyGeoposition(final_position_latitude, final_position_longitude); | 639 NotifyGeoposition(final_position_latitude, final_position_longitude); |
| 640 observer.Wait(); | 640 observer.Wait(); |
| 641 CheckGeoposition(final_position_latitude, final_position_longitude); | 641 CheckGeoposition(final_position_latitude, final_position_longitude); |
| 642 } | 642 } |
| 643 | 643 |
| 644 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TabDestroyed) { | 644 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TabDestroyed) { |
| 645 html_for_tests_ = "files/geolocation/tab_destroyed.html"; | 645 html_for_tests_ = "files/geolocation/tab_destroyed.html"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 659 "window.domAutomationController.setAutomationId(0);" | 659 "window.domAutomationController.setAutomationId(0);" |
| 660 "window.domAutomationController.send(window.close());"; | 660 "window.domAutomationController.send(window.close());"; |
| 661 bool result = | 661 bool result = |
| 662 ui_test_utils::ExecuteJavaScript( | 662 ui_test_utils::ExecuteJavaScript( |
| 663 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), | 663 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), |
| 664 L"", UTF8ToWide(script)); | 664 L"", UTF8ToWide(script)); |
| 665 EXPECT_EQ(result, true); | 665 EXPECT_EQ(result, true); |
| 666 } | 666 } |
| 667 | 667 |
| 668 } // namespace | 668 } // namespace |
| OLD | NEW |