Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/geolocation/geolocation_browsertest.cc

Issue 11728003: Change ExecuteJavaScript* helper functions in browser_test_utils.{h,cc} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding files for gpu_tests and NaCl browser tests. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 content::RunMessageLoop(); 64 content::RunMessageLoop();
65 65
66 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_); 66 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_);
67 registrar_.RemoveAll(); 67 registrar_.RemoveAll();
68 // Now that we loaded the iframe, let's fetch its src. 68 // Now that we loaded the iframe, let's fetch its src.
69 script = base::StringPrintf( 69 script = base::StringPrintf(
70 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); 70 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id);
71 std::string iframe_src; 71 std::string iframe_src;
72 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( 72 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString(
73 chrome::GetActiveWebContents(browser)->GetRenderViewHost(), 73 chrome::GetActiveWebContents(browser)->GetRenderViewHost(),
74 L"", UTF8ToWide(script), &iframe_src)); 74 "",
75 script,
76 &iframe_src));
75 iframe_url_ = GURL(iframe_src); 77 iframe_url_ = GURL(iframe_src);
76 } 78 }
77 79
78 GURL iframe_url() const { return iframe_url_; } 80 GURL iframe_url() const { return iframe_url_; }
79 81
80 virtual void Observe(int type, 82 virtual void Observe(int type,
81 const content::NotificationSource& source, 83 const content::NotificationSource& source,
82 const content::NotificationDetails& details) { 84 const content::NotificationDetails& details) {
83 if (type == content::NOTIFICATION_LOAD_STOP) { 85 if (type == content::NOTIFICATION_LOAD_STOP) {
84 navigation_completed_ = true; 86 navigation_completed_ = true;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 129 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
128 content::NotificationService::AllSources()); 130 content::NotificationService::AllSources());
129 registrar_.Add(this, content::NOTIFICATION_LOAD_START, 131 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
130 content::NotificationService::AllSources()); 132 content::NotificationService::AllSources());
131 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, 133 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
132 content::NotificationService::AllSources()); 134 content::NotificationService::AllSources());
133 } 135 }
134 } 136 }
135 137
136 void AddWatchAndWaitForNotification(content::RenderViewHost* render_view_host, 138 void AddWatchAndWaitForNotification(content::RenderViewHost* render_view_host,
137 const std::wstring& iframe_xpath) { 139 const std::string& iframe_xpath) {
138 LOG(WARNING) << "will add geolocation watch"; 140 LOG(WARNING) << "will add geolocation watch";
139 std::string script = 141 std::string script =
140 "window.domAutomationController.setAutomationId(0);" 142 "window.domAutomationController.setAutomationId(0);"
141 "window.domAutomationController.send(geoStart());"; 143 "window.domAutomationController.send(geoStart());";
142 render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), 144 render_view_host->ExecuteJavascriptInWebFrame(UTF8ToUTF16(iframe_xpath),
143 UTF8ToUTF16(script)); 145 UTF8ToUTF16(script));
144 content::RunMessageLoop(); 146 content::RunMessageLoop();
145 registrar_.RemoveAll(); 147 registrar_.RemoveAll();
146 LOG(WARNING) << "got geolocation watch" << javascript_response_; 148 LOG(WARNING) << "got geolocation watch" << javascript_response_;
147 EXPECT_NE("\"0\"", javascript_response_); 149 EXPECT_NE("\"0\"", javascript_response_);
148 if (wait_for_infobar_) { 150 if (wait_for_infobar_) {
149 EXPECT_TRUE(infobar_); 151 EXPECT_TRUE(infobar_);
150 } else { 152 } else {
151 EXPECT_TRUE(navigation_completed_); 153 EXPECT_TRUE(navigation_completed_);
152 } 154 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 324 }
323 325
324 void CheckStringValueFromJavascriptForTab( 326 void CheckStringValueFromJavascriptForTab(
325 const std::string& expected, const std::string& function, 327 const std::string& expected, const std::string& function,
326 WebContents* web_contents) { 328 WebContents* web_contents) {
327 std::string script = base::StringPrintf( 329 std::string script = base::StringPrintf(
328 "window.domAutomationController.send(%s)", function.c_str()); 330 "window.domAutomationController.send(%s)", function.c_str());
329 std::string result; 331 std::string result;
330 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( 332 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
331 web_contents->GetRenderViewHost(), 333 web_contents->GetRenderViewHost(),
332 iframe_xpath_, UTF8ToWide(script), &result)); 334 iframe_xpath_,
335 script,
336 &result));
333 EXPECT_EQ(expected, result); 337 EXPECT_EQ(expected, result);
334 } 338 }
335 339
336 void CheckStringValueFromJavascript( 340 void CheckStringValueFromJavascript(
337 const std::string& expected, const std::string& function) { 341 const std::string& expected, const std::string& function) {
338 CheckStringValueFromJavascriptForTab( 342 CheckStringValueFromJavascriptForTab(
339 expected, function, chrome::GetActiveWebContents(current_browser_)); 343 expected, function, chrome::GetActiveWebContents(current_browser_));
340 } 344 }
341 345
342 void NotifyGeoposition(double latitude, double longitude) { 346 void NotifyGeoposition(double latitude, double longitude) {
343 fake_latitude_ = latitude; 347 fake_latitude_ = latitude;
344 fake_longitude_ = longitude; 348 fake_longitude_ = longitude;
345 ui_test_utils::OverrideGeolocation(latitude, longitude); 349 ui_test_utils::OverrideGeolocation(latitude, longitude);
346 LOG(WARNING) << "MockLocationProvider listeners updated"; 350 LOG(WARNING) << "MockLocationProvider listeners updated";
347 } 351 }
348 352
349 InfoBarDelegate* infobar_; 353 InfoBarDelegate* infobar_;
350 Browser* current_browser_; 354 Browser* current_browser_;
351 // path element of a URL referencing the html content for this test. 355 // path element of a URL referencing the html content for this test.
352 std::string html_for_tests_; 356 std::string html_for_tests_;
353 // This member defines the iframe (or top-level page, if empty) where the 357 // This member defines the iframe (or top-level page, if empty) where the
354 // javascript calls will run. 358 // javascript calls will run.
355 std::wstring iframe_xpath_; 359 std::string iframe_xpath_;
356 // The current url for the top level page. 360 // The current url for the top level page.
357 GURL current_url_; 361 GURL current_url_;
358 // If not empty, the GURLs for the iframes loaded by LoadIFrames(). 362 // If not empty, the GURLs for the iframes loaded by LoadIFrames().
359 std::vector<GURL> iframe_urls_; 363 std::vector<GURL> iframe_urls_;
360 double fake_latitude_; 364 double fake_latitude_;
361 double fake_longitude_; 365 double fake_longitude_;
362 366
363 // TODO(phajdan.jr): Remove after we can ask TestServer whether it is started. 367 // TODO(phajdan.jr): Remove after we can ask TestServer whether it is started.
364 bool started_test_server_; 368 bool started_test_server_;
365 }; 369 };
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 CheckGeoposition(fake_latitude_, fake_longitude_); 459 CheckGeoposition(fake_latitude_, fake_longitude_);
456 } 460 }
457 461
458 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, 462 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
459 IFramesWithFreshPosition) { 463 IFramesWithFreshPosition) {
460 html_for_tests_ = "files/geolocation/iframes_different_origin.html"; 464 html_for_tests_ = "files/geolocation/iframes_different_origin.html";
461 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); 465 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES));
462 LoadIFrames(2); 466 LoadIFrames(2);
463 LOG(WARNING) << "frames loaded"; 467 LOG(WARNING) << "frames loaded";
464 468
465 iframe_xpath_ = L"//iframe[@id='iframe_0']"; 469 iframe_xpath_ = "//iframe[@id='iframe_0']";
466 AddGeolocationWatch(true); 470 AddGeolocationWatch(true);
467 SetInfobarResponse(iframe_urls_[0], true); 471 SetInfobarResponse(iframe_urls_[0], true);
468 CheckGeoposition(fake_latitude_, fake_longitude_); 472 CheckGeoposition(fake_latitude_, fake_longitude_);
469 // Disables further prompts from this iframe. 473 // Disables further prompts from this iframe.
470 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); 474 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)");
471 475
472 // Test second iframe from a different origin with a cached geoposition will 476 // Test second iframe from a different origin with a cached geoposition will
473 // create the infobar. 477 // create the infobar.
474 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 478 iframe_xpath_ = "//iframe[@id='iframe_1']";
475 AddGeolocationWatch(true); 479 AddGeolocationWatch(true);
476 480
477 // Back to the first frame, enable navigation and refresh geoposition. 481 // Back to the first frame, enable navigation and refresh geoposition.
478 iframe_xpath_ = L"//iframe[@id='iframe_0']"; 482 iframe_xpath_ = "//iframe[@id='iframe_0']";
479 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); 483 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)");
480 double fresh_position_latitude = 3.17; 484 double fresh_position_latitude = 3.17;
481 double fresh_position_longitude = 4.23; 485 double fresh_position_longitude = 4.23;
482 content::WindowedNotificationObserver observer( 486 content::WindowedNotificationObserver observer(
483 content::NOTIFICATION_LOAD_STOP, 487 content::NOTIFICATION_LOAD_STOP,
484 content::Source<NavigationController>( 488 content::Source<NavigationController>(
485 &chrome::GetActiveWebContents(current_browser_)->GetController())); 489 &chrome::GetActiveWebContents(current_browser_)->GetController()));
486 NotifyGeoposition(fresh_position_latitude, fresh_position_longitude); 490 NotifyGeoposition(fresh_position_latitude, fresh_position_longitude);
487 observer.Wait(); 491 observer.Wait();
488 CheckGeoposition(fresh_position_latitude, fresh_position_longitude); 492 CheckGeoposition(fresh_position_latitude, fresh_position_longitude);
489 493
490 // Disable navigation for this frame. 494 // Disable navigation for this frame.
491 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); 495 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)");
492 496
493 // Now go ahead an authorize the second frame. 497 // Now go ahead an authorize the second frame.
494 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 498 iframe_xpath_ = "//iframe[@id='iframe_1']";
495 // Infobar was displayed, allow access and check there's no error code. 499 // Infobar was displayed, allow access and check there's no error code.
496 SetInfobarResponse(iframe_urls_[1], true); 500 SetInfobarResponse(iframe_urls_[1], true);
497 LOG(WARNING) << "Checking position..."; 501 LOG(WARNING) << "Checking position...";
498 CheckGeoposition(fresh_position_latitude, fresh_position_longitude); 502 CheckGeoposition(fresh_position_latitude, fresh_position_longitude);
499 LOG(WARNING) << "...done."; 503 LOG(WARNING) << "...done.";
500 } 504 }
501 505
502 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, 506 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
503 IFramesWithCachedPosition) { 507 IFramesWithCachedPosition) {
504 html_for_tests_ = "files/geolocation/iframes_different_origin.html"; 508 html_for_tests_ = "files/geolocation/iframes_different_origin.html";
505 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); 509 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES));
506 LoadIFrames(2); 510 LoadIFrames(2);
507 511
508 iframe_xpath_ = L"//iframe[@id='iframe_0']"; 512 iframe_xpath_ = "//iframe[@id='iframe_0']";
509 AddGeolocationWatch(true); 513 AddGeolocationWatch(true);
510 SetInfobarResponse(iframe_urls_[0], true); 514 SetInfobarResponse(iframe_urls_[0], true);
511 CheckGeoposition(fake_latitude_, fake_longitude_); 515 CheckGeoposition(fake_latitude_, fake_longitude_);
512 516
513 // Refresh geoposition, but let's not yet create the watch on the second frame 517 // Refresh geoposition, but let's not yet create the watch on the second frame
514 // so that it'll fetch from cache. 518 // so that it'll fetch from cache.
515 double cached_position_latitude = 5.67; 519 double cached_position_latitude = 5.67;
516 double cached_position_lognitude = 8.09; 520 double cached_position_lognitude = 8.09;
517 content::WindowedNotificationObserver observer( 521 content::WindowedNotificationObserver observer(
518 content::NOTIFICATION_LOAD_STOP, 522 content::NOTIFICATION_LOAD_STOP,
519 content::Source<NavigationController>( 523 content::Source<NavigationController>(
520 &chrome::GetActiveWebContents(current_browser_)->GetController())); 524 &chrome::GetActiveWebContents(current_browser_)->GetController()));
521 NotifyGeoposition(cached_position_latitude, cached_position_lognitude); 525 NotifyGeoposition(cached_position_latitude, cached_position_lognitude);
522 observer.Wait(); 526 observer.Wait();
523 CheckGeoposition(cached_position_latitude, cached_position_lognitude); 527 CheckGeoposition(cached_position_latitude, cached_position_lognitude);
524 528
525 // Disable navigation for this frame. 529 // Disable navigation for this frame.
526 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); 530 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)");
527 531
528 // Now go ahead an authorize the second frame. 532 // Now go ahead an authorize the second frame.
529 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 533 iframe_xpath_ = "//iframe[@id='iframe_1']";
530 AddGeolocationWatch(true); 534 AddGeolocationWatch(true);
531 // WebKit will use its cache, but we also broadcast a position shortly 535 // WebKit will use its cache, but we also broadcast a position shortly
532 // afterwards. We're only interested in the first navigation for the success 536 // afterwards. We're only interested in the first navigation for the success
533 // callback from the cached position. 537 // callback from the cached position.
534 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)"); 538 CheckStringValueFromJavascript("1", "geoSetMaxNavigateCount(1)");
535 SetInfobarResponse(iframe_urls_[1], true); 539 SetInfobarResponse(iframe_urls_[1], true);
536 CheckGeoposition(cached_position_latitude, cached_position_lognitude); 540 CheckGeoposition(cached_position_latitude, cached_position_lognitude);
537 } 541 }
538 542
539 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, CancelPermissionForFrame) { 543 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, CancelPermissionForFrame) {
540 html_for_tests_ = "files/geolocation/iframes_different_origin.html"; 544 html_for_tests_ = "files/geolocation/iframes_different_origin.html";
541 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); 545 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES));
542 LoadIFrames(2); 546 LoadIFrames(2);
543 LOG(WARNING) << "frames loaded"; 547 LOG(WARNING) << "frames loaded";
544 548
545 iframe_xpath_ = L"//iframe[@id='iframe_0']"; 549 iframe_xpath_ = "//iframe[@id='iframe_0']";
546 AddGeolocationWatch(true); 550 AddGeolocationWatch(true);
547 SetInfobarResponse(iframe_urls_[0], true); 551 SetInfobarResponse(iframe_urls_[0], true);
548 CheckGeoposition(fake_latitude_, fake_longitude_); 552 CheckGeoposition(fake_latitude_, fake_longitude_);
549 // Disables further prompts from this iframe. 553 // Disables further prompts from this iframe.
550 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); 554 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)");
551 555
552 // Test second iframe from a different origin with a cached geoposition will 556 // Test second iframe from a different origin with a cached geoposition will
553 // create the infobar. 557 // create the infobar.
554 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 558 iframe_xpath_ = "//iframe[@id='iframe_1']";
555 AddGeolocationWatch(true); 559 AddGeolocationWatch(true);
556 560
557 InfoBarService* infobar_service = InfoBarService::FromWebContents( 561 InfoBarService* infobar_service = InfoBarService::FromWebContents(
558 chrome::GetActiveWebContents(current_browser_)); 562 chrome::GetActiveWebContents(current_browser_));
559 size_t num_infobars_before_cancel = infobar_service->GetInfoBarCount(); 563 size_t num_infobars_before_cancel = infobar_service->GetInfoBarCount();
560 // Change the iframe, and ensure the infobar is gone. 564 // Change the iframe, and ensure the infobar is gone.
561 IFrameLoader change_iframe_1(current_browser_, 1, current_url_); 565 IFrameLoader change_iframe_1(current_browser_, 1, current_url_);
562 size_t num_infobars_after_cancel = infobar_service->GetInfoBarCount(); 566 size_t num_infobars_after_cancel = infobar_service->GetInfoBarCount();
563 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); 567 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1);
564 } 568 }
(...skipping 10 matching lines...) Expand all
575 579
576 // Crashy, http://crbug.com/66400. 580 // Crashy, http://crbug.com/66400.
577 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoInfoBarBeforeStart) { 581 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoInfoBarBeforeStart) {
578 // See http://crbug.com/42789 582 // See http://crbug.com/42789
579 html_for_tests_ = "files/geolocation/iframes_different_origin.html"; 583 html_for_tests_ = "files/geolocation/iframes_different_origin.html";
580 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); 584 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES));
581 LoadIFrames(2); 585 LoadIFrames(2);
582 LOG(WARNING) << "frames loaded"; 586 LOG(WARNING) << "frames loaded";
583 587
584 // Access navigator.geolocation, but ensure it won't request permission. 588 // Access navigator.geolocation, but ensure it won't request permission.
585 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 589 iframe_xpath_ = "//iframe[@id='iframe_1']";
586 CheckStringValueFromJavascript("object", "geoAccessNavigatorGeolocation()"); 590 CheckStringValueFromJavascript("object", "geoAccessNavigatorGeolocation()");
587 591
588 iframe_xpath_ = L"//iframe[@id='iframe_0']"; 592 iframe_xpath_ = "//iframe[@id='iframe_0']";
589 AddGeolocationWatch(true); 593 AddGeolocationWatch(true);
590 SetInfobarResponse(iframe_urls_[0], true); 594 SetInfobarResponse(iframe_urls_[0], true);
591 CheckGeoposition(fake_latitude_, fake_longitude_); 595 CheckGeoposition(fake_latitude_, fake_longitude_);
592 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); 596 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)");
593 597
594 // Permission should be requested after adding a watch. 598 // Permission should be requested after adding a watch.
595 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 599 iframe_xpath_ = "//iframe[@id='iframe_1']";
596 AddGeolocationWatch(true); 600 AddGeolocationWatch(true);
597 SetInfobarResponse(iframe_urls_[1], true); 601 SetInfobarResponse(iframe_urls_[1], true);
598 CheckGeoposition(fake_latitude_, fake_longitude_); 602 CheckGeoposition(fake_latitude_, fake_longitude_);
599 } 603 }
600 604
601 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TwoWatchesInOneFrame) { 605 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TwoWatchesInOneFrame) {
602 html_for_tests_ = "files/geolocation/two_watches.html"; 606 html_for_tests_ = "files/geolocation/two_watches.html";
603 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); 607 ASSERT_TRUE(Initialize(INITIALIZATION_NONE));
604 // First, set the JavaScript to navigate when it receives |final_position|. 608 // First, set the JavaScript to navigate when it receives |final_position|.
605 double final_position_latitude = 3.17; 609 double final_position_latitude = 3.17;
606 double final_position_longitude = 4.23; 610 double final_position_longitude = 4.23;
607 std::string script = base::StringPrintf( 611 std::string script = base::StringPrintf(
608 "window.domAutomationController.send(geoSetFinalPosition(%f, %f))", 612 "window.domAutomationController.send(geoSetFinalPosition(%f, %f))",
609 final_position_latitude, final_position_longitude); 613 final_position_latitude, final_position_longitude);
610 std::string js_result; 614 std::string js_result;
611 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( 615 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString(
612 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), 616 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(),
613 L"", UTF8ToWide(script), &js_result)); 617 "",
618 script,
619 &js_result));
614 EXPECT_EQ(js_result, "ok"); 620 EXPECT_EQ(js_result, "ok");
615 621
616 // Send a position which both geolocation watches will receive. 622 // Send a position which both geolocation watches will receive.
617 AddGeolocationWatch(true); 623 AddGeolocationWatch(true);
618 SetInfobarResponse(current_url_, true); 624 SetInfobarResponse(current_url_, true);
619 CheckGeoposition(fake_latitude_, fake_longitude_); 625 CheckGeoposition(fake_latitude_, fake_longitude_);
620 626
621 // The second watch will now have cancelled. Ensure an update still makes 627 // The second watch will now have cancelled. Ensure an update still makes
622 // its way through to the first watcher. 628 // its way through to the first watcher.
623 content::WindowedNotificationObserver observer( 629 content::WindowedNotificationObserver observer(
624 content::NOTIFICATION_LOAD_STOP, 630 content::NOTIFICATION_LOAD_STOP,
625 content::Source<NavigationController>( 631 content::Source<NavigationController>(
626 &chrome::GetActiveWebContents(current_browser_)->GetController())); 632 &chrome::GetActiveWebContents(current_browser_)->GetController()));
627 NotifyGeoposition(final_position_latitude, final_position_longitude); 633 NotifyGeoposition(final_position_latitude, final_position_longitude);
628 observer.Wait(); 634 observer.Wait();
629 CheckGeoposition(final_position_latitude, final_position_longitude); 635 CheckGeoposition(final_position_latitude, final_position_longitude);
630 } 636 }
631 637
632 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TabDestroyed) { 638 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TabDestroyed) {
633 html_for_tests_ = "files/geolocation/tab_destroyed.html"; 639 html_for_tests_ = "files/geolocation/tab_destroyed.html";
634 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES)); 640 ASSERT_TRUE(Initialize(INITIALIZATION_IFRAMES));
635 LoadIFrames(3); 641 LoadIFrames(3);
636 642
637 iframe_xpath_ = L"//iframe[@id='iframe_0']"; 643 iframe_xpath_ = "//iframe[@id='iframe_0']";
638 AddGeolocationWatch(true); 644 AddGeolocationWatch(true);
639 645
640 iframe_xpath_ = L"//iframe[@id='iframe_1']"; 646 iframe_xpath_ = "//iframe[@id='iframe_1']";
641 AddGeolocationWatch(false); 647 AddGeolocationWatch(false);
642 648
643 iframe_xpath_ = L"//iframe[@id='iframe_2']"; 649 iframe_xpath_ = "//iframe[@id='iframe_2']";
644 AddGeolocationWatch(false); 650 AddGeolocationWatch(false);
645 651
646 std::string script = 652 std::string script =
647 "window.domAutomationController.setAutomationId(0);"
648 "window.domAutomationController.send(window.close());"; 653 "window.domAutomationController.send(window.close());";
649 bool result = 654 bool result =
650 content::ExecuteJavaScript( 655 content::ExecuteJavaScript(
651 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), 656 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(),
652 L"", UTF8ToWide(script)); 657 "",
658 script);
653 EXPECT_EQ(result, true); 659 EXPECT_EQ(result, true);
654 } 660 }
655 661
656 } // namespace 662 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/window_open_apitest.cc ('k') | chrome/browser/history/history_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698