OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 private: | 131 private: |
132 OwnPtr<WebLayerTreeView> m_layerTreeView; | 132 OwnPtr<WebLayerTreeView> m_layerTreeView; |
133 }; | 133 }; |
134 | 134 |
135 class WebFrameTest : public testing::Test { | 135 class WebFrameTest : public testing::Test { |
136 public: | 136 public: |
137 WebFrameTest() | 137 WebFrameTest() |
138 : m_baseURL("http://www.test.com/") | 138 : m_baseURL("http://www.test.com/") |
139 , m_chromeURL("chrome://") | 139 , m_chromeURL("chrome://") |
140 , m_webView(0) | 140 , m_webView(0) |
| 141 , m_mainFrame(0) |
141 { | 142 { |
142 } | 143 } |
143 | 144 |
144 virtual ~WebFrameTest() | 145 virtual ~WebFrameTest() |
145 { | 146 { |
| 147 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 148 |
146 if (m_webView) | 149 if (m_webView) |
147 m_webView->close(); | 150 m_webView->close(); |
148 } | 151 if (m_mainFrame) |
149 | 152 m_mainFrame->close(); |
150 virtual void TearDown() | |
151 { | |
152 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | |
153 } | 153 } |
154 | 154 |
155 void registerMockedHttpURLLoad(const std::string& fileName) | 155 void registerMockedHttpURLLoad(const std::string& fileName) |
156 { | 156 { |
157 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 157 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
158 } | 158 } |
159 | 159 |
160 void registerMockedChromeURLLoad(const std::string& fileName) | 160 void registerMockedChromeURLLoad(const std::string& fileName) |
161 { | 161 { |
162 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 162 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
163 } | 163 } |
164 | 164 |
165 void createCompositingWebView() | 165 void createCompositingWebView() |
166 { | 166 { |
167 m_fakeCompositingWebViewClient = adoptPtr(new FakeCompositingWebViewClie
nt()); | 167 m_fakeCompositingWebViewClient = adoptPtr(new FakeCompositingWebViewClie
nt()); |
| 168 m_mainFrame = WebFrame::create(&m_fakeCompositingWebViewClient->m_fakeWe
bFrameClient); |
168 m_webView = WebView::create(m_fakeCompositingWebViewClient.get()); | 169 m_webView = WebView::create(m_fakeCompositingWebViewClient.get()); |
169 m_webView->settings()->setJavaScriptEnabled(true); | 170 m_webView->settings()->setJavaScriptEnabled(true); |
170 m_webView->settings()->setForceCompositingMode(true); | 171 m_webView->settings()->setForceCompositingMode(true); |
171 m_webView->settings()->setAcceleratedCompositingEnabled(true); | 172 m_webView->settings()->setAcceleratedCompositingEnabled(true); |
172 m_webView->settings()->setAcceleratedCompositingForFixedPositionEnabled(
true); | 173 m_webView->settings()->setAcceleratedCompositingForFixedPositionEnabled(
true); |
173 m_webView->settings()->setAcceleratedCompositingForOverflowScrollEnabled
(true); | 174 m_webView->settings()->setAcceleratedCompositingForOverflowScrollEnabled
(true); |
174 m_webView->settings()->setAcceleratedCompositingForScrollableFramesEnabl
ed(true); | 175 m_webView->settings()->setAcceleratedCompositingForScrollableFramesEnabl
ed(true); |
175 m_webView->settings()->setCompositedScrollingForFramesEnabled(true); | 176 m_webView->settings()->setCompositedScrollingForFramesEnabled(true); |
176 m_webView->settings()->setFixedPositionCreatesStackingContext(true); | 177 m_webView->settings()->setFixedPositionCreatesStackingContext(true); |
177 m_webView->initializeMainFrame(&m_fakeCompositingWebViewClient->m_fakeWe
bFrameClient); | 178 m_webView->initializeMainFrame(m_mainFrame); |
| 179 } |
| 180 |
| 181 // Wrapper around FrameTestHelpers::createWebViewAndLoad() that allows the t
est fixture to handle the main frame's lifetime. |
| 182 void initializeWebViewAndLoad(const std::string& url, bool enableJavascript
= false, WebFrameClient* webFrameClient = 0, WebViewClient* webViewClient = 0) |
| 183 { |
| 184 ASSERT(!m_webView); |
| 185 ASSERT(!m_mainFrame); |
| 186 m_mainFrame = WebFrame::create(webFrameClient); |
| 187 initializeWebViewAndLoad(m_mainFrame, url, enableJavascript, webViewClie
nt); |
| 188 } |
| 189 |
| 190 void initializeWebView(bool enableJavascript, WebFrameClient* webFrameClient
, WebViewClient* webViewClient = 0) |
| 191 { |
| 192 ASSERT(!m_webView); |
| 193 ASSERT(!m_mainFrame); |
| 194 m_mainFrame = WebFrame::create(webFrameClient); |
| 195 initializeWebView(m_mainFrame, enableJavascript, webViewClient); |
178 } | 196 } |
179 | 197 |
180 protected: | 198 protected: |
181 WebViewImpl* webViewImpl() const { return toWebViewImpl(m_webView); } | 199 WebViewImpl* webViewImpl() const { return toWebViewImpl(m_webView); } |
182 | 200 |
183 std::string m_baseURL; | 201 std::string m_baseURL; |
184 std::string m_chromeURL; | 202 std::string m_chromeURL; |
185 OwnPtr<FakeCompositingWebViewClient> m_fakeCompositingWebViewClient; | 203 OwnPtr<FakeCompositingWebViewClient> m_fakeCompositingWebViewClient; |
186 | 204 |
187 WebView* m_webView; | 205 WebView* m_webView; |
| 206 WebFrame* m_mainFrame; |
188 }; | 207 }; |
189 | 208 |
190 TEST_F(WebFrameTest, ContentText) | 209 TEST_F(WebFrameTest, ContentText) |
191 { | 210 { |
192 registerMockedHttpURLLoad("iframes_test.html"); | 211 registerMockedHttpURLLoad("iframes_test.html"); |
193 registerMockedHttpURLLoad("visible_iframe.html"); | 212 registerMockedHttpURLLoad("visible_iframe.html"); |
194 registerMockedHttpURLLoad("invisible_iframe.html"); | 213 registerMockedHttpURLLoad("invisible_iframe.html"); |
195 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 214 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
196 | 215 |
197 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test
.html"); | 216 initializeWebViewAndLoad(m_baseURL + "iframes_test.html"); |
198 | 217 |
199 // Now retrieve the frames text and test it only includes visible elements. | 218 // Now retrieve the frames text and test it only includes visible elements. |
200 std::string content = std::string(m_webView->mainFrame()->contentAsText(1024
).utf8().data()); | 219 std::string content = std::string(m_webView->mainFrame()->contentAsText(1024
).utf8().data()); |
201 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); | 220 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); |
202 EXPECT_NE(std::string::npos, content.find(" visible iframe")); | 221 EXPECT_NE(std::string::npos, content.find(" visible iframe")); |
203 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); | 222 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); |
204 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); | 223 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); |
205 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); | 224 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); |
206 } | 225 } |
207 | 226 |
208 TEST_F(WebFrameTest, FrameForEnteredContext) | 227 TEST_F(WebFrameTest, FrameForEnteredContext) |
209 { | 228 { |
210 registerMockedHttpURLLoad("iframes_test.html"); | 229 registerMockedHttpURLLoad("iframes_test.html"); |
211 registerMockedHttpURLLoad("visible_iframe.html"); | 230 registerMockedHttpURLLoad("visible_iframe.html"); |
212 registerMockedHttpURLLoad("invisible_iframe.html"); | 231 registerMockedHttpURLLoad("invisible_iframe.html"); |
213 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 232 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
214 | 233 |
215 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test
.html", true); | 234 initializeWebViewAndLoad(m_baseURL + "iframes_test.html", true); |
216 | 235 |
217 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 236 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
218 EXPECT_EQ(m_webView->mainFrame(), | 237 EXPECT_EQ(m_webView->mainFrame(), |
219 WebFrame::frameForContext( | 238 WebFrame::frameForContext( |
220 m_webView->mainFrame()->mainWorldScriptContext())); | 239 m_webView->mainFrame()->mainWorldScriptContext())); |
221 EXPECT_EQ(m_webView->mainFrame()->firstChild(), | 240 EXPECT_EQ(m_webView->mainFrame()->firstChild(), |
222 WebFrame::frameForContext( | 241 WebFrame::frameForContext( |
223 m_webView->mainFrame()->firstChild()->mainWorldScriptContext()
)); | 242 m_webView->mainFrame()->firstChild()->mainWorldScriptContext()
)); |
224 } | 243 } |
225 | 244 |
226 TEST_F(WebFrameTest, FormWithNullFrame) | 245 TEST_F(WebFrameTest, FormWithNullFrame) |
227 { | 246 { |
228 registerMockedHttpURLLoad("form.html"); | 247 registerMockedHttpURLLoad("form.html"); |
229 | 248 |
230 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.html"); | 249 initializeWebViewAndLoad(m_baseURL + "form.html"); |
231 | 250 |
232 WebVector<WebFormElement> forms; | 251 WebVector<WebFormElement> forms; |
233 m_webView->mainFrame()->document().forms(forms); | 252 m_webView->mainFrame()->document().forms(forms); |
234 m_webView->close(); | 253 m_webView->close(); |
235 m_webView = 0; | 254 m_webView = 0; |
236 | 255 |
237 EXPECT_EQ(forms.size(), 1U); | 256 EXPECT_EQ(forms.size(), 1U); |
238 | 257 |
239 // This test passes if this doesn't crash. | 258 // This test passes if this doesn't crash. |
240 WebSearchableFormData searchableDataForm(forms[0]); | 259 WebSearchableFormData searchableDataForm(forms[0]); |
241 } | 260 } |
242 | 261 |
243 TEST_F(WebFrameTest, ChromePageJavascript) | 262 TEST_F(WebFrameTest, ChromePageJavascript) |
244 { | 263 { |
245 registerMockedChromeURLLoad("history.html"); | 264 registerMockedChromeURLLoad("history.html"); |
246 | 265 |
247 // Pass true to enable JavaScript. | 266 // Pass true to enable JavaScript. |
248 m_webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.ht
ml", true); | 267 initializeWebViewAndLoad(m_chromeURL + "history.html", true); |
249 | 268 |
250 // Try to run JS against the chrome-style URL. | 269 // Try to run JS against the chrome-style URL. |
251 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Clobbered'))"); | 270 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Clobbered'))"); |
252 | 271 |
253 // Required to see any updates in contentAsText. | 272 // Required to see any updates in contentAsText. |
254 m_webView->layout(); | 273 m_webView->layout(); |
255 | 274 |
256 // Now retrieve the frame's text and ensure it was modified by running javas
cript. | 275 // Now retrieve the frame's text and ensure it was modified by running javas
cript. |
257 std::string content = std::string(m_webView->mainFrame()->contentAsText(1024
).utf8().data()); | 276 std::string content = std::string(m_webView->mainFrame()->contentAsText(1024
).utf8().data()); |
258 EXPECT_NE(std::string::npos, content.find("Clobbered")); | 277 EXPECT_NE(std::string::npos, content.find("Clobbered")); |
259 } | 278 } |
260 | 279 |
261 TEST_F(WebFrameTest, ChromePageNoJavascript) | 280 TEST_F(WebFrameTest, ChromePageNoJavascript) |
262 { | 281 { |
263 registerMockedChromeURLLoad("history.html"); | 282 registerMockedChromeURLLoad("history.html"); |
264 | 283 |
265 /// Pass true to enable JavaScript. | 284 /// Pass true to enable JavaScript. |
266 m_webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.ht
ml", true); | 285 initializeWebViewAndLoad(m_chromeURL + "history.html", true); |
267 | 286 |
268 // Try to run JS against the chrome-style URL after prohibiting it. | 287 // Try to run JS against the chrome-style URL after prohibiting it. |
269 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); | 288 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); |
270 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Clobbered'))"); | 289 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Clobbered'))"); |
271 | 290 |
272 // Required to see any updates in contentAsText. | 291 // Required to see any updates in contentAsText. |
273 m_webView->layout(); | 292 m_webView->layout(); |
274 | 293 |
275 // Now retrieve the frame's text and ensure it wasn't modified by running ja
vascript. | 294 // Now retrieve the frame's text and ensure it wasn't modified by running ja
vascript. |
276 std::string content = std::string(m_webView->mainFrame()->contentAsText(1024
).utf8().data()); | 295 std::string content = std::string(m_webView->mainFrame()->contentAsText(1024
).utf8().data()); |
277 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 296 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
278 } | 297 } |
279 | 298 |
280 TEST_F(WebFrameTest, DispatchMessageEventWithOriginCheck) | 299 TEST_F(WebFrameTest, DispatchMessageEventWithOriginCheck) |
281 { | 300 { |
282 registerMockedHttpURLLoad("postmessage_test.html"); | 301 registerMockedHttpURLLoad("postmessage_test.html"); |
283 | 302 |
284 // Pass true to enable JavaScript. | 303 // Pass true to enable JavaScript. |
285 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "postmessage_
test.html", true); | 304 initializeWebViewAndLoad(m_baseURL + "postmessage_test.html", true); |
286 | 305 |
287 // Send a message with the correct origin. | 306 // Send a message with the correct origin. |
288 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))
); | 307 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))
); |
289 WebDOMEvent event = m_webView->mainFrame()->document().createEvent("MessageE
vent"); | 308 WebDOMEvent event = m_webView->mainFrame()->document().createEvent("MessageE
vent"); |
290 WebDOMMessageEvent message = event.to<WebDOMMessageEvent>(); | 309 WebDOMMessageEvent message = event.to<WebDOMMessageEvent>(); |
291 WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); | 310 WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); |
292 message.initMessageEvent("message", false, false, data, "http://origin.com",
0, ""); | 311 message.initMessageEvent("message", false, false, data, "http://origin.com",
0, ""); |
293 m_webView->mainFrame()->dispatchMessageEventWithOriginCheck(correctOrigin, m
essage); | 312 m_webView->mainFrame()->dispatchMessageEventWithOriginCheck(correctOrigin, m
essage); |
294 | 313 |
295 // Send another message with incorrect origin. | 314 // Send another message with incorrect origin. |
(...skipping 19 matching lines...) Expand all Loading... |
315 TEST_F(WebFrameTest, FrameViewNeedsLayoutOnFixedLayoutResize) | 334 TEST_F(WebFrameTest, FrameViewNeedsLayoutOnFixedLayoutResize) |
316 { | 335 { |
317 registerMockedHttpURLLoad("fixed_layout.html"); | 336 registerMockedHttpURLLoad("fixed_layout.html"); |
318 | 337 |
319 FixedLayoutTestWebViewClient client; | 338 FixedLayoutTestWebViewClient client; |
320 int viewportWidth = 640; | 339 int viewportWidth = 640; |
321 int viewportHeight = 480; | 340 int viewportHeight = 480; |
322 | 341 |
323 // Make sure we initialize to minimum scale, even if the window size | 342 // Make sure we initialize to minimum scale, even if the window size |
324 // only becomes available after the load begins. | 343 // only becomes available after the load begins. |
325 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 344 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
326 m_webView->enableFixedLayoutMode(true); | 345 m_webView->enableFixedLayoutMode(true); |
327 m_webView->settings()->setViewportEnabled(true); | 346 m_webView->settings()->setViewportEnabled(true); |
328 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 347 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
329 m_webView->layout(); | 348 m_webView->layout(); |
330 | 349 |
331 webViewImpl()->mainFrameImpl()->frameView()->setFixedLayoutSize(WebCore::Int
Size(100, 100)); | 350 webViewImpl()->mainFrameImpl()->frameView()->setFixedLayoutSize(WebCore::Int
Size(100, 100)); |
332 EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); | 351 EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); |
333 | 352 |
334 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); | 353 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); |
335 webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebCore::IntRect(0
, 0, 641, 481)); | 354 webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebCore::IntRect(0
, 0, 641, 481)); |
336 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); | 355 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); |
337 | 356 |
338 webViewImpl()->layout(); | 357 webViewImpl()->layout(); |
339 } | 358 } |
340 | 359 |
341 TEST_F(WebFrameTest, ChangeInFixedLayoutTriggersTextAutosizingRecalculate) | 360 TEST_F(WebFrameTest, ChangeInFixedLayoutTriggersTextAutosizingRecalculate) |
342 { | 361 { |
343 registerMockedHttpURLLoad("fixed_layout.html"); | 362 registerMockedHttpURLLoad("fixed_layout.html"); |
344 | 363 |
345 FixedLayoutTestWebViewClient client; | 364 FixedLayoutTestWebViewClient client; |
346 int viewportWidth = 640; | 365 int viewportWidth = 640; |
347 int viewportHeight = 480; | 366 int viewportHeight = 480; |
348 | 367 |
349 // Make sure we initialize to minimum scale, even if the window size | 368 // Make sure we initialize to minimum scale, even if the window size |
350 // only becomes available after the load begins. | 369 // only becomes available after the load begins. |
351 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 370 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
352 m_webView->enableFixedLayoutMode(true); | 371 m_webView->enableFixedLayoutMode(true); |
353 m_webView->settings()->setViewportEnabled(true); | 372 m_webView->settings()->setViewportEnabled(true); |
354 | 373 |
355 WebCore::Document* document = webViewImpl()->page()->mainFrame()->document()
; | 374 WebCore::Document* document = webViewImpl()->page()->mainFrame()->document()
; |
356 document->settings()->setTextAutosizingEnabled(true); | 375 document->settings()->setTextAutosizingEnabled(true); |
357 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 376 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
358 webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 377 webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
359 webViewImpl()->layout(); | 378 webViewImpl()->layout(); |
360 | 379 |
361 WebCore::RenderObject* renderer = document->renderer(); | 380 WebCore::RenderObject* renderer = document->renderer(); |
(...skipping 29 matching lines...) Expand all Loading... |
391 TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag) | 410 TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag) |
392 { | 411 { |
393 registerMockedHttpURLLoad("no_viewport_tag.html"); | 412 registerMockedHttpURLLoad("no_viewport_tag.html"); |
394 | 413 |
395 int viewportWidth = 640; | 414 int viewportWidth = 640; |
396 int viewportHeight = 480; | 415 int viewportHeight = 480; |
397 | 416 |
398 FixedLayoutTestWebViewClient client; | 417 FixedLayoutTestWebViewClient client; |
399 client.m_screenInfo.deviceScaleFactor = 2; | 418 client.m_screenInfo.deviceScaleFactor = 2; |
400 | 419 |
401 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_
tag.html", true, 0, &client); | 420 initializeWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &clien
t); |
402 | 421 |
403 m_webView->settings()->setViewportEnabled(true); | 422 m_webView->settings()->setViewportEnabled(true); |
404 m_webView->enableFixedLayoutMode(true); | 423 m_webView->enableFixedLayoutMode(true); |
405 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 424 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
406 m_webView->layout(); | 425 m_webView->layout(); |
407 | 426 |
408 EXPECT_EQ(2, m_webView->deviceScaleFactor()); | 427 EXPECT_EQ(2, m_webView->deviceScaleFactor()); |
409 | 428 |
410 // Device scale factor should be independent of page scale. | 429 // Device scale factor should be independent of page scale. |
411 m_webView->setPageScaleFactorLimits(1, 2); | 430 m_webView->setPageScaleFactorLimits(1, 2); |
(...skipping 12 matching lines...) Expand all Loading... |
424 | 443 |
425 registerMockedHttpURLLoad("fixed_layout.html"); | 444 registerMockedHttpURLLoad("fixed_layout.html"); |
426 | 445 |
427 FixedLayoutTestWebViewClient client; | 446 FixedLayoutTestWebViewClient client; |
428 client.m_screenInfo.deviceScaleFactor = 1; | 447 client.m_screenInfo.deviceScaleFactor = 1; |
429 int viewportWidth = 640; | 448 int viewportWidth = 640; |
430 int viewportHeight = 480; | 449 int viewportHeight = 480; |
431 | 450 |
432 // Make sure we initialize to minimum scale, even if the window size | 451 // Make sure we initialize to minimum scale, even if the window size |
433 // only becomes available after the load begins. | 452 // only becomes available after the load begins. |
434 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 453 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
435 m_webView->enableFixedLayoutMode(true); | 454 m_webView->enableFixedLayoutMode(true); |
436 m_webView->settings()->setViewportEnabled(true); | 455 m_webView->settings()->setViewportEnabled(true); |
437 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 456 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
438 | 457 |
439 int defaultFixedLayoutWidth = 980; | 458 int defaultFixedLayoutWidth = 980; |
440 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; | 459 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; |
441 EXPECT_EQ(minimumPageScaleFactor, m_webView->pageScaleFactor()); | 460 EXPECT_EQ(minimumPageScaleFactor, m_webView->pageScaleFactor()); |
442 EXPECT_EQ(minimumPageScaleFactor, m_webView->minimumPageScaleFactor()); | 461 EXPECT_EQ(minimumPageScaleFactor, m_webView->minimumPageScaleFactor()); |
443 | 462 |
444 // Assume the user has pinch zoomed to page scale factor 2. | 463 // Assume the user has pinch zoomed to page scale factor 2. |
(...skipping 19 matching lines...) Expand all Loading... |
464 | 483 |
465 registerMockedHttpURLLoad("wide_document.html"); | 484 registerMockedHttpURLLoad("wide_document.html"); |
466 | 485 |
467 FixedLayoutTestWebViewClient client; | 486 FixedLayoutTestWebViewClient client; |
468 client.m_screenInfo.deviceScaleFactor = 1; | 487 client.m_screenInfo.deviceScaleFactor = 1; |
469 int viewportWidth = 640; | 488 int viewportWidth = 640; |
470 int viewportHeight = 480; | 489 int viewportHeight = 480; |
471 | 490 |
472 // Make sure we initialize to minimum scale, even if the window size | 491 // Make sure we initialize to minimum scale, even if the window size |
473 // only becomes available after the load begins. | 492 // only becomes available after the load begins. |
474 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "wide_documen
t.html", true, 0, &client); | 493 initializeWebViewAndLoad(m_baseURL + "wide_document.html", true, 0, &client)
; |
475 m_webView->enableFixedLayoutMode(true); | 494 m_webView->enableFixedLayoutMode(true); |
476 m_webView->settings()->setViewportEnabled(true); | 495 m_webView->settings()->setViewportEnabled(true); |
477 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 496 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
478 | 497 |
479 int wideDocumentWidth = 1500; | 498 int wideDocumentWidth = 1500; |
480 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; | 499 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; |
481 EXPECT_EQ(minimumPageScaleFactor, m_webView->pageScaleFactor()); | 500 EXPECT_EQ(minimumPageScaleFactor, m_webView->pageScaleFactor()); |
482 EXPECT_EQ(minimumPageScaleFactor, m_webView->minimumPageScaleFactor()); | 501 EXPECT_EQ(minimumPageScaleFactor, m_webView->minimumPageScaleFactor()); |
483 | 502 |
484 // Assume the user has pinch zoomed to page scale factor 2. | 503 // Assume the user has pinch zoomed to page scale factor 2. |
(...skipping 14 matching lines...) Expand all Loading... |
499 | 518 |
500 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) | 519 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) |
501 { | 520 { |
502 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 521 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
503 | 522 |
504 FixedLayoutTestWebViewClient client; | 523 FixedLayoutTestWebViewClient client; |
505 client.m_screenInfo.deviceScaleFactor = 1; | 524 client.m_screenInfo.deviceScaleFactor = 1; |
506 int viewportWidth = 640; | 525 int viewportWidth = 640; |
507 int viewportHeight = 480; | 526 int viewportHeight = 480; |
508 | 527 |
509 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-aut
o-initial-scale.html", true, 0, &client); | 528 initializeWebViewAndLoad(m_baseURL + "viewport-auto-initial-scale.html", tru
e, 0, &client); |
510 m_webView->enableFixedLayoutMode(true); | 529 m_webView->enableFixedLayoutMode(true); |
511 m_webView->settings()->setViewportEnabled(true); | 530 m_webView->settings()->setViewportEnabled(true); |
512 m_webView->settings()->setLoadWithOverviewMode(false); | 531 m_webView->settings()->setLoadWithOverviewMode(false); |
513 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 532 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
514 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 533 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
515 | 534 |
516 // The page must be displayed at 100% zoom. | 535 // The page must be displayed at 100% zoom. |
517 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); | 536 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); |
518 } | 537 } |
519 | 538 |
520 TEST_F(WebFrameTest, SetLoadWithOverviewModeToFalseAndNoWideViewport) | 539 TEST_F(WebFrameTest, SetLoadWithOverviewModeToFalseAndNoWideViewport) |
521 { | 540 { |
522 registerMockedHttpURLLoad("large-div.html"); | 541 registerMockedHttpURLLoad("large-div.html"); |
523 | 542 |
524 FixedLayoutTestWebViewClient client; | 543 FixedLayoutTestWebViewClient client; |
525 client.m_screenInfo.deviceScaleFactor = 1; | 544 client.m_screenInfo.deviceScaleFactor = 1; |
526 int viewportWidth = 640; | 545 int viewportWidth = 640; |
527 int viewportHeight = 480; | 546 int viewportHeight = 480; |
528 | 547 |
529 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "large-div.ht
ml", true, 0, &client); | 548 initializeWebViewAndLoad(m_baseURL + "large-div.html", true, 0, &client); |
530 m_webView->enableFixedLayoutMode(true); | 549 m_webView->enableFixedLayoutMode(true); |
531 m_webView->settings()->setViewportEnabled(true); | 550 m_webView->settings()->setViewportEnabled(true); |
532 m_webView->settings()->setLoadWithOverviewMode(false); | 551 m_webView->settings()->setLoadWithOverviewMode(false); |
533 m_webView->settings()->setUseWideViewport(false); | 552 m_webView->settings()->setUseWideViewport(false); |
534 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 553 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
535 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 554 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
536 | 555 |
537 // The page must be displayed at 100% zoom, despite that it hosts a wide div
element. | 556 // The page must be displayed at 100% zoom, despite that it hosts a wide div
element. |
538 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); | 557 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); |
539 } | 558 } |
540 | 559 |
541 TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidth) | 560 TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidth) |
542 { | 561 { |
543 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 562 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
544 | 563 |
545 FixedLayoutTestWebViewClient client; | 564 FixedLayoutTestWebViewClient client; |
546 client.m_screenInfo.deviceScaleFactor = 1; | 565 client.m_screenInfo.deviceScaleFactor = 1; |
547 int viewportWidth = 640; | 566 int viewportWidth = 640; |
548 int viewportHeight = 480; | 567 int viewportHeight = 480; |
549 | 568 |
550 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-aut
o-initial-scale.html", true, 0, &client); | 569 initializeWebViewAndLoad(m_baseURL + "viewport-auto-initial-scale.html", tru
e, 0, &client); |
551 m_webView->enableFixedLayoutMode(true); | 570 m_webView->enableFixedLayoutMode(true); |
552 m_webView->settings()->setViewportEnabled(true); | 571 m_webView->settings()->setViewportEnabled(true); |
553 m_webView->settings()->setUseWideViewport(false); | 572 m_webView->settings()->setUseWideViewport(false); |
554 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 573 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
555 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 574 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
556 | 575 |
557 // The page sets viewport width to 3000, but with UseWideViewport == false i
s must be ignored. | 576 // The page sets viewport width to 3000, but with UseWideViewport == false i
s must be ignored. |
558 EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->conten
tsSize().width()); | 577 EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->conten
tsSize().width()); |
559 EXPECT_EQ(viewportHeight, webViewImpl()->mainFrameImpl()->frameView()->conte
ntsSize().height()); | 578 EXPECT_EQ(viewportHeight, webViewImpl()->mainFrameImpl()->frameView()->conte
ntsSize().height()); |
560 } | 579 } |
561 | 580 |
562 TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccountsScale) | 581 TEST_F(WebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccountsScale) |
563 { | 582 { |
564 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 583 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
565 | 584 |
566 FixedLayoutTestWebViewClient client; | 585 FixedLayoutTestWebViewClient client; |
567 client.m_screenInfo.deviceScaleFactor = 1; | 586 client.m_screenInfo.deviceScaleFactor = 1; |
568 int viewportWidth = 640; | 587 int viewportWidth = 640; |
569 int viewportHeight = 480; | 588 int viewportHeight = 480; |
570 | 589 |
571 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-wid
e-2x-initial-scale.html", true, 0, &client); | 590 initializeWebViewAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html",
true, 0, &client); |
572 m_webView->enableFixedLayoutMode(true); | 591 m_webView->enableFixedLayoutMode(true); |
573 m_webView->settings()->setViewportEnabled(true); | 592 m_webView->settings()->setViewportEnabled(true); |
574 m_webView->settings()->setUseWideViewport(false); | 593 m_webView->settings()->setUseWideViewport(false); |
575 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 594 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
576 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 595 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
577 | 596 |
578 // The page sets viewport width to 3000, but with UseWideViewport == false i
s must be ignored. | 597 // The page sets viewport width to 3000, but with UseWideViewport == false i
s must be ignored. |
579 // While the initial scale specified by the page must be accounted. | 598 // While the initial scale specified by the page must be accounted. |
580 EXPECT_EQ(viewportWidth / 2, webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); | 599 EXPECT_EQ(viewportWidth / 2, webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); |
581 EXPECT_EQ(viewportHeight / 2, webViewImpl()->mainFrameImpl()->frameView()->c
ontentsSize().height()); | 600 EXPECT_EQ(viewportHeight / 2, webViewImpl()->mainFrameImpl()->frameView()->c
ontentsSize().height()); |
582 } | 601 } |
583 | 602 |
584 TEST_F(WebFrameTest, WideViewportSetsTo980WithoutViewportTag) | 603 TEST_F(WebFrameTest, WideViewportSetsTo980WithoutViewportTag) |
585 { | 604 { |
586 registerMockedHttpURLLoad("no_viewport_tag.html"); | 605 registerMockedHttpURLLoad("no_viewport_tag.html"); |
587 | 606 |
588 FixedLayoutTestWebViewClient client; | 607 FixedLayoutTestWebViewClient client; |
589 client.m_screenInfo.deviceScaleFactor = 1; | 608 client.m_screenInfo.deviceScaleFactor = 1; |
590 int viewportWidth = 640; | 609 int viewportWidth = 640; |
591 int viewportHeight = 480; | 610 int viewportHeight = 480; |
592 | 611 |
593 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_
tag.html", true, 0, &client); | 612 initializeWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &clien
t); |
594 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 613 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
595 m_webView->enableFixedLayoutMode(true); | 614 m_webView->enableFixedLayoutMode(true); |
596 m_webView->settings()->setUseWideViewport(true); | 615 m_webView->settings()->setUseWideViewport(true); |
597 m_webView->settings()->setViewportEnabled(true); | 616 m_webView->settings()->setViewportEnabled(true); |
598 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 617 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
599 | 618 |
600 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); | 619 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); |
601 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameIm
pl()->frameView()->contentsSize().height()); | 620 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameIm
pl()->frameView()->contentsSize().height()); |
602 } | 621 } |
603 | 622 |
604 TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta) | 623 TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta) |
605 { | 624 { |
606 registerMockedHttpURLLoad("viewport-height-1000.html"); | 625 registerMockedHttpURLLoad("viewport-height-1000.html"); |
607 | 626 |
608 FixedLayoutTestWebViewClient client; | 627 FixedLayoutTestWebViewClient client; |
609 client.m_screenInfo.deviceScaleFactor = 1; | 628 client.m_screenInfo.deviceScaleFactor = 1; |
610 int viewportWidth = 640; | 629 int viewportWidth = 640; |
611 int viewportHeight = 480; | 630 int viewportHeight = 480; |
612 | 631 |
613 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-hei
ght-1000.html", true, 0, &client); | 632 initializeWebViewAndLoad(m_baseURL + "viewport-height-1000.html", true, 0, &
client); |
614 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 633 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
615 m_webView->enableFixedLayoutMode(true); | 634 m_webView->enableFixedLayoutMode(true); |
616 m_webView->settings()->setUseWideViewport(false); | 635 m_webView->settings()->setUseWideViewport(false); |
617 m_webView->settings()->setViewportEnabled(true); | 636 m_webView->settings()->setViewportEnabled(true); |
618 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 637 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
619 | 638 |
620 EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->conten
tsSize().width()); | 639 EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->conten
tsSize().width()); |
621 } | 640 } |
622 | 641 |
623 TEST_F(WebFrameTest, WideViewportSetsTo980WithAutoWidth) | 642 TEST_F(WebFrameTest, WideViewportSetsTo980WithAutoWidth) |
624 { | 643 { |
625 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); | 644 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); |
626 | 645 |
627 FixedLayoutTestWebViewClient client; | 646 FixedLayoutTestWebViewClient client; |
628 client.m_screenInfo.deviceScaleFactor = 1; | 647 client.m_screenInfo.deviceScaleFactor = 1; |
629 int viewportWidth = 640; | 648 int viewportWidth = 640; |
630 int viewportHeight = 480; | 649 int viewportHeight = 480; |
631 | 650 |
632 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-2x-
initial-scale.html", true, 0, &client); | 651 initializeWebViewAndLoad(m_baseURL + "viewport-2x-initial-scale.html", true,
0, &client); |
633 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 652 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
634 m_webView->enableFixedLayoutMode(true); | 653 m_webView->enableFixedLayoutMode(true); |
635 m_webView->settings()->setUseWideViewport(true); | 654 m_webView->settings()->setUseWideViewport(true); |
636 m_webView->settings()->setViewportEnabled(true); | 655 m_webView->settings()->setViewportEnabled(true); |
637 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 656 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
638 | 657 |
639 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); | 658 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); |
640 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameIm
pl()->frameView()->contentsSize().height()); | 659 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameIm
pl()->frameView()->contentsSize().height()); |
641 } | 660 } |
642 | 661 |
643 TEST_F(WebFrameTest, PageViewportInitialScaleOverridesLoadWithOverviewMode) | 662 TEST_F(WebFrameTest, PageViewportInitialScaleOverridesLoadWithOverviewMode) |
644 { | 663 { |
645 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 664 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
646 | 665 |
647 FixedLayoutTestWebViewClient client; | 666 FixedLayoutTestWebViewClient client; |
648 client.m_screenInfo.deviceScaleFactor = 1; | 667 client.m_screenInfo.deviceScaleFactor = 1; |
649 int viewportWidth = 640; | 668 int viewportWidth = 640; |
650 int viewportHeight = 480; | 669 int viewportHeight = 480; |
651 | 670 |
652 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-wid
e-2x-initial-scale.html", true, 0, &client); | 671 initializeWebViewAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html",
true, 0, &client); |
653 m_webView->enableFixedLayoutMode(true); | 672 m_webView->enableFixedLayoutMode(true); |
654 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 673 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
655 m_webView->settings()->setViewportEnabled(true); | 674 m_webView->settings()->setViewportEnabled(true); |
656 m_webView->settings()->setLoadWithOverviewMode(false); | 675 m_webView->settings()->setLoadWithOverviewMode(false); |
657 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 676 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
658 | 677 |
659 // The page must be displayed at 200% zoom, as specified in its viewport met
a tag. | 678 // The page must be displayed at 200% zoom, as specified in its viewport met
a tag. |
660 EXPECT_EQ(2.0f, m_webView->pageScaleFactor()); | 679 EXPECT_EQ(2.0f, m_webView->pageScaleFactor()); |
661 } | 680 } |
662 | 681 |
663 TEST_F(WebFrameTest, setInitialPageScaleFactorPermanently) | 682 TEST_F(WebFrameTest, setInitialPageScaleFactorPermanently) |
664 { | 683 { |
665 WebCore::Settings::setMockScrollbarsEnabled(true); | 684 WebCore::Settings::setMockScrollbarsEnabled(true); |
666 WebCore::Settings::setUsesOverlayScrollbars(true); | 685 WebCore::Settings::setUsesOverlayScrollbars(true); |
667 | 686 |
668 registerMockedHttpURLLoad("fixed_layout.html"); | 687 registerMockedHttpURLLoad("fixed_layout.html"); |
669 | 688 |
670 FixedLayoutTestWebViewClient client; | 689 FixedLayoutTestWebViewClient client; |
671 client.m_screenInfo.deviceScaleFactor = 1; | 690 client.m_screenInfo.deviceScaleFactor = 1; |
672 float enforcedPageScaleFactor = 2.0f; | 691 float enforcedPageScaleFactor = 2.0f; |
673 | 692 |
674 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 693 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
675 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 694 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
676 m_webView->settings()->setLoadWithOverviewMode(false); | 695 m_webView->settings()->setLoadWithOverviewMode(false); |
677 m_webView->setInitialPageScaleOverride(enforcedPageScaleFactor); | 696 m_webView->setInitialPageScaleOverride(enforcedPageScaleFactor); |
678 m_webView->enableFixedLayoutMode(true); | 697 m_webView->enableFixedLayoutMode(true); |
679 m_webView->settings()->setViewportEnabled(true); | 698 m_webView->settings()->setViewportEnabled(true); |
680 m_webView->layout(); | 699 m_webView->layout(); |
681 | 700 |
682 EXPECT_EQ(enforcedPageScaleFactor, m_webView->pageScaleFactor()); | 701 EXPECT_EQ(enforcedPageScaleFactor, m_webView->pageScaleFactor()); |
683 | 702 |
684 int viewportWidth = 640; | 703 int viewportWidth = 640; |
(...skipping 11 matching lines...) Expand all Loading... |
696 TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesLoadWithOverviewMod
e) | 715 TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesLoadWithOverviewMod
e) |
697 { | 716 { |
698 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 717 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
699 | 718 |
700 FixedLayoutTestWebViewClient client; | 719 FixedLayoutTestWebViewClient client; |
701 client.m_screenInfo.deviceScaleFactor = 1; | 720 client.m_screenInfo.deviceScaleFactor = 1; |
702 int viewportWidth = 640; | 721 int viewportWidth = 640; |
703 int viewportHeight = 480; | 722 int viewportHeight = 480; |
704 float enforcedPageScalePactor = 0.5f; | 723 float enforcedPageScalePactor = 0.5f; |
705 | 724 |
706 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-aut
o-initial-scale.html", true, 0, &client); | 725 initializeWebViewAndLoad(m_baseURL + "viewport-auto-initial-scale.html", tru
e, 0, &client); |
707 m_webView->enableFixedLayoutMode(true); | 726 m_webView->enableFixedLayoutMode(true); |
708 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 727 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
709 m_webView->settings()->setViewportEnabled(true); | 728 m_webView->settings()->setViewportEnabled(true); |
710 m_webView->settings()->setLoadWithOverviewMode(false); | 729 m_webView->settings()->setLoadWithOverviewMode(false); |
711 m_webView->setInitialPageScaleOverride(enforcedPageScalePactor); | 730 m_webView->setInitialPageScaleOverride(enforcedPageScalePactor); |
712 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 731 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
713 | 732 |
714 EXPECT_EQ(enforcedPageScalePactor, m_webView->pageScaleFactor()); | 733 EXPECT_EQ(enforcedPageScalePactor, m_webView->pageScaleFactor()); |
715 } | 734 } |
716 | 735 |
717 TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesPageViewportInitial
Scale) | 736 TEST_F(WebFrameTest, PermanentInitialPageScaleFactorOverridesPageViewportInitial
Scale) |
718 { | 737 { |
719 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 738 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
720 | 739 |
721 FixedLayoutTestWebViewClient client; | 740 FixedLayoutTestWebViewClient client; |
722 client.m_screenInfo.deviceScaleFactor = 1; | 741 client.m_screenInfo.deviceScaleFactor = 1; |
723 int viewportWidth = 640; | 742 int viewportWidth = 640; |
724 int viewportHeight = 480; | 743 int viewportHeight = 480; |
725 float enforcedPageScalePactor = 0.5f; | 744 float enforcedPageScalePactor = 0.5f; |
726 | 745 |
727 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-wid
e-2x-initial-scale.html", true, 0, &client); | 746 initializeWebViewAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.html",
true, 0, &client); |
728 m_webView->enableFixedLayoutMode(true); | 747 m_webView->enableFixedLayoutMode(true); |
729 m_webView->settings()->setViewportEnabled(true); | 748 m_webView->settings()->setViewportEnabled(true); |
730 m_webView->setInitialPageScaleOverride(enforcedPageScalePactor); | 749 m_webView->setInitialPageScaleOverride(enforcedPageScalePactor); |
731 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 750 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
732 | 751 |
733 EXPECT_EQ(enforcedPageScalePactor, m_webView->pageScaleFactor()); | 752 EXPECT_EQ(enforcedPageScalePactor, m_webView->pageScaleFactor()); |
734 } | 753 } |
735 | 754 |
736 TEST_F(WebFrameTest, WideViewportInitialScaleDoesNotExpandFixedLayoutWidth) | 755 TEST_F(WebFrameTest, WideViewportInitialScaleDoesNotExpandFixedLayoutWidth) |
737 { | 756 { |
738 registerMockedHttpURLLoad("viewport-device-0.5x-initial-scale.html"); | 757 registerMockedHttpURLLoad("viewport-device-0.5x-initial-scale.html"); |
739 | 758 |
740 FixedLayoutTestWebViewClient client; | 759 FixedLayoutTestWebViewClient client; |
741 client.m_screenInfo.deviceScaleFactor = 1; | 760 client.m_screenInfo.deviceScaleFactor = 1; |
742 int viewportWidth = 640; | 761 int viewportWidth = 640; |
743 int viewportHeight = 480; | 762 int viewportHeight = 480; |
744 | 763 |
745 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-dev
ice-0.5x-initial-scale.html", true, 0, &client); | 764 initializeWebViewAndLoad(m_baseURL + "viewport-device-0.5x-initial-scale.htm
l", true, 0, &client); |
746 m_webView->enableFixedLayoutMode(true); | 765 m_webView->enableFixedLayoutMode(true); |
747 m_webView->settings()->setViewportEnabled(true); | 766 m_webView->settings()->setViewportEnabled(true); |
748 m_webView->settings()->setUseWideViewport(true); | 767 m_webView->settings()->setUseWideViewport(true); |
749 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 768 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
750 m_webView->settings()->setViewportMetaLayoutSizeQuirk(true); | 769 m_webView->settings()->setViewportMetaLayoutSizeQuirk(true); |
751 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 770 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
752 | 771 |
753 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 772 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
754 EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLay
outSize().width()); | 773 EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLay
outSize().width()); |
755 } | 774 } |
756 | 775 |
757 TEST_F(WebFrameTest, ZeroValuesQuirk) | 776 TEST_F(WebFrameTest, ZeroValuesQuirk) |
758 { | 777 { |
759 registerMockedHttpURLLoad("viewport-zero-values.html"); | 778 registerMockedHttpURLLoad("viewport-zero-values.html"); |
760 | 779 |
761 FixedLayoutTestWebViewClient client; | 780 FixedLayoutTestWebViewClient client; |
762 client.m_screenInfo.deviceScaleFactor = 1; | 781 client.m_screenInfo.deviceScaleFactor = 1; |
763 int viewportWidth = 640; | 782 int viewportWidth = 640; |
764 int viewportHeight = 480; | 783 int viewportHeight = 480; |
765 | 784 |
766 m_webView = FrameTestHelpers::createWebView(true, 0, &client); | 785 initializeWebView(true, 0, &client); |
767 m_webView->enableFixedLayoutMode(true); | 786 m_webView->enableFixedLayoutMode(true); |
768 m_webView->settings()->setViewportEnabled(true); | 787 m_webView->settings()->setViewportEnabled(true); |
769 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 788 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
770 m_webView->settings()->setViewportMetaZeroValuesQuirk(true); | 789 m_webView->settings()->setViewportMetaZeroValuesQuirk(true); |
771 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "viewport-ze
ro-values.html"); | 790 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "viewport-ze
ro-values.html"); |
772 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 791 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
773 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 792 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
774 | 793 |
775 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 794 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
776 EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLay
outSize().width()); | 795 EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLay
outSize().width()); |
777 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); | 796 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); |
778 | 797 |
779 m_webView->settings()->setUseWideViewport(true); | 798 m_webView->settings()->setUseWideViewport(true); |
780 m_webView->layout(); | 799 m_webView->layout(); |
781 EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLay
outSize().width()); | 800 EXPECT_EQ(viewportWidth, webViewImpl->mainFrameImpl()->frameView()->fixedLay
outSize().width()); |
782 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); | 801 EXPECT_EQ(1.0f, m_webView->pageScaleFactor()); |
783 } | 802 } |
784 | 803 |
785 TEST_F(WebFrameTest, ScaleFactorShouldNotOscillate) | 804 TEST_F(WebFrameTest, ScaleFactorShouldNotOscillate) |
786 { | 805 { |
787 registerMockedHttpURLLoad("scale_oscillate.html"); | 806 registerMockedHttpURLLoad("scale_oscillate.html"); |
788 | 807 |
789 FixedLayoutTestWebViewClient client; | 808 FixedLayoutTestWebViewClient client; |
790 client.m_screenInfo.deviceScaleFactor = static_cast<float>(1.325); | 809 client.m_screenInfo.deviceScaleFactor = static_cast<float>(1.325); |
791 int viewportWidth = 800; | 810 int viewportWidth = 800; |
792 int viewportHeight = 1057; | 811 int viewportHeight = 1057; |
793 | 812 |
794 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "scale_oscill
ate.html", true, 0, &client); | 813 initializeWebViewAndLoad(m_baseURL + "scale_oscillate.html", true, 0, &clien
t); |
795 m_webView->enableFixedLayoutMode(true); | 814 m_webView->enableFixedLayoutMode(true); |
796 m_webView->settings()->setViewportEnabled(true); | 815 m_webView->settings()->setViewportEnabled(true); |
797 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 816 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
798 m_webView->layout(); | 817 m_webView->layout(); |
799 } | 818 } |
800 | 819 |
801 TEST_F(WebFrameTest, setPageScaleFactorDoesNotLayout) | 820 TEST_F(WebFrameTest, setPageScaleFactorDoesNotLayout) |
802 { | 821 { |
803 registerMockedHttpURLLoad("fixed_layout.html"); | 822 registerMockedHttpURLLoad("fixed_layout.html"); |
804 | 823 |
805 FixedLayoutTestWebViewClient client; | 824 FixedLayoutTestWebViewClient client; |
806 client.m_screenInfo.deviceScaleFactor = 1; | 825 client.m_screenInfo.deviceScaleFactor = 1; |
807 // Small viewport to ensure there are always scrollbars. | 826 // Small viewport to ensure there are always scrollbars. |
808 int viewportWidth = 64; | 827 int viewportWidth = 64; |
809 int viewportHeight = 48; | 828 int viewportHeight = 48; |
810 | 829 |
811 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 830 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
812 m_webView->enableFixedLayoutMode(true); | 831 m_webView->enableFixedLayoutMode(true); |
813 m_webView->settings()->setViewportEnabled(true); | 832 m_webView->settings()->setViewportEnabled(true); |
814 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 833 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
815 m_webView->layout(); | 834 m_webView->layout(); |
816 | 835 |
817 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); | 836 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); |
818 webViewImpl()->setPageScaleFactor(3, WebPoint()); | 837 webViewImpl()->setPageScaleFactor(3, WebPoint()); |
819 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); | 838 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); |
820 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); | 839 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); |
821 } | 840 } |
822 | 841 |
823 TEST_F(WebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) | 842 TEST_F(WebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) |
824 { | 843 { |
825 WebCore::Settings::setMockScrollbarsEnabled(true); | 844 WebCore::Settings::setMockScrollbarsEnabled(true); |
826 WebCore::Settings::setUsesOverlayScrollbars(true); | 845 WebCore::Settings::setUsesOverlayScrollbars(true); |
827 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); | 846 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); |
828 | 847 |
829 registerMockedHttpURLLoad("fixed_layout.html"); | 848 registerMockedHttpURLLoad("fixed_layout.html"); |
830 | 849 |
831 FixedLayoutTestWebViewClient client; | 850 FixedLayoutTestWebViewClient client; |
832 client.m_screenInfo.deviceScaleFactor = 1; | 851 client.m_screenInfo.deviceScaleFactor = 1; |
833 int viewportWidth = 640; | 852 int viewportWidth = 640; |
834 int viewportHeight = 480; | 853 int viewportHeight = 480; |
835 | 854 |
836 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 855 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
837 m_webView->enableFixedLayoutMode(true); | 856 m_webView->enableFixedLayoutMode(true); |
838 m_webView->settings()->setViewportEnabled(true); | 857 m_webView->settings()->setViewportEnabled(true); |
839 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 858 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
840 m_webView->layout(); | 859 m_webView->layout(); |
841 | 860 |
842 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); | 861 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); |
843 webViewImpl()->setPageScaleFactor(30, WebPoint()); | 862 webViewImpl()->setPageScaleFactor(30, WebPoint()); |
844 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); | 863 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); |
845 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); | 864 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); |
846 | 865 |
847 WebCore::Settings::setMockScrollbarsEnabled(false); | 866 WebCore::Settings::setMockScrollbarsEnabled(false); |
848 WebCore::Settings::setUsesOverlayScrollbars(false); | 867 WebCore::Settings::setUsesOverlayScrollbars(false); |
849 } | 868 } |
850 | 869 |
851 TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) | 870 TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) |
852 { | 871 { |
853 registerMockedHttpURLLoad("fixed_layout.html"); | 872 registerMockedHttpURLLoad("fixed_layout.html"); |
854 | 873 |
855 float pageScaleFactor = 3; | 874 float pageScaleFactor = 3; |
856 m_webView = FrameTestHelpers::createWebViewAndLoad("about:html", true, 0, 0)
; | 875 initializeWebViewAndLoad("about:html", true, 0, 0); |
857 m_webView->setPageScaleFactor(pageScaleFactor, WebPoint()); | 876 m_webView->setPageScaleFactor(pageScaleFactor, WebPoint()); |
858 | 877 |
859 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "fixed_layou
t.html"); | 878 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "fixed_layou
t.html"); |
860 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 879 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
861 WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); | 880 WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); |
862 EXPECT_EQ(pageScaleFactor, view->visibleContentScaleFactor()); | 881 EXPECT_EQ(pageScaleFactor, view->visibleContentScaleFactor()); |
863 } | 882 } |
864 | 883 |
865 TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem) | 884 TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem) |
866 { | 885 { |
867 registerMockedHttpURLLoad("fixed_layout.html"); | 886 registerMockedHttpURLLoad("fixed_layout.html"); |
868 | 887 |
869 FixedLayoutTestWebViewClient client; | 888 FixedLayoutTestWebViewClient client; |
870 client.m_screenInfo.deviceScaleFactor = 1; | 889 client.m_screenInfo.deviceScaleFactor = 1; |
871 int viewportWidth = 640; | 890 int viewportWidth = 640; |
872 int viewportHeight = 480; | 891 int viewportHeight = 480; |
873 | 892 |
874 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 893 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
875 m_webView->enableFixedLayoutMode(true); | 894 m_webView->enableFixedLayoutMode(true); |
876 m_webView->settings()->setViewportEnabled(true); | 895 m_webView->settings()->setViewportEnabled(true); |
877 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 896 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
878 m_webView->layout(); | 897 m_webView->layout(); |
879 | 898 |
880 m_webView->setPageScaleFactor(3, WebPoint()); | 899 m_webView->setPageScaleFactor(3, WebPoint()); |
881 webViewImpl()->page()->mainFrame()->loader()->history()->saveDocumentAndScro
llState(); | 900 webViewImpl()->page()->mainFrame()->loader()->history()->saveDocumentAndScro
llState(); |
882 m_webView->setPageScaleFactor(1, WebPoint()); | 901 m_webView->setPageScaleFactor(1, WebPoint()); |
883 webViewImpl()->page()->mainFrame()->loader()->history()->restoreScrollPositi
onAndViewState(); | 902 webViewImpl()->page()->mainFrame()->loader()->history()->restoreScrollPositi
onAndViewState(); |
884 EXPECT_EQ(3, m_webView->pageScaleFactor()); | 903 EXPECT_EQ(3, m_webView->pageScaleFactor()); |
885 } | 904 } |
886 | 905 |
887 TEST_F(WebFrameTest, pageScaleFactorShrinksViewport) | 906 TEST_F(WebFrameTest, pageScaleFactorShrinksViewport) |
888 { | 907 { |
889 registerMockedHttpURLLoad("fixed_layout.html"); | 908 registerMockedHttpURLLoad("fixed_layout.html"); |
890 | 909 |
891 FixedLayoutTestWebViewClient client; | 910 FixedLayoutTestWebViewClient client; |
892 client.m_screenInfo.deviceScaleFactor = 1; | 911 client.m_screenInfo.deviceScaleFactor = 1; |
893 // Small viewport to ensure there are always scrollbars. | 912 // Small viewport to ensure there are always scrollbars. |
894 int viewportWidth = 64; | 913 int viewportWidth = 64; |
895 int viewportHeight = 48; | 914 int viewportHeight = 48; |
896 | 915 |
897 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 916 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
898 m_webView->enableFixedLayoutMode(true); | 917 m_webView->enableFixedLayoutMode(true); |
899 m_webView->settings()->setViewportEnabled(true); | 918 m_webView->settings()->setViewportEnabled(true); |
900 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 919 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
901 m_webView->layout(); | 920 m_webView->layout(); |
902 | 921 |
903 WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); | 922 WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); |
904 int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()
->isOverlayScrollbar() ? 0 : 15); | 923 int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()
->isOverlayScrollbar() ? 0 : 15); |
905 int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollb
ar()->isOverlayScrollbar() ? 0 : 15); | 924 int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollb
ar()->isOverlayScrollbar() ? 0 : 15); |
906 | 925 |
907 m_webView->setPageScaleFactor(2, WebPoint()); | 926 m_webView->setPageScaleFactor(2, WebPoint()); |
(...skipping 13 matching lines...) Expand all Loading... |
921 | 940 |
922 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) | 941 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) |
923 { | 942 { |
924 registerMockedHttpURLLoad("fixed_layout.html"); | 943 registerMockedHttpURLLoad("fixed_layout.html"); |
925 | 944 |
926 FixedLayoutTestWebViewClient client; | 945 FixedLayoutTestWebViewClient client; |
927 client.m_screenInfo.deviceScaleFactor = 1; | 946 client.m_screenInfo.deviceScaleFactor = 1; |
928 int viewportWidth = 640; | 947 int viewportWidth = 640; |
929 int viewportHeight = 480; | 948 int viewportHeight = 480; |
930 | 949 |
931 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 950 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
932 m_webView->enableFixedLayoutMode(true); | 951 m_webView->enableFixedLayoutMode(true); |
933 m_webView->settings()->setViewportEnabled(true); | 952 m_webView->settings()->setViewportEnabled(true); |
934 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 953 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
935 m_webView->layout(); | 954 m_webView->layout(); |
936 | 955 |
937 m_webView->setPageScaleFactor(2, WebPoint()); | 956 m_webView->setPageScaleFactor(2, WebPoint()); |
938 | 957 |
939 EXPECT_EQ(980, webViewImpl()->page()->mainFrame()->contentRenderer()->unscal
edDocumentRect().width()); | 958 EXPECT_EQ(980, webViewImpl()->page()->mainFrame()->contentRenderer()->unscal
edDocumentRect().width()); |
940 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); | 959 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); |
941 } | 960 } |
942 | 961 |
943 TEST_F(WebFrameTest, targetDensityDpiHigh) | 962 TEST_F(WebFrameTest, targetDensityDpiHigh) |
944 { | 963 { |
945 WebCore::Settings::setMockScrollbarsEnabled(true); | 964 WebCore::Settings::setMockScrollbarsEnabled(true); |
946 WebCore::Settings::setUsesOverlayScrollbars(true); | 965 WebCore::Settings::setUsesOverlayScrollbars(true); |
947 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); | 966 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); |
948 | 967 |
949 FixedLayoutTestWebViewClient client; | 968 FixedLayoutTestWebViewClient client; |
950 // high-dpi = 240 | 969 // high-dpi = 240 |
951 float targetDpi = 240.0f; | 970 float targetDpi = 240.0f; |
952 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 971 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
953 int viewportWidth = 640; | 972 int viewportWidth = 640; |
954 int viewportHeight = 480; | 973 int viewportHeight = 480; |
955 | 974 |
956 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { | 975 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { |
957 float deviceScaleFactor = deviceScaleFactors[i]; | 976 float deviceScaleFactor = deviceScaleFactors[i]; |
958 float deviceDpi = deviceScaleFactor * 160.0f; | 977 float deviceDpi = deviceScaleFactor * 160.0f; |
959 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; | 978 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; |
960 | 979 |
961 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport
-target-densitydpi-high.html", true, 0, &client); | 980 initializeWebViewAndLoad(m_baseURL + "viewport-target-densitydpi-high.ht
ml", true, 0, &client); |
962 m_webView->enableFixedLayoutMode(true); | 981 m_webView->enableFixedLayoutMode(true); |
963 m_webView->settings()->setViewportEnabled(true); | 982 m_webView->settings()->setViewportEnabled(true); |
964 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 983 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
965 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 984 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
966 | 985 |
967 // We need to account for the fact that logical pixels are unconditional
ly multiplied by deviceScaleFactor to produce | 986 // We need to account for the fact that logical pixels are unconditional
ly multiplied by deviceScaleFactor to produce |
968 // physical pixels. | 987 // physical pixels. |
969 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; | 988 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; |
970 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, m_webView->fixedLayout
Size().width, 1.0f); | 989 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, m_webView->fixedLayout
Size().width, 1.0f); |
971 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, m_webView->fixedLayou
tSize().height, 1.0f); | 990 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, m_webView->fixedLayou
tSize().height, 1.0f); |
(...skipping 12 matching lines...) Expand all Loading... |
984 | 1003 |
985 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 1004 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
986 | 1005 |
987 FixedLayoutTestWebViewClient client; | 1006 FixedLayoutTestWebViewClient client; |
988 int viewportWidth = 640; | 1007 int viewportWidth = 640; |
989 int viewportHeight = 480; | 1008 int viewportHeight = 480; |
990 | 1009 |
991 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { | 1010 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { |
992 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; | 1011 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; |
993 | 1012 |
994 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport
-target-densitydpi-device.html", true, 0, &client); | 1013 initializeWebViewAndLoad(m_baseURL + "viewport-target-densitydpi-device.
html", true, 0, &client); |
995 m_webView->enableFixedLayoutMode(true); | 1014 m_webView->enableFixedLayoutMode(true); |
996 m_webView->settings()->setViewportEnabled(true); | 1015 m_webView->settings()->setViewportEnabled(true); |
997 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 1016 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
998 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1017 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
999 | 1018 |
1000 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, m_web
View->fixedLayoutSize().width, 1.0f); | 1019 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, m_web
View->fixedLayoutSize().width, 1.0f); |
1001 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, m_we
bView->fixedLayoutSize().height, 1.0f); | 1020 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, m_we
bView->fixedLayoutSize().height, 1.0f); |
1002 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, m_webView->pag
eScaleFactor(), 0.01f); | 1021 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, m_webView->pag
eScaleFactor(), 0.01f); |
1003 | 1022 |
1004 m_webView->close(); | 1023 m_webView->close(); |
(...skipping 13 matching lines...) Expand all Loading... |
1018 | 1037 |
1019 void testResizeYieldsCorrectScrollAndScale(const char* url, | 1038 void testResizeYieldsCorrectScrollAndScale(const char* url, |
1020 const float initialPageScaleFacto
r, | 1039 const float initialPageScaleFacto
r, |
1021 const WebSize scrollOffset, | 1040 const WebSize scrollOffset, |
1022 const WebSize viewportSize, | 1041 const WebSize viewportSize, |
1023 const bool shouldScaleRelativeToV
iewportWidth) { | 1042 const bool shouldScaleRelativeToV
iewportWidth) { |
1024 registerMockedHttpURLLoad(url); | 1043 registerMockedHttpURLLoad(url); |
1025 | 1044 |
1026 const float aspectRatio = static_cast<float>(viewportSize.width) / viewp
ortSize.height; | 1045 const float aspectRatio = static_cast<float>(viewportSize.width) / viewp
ortSize.height; |
1027 | 1046 |
1028 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + url, true
); | 1047 initializeWebViewAndLoad(m_baseURL + url, true); |
1029 m_webView->settings()->setViewportEnabled(true); | 1048 m_webView->settings()->setViewportEnabled(true); |
1030 m_webView->enableFixedLayoutMode(true); | 1049 m_webView->enableFixedLayoutMode(true); |
1031 | 1050 |
1032 // Origin scrollOffsets preserved under resize. | 1051 // Origin scrollOffsets preserved under resize. |
1033 { | 1052 { |
1034 webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.heigh
t)); | 1053 webViewImpl()->resize(WebSize(viewportSize.width, viewportSize.heigh
t)); |
1035 webViewImpl()->setPageScaleFactor(initialPageScaleFactor, WebPoint()
); | 1054 webViewImpl()->setPageScaleFactor(initialPageScaleFactor, WebPoint()
); |
1036 ASSERT_EQ(viewportSize, webViewImpl()->size()); | 1055 ASSERT_EQ(viewportSize, webViewImpl()->size()); |
1037 ASSERT_EQ(initialPageScaleFactor, webViewImpl()->pageScaleFactor()); | 1056 ASSERT_EQ(initialPageScaleFactor, webViewImpl()->pageScaleFactor()); |
1038 webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.widt
h)); | 1057 webViewImpl()->resize(WebSize(viewportSize.height, viewportSize.widt
h)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 | 1144 |
1126 TEST_F(WebFrameTest, pageScaleFactorScalesPaintClip) | 1145 TEST_F(WebFrameTest, pageScaleFactorScalesPaintClip) |
1127 { | 1146 { |
1128 registerMockedHttpURLLoad("fixed_layout.html"); | 1147 registerMockedHttpURLLoad("fixed_layout.html"); |
1129 | 1148 |
1130 FixedLayoutTestWebViewClient client; | 1149 FixedLayoutTestWebViewClient client; |
1131 client.m_screenInfo.deviceScaleFactor = 1; | 1150 client.m_screenInfo.deviceScaleFactor = 1; |
1132 int viewportWidth = 50; | 1151 int viewportWidth = 50; |
1133 int viewportHeight = 50; | 1152 int viewportHeight = 50; |
1134 | 1153 |
1135 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 1154 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
1136 m_webView->enableFixedLayoutMode(true); | 1155 m_webView->enableFixedLayoutMode(true); |
1137 m_webView->settings()->setViewportEnabled(true); | 1156 m_webView->settings()->setViewportEnabled(true); |
1138 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1157 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1139 m_webView->layout(); | 1158 m_webView->layout(); |
1140 | 1159 |
1141 // Set <1 page scale so that the clip rect should be larger than | 1160 // Set <1 page scale so that the clip rect should be larger than |
1142 // the viewport size as passed into resize(). | 1161 // the viewport size as passed into resize(). |
1143 m_webView->setPageScaleFactor(0.5, WebPoint()); | 1162 m_webView->setPageScaleFactor(0.5, WebPoint()); |
1144 | 1163 |
1145 SkBitmap bitmap; | 1164 SkBitmap bitmap; |
(...skipping 19 matching lines...) Expand all Loading... |
1165 | 1184 |
1166 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) | 1185 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) |
1167 { | 1186 { |
1168 registerMockedHttpURLLoad("fixed_layout.html"); | 1187 registerMockedHttpURLLoad("fixed_layout.html"); |
1169 | 1188 |
1170 FixedLayoutTestWebViewClient client; | 1189 FixedLayoutTestWebViewClient client; |
1171 client.m_screenInfo.deviceScaleFactor = 1; | 1190 client.m_screenInfo.deviceScaleFactor = 1; |
1172 int viewportWidth = 640; | 1191 int viewportWidth = 640; |
1173 int viewportHeight = 480; | 1192 int viewportHeight = 480; |
1174 | 1193 |
1175 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 1194 initializeWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client); |
1176 m_webView->enableFixedLayoutMode(true); | 1195 m_webView->enableFixedLayoutMode(true); |
1177 m_webView->settings()->setViewportEnabled(true); | 1196 m_webView->settings()->setViewportEnabled(true); |
1178 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1197 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1179 m_webView->layout(); | 1198 m_webView->layout(); |
1180 | 1199 |
1181 WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); | 1200 WebCore::FrameView* view = webViewImpl()->mainFrameImpl()->frameView(); |
1182 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); | 1201 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); |
1183 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); | 1202 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); |
1184 | 1203 |
1185 m_webView->setPageScaleFactor(10, WebPoint()); | 1204 m_webView->setPageScaleFactor(10, WebPoint()); |
1186 | 1205 |
1187 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); | 1206 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); |
1188 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); | 1207 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); |
1189 } | 1208 } |
1190 | 1209 |
1191 TEST_F(WebFrameTest, CanOverrideScaleLimits) | 1210 TEST_F(WebFrameTest, CanOverrideScaleLimits) |
1192 { | 1211 { |
1193 WebCore::Settings::setMockScrollbarsEnabled(true); | 1212 WebCore::Settings::setMockScrollbarsEnabled(true); |
1194 WebCore::Settings::setUsesOverlayScrollbars(true); | 1213 WebCore::Settings::setUsesOverlayScrollbars(true); |
1195 | 1214 |
1196 registerMockedHttpURLLoad("no_scale_for_you.html"); | 1215 registerMockedHttpURLLoad("no_scale_for_you.html"); |
1197 | 1216 |
1198 FixedLayoutTestWebViewClient client; | 1217 FixedLayoutTestWebViewClient client; |
1199 client.m_screenInfo.deviceScaleFactor = 1; | 1218 client.m_screenInfo.deviceScaleFactor = 1; |
1200 int viewportWidth = 640; | 1219 int viewportWidth = 640; |
1201 int viewportHeight = 480; | 1220 int viewportHeight = 480; |
1202 | 1221 |
1203 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for
_you.html", true, 0, &client); | 1222 initializeWebViewAndLoad(m_baseURL + "no_scale_for_you.html", true, 0, &clie
nt); |
1204 m_webView->enableFixedLayoutMode(true); | 1223 m_webView->enableFixedLayoutMode(true); |
1205 m_webView->settings()->setViewportEnabled(true); | 1224 m_webView->settings()->setViewportEnabled(true); |
1206 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1225 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1207 | 1226 |
1208 EXPECT_EQ(2.0f, m_webView->minimumPageScaleFactor()); | 1227 EXPECT_EQ(2.0f, m_webView->minimumPageScaleFactor()); |
1209 EXPECT_EQ(2.0f, m_webView->maximumPageScaleFactor()); | 1228 EXPECT_EQ(2.0f, m_webView->maximumPageScaleFactor()); |
1210 | 1229 |
1211 m_webView->setIgnoreViewportTagScaleLimits(true); | 1230 m_webView->setIgnoreViewportTagScaleLimits(true); |
1212 m_webView->layout(); | 1231 m_webView->layout(); |
1213 | 1232 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 } | 1274 } |
1256 | 1275 |
1257 TEST_F(WebFrameTest, DivAutoZoomParamsTest) | 1276 TEST_F(WebFrameTest, DivAutoZoomParamsTest) |
1258 { | 1277 { |
1259 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); | 1278 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
1260 | 1279 |
1261 const float deviceScaleFactor = 2.0f; | 1280 const float deviceScaleFactor = 2.0f; |
1262 int viewportWidth = 640 / deviceScaleFactor; | 1281 int viewportWidth = 640 / deviceScaleFactor; |
1263 int viewportHeight = 1280 / deviceScaleFactor; | 1282 int viewportHeight = 1280 / deviceScaleFactor; |
1264 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1283 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
1265 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo
r_auto_zoom_into_div_test.html"); // | 1284 initializeWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.
html"); |
1266 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 1285 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
1267 m_webView->setPageScaleFactorLimits(0.01f, 4); | 1286 m_webView->setPageScaleFactorLimits(0.01f, 4); |
1268 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | 1287 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); |
1269 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1288 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1270 m_webView->enableFixedLayoutMode(true); | 1289 m_webView->enableFixedLayoutMode(true); |
1271 m_webView->layout(); | 1290 m_webView->layout(); |
1272 | 1291 |
1273 WebRect wideDiv(200, 100, 400, 150); | 1292 WebRect wideDiv(200, 100, 400, 150); |
1274 WebRect tallDiv(200, 300, 400, 800); | 1293 WebRect tallDiv(200, 300, 400, 800); |
1275 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); | 1294 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 } | 1354 } |
1336 | 1355 |
1337 TEST_F(WebFrameTest, DivAutoZoomWideDivTest) | 1356 TEST_F(WebFrameTest, DivAutoZoomWideDivTest) |
1338 { | 1357 { |
1339 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); | 1358 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); |
1340 | 1359 |
1341 const float deviceScaleFactor = 2.0f; | 1360 const float deviceScaleFactor = 2.0f; |
1342 int viewportWidth = 640 / deviceScaleFactor; | 1361 int viewportWidth = 640 / deviceScaleFactor; |
1343 int viewportHeight = 1280 / deviceScaleFactor; | 1362 int viewportHeight = 1280 / deviceScaleFactor; |
1344 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1363 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
1345 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_wide_div
_for_auto_zoom_test.html"); | 1364 initializeWebViewAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test.html")
; |
1346 m_webView->enableFixedLayoutMode(true); | 1365 m_webView->enableFixedLayoutMode(true); |
1347 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1366 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1348 m_webView->setPageScaleFactorLimits(1.0f, 4); | 1367 m_webView->setPageScaleFactorLimits(1.0f, 4); |
1349 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 1368 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
1350 m_webView->setPageScaleFactor(1.0f, WebPoint(0, 0)); | 1369 m_webView->setPageScaleFactor(1.0f, WebPoint(0, 0)); |
1351 m_webView->layout(); | 1370 m_webView->layout(); |
1352 | 1371 |
1353 webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 1372 webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
1354 | 1373 |
1355 float doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFact
or() * doubleTapZoomAlreadyLegibleRatio; | 1374 float doubleTapZoomAlreadyLegibleScale = webViewImpl()->minimumPageScaleFact
or() * doubleTapZoomAlreadyLegibleRatio; |
(...skipping 10 matching lines...) Expand all Loading... |
1366 } | 1385 } |
1367 | 1386 |
1368 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) | 1387 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) |
1369 { | 1388 { |
1370 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 1389 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
1371 | 1390 |
1372 const float deviceScaleFactor = 2.0f; | 1391 const float deviceScaleFactor = 2.0f; |
1373 int viewportWidth = 640 / deviceScaleFactor; | 1392 int viewportWidth = 640 / deviceScaleFactor; |
1374 int viewportHeight = 1280 / deviceScaleFactor; | 1393 int viewportHeight = 1280 / deviceScaleFactor; |
1375 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1394 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
1376 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple
_divs_for_auto_zoom_test.html"); | 1395 initializeWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.h
tml"); |
1377 m_webView->enableFixedLayoutMode(true); | 1396 m_webView->enableFixedLayoutMode(true); |
1378 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1397 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1379 m_webView->setPageScaleFactorLimits(0.5f, 4); | 1398 m_webView->setPageScaleFactorLimits(0.5f, 4); |
1380 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 1399 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
1381 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | 1400 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); |
1382 m_webView->layout(); | 1401 m_webView->layout(); |
1383 | 1402 |
1384 webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 1403 webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
1385 | 1404 |
1386 WebRect topDiv(200, 100, 200, 150); | 1405 WebRect topDiv(200, 100, 200, 150); |
(...skipping 27 matching lines...) Expand all Loading... |
1414 EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); | 1433 EXPECT_FLOAT_EQ(webViewImpl()->minimumPageScaleFactor(), scale); |
1415 } | 1434 } |
1416 | 1435 |
1417 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) | 1436 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) |
1418 { | 1437 { |
1419 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 1438 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
1420 | 1439 |
1421 int viewportWidth = 320; | 1440 int viewportWidth = 320; |
1422 int viewportHeight = 480; | 1441 int viewportHeight = 480; |
1423 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1442 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
1424 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo
unds_check_for_auto_zoom_test.html"); | 1443 initializeWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_t
est.html"); |
1425 m_webView->enableFixedLayoutMode(true); | 1444 m_webView->enableFixedLayoutMode(true); |
1426 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1445 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1427 m_webView->setDeviceScaleFactor(1.5f); | 1446 m_webView->setDeviceScaleFactor(1.5f); |
1428 m_webView->layout(); | 1447 m_webView->layout(); |
1429 | 1448 |
1430 webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 1449 webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
1431 | 1450 |
1432 WebRect div(200, 100, 200, 150); | 1451 WebRect div(200, 100, 200, 150); |
1433 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 1452 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
1434 float scale; | 1453 float scale; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 } | 1495 } |
1477 | 1496 |
1478 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) | 1497 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) |
1479 { | 1498 { |
1480 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 1499 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
1481 | 1500 |
1482 int viewportWidth = 320; | 1501 int viewportWidth = 320; |
1483 int viewportHeight = 480; | 1502 int viewportHeight = 480; |
1484 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1503 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
1485 float textAutosizingFontScaleFactor = 1.13f; | 1504 float textAutosizingFontScaleFactor = 1.13f; |
1486 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo
unds_check_for_auto_zoom_test.html"); | 1505 initializeWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_t
est.html"); |
1487 m_webView->enableFixedLayoutMode(true); | 1506 m_webView->enableFixedLayoutMode(true); |
1488 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1507 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1489 m_webView->layout(); | 1508 m_webView->layout(); |
1490 | 1509 |
1491 webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 1510 webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
1492 webViewImpl()->page()->settings().setTextAutosizingEnabled(true); | 1511 webViewImpl()->page()->settings().setTextAutosizingEnabled(true); |
1493 webViewImpl()->page()->settings().setTextAutosizingFontScaleFactor(textAutos
izingFontScaleFactor); | 1512 webViewImpl()->page()->settings().setTextAutosizingFontScaleFactor(textAutos
izingFontScaleFactor); |
1494 | 1513 |
1495 WebRect div(200, 100, 200, 150); | 1514 WebRect div(200, 100, 200, 150); |
1496 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 1515 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 } | 1573 } |
1555 | 1574 |
1556 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) | 1575 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) |
1557 { | 1576 { |
1558 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 1577 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
1559 | 1578 |
1560 const float deviceScaleFactor = 2.0f; | 1579 const float deviceScaleFactor = 2.0f; |
1561 int viewportWidth = 640 / deviceScaleFactor; | 1580 int viewportWidth = 640 / deviceScaleFactor; |
1562 int viewportHeight = 1280 / deviceScaleFactor; | 1581 int viewportHeight = 1280 / deviceScaleFactor; |
1563 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1582 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
1564 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple
_divs_for_auto_zoom_test.html"); | 1583 initializeWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.h
tml"); |
1565 m_webView->enableFixedLayoutMode(true); | 1584 m_webView->enableFixedLayoutMode(true); |
1566 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1585 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1567 m_webView->setPageScaleFactorLimits(0.5f, 4); | 1586 m_webView->setPageScaleFactorLimits(0.5f, 4); |
1568 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 1587 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
1569 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | 1588 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); |
1570 m_webView->layout(); | 1589 m_webView->layout(); |
1571 | 1590 |
1572 webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 1591 webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
1573 | 1592 |
1574 WebRect viewportRect(0, 0, viewportWidth, viewportHeight); | 1593 WebRect viewportRect(0, 0, viewportWidth, viewportHeight); |
(...skipping 15 matching lines...) Expand all Loading... |
1590 | 1609 |
1591 TEST_F(WebFrameTest, DivScrollIntoEditableTest) | 1610 TEST_F(WebFrameTest, DivScrollIntoEditableTest) |
1592 { | 1611 { |
1593 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 1612 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
1594 | 1613 |
1595 int viewportWidth = 450; | 1614 int viewportWidth = 450; |
1596 int viewportHeight = 300; | 1615 int viewportHeight = 300; |
1597 float leftBoxRatio = 0.3f; | 1616 float leftBoxRatio = 0.3f; |
1598 int caretPadding = 10; | 1617 int caretPadding = 10; |
1599 float minReadableCaretHeight = 18.0f; | 1618 float minReadableCaretHeight = 18.0f; |
1600 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo
r_zoom_into_editable_test.html"); | 1619 initializeWebViewAndLoad(m_baseURL + "get_scale_for_zoom_into_editable_test.
html"); |
1601 m_webView->enableFixedLayoutMode(true); | 1620 m_webView->enableFixedLayoutMode(true); |
1602 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1621 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
1603 m_webView->setPageScaleFactorLimits(1, 4); | 1622 m_webView->setPageScaleFactorLimits(1, 4); |
1604 m_webView->layout(); | 1623 m_webView->layout(); |
1605 m_webView->setDeviceScaleFactor(1.5f); | 1624 m_webView->setDeviceScaleFactor(1.5f); |
1606 m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); | 1625 m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); |
1607 | 1626 |
1608 webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 1627 webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
1609 | 1628 |
1610 WebRect editBoxWithText(200, 200, 250, 20); | 1629 WebRect editBoxWithText(200, 200, 250, 20); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 } | 1696 } |
1678 }; | 1697 }; |
1679 | 1698 |
1680 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) | 1699 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) |
1681 { | 1700 { |
1682 // Test for case in http://crbug.com/73104. Reloading a frame very quickly | 1701 // Test for case in http://crbug.com/73104. Reloading a frame very quickly |
1683 // would sometimes call decidePolicyForNavigation with isRedirect=true | 1702 // would sometimes call decidePolicyForNavigation with isRedirect=true |
1684 registerMockedHttpURLLoad("form.html"); | 1703 registerMockedHttpURLLoad("form.html"); |
1685 | 1704 |
1686 TestReloadDoesntRedirectWebFrameClient webFrameClient; | 1705 TestReloadDoesntRedirectWebFrameClient webFrameClient; |
1687 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.html",
false, &webFrameClient); | 1706 initializeWebViewAndLoad(m_baseURL + "form.html", false, &webFrameClient); |
1688 | 1707 |
1689 m_webView->mainFrame()->reload(true); | 1708 m_webView->mainFrame()->reload(true); |
1690 // start reload before request is delivered. | 1709 // start reload before request is delivered. |
1691 m_webView->mainFrame()->reload(true); | 1710 m_webView->mainFrame()->reload(true); |
1692 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 1711 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
1693 | 1712 |
1694 m_webView->close(); | 1713 m_webView->close(); |
1695 m_webView = 0; | 1714 m_webView = 0; |
1696 } | 1715 } |
1697 | 1716 |
1698 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) | 1717 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) |
1699 { | 1718 { |
1700 const std::string firstURL = "find.html"; | 1719 const std::string firstURL = "find.html"; |
1701 const std::string secondURL = "form.html"; | 1720 const std::string secondURL = "form.html"; |
1702 const std::string thirdURL = "history.html"; | 1721 const std::string thirdURL = "history.html"; |
1703 const float pageScaleFactor = 1.1684f; | 1722 const float pageScaleFactor = 1.1684f; |
1704 const int pageWidth = 640; | 1723 const int pageWidth = 640; |
1705 const int pageHeight = 480; | 1724 const int pageHeight = 480; |
1706 | 1725 |
1707 registerMockedHttpURLLoad(firstURL); | 1726 registerMockedHttpURLLoad(firstURL); |
1708 registerMockedHttpURLLoad(secondURL); | 1727 registerMockedHttpURLLoad(secondURL); |
1709 registerMockedHttpURLLoad(thirdURL); | 1728 registerMockedHttpURLLoad(thirdURL); |
1710 | 1729 |
1711 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + firstURL, tru
e); | 1730 initializeWebViewAndLoad(m_baseURL + firstURL, true); |
1712 webViewImpl()->resize(WebSize(pageWidth, pageHeight)); | 1731 webViewImpl()->resize(WebSize(pageWidth, pageHeight)); |
1713 webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeigh
t / 4)); | 1732 webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeigh
t / 4)); |
1714 webViewImpl()->setPageScaleFactorPreservingScrollOffset(pageScaleFactor); | 1733 webViewImpl()->setPageScaleFactorPreservingScrollOffset(pageScaleFactor); |
1715 | 1734 |
1716 WebSize previousOffset = webViewImpl()->mainFrame()->scrollOffset(); | 1735 WebSize previousOffset = webViewImpl()->mainFrame()->scrollOffset(); |
1717 float previousScale = webViewImpl()->pageScaleFactor(); | 1736 float previousScale = webViewImpl()->pageScaleFactor(); |
1718 | 1737 |
1719 // Reload the page using the cache. | 1738 // Reload the page using the cache. |
1720 webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondU
RL), false); | 1739 webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondU
RL), false); |
1721 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 1740 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
(...skipping 10 matching lines...) Expand all Loading... |
1732 class TestReloadWhileProvisionalFrameClient : public WebFrameClient { | 1751 class TestReloadWhileProvisionalFrameClient : public WebFrameClient { |
1733 }; | 1752 }; |
1734 | 1753 |
1735 TEST_F(WebFrameTest, ReloadWhileProvisional) | 1754 TEST_F(WebFrameTest, ReloadWhileProvisional) |
1736 { | 1755 { |
1737 // Test that reloading while the previous load is still pending does not cau
se the initial | 1756 // Test that reloading while the previous load is still pending does not cau
se the initial |
1738 // request to get lost. | 1757 // request to get lost. |
1739 registerMockedHttpURLLoad("fixed_layout.html"); | 1758 registerMockedHttpURLLoad("fixed_layout.html"); |
1740 | 1759 |
1741 TestReloadWhileProvisionalFrameClient webFrameClient; | 1760 TestReloadWhileProvisionalFrameClient webFrameClient; |
1742 m_webView = FrameTestHelpers::createWebView(false, &webFrameClient); | 1761 initializeWebView(false, &webFrameClient); |
1743 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "fixed_layou
t.html"); | 1762 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "fixed_layou
t.html"); |
1744 // start reload before first request is delivered. | 1763 // start reload before first request is delivered. |
1745 m_webView->mainFrame()->reload(true); | 1764 m_webView->mainFrame()->reload(true); |
1746 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 1765 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
1747 ASSERT_EQ(WebURL(toKURL(m_baseURL + "fixed_layout.html")), | 1766 ASSERT_EQ(WebURL(toKURL(m_baseURL + "fixed_layout.html")), |
1748 m_webView->mainFrame()->dataSource()->request().url()); | 1767 m_webView->mainFrame()->dataSource()->request().url()); |
1749 | 1768 |
1750 m_webView->close(); | 1769 m_webView->close(); |
1751 m_webView = 0; | 1770 m_webView = 0; |
1752 } | 1771 } |
1753 | 1772 |
1754 TEST_F(WebFrameTest, IframeRedirect) | 1773 TEST_F(WebFrameTest, IframeRedirect) |
1755 { | 1774 { |
1756 registerMockedHttpURLLoad("iframe_redirect.html"); | 1775 registerMockedHttpURLLoad("iframe_redirect.html"); |
1757 registerMockedHttpURLLoad("visible_iframe.html"); | 1776 registerMockedHttpURLLoad("visible_iframe.html"); |
1758 | 1777 |
1759 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_redir
ect.html", true); | 1778 initializeWebViewAndLoad(m_baseURL + "iframe_redirect.html", true); |
1760 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); /
/ Load the iframe. | 1779 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); /
/ Load the iframe. |
1761 | 1780 |
1762 WebFrame* iframe = m_webView->findFrameByName(WebString::fromUTF8("ifr")); | 1781 WebFrame* iframe = m_webView->findFrameByName(WebString::fromUTF8("ifr")); |
1763 ASSERT_TRUE(iframe); | 1782 ASSERT_TRUE(iframe); |
1764 WebDataSource* iframeDataSource = iframe->dataSource(); | 1783 WebDataSource* iframeDataSource = iframe->dataSource(); |
1765 ASSERT_TRUE(iframeDataSource); | 1784 ASSERT_TRUE(iframeDataSource); |
1766 WebVector<WebURL> redirects; | 1785 WebVector<WebURL> redirects; |
1767 iframeDataSource->redirectChain(redirects); | 1786 iframeDataSource->redirectChain(redirects); |
1768 ASSERT_EQ(2U, redirects.size()); | 1787 ASSERT_EQ(2U, redirects.size()); |
1769 EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); | 1788 EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); |
1770 EXPECT_EQ(toKURL("http://www.test.com/visible_iframe.html"), toKURL(redirect
s[1].spec().data())); | 1789 EXPECT_EQ(toKURL("http://www.test.com/visible_iframe.html"), toKURL(redirect
s[1].spec().data())); |
1771 } | 1790 } |
1772 | 1791 |
1773 TEST_F(WebFrameTest, ClearFocusedNodeTest) | 1792 TEST_F(WebFrameTest, ClearFocusedNodeTest) |
1774 { | 1793 { |
1775 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); | 1794 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); |
1776 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); | 1795 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); |
1777 | 1796 |
1778 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_clear
_focused_node_test.html", true); | 1797 initializeWebViewAndLoad(m_baseURL + "iframe_clear_focused_node_test.html",
true); |
1779 | 1798 |
1780 // Clear the focused node. | 1799 // Clear the focused node. |
1781 m_webView->clearFocusedNode(); | 1800 m_webView->clearFocusedNode(); |
1782 | 1801 |
1783 // Now retrieve the FocusedNode and test it should be null. | 1802 // Now retrieve the FocusedNode and test it should be null. |
1784 EXPECT_EQ(0, webViewImpl()->focusedElement()); | 1803 EXPECT_EQ(0, webViewImpl()->focusedElement()); |
1785 } | 1804 } |
1786 | 1805 |
1787 // Implementation of WebFrameClient that tracks the v8 contexts that are created | 1806 // Implementation of WebFrameClient that tracks the v8 contexts that are created |
1788 // and destroyed for verification. | 1807 // and destroyed for verification. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 // TODO(aa): Deflake this test. | 1866 // TODO(aa): Deflake this test. |
1848 TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) | 1867 TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) |
1849 { | 1868 { |
1850 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 1869 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
1851 | 1870 |
1852 registerMockedHttpURLLoad("context_notifications_test.html"); | 1871 registerMockedHttpURLLoad("context_notifications_test.html"); |
1853 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 1872 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
1854 | 1873 |
1855 // Load a frame with an iframe, make sure we get the right create notificati
ons. | 1874 // Load a frame with an iframe, make sure we get the right create notificati
ons. |
1856 ContextLifetimeTestWebFrameClient webFrameClient; | 1875 ContextLifetimeTestWebFrameClient webFrameClient; |
1857 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_noti
fications_test.html", true, &webFrameClient); | 1876 initializeWebViewAndLoad(m_baseURL + "context_notifications_test.html", true
, &webFrameClient); |
1858 | 1877 |
1859 WebFrame* mainFrame = m_webView->mainFrame(); | 1878 WebFrame* mainFrame = m_webView->mainFrame(); |
1860 WebFrame* childFrame = mainFrame->firstChild(); | 1879 WebFrame* childFrame = mainFrame->firstChild(); |
1861 | 1880 |
1862 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); | 1881 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); |
1863 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); | 1882 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); |
1864 | 1883 |
1865 ContextLifetimeTestWebFrameClient::Notification* firstCreateNotification = w
ebFrameClient.createNotifications[0]; | 1884 ContextLifetimeTestWebFrameClient::Notification* firstCreateNotification = w
ebFrameClient.createNotifications[0]; |
1866 ContextLifetimeTestWebFrameClient::Notification* secondCreateNotification =
webFrameClient.createNotifications[1]; | 1885 ContextLifetimeTestWebFrameClient::Notification* secondCreateNotification =
webFrameClient.createNotifications[1]; |
1867 | 1886 |
(...skipping 18 matching lines...) Expand all Loading... |
1886 } | 1905 } |
1887 | 1906 |
1888 TEST_F(WebFrameTest, ContextNotificationsReload) | 1907 TEST_F(WebFrameTest, ContextNotificationsReload) |
1889 { | 1908 { |
1890 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 1909 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
1891 | 1910 |
1892 registerMockedHttpURLLoad("context_notifications_test.html"); | 1911 registerMockedHttpURLLoad("context_notifications_test.html"); |
1893 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 1912 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
1894 | 1913 |
1895 ContextLifetimeTestWebFrameClient webFrameClient; | 1914 ContextLifetimeTestWebFrameClient webFrameClient; |
1896 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_noti
fications_test.html", true, &webFrameClient); | 1915 initializeWebViewAndLoad(m_baseURL + "context_notifications_test.html", true
, &webFrameClient); |
1897 | 1916 |
1898 // Refresh, we should get two release notifications and two more create noti
fications. | 1917 // Refresh, we should get two release notifications and two more create noti
fications. |
1899 m_webView->mainFrame()->reload(false); | 1918 m_webView->mainFrame()->reload(false); |
1900 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 1919 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
1901 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); | 1920 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); |
1902 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 1921 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
1903 | 1922 |
1904 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. | 1923 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. |
1905 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 1924 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
1906 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( | 1925 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( |
(...skipping 20 matching lines...) Expand all Loading... |
1927 | 1946 |
1928 TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) | 1947 TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) |
1929 { | 1948 { |
1930 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1949 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
1931 v8::HandleScope handleScope(isolate); | 1950 v8::HandleScope handleScope(isolate); |
1932 | 1951 |
1933 registerMockedHttpURLLoad("context_notifications_test.html"); | 1952 registerMockedHttpURLLoad("context_notifications_test.html"); |
1934 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 1953 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
1935 | 1954 |
1936 ContextLifetimeTestWebFrameClient webFrameClient; | 1955 ContextLifetimeTestWebFrameClient webFrameClient; |
1937 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_noti
fications_test.html", true, &webFrameClient); | 1956 initializeWebViewAndLoad(m_baseURL + "context_notifications_test.html", true
, &webFrameClient); |
1938 | 1957 |
1939 // Add an isolated world. | 1958 // Add an isolated world. |
1940 webFrameClient.reset(); | 1959 webFrameClient.reset(); |
1941 | 1960 |
1942 int isolatedWorldId = 42; | 1961 int isolatedWorldId = 42; |
1943 WebScriptSource scriptSource("hi!"); | 1962 WebScriptSource scriptSource("hi!"); |
1944 int numSources = 1; | 1963 int numSources = 1; |
1945 int extensionGroup = 0; | 1964 int extensionGroup = 0; |
1946 m_webView->mainFrame()->executeScriptInIsolatedWorld(isolatedWorldId, &scrip
tSource, numSources, extensionGroup); | 1965 m_webView->mainFrame()->executeScriptInIsolatedWorld(isolatedWorldId, &scrip
tSource, numSources, extensionGroup); |
1947 | 1966 |
(...skipping 17 matching lines...) Expand all Loading... |
1965 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 1984 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
1966 if (webFrameClient.releaseNotifications[i]->Equals(webFrameClient.createNo
tifications[0])) | 1985 if (webFrameClient.releaseNotifications[i]->Equals(webFrameClient.createNo
tifications[0])) |
1967 ++matchCount; | 1986 ++matchCount; |
1968 } | 1987 } |
1969 EXPECT_EQ(1, matchCount); | 1988 EXPECT_EQ(1, matchCount); |
1970 } | 1989 } |
1971 | 1990 |
1972 TEST_F(WebFrameTest, FindInPage) | 1991 TEST_F(WebFrameTest, FindInPage) |
1973 { | 1992 { |
1974 registerMockedHttpURLLoad("find.html"); | 1993 registerMockedHttpURLLoad("find.html"); |
1975 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find.html"); | 1994 initializeWebViewAndLoad(m_baseURL + "find.html"); |
1976 WebFrame* frame = m_webView->mainFrame(); | 1995 WebFrame* frame = m_webView->mainFrame(); |
1977 const int findIdentifier = 12345; | 1996 const int findIdentifier = 12345; |
1978 WebFindOptions options; | 1997 WebFindOptions options; |
1979 | 1998 |
1980 // Find in a <div> element. | 1999 // Find in a <div> element. |
1981 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options
, false, 0)); | 2000 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options
, false, 0)); |
1982 frame->stopFinding(false); | 2001 frame->stopFinding(false); |
1983 WebRange range = frame->selectionRange(); | 2002 WebRange range = frame->selectionRange(); |
1984 EXPECT_EQ(5, range.startOffset()); | 2003 EXPECT_EQ(5, range.startOffset()); |
1985 EXPECT_EQ(9, range.endOffset()); | 2004 EXPECT_EQ(9, range.endOffset()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false, 0)); | 2039 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false, 0)); |
2021 // If there are any matches, stopFinding will set the selection on the found
text. | 2040 // If there are any matches, stopFinding will set the selection on the found
text. |
2022 // However, we do not expect any matches, so check that the selection is nul
l. | 2041 // However, we do not expect any matches, so check that the selection is nul
l. |
2023 frame->stopFinding(false); | 2042 frame->stopFinding(false); |
2024 range = frame->selectionRange(); | 2043 range = frame->selectionRange(); |
2025 ASSERT_TRUE(range.isNull()); | 2044 ASSERT_TRUE(range.isNull()); |
2026 } | 2045 } |
2027 | 2046 |
2028 TEST_F(WebFrameTest, GetContentAsPlainText) | 2047 TEST_F(WebFrameTest, GetContentAsPlainText) |
2029 { | 2048 { |
2030 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); | 2049 initializeWebViewAndLoad("about:blank", true); |
2031 // We set the size because it impacts line wrapping, which changes the | 2050 // We set the size because it impacts line wrapping, which changes the |
2032 // resulting text value. | 2051 // resulting text value. |
2033 m_webView->resize(WebSize(640, 480)); | 2052 m_webView->resize(WebSize(640, 480)); |
2034 WebFrame* frame = m_webView->mainFrame(); | 2053 WebFrame* frame = m_webView->mainFrame(); |
2035 | 2054 |
2036 // Generate a simple test case. | 2055 // Generate a simple test case. |
2037 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 2056 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
2038 WebCore::KURL testURL = toKURL("about:blank"); | 2057 WebCore::KURL testURL = toKURL("about:blank"); |
2039 frame->loadHTMLString(simpleSource, testURL); | 2058 frame->loadHTMLString(simpleSource, testURL); |
2040 runPendingTasks(); | 2059 runPendingTasks(); |
(...skipping 23 matching lines...) Expand all Loading... |
2064 EXPECT_EQ("Hello world\n\nsub\ntext", std::string(text.utf8().data())); | 2083 EXPECT_EQ("Hello world\n\nsub\ntext", std::string(text.utf8().data())); |
2065 | 2084 |
2066 // Get the frame text where the subframe separator falls on the boundary of | 2085 // Get the frame text where the subframe separator falls on the boundary of |
2067 // what we'll take. There used to be a crash in this case. | 2086 // what we'll take. There used to be a crash in this case. |
2068 text = frame->contentAsText(12); | 2087 text = frame->contentAsText(12); |
2069 EXPECT_EQ("Hello world", std::string(text.utf8().data())); | 2088 EXPECT_EQ("Hello world", std::string(text.utf8().data())); |
2070 } | 2089 } |
2071 | 2090 |
2072 TEST_F(WebFrameTest, GetFullHtmlOfPage) | 2091 TEST_F(WebFrameTest, GetFullHtmlOfPage) |
2073 { | 2092 { |
2074 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); | 2093 initializeWebViewAndLoad("about:blank", true); |
2075 WebFrame* frame = m_webView->mainFrame(); | 2094 WebFrame* frame = m_webView->mainFrame(); |
2076 | 2095 |
2077 // Generate a simple test case. | 2096 // Generate a simple test case. |
2078 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 2097 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
2079 WebCore::KURL testURL = toKURL("about:blank"); | 2098 WebCore::KURL testURL = toKURL("about:blank"); |
2080 frame->loadHTMLString(simpleSource, testURL); | 2099 frame->loadHTMLString(simpleSource, testURL); |
2081 runPendingTasks(); | 2100 runPendingTasks(); |
2082 | 2101 |
2083 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 2102 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
2084 EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8().data())); | 2103 EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8().data())); |
(...skipping 25 matching lines...) Expand all Loading... |
2110 { | 2129 { |
2111 frame->executeScript(WebScriptSource("window.history = 'replaced';")); | 2130 frame->executeScript(WebScriptSource("window.history = 'replaced';")); |
2112 } | 2131 } |
2113 }; | 2132 }; |
2114 | 2133 |
2115 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) | 2134 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) |
2116 { | 2135 { |
2117 registerMockedHttpURLLoad("hello_world.html"); | 2136 registerMockedHttpURLLoad("hello_world.html"); |
2118 | 2137 |
2119 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; | 2138 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; |
2120 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.
html", true, &webFrameClient); | 2139 initializeWebViewAndLoad(m_baseURL + "hello_world.html", true, &webFrameClie
nt); |
2121 | 2140 |
2122 m_webView->mainFrame()->reload(); | 2141 m_webView->mainFrame()->reload(); |
2123 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 2142 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
2124 | 2143 |
2125 m_webView->close(); | 2144 m_webView->close(); |
2126 m_webView = 0; | 2145 m_webView = 0; |
2127 } | 2146 } |
2128 | 2147 |
2129 class TestDidCreateFrameWebFrameClient : public WebFrameClient { | 2148 class TestDidCreateFrameWebFrameClient : public WebFrameClient { |
2130 public: | 2149 public: |
2131 TestDidCreateFrameWebFrameClient() : m_frameCount(0), m_parent(0) | 2150 TestDidCreateFrameWebFrameClient() : m_frameCount(0), m_parent(0) |
2132 { | 2151 { |
2133 } | 2152 } |
2134 | 2153 |
2135 virtual void didCreateFrame(WebFrame* parent, WebFrame* child) | 2154 virtual WebFrame* didCreateFrame(WebString name) |
2136 { | 2155 { |
2137 m_frameCount++; | 2156 m_frameCount++; |
| 2157 /* |
2138 if (!m_parent) | 2158 if (!m_parent) |
2139 m_parent = parent; | 2159 m_parent = parent; |
| 2160 */ |
| 2161 return 0; |
2140 } | 2162 } |
2141 | 2163 |
2142 int m_frameCount; | 2164 int m_frameCount; |
2143 WebFrame* m_parent; | 2165 WebFrame* m_parent; |
2144 }; | 2166 }; |
2145 | 2167 |
2146 TEST_F(WebFrameTest, DidCreateFrame) | 2168 TEST_F(WebFrameTest, DidCreateFrame) |
2147 { | 2169 { |
2148 registerMockedHttpURLLoad("iframes_test.html"); | 2170 registerMockedHttpURLLoad("iframes_test.html"); |
2149 registerMockedHttpURLLoad("visible_iframe.html"); | 2171 registerMockedHttpURLLoad("visible_iframe.html"); |
2150 registerMockedHttpURLLoad("invisible_iframe.html"); | 2172 registerMockedHttpURLLoad("invisible_iframe.html"); |
2151 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 2173 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
2152 | 2174 |
2153 TestDidCreateFrameWebFrameClient webFrameClient; | 2175 TestDidCreateFrameWebFrameClient webFrameClient; |
2154 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test
.html", false, &webFrameClient); | 2176 initializeWebViewAndLoad(m_baseURL + "iframes_test.html", false, &webFrameCl
ient); |
2155 | 2177 |
2156 EXPECT_EQ(webFrameClient.m_frameCount, 3); | 2178 EXPECT_EQ(webFrameClient.m_frameCount, 3); |
2157 EXPECT_EQ(webFrameClient.m_parent, m_webView->mainFrame()); | 2179 EXPECT_EQ(webFrameClient.m_parent, m_webView->mainFrame()); |
2158 | 2180 |
2159 m_webView->close(); | 2181 m_webView->close(); |
2160 m_webView = 0; | 2182 m_webView = 0; |
2161 } | 2183 } |
2162 | 2184 |
2163 class FindUpdateWebFrameClient : public WebFrameClient { | 2185 class FindUpdateWebFrameClient : public WebFrameClient { |
2164 public: | 2186 public: |
(...skipping 22 matching lines...) Expand all Loading... |
2187 #if OS(MACOSX) | 2209 #if OS(MACOSX) |
2188 TEST_F(WebFrameTest, DISABLED_FindInPageMatchRects) | 2210 TEST_F(WebFrameTest, DISABLED_FindInPageMatchRects) |
2189 #else | 2211 #else |
2190 TEST_F(WebFrameTest, FindInPageMatchRects) | 2212 TEST_F(WebFrameTest, FindInPageMatchRects) |
2191 #endif | 2213 #endif |
2192 { | 2214 { |
2193 registerMockedHttpURLLoad("find_in_page.html"); | 2215 registerMockedHttpURLLoad("find_in_page.html"); |
2194 registerMockedHttpURLLoad("find_in_page_frame.html"); | 2216 registerMockedHttpURLLoad("find_in_page_frame.html"); |
2195 | 2217 |
2196 FindUpdateWebFrameClient client; | 2218 FindUpdateWebFrameClient client; |
2197 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page
.html", true, &client); | 2219 initializeWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); |
2198 m_webView->resize(WebSize(640, 480)); | 2220 m_webView->resize(WebSize(640, 480)); |
2199 m_webView->layout(); | 2221 m_webView->layout(); |
2200 runPendingTasks(); | 2222 runPendingTasks(); |
2201 | 2223 |
2202 // Note that the 'result 19' in the <select> element is not expected to prod
uce a match. | 2224 // Note that the 'result 19' in the <select> element is not expected to prod
uce a match. |
2203 static const char* kFindString = "result"; | 2225 static const char* kFindString = "result"; |
2204 static const int kFindIdentifier = 12345; | 2226 static const int kFindIdentifier = 12345; |
2205 static const int kNumResults = 19; | 2227 static const int kNumResults = 19; |
2206 | 2228 |
2207 WebFindOptions options; | 2229 WebFindOptions options; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 | 2329 |
2308 m_webView->close(); | 2330 m_webView->close(); |
2309 m_webView = 0; | 2331 m_webView = 0; |
2310 } | 2332 } |
2311 | 2333 |
2312 TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) | 2334 TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) |
2313 { | 2335 { |
2314 registerMockedHttpURLLoad("find_in_hidden_frame.html"); | 2336 registerMockedHttpURLLoad("find_in_hidden_frame.html"); |
2315 | 2337 |
2316 FindUpdateWebFrameClient client; | 2338 FindUpdateWebFrameClient client; |
2317 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_hidd
en_frame.html", true, &client); | 2339 initializeWebViewAndLoad(m_baseURL + "find_in_hidden_frame.html", true, &cli
ent); |
2318 m_webView->resize(WebSize(640, 480)); | 2340 m_webView->resize(WebSize(640, 480)); |
2319 m_webView->layout(); | 2341 m_webView->layout(); |
2320 runPendingTasks(); | 2342 runPendingTasks(); |
2321 | 2343 |
2322 static const char* kFindString = "hello"; | 2344 static const char* kFindString = "hello"; |
2323 static const int kFindIdentifier = 12345; | 2345 static const int kFindIdentifier = 12345; |
2324 static const int kNumResults = 1; | 2346 static const int kNumResults = 1; |
2325 | 2347 |
2326 WebFindOptions options; | 2348 WebFindOptions options; |
2327 WebString searchText = WebString::fromUTF8(kFindString); | 2349 WebString searchText = WebString::fromUTF8(kFindString); |
(...skipping 12 matching lines...) Expand all Loading... |
2340 m_webView->close(); | 2362 m_webView->close(); |
2341 m_webView = 0; | 2363 m_webView = 0; |
2342 } | 2364 } |
2343 | 2365 |
2344 TEST_F(WebFrameTest, FindOnDetachedFrame) | 2366 TEST_F(WebFrameTest, FindOnDetachedFrame) |
2345 { | 2367 { |
2346 registerMockedHttpURLLoad("find_in_page.html"); | 2368 registerMockedHttpURLLoad("find_in_page.html"); |
2347 registerMockedHttpURLLoad("find_in_page_frame.html"); | 2369 registerMockedHttpURLLoad("find_in_page_frame.html"); |
2348 | 2370 |
2349 FindUpdateWebFrameClient client; | 2371 FindUpdateWebFrameClient client; |
2350 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page
.html", true, &client); | 2372 initializeWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); |
2351 m_webView->resize(WebSize(640, 480)); | 2373 m_webView->resize(WebSize(640, 480)); |
2352 m_webView->layout(); | 2374 m_webView->layout(); |
2353 runPendingTasks(); | 2375 runPendingTasks(); |
2354 | 2376 |
2355 static const char* kFindString = "result"; | 2377 static const char* kFindString = "result"; |
2356 static const int kFindIdentifier = 12345; | 2378 static const int kFindIdentifier = 12345; |
2357 | 2379 |
2358 WebFindOptions options; | 2380 WebFindOptions options; |
2359 WebString searchText = WebString::fromUTF8(kFindString); | 2381 WebString searchText = WebString::fromUTF8(kFindString); |
2360 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); | 2382 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); |
(...skipping 22 matching lines...) Expand all Loading... |
2383 m_webView->close(); | 2405 m_webView->close(); |
2384 m_webView = 0; | 2406 m_webView = 0; |
2385 } | 2407 } |
2386 | 2408 |
2387 TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) | 2409 TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) |
2388 { | 2410 { |
2389 registerMockedHttpURLLoad("find_in_page.html"); | 2411 registerMockedHttpURLLoad("find_in_page.html"); |
2390 registerMockedHttpURLLoad("find_in_page_frame.html"); | 2412 registerMockedHttpURLLoad("find_in_page_frame.html"); |
2391 | 2413 |
2392 FindUpdateWebFrameClient client; | 2414 FindUpdateWebFrameClient client; |
2393 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page
.html", true, &client); | 2415 initializeWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); |
2394 m_webView->resize(WebSize(640, 480)); | 2416 m_webView->resize(WebSize(640, 480)); |
2395 m_webView->layout(); | 2417 m_webView->layout(); |
2396 runPendingTasks(); | 2418 runPendingTasks(); |
2397 | 2419 |
2398 static const char* kFindString = "result"; | 2420 static const char* kFindString = "result"; |
2399 static const int kFindIdentifier = 12345; | 2421 static const int kFindIdentifier = 12345; |
2400 | 2422 |
2401 WebFindOptions options; | 2423 WebFindOptions options; |
2402 WebString searchText = WebString::fromUTF8(kFindString); | 2424 WebString searchText = WebString::fromUTF8(kFindString); |
2403 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); | 2425 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); |
(...skipping 22 matching lines...) Expand all Loading... |
2426 m_webView->close(); | 2448 m_webView->close(); |
2427 m_webView = 0; | 2449 m_webView = 0; |
2428 } | 2450 } |
2429 | 2451 |
2430 TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) | 2452 TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) |
2431 { | 2453 { |
2432 registerMockedHttpURLLoad("find_in_page.html"); | 2454 registerMockedHttpURLLoad("find_in_page.html"); |
2433 registerMockedHttpURLLoad("find_in_page_frame.html"); | 2455 registerMockedHttpURLLoad("find_in_page_frame.html"); |
2434 | 2456 |
2435 FindUpdateWebFrameClient client; | 2457 FindUpdateWebFrameClient client; |
2436 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page
.html", true, &client); | 2458 initializeWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client); |
2437 m_webView->resize(WebSize(640, 480)); | 2459 m_webView->resize(WebSize(640, 480)); |
2438 m_webView->layout(); | 2460 m_webView->layout(); |
2439 runPendingTasks(); | 2461 runPendingTasks(); |
2440 | 2462 |
2441 static const char* kFindString = "result"; | 2463 static const char* kFindString = "result"; |
2442 static const int kFindIdentifier = 12345; | 2464 static const int kFindIdentifier = 12345; |
2443 | 2465 |
2444 WebFindOptions options; | 2466 WebFindOptions options; |
2445 WebString searchText = WebString::fromUTF8(kFindString); | 2467 WebString searchText = WebString::fromUTF8(kFindString); |
2446 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); | 2468 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); |
(...skipping 18 matching lines...) Expand all Loading... |
2465 EXPECT_TRUE(client.findResultsAreReady()); | 2487 EXPECT_TRUE(client.findResultsAreReady()); |
2466 | 2488 |
2467 holdSecondFrame.release(); | 2489 holdSecondFrame.release(); |
2468 | 2490 |
2469 m_webView->close(); | 2491 m_webView->close(); |
2470 m_webView = 0; | 2492 m_webView = 0; |
2471 } | 2493 } |
2472 | 2494 |
2473 static WebView* createWebViewForTextSelection(const std::string& url) | 2495 static WebView* createWebViewForTextSelection(const std::string& url) |
2474 { | 2496 { |
2475 WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true); | 2497 WebView* webView = createWebViewAndLoad(url, true); |
2476 webView->settings()->setDefaultFontSize(12); | 2498 webView->settings()->setDefaultFontSize(12); |
2477 webView->enableFixedLayoutMode(false); | 2499 webView->enableFixedLayoutMode(false); |
2478 webView->resize(WebSize(640, 480)); | 2500 webView->resize(WebSize(640, 480)); |
2479 return webView; | 2501 return webView; |
2480 } | 2502 } |
2481 | 2503 |
2482 static WebPoint topLeft(const WebRect& rect) | 2504 static WebPoint topLeft(const WebRect& rect) |
2483 { | 2505 { |
2484 return WebPoint(rect.x, rect.y); | 2506 return WebPoint(rect.x, rect.y); |
2485 } | 2507 } |
(...skipping 19 matching lines...) Expand all Loading... |
2505 | 2527 |
2506 TEST_F(WebFrameTest, SelectRange) | 2528 TEST_F(WebFrameTest, SelectRange) |
2507 { | 2529 { |
2508 WebFrame* frame; | 2530 WebFrame* frame; |
2509 WebRect startWebRect; | 2531 WebRect startWebRect; |
2510 WebRect endWebRect; | 2532 WebRect endWebRect; |
2511 | 2533 |
2512 registerMockedHttpURLLoad("select_range_basic.html"); | 2534 registerMockedHttpURLLoad("select_range_basic.html"); |
2513 registerMockedHttpURLLoad("select_range_scroll.html"); | 2535 registerMockedHttpURLLoad("select_range_scroll.html"); |
2514 | 2536 |
2515 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_basic.ht
ml"); | 2537 initializeWebViewForTextSelection(m_baseURL + "select_range_basic.html"); |
2516 frame = m_webView->mainFrame(); | 2538 frame = m_webView->mainFrame(); |
2517 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); | 2539 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); |
2518 m_webView->selectionBounds(startWebRect, endWebRect); | 2540 m_webView->selectionBounds(startWebRect, endWebRect); |
2519 frame->executeCommand(WebString::fromUTF8("Unselect")); | 2541 frame->executeCommand(WebString::fromUTF8("Unselect")); |
2520 EXPECT_EQ("", selectionAsString(frame)); | 2542 EXPECT_EQ("", selectionAsString(frame)); |
2521 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 2543 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
2522 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); | 2544 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); |
2523 m_webView->close(); | 2545 m_webView->close(); |
2524 m_webView = 0; | 2546 m_webView = 0; |
2525 | 2547 |
2526 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_scroll.h
tml"); | 2548 initializeWebViewForTextSelection(m_baseURL + "select_range_scroll.html"); |
2527 frame = m_webView->mainFrame(); | 2549 frame = m_webView->mainFrame(); |
2528 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame))
; | 2550 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame))
; |
2529 m_webView->selectionBounds(startWebRect, endWebRect); | 2551 m_webView->selectionBounds(startWebRect, endWebRect); |
2530 frame->executeCommand(WebString::fromUTF8("Unselect")); | 2552 frame->executeCommand(WebString::fromUTF8("Unselect")); |
2531 EXPECT_EQ("", selectionAsString(frame)); | 2553 EXPECT_EQ("", selectionAsString(frame)); |
2532 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 2554 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
2533 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame))
; | 2555 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame))
; |
2534 m_webView->close(); | 2556 m_webView->close(); |
2535 m_webView = 0; | 2557 m_webView = 0; |
2536 } | 2558 } |
2537 | 2559 |
2538 TEST_F(WebFrameTest, SelectRangeInIframe) | 2560 TEST_F(WebFrameTest, SelectRangeInIframe) |
2539 { | 2561 { |
2540 WebFrame* frame; | 2562 WebFrame* frame; |
2541 WebRect startWebRect; | 2563 WebRect startWebRect; |
2542 WebRect endWebRect; | 2564 WebRect endWebRect; |
2543 | 2565 |
2544 registerMockedHttpURLLoad("select_range_iframe.html"); | 2566 registerMockedHttpURLLoad("select_range_iframe.html"); |
2545 registerMockedHttpURLLoad("select_range_basic.html"); | 2567 registerMockedHttpURLLoad("select_range_basic.html"); |
2546 | 2568 |
2547 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_iframe.h
tml"); | 2569 initializeWebViewForTextSelection(m_baseURL + "select_range_iframe.html"); |
2548 frame = m_webView->mainFrame(); | 2570 frame = m_webView->mainFrame(); |
2549 WebFrame* subframe = frame->findChildByExpression(WebString::fromUTF8("/html
/body/iframe")); | 2571 WebFrame* subframe = frame->findChildByExpression(WebString::fromUTF8("/html
/body/iframe")); |
2550 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); | 2572 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); |
2551 m_webView->selectionBounds(startWebRect, endWebRect); | 2573 m_webView->selectionBounds(startWebRect, endWebRect); |
2552 subframe->executeCommand(WebString::fromUTF8("Unselect")); | 2574 subframe->executeCommand(WebString::fromUTF8("Unselect")); |
2553 EXPECT_EQ("", selectionAsString(subframe)); | 2575 EXPECT_EQ("", selectionAsString(subframe)); |
2554 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)
); | 2576 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)
); |
2555 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); | 2577 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); |
2556 m_webView->close(); | 2578 m_webView->close(); |
2557 m_webView = 0; | 2579 m_webView = 0; |
2558 } | 2580 } |
2559 | 2581 |
2560 TEST_F(WebFrameTest, SelectRangeDivContentEditable) | 2582 TEST_F(WebFrameTest, SelectRangeDivContentEditable) |
2561 { | 2583 { |
2562 WebFrame* frame; | 2584 WebFrame* frame; |
2563 WebRect startWebRect; | 2585 WebRect startWebRect; |
2564 WebRect endWebRect; | 2586 WebRect endWebRect; |
2565 | 2587 |
2566 registerMockedHttpURLLoad("select_range_div_editable.html"); | 2588 registerMockedHttpURLLoad("select_range_div_editable.html"); |
2567 | 2589 |
2568 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. | 2590 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. |
2569 // The selection range should be clipped to the bounds of the editable eleme
nt. | 2591 // The selection range should be clipped to the bounds of the editable eleme
nt. |
2570 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_edit
able.html"); | 2592 initializeWebViewForTextSelection(m_baseURL + "select_range_div_editable.htm
l"); |
2571 frame = m_webView->mainFrame(); | 2593 frame = m_webView->mainFrame(); |
2572 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 2594 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
2573 m_webView->selectionBounds(startWebRect, endWebRect); | 2595 m_webView->selectionBounds(startWebRect, endWebRect); |
2574 | 2596 |
2575 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); | 2597 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
2576 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); | 2598 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); |
2577 m_webView->close(); | 2599 m_webView->close(); |
2578 m_webView = 0; | 2600 m_webView = 0; |
2579 | 2601 |
2580 // As above, but extending the selection to the bottom of the document. | 2602 // As above, but extending the selection to the bottom of the document. |
2581 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_edit
able.html"); | 2603 initializeWebViewForTextSelection(m_baseURL + "select_range_div_editable.htm
l"); |
2582 frame = m_webView->mainFrame(); | 2604 frame = m_webView->mainFrame(); |
2583 | 2605 |
2584 m_webView->selectionBounds(startWebRect, endWebRect); | 2606 m_webView->selectionBounds(startWebRect, endWebRect); |
2585 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 2607 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
2586 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 2608 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
2587 m_webView->selectionBounds(startWebRect, endWebRect); | 2609 m_webView->selectionBounds(startWebRect, endWebRect); |
2588 | 2610 |
2589 m_webView->selectionBounds(startWebRect, endWebRect); | 2611 m_webView->selectionBounds(startWebRect, endWebRect); |
2590 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); | 2612 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); |
2591 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); | 2613 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); |
2592 m_webView->close(); | 2614 m_webView->close(); |
2593 m_webView = 0; | 2615 m_webView = 0; |
2594 } | 2616 } |
2595 | 2617 |
2596 // positionForPoint returns the wrong values for contenteditable spans. See | 2618 // positionForPoint returns the wrong values for contenteditable spans. See |
2597 // http://crbug.com/238334. | 2619 // http://crbug.com/238334. |
2598 TEST_F(WebFrameTest, DISABLED_SelectRangeSpanContentEditable) | 2620 TEST_F(WebFrameTest, DISABLED_SelectRangeSpanContentEditable) |
2599 { | 2621 { |
2600 WebFrame* frame; | 2622 WebFrame* frame; |
2601 WebRect startWebRect; | 2623 WebRect startWebRect; |
2602 WebRect endWebRect; | 2624 WebRect endWebRect; |
2603 | 2625 |
2604 registerMockedHttpURLLoad("select_range_span_editable.html"); | 2626 registerMockedHttpURLLoad("select_range_span_editable.html"); |
2605 | 2627 |
2606 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. | 2628 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. |
2607 // The selection range should be clipped to the bounds of the editable eleme
nt. | 2629 // The selection range should be clipped to the bounds of the editable eleme
nt. |
2608 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_edi
table.html"); | 2630 initializeWebViewForTextSelection(m_baseURL + "select_range_span_editable.ht
ml"); |
2609 frame = m_webView->mainFrame(); | 2631 frame = m_webView->mainFrame(); |
2610 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 2632 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
2611 m_webView->selectionBounds(startWebRect, endWebRect); | 2633 m_webView->selectionBounds(startWebRect, endWebRect); |
2612 | 2634 |
2613 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); | 2635 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
2614 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); | 2636 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); |
2615 m_webView->close(); | 2637 m_webView->close(); |
2616 m_webView = 0; | 2638 m_webView = 0; |
2617 | 2639 |
2618 // As above, but extending the selection to the bottom of the document. | 2640 // As above, but extending the selection to the bottom of the document. |
2619 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_edi
table.html"); | 2641 initializeWebViewForTextSelection(m_baseURL + "select_range_span_editable.ht
ml"); |
2620 frame = m_webView->mainFrame(); | 2642 frame = m_webView->mainFrame(); |
2621 | 2643 |
2622 m_webView->selectionBounds(startWebRect, endWebRect); | 2644 m_webView->selectionBounds(startWebRect, endWebRect); |
2623 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 2645 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
2624 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 2646 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
2625 m_webView->selectionBounds(startWebRect, endWebRect); | 2647 m_webView->selectionBounds(startWebRect, endWebRect); |
2626 | 2648 |
2627 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 2649 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
2628 m_webView->selectionBounds(startWebRect, endWebRect); | 2650 m_webView->selectionBounds(startWebRect, endWebRect); |
2629 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); | 2651 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); |
2630 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); | 2652 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); |
2631 m_webView->close(); | 2653 m_webView->close(); |
2632 m_webView = 0; | 2654 m_webView = 0; |
2633 } | 2655 } |
2634 | 2656 |
2635 TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart) | 2657 TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart) |
2636 { | 2658 { |
2637 registerMockedHttpURLLoad("text_selection.html"); | 2659 registerMockedHttpURLLoad("text_selection.html"); |
2638 m_webView = createWebViewForTextSelection(m_baseURL + "text_selection.html")
; | 2660 initializeWebViewForTextSelection(m_baseURL + "text_selection.html"); |
2639 WebFrame* frame = m_webView->mainFrame(); | 2661 WebFrame* frame = m_webView->mainFrame(); |
2640 | 2662 |
2641 // Select second span. We can move the start to include the first span. | 2663 // Select second span. We can move the start to include the first span. |
2642 frame->executeScript(WebScriptSource("selectElement('header_2');")); | 2664 frame->executeScript(WebScriptSource("selectElement('header_2');")); |
2643 EXPECT_EQ("Header 2.", selectionAsString(frame)); | 2665 EXPECT_EQ("Header 2.", selectionAsString(frame)); |
2644 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to
pLeft(elementBounds(frame, "header_1"))); | 2666 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to
pLeft(elementBounds(frame, "header_1"))); |
2645 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); | 2667 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); |
2646 | 2668 |
2647 // We can move the start and end together. | 2669 // We can move the start and end together. |
2648 frame->executeScript(WebScriptSource("selectElement('header_1');")); | 2670 frame->executeScript(WebScriptSource("selectElement('header_1');")); |
(...skipping 26 matching lines...) Expand all Loading... |
2675 EXPECT_EQ("Editable 2.", selectionAsString(frame)); | 2697 EXPECT_EQ("Editable 2.", selectionAsString(frame)); |
2676 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")),
topLeft(elementBounds(frame, "header_2"))); | 2698 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")),
topLeft(elementBounds(frame, "header_2"))); |
2677 // positionForPoint returns the wrong values for contenteditable spans. See | 2699 // positionForPoint returns the wrong values for contenteditable spans. See |
2678 // http://crbug.com/238334. | 2700 // http://crbug.com/238334. |
2679 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); | 2701 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); |
2680 } | 2702 } |
2681 | 2703 |
2682 TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd) | 2704 TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd) |
2683 { | 2705 { |
2684 registerMockedHttpURLLoad("text_selection.html"); | 2706 registerMockedHttpURLLoad("text_selection.html"); |
2685 m_webView = createWebViewForTextSelection(m_baseURL + "text_selection.html")
; | 2707 initializeWebViewForTextSelection(m_baseURL + "text_selection.html"); |
2686 WebFrame* frame = m_webView->mainFrame(); | 2708 WebFrame* frame = m_webView->mainFrame(); |
2687 | 2709 |
2688 // Select first span. We can move the end to include the second span. | 2710 // Select first span. We can move the end to include the second span. |
2689 frame->executeScript(WebScriptSource("selectElement('header_1');")); | 2711 frame->executeScript(WebScriptSource("selectElement('header_1');")); |
2690 EXPECT_EQ("Header 1.", selectionAsString(frame)); | 2712 EXPECT_EQ("Header 1.", selectionAsString(frame)); |
2691 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin
usOne(elementBounds(frame, "header_2"))); | 2713 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin
usOne(elementBounds(frame, "header_2"))); |
2692 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); | 2714 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); |
2693 | 2715 |
2694 // We can move the start and end together. | 2716 // We can move the start and end together. |
2695 frame->executeScript(WebScriptSource("selectElement('header_2');")); | 2717 frame->executeScript(WebScriptSource("selectElement('header_2');")); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 static int computeOffset(WebCore::RenderObject* renderer, int x, int y) | 2751 static int computeOffset(WebCore::RenderObject* renderer, int x, int y) |
2730 { | 2752 { |
2731 return WebCore::VisiblePosition(renderer->positionForPoint(WebCore::LayoutPo
int(x, y))).deepEquivalent().computeOffsetInContainerNode(); | 2753 return WebCore::VisiblePosition(renderer->positionForPoint(WebCore::LayoutPo
int(x, y))).deepEquivalent().computeOffsetInContainerNode(); |
2732 } | 2754 } |
2733 | 2755 |
2734 // positionForPoint returns the wrong values for contenteditable spans. See | 2756 // positionForPoint returns the wrong values for contenteditable spans. See |
2735 // http://crbug.com/238334. | 2757 // http://crbug.com/238334. |
2736 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) | 2758 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) |
2737 { | 2759 { |
2738 registerMockedHttpURLLoad("select_range_span_editable.html"); | 2760 registerMockedHttpURLLoad("select_range_span_editable.html"); |
2739 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_edi
table.html"); | 2761 initializeWebViewForTextSelection(m_baseURL + "select_range_span_editable.ht
ml"); |
2740 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); | 2762 WebFrameImpl* mainFrame = toWebFrameImpl(m_webView->mainFrame()); |
2741 WebCore::RenderObject* renderer = mainFrame->frame()->selection().rootEditab
leElement()->renderer(); | 2763 WebCore::RenderObject* renderer = mainFrame->frame()->selection().rootEditab
leElement()->renderer(); |
2742 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 2764 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
2743 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 2765 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
2744 | 2766 |
2745 registerMockedHttpURLLoad("select_range_div_editable.html"); | 2767 registerMockedHttpURLLoad("select_range_div_editable.html"); |
2746 m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_edit
able.html"); | 2768 initializeWebViewForTextSelection(m_baseURL + "select_range_div_editable.htm
l"); |
2747 mainFrame = toWebFrameImpl(m_webView->mainFrame()); | 2769 mainFrame = toWebFrameImpl(m_webView->mainFrame()); |
2748 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; | 2770 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; |
2749 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 2771 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
2750 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 2772 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
2751 } | 2773 } |
2752 | 2774 |
2753 #if !OS(MACOSX) | 2775 #if !OS(MACOSX) |
2754 TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) | 2776 TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) |
2755 { | 2777 { |
2756 WebFrameImpl* frame; | 2778 WebFrameImpl* frame; |
2757 registerMockedHttpURLLoad("move_caret.html"); | 2779 registerMockedHttpURLLoad("move_caret.html"); |
2758 | 2780 |
2759 m_webView = createWebViewForTextSelection(m_baseURL + "move_caret.html"); | 2781 initializeWebViewForTextSelection(m_baseURL + "move_caret.html"); |
2760 frame = (WebFrameImpl*)m_webView->mainFrame(); | 2782 frame = (WebFrameImpl*)m_webView->mainFrame(); |
2761 | 2783 |
2762 WebRect initialStartRect; | 2784 WebRect initialStartRect; |
2763 WebRect initialEndRect; | 2785 WebRect initialEndRect; |
2764 WebRect startRect; | 2786 WebRect startRect; |
2765 WebRect endRect; | 2787 WebRect endRect; |
2766 | 2788 |
2767 frame->executeScript(WebScriptSource("selectRange();")); | 2789 frame->executeScript(WebScriptSource("selectRange();")); |
2768 m_webView->selectionBounds(initialStartRect, initialEndRect); | 2790 m_webView->selectionBounds(initialStartRect, initialEndRect); |
2769 WebPoint movedStart(topLeft(initialStartRect)); | 2791 WebPoint movedStart(topLeft(initialStartRect)); |
(...skipping 23 matching lines...) Expand all Loading... |
2793 m_webView->selectionBounds(startRect, endRect); | 2815 m_webView->selectionBounds(startRect, endRect); |
2794 EXPECT_EQ(startRect, initialStartRect); | 2816 EXPECT_EQ(startRect, initialStartRect); |
2795 EXPECT_EQ(endRect, initialEndRect); | 2817 EXPECT_EQ(endRect, initialEndRect); |
2796 } | 2818 } |
2797 | 2819 |
2798 TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) | 2820 TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) |
2799 { | 2821 { |
2800 WebFrameImpl* frame; | 2822 WebFrameImpl* frame; |
2801 registerMockedHttpURLLoad("move_caret.html"); | 2823 registerMockedHttpURLLoad("move_caret.html"); |
2802 | 2824 |
2803 m_webView = createWebViewForTextSelection(m_baseURL + "move_caret.html"); | 2825 initializeWebViewForTextSelection(m_baseURL + "move_caret.html"); |
2804 frame = (WebFrameImpl*)m_webView->mainFrame(); | 2826 frame = (WebFrameImpl*)m_webView->mainFrame(); |
2805 | 2827 |
2806 WebRect initialStartRect; | 2828 WebRect initialStartRect; |
2807 WebRect initialEndRect; | 2829 WebRect initialEndRect; |
2808 WebRect startRect; | 2830 WebRect startRect; |
2809 WebRect endRect; | 2831 WebRect endRect; |
2810 | 2832 |
2811 frame->executeScript(WebScriptSource("selectCaret();")); | 2833 frame->executeScript(WebScriptSource("selectCaret();")); |
2812 m_webView->selectionBounds(initialStartRect, initialEndRect); | 2834 m_webView->selectionBounds(initialStartRect, initialEndRect); |
2813 WebPoint moveTo(topLeft(initialStartRect)); | 2835 WebPoint moveTo(topLeft(initialStartRect)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2853 | 2875 |
2854 TEST_F(WebFrameTest, DisambiguationPopup) | 2876 TEST_F(WebFrameTest, DisambiguationPopup) |
2855 { | 2877 { |
2856 const std::string htmlFile = "disambiguation_popup.html"; | 2878 const std::string htmlFile = "disambiguation_popup.html"; |
2857 registerMockedHttpURLLoad(htmlFile); | 2879 registerMockedHttpURLLoad(htmlFile); |
2858 | 2880 |
2859 DisambiguationPopupTestWebViewClient client; | 2881 DisambiguationPopupTestWebViewClient client; |
2860 | 2882 |
2861 // Make sure we initialize to minimum scale, even if the window size | 2883 // Make sure we initialize to minimum scale, even if the window size |
2862 // only becomes available after the load begins. | 2884 // only becomes available after the load begins. |
2863 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, tru
e, 0, &client); | 2885 initializeWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); |
2864 m_webView->resize(WebSize(1000, 1000)); | 2886 m_webView->resize(WebSize(1000, 1000)); |
2865 m_webView->layout(); | 2887 m_webView->layout(); |
2866 | 2888 |
2867 client.resetTriggered(); | 2889 client.resetTriggered(); |
2868 m_webView->handleInputEvent(fatTap(0, 0)); | 2890 m_webView->handleInputEvent(fatTap(0, 0)); |
2869 EXPECT_FALSE(client.triggered()); | 2891 EXPECT_FALSE(client.triggered()); |
2870 | 2892 |
2871 client.resetTriggered(); | 2893 client.resetTriggered(); |
2872 m_webView->handleInputEvent(fatTap(200, 115)); | 2894 m_webView->handleInputEvent(fatTap(200, 115)); |
2873 EXPECT_FALSE(client.triggered()); | 2895 EXPECT_FALSE(client.triggered()); |
(...skipping 26 matching lines...) Expand all Loading... |
2900 } | 2922 } |
2901 | 2923 |
2902 TEST_F(WebFrameTest, DisambiguationPopupNoContainer) | 2924 TEST_F(WebFrameTest, DisambiguationPopupNoContainer) |
2903 { | 2925 { |
2904 registerMockedHttpURLLoad("disambiguation_popup_no_container.html"); | 2926 registerMockedHttpURLLoad("disambiguation_popup_no_container.html"); |
2905 | 2927 |
2906 DisambiguationPopupTestWebViewClient client; | 2928 DisambiguationPopupTestWebViewClient client; |
2907 | 2929 |
2908 // Make sure we initialize to minimum scale, even if the window size | 2930 // Make sure we initialize to minimum scale, even if the window size |
2909 // only becomes available after the load begins. | 2931 // only becomes available after the load begins. |
2910 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "disambiguati
on_popup_no_container.html", true, 0, &client); | 2932 initializeWebViewAndLoad(m_baseURL + "disambiguation_popup_no_container.html
", true, 0, &client); |
2911 m_webView->resize(WebSize(1000, 1000)); | 2933 m_webView->resize(WebSize(1000, 1000)); |
2912 m_webView->layout(); | 2934 m_webView->layout(); |
2913 | 2935 |
2914 client.resetTriggered(); | 2936 client.resetTriggered(); |
2915 m_webView->handleInputEvent(fatTap(50, 50)); | 2937 m_webView->handleInputEvent(fatTap(50, 50)); |
2916 EXPECT_FALSE(client.triggered()); | 2938 EXPECT_FALSE(client.triggered()); |
2917 | 2939 |
2918 m_webView->close(); | 2940 m_webView->close(); |
2919 m_webView = 0; | 2941 m_webView = 0; |
2920 } | 2942 } |
2921 | 2943 |
2922 TEST_F(WebFrameTest, DisambiguationPopupMobileSite) | 2944 TEST_F(WebFrameTest, DisambiguationPopupMobileSite) |
2923 { | 2945 { |
2924 const std::string htmlFile = "disambiguation_popup_mobile_site.html"; | 2946 const std::string htmlFile = "disambiguation_popup_mobile_site.html"; |
2925 registerMockedHttpURLLoad(htmlFile); | 2947 registerMockedHttpURLLoad(htmlFile); |
2926 | 2948 |
2927 DisambiguationPopupTestWebViewClient client; | 2949 DisambiguationPopupTestWebViewClient client; |
2928 | 2950 |
2929 // Make sure we initialize to minimum scale, even if the window size | 2951 // Make sure we initialize to minimum scale, even if the window size |
2930 // only becomes available after the load begins. | 2952 // only becomes available after the load begins. |
2931 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, tru
e, 0, &client); | 2953 initializeWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); |
2932 m_webView->enableFixedLayoutMode(true); | 2954 m_webView->enableFixedLayoutMode(true); |
2933 m_webView->settings()->setViewportEnabled(true); | 2955 m_webView->settings()->setViewportEnabled(true); |
2934 m_webView->resize(WebSize(1000, 1000)); | 2956 m_webView->resize(WebSize(1000, 1000)); |
2935 m_webView->layout(); | 2957 m_webView->layout(); |
2936 | 2958 |
2937 client.resetTriggered(); | 2959 client.resetTriggered(); |
2938 m_webView->handleInputEvent(fatTap(0, 0)); | 2960 m_webView->handleInputEvent(fatTap(0, 0)); |
2939 EXPECT_FALSE(client.triggered()); | 2961 EXPECT_FALSE(client.triggered()); |
2940 | 2962 |
2941 client.resetTriggered(); | 2963 client.resetTriggered(); |
(...skipping 18 matching lines...) Expand all Loading... |
2960 | 2982 |
2961 TEST_F(WebFrameTest, DisambiguationPopupViewportSite) | 2983 TEST_F(WebFrameTest, DisambiguationPopupViewportSite) |
2962 { | 2984 { |
2963 const std::string htmlFile = "disambiguation_popup_viewport_site.html"; | 2985 const std::string htmlFile = "disambiguation_popup_viewport_site.html"; |
2964 registerMockedHttpURLLoad(htmlFile); | 2986 registerMockedHttpURLLoad(htmlFile); |
2965 | 2987 |
2966 DisambiguationPopupTestWebViewClient client; | 2988 DisambiguationPopupTestWebViewClient client; |
2967 | 2989 |
2968 // Make sure we initialize to minimum scale, even if the window size | 2990 // Make sure we initialize to minimum scale, even if the window size |
2969 // only becomes available after the load begins. | 2991 // only becomes available after the load begins. |
2970 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, tru
e, 0, &client); | 2992 initializeWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); |
2971 m_webView->enableFixedLayoutMode(true); | 2993 m_webView->enableFixedLayoutMode(true); |
2972 m_webView->settings()->setViewportEnabled(true); | 2994 m_webView->settings()->setViewportEnabled(true); |
2973 m_webView->resize(WebSize(1000, 1000)); | 2995 m_webView->resize(WebSize(1000, 1000)); |
2974 m_webView->layout(); | 2996 m_webView->layout(); |
2975 | 2997 |
2976 client.resetTriggered(); | 2998 client.resetTriggered(); |
2977 m_webView->handleInputEvent(fatTap(0, 0)); | 2999 m_webView->handleInputEvent(fatTap(0, 0)); |
2978 EXPECT_FALSE(client.triggered()); | 3000 EXPECT_FALSE(client.triggered()); |
2979 | 3001 |
2980 client.resetTriggered(); | 3002 client.resetTriggered(); |
(...skipping 21 matching lines...) Expand all Loading... |
3002 const unsigned viewportWidth = 500; | 3024 const unsigned viewportWidth = 500; |
3003 const unsigned viewportHeight = 1000; | 3025 const unsigned viewportHeight = 1000; |
3004 const unsigned divHeight = 100; | 3026 const unsigned divHeight = 100; |
3005 const std::string htmlFile = "disambiguation_popup_blacklist.html"; | 3027 const std::string htmlFile = "disambiguation_popup_blacklist.html"; |
3006 registerMockedHttpURLLoad(htmlFile); | 3028 registerMockedHttpURLLoad(htmlFile); |
3007 | 3029 |
3008 DisambiguationPopupTestWebViewClient client; | 3030 DisambiguationPopupTestWebViewClient client; |
3009 | 3031 |
3010 // Make sure we initialize to minimum scale, even if the window size | 3032 // Make sure we initialize to minimum scale, even if the window size |
3011 // only becomes available after the load begins. | 3033 // only becomes available after the load begins. |
3012 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile, tru
e, 0, &client); | 3034 initializeWebViewAndLoad(m_baseURL + htmlFile, true, 0, &client); |
3013 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 3035 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
3014 m_webView->layout(); | 3036 m_webView->layout(); |
3015 | 3037 |
3016 // Click somewhere where the popup shouldn't appear. | 3038 // Click somewhere where the popup shouldn't appear. |
3017 client.resetTriggered(); | 3039 client.resetTriggered(); |
3018 m_webView->handleInputEvent(fatTap(viewportWidth / 2, 0)); | 3040 m_webView->handleInputEvent(fatTap(viewportWidth / 2, 0)); |
3019 EXPECT_FALSE(client.triggered()); | 3041 EXPECT_FALSE(client.triggered()); |
3020 | 3042 |
3021 // Click directly in between two container divs with click handlers, with ch
ildren that don't handle clicks. | 3043 // Click directly in between two container divs with click handlers, with ch
ildren that don't handle clicks. |
3022 client.resetTriggered(); | 3044 client.resetTriggered(); |
(...skipping 10 matching lines...) Expand all Loading... |
3033 } | 3055 } |
3034 | 3056 |
3035 TEST_F(WebFrameTest, DisambiguationPopupPageScale) | 3057 TEST_F(WebFrameTest, DisambiguationPopupPageScale) |
3036 { | 3058 { |
3037 registerMockedHttpURLLoad("disambiguation_popup_page_scale.html"); | 3059 registerMockedHttpURLLoad("disambiguation_popup_page_scale.html"); |
3038 | 3060 |
3039 DisambiguationPopupTestWebViewClient client; | 3061 DisambiguationPopupTestWebViewClient client; |
3040 | 3062 |
3041 // Make sure we initialize to minimum scale, even if the window size | 3063 // Make sure we initialize to minimum scale, even if the window size |
3042 // only becomes available after the load begins. | 3064 // only becomes available after the load begins. |
3043 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "disambiguati
on_popup_page_scale.html", true, 0, &client); | 3065 initializeWebViewAndLoad(m_baseURL + "disambiguation_popup_page_scale.html",
true, 0, &client); |
3044 m_webView->resize(WebSize(1000, 1000)); | 3066 m_webView->resize(WebSize(1000, 1000)); |
3045 m_webView->layout(); | 3067 m_webView->layout(); |
3046 | 3068 |
3047 client.resetTriggered(); | 3069 client.resetTriggered(); |
3048 m_webView->handleInputEvent(fatTap(80, 80)); | 3070 m_webView->handleInputEvent(fatTap(80, 80)); |
3049 EXPECT_TRUE(client.triggered()); | 3071 EXPECT_TRUE(client.triggered()); |
3050 | 3072 |
3051 client.resetTriggered(); | 3073 client.resetTriggered(); |
3052 m_webView->handleInputEvent(fatTap(230, 190)); | 3074 m_webView->handleInputEvent(fatTap(230, 190)); |
3053 EXPECT_TRUE(client.triggered()); | 3075 EXPECT_TRUE(client.triggered()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3089 bool commitCalled() const { return m_commitCalled; } | 3111 bool commitCalled() const { return m_commitCalled; } |
3090 | 3112 |
3091 private: | 3113 private: |
3092 bool m_commitCalled; | 3114 bool m_commitCalled; |
3093 }; | 3115 }; |
3094 | 3116 |
3095 TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) | 3117 TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) |
3096 { | 3118 { |
3097 TestSubstituteDataWebFrameClient webFrameClient; | 3119 TestSubstituteDataWebFrameClient webFrameClient; |
3098 | 3120 |
3099 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true, &web
FrameClient); | 3121 initializeWebViewAndLoad("about:blank", true, &webFrameClient); |
3100 runPendingTasks(); | 3122 runPendingTasks(); |
3101 WebFrame* frame = m_webView->mainFrame(); | 3123 WebFrame* frame = m_webView->mainFrame(); |
3102 | 3124 |
3103 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient | 3125 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient |
3104 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. | 3126 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. |
3105 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting | 3127 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting |
3106 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. | 3128 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. |
3107 WebURLError error; | 3129 WebURLError error; |
3108 error.reason = 1337; | 3130 error.reason = 1337; |
3109 error.domain = "WebFrameTest"; | 3131 error.domain = "WebFrameTest"; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 | 3175 |
3154 int m_numBodies; | 3176 int m_numBodies; |
3155 bool m_didLoad; | 3177 bool m_didLoad; |
3156 }; | 3178 }; |
3157 | 3179 |
3158 TEST_F(WebFrameTest, HTMLDocument) | 3180 TEST_F(WebFrameTest, HTMLDocument) |
3159 { | 3181 { |
3160 registerMockedHttpURLLoad("clipped-body.html"); | 3182 registerMockedHttpURLLoad("clipped-body.html"); |
3161 | 3183 |
3162 TestWillInsertBodyWebFrameClient webFrameClient; | 3184 TestWillInsertBodyWebFrameClient webFrameClient; |
3163 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "clipped-body
.html", false, &webFrameClient); | 3185 initializeWebViewAndLoad(m_baseURL + "clipped-body.html", false, &webFrameCl
ient); |
3164 | 3186 |
3165 EXPECT_TRUE(webFrameClient.m_didLoad); | 3187 EXPECT_TRUE(webFrameClient.m_didLoad); |
3166 EXPECT_EQ(1, webFrameClient.m_numBodies); | 3188 EXPECT_EQ(1, webFrameClient.m_numBodies); |
3167 | 3189 |
3168 m_webView->close(); | 3190 m_webView->close(); |
3169 m_webView = 0; | 3191 m_webView = 0; |
3170 } | 3192 } |
3171 | 3193 |
3172 TEST_F(WebFrameTest, EmptyDocument) | 3194 TEST_F(WebFrameTest, EmptyDocument) |
3173 { | 3195 { |
3174 registerMockedHttpURLLoad("pageserializer/green_rectangle.svg"); | 3196 registerMockedHttpURLLoad("pageserializer/green_rectangle.svg"); |
3175 | 3197 |
3176 TestWillInsertBodyWebFrameClient webFrameClient; | 3198 TestWillInsertBodyWebFrameClient webFrameClient; |
3177 m_webView = FrameTestHelpers::createWebView(false, &webFrameClient); | 3199 initializeWebView(false, &webFrameClient); |
3178 | 3200 |
3179 EXPECT_FALSE(webFrameClient.m_didLoad); | 3201 EXPECT_FALSE(webFrameClient.m_didLoad); |
3180 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f
rame starts with triggers this. | 3202 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f
rame starts with triggers this. |
3181 m_webView->close(); | 3203 m_webView->close(); |
3182 m_webView = 0; | 3204 m_webView = 0; |
3183 } | 3205 } |
3184 | 3206 |
3185 TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) | 3207 TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) |
3186 { | 3208 { |
3187 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); | 3209 initializeWebViewAndLoad("about:blank", true); |
3188 WebFrame* frame = m_webView->mainFrame(); | 3210 WebFrame* frame = m_webView->mainFrame(); |
3189 | 3211 |
3190 // This test passes if this doesn't crash. | 3212 // This test passes if this doesn't crash. |
3191 frame->moveCaretSelectionTowardsWindowPoint(WebPoint(0, 0)); | 3213 frame->moveCaretSelectionTowardsWindowPoint(WebPoint(0, 0)); |
3192 } | 3214 } |
3193 | 3215 |
3194 class SpellCheckClient : public WebSpellCheckClient { | 3216 class SpellCheckClient : public WebSpellCheckClient { |
3195 public: | 3217 public: |
3196 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } | 3218 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } |
3197 virtual ~SpellCheckClient() { } | 3219 virtual ~SpellCheckClient() { } |
3198 virtual void requestCheckingOfText(const WebKit::WebString&, const WebKit::W
ebVector<uint32_t>&, const WebKit::WebVector<unsigned>&, WebKit::WebTextChecking
Completion* completion) OVERRIDE | 3220 virtual void requestCheckingOfText(const WebKit::WebString&, const WebKit::W
ebVector<uint32_t>&, const WebKit::WebVector<unsigned>&, WebKit::WebTextChecking
Completion* completion) OVERRIDE |
3199 { | 3221 { |
3200 ++m_numberOfTimesChecked; | 3222 ++m_numberOfTimesChecked; |
3201 Vector<WebTextCheckingResult> results; | 3223 Vector<WebTextCheckingResult> results; |
3202 const int misspellingStartOffset = 1; | 3224 const int misspellingStartOffset = 1; |
3203 const int misspellingLength = 8; | 3225 const int misspellingLength = 8; |
3204 results.append(WebTextCheckingResult(WebTextCheckingTypeSpelling, misspe
llingStartOffset, misspellingLength, WebString(), m_hash)); | 3226 results.append(WebTextCheckingResult(WebTextCheckingTypeSpelling, misspe
llingStartOffset, misspellingLength, WebString(), m_hash)); |
3205 completion->didFinishCheckingText(results); | 3227 completion->didFinishCheckingText(results); |
3206 } | 3228 } |
3207 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } | 3229 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } |
3208 private: | 3230 private: |
3209 int m_numberOfTimesChecked; | 3231 int m_numberOfTimesChecked; |
3210 uint32_t m_hash; | 3232 uint32_t m_hash; |
3211 }; | 3233 }; |
3212 | 3234 |
3213 TEST_F(WebFrameTest, ReplaceMisspelledRange) | 3235 TEST_F(WebFrameTest, ReplaceMisspelledRange) |
3214 { | 3236 { |
3215 registerMockedHttpURLLoad("spell.html"); | 3237 registerMockedHttpURLLoad("spell.html"); |
3216 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html")
; | 3238 initializeWebViewAndLoad(m_baseURL + "spell.html"); |
3217 SpellCheckClient spellcheck; | 3239 SpellCheckClient spellcheck; |
3218 m_webView->setSpellCheckClient(&spellcheck); | 3240 m_webView->setSpellCheckClient(&spellcheck); |
3219 | 3241 |
3220 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); | 3242 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); |
3221 Document* document = frame->frame()->document(); | 3243 Document* document = frame->frame()->document(); |
3222 Element* element = document->getElementById("data"); | 3244 Element* element = document->getElementById("data"); |
3223 | 3245 |
3224 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); | 3246 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); |
3225 m_webView->settings()->setUnifiedTextCheckerEnabled(true); | 3247 m_webView->settings()->setUnifiedTextCheckerEnabled(true); |
3226 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); | 3248 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); |
(...skipping 12 matching lines...) Expand all Loading... |
3239 frame->replaceMisspelledRange("welcome"); | 3261 frame->replaceMisspelledRange("welcome"); |
3240 EXPECT_EQ("_welcome_.", std::string(frame->contentAsText(std::numeric_limits
<size_t>::max()).utf8().data())); | 3262 EXPECT_EQ("_welcome_.", std::string(frame->contentAsText(std::numeric_limits
<size_t>::max()).utf8().data())); |
3241 | 3263 |
3242 m_webView->close(); | 3264 m_webView->close(); |
3243 m_webView = 0; | 3265 m_webView = 0; |
3244 } | 3266 } |
3245 | 3267 |
3246 TEST_F(WebFrameTest, RemoveSpellingMarkers) | 3268 TEST_F(WebFrameTest, RemoveSpellingMarkers) |
3247 { | 3269 { |
3248 registerMockedHttpURLLoad("spell.html"); | 3270 registerMockedHttpURLLoad("spell.html"); |
3249 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html")
; | 3271 initializeWebViewAndLoad(m_baseURL + "spell.html"); |
3250 SpellCheckClient spellcheck; | 3272 SpellCheckClient spellcheck; |
3251 m_webView->setSpellCheckClient(&spellcheck); | 3273 m_webView->setSpellCheckClient(&spellcheck); |
3252 | 3274 |
3253 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); | 3275 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); |
3254 Document* document = frame->frame()->document(); | 3276 Document* document = frame->frame()->document(); |
3255 Element* element = document->getElementById("data"); | 3277 Element* element = document->getElementById("data"); |
3256 | 3278 |
3257 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); | 3279 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); |
3258 m_webView->settings()->setUnifiedTextCheckerEnabled(true); | 3280 m_webView->settings()->setUnifiedTextCheckerEnabled(true); |
3259 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); | 3281 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); |
3260 | 3282 |
3261 element->focus(); | 3283 element->focus(); |
3262 document->execCommand("InsertText", false, "_wellcome_."); | 3284 document->execCommand("InsertText", false, "_wellcome_."); |
3263 | 3285 |
3264 frame->removeSpellingMarkers(); | 3286 frame->removeSpellingMarkers(); |
3265 | 3287 |
3266 const int allTextBeginOffset = 0; | 3288 const int allTextBeginOffset = 0; |
3267 const int allTextLength = 11; | 3289 const int allTextLength = 11; |
3268 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al
lTextLength)); | 3290 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al
lTextLength)); |
3269 RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange
(); | 3291 RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange
(); |
3270 | 3292 |
3271 EXPECT_EQ(0U, document->markers()->markersInRange(selectionRange.get(), Docu
mentMarker::Spelling).size()); | 3293 EXPECT_EQ(0U, document->markers()->markersInRange(selectionRange.get(), Docu
mentMarker::Spelling).size()); |
3272 | 3294 |
3273 m_webView->close(); | 3295 m_webView->close(); |
3274 m_webView = 0; | 3296 m_webView = 0; |
3275 } | 3297 } |
3276 | 3298 |
3277 TEST_F(WebFrameTest, MarkerHashIdentifiers) { | 3299 TEST_F(WebFrameTest, MarkerHashIdentifiers) { |
3278 registerMockedHttpURLLoad("spell.html"); | 3300 registerMockedHttpURLLoad("spell.html"); |
3279 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html")
; | 3301 initializeWebViewAndLoad(m_baseURL + "spell.html"); |
3280 | 3302 |
3281 static const uint32_t kHash = 42; | 3303 static const uint32_t kHash = 42; |
3282 SpellCheckClient spellcheck(kHash); | 3304 SpellCheckClient spellcheck(kHash); |
3283 m_webView->setSpellCheckClient(&spellcheck); | 3305 m_webView->setSpellCheckClient(&spellcheck); |
3284 | 3306 |
3285 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); | 3307 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); |
3286 Document* document = frame->frame()->document(); | 3308 Document* document = frame->frame()->document(); |
3287 Element* element = document->getElementById("data"); | 3309 Element* element = document->getElementById("data"); |
3288 | 3310 |
3289 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); | 3311 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3328 m_completion = 0; | 3350 m_completion = 0; |
3329 } | 3351 } |
3330 | 3352 |
3331 private: | 3353 private: |
3332 WebKit::WebTextCheckingCompletion* m_completion; | 3354 WebKit::WebTextCheckingCompletion* m_completion; |
3333 }; | 3355 }; |
3334 | 3356 |
3335 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) | 3357 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) |
3336 { | 3358 { |
3337 registerMockedHttpURLLoad("spell.html"); | 3359 registerMockedHttpURLLoad("spell.html"); |
3338 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html")
; | 3360 initializeWebViewAndLoad(m_baseURL + "spell.html"); |
3339 | 3361 |
3340 StubbornSpellCheckClient spellcheck; | 3362 StubbornSpellCheckClient spellcheck; |
3341 m_webView->setSpellCheckClient(&spellcheck); | 3363 m_webView->setSpellCheckClient(&spellcheck); |
3342 | 3364 |
3343 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); | 3365 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); |
3344 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); | 3366 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); |
3345 Document* document = frame->frame()->document(); | 3367 Document* document = frame->frame()->document(); |
3346 Element* element = document->getElementById("data"); | 3368 Element* element = document->getElementById("data"); |
3347 | 3369 |
3348 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); | 3370 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); |
(...skipping 13 matching lines...) Expand all Loading... |
3362 | 3384 |
3363 m_webView->close(); | 3385 m_webView->close(); |
3364 m_webView = 0; | 3386 m_webView = 0; |
3365 } | 3387 } |
3366 | 3388 |
3367 // This test verifies that cancelling spelling request does not cause a | 3389 // This test verifies that cancelling spelling request does not cause a |
3368 // write-after-free when there's no spellcheck client set. | 3390 // write-after-free when there's no spellcheck client set. |
3369 TEST_F(WebFrameTest, CancelSpellingRequestCrash) | 3391 TEST_F(WebFrameTest, CancelSpellingRequestCrash) |
3370 { | 3392 { |
3371 registerMockedHttpURLLoad("spell.html"); | 3393 registerMockedHttpURLLoad("spell.html"); |
3372 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html")
; | 3394 initializeWebViewAndLoad(m_baseURL + "spell.html"); |
3373 m_webView->setSpellCheckClient(0); | 3395 m_webView->setSpellCheckClient(0); |
3374 | 3396 |
3375 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); | 3397 WebFrameImpl* frame = toWebFrameImpl(m_webView->mainFrame()); |
3376 Document* document = frame->frame()->document(); | 3398 Document* document = frame->frame()->document(); |
3377 Element* element = document->getElementById("data"); | 3399 Element* element = document->getElementById("data"); |
3378 | 3400 |
3379 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); | 3401 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); |
3380 m_webView->settings()->setUnifiedTextCheckerEnabled(true); | 3402 m_webView->settings()->setUnifiedTextCheckerEnabled(true); |
3381 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); | 3403 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); |
3382 | 3404 |
(...skipping 16 matching lines...) Expand all Loading... |
3399 EXPECT_TRUE(!m_didAccessInitialDocument); | 3421 EXPECT_TRUE(!m_didAccessInitialDocument); |
3400 m_didAccessInitialDocument = true; | 3422 m_didAccessInitialDocument = true; |
3401 } | 3423 } |
3402 | 3424 |
3403 bool m_didAccessInitialDocument; | 3425 bool m_didAccessInitialDocument; |
3404 }; | 3426 }; |
3405 | 3427 |
3406 TEST_F(WebFrameTest, DidAccessInitialDocumentBody) | 3428 TEST_F(WebFrameTest, DidAccessInitialDocumentBody) |
3407 { | 3429 { |
3408 TestAccessInitialDocumentWebFrameClient webFrameClient; | 3430 TestAccessInitialDocumentWebFrameClient webFrameClient; |
3409 m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); | 3431 initializeWebView(true, &webFrameClient); |
3410 runPendingTasks(); | 3432 runPendingTasks(); |
3411 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3433 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3412 | 3434 |
3413 // Create another window that will try to access it. | 3435 // Create another window that will try to access it. |
3414 WebView* newView = FrameTestHelpers::createWebView(true); | 3436 WebView* newView = FrameTestHelpers::createWebView(true); |
3415 newView->mainFrame()->setOpener(m_webView->mainFrame()); | 3437 newView->mainFrame()->setOpener(m_webView->mainFrame()); |
3416 runPendingTasks(); | 3438 runPendingTasks(); |
3417 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3439 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3418 | 3440 |
3419 // Access the initial document by modifying the body. | 3441 // Access the initial document by modifying the body. |
3420 newView->mainFrame()->executeScript( | 3442 newView->mainFrame()->executeScript( |
3421 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 3443 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
3422 runPendingTasks(); | 3444 runPendingTasks(); |
3423 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 3445 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
3424 | 3446 |
3425 // Access the initial document again, to ensure we don't notify twice. | 3447 // Access the initial document again, to ensure we don't notify twice. |
3426 newView->mainFrame()->executeScript( | 3448 newView->mainFrame()->executeScript( |
3427 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 3449 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
3428 runPendingTasks(); | 3450 runPendingTasks(); |
3429 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 3451 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
3430 | 3452 |
3431 newView->close(); | 3453 newView->close(); |
3432 m_webView->close(); | 3454 m_webView->close(); |
3433 m_webView = 0; | 3455 m_webView = 0; |
3434 } | 3456 } |
3435 | 3457 |
3436 TEST_F(WebFrameTest, DidAccessInitialDocumentNavigator) | 3458 TEST_F(WebFrameTest, DidAccessInitialDocumentNavigator) |
3437 { | 3459 { |
3438 TestAccessInitialDocumentWebFrameClient webFrameClient; | 3460 TestAccessInitialDocumentWebFrameClient webFrameClient; |
3439 m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); | 3461 initializeWebView(true, &webFrameClient); |
3440 runPendingTasks(); | 3462 runPendingTasks(); |
3441 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3463 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3442 | 3464 |
3443 // Create another window that will try to access it. | 3465 // Create another window that will try to access it. |
3444 WebView* newView = FrameTestHelpers::createWebView(true); | 3466 WebView* newView = FrameTestHelpers::createWebView(true); |
3445 newView->mainFrame()->setOpener(m_webView->mainFrame()); | 3467 newView->mainFrame()->setOpener(m_webView->mainFrame()); |
3446 runPendingTasks(); | 3468 runPendingTasks(); |
3447 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3469 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3448 | 3470 |
3449 // Access the initial document to get to the navigator object. | 3471 // Access the initial document to get to the navigator object. |
3450 newView->mainFrame()->executeScript( | 3472 newView->mainFrame()->executeScript( |
3451 WebScriptSource("console.log(window.opener.navigator);")); | 3473 WebScriptSource("console.log(window.opener.navigator);")); |
3452 runPendingTasks(); | 3474 runPendingTasks(); |
3453 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 3475 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
3454 | 3476 |
3455 newView->close(); | 3477 newView->close(); |
3456 m_webView->close(); | 3478 m_webView->close(); |
3457 m_webView = 0; | 3479 m_webView = 0; |
3458 } | 3480 } |
3459 | 3481 |
3460 TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) | 3482 TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) |
3461 { | 3483 { |
3462 TestAccessInitialDocumentWebFrameClient webFrameClient; | 3484 TestAccessInitialDocumentWebFrameClient webFrameClient; |
3463 m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); | 3485 initializeWebView(true, &webFrameClient); |
3464 runPendingTasks(); | 3486 runPendingTasks(); |
3465 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3487 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3466 | 3488 |
3467 // Access the initial document from a javascript: URL. | 3489 // Access the initial document from a javascript: URL. |
3468 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Modified'))"); | 3490 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Modified'))"); |
3469 runPendingTasks(); | 3491 runPendingTasks(); |
3470 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 3492 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
3471 | 3493 |
3472 m_webView->close(); | 3494 m_webView->close(); |
3473 m_webView = 0; | 3495 m_webView = 0; |
3474 } | 3496 } |
3475 | 3497 |
3476 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) | 3498 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) |
3477 { | 3499 { |
3478 TestAccessInitialDocumentWebFrameClient webFrameClient; | 3500 TestAccessInitialDocumentWebFrameClient webFrameClient; |
3479 m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); | 3501 initializeWebView(true, &webFrameClient); |
3480 runPendingTasks(); | 3502 runPendingTasks(); |
3481 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3503 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3482 | 3504 |
3483 // Create another window that will try to access it. | 3505 // Create another window that will try to access it. |
3484 WebView* newView = FrameTestHelpers::createWebView(true); | 3506 WebView* newView = FrameTestHelpers::createWebView(true); |
3485 newView->mainFrame()->setOpener(m_webView->mainFrame()); | 3507 newView->mainFrame()->setOpener(m_webView->mainFrame()); |
3486 runPendingTasks(); | 3508 runPendingTasks(); |
3487 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 3509 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
3488 | 3510 |
3489 // Access the initial document by modifying the body. We normally set a | 3511 // Access the initial document by modifying the body. We normally set a |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3537 bool m_wasProgrammaticScroll; | 3559 bool m_wasProgrammaticScroll; |
3538 }; | 3560 }; |
3539 | 3561 |
3540 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) | 3562 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) |
3541 { | 3563 { |
3542 registerMockedHttpURLLoad("long_scroll.html"); | 3564 registerMockedHttpURLLoad("long_scroll.html"); |
3543 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 3565 TestMainFrameUserOrProgrammaticScrollFrameClient client; |
3544 | 3566 |
3545 // Make sure we initialize to minimum scale, even if the window size | 3567 // Make sure we initialize to minimum scale, even if the window size |
3546 // only becomes available after the load begins. | 3568 // only becomes available after the load begins. |
3547 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "long_scroll.
html", true, &client); | 3569 initializeWebViewAndLoad(m_baseURL + "long_scroll.html", true, &client); |
3548 m_webView->resize(WebSize(1000, 1000)); | 3570 m_webView->resize(WebSize(1000, 1000)); |
3549 m_webView->layout(); | 3571 m_webView->layout(); |
3550 | 3572 |
3551 EXPECT_FALSE(client.wasUserScroll()); | 3573 EXPECT_FALSE(client.wasUserScroll()); |
3552 EXPECT_FALSE(client.wasProgrammaticScroll()); | 3574 EXPECT_FALSE(client.wasProgrammaticScroll()); |
3553 | 3575 |
3554 // Do a compositor scroll, verify that this is counted as a user scroll. | 3576 // Do a compositor scroll, verify that this is counted as a user scroll. |
3555 webViewImpl()->applyScrollAndScale(WebSize(0, 1), 1.1f); | 3577 webViewImpl()->applyScrollAndScale(WebSize(0, 1), 1.1f); |
3556 EXPECT_TRUE(client.wasUserScroll()); | 3578 EXPECT_TRUE(client.wasUserScroll()); |
3557 client.reset(); | 3579 client.reset(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3592 m_webView = 0; | 3614 m_webView = 0; |
3593 } | 3615 } |
3594 | 3616 |
3595 TEST_F(WebFrameTest, CompositorScrollIsUserScrollShortPage) | 3617 TEST_F(WebFrameTest, CompositorScrollIsUserScrollShortPage) |
3596 { | 3618 { |
3597 registerMockedHttpURLLoad("short_scroll.html"); | 3619 registerMockedHttpURLLoad("short_scroll.html"); |
3598 | 3620 |
3599 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 3621 TestMainFrameUserOrProgrammaticScrollFrameClient client; |
3600 | 3622 |
3601 // Short page tests. | 3623 // Short page tests. |
3602 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "short_scroll
.html", true, &client); | 3624 initializeWebViewAndLoad(m_baseURL + "short_scroll.html", true, &client); |
3603 | 3625 |
3604 m_webView->resize(WebSize(1000, 1000)); | 3626 m_webView->resize(WebSize(1000, 1000)); |
3605 m_webView->layout(); | 3627 m_webView->layout(); |
3606 | 3628 |
3607 EXPECT_FALSE(client.wasUserScroll()); | 3629 EXPECT_FALSE(client.wasUserScroll()); |
3608 EXPECT_FALSE(client.wasProgrammaticScroll()); | 3630 EXPECT_FALSE(client.wasProgrammaticScroll()); |
3609 | 3631 |
3610 // Non zero page scale and scroll. | 3632 // Non zero page scale and scroll. |
3611 webViewImpl()->applyScrollAndScale(WebSize(9, 13), 2.0f); | 3633 webViewImpl()->applyScrollAndScale(WebSize(9, 13), 2.0f); |
3612 EXPECT_FALSE(client.wasProgrammaticScroll()); | 3634 EXPECT_FALSE(client.wasProgrammaticScroll()); |
(...skipping 17 matching lines...) Expand all Loading... |
3630 redirectResponse.setMIMEType("text/html"); | 3652 redirectResponse.setMIMEType("text/html"); |
3631 redirectResponse.setHTTPStatusCode(302); | 3653 redirectResponse.setHTTPStatusCode(302); |
3632 redirectResponse.setHTTPHeaderField("Location", redirect); | 3654 redirectResponse.setHTTPHeaderField("Location", redirect); |
3633 Platform::current()->unitTestSupport()->registerMockedURL(testURL, redirectR
esponse, filePath); | 3655 Platform::current()->unitTestSupport()->registerMockedURL(testURL, redirectR
esponse, filePath); |
3634 | 3656 |
3635 WebURLResponse finalResponse; | 3657 WebURLResponse finalResponse; |
3636 finalResponse.initialize(); | 3658 finalResponse.initialize(); |
3637 finalResponse.setMIMEType("text/html"); | 3659 finalResponse.setMIMEType("text/html"); |
3638 Platform::current()->unitTestSupport()->registerMockedURL(redirectURL, final
Response, filePath); | 3660 Platform::current()->unitTestSupport()->registerMockedURL(redirectURL, final
Response, filePath); |
3639 | 3661 |
3640 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "first_party_
redirect.html", true); | 3662 initializeWebViewAndLoad(m_baseURL + "first_party_redirect.html", true); |
3641 EXPECT_TRUE(m_webView->mainFrame()->document().firstPartyForCookies() == red
irectURL); | 3663 EXPECT_TRUE(m_webView->mainFrame()->document().firstPartyForCookies() == red
irectURL); |
3642 | 3664 |
3643 m_webView->close(); | 3665 m_webView->close(); |
3644 m_webView = 0; | 3666 m_webView = 0; |
3645 } | 3667 } |
3646 | 3668 |
3647 class TestNavigationPolicyWebFrameClient : public WebFrameClient { | 3669 class TestNavigationPolicyWebFrameClient : public WebFrameClient { |
3648 public: | 3670 public: |
3649 | 3671 |
3650 virtual void didNavigateWithinPage(WebFrame*, bool) | 3672 virtual void didNavigateWithinPage(WebFrame*, bool) |
3651 { | 3673 { |
3652 EXPECT_TRUE(false); | 3674 EXPECT_TRUE(false); |
3653 } | 3675 } |
3654 }; | 3676 }; |
3655 | 3677 |
3656 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) | 3678 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) |
3657 { | 3679 { |
3658 registerMockedHttpURLLoad("fragment_middle_click.html"); | 3680 registerMockedHttpURLLoad("fragment_middle_click.html"); |
3659 TestNavigationPolicyWebFrameClient client; | 3681 TestNavigationPolicyWebFrameClient client; |
3660 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fragment_mid
dle_click.html", true, &client); | 3682 initializeWebViewAndLoad(m_baseURL + "fragment_middle_click.html", true, &cl
ient); |
3661 | 3683 |
3662 WebCore::Document* document = webViewImpl()->page()->mainFrame()->document()
; | 3684 WebCore::Document* document = webViewImpl()->page()->mainFrame()->document()
; |
3663 WebCore::KURL destination = document->url(); | 3685 WebCore::KURL destination = document->url(); |
3664 destination.setFragmentIdentifier("test"); | 3686 destination.setFragmentIdentifier("test"); |
3665 | 3687 |
3666 RefPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCore::eventNam
es().clickEvent, false, false, | 3688 RefPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCore::eventNam
es().clickEvent, false, false, |
3667 document->defaultView(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false
, 1, 0, 0); | 3689 document->defaultView(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false
, 1, 0, 0); |
3668 WebCore::FrameLoadRequest frameRequest(document->securityOrigin(), WebCore::
ResourceRequest(destination)); | 3690 WebCore::FrameLoadRequest frameRequest(document->securityOrigin(), WebCore::
ResourceRequest(destination)); |
3669 frameRequest.setTriggeringEvent(event); | 3691 frameRequest.setTriggeringEvent(event); |
3670 webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); | 3692 webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); |
3671 | 3693 |
3672 m_webView->close(); | 3694 m_webView->close(); |
3673 m_webView = 0; | 3695 m_webView = 0; |
3674 } | 3696 } |
3675 | 3697 |
3676 TEST_F(WebFrameTest, BackToReload) | 3698 TEST_F(WebFrameTest, BackToReload) |
3677 { | 3699 { |
3678 registerMockedHttpURLLoad("fragment_middle_click.html"); | 3700 registerMockedHttpURLLoad("fragment_middle_click.html"); |
3679 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fragment_mid
dle_click.html", true); | 3701 initializeWebViewAndLoad(m_baseURL + "fragment_middle_click.html", true); |
3680 WebFrame* frame = m_webView->mainFrame(); | 3702 WebFrame* frame = m_webView->mainFrame(); |
3681 WebHistoryItem firstItem = frame->currentHistoryItem(); | 3703 WebHistoryItem firstItem = frame->currentHistoryItem(); |
3682 EXPECT_FALSE(firstItem.isNull()); | 3704 EXPECT_FALSE(firstItem.isNull()); |
3683 | 3705 |
3684 registerMockedHttpURLLoad("white-1x1.png"); | 3706 registerMockedHttpURLLoad("white-1x1.png"); |
3685 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 3707 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
3686 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 3708 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
3687 EXPECT_FALSE(frame->previousHistoryItem().isNull()); | 3709 EXPECT_FALSE(frame->previousHistoryItem().isNull()); |
3688 EXPECT_EQ(firstItem.urlString(), frame->previousHistoryItem().urlString()); | 3710 EXPECT_EQ(firstItem.urlString(), frame->previousHistoryItem().urlString()); |
3689 | 3711 |
(...skipping 25 matching lines...) Expand all Loading... |
3715 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } | 3737 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } |
3716 | 3738 |
3717 private: | 3739 private: |
3718 bool m_frameLoadTypeSameSeen; | 3740 bool m_frameLoadTypeSameSeen; |
3719 }; | 3741 }; |
3720 | 3742 |
3721 TEST_F(WebFrameTest, NavigateToSame) | 3743 TEST_F(WebFrameTest, NavigateToSame) |
3722 { | 3744 { |
3723 registerMockedHttpURLLoad("navigate_to_same.html"); | 3745 registerMockedHttpURLLoad("navigate_to_same.html"); |
3724 TestSameDocumentWebFrameClient client; | 3746 TestSameDocumentWebFrameClient client; |
3725 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "navigate_to_
same.html", true, &client); | 3747 initializeWebViewAndLoad(m_baseURL + "navigate_to_same.html", true, &client)
; |
3726 EXPECT_FALSE(client.frameLoadTypeSameSeen()); | 3748 EXPECT_FALSE(client.frameLoadTypeSameSeen()); |
3727 | 3749 |
3728 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewIm
pl()->page()->mainFrame()->document()->url())); | 3750 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewIm
pl()->page()->mainFrame()->document()->url())); |
3729 webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); | 3751 webViewImpl()->page()->mainFrame()->loader()->load(frameRequest); |
3730 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 3752 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
3731 | 3753 |
3732 EXPECT_TRUE(client.frameLoadTypeSameSeen()); | 3754 EXPECT_TRUE(client.frameLoadTypeSameSeen()); |
3733 m_webView->close(); | 3755 m_webView->close(); |
3734 m_webView = 0; | 3756 m_webView = 0; |
3735 } | 3757 } |
3736 | 3758 |
3737 TEST_F(WebFrameTest, WebNodeImageContents) | 3759 TEST_F(WebFrameTest, WebNodeImageContents) |
3738 { | 3760 { |
3739 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); | 3761 initializeWebViewAndLoad("about:blank", true); |
3740 WebFrame* frame = m_webView->mainFrame(); | 3762 WebFrame* frame = m_webView->mainFrame(); |
3741 | 3763 |
3742 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; | 3764 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
3743 | 3765 |
3744 // Load up the image and test that we can extract the contents. | 3766 // Load up the image and test that we can extract the contents. |
3745 WebCore::KURL testURL = toKURL("about:blank"); | 3767 WebCore::KURL testURL = toKURL("about:blank"); |
3746 frame->loadHTMLString(bluePNG, testURL); | 3768 frame->loadHTMLString(bluePNG, testURL); |
3747 runPendingTasks(); | 3769 runPendingTasks(); |
3748 | 3770 |
3749 WebNode node = frame->document().body().firstChild(); | 3771 WebNode node = frame->document().body().firstChild(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3783 | 3805 |
3784 private: | 3806 private: |
3785 int m_startLoadingCount; | 3807 int m_startLoadingCount; |
3786 int m_stopLoadingCount; | 3808 int m_stopLoadingCount; |
3787 }; | 3809 }; |
3788 | 3810 |
3789 TEST_F(WebFrameTest, PushStateStartsAndStops) | 3811 TEST_F(WebFrameTest, PushStateStartsAndStops) |
3790 { | 3812 { |
3791 registerMockedHttpURLLoad("push_state.html"); | 3813 registerMockedHttpURLLoad("push_state.html"); |
3792 TestStartStopCallbackWebViewClient client; | 3814 TestStartStopCallbackWebViewClient client; |
3793 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); | 3815 initializeWebViewAndLoad(m_baseURL + "push_state.html", true, 0, &client); |
3794 runPendingTasks(); | 3816 runPendingTasks(); |
3795 | 3817 |
3796 EXPECT_EQ(client.startLoadingCount(), 2); | 3818 EXPECT_EQ(client.startLoadingCount(), 2); |
3797 EXPECT_EQ(client.stopLoadingCount(), 2); | 3819 EXPECT_EQ(client.stopLoadingCount(), 2); |
3798 m_webView->close(); | 3820 m_webView->close(); |
3799 m_webView = 0; | 3821 m_webView = 0; |
3800 } | 3822 } |
3801 | 3823 |
3802 } // namespace | 3824 } // namespace |
OLD | NEW |