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" |
11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 11 #include "chrome/browser/content_settings/host_content_settings_map.h" |
12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
13 #include "chrome/browser/geolocation/geolocation_settings_state.h" | 13 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
14 #include "chrome/browser/infobars/infobar.h" | 14 #include "chrome/browser/infobars/infobar.h" |
15 #include "chrome/browser/infobars/infobar_tab_helper.h" | 15 #include "chrome/browser/infobars/infobar_tab_helper.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_tabstrip.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
22 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/content_settings_pattern.h" | 25 #include "chrome/common/content_settings_pattern.h" |
25 #include "chrome/test/base/in_process_browser_test.h" | 26 #include "chrome/test/base/in_process_browser_test.h" |
26 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
27 #include "content/public/browser/dom_operation_notification_details.h" | 28 #include "content/public/browser/dom_operation_notification_details.h" |
28 #include "content/public/browser/navigation_controller.h" | 29 #include "content/public/browser/navigation_controller.h" |
29 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
30 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
42 // Used to block until an iframe is loaded via a javascript call. | 43 // Used to block until an iframe is loaded via a javascript call. |
43 // Note: NavigateToURLBlockUntilNavigationsComplete doesn't seem to work for | 44 // Note: NavigateToURLBlockUntilNavigationsComplete doesn't seem to work for |
44 // multiple embedded iframes, as notifications seem to be 'batched'. Instead, we | 45 // multiple embedded iframes, as notifications seem to be 'batched'. Instead, we |
45 // load and wait one single frame here by calling a javascript function. | 46 // load and wait one single frame here by calling a javascript function. |
46 class IFrameLoader : public content::NotificationObserver { | 47 class IFrameLoader : public content::NotificationObserver { |
47 public: | 48 public: |
48 IFrameLoader(Browser* browser, int iframe_id, const GURL& url) | 49 IFrameLoader(Browser* browser, int iframe_id, const GURL& url) |
49 : navigation_completed_(false), | 50 : navigation_completed_(false), |
50 javascript_completed_(false) { | 51 javascript_completed_(false) { |
51 NavigationController* controller = | 52 NavigationController* controller = |
52 &browser->GetActiveWebContents()->GetController(); | 53 &chrome::GetActiveWebContents(browser)->GetController(); |
53 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 54 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
54 content::Source<NavigationController>(controller)); | 55 content::Source<NavigationController>(controller)); |
55 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, | 56 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, |
56 content::NotificationService::AllSources()); | 57 content::NotificationService::AllSources()); |
57 std::string script = base::StringPrintf( | 58 std::string script = base::StringPrintf( |
58 "window.domAutomationController.setAutomationId(0);" | 59 "window.domAutomationController.setAutomationId(0);" |
59 "window.domAutomationController.send(addIFrame(%d, \"%s\"));", | 60 "window.domAutomationController.send(addIFrame(%d, \"%s\"));", |
60 iframe_id, | 61 iframe_id, |
61 url.spec().c_str()); | 62 url.spec().c_str()); |
62 browser->GetActiveWebContents()->GetRenderViewHost()-> | 63 chrome::GetActiveWebContents(browser)->GetRenderViewHost()-> |
63 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(script)); | 64 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(script)); |
64 ui_test_utils::RunMessageLoop(); | 65 ui_test_utils::RunMessageLoop(); |
65 | 66 |
66 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_); | 67 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_); |
67 registrar_.RemoveAll(); | 68 registrar_.RemoveAll(); |
68 // Now that we loaded the iframe, let's fetch its src. | 69 // Now that we loaded the iframe, let's fetch its src. |
69 script = base::StringPrintf( | 70 script = base::StringPrintf( |
70 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); | 71 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); |
71 std::string iframe_src; | 72 std::string iframe_src; |
72 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 73 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
73 browser->GetActiveWebContents()->GetRenderViewHost(), | 74 chrome::GetActiveWebContents(browser)->GetRenderViewHost(), |
74 L"", UTF8ToWide(script), &iframe_src)); | 75 L"", UTF8ToWide(script), &iframe_src)); |
75 iframe_url_ = GURL(iframe_src); | 76 iframe_url_ = GURL(iframe_src); |
76 } | 77 } |
77 | 78 |
78 GURL iframe_url() const { return iframe_url_; } | 79 GURL iframe_url() const { return iframe_url_; } |
79 | 80 |
80 virtual void Observe(int type, | 81 virtual void Observe(int type, |
81 const content::NotificationSource& source, | 82 const content::NotificationSource& source, |
82 const content::NotificationDetails& details) { | 83 const content::NotificationDetails& details) { |
83 if (type == content::NOTIFICATION_LOAD_STOP) { | 84 if (type == content::NOTIFICATION_LOAD_STOP) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 iframe_urls_.resize(number_iframes); | 268 iframe_urls_.resize(number_iframes); |
268 for (int i = 0; i < number_iframes; ++i) { | 269 for (int i = 0; i < number_iframes; ++i) { |
269 IFrameLoader loader(current_browser_, i, GURL()); | 270 IFrameLoader loader(current_browser_, i, GURL()); |
270 iframe_urls_[i] = loader.iframe_url(); | 271 iframe_urls_[i] = loader.iframe_url(); |
271 } | 272 } |
272 } | 273 } |
273 | 274 |
274 void AddGeolocationWatch(bool wait_for_infobar) { | 275 void AddGeolocationWatch(bool wait_for_infobar) { |
275 GeolocationNotificationObserver notification_observer(wait_for_infobar); | 276 GeolocationNotificationObserver notification_observer(wait_for_infobar); |
276 notification_observer.AddWatchAndWaitForNotification( | 277 notification_observer.AddWatchAndWaitForNotification( |
277 current_browser_->GetActiveWebContents()->GetRenderViewHost(), | 278 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), |
278 iframe_xpath_); | 279 iframe_xpath_); |
279 if (wait_for_infobar) { | 280 if (wait_for_infobar) { |
280 EXPECT_TRUE(notification_observer.infobar_); | 281 EXPECT_TRUE(notification_observer.infobar_); |
281 infobar_ = notification_observer.infobar_; | 282 infobar_ = notification_observer.infobar_; |
282 } | 283 } |
283 } | 284 } |
284 | 285 |
285 void CheckGeoposition(double latitude, double longitude) { | 286 void CheckGeoposition(double latitude, double longitude) { |
286 // Checks we have no error. | 287 // Checks we have no error. |
287 CheckStringValueFromJavascript("0", "geoGetLastError()"); | 288 CheckStringValueFromJavascript("0", "geoGetLastError()"); |
288 CheckStringValueFromJavascript(base::DoubleToString(latitude), | 289 CheckStringValueFromJavascript(base::DoubleToString(latitude), |
289 "geoGetLastPositionLatitude()"); | 290 "geoGetLastPositionLatitude()"); |
290 CheckStringValueFromJavascript(base::DoubleToString(longitude), | 291 CheckStringValueFromJavascript(base::DoubleToString(longitude), |
291 "geoGetLastPositionLongitude()"); | 292 "geoGetLastPositionLongitude()"); |
292 } | 293 } |
293 | 294 |
294 void SetInfobarResponse(const GURL& requesting_url, bool allowed) { | 295 void SetInfobarResponse(const GURL& requesting_url, bool allowed) { |
295 TabContents* tab_contents = current_browser_->GetActiveTabContents(); | 296 TabContents* tab_contents = chrome::GetActiveTabContents(current_browser_); |
296 TabSpecificContentSettings* content_settings = | 297 TabSpecificContentSettings* content_settings = |
297 tab_contents->content_settings(); | 298 tab_contents->content_settings(); |
298 const GeolocationSettingsState& settings_state = | 299 const GeolocationSettingsState& settings_state = |
299 content_settings->geolocation_settings_state(); | 300 content_settings->geolocation_settings_state(); |
300 size_t state_map_size = settings_state.state_map().size(); | 301 size_t state_map_size = settings_state.state_map().size(); |
301 ASSERT_TRUE(infobar_); | 302 ASSERT_TRUE(infobar_); |
302 LOG(WARNING) << "will set infobar response"; | 303 LOG(WARNING) << "will set infobar response"; |
303 { | 304 { |
304 ui_test_utils::WindowedNotificationObserver observer( | 305 ui_test_utils::WindowedNotificationObserver observer( |
305 content::NOTIFICATION_LOAD_STOP, | 306 content::NOTIFICATION_LOAD_STOP, |
(...skipping 26 matching lines...) Expand all Loading... |
332 std::string result; | 333 std::string result; |
333 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 334 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
334 web_contents->GetRenderViewHost(), | 335 web_contents->GetRenderViewHost(), |
335 iframe_xpath_, UTF8ToWide(script), &result)); | 336 iframe_xpath_, UTF8ToWide(script), &result)); |
336 EXPECT_EQ(expected, result); | 337 EXPECT_EQ(expected, result); |
337 } | 338 } |
338 | 339 |
339 void CheckStringValueFromJavascript( | 340 void CheckStringValueFromJavascript( |
340 const std::string& expected, const std::string& function) { | 341 const std::string& expected, const std::string& function) { |
341 CheckStringValueFromJavascriptForTab( | 342 CheckStringValueFromJavascriptForTab( |
342 expected, function, current_browser_->GetActiveWebContents()); | 343 expected, function, chrome::GetActiveWebContents(current_browser_)); |
343 } | 344 } |
344 | 345 |
345 void NotifyGeoposition(double latitude, double longitude) { | 346 void NotifyGeoposition(double latitude, double longitude) { |
346 fake_latitude_ = latitude; | 347 fake_latitude_ = latitude; |
347 fake_longitude_ = longitude; | 348 fake_longitude_ = longitude; |
348 ui_test_utils::OverrideGeolocation(latitude, longitude); | 349 ui_test_utils::OverrideGeolocation(latitude, longitude); |
349 LOG(WARNING) << "MockLocationProvider listeners updated"; | 350 LOG(WARNING) << "MockLocationProvider listeners updated"; |
350 } | 351 } |
351 | 352 |
352 InfoBarDelegate* infobar_; | 353 InfoBarDelegate* infobar_; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 AddGeolocationWatch(true); | 487 AddGeolocationWatch(true); |
487 | 488 |
488 // Back to the first frame, enable navigation and refresh geoposition. | 489 // Back to the first frame, enable navigation and refresh geoposition. |
489 iframe_xpath_ = L"//iframe[@id='iframe_0']"; | 490 iframe_xpath_ = L"//iframe[@id='iframe_0']"; |
490 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); | 491 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); |
491 double fresh_position_latitude = 3.17; | 492 double fresh_position_latitude = 3.17; |
492 double fresh_position_longitude = 4.23; | 493 double fresh_position_longitude = 4.23; |
493 ui_test_utils::WindowedNotificationObserver observer( | 494 ui_test_utils::WindowedNotificationObserver observer( |
494 content::NOTIFICATION_LOAD_STOP, | 495 content::NOTIFICATION_LOAD_STOP, |
495 content::Source<NavigationController>( | 496 content::Source<NavigationController>( |
496 ¤t_browser_->GetActiveWebContents()->GetController())); | 497 &chrome::GetActiveWebContents(current_browser_)->GetController())); |
497 NotifyGeoposition(fresh_position_latitude, fresh_position_longitude); | 498 NotifyGeoposition(fresh_position_latitude, fresh_position_longitude); |
498 observer.Wait(); | 499 observer.Wait(); |
499 CheckGeoposition(fresh_position_latitude, fresh_position_longitude); | 500 CheckGeoposition(fresh_position_latitude, fresh_position_longitude); |
500 | 501 |
501 // Disable navigation for this frame. | 502 // Disable navigation for this frame. |
502 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 503 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
503 | 504 |
504 // Now go ahead an authorize the second frame. | 505 // Now go ahead an authorize the second frame. |
505 iframe_xpath_ = L"//iframe[@id='iframe_1']"; | 506 iframe_xpath_ = L"//iframe[@id='iframe_1']"; |
506 // Infobar was displayed, allow access and check there's no error code. | 507 // Infobar was displayed, allow access and check there's no error code. |
(...skipping 15 matching lines...) Expand all Loading... |
522 SetInfobarResponse(iframe_urls_[0], true); | 523 SetInfobarResponse(iframe_urls_[0], true); |
523 CheckGeoposition(fake_latitude_, fake_longitude_); | 524 CheckGeoposition(fake_latitude_, fake_longitude_); |
524 | 525 |
525 // Refresh geoposition, but let's not yet create the watch on the second frame | 526 // Refresh geoposition, but let's not yet create the watch on the second frame |
526 // so that it'll fetch from cache. | 527 // so that it'll fetch from cache. |
527 double cached_position_latitude = 5.67; | 528 double cached_position_latitude = 5.67; |
528 double cached_position_lognitude = 8.09; | 529 double cached_position_lognitude = 8.09; |
529 ui_test_utils::WindowedNotificationObserver observer( | 530 ui_test_utils::WindowedNotificationObserver observer( |
530 content::NOTIFICATION_LOAD_STOP, | 531 content::NOTIFICATION_LOAD_STOP, |
531 content::Source<NavigationController>( | 532 content::Source<NavigationController>( |
532 ¤t_browser_->GetActiveWebContents()->GetController())); | 533 &chrome::GetActiveWebContents(current_browser_)->GetController())); |
533 NotifyGeoposition(cached_position_latitude, cached_position_lognitude); | 534 NotifyGeoposition(cached_position_latitude, cached_position_lognitude); |
534 observer.Wait(); | 535 observer.Wait(); |
535 CheckGeoposition(cached_position_latitude, cached_position_lognitude); | 536 CheckGeoposition(cached_position_latitude, cached_position_lognitude); |
536 | 537 |
537 // Disable navigation for this frame. | 538 // Disable navigation for this frame. |
538 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 539 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
539 | 540 |
540 // Now go ahead an authorize the second frame. | 541 // Now go ahead an authorize the second frame. |
541 iframe_xpath_ = L"//iframe[@id='iframe_1']"; | 542 iframe_xpath_ = L"//iframe[@id='iframe_1']"; |
542 AddGeolocationWatch(true); | 543 AddGeolocationWatch(true); |
(...skipping 18 matching lines...) Expand all Loading... |
561 SetInfobarResponse(iframe_urls_[0], true); | 562 SetInfobarResponse(iframe_urls_[0], true); |
562 CheckGeoposition(fake_latitude_, fake_longitude_); | 563 CheckGeoposition(fake_latitude_, fake_longitude_); |
563 // Disables further prompts from this iframe. | 564 // Disables further prompts from this iframe. |
564 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 565 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
565 | 566 |
566 // Test second iframe from a different origin with a cached geoposition will | 567 // Test second iframe from a different origin with a cached geoposition will |
567 // create the infobar. | 568 // create the infobar. |
568 iframe_xpath_ = L"//iframe[@id='iframe_1']"; | 569 iframe_xpath_ = L"//iframe[@id='iframe_1']"; |
569 AddGeolocationWatch(true); | 570 AddGeolocationWatch(true); |
570 | 571 |
571 InfoBarTabHelper* infobar_helper = current_browser_-> | 572 InfoBarTabHelper* infobar_helper = |
572 GetActiveTabContents()->infobar_tab_helper(); | 573 chrome::GetActiveTabContents(current_browser_)->infobar_tab_helper(); |
573 size_t num_infobars_before_cancel = infobar_helper->infobar_count(); | 574 size_t num_infobars_before_cancel = infobar_helper->infobar_count(); |
574 // Change the iframe, and ensure the infobar is gone. | 575 // Change the iframe, and ensure the infobar is gone. |
575 IFrameLoader change_iframe_1(current_browser_, 1, current_url_); | 576 IFrameLoader change_iframe_1(current_browser_, 1, current_url_); |
576 size_t num_infobars_after_cancel = infobar_helper->infobar_count(); | 577 size_t num_infobars_after_cancel = infobar_helper->infobar_count(); |
577 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); | 578 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); |
578 } | 579 } |
579 | 580 |
580 // Disabled, http://crbug.com/66959. | 581 // Disabled, http://crbug.com/66959. |
581 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_InvalidUrlRequest) { | 582 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_InvalidUrlRequest) { |
582 // Tests that an invalid URL (e.g. from a popup window) is rejected | 583 // Tests that an invalid URL (e.g. from a popup window) is rejected |
583 // correctly. Also acts as a regression test for http://crbug.com/40478 | 584 // correctly. Also acts as a regression test for http://crbug.com/40478 |
584 html_for_tests_ = "files/geolocation/invalid_request_url.html"; | 585 html_for_tests_ = "files/geolocation/invalid_request_url.html"; |
585 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 586 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
586 WebContents* original_tab = current_browser_->GetActiveWebContents(); | 587 WebContents* original_tab = chrome::GetActiveWebContents(current_browser_); |
587 CheckStringValueFromJavascript("1", "requestGeolocationFromInvalidUrl()"); | 588 CheckStringValueFromJavascript("1", "requestGeolocationFromInvalidUrl()"); |
588 CheckStringValueFromJavascriptForTab("1", "isAlive()", original_tab); | 589 CheckStringValueFromJavascriptForTab("1", "isAlive()", original_tab); |
589 } | 590 } |
590 | 591 |
591 // Crashy, http://crbug.com/66400. | 592 // Crashy, http://crbug.com/66400. |
592 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoInfoBarBeforeStart) { | 593 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoInfoBarBeforeStart) { |
593 // See http://crbug.com/42789 | 594 // See http://crbug.com/42789 |
594 html_for_tests_ = "files/geolocation/iframes_different_origin.html"; | 595 html_for_tests_ = "files/geolocation/iframes_different_origin.html"; |
595 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); | 596 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); |
596 LoadIFrames(2); | 597 LoadIFrames(2); |
(...skipping 20 matching lines...) Expand all Loading... |
617 html_for_tests_ = "files/geolocation/two_watches.html"; | 618 html_for_tests_ = "files/geolocation/two_watches.html"; |
618 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 619 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
619 // First, set the JavaScript to navigate when it receives |final_position|. | 620 // First, set the JavaScript to navigate when it receives |final_position|. |
620 double final_position_latitude = 3.17; | 621 double final_position_latitude = 3.17; |
621 double final_position_longitude = 4.23; | 622 double final_position_longitude = 4.23; |
622 std::string script = base::StringPrintf( | 623 std::string script = base::StringPrintf( |
623 "window.domAutomationController.send(geoSetFinalPosition(%f, %f))", | 624 "window.domAutomationController.send(geoSetFinalPosition(%f, %f))", |
624 final_position_latitude, final_position_longitude); | 625 final_position_latitude, final_position_longitude); |
625 std::string js_result; | 626 std::string js_result; |
626 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 627 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
627 current_browser_->GetActiveWebContents()->GetRenderViewHost(), | 628 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), |
628 L"", UTF8ToWide(script), &js_result)); | 629 L"", UTF8ToWide(script), &js_result)); |
629 EXPECT_EQ(js_result, "ok"); | 630 EXPECT_EQ(js_result, "ok"); |
630 | 631 |
631 // Send a position which both geolocation watches will receive. | 632 // Send a position which both geolocation watches will receive. |
632 AddGeolocationWatch(true); | 633 AddGeolocationWatch(true); |
633 SetInfobarResponse(current_url_, true); | 634 SetInfobarResponse(current_url_, true); |
634 CheckGeoposition(fake_latitude_, fake_longitude_); | 635 CheckGeoposition(fake_latitude_, fake_longitude_); |
635 | 636 |
636 // The second watch will now have cancelled. Ensure an update still makes | 637 // The second watch will now have cancelled. Ensure an update still makes |
637 // its way through to the first watcher. | 638 // its way through to the first watcher. |
638 ui_test_utils::WindowedNotificationObserver observer( | 639 ui_test_utils::WindowedNotificationObserver observer( |
639 content::NOTIFICATION_LOAD_STOP, | 640 content::NOTIFICATION_LOAD_STOP, |
640 content::Source<NavigationController>( | 641 content::Source<NavigationController>( |
641 ¤t_browser_->GetActiveWebContents()->GetController())); | 642 &chrome::GetActiveWebContents(current_browser_)->GetController())); |
642 NotifyGeoposition(final_position_latitude, final_position_longitude); | 643 NotifyGeoposition(final_position_latitude, final_position_longitude); |
643 observer.Wait(); | 644 observer.Wait(); |
644 CheckGeoposition(final_position_latitude, final_position_longitude); | 645 CheckGeoposition(final_position_latitude, final_position_longitude); |
645 } | 646 } |
646 | 647 |
647 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TabDestroyed) { | 648 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TabDestroyed) { |
648 html_for_tests_ = "files/geolocation/tab_destroyed.html"; | 649 html_for_tests_ = "files/geolocation/tab_destroyed.html"; |
649 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); | 650 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); |
650 LoadIFrames(3); | 651 LoadIFrames(3); |
651 | 652 |
652 iframe_xpath_ = L"//iframe[@id='iframe_0']"; | 653 iframe_xpath_ = L"//iframe[@id='iframe_0']"; |
653 AddGeolocationWatch(true); | 654 AddGeolocationWatch(true); |
654 | 655 |
655 iframe_xpath_ = L"//iframe[@id='iframe_1']"; | 656 iframe_xpath_ = L"//iframe[@id='iframe_1']"; |
656 AddGeolocationWatch(false); | 657 AddGeolocationWatch(false); |
657 | 658 |
658 iframe_xpath_ = L"//iframe[@id='iframe_2']"; | 659 iframe_xpath_ = L"//iframe[@id='iframe_2']"; |
659 AddGeolocationWatch(false); | 660 AddGeolocationWatch(false); |
660 | 661 |
661 std::string script = | 662 std::string script = |
662 "window.domAutomationController.setAutomationId(0);" | 663 "window.domAutomationController.setAutomationId(0);" |
663 "window.domAutomationController.send(window.close());"; | 664 "window.domAutomationController.send(window.close());"; |
664 bool result = | 665 bool result = |
665 ui_test_utils::ExecuteJavaScript( | 666 ui_test_utils::ExecuteJavaScript( |
666 current_browser_->GetActiveWebContents()->GetRenderViewHost(), | 667 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), |
667 L"", UTF8ToWide(script)); | 668 L"", UTF8ToWide(script)); |
668 EXPECT_EQ(result, true); | 669 EXPECT_EQ(result, true); |
669 } | 670 } |
670 | 671 |
671 } // namespace | 672 } // namespace |
OLD | NEW |