OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/waitable_event.h" | 7 #include "base/waitable_event.h" |
8 #include "chrome/browser/app_modal_dialog.h" | 8 #include "chrome/browser/app_modal_dialog.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/geoposition.h" | 24 #include "chrome/common/geoposition.h" |
25 #include "chrome/common/notification_details.h" | 25 #include "chrome/common/notification_details.h" |
26 #include "chrome/common/notification_service.h" | 26 #include "chrome/common/notification_service.h" |
27 #include "chrome/common/notification_type.h" | 27 #include "chrome/common/notification_type.h" |
28 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
29 #include "chrome/test/in_process_browser_test.h" | 29 #include "chrome/test/in_process_browser_test.h" |
30 #include "chrome/test/ui_test_utils.h" | 30 #include "chrome/test/ui_test_utils.h" |
31 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
| 32 #include "net/test/test_server.h" |
32 | 33 |
33 // Used to block until an iframe is loaded via a javascript call. | 34 // Used to block until an iframe is loaded via a javascript call. |
34 // Note: NavigateToURLBlockUntilNavigationsComplete doesn't seem to work for | 35 // Note: NavigateToURLBlockUntilNavigationsComplete doesn't seem to work for |
35 // multiple embedded iframes, as notifications seem to be 'batched'. Instead, we | 36 // multiple embedded iframes, as notifications seem to be 'batched'. Instead, we |
36 // load and wait one single frame here by calling a javascript function. | 37 // load and wait one single frame here by calling a javascript function. |
37 class IFrameLoader : public NotificationObserver { | 38 class IFrameLoader : public NotificationObserver { |
38 public: | 39 public: |
39 IFrameLoader(Browser* browser, int iframe_id, const GURL& url) | 40 IFrameLoader(Browser* browser, int iframe_id, const GURL& url) |
40 : navigation_completed_(false), | 41 : navigation_completed_(false), |
41 javascript_completed_(false) { | 42 javascript_completed_(false) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 iframe_xpath_, UTF8ToWide(script), &result); | 324 iframe_xpath_, UTF8ToWide(script), &result); |
324 EXPECT_EQ(expected, result); | 325 EXPECT_EQ(expected, result); |
325 } | 326 } |
326 | 327 |
327 void CheckStringValueFromJavascript( | 328 void CheckStringValueFromJavascript( |
328 const std::string& expected, const std::string& function) { | 329 const std::string& expected, const std::string& function) { |
329 CheckStringValueFromJavascriptForTab( | 330 CheckStringValueFromJavascriptForTab( |
330 expected, function, current_browser_->GetSelectedTabContents()); | 331 expected, function, current_browser_->GetSelectedTabContents()); |
331 } | 332 } |
332 | 333 |
333 scoped_refptr<HTTPTestServer> server_; | 334 scoped_refptr<net::HTTPTestServer> server_; |
334 InfoBarDelegate* infobar_; | 335 InfoBarDelegate* infobar_; |
335 Browser* current_browser_; | 336 Browser* current_browser_; |
336 // path element of a URL referencing the html content for this test. | 337 // path element of a URL referencing the html content for this test. |
337 std::string html_for_tests_; | 338 std::string html_for_tests_; |
338 // This member defines the iframe (or top-level page, if empty) where the | 339 // This member defines the iframe (or top-level page, if empty) where the |
339 // javascript calls will run. | 340 // javascript calls will run. |
340 std::wstring iframe_xpath_; | 341 std::wstring iframe_xpath_; |
341 // The current url for the top level page. | 342 // The current url for the top level page. |
342 GURL current_url_; | 343 GURL current_url_; |
343 // If not empty, the GURL for the first iframe. | 344 // If not empty, the GURL for the first iframe. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 SetInfobarResponse(current_url_, true); | 577 SetInfobarResponse(current_url_, true); |
577 CheckGeoposition(MockLocationProvider::instance_->position_); | 578 CheckGeoposition(MockLocationProvider::instance_->position_); |
578 | 579 |
579 // The second watch will now have cancelled. Ensure an update still makes | 580 // The second watch will now have cancelled. Ensure an update still makes |
580 // its way through to the first watcher. | 581 // its way through to the first watcher. |
581 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, NewRunnableFunction( | 582 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, NewRunnableFunction( |
582 &NotifyGeopositionOnIOThread, final_position)); | 583 &NotifyGeopositionOnIOThread, final_position)); |
583 WaitForJSPrompt(); | 584 WaitForJSPrompt(); |
584 CheckGeoposition(final_position); | 585 CheckGeoposition(final_position); |
585 } | 586 } |
OLD | NEW |