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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 406 } |
407 | 407 |
408 void GeolocationBrowserTest::ExpectValueFromScript( | 408 void GeolocationBrowserTest::ExpectValueFromScript( |
409 const std::string& expected, | 409 const std::string& expected, |
410 const std::string& function) { | 410 const std::string& function) { |
411 ExpectValueFromScriptForFrame(expected, function, render_frame_host_); | 411 ExpectValueFromScriptForFrame(expected, function, render_frame_host_); |
412 } | 412 } |
413 | 413 |
414 bool GeolocationBrowserTest::SetPositionAndWaitUntilUpdated(double latitude, | 414 bool GeolocationBrowserTest::SetPositionAndWaitUntilUpdated(double latitude, |
415 double longitude) { | 415 double longitude) { |
| 416 content::DOMMessageQueue dom_message_queue; |
| 417 |
416 fake_latitude_ = latitude; | 418 fake_latitude_ = latitude; |
417 fake_longitude_ = longitude; | 419 fake_longitude_ = longitude; |
418 ui_test_utils::OverrideGeolocation(latitude, longitude); | 420 ui_test_utils::OverrideGeolocation(latitude, longitude); |
419 | 421 |
420 // Now wait until the new position gets to the script. | 422 std::string result; |
421 // Control will return (a) if the update has already been received, or (b) | 423 if (!dom_message_queue.WaitForMessage(&result)) |
422 // when the update is received. This will hang if the position is never | 424 return false; |
423 // updated. Currently this expects the position to be updated once; if your | 425 return result == "\"geoposition-updated\""; |
424 // test updates it repeatedly, |position_updated| (JS) needs to change to an | |
425 // int to count how often it's been updated. | |
426 std::string result = | |
427 RunScript(render_frame_host_, "checkIfGeopositionUpdated()"); | |
428 return result == "geoposition-updated"; | |
429 } | 426 } |
430 | 427 |
431 int GeolocationBrowserTest::GetRequestQueueSize( | 428 int GeolocationBrowserTest::GetRequestQueueSize( |
432 PermissionRequestManager* manager) { | 429 PermissionRequestManager* manager) { |
433 return static_cast<int>(manager->requests_.size()); | 430 return static_cast<int>(manager->requests_.size()); |
434 } | 431 } |
435 | 432 |
436 void GeolocationBrowserTest::TogglePersist(bool persist) { | 433 void GeolocationBrowserTest::TogglePersist(bool persist) { |
437 content::WebContents* web_contents = | 434 content::WebContents* web_contents = |
438 current_browser()->tab_strip_model()->GetActiveWebContents(); | 435 current_browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT)); | 735 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT)); |
739 WatchPositionAndObservePermissionRequest(true); | 736 WatchPositionAndObservePermissionRequest(true); |
740 | 737 |
741 // TODO(mvanouwerkerk): Can't close a window you did not open. Maybe this was | 738 // TODO(mvanouwerkerk): Can't close a window you did not open. Maybe this was |
742 // valid when the test was written, but now it just prints "Scripts may close | 739 // valid when the test was written, but now it just prints "Scripts may close |
743 // only the windows that were opened by it." | 740 // only the windows that were opened by it." |
744 std::string script = "window.domAutomationController.send(window.close())"; | 741 std::string script = "window.domAutomationController.send(window.close())"; |
745 ASSERT_TRUE(content::ExecuteScript( | 742 ASSERT_TRUE(content::ExecuteScript( |
746 current_browser()->tab_strip_model()->GetActiveWebContents(), script)); | 743 current_browser()->tab_strip_model()->GetActiveWebContents(), script)); |
747 } | 744 } |
OLD | NEW |