OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
9 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 zoomed_correctly(false), | 127 zoomed_correctly(false), |
128 expected_inner_width(inner_width), | 128 expected_inner_width(inner_width), |
129 tolerance(tolerance) { | 129 tolerance(tolerance) { |
130 SetupOnResizeCallback(host, msg_label); | 130 SetupOnResizeCallback(host, msg_label); |
131 } | 131 } |
132 | 132 |
133 void SetupOnResizeCallback(const ToRenderFrameHost& adapter, | 133 void SetupOnResizeCallback(const ToRenderFrameHost& adapter, |
134 const std::string& label) { | 134 const std::string& label) { |
135 const char kOnResizeCallbackSetup[] = | 135 const char kOnResizeCallbackSetup[] = |
136 "document.body.onresize = function(){" | 136 "document.body.onresize = function(){" |
137 " window.domAutomationController.setAutomationId(0);" | |
138 " window.domAutomationController.send('%s ' + window.innerWidth);" | 137 " window.domAutomationController.send('%s ' + window.innerWidth);" |
139 "};"; | 138 "};"; |
140 EXPECT_TRUE(ExecuteScript( | 139 EXPECT_TRUE(ExecuteScript( |
141 adapter, base::StringPrintf(kOnResizeCallbackSetup, label.c_str()))); | 140 adapter, base::StringPrintf(kOnResizeCallbackSetup, label.c_str()))); |
142 } | 141 } |
143 | 142 |
144 void Check(const std::string& status_msg) { | 143 void Check(const std::string& status_msg) { |
145 if (!base::StartsWith(status_msg, msg_label, base::CompareCase::SENSITIVE)) | 144 if (!base::StartsWith(status_msg, msg_label, base::CompareCase::SENSITIVE)) |
146 return; | 145 return; |
147 | 146 |
(...skipping 13 matching lines...) Expand all Loading... |
161 // This struct is used to wait until a resize has occurred. | 160 // This struct is used to wait until a resize has occurred. |
162 struct ResizeObserver { | 161 struct ResizeObserver { |
163 ResizeObserver(RenderFrameHost* host) | 162 ResizeObserver(RenderFrameHost* host) |
164 : frame_host(host) { | 163 : frame_host(host) { |
165 SetupOnResizeCallback(host); | 164 SetupOnResizeCallback(host); |
166 } | 165 } |
167 | 166 |
168 void SetupOnResizeCallback(const ToRenderFrameHost& adapter) { | 167 void SetupOnResizeCallback(const ToRenderFrameHost& adapter) { |
169 const char kOnResizeCallbackSetup[] = | 168 const char kOnResizeCallbackSetup[] = |
170 "document.body.onresize = function(){" | 169 "document.body.onresize = function(){" |
171 " window.domAutomationController.setAutomationId(0);" | |
172 " window.domAutomationController.send('Resized');" | 170 " window.domAutomationController.send('Resized');" |
173 "};"; | 171 "};"; |
174 EXPECT_TRUE(ExecuteScript( | 172 EXPECT_TRUE(ExecuteScript( |
175 adapter, kOnResizeCallbackSetup)); | 173 adapter, kOnResizeCallbackSetup)); |
176 } | 174 } |
177 | 175 |
178 bool IsResizeCallback(const std::string& status_msg) { | 176 bool IsResizeCallback(const std::string& status_msg) { |
179 return status_msg == "Resized"; | 177 return status_msg == "Resized"; |
180 } | 178 } |
181 | 179 |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 // approximate. As the common failure mode would be that the zoom is ~1 | 649 // approximate. As the common failure mode would be that the zoom is ~1 |
652 // instead of ~2, this approximation shouldn't be problematic. | 650 // instead of ~2, this approximation shouldn't be problematic. |
653 EXPECT_NEAR( | 651 EXPECT_NEAR( |
654 new_zoom_factor, | 652 new_zoom_factor, |
655 GetMainFrameZoomFactor(web_contents(), main_frame_window_border), | 653 GetMainFrameZoomFactor(web_contents(), main_frame_window_border), |
656 .1); | 654 .1); |
657 } | 655 } |
658 #endif | 656 #endif |
659 | 657 |
660 } // namespace content | 658 } // namespace content |
OLD | NEW |