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_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/dom_operation_notification_details.h" | 10 #include "chrome/browser/dom_operation_notification_details.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 registrar_.Add(this, NotificationType::LOAD_STOP, | 44 registrar_.Add(this, NotificationType::LOAD_STOP, |
45 Source<NavigationController>(controller)); | 45 Source<NavigationController>(controller)); |
46 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, | 46 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, |
47 NotificationService::AllSources()); | 47 NotificationService::AllSources()); |
48 std::string script = StringPrintf( | 48 std::string script = StringPrintf( |
49 "window.domAutomationController.setAutomationId(0);" | 49 "window.domAutomationController.setAutomationId(0);" |
50 "window.domAutomationController.send(addIFrame(%d, \"%s\"));", | 50 "window.domAutomationController.send(addIFrame(%d, \"%s\"));", |
51 iframe_id, | 51 iframe_id, |
52 url.spec().c_str()); | 52 url.spec().c_str()); |
53 browser->GetSelectedTabContents()->render_view_host()-> | 53 browser->GetSelectedTabContents()->render_view_host()-> |
54 ExecuteJavascriptInWebFrame(L"", UTF8ToWide(script)); | 54 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(script)); |
55 ui_test_utils::RunMessageLoop(); | 55 ui_test_utils::RunMessageLoop(); |
56 | 56 |
57 EXPECT_EQ(StringPrintf("\"%d\"", iframe_id), javascript_response_); | 57 EXPECT_EQ(StringPrintf("\"%d\"", iframe_id), javascript_response_); |
58 registrar_.RemoveAll(); | 58 registrar_.RemoveAll(); |
59 // Now that we loaded the iframe, let's fetch its src. | 59 // Now that we loaded the iframe, let's fetch its src. |
60 script = StringPrintf( | 60 script = StringPrintf( |
61 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); | 61 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); |
62 std::string iframe_src; | 62 std::string iframe_src; |
63 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 63 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
64 browser->GetSelectedTabContents()->render_view_host(), | 64 browser->GetSelectedTabContents()->render_view_host(), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 NotificationService::AllSources()); | 123 NotificationService::AllSources()); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 void AddWatchAndWaitForNotification(RenderViewHost* render_view_host, | 127 void AddWatchAndWaitForNotification(RenderViewHost* render_view_host, |
128 const std::wstring& iframe_xpath) { | 128 const std::wstring& iframe_xpath) { |
129 LOG(WARNING) << "will add geolocation watch"; | 129 LOG(WARNING) << "will add geolocation watch"; |
130 std::string script = | 130 std::string script = |
131 "window.domAutomationController.setAutomationId(0);" | 131 "window.domAutomationController.setAutomationId(0);" |
132 "window.domAutomationController.send(geoStart());"; | 132 "window.domAutomationController.send(geoStart());"; |
133 render_view_host->ExecuteJavascriptInWebFrame(iframe_xpath, | 133 render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), |
134 UTF8ToWide(script)); | 134 UTF8ToUTF16(script)); |
135 ui_test_utils::RunMessageLoop(); | 135 ui_test_utils::RunMessageLoop(); |
136 registrar_.RemoveAll(); | 136 registrar_.RemoveAll(); |
137 LOG(WARNING) << "got geolocation watch" << javascript_response_; | 137 LOG(WARNING) << "got geolocation watch" << javascript_response_; |
138 EXPECT_NE("\"0\"", javascript_response_); | 138 EXPECT_NE("\"0\"", javascript_response_); |
139 if (wait_for_infobar_) { | 139 if (wait_for_infobar_) { |
140 EXPECT_TRUE(infobar_); | 140 EXPECT_TRUE(infobar_); |
141 } else { | 141 } else { |
142 EXPECT_TRUE(navigation_completed_); | 142 EXPECT_TRUE(navigation_completed_); |
143 } | 143 } |
144 } | 144 } |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 "window.domAutomationController.setAutomationId(0);" | 642 "window.domAutomationController.setAutomationId(0);" |
643 "window.domAutomationController.send(window.close());"; | 643 "window.domAutomationController.send(window.close());"; |
644 bool result = | 644 bool result = |
645 ui_test_utils::ExecuteJavaScript( | 645 ui_test_utils::ExecuteJavaScript( |
646 current_browser_->GetSelectedTabContents()->render_view_host(), | 646 current_browser_->GetSelectedTabContents()->render_view_host(), |
647 L"", UTF8ToWide(script)); | 647 L"", UTF8ToWide(script)); |
648 EXPECT_EQ(result, true); | 648 EXPECT_EQ(result, true); |
649 } | 649 } |
650 | 650 |
651 } // namespace | 651 } // namespace |
OLD | NEW |