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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 #include "core/testing/NullExecutionContext.h" | 78 #include "core/testing/NullExecutionContext.h" |
79 #include "modules/mediastream/MediaStream.h" | 79 #include "modules/mediastream/MediaStream.h" |
80 #include "modules/mediastream/MediaStreamRegistry.h" | 80 #include "modules/mediastream/MediaStreamRegistry.h" |
81 #include "platform/DragImage.h" | 81 #include "platform/DragImage.h" |
82 #include "platform/PlatformResourceLoader.h" | 82 #include "platform/PlatformResourceLoader.h" |
83 #include "platform/RuntimeEnabledFeatures.h" | 83 #include "platform/RuntimeEnabledFeatures.h" |
84 #include "platform/UserGestureIndicator.h" | 84 #include "platform/UserGestureIndicator.h" |
85 #include "platform/geometry/FloatRect.h" | 85 #include "platform/geometry/FloatRect.h" |
86 #include "platform/network/ResourceError.h" | 86 #include "platform/network/ResourceError.h" |
87 #include "platform/scroll/ScrollbarTheme.h" | 87 #include "platform/scroll/ScrollbarTheme.h" |
| 88 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
88 #include "platform/testing/URLTestHelpers.h" | 89 #include "platform/testing/URLTestHelpers.h" |
89 #include "platform/testing/UnitTestHelpers.h" | 90 #include "platform/testing/UnitTestHelpers.h" |
90 #include "platform/weborigin/KURLHash.h" | 91 #include "platform/weborigin/KURLHash.h" |
91 #include "platform/weborigin/SchemeRegistry.h" | 92 #include "platform/weborigin/SchemeRegistry.h" |
92 #include "platform/weborigin/SecurityOrigin.h" | 93 #include "platform/weborigin/SecurityOrigin.h" |
93 #include "public/platform/Platform.h" | 94 #include "public/platform/Platform.h" |
94 #include "public/platform/WebCachePolicy.h" | 95 #include "public/platform/WebCachePolicy.h" |
95 #include "public/platform/WebClipboard.h" | 96 #include "public/platform/WebClipboard.h" |
96 #include "public/platform/WebFloatRect.h" | 97 #include "public/platform/WebFloatRect.h" |
97 #include "public/platform/WebMockClipboard.h" | 98 #include "public/platform/WebMockClipboard.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 Element* element = frame->frame()->document()->getElementById(id); | 276 Element* element = frame->frame()->document()->getElementById(id); |
276 DCHECK(element); | 277 DCHECK(element); |
277 element->remove(); | 278 element->remove(); |
278 } | 279 } |
279 | 280 |
280 std::string m_baseURL; | 281 std::string m_baseURL; |
281 std::string m_notBaseURL; | 282 std::string m_notBaseURL; |
282 std::string m_chromeURL; | 283 std::string m_chromeURL; |
283 }; | 284 }; |
284 | 285 |
| 286 typedef bool TestParamRootLayerScrolling; |
285 class ParameterizedWebFrameTest | 287 class ParameterizedWebFrameTest |
286 : public WebFrameTest | 288 : public ::testing::WithParamInterface<TestParamRootLayerScrolling> |
287 , public ::testing::WithParamInterface<FrameTestHelpers::SettingOverrideFunc
tion> | 289 , private ScopedRootLayerScrollingForTest |
288 , public FrameTestHelpers::SettingOverrider { | 290 , public WebFrameTest { |
289 public: | 291 public: |
290 | 292 ParameterizedWebFrameTest() |
291 void overrideSettings(WebSettings *settings) override | 293 : ScopedRootLayerScrollingForTest(GetParam()) { } |
292 { | |
293 GetParam()(settings); | |
294 } | |
295 }; | 294 }; |
296 | 295 |
297 INSTANTIATE_TEST_CASE_P(All, ParameterizedWebFrameTest, ::testing::Values( | 296 INSTANTIATE_TEST_CASE_P(All, ParameterizedWebFrameTest, ::testing::Bool()); |
298 FrameTestHelpers::DefaultSettingOverride, | |
299 FrameTestHelpers::RootLayerScrollsSettingOverride)); | |
300 | 297 |
301 TEST_P(ParameterizedWebFrameTest, ContentText) | 298 TEST_P(ParameterizedWebFrameTest, ContentText) |
302 { | 299 { |
303 registerMockedHttpURLLoad("iframes_test.html"); | 300 registerMockedHttpURLLoad("iframes_test.html"); |
304 registerMockedHttpURLLoad("visible_iframe.html"); | 301 registerMockedHttpURLLoad("visible_iframe.html"); |
305 registerMockedHttpURLLoad("invisible_iframe.html"); | 302 registerMockedHttpURLLoad("invisible_iframe.html"); |
306 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 303 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
307 | 304 |
308 FrameTestHelpers::WebViewHelper webViewHelper(this); | 305 FrameTestHelpers::WebViewHelper webViewHelper; |
309 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html"); | 306 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html"); |
310 | 307 |
311 // Now retrieve the frames text and test it only includes visible elements. | 308 // Now retrieve the frames text and test it only includes visible elements. |
312 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 309 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
313 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); | 310 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); |
314 EXPECT_NE(std::string::npos, content.find(" visible iframe")); | 311 EXPECT_NE(std::string::npos, content.find(" visible iframe")); |
315 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); | 312 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); |
316 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); | 313 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); |
317 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); | 314 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); |
318 } | 315 } |
319 | 316 |
320 TEST_P(ParameterizedWebFrameTest, FrameForEnteredContext) | 317 TEST_P(ParameterizedWebFrameTest, FrameForEnteredContext) |
321 { | 318 { |
322 registerMockedHttpURLLoad("iframes_test.html"); | 319 registerMockedHttpURLLoad("iframes_test.html"); |
323 registerMockedHttpURLLoad("visible_iframe.html"); | 320 registerMockedHttpURLLoad("visible_iframe.html"); |
324 registerMockedHttpURLLoad("invisible_iframe.html"); | 321 registerMockedHttpURLLoad("invisible_iframe.html"); |
325 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 322 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
326 | 323 |
327 FrameTestHelpers::WebViewHelper webViewHelper(this); | 324 FrameTestHelpers::WebViewHelper webViewHelper; |
328 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html", true); | 325 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html", true); |
329 | 326 |
330 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 327 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
331 EXPECT_EQ(webViewHelper.webView()->mainFrame(), WebLocalFrame::frameForConte
xt(webViewHelper.webView()->mainFrame()->mainWorldScriptContext())); | 328 EXPECT_EQ(webViewHelper.webView()->mainFrame(), WebLocalFrame::frameForConte
xt(webViewHelper.webView()->mainFrame()->mainWorldScriptContext())); |
332 EXPECT_EQ(webViewHelper.webView()->mainFrame()->firstChild(), WebLocalFrame:
:frameForContext(webViewHelper.webView()->mainFrame()->firstChild()->mainWorldSc
riptContext())); | 329 EXPECT_EQ(webViewHelper.webView()->mainFrame()->firstChild(), WebLocalFrame:
:frameForContext(webViewHelper.webView()->mainFrame()->firstChild()->mainWorldSc
riptContext())); |
333 } | 330 } |
334 | 331 |
335 class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { | 332 class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { |
336 public: | 333 public: |
337 explicit ScriptExecutionCallbackHelper(v8::Local<v8::Context> context) | 334 explicit ScriptExecutionCallbackHelper(v8::Local<v8::Context> context) |
(...skipping 15 matching lines...) Expand all Loading... |
353 | 350 |
354 bool m_didComplete; | 351 bool m_didComplete; |
355 String m_stringValue; | 352 String m_stringValue; |
356 v8::Local<v8::Context> m_context; | 353 v8::Local<v8::Context> m_context; |
357 }; | 354 }; |
358 | 355 |
359 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) | 356 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) |
360 { | 357 { |
361 registerMockedHttpURLLoad("foo.html"); | 358 registerMockedHttpURLLoad("foo.html"); |
362 | 359 |
363 FrameTestHelpers::WebViewHelper webViewHelper(this); | 360 FrameTestHelpers::WebViewHelper webViewHelper; |
364 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 361 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
365 | 362 |
366 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 363 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
367 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr
ame()->mainWorldScriptContext()); | 364 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr
ame()->mainWorldScriptContext()); |
368 webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecuteScrip
tAndReturnValue(WebScriptSource(WebString("'hello';")), false, &callbackHelper); | 365 webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecuteScrip
tAndReturnValue(WebScriptSource(WebString("'hello';")), false, &callbackHelper); |
369 runPendingTasks(); | 366 runPendingTasks(); |
370 EXPECT_TRUE(callbackHelper.didComplete()); | 367 EXPECT_TRUE(callbackHelper.didComplete()); |
371 EXPECT_EQ("hello", callbackHelper.stringValue()); | 368 EXPECT_EQ("hello", callbackHelper.stringValue()); |
372 } | 369 } |
373 | 370 |
374 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) | 371 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) |
375 { | 372 { |
376 registerMockedHttpURLLoad("foo.html"); | 373 registerMockedHttpURLLoad("foo.html"); |
377 registerMockedHttpURLLoad("bar.html"); | 374 registerMockedHttpURLLoad("bar.html"); |
378 | 375 |
379 FrameTestHelpers::WebViewHelper webViewHelper(this); | 376 FrameTestHelpers::WebViewHelper webViewHelper; |
380 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 377 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
381 | 378 |
382 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 379 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
383 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr
ame()->mainWorldScriptContext()); | 380 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr
ame()->mainWorldScriptContext()); |
384 | 381 |
385 // Suspend scheduled tasks so the script doesn't run. | 382 // Suspend scheduled tasks so the script doesn't run. |
386 webViewHelper.webView()->mainFrameImpl()->frame()->document()->suspendSchedu
ledTasks(); | 383 webViewHelper.webView()->mainFrameImpl()->frame()->document()->suspendSchedu
ledTasks(); |
387 webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndReturnValue
(WebScriptSource(WebString("'hello';")), false, &callbackHelper); | 384 webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndReturnValue
(WebScriptSource(WebString("'hello';")), false, &callbackHelper); |
388 runPendingTasks(); | 385 runPendingTasks(); |
389 EXPECT_FALSE(callbackHelper.didComplete()); | 386 EXPECT_FALSE(callbackHelper.didComplete()); |
390 | 387 |
391 // If the frame navigates, pending scripts should be removed, but the callba
ck should always be ran. | 388 // If the frame navigates, pending scripts should be removed, but the callba
ck should always be ran. |
392 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "bar.html"); | 389 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "bar.html"); |
393 EXPECT_TRUE(callbackHelper.didComplete()); | 390 EXPECT_TRUE(callbackHelper.didComplete()); |
394 EXPECT_EQ(String(), callbackHelper.stringValue()); | 391 EXPECT_EQ(String(), callbackHelper.stringValue()); |
395 } | 392 } |
396 | 393 |
397 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) | 394 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) |
398 { | 395 { |
399 registerMockedHttpURLLoad("single_iframe.html"); | 396 registerMockedHttpURLLoad("single_iframe.html"); |
400 registerMockedHttpURLLoad("visible_iframe.html"); | 397 registerMockedHttpURLLoad("visible_iframe.html"); |
401 | 398 |
402 FrameTestHelpers::WebViewHelper webViewHelper(this); | 399 FrameTestHelpers::WebViewHelper webViewHelper; |
403 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true); | 400 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true); |
404 | 401 |
405 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 402 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
406 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr
ame()->mainWorldScriptContext()); | 403 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr
ame()->mainWorldScriptContext()); |
407 webViewHelper.webView()->mainFrame()->firstChild()->toWebLocalFrame()->reque
stExecuteScriptAndReturnValue(WebScriptSource(WebString("var iframe = window.top
.document.getElementsByTagName('iframe')[0]; window.top.document.body.removeChil
d(iframe); 'hello';")), false, &callbackHelper); | 404 webViewHelper.webView()->mainFrame()->firstChild()->toWebLocalFrame()->reque
stExecuteScriptAndReturnValue(WebScriptSource(WebString("var iframe = window.top
.document.getElementsByTagName('iframe')[0]; window.top.document.body.removeChil
d(iframe); 'hello';")), false, &callbackHelper); |
408 runPendingTasks(); | 405 runPendingTasks(); |
409 EXPECT_TRUE(callbackHelper.didComplete()); | 406 EXPECT_TRUE(callbackHelper.didComplete()); |
410 EXPECT_EQ(String(), callbackHelper.stringValue()); | 407 EXPECT_EQ(String(), callbackHelper.stringValue()); |
411 } | 408 } |
412 | 409 |
413 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) | 410 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) |
414 { | 411 { |
415 registerMockedHttpURLLoad("form.html"); | 412 registerMockedHttpURLLoad("form.html"); |
416 | 413 |
417 FrameTestHelpers::WebViewHelper webViewHelper(this); | 414 FrameTestHelpers::WebViewHelper webViewHelper; |
418 webViewHelper.initializeAndLoad(m_baseURL + "form.html"); | 415 webViewHelper.initializeAndLoad(m_baseURL + "form.html"); |
419 | 416 |
420 WebVector<WebFormElement> forms; | 417 WebVector<WebFormElement> forms; |
421 webViewHelper.webView()->mainFrame()->document().forms(forms); | 418 webViewHelper.webView()->mainFrame()->document().forms(forms); |
422 webViewHelper.reset(); | 419 webViewHelper.reset(); |
423 | 420 |
424 EXPECT_EQ(forms.size(), 1U); | 421 EXPECT_EQ(forms.size(), 1U); |
425 | 422 |
426 // This test passes if this doesn't crash. | 423 // This test passes if this doesn't crash. |
427 WebSearchableFormData searchableDataForm(forms[0]); | 424 WebSearchableFormData searchableDataForm(forms[0]); |
428 } | 425 } |
429 | 426 |
430 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) | 427 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) |
431 { | 428 { |
432 registerMockedChromeURLLoad("history.html"); | 429 registerMockedChromeURLLoad("history.html"); |
433 | 430 |
434 // Pass true to enable JavaScript. | 431 // Pass true to enable JavaScript. |
435 FrameTestHelpers::WebViewHelper webViewHelper(this); | 432 FrameTestHelpers::WebViewHelper webViewHelper; |
436 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); | 433 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); |
437 | 434 |
438 // Try to run JS against the chrome-style URL. | 435 // Try to run JS against the chrome-style URL. |
439 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); | 436 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); |
440 | 437 |
441 // Now retrieve the frame's text and ensure it was modified by running javas
cript. | 438 // Now retrieve the frame's text and ensure it was modified by running javas
cript. |
442 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 439 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
443 EXPECT_NE(std::string::npos, content.find("Clobbered")); | 440 EXPECT_NE(std::string::npos, content.find("Clobbered")); |
444 } | 441 } |
445 | 442 |
446 TEST_P(ParameterizedWebFrameTest, ChromePageNoJavascript) | 443 TEST_P(ParameterizedWebFrameTest, ChromePageNoJavascript) |
447 { | 444 { |
448 registerMockedChromeURLLoad("history.html"); | 445 registerMockedChromeURLLoad("history.html"); |
449 | 446 |
450 /// Pass true to enable JavaScript. | 447 /// Pass true to enable JavaScript. |
451 FrameTestHelpers::WebViewHelper webViewHelper(this); | 448 FrameTestHelpers::WebViewHelper webViewHelper; |
452 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); | 449 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); |
453 | 450 |
454 // Try to run JS against the chrome-style URL after prohibiting it. | 451 // Try to run JS against the chrome-style URL after prohibiting it. |
455 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); | 452 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); |
456 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); | 453 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); |
457 | 454 |
458 // Now retrieve the frame's text and ensure it wasn't modified by running ja
vascript. | 455 // Now retrieve the frame's text and ensure it wasn't modified by running ja
vascript. |
459 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 456 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
460 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 457 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
461 } | 458 } |
462 | 459 |
463 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) | 460 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) |
464 { | 461 { |
465 std::string fileName = "print-location-href.html"; | 462 std::string fileName = "print-location-href.html"; |
466 registerMockedHttpURLLoad(fileName); | 463 registerMockedHttpURLLoad(fileName); |
467 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); | 464 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); |
468 | 465 |
469 FrameTestHelpers::WebViewHelper webViewHelper(this); | 466 FrameTestHelpers::WebViewHelper webViewHelper; |
470 | 467 |
471 /// Pass true to enable JavaScript. | 468 /// Pass true to enable JavaScript. |
472 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 469 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
473 | 470 |
474 // Setting host to "hostname:" should be treated as "hostname:0". | 471 // Setting host to "hostname:" should be treated as "hostname:0". |
475 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.host = 'internal.test:'; void 0;"); | 472 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.host = 'internal.test:'; void 0;"); |
476 | 473 |
477 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); | 474 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); |
478 | 475 |
479 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 476 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
480 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 477 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
481 } | 478 } |
482 | 479 |
483 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) | 480 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) |
484 { | 481 { |
485 std::string fileName = "print-location-href.html"; | 482 std::string fileName = "print-location-href.html"; |
486 registerMockedHttpURLLoad(fileName); | 483 registerMockedHttpURLLoad(fileName); |
487 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); | 484 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); |
488 | 485 |
489 FrameTestHelpers::WebViewHelper webViewHelper(this); | 486 FrameTestHelpers::WebViewHelper webViewHelper; |
490 | 487 |
491 /// Pass true to enable JavaScript. | 488 /// Pass true to enable JavaScript. |
492 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 489 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
493 | 490 |
494 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.port = ''; void 0;"); | 491 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.port = ''; void 0;"); |
495 | 492 |
496 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); | 493 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); |
497 | 494 |
498 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 495 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
499 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 496 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
(...skipping 13 matching lines...) Expand all Loading... |
513 m_executing = false; | 510 m_executing = false; |
514 } | 511 } |
515 | 512 |
516 bool m_executing; | 513 bool m_executing; |
517 bool m_wasExecuted; | 514 bool m_wasExecuted; |
518 }; | 515 }; |
519 | 516 |
520 TEST_P(ParameterizedWebFrameTest, DidClearWindowObjectIsNotRecursive) | 517 TEST_P(ParameterizedWebFrameTest, DidClearWindowObjectIsNotRecursive) |
521 { | 518 { |
522 EvaluateOnLoadWebFrameClient webFrameClient; | 519 EvaluateOnLoadWebFrameClient webFrameClient; |
523 FrameTestHelpers::WebViewHelper webViewHelper(this); | 520 FrameTestHelpers::WebViewHelper webViewHelper; |
524 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); | 521 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); |
525 EXPECT_TRUE(webFrameClient.m_wasExecuted); | 522 EXPECT_TRUE(webFrameClient.m_wasExecuted); |
526 } | 523 } |
527 | 524 |
528 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 525 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
529 public: | 526 public: |
530 CSSCallbackWebFrameClient() : m_updateCount(0) { } | 527 CSSCallbackWebFrameClient() : m_updateCount(0) { } |
531 void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMatchingSe
lectors, const WebVector<WebString>& stoppedMatchingSelectors) override; | 528 void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMatchingSe
lectors, const WebVector<WebString>& stoppedMatchingSelectors) override; |
532 | 529 |
533 std::map<WebLocalFrame*, std::set<std::string>> m_matchedSelectors; | 530 std::map<WebLocalFrame*, std::set<std::string>> m_matchedSelectors; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 EXPECT_EQ(1, updateCount()); | 787 EXPECT_EQ(1, updateCount()); |
791 EXPECT_THAT(matchedSelectors(), ElementsAre("span")) | 788 EXPECT_THAT(matchedSelectors(), ElementsAre("span")) |
792 << "An invalid selector shouldn't prevent other selectors from matching.
"; | 789 << "An invalid selector shouldn't prevent other selectors from matching.
"; |
793 } | 790 } |
794 | 791 |
795 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) | 792 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) |
796 { | 793 { |
797 registerMockedHttpURLLoad("postmessage_test.html"); | 794 registerMockedHttpURLLoad("postmessage_test.html"); |
798 | 795 |
799 // Pass true to enable JavaScript. | 796 // Pass true to enable JavaScript. |
800 FrameTestHelpers::WebViewHelper webViewHelper(this); | 797 FrameTestHelpers::WebViewHelper webViewHelper; |
801 webViewHelper.initializeAndLoad(m_baseURL + "postmessage_test.html", true); | 798 webViewHelper.initializeAndLoad(m_baseURL + "postmessage_test.html", true); |
802 | 799 |
803 // Send a message with the correct origin. | 800 // Send a message with the correct origin. |
804 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))
); | 801 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))
); |
805 WebDocument document = webViewHelper.webView()->mainFrame()->document(); | 802 WebDocument document = webViewHelper.webView()->mainFrame()->document(); |
806 WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); | 803 WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); |
807 WebDOMMessageEvent message(data, "http://origin.com"); | 804 WebDOMMessageEvent message(data, "http://origin.com"); |
808 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(co
rrectOrigin, message); | 805 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(co
rrectOrigin, message); |
809 | 806 |
810 // Send another message with incorrect origin. | 807 // Send another message with incorrect origin. |
811 WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create(toKURL(m_chromeU
RL))); | 808 WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create(toKURL(m_chromeU
RL))); |
812 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(in
correctOrigin, message); | 809 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(in
correctOrigin, message); |
813 | 810 |
814 // Verify that only the first addition is in the body of the page. | 811 // Verify that only the first addition is in the body of the page. |
815 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 812 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
816 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 813 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
817 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 814 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
818 } | 815 } |
819 | 816 |
820 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) | 817 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) |
821 { | 818 { |
822 FrameTestHelpers::WebViewHelper webViewHelper(this); | 819 FrameTestHelpers::WebViewHelper webViewHelper; |
823 webViewHelper.initializeAndLoad("about:blank"); | 820 webViewHelper.initializeAndLoad("about:blank"); |
824 | 821 |
825 LocalFrame* frame = toLocalFrame(webViewHelper.webView()->page()->mainFrame(
)); | 822 LocalFrame* frame = toLocalFrame(webViewHelper.webView()->page()->mainFrame(
)); |
826 NonThrowableExceptionState exceptionState; | 823 NonThrowableExceptionState exceptionState; |
827 MessagePortArray messagePorts; | 824 MessagePortArray messagePorts; |
828 frame->domWindow()->postMessage(SerializedScriptValue::serialize("message"),
messagePorts, "*", frame->localDOMWindow(), exceptionState); | 825 frame->domWindow()->postMessage(SerializedScriptValue::serialize("message"),
messagePorts, "*", frame->localDOMWindow(), exceptionState); |
829 webViewHelper.reset(); | 826 webViewHelper.reset(); |
830 EXPECT_FALSE(exceptionState.hadException()); | 827 EXPECT_FALSE(exceptionState.hadException()); |
831 | 828 |
832 // Success is not crashing. | 829 // Success is not crashing. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 } // anonymous namespace | 882 } // anonymous namespace |
886 | 883 |
887 TEST_P(ParameterizedWebFrameTest, ChangeInFixedLayoutResetsTextAutosizingMultipl
iers) | 884 TEST_P(ParameterizedWebFrameTest, ChangeInFixedLayoutResetsTextAutosizingMultipl
iers) |
888 { | 885 { |
889 registerMockedHttpURLLoad("fixed_layout.html"); | 886 registerMockedHttpURLLoad("fixed_layout.html"); |
890 | 887 |
891 FixedLayoutTestWebViewClient client; | 888 FixedLayoutTestWebViewClient client; |
892 int viewportWidth = 640; | 889 int viewportWidth = 640; |
893 int viewportHeight = 480; | 890 int viewportHeight = 480; |
894 | 891 |
895 FrameTestHelpers::WebViewHelper webViewHelper(this); | 892 FrameTestHelpers::WebViewHelper webViewHelper; |
896 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 893 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
897 | 894 |
898 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); | 895 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); |
899 document->settings()->setTextAutosizingEnabled(true); | 896 document->settings()->setTextAutosizingEnabled(true); |
900 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 897 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
901 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 898 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
902 | 899 |
903 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); | 900 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); |
904 | 901 |
905 ViewportDescription description = document->viewportDescription(); | 902 ViewportDescription description = document->viewportDescription(); |
906 // Choose a width that's not going match the viewport width of the loaded do
cument. | 903 // Choose a width that's not going match the viewport width of the loaded do
cument. |
907 description.minWidth = Length(100, blink::Fixed); | 904 description.minWidth = Length(100, blink::Fixed); |
908 description.maxWidth = Length(100, blink::Fixed); | 905 description.maxWidth = Length(100, blink::Fixed); |
909 webViewHelper.webView()->updatePageDefinedViewportConstraints(description); | 906 webViewHelper.webView()->updatePageDefinedViewportConstraints(description); |
910 | 907 |
911 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); | 908 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); |
912 } | 909 } |
913 | 910 |
914 TEST_P(ParameterizedWebFrameTest, WorkingTextAutosizingMultipliers_VirtualViewpo
rt) | 911 TEST_P(ParameterizedWebFrameTest, WorkingTextAutosizingMultipliers_VirtualViewpo
rt) |
915 { | 912 { |
916 const std::string htmlFile = "fixed_layout.html"; | 913 const std::string htmlFile = "fixed_layout.html"; |
917 registerMockedHttpURLLoad(htmlFile); | 914 registerMockedHttpURLLoad(htmlFile); |
918 | 915 |
919 FixedLayoutTestWebViewClient client; | 916 FixedLayoutTestWebViewClient client; |
920 | 917 |
921 FrameTestHelpers::WebViewHelper webViewHelper(this); | 918 FrameTestHelpers::WebViewHelper webViewHelper; |
922 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client
, nullptr, configureAndroid); | 919 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client
, nullptr, configureAndroid); |
923 | 920 |
924 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); | 921 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); |
925 document->settings()->setTextAutosizingEnabled(true); | 922 document->settings()->setTextAutosizingEnabled(true); |
926 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 923 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
927 | 924 |
928 webViewHelper.resize(WebSize(490, 800)); | 925 webViewHelper.resize(WebSize(490, 800)); |
929 | 926 |
930 // Multiplier: 980 / 490 = 2.0 | 927 // Multiplier: 980 / 490 = 2.0 |
931 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 2.0)); | 928 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 2.0)); |
932 } | 929 } |
933 | 930 |
934 TEST_P(ParameterizedWebFrameTest, VisualViewportSetSizeInvalidatesTextAutosizing
Multipliers) | 931 TEST_P(ParameterizedWebFrameTest, VisualViewportSetSizeInvalidatesTextAutosizing
Multipliers) |
935 { | 932 { |
936 registerMockedHttpURLLoad("iframe_reload.html"); | 933 registerMockedHttpURLLoad("iframe_reload.html"); |
937 registerMockedHttpURLLoad("visible_iframe.html"); | 934 registerMockedHttpURLLoad("visible_iframe.html"); |
938 | 935 |
939 FixedLayoutTestWebViewClient client; | 936 FixedLayoutTestWebViewClient client; |
940 int viewportWidth = 640; | 937 int viewportWidth = 640; |
941 int viewportHeight = 480; | 938 int viewportHeight = 480; |
942 | 939 |
943 FrameTestHelpers::WebViewHelper webViewHelper(this); | 940 FrameTestHelpers::WebViewHelper webViewHelper; |
944 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, null
ptr, &client, nullptr, enableViewportSettings); | 941 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, null
ptr, &client, nullptr, enableViewportSettings); |
945 | 942 |
946 LocalFrame* mainFrame = toLocalFrame(webViewHelper.webView()->page()->mainFr
ame()); | 943 LocalFrame* mainFrame = toLocalFrame(webViewHelper.webView()->page()->mainFr
ame()); |
947 Document* document = mainFrame->document(); | 944 Document* document = mainFrame->document(); |
948 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView()
; | 945 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView()
; |
949 document->settings()->setTextAutosizingEnabled(true); | 946 document->settings()->setTextAutosizingEnabled(true); |
950 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 947 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
951 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 948 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
952 | 949 |
953 for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext())
{ | 950 for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext())
{ |
(...skipping 18 matching lines...) Expand all Loading... |
972 } | 969 } |
973 } | 970 } |
974 | 971 |
975 TEST_P(ParameterizedWebFrameTest, ZeroHeightPositiveWidthNotIgnored) | 972 TEST_P(ParameterizedWebFrameTest, ZeroHeightPositiveWidthNotIgnored) |
976 { | 973 { |
977 FixedLayoutTestWebViewClient client; | 974 FixedLayoutTestWebViewClient client; |
978 client.m_screenInfo.deviceScaleFactor = 1; | 975 client.m_screenInfo.deviceScaleFactor = 1; |
979 int viewportWidth = 1280; | 976 int viewportWidth = 1280; |
980 int viewportHeight = 0; | 977 int viewportHeight = 0; |
981 | 978 |
982 FrameTestHelpers::WebViewHelper webViewHelper(this); | 979 FrameTestHelpers::WebViewHelper webViewHelper; |
983 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 980 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
984 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 981 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
985 | 982 |
986 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->layoutSize().width()); | 983 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->layoutSize().width()); |
987 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->layoutSize().height()); | 984 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->layoutSize().height()); |
988 } | 985 } |
989 | 986 |
990 TEST_P(ParameterizedWebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag
) | 987 TEST_P(ParameterizedWebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag
) |
991 { | 988 { |
992 registerMockedHttpURLLoad("no_viewport_tag.html"); | 989 registerMockedHttpURLLoad("no_viewport_tag.html"); |
993 | 990 |
994 int viewportWidth = 640; | 991 int viewportWidth = 640; |
995 int viewportHeight = 480; | 992 int viewportHeight = 480; |
996 | 993 |
997 FixedLayoutTestWebViewClient client; | 994 FixedLayoutTestWebViewClient client; |
998 client.m_screenInfo.deviceScaleFactor = 2; | 995 client.m_screenInfo.deviceScaleFactor = 2; |
999 | 996 |
1000 FrameTestHelpers::WebViewHelper webViewHelper(this); | 997 FrameTestHelpers::WebViewHelper webViewHelper; |
1001 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu
llptr, &client, nullptr, enableViewportSettings); | 998 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu
llptr, &client, nullptr, enableViewportSettings); |
1002 | 999 |
1003 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1000 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1004 | 1001 |
1005 EXPECT_EQ(2, webViewHelper.webView()->page()->deviceScaleFactor()); | 1002 EXPECT_EQ(2, webViewHelper.webView()->page()->deviceScaleFactor()); |
1006 | 1003 |
1007 // Device scale factor should be independent of page scale. | 1004 // Device scale factor should be independent of page scale. |
1008 webViewHelper.webView()->setDefaultPageScaleLimits(1, 2); | 1005 webViewHelper.webView()->setDefaultPageScaleLimits(1, 2); |
1009 webViewHelper.webView()->setPageScaleFactor(0.5); | 1006 webViewHelper.webView()->setPageScaleFactor(0.5); |
1010 webViewHelper.webView()->updateAllLifecyclePhases(); | 1007 webViewHelper.webView()->updateAllLifecyclePhases(); |
1011 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1008 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
1012 | 1009 |
1013 // Force the layout to happen before leaving the test. | 1010 // Force the layout to happen before leaving the test. |
1014 webViewHelper.webView()->updateAllLifecyclePhases(); | 1011 webViewHelper.webView()->updateAllLifecyclePhases(); |
1015 } | 1012 } |
1016 | 1013 |
1017 TEST_P(ParameterizedWebFrameTest, FixedLayoutInitializeAtMinimumScale) | 1014 TEST_P(ParameterizedWebFrameTest, FixedLayoutInitializeAtMinimumScale) |
1018 { | 1015 { |
1019 registerMockedHttpURLLoad("fixed_layout.html"); | 1016 registerMockedHttpURLLoad("fixed_layout.html"); |
1020 | 1017 |
1021 FixedLayoutTestWebViewClient client; | 1018 FixedLayoutTestWebViewClient client; |
1022 client.m_screenInfo.deviceScaleFactor = 1; | 1019 client.m_screenInfo.deviceScaleFactor = 1; |
1023 int viewportWidth = 640; | 1020 int viewportWidth = 640; |
1024 int viewportHeight = 480; | 1021 int viewportHeight = 480; |
1025 | 1022 |
1026 // Make sure we initialize to minimum scale, even if the window size | 1023 // Make sure we initialize to minimum scale, even if the window size |
1027 // only becomes available after the load begins. | 1024 // only becomes available after the load begins. |
1028 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1025 FrameTestHelpers::WebViewHelper webViewHelper; |
1029 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 1026 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
1030 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 1027 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
1031 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); | 1028 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); |
1032 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1029 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1033 | 1030 |
1034 int defaultFixedLayoutWidth = 980; | 1031 int defaultFixedLayoutWidth = 980; |
1035 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; | 1032 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; |
1036 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); | 1033 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); |
1037 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); | 1034 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); |
1038 | 1035 |
(...skipping 16 matching lines...) Expand all Loading... |
1055 { | 1052 { |
1056 registerMockedHttpURLLoad("wide_document.html"); | 1053 registerMockedHttpURLLoad("wide_document.html"); |
1057 | 1054 |
1058 FixedLayoutTestWebViewClient client; | 1055 FixedLayoutTestWebViewClient client; |
1059 client.m_screenInfo.deviceScaleFactor = 1; | 1056 client.m_screenInfo.deviceScaleFactor = 1; |
1060 int viewportWidth = 640; | 1057 int viewportWidth = 640; |
1061 int viewportHeight = 480; | 1058 int viewportHeight = 480; |
1062 | 1059 |
1063 // Make sure we initialize to minimum scale, even if the window size | 1060 // Make sure we initialize to minimum scale, even if the window size |
1064 // only becomes available after the load begins. | 1061 // only becomes available after the load begins. |
1065 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1062 FrameTestHelpers::WebViewHelper webViewHelper; |
1066 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 1063 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
1067 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 1064 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
1068 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "wide_document.html"); | 1065 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "wide_document.html"); |
1069 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1066 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1070 | 1067 |
1071 int wideDocumentWidth = 1500; | 1068 int wideDocumentWidth = 1500; |
1072 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; | 1069 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; |
1073 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); | 1070 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); |
1074 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); | 1071 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); |
1075 | 1072 |
(...skipping 14 matching lines...) Expand all Loading... |
1090 | 1087 |
1091 TEST_P(ParameterizedWebFrameTest, DelayedViewportInitialScale) | 1088 TEST_P(ParameterizedWebFrameTest, DelayedViewportInitialScale) |
1092 { | 1089 { |
1093 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1090 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
1094 | 1091 |
1095 FixedLayoutTestWebViewClient client; | 1092 FixedLayoutTestWebViewClient client; |
1096 client.m_screenInfo.deviceScaleFactor = 1; | 1093 client.m_screenInfo.deviceScaleFactor = 1; |
1097 int viewportWidth = 640; | 1094 int viewportWidth = 640; |
1098 int viewportHeight = 480; | 1095 int viewportHeight = 480; |
1099 | 1096 |
1100 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1097 FrameTestHelpers::WebViewHelper webViewHelper; |
1101 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); | 1098 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); |
1102 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1099 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1103 | 1100 |
1104 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); | 1101 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); |
1105 | 1102 |
1106 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); | 1103 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); |
1107 ViewportDescription description = document->viewportDescription(); | 1104 ViewportDescription description = document->viewportDescription(); |
1108 description.zoom = 2; | 1105 description.zoom = 2; |
1109 document->setViewportDescription(description); | 1106 document->setViewportDescription(description); |
1110 webViewHelper.webView()->updateAllLifecyclePhases(); | 1107 webViewHelper.webView()->updateAllLifecyclePhases(); |
1111 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); | 1108 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); |
1112 } | 1109 } |
1113 | 1110 |
1114 TEST_P(ParameterizedWebFrameTest, setLoadWithOverviewModeToFalse) | 1111 TEST_P(ParameterizedWebFrameTest, setLoadWithOverviewModeToFalse) |
1115 { | 1112 { |
1116 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1113 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
1117 | 1114 |
1118 FixedLayoutTestWebViewClient client; | 1115 FixedLayoutTestWebViewClient client; |
1119 client.m_screenInfo.deviceScaleFactor = 1; | 1116 client.m_screenInfo.deviceScaleFactor = 1; |
1120 int viewportWidth = 640; | 1117 int viewportWidth = 640; |
1121 int viewportHeight = 480; | 1118 int viewportHeight = 480; |
1122 | 1119 |
1123 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1120 FrameTestHelpers::WebViewHelper webViewHelper; |
1124 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); | 1121 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); |
1125 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1122 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1126 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1123 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1127 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1124 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1128 | 1125 |
1129 // The page must be displayed at 100% zoom. | 1126 // The page must be displayed at 100% zoom. |
1130 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1127 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
1131 } | 1128 } |
1132 | 1129 |
1133 TEST_P(ParameterizedWebFrameTest, SetLoadWithOverviewModeToFalseAndNoWideViewpor
t) | 1130 TEST_P(ParameterizedWebFrameTest, SetLoadWithOverviewModeToFalseAndNoWideViewpor
t) |
1134 { | 1131 { |
1135 registerMockedHttpURLLoad("large-div.html"); | 1132 registerMockedHttpURLLoad("large-div.html"); |
1136 | 1133 |
1137 FixedLayoutTestWebViewClient client; | 1134 FixedLayoutTestWebViewClient client; |
1138 client.m_screenInfo.deviceScaleFactor = 1; | 1135 client.m_screenInfo.deviceScaleFactor = 1; |
1139 int viewportWidth = 640; | 1136 int viewportWidth = 640; |
1140 int viewportHeight = 480; | 1137 int viewportHeight = 480; |
1141 | 1138 |
1142 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1139 FrameTestHelpers::WebViewHelper webViewHelper; |
1143 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr,
&client, nullptr, enableViewportSettings); | 1140 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr,
&client, nullptr, enableViewportSettings); |
1144 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1141 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1145 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1142 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1146 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1143 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1147 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1144 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1148 | 1145 |
1149 // The page must be displayed at 100% zoom, despite that it hosts a wide div
element. | 1146 // The page must be displayed at 100% zoom, despite that it hosts a wide div
element. |
1150 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1147 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
1151 } | 1148 } |
1152 | 1149 |
1153 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidth) | 1150 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidth) |
1154 { | 1151 { |
1155 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1152 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
1156 | 1153 |
1157 FixedLayoutTestWebViewClient client; | 1154 FixedLayoutTestWebViewClient client; |
1158 client.m_screenInfo.deviceScaleFactor = 1; | 1155 client.m_screenInfo.deviceScaleFactor = 1; |
1159 int viewportWidth = 640; | 1156 int viewportWidth = 640; |
1160 int viewportHeight = 480; | 1157 int viewportHeight = 480; |
1161 | 1158 |
1162 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1159 FrameTestHelpers::WebViewHelper webViewHelper; |
1163 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); | 1160 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); |
1164 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1161 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1165 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1162 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1166 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1163 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1167 | 1164 |
1168 // The page sets viewport width to 3000, but with UseWideViewport == false i
s must be ignored. | 1165 // The page sets viewport width to 3000, but with UseWideViewport == false i
s must be ignored. |
1169 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->contentsSize().width()); | 1166 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->contentsSize().width()); |
1170 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->contentsSize().height()); | 1167 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->contentsSize().height()); |
1171 } | 1168 } |
1172 | 1169 |
1173 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccou
ntsScale) | 1170 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccou
ntsScale) |
1174 { | 1171 { |
1175 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 1172 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
1176 | 1173 |
1177 FixedLayoutTestWebViewClient client; | 1174 FixedLayoutTestWebViewClient client; |
1178 client.m_screenInfo.deviceScaleFactor = 1; | 1175 client.m_screenInfo.deviceScaleFactor = 1; |
1179 int viewportWidth = 640; | 1176 int viewportWidth = 640; |
1180 int viewportHeight = 480; | 1177 int viewportHeight = 480; |
1181 | 1178 |
1182 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1179 FrameTestHelpers::WebViewHelper webViewHelper; |
1183 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.
html", true, nullptr, &client, nullptr, enableViewportSettings); | 1180 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.
html", true, nullptr, &client, nullptr, enableViewportSettings); |
1184 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1181 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1185 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1182 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1186 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1183 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1187 | 1184 |
1188 // The page sets viewport width to 3000, but with UseWideViewport == false i
t must be ignored. | 1185 // The page sets viewport width to 3000, but with UseWideViewport == false i
t must be ignored. |
1189 // While the initial scale specified by the page must be accounted. | 1186 // While the initial scale specified by the page must be accounted. |
1190 EXPECT_EQ(viewportWidth / 2, webViewHelper.webView()->mainFrameImpl()->frame
View()->contentsSize().width()); | 1187 EXPECT_EQ(viewportWidth / 2, webViewHelper.webView()->mainFrameImpl()->frame
View()->contentsSize().width()); |
1191 EXPECT_EQ(viewportHeight / 2, webViewHelper.webView()->mainFrameImpl()->fram
eView()->contentsSize().height()); | 1188 EXPECT_EQ(viewportHeight / 2, webViewHelper.webView()->mainFrameImpl()->fram
eView()->contentsSize().height()); |
1192 } | 1189 } |
1193 | 1190 |
1194 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithoutViewportTag) | 1191 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithoutViewportTag) |
1195 { | 1192 { |
1196 registerMockedHttpURLLoad("no_viewport_tag.html"); | 1193 registerMockedHttpURLLoad("no_viewport_tag.html"); |
1197 | 1194 |
1198 FixedLayoutTestWebViewClient client; | 1195 FixedLayoutTestWebViewClient client; |
1199 client.m_screenInfo.deviceScaleFactor = 1; | 1196 client.m_screenInfo.deviceScaleFactor = 1; |
1200 int viewportWidth = 640; | 1197 int viewportWidth = 640; |
1201 int viewportHeight = 480; | 1198 int viewportHeight = 480; |
1202 | 1199 |
1203 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1200 FrameTestHelpers::WebViewHelper webViewHelper; |
1204 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu
llptr, &client, nullptr, enableViewportSettings); | 1201 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu
llptr, &client, nullptr, enableViewportSettings); |
1205 applyViewportStyleOverride(&webViewHelper); | 1202 applyViewportStyleOverride(&webViewHelper); |
1206 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1203 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1207 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1204 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1208 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1205 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1209 | 1206 |
1210 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten
tsSize().width()); | 1207 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten
tsSize().width()); |
1211 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webView()->m
ainFrameImpl()->frameView()->contentsSize().height()); | 1208 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webView()->m
ainFrameImpl()->frameView()->contentsSize().height()); |
1212 } | 1209 } |
1213 | 1210 |
1214 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithXhtmlMp) | 1211 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithXhtmlMp) |
1215 { | 1212 { |
1216 registerMockedHttpURLLoad("viewport/viewport-legacy-xhtmlmp.html"); | 1213 registerMockedHttpURLLoad("viewport/viewport-legacy-xhtmlmp.html"); |
1217 | 1214 |
1218 FixedLayoutTestWebViewClient client; | 1215 FixedLayoutTestWebViewClient client; |
1219 client.m_screenInfo.deviceScaleFactor = 1; | 1216 client.m_screenInfo.deviceScaleFactor = 1; |
1220 int viewportWidth = 640; | 1217 int viewportWidth = 640; |
1221 int viewportHeight = 480; | 1218 int viewportHeight = 480; |
1222 | 1219 |
1223 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1220 FrameTestHelpers::WebViewHelper webViewHelper; |
1224 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 1221 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
1225 applyViewportStyleOverride(&webViewHelper); | 1222 applyViewportStyleOverride(&webViewHelper); |
1226 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1223 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1227 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1224 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1228 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-legacy-xhtmlmp.html"); | 1225 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-legacy-xhtmlmp.html"); |
1229 | 1226 |
1230 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1227 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1231 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->contentsSize().width()); | 1228 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->contentsSize().width()); |
1232 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->contentsSize().height()); | 1229 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->contentsSize().height()); |
1233 } | 1230 } |
1234 | 1231 |
1235 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndHeightInMeta) | 1232 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndHeightInMeta) |
1236 { | 1233 { |
1237 registerMockedHttpURLLoad("viewport-height-1000.html"); | 1234 registerMockedHttpURLLoad("viewport-height-1000.html"); |
1238 | 1235 |
1239 FixedLayoutTestWebViewClient client; | 1236 FixedLayoutTestWebViewClient client; |
1240 client.m_screenInfo.deviceScaleFactor = 1; | 1237 client.m_screenInfo.deviceScaleFactor = 1; |
1241 int viewportWidth = 640; | 1238 int viewportWidth = 640; |
1242 int viewportHeight = 480; | 1239 int viewportHeight = 480; |
1243 | 1240 |
1244 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1241 FrameTestHelpers::WebViewHelper webViewHelper; |
1245 webViewHelper.initializeAndLoad(m_baseURL + "viewport-height-1000.html", tru
e, nullptr, &client, nullptr, enableViewportSettings); | 1242 webViewHelper.initializeAndLoad(m_baseURL + "viewport-height-1000.html", tru
e, nullptr, &client, nullptr, enableViewportSettings); |
1246 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1243 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1247 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1244 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1248 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1245 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1249 | 1246 |
1250 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->contentsSize().width()); | 1247 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->contentsSize().width()); |
1251 } | 1248 } |
1252 | 1249 |
1253 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithAutoWidth) | 1250 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithAutoWidth) |
1254 { | 1251 { |
1255 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); | 1252 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); |
1256 | 1253 |
1257 FixedLayoutTestWebViewClient client; | 1254 FixedLayoutTestWebViewClient client; |
1258 client.m_screenInfo.deviceScaleFactor = 1; | 1255 client.m_screenInfo.deviceScaleFactor = 1; |
1259 int viewportWidth = 640; | 1256 int viewportWidth = 640; |
1260 int viewportHeight = 480; | 1257 int viewportHeight = 480; |
1261 | 1258 |
1262 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1259 FrameTestHelpers::WebViewHelper webViewHelper; |
1263 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html"
, true, nullptr, &client, nullptr, enableViewportSettings); | 1260 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html"
, true, nullptr, &client, nullptr, enableViewportSettings); |
1264 applyViewportStyleOverride(&webViewHelper); | 1261 applyViewportStyleOverride(&webViewHelper); |
1265 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1262 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1266 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1263 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1267 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1264 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1268 | 1265 |
1269 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten
tsSize().width()); | 1266 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten
tsSize().width()); |
1270 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webView()->m
ainFrameImpl()->frameView()->contentsSize().height()); | 1267 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webView()->m
ainFrameImpl()->frameView()->contentsSize().height()); |
1271 } | 1268 } |
1272 | 1269 |
1273 TEST_P(ParameterizedWebFrameTest, PageViewportInitialScaleOverridesLoadWithOverv
iewMode) | 1270 TEST_P(ParameterizedWebFrameTest, PageViewportInitialScaleOverridesLoadWithOverv
iewMode) |
1274 { | 1271 { |
1275 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 1272 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
1276 | 1273 |
1277 FixedLayoutTestWebViewClient client; | 1274 FixedLayoutTestWebViewClient client; |
1278 client.m_screenInfo.deviceScaleFactor = 1; | 1275 client.m_screenInfo.deviceScaleFactor = 1; |
1279 int viewportWidth = 640; | 1276 int viewportWidth = 640; |
1280 int viewportHeight = 480; | 1277 int viewportHeight = 480; |
1281 | 1278 |
1282 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1279 FrameTestHelpers::WebViewHelper webViewHelper; |
1283 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.
html", true, nullptr, &client, nullptr, enableViewportSettings); | 1280 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.
html", true, nullptr, &client, nullptr, enableViewportSettings); |
1284 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1281 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1285 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1282 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1286 | 1283 |
1287 // The page must be displayed at 200% zoom, as specified in its viewport met
a tag. | 1284 // The page must be displayed at 200% zoom, as specified in its viewport met
a tag. |
1288 EXPECT_EQ(2.0f, webViewHelper.webView()->pageScaleFactor()); | 1285 EXPECT_EQ(2.0f, webViewHelper.webView()->pageScaleFactor()); |
1289 } | 1286 } |
1290 | 1287 |
1291 TEST_P(ParameterizedWebFrameTest, setInitialPageScaleFactorPermanently) | 1288 TEST_P(ParameterizedWebFrameTest, setInitialPageScaleFactorPermanently) |
1292 { | 1289 { |
1293 registerMockedHttpURLLoad("fixed_layout.html"); | 1290 registerMockedHttpURLLoad("fixed_layout.html"); |
1294 | 1291 |
1295 FixedLayoutTestWebViewClient client; | 1292 FixedLayoutTestWebViewClient client; |
1296 client.m_screenInfo.deviceScaleFactor = 1; | 1293 client.m_screenInfo.deviceScaleFactor = 1; |
1297 float enforcedPageScaleFactor = 2.0f; | 1294 float enforcedPageScaleFactor = 2.0f; |
1298 | 1295 |
1299 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1296 FrameTestHelpers::WebViewHelper webViewHelper; |
1300 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 1297 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
1301 applyViewportStyleOverride(&webViewHelper); | 1298 applyViewportStyleOverride(&webViewHelper); |
1302 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1299 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1303 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1300 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1304 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); | 1301 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); |
1305 webViewHelper.webView()->updateAllLifecyclePhases(); | 1302 webViewHelper.webView()->updateAllLifecyclePhases(); |
1306 | 1303 |
1307 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1304 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1308 | 1305 |
1309 int viewportWidth = 640; | 1306 int viewportWidth = 640; |
(...skipping 10 matching lines...) Expand all Loading... |
1320 TEST_P(ParameterizedWebFrameTest, PermanentInitialPageScaleFactorOverridesLoadWi
thOverviewMode) | 1317 TEST_P(ParameterizedWebFrameTest, PermanentInitialPageScaleFactorOverridesLoadWi
thOverviewMode) |
1321 { | 1318 { |
1322 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1319 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
1323 | 1320 |
1324 FixedLayoutTestWebViewClient client; | 1321 FixedLayoutTestWebViewClient client; |
1325 client.m_screenInfo.deviceScaleFactor = 1; | 1322 client.m_screenInfo.deviceScaleFactor = 1; |
1326 int viewportWidth = 640; | 1323 int viewportWidth = 640; |
1327 int viewportHeight = 480; | 1324 int viewportHeight = 480; |
1328 float enforcedPageScaleFactor = 0.5f; | 1325 float enforcedPageScaleFactor = 0.5f; |
1329 | 1326 |
1330 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1327 FrameTestHelpers::WebViewHelper webViewHelper; |
1331 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); | 1328 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, nullptr, &client, nullptr, enableViewportSettings); |
1332 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1329 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1333 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); | 1330 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); |
1334 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1331 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1335 | 1332 |
1336 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1333 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1337 } | 1334 } |
1338 | 1335 |
1339 TEST_P(ParameterizedWebFrameTest, PermanentInitialPageScaleFactorOverridesPageVi
ewportInitialScale) | 1336 TEST_P(ParameterizedWebFrameTest, PermanentInitialPageScaleFactorOverridesPageVi
ewportInitialScale) |
1340 { | 1337 { |
1341 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 1338 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
1342 | 1339 |
1343 FixedLayoutTestWebViewClient client; | 1340 FixedLayoutTestWebViewClient client; |
1344 client.m_screenInfo.deviceScaleFactor = 1; | 1341 client.m_screenInfo.deviceScaleFactor = 1; |
1345 int viewportWidth = 640; | 1342 int viewportWidth = 640; |
1346 int viewportHeight = 480; | 1343 int viewportHeight = 480; |
1347 float enforcedPageScaleFactor = 0.5f; | 1344 float enforcedPageScaleFactor = 0.5f; |
1348 | 1345 |
1349 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1346 FrameTestHelpers::WebViewHelper webViewHelper; |
1350 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.
html", true, nullptr, &client, nullptr, enableViewportSettings); | 1347 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale.
html", true, nullptr, &client, nullptr, enableViewportSettings); |
1351 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); | 1348 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); |
1352 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1349 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1353 | 1350 |
1354 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1351 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1355 } | 1352 } |
1356 | 1353 |
1357 TEST_P(ParameterizedWebFrameTest, SmallPermanentInitialPageScaleFactorIsClobbere
d) | 1354 TEST_P(ParameterizedWebFrameTest, SmallPermanentInitialPageScaleFactorIsClobbere
d) |
1358 { | 1355 { |
1359 const char* pages[] = { | 1356 const char* pages[] = { |
1360 // These pages trigger the clobbering condition. There must be a matchin
g item in "pageScaleFactors" array. | 1357 // These pages trigger the clobbering condition. There must be a matchin
g item in "pageScaleFactors" array. |
1361 "viewport-device-0.5x-initial-scale.html", | 1358 "viewport-device-0.5x-initial-scale.html", |
1362 "viewport-initial-scale-1.html", | 1359 "viewport-initial-scale-1.html", |
1363 // These ones do not. | 1360 // These ones do not. |
1364 "viewport-auto-initial-scale.html", | 1361 "viewport-auto-initial-scale.html", |
1365 "viewport-target-densitydpi-device-and-fixed-width.html" | 1362 "viewport-target-densitydpi-device-and-fixed-width.html" |
1366 }; | 1363 }; |
1367 float pageScaleFactors[] = { 0.5f, 1.0f }; | 1364 float pageScaleFactors[] = { 0.5f, 1.0f }; |
1368 for (size_t i = 0; i < WTF_ARRAY_LENGTH(pages); ++i) | 1365 for (size_t i = 0; i < WTF_ARRAY_LENGTH(pages); ++i) |
1369 registerMockedHttpURLLoad(pages[i]); | 1366 registerMockedHttpURLLoad(pages[i]); |
1370 | 1367 |
1371 FixedLayoutTestWebViewClient client; | 1368 FixedLayoutTestWebViewClient client; |
1372 client.m_screenInfo.deviceScaleFactor = 1; | 1369 client.m_screenInfo.deviceScaleFactor = 1; |
1373 int viewportWidth = 400; | 1370 int viewportWidth = 400; |
1374 int viewportHeight = 300; | 1371 int viewportHeight = 300; |
1375 float enforcedPageScaleFactor = 0.75f; | 1372 float enforcedPageScaleFactor = 0.75f; |
1376 | 1373 |
1377 for (size_t i = 0; i < WTF_ARRAY_LENGTH(pages); ++i) { | 1374 for (size_t i = 0; i < WTF_ARRAY_LENGTH(pages); ++i) { |
1378 for (int quirkEnabled = 0; quirkEnabled <= 1; ++quirkEnabled) { | 1375 for (int quirkEnabled = 0; quirkEnabled <= 1; ++quirkEnabled) { |
1379 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1376 FrameTestHelpers::WebViewHelper webViewHelper; |
1380 webViewHelper.initializeAndLoad(m_baseURL + pages[i], true, nullptr,
&client, nullptr, enableViewportSettings); | 1377 webViewHelper.initializeAndLoad(m_baseURL + pages[i], true, nullptr,
&client, nullptr, enableViewportSettings); |
1381 applyViewportStyleOverride(&webViewHelper); | 1378 applyViewportStyleOverride(&webViewHelper); |
1382 webViewHelper.webView()->settings()->setClobberUserAgentInitialScale
Quirk(quirkEnabled); | 1379 webViewHelper.webView()->settings()->setClobberUserAgentInitialScale
Quirk(quirkEnabled); |
1383 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageSca
leFactor); | 1380 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageSca
leFactor); |
1384 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1381 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1385 | 1382 |
1386 float expectedPageScaleFactor = quirkEnabled && i < WTF_ARRAY_LENGTH
(pageScaleFactors) ? pageScaleFactors[i] : enforcedPageScaleFactor; | 1383 float expectedPageScaleFactor = quirkEnabled && i < WTF_ARRAY_LENGTH
(pageScaleFactors) ? pageScaleFactors[i] : enforcedPageScaleFactor; |
1387 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScal
eFactor()); | 1384 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScal
eFactor()); |
1388 } | 1385 } |
1389 } | 1386 } |
1390 } | 1387 } |
1391 | 1388 |
1392 TEST_P(ParameterizedWebFrameTest, PermanentInitialPageScaleFactorAffectsLayoutWi
dth) | 1389 TEST_P(ParameterizedWebFrameTest, PermanentInitialPageScaleFactorAffectsLayoutWi
dth) |
1393 { | 1390 { |
1394 FixedLayoutTestWebViewClient client; | 1391 FixedLayoutTestWebViewClient client; |
1395 client.m_screenInfo.deviceScaleFactor = 1; | 1392 client.m_screenInfo.deviceScaleFactor = 1; |
1396 int viewportWidth = 640; | 1393 int viewportWidth = 640; |
1397 int viewportHeight = 480; | 1394 int viewportHeight = 480; |
1398 float enforcedPageScaleFactor = 0.5; | 1395 float enforcedPageScaleFactor = 0.5; |
1399 | 1396 |
1400 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1397 FrameTestHelpers::WebViewHelper webViewHelper; |
1401 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); | 1398 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); |
1402 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1399 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1403 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1400 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1404 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1401 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1405 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); | 1402 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); |
1406 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1403 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1407 | 1404 |
1408 EXPECT_EQ(viewportWidth / enforcedPageScaleFactor, webViewHelper.webView()->
mainFrameImpl()->frameView()->contentsSize().width()); | 1405 EXPECT_EQ(viewportWidth / enforcedPageScaleFactor, webViewHelper.webView()->
mainFrameImpl()->frameView()->contentsSize().width()); |
1409 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1406 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1410 } | 1407 } |
1411 | 1408 |
1412 TEST_P(ParameterizedWebFrameTest, DocumentElementClientHeightWorksWithWrapConten
tMode) | 1409 TEST_P(ParameterizedWebFrameTest, DocumentElementClientHeightWorksWithWrapConten
tMode) |
1413 { | 1410 { |
1414 registerMockedHttpURLLoad("0-by-0.html"); | 1411 registerMockedHttpURLLoad("0-by-0.html"); |
1415 | 1412 |
1416 FixedLayoutTestWebViewClient client; | 1413 FixedLayoutTestWebViewClient client; |
1417 client.m_screenInfo.deviceScaleFactor = 1; | 1414 client.m_screenInfo.deviceScaleFactor = 1; |
1418 int viewportWidth = 640; | 1415 int viewportWidth = 640; |
1419 int viewportHeight = 480; | 1416 int viewportHeight = 480; |
1420 | 1417 |
1421 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1418 FrameTestHelpers::WebViewHelper webViewHelper; |
1422 | 1419 |
1423 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c
lient, nullptr, configureAndroid); | 1420 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c
lient, nullptr, configureAndroid); |
1424 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); | 1421 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
1425 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1422 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1426 | 1423 |
1427 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); | 1424 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); |
1428 Document* document = frame->document(); | 1425 Document* document = frame->document(); |
1429 EXPECT_EQ(viewportHeight, document->documentElement()->clientHeight()); | 1426 EXPECT_EQ(viewportHeight, document->documentElement()->clientHeight()); |
1430 EXPECT_EQ(viewportWidth, document->documentElement()->clientWidth()); | 1427 EXPECT_EQ(viewportWidth, document->documentElement()->clientWidth()); |
1431 } | 1428 } |
1432 | 1429 |
1433 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksWithWrapContentMo
de) | 1430 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksWithWrapContentMo
de) |
1434 { | 1431 { |
1435 registerMockedHttpURLLoad("0-by-0.html"); | 1432 registerMockedHttpURLLoad("0-by-0.html"); |
1436 | 1433 |
1437 FixedLayoutTestWebViewClient client; | 1434 FixedLayoutTestWebViewClient client; |
1438 client.m_screenInfo.deviceScaleFactor = 1; | 1435 client.m_screenInfo.deviceScaleFactor = 1; |
1439 int viewportWidth = 640; | 1436 int viewportWidth = 640; |
1440 int viewportHeight = 480; | 1437 int viewportHeight = 480; |
1441 | 1438 |
1442 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1439 FrameTestHelpers::WebViewHelper webViewHelper; |
1443 | 1440 |
1444 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c
lient, nullptr, configureAndroid); | 1441 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c
lient, nullptr, configureAndroid); |
1445 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); | 1442 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
1446 PaintLayerCompositor* compositor = webViewHelper.webView()->compositor(); | 1443 PaintLayerCompositor* compositor = webViewHelper.webView()->compositor(); |
1447 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().width()); | 1444 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().width()); |
1448 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); | 1445 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); |
1449 EXPECT_EQ(0.0, compositor->containerLayer()->size().width()); | 1446 EXPECT_EQ(0.0, compositor->containerLayer()->size().width()); |
1450 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); | 1447 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); |
1451 | 1448 |
1452 webViewHelper.resize(WebSize(viewportWidth, 0)); | 1449 webViewHelper.resize(WebSize(viewportWidth, 0)); |
(...skipping 21 matching lines...) Expand all Loading... |
1474 | 1471 |
1475 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeight) | 1472 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeight) |
1476 { | 1473 { |
1477 registerMockedHttpURLLoad("200-by-300.html"); | 1474 registerMockedHttpURLLoad("200-by-300.html"); |
1478 | 1475 |
1479 FixedLayoutTestWebViewClient client; | 1476 FixedLayoutTestWebViewClient client; |
1480 client.m_screenInfo.deviceScaleFactor = 1; | 1477 client.m_screenInfo.deviceScaleFactor = 1; |
1481 int viewportWidth = 640; | 1478 int viewportWidth = 640; |
1482 int viewportHeight = 480; | 1479 int viewportHeight = 480; |
1483 | 1480 |
1484 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1481 FrameTestHelpers::WebViewHelper webViewHelper; |
1485 | 1482 |
1486 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr
, &client, nullptr, enableViewportSettings); | 1483 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr
, &client, nullptr, enableViewportSettings); |
1487 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1484 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1488 | 1485 |
1489 EXPECT_LE(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->layoutSize().height()); | 1486 EXPECT_LE(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie
w()->layoutSize().height()); |
1490 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); | 1487 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
1491 EXPECT_TRUE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLayo
ut()); | 1488 EXPECT_TRUE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLayo
ut()); |
1492 | 1489 |
1493 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); | 1490 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); |
1494 | 1491 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations
) | 1634 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations
) |
1638 { | 1635 { |
1639 registerMockedHttpURLLoad("200-by-300.html"); | 1636 registerMockedHttpURLLoad("200-by-300.html"); |
1640 registerMockedHttpURLLoad("large-div.html"); | 1637 registerMockedHttpURLLoad("large-div.html"); |
1641 | 1638 |
1642 FixedLayoutTestWebViewClient client; | 1639 FixedLayoutTestWebViewClient client; |
1643 client.m_screenInfo.deviceScaleFactor = 1; | 1640 client.m_screenInfo.deviceScaleFactor = 1; |
1644 int viewportWidth = 640; | 1641 int viewportWidth = 640; |
1645 int viewportHeight = 480; | 1642 int viewportHeight = 480; |
1646 | 1643 |
1647 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1644 FrameTestHelpers::WebViewHelper webViewHelper; |
1648 | 1645 |
1649 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr
, &client, nullptr, enableViewportSettings); | 1646 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr
, &client, nullptr, enableViewportSettings); |
1650 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); | 1647 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
1651 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1648 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1652 | 1649 |
1653 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); | 1650 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); |
1654 webViewHelper.webView()->updateAllLifecyclePhases(); | 1651 webViewHelper.webView()->updateAllLifecyclePhases(); |
1655 | 1652 |
1656 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); | 1653 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); |
1657 } | 1654 } |
1658 | 1655 |
1659 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWithWideViewportQuirk) | 1656 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWithWideViewportQuirk) |
1660 { | 1657 { |
1661 registerMockedHttpURLLoad("200-by-300.html"); | 1658 registerMockedHttpURLLoad("200-by-300.html"); |
1662 | 1659 |
1663 FixedLayoutTestWebViewClient client; | 1660 FixedLayoutTestWebViewClient client; |
1664 client.m_screenInfo.deviceScaleFactor = 1; | 1661 client.m_screenInfo.deviceScaleFactor = 1; |
1665 int viewportWidth = 640; | 1662 int viewportWidth = 640; |
1666 int viewportHeight = 480; | 1663 int viewportHeight = 480; |
1667 | 1664 |
1668 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1665 FrameTestHelpers::WebViewHelper webViewHelper; |
1669 | 1666 |
1670 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr
, &client, nullptr, enableViewportSettings); | 1667 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr
, &client, nullptr, enableViewportSettings); |
1671 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1668 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1672 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1669 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1673 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); | 1670 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
1674 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1671 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1675 | 1672 |
1676 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); | 1673 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi
ze().height()); |
1677 } | 1674 } |
1678 | 1675 |
1679 TEST_P(ParameterizedWebFrameTest, WideViewportAndWideContentWithInitialScale) | 1676 TEST_P(ParameterizedWebFrameTest, WideViewportAndWideContentWithInitialScale) |
1680 { | 1677 { |
1681 registerMockedHttpURLLoad("wide_document_width_viewport.html"); | 1678 registerMockedHttpURLLoad("wide_document_width_viewport.html"); |
1682 registerMockedHttpURLLoad("white-1x1.png"); | 1679 registerMockedHttpURLLoad("white-1x1.png"); |
1683 | 1680 |
1684 FixedLayoutTestWebViewClient client; | 1681 FixedLayoutTestWebViewClient client; |
1685 client.m_screenInfo.deviceScaleFactor = 1; | 1682 client.m_screenInfo.deviceScaleFactor = 1; |
1686 int viewportWidth = 600; | 1683 int viewportWidth = 600; |
1687 int viewportHeight = 800; | 1684 int viewportHeight = 800; |
1688 | 1685 |
1689 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1686 FrameTestHelpers::WebViewHelper webViewHelper; |
1690 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); | 1687 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); |
1691 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1688 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1692 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1689 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1693 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1690 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
1694 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1691 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1695 | 1692 |
1696 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "wide_document_width_viewport.html"); | 1693 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "wide_document_width_viewport.html"); |
1697 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1694 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1698 | 1695 |
1699 int wideDocumentWidth = 800; | 1696 int wideDocumentWidth = 800; |
1700 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; | 1697 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; |
1701 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); | 1698 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); |
1702 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); | 1699 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); |
1703 } | 1700 } |
1704 | 1701 |
1705 TEST_P(ParameterizedWebFrameTest, WideViewportQuirkClobbersHeight) | 1702 TEST_P(ParameterizedWebFrameTest, WideViewportQuirkClobbersHeight) |
1706 { | 1703 { |
1707 registerMockedHttpURLLoad("viewport-height-1000.html"); | 1704 registerMockedHttpURLLoad("viewport-height-1000.html"); |
1708 | 1705 |
1709 FixedLayoutTestWebViewClient client; | 1706 FixedLayoutTestWebViewClient client; |
1710 client.m_screenInfo.deviceScaleFactor = 1; | 1707 client.m_screenInfo.deviceScaleFactor = 1; |
1711 int viewportWidth = 600; | 1708 int viewportWidth = 600; |
1712 int viewportHeight = 800; | 1709 int viewportHeight = 800; |
1713 | 1710 |
1714 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1711 FrameTestHelpers::WebViewHelper webViewHelper; |
1715 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); | 1712 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); |
1716 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1713 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1717 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1714 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1718 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1715 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
1719 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1716 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1720 | 1717 |
1721 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-height-1000.html"); | 1718 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-height-1000.html"); |
1722 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1719 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1723 | 1720 |
1724 EXPECT_EQ(800, webViewHelper.webView()->mainFrameImpl()->frameView()->layout
Size().height()); | 1721 EXPECT_EQ(800, webViewHelper.webView()->mainFrameImpl()->frameView()->layout
Size().height()); |
1725 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1722 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
1726 } | 1723 } |
1727 | 1724 |
1728 TEST_P(ParameterizedWebFrameTest, LayoutSize320Quirk) | 1725 TEST_P(ParameterizedWebFrameTest, LayoutSize320Quirk) |
1729 { | 1726 { |
1730 registerMockedHttpURLLoad("viewport/viewport-30.html"); | 1727 registerMockedHttpURLLoad("viewport/viewport-30.html"); |
1731 | 1728 |
1732 FixedLayoutTestWebViewClient client; | 1729 FixedLayoutTestWebViewClient client; |
1733 client.m_screenInfo.deviceScaleFactor = 1; | 1730 client.m_screenInfo.deviceScaleFactor = 1; |
1734 int viewportWidth = 600; | 1731 int viewportWidth = 600; |
1735 int viewportHeight = 800; | 1732 int viewportHeight = 800; |
1736 | 1733 |
1737 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1734 FrameTestHelpers::WebViewHelper webViewHelper; |
1738 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); | 1735 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp
tr, enableViewportSettings); |
1739 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1736 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1740 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1737 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1741 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1738 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
1742 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1739 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1743 | 1740 |
1744 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); | 1741 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); |
1745 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1742 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1746 | 1743 |
1747 EXPECT_EQ(600, webViewHelper.webView()->mainFrameImpl()->frameView()->layout
Size().width()); | 1744 EXPECT_EQ(600, webViewHelper.webView()->mainFrameImpl()->frameView()->layout
Size().width()); |
(...skipping 30 matching lines...) Expand all Loading... |
1778 | 1775 |
1779 TEST_P(ParameterizedWebFrameTest, ZeroValuesQuirk) | 1776 TEST_P(ParameterizedWebFrameTest, ZeroValuesQuirk) |
1780 { | 1777 { |
1781 registerMockedHttpURLLoad("viewport-zero-values.html"); | 1778 registerMockedHttpURLLoad("viewport-zero-values.html"); |
1782 | 1779 |
1783 FixedLayoutTestWebViewClient client; | 1780 FixedLayoutTestWebViewClient client; |
1784 client.m_screenInfo.deviceScaleFactor = 1; | 1781 client.m_screenInfo.deviceScaleFactor = 1; |
1785 int viewportWidth = 640; | 1782 int viewportWidth = 640; |
1786 int viewportHeight = 480; | 1783 int viewportHeight = 480; |
1787 | 1784 |
1788 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1785 FrameTestHelpers::WebViewHelper webViewHelper; |
1789 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 1786 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
1790 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); | 1787 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); |
1791 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1788 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1792 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1789 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
1793 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-zero-values.html"); | 1790 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-zero-values.html"); |
1794 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1791 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1795 | 1792 |
1796 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->layoutSize().width()); | 1793 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->layoutSize().width()); |
1797 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1794 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
1798 | 1795 |
1799 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1796 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1800 webViewHelper.webView()->updateAllLifecyclePhases(); | 1797 webViewHelper.webView()->updateAllLifecyclePhases(); |
1801 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->layoutSize().width()); | 1798 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView
()->layoutSize().width()); |
1802 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1799 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
1803 } | 1800 } |
1804 | 1801 |
1805 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrolling) | 1802 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrolling) |
1806 { | 1803 { |
1807 registerMockedHttpURLLoad("body-overflow-hidden.html"); | 1804 registerMockedHttpURLLoad("body-overflow-hidden.html"); |
1808 | 1805 |
1809 FixedLayoutTestWebViewClient client; | 1806 FixedLayoutTestWebViewClient client; |
1810 client.m_screenInfo.deviceScaleFactor = 1; | 1807 client.m_screenInfo.deviceScaleFactor = 1; |
1811 int viewportWidth = 640; | 1808 int viewportWidth = 640; |
1812 int viewportHeight = 480; | 1809 int viewportHeight = 480; |
1813 | 1810 |
1814 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1811 FrameTestHelpers::WebViewHelper webViewHelper; |
1815 webViewHelper.initialize(true, nullptr, &client, nullptr); | 1812 webViewHelper.initialize(true, nullptr, &client, nullptr); |
1816 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1813 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
1817 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1814 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1818 | 1815 |
1819 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); | 1816 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); |
1820 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); | 1817 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); |
1821 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); | 1818 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); |
1822 } | 1819 } |
1823 | 1820 |
1824 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrollingWithSetCanHaveS
crollbars) | 1821 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrollingWithSetCanHaveS
crollbars) |
1825 { | 1822 { |
1826 registerMockedHttpURLLoad("body-overflow-hidden-short.html"); | 1823 registerMockedHttpURLLoad("body-overflow-hidden-short.html"); |
1827 | 1824 |
1828 FixedLayoutTestWebViewClient client; | 1825 FixedLayoutTestWebViewClient client; |
1829 client.m_screenInfo.deviceScaleFactor = 1; | 1826 client.m_screenInfo.deviceScaleFactor = 1; |
1830 int viewportWidth = 640; | 1827 int viewportWidth = 640; |
1831 int viewportHeight = 480; | 1828 int viewportHeight = 480; |
1832 | 1829 |
1833 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1830 FrameTestHelpers::WebViewHelper webViewHelper; |
1834 webViewHelper.initialize(true, nullptr, &client, nullptr); | 1831 webViewHelper.initialize(true, nullptr, &client, nullptr); |
1835 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden-short.html"); | 1832 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden-short.html"); |
1836 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1833 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1837 | 1834 |
1838 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); | 1835 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); |
1839 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); | 1836 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); |
1840 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); | 1837 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); |
1841 | 1838 |
1842 webViewHelper.webView()->mainFrameImpl()->setCanHaveScrollbars(true); | 1839 webViewHelper.webView()->mainFrameImpl()->setCanHaveScrollbars(true); |
1843 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); | 1840 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); |
(...skipping 22 matching lines...) Expand all Loading... |
1866 TEST_P(ParameterizedWebFrameTest, NonZeroValuesNoQuirk) | 1863 TEST_P(ParameterizedWebFrameTest, NonZeroValuesNoQuirk) |
1867 { | 1864 { |
1868 registerMockedHttpURLLoad("viewport-nonzero-values.html"); | 1865 registerMockedHttpURLLoad("viewport-nonzero-values.html"); |
1869 | 1866 |
1870 FixedLayoutTestWebViewClient client; | 1867 FixedLayoutTestWebViewClient client; |
1871 client.m_screenInfo.deviceScaleFactor = 1; | 1868 client.m_screenInfo.deviceScaleFactor = 1; |
1872 int viewportWidth = 640; | 1869 int viewportWidth = 640; |
1873 int viewportHeight = 480; | 1870 int viewportHeight = 480; |
1874 float expectedPageScaleFactor = 0.5f; | 1871 float expectedPageScaleFactor = 0.5f; |
1875 | 1872 |
1876 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1873 FrameTestHelpers::WebViewHelper webViewHelper; |
1877 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 1874 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
1878 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); | 1875 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); |
1879 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1876 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1880 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-nonzero-values.html"); | 1877 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-nonzero-values.html"); |
1881 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1878 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1882 | 1879 |
1883 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webView()->
mainFrameImpl()->frameView()->layoutSize().width()); | 1880 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webView()->
mainFrameImpl()->frameView()->layoutSize().width()); |
1884 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1881 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1885 | 1882 |
1886 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1883 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1887 webViewHelper.webView()->updateAllLifecyclePhases(); | 1884 webViewHelper.webView()->updateAllLifecyclePhases(); |
1888 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webView()->
mainFrameImpl()->frameView()->layoutSize().width()); | 1885 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webView()->
mainFrameImpl()->frameView()->layoutSize().width()); |
1889 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1886 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1890 } | 1887 } |
1891 | 1888 |
1892 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorDoesNotLayout) | 1889 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorDoesNotLayout) |
1893 { | 1890 { |
1894 registerMockedHttpURLLoad("fixed_layout.html"); | 1891 registerMockedHttpURLLoad("fixed_layout.html"); |
1895 | 1892 |
1896 FixedLayoutTestWebViewClient client; | 1893 FixedLayoutTestWebViewClient client; |
1897 client.m_screenInfo.deviceScaleFactor = 1; | 1894 client.m_screenInfo.deviceScaleFactor = 1; |
1898 // Small viewport to ensure there are always scrollbars. | 1895 // Small viewport to ensure there are always scrollbars. |
1899 int viewportWidth = 64; | 1896 int viewportWidth = 64; |
1900 int viewportHeight = 48; | 1897 int viewportHeight = 48; |
1901 | 1898 |
1902 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1899 FrameTestHelpers::WebViewHelper webViewHelper; |
1903 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 1900 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
1904 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1901 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1905 | 1902 |
1906 int prevLayoutCount = webViewHelper.webView()->mainFrameImpl()->frameView()-
>layoutCount(); | 1903 int prevLayoutCount = webViewHelper.webView()->mainFrameImpl()->frameView()-
>layoutCount(); |
1907 webViewHelper.webView()->setPageScaleFactor(3); | 1904 webViewHelper.webView()->setPageScaleFactor(3); |
1908 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay
out()); | 1905 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay
out()); |
1909 EXPECT_EQ(prevLayoutCount, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutCount()); | 1906 EXPECT_EQ(prevLayoutCount, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutCount()); |
1910 } | 1907 } |
1911 | 1908 |
1912 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNot
Layout) | 1909 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNot
Layout) |
1913 { | 1910 { |
1914 registerMockedHttpURLLoad("fixed_layout.html"); | 1911 registerMockedHttpURLLoad("fixed_layout.html"); |
1915 | 1912 |
1916 FixedLayoutTestWebViewClient client; | 1913 FixedLayoutTestWebViewClient client; |
1917 client.m_screenInfo.deviceScaleFactor = 1; | 1914 client.m_screenInfo.deviceScaleFactor = 1; |
1918 int viewportWidth = 640; | 1915 int viewportWidth = 640; |
1919 int viewportHeight = 480; | 1916 int viewportHeight = 480; |
1920 | 1917 |
1921 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1918 FrameTestHelpers::WebViewHelper webViewHelper; |
1922 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 1919 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
1923 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1920 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1924 | 1921 |
1925 int prevLayoutCount = webViewHelper.webView()->mainFrameImpl()->frameView()-
>layoutCount(); | 1922 int prevLayoutCount = webViewHelper.webView()->mainFrameImpl()->frameView()-
>layoutCount(); |
1926 webViewHelper.webView()->setPageScaleFactor(30); | 1923 webViewHelper.webView()->setPageScaleFactor(30); |
1927 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay
out()); | 1924 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay
out()); |
1928 EXPECT_EQ(prevLayoutCount, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutCount()); | 1925 EXPECT_EQ(prevLayoutCount, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutCount()); |
1929 | 1926 |
1930 } | 1927 } |
1931 | 1928 |
1932 TEST_P(ParameterizedWebFrameTest, pageScaleFactorWrittenToHistoryItem) | 1929 TEST_P(ParameterizedWebFrameTest, pageScaleFactorWrittenToHistoryItem) |
1933 { | 1930 { |
1934 registerMockedHttpURLLoad("fixed_layout.html"); | 1931 registerMockedHttpURLLoad("fixed_layout.html"); |
1935 | 1932 |
1936 FixedLayoutTestWebViewClient client; | 1933 FixedLayoutTestWebViewClient client; |
1937 client.m_screenInfo.deviceScaleFactor = 1; | 1934 client.m_screenInfo.deviceScaleFactor = 1; |
1938 int viewportWidth = 640; | 1935 int viewportWidth = 640; |
1939 int viewportHeight = 480; | 1936 int viewportHeight = 480; |
1940 | 1937 |
1941 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1938 FrameTestHelpers::WebViewHelper webViewHelper; |
1942 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 1939 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
1943 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1940 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1944 | 1941 |
1945 webViewHelper.webView()->setPageScaleFactor(3); | 1942 webViewHelper.webView()->setPageScaleFactor(3); |
1946 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loa
der().currentItem()->pageScaleFactor()); | 1943 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loa
der().currentItem()->pageScaleFactor()); |
1947 } | 1944 } |
1948 | 1945 |
1949 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) | 1946 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) |
1950 { | 1947 { |
1951 registerMockedHttpURLLoad("fixed_layout.html"); | 1948 registerMockedHttpURLLoad("fixed_layout.html"); |
1952 | 1949 |
1953 FixedLayoutTestWebViewClient client; | 1950 FixedLayoutTestWebViewClient client; |
1954 client.m_screenInfo.deviceScaleFactor = 1; | 1951 client.m_screenInfo.deviceScaleFactor = 1; |
1955 int viewportWidth = 640; | 1952 int viewportWidth = 640; |
1956 int viewportHeight = 480; | 1953 int viewportHeight = 480; |
1957 | 1954 |
1958 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1955 FrameTestHelpers::WebViewHelper webViewHelper; |
1959 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); | 1956 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett
ings); |
1960 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 1957 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
1961 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); | 1958 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); |
1962 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1959 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1963 | 1960 |
1964 int defaultFixedLayoutWidth = 980; | 1961 int defaultFixedLayoutWidth = 980; |
1965 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; | 1962 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; |
1966 EXPECT_EQ(minimumPageScaleFactor, toLocalFrame(webViewHelper.webView()->page
()->mainFrame())->loader().currentItem()->pageScaleFactor()); | 1963 EXPECT_EQ(minimumPageScaleFactor, toLocalFrame(webViewHelper.webView()->page
()->mainFrame())->loader().currentItem()->pageScaleFactor()); |
1967 } | 1964 } |
1968 | 1965 |
1969 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) | 1966 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) |
1970 { | 1967 { |
1971 registerMockedHttpURLLoad("large-div.html"); | 1968 registerMockedHttpURLLoad("large-div.html"); |
1972 | 1969 |
1973 FixedLayoutTestWebViewClient client; | 1970 FixedLayoutTestWebViewClient client; |
1974 client.m_screenInfo.deviceScaleFactor = 1; | 1971 client.m_screenInfo.deviceScaleFactor = 1; |
1975 // Small viewport to ensure there are always scrollbars. | 1972 // Small viewport to ensure there are always scrollbars. |
1976 int viewportWidth = 64; | 1973 int viewportWidth = 64; |
1977 int viewportHeight = 48; | 1974 int viewportHeight = 48; |
1978 | 1975 |
1979 FrameTestHelpers::WebViewHelper webViewHelper(this); | 1976 FrameTestHelpers::WebViewHelper webViewHelper; |
1980 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr,
&client, nullptr, enableViewportSettings); | 1977 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr,
&client, nullptr, enableViewportSettings); |
1981 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1978 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1982 | 1979 |
1983 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); | 1980 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); |
1984 int viewportWidthMinusScrollbar = viewportWidth; | 1981 int viewportWidthMinusScrollbar = viewportWidth; |
1985 int viewportHeightMinusScrollbar = viewportHeight; | 1982 int viewportHeightMinusScrollbar = viewportHeight; |
1986 | 1983 |
1987 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScroll
bar()) | 1984 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScroll
bar()) |
1988 viewportWidthMinusScrollbar -= 15; | 1985 viewportWidthMinusScrollbar -= 15; |
1989 | 1986 |
(...skipping 17 matching lines...) Expand all Loading... |
2007 | 2004 |
2008 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesNotApplyCssTransform) | 2005 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesNotApplyCssTransform) |
2009 { | 2006 { |
2010 registerMockedHttpURLLoad("fixed_layout.html"); | 2007 registerMockedHttpURLLoad("fixed_layout.html"); |
2011 | 2008 |
2012 FixedLayoutTestWebViewClient client; | 2009 FixedLayoutTestWebViewClient client; |
2013 client.m_screenInfo.deviceScaleFactor = 1; | 2010 client.m_screenInfo.deviceScaleFactor = 1; |
2014 int viewportWidth = 640; | 2011 int viewportWidth = 640; |
2015 int viewportHeight = 480; | 2012 int viewportHeight = 480; |
2016 | 2013 |
2017 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2014 FrameTestHelpers::WebViewHelper webViewHelper; |
2018 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 2015 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
2019 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2016 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2020 | 2017 |
2021 webViewHelper.webView()->setPageScaleFactor(2); | 2018 webViewHelper.webView()->setPageScaleFactor(2); |
2022 | 2019 |
2023 EXPECT_EQ(980, toLocalFrame(webViewHelper.webView()->page()->mainFrame())->c
ontentLayoutItem().documentRect().width()); | 2020 EXPECT_EQ(980, toLocalFrame(webViewHelper.webView()->page()->mainFrame())->c
ontentLayoutItem().documentRect().width()); |
2024 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten
tsSize().width()); | 2021 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten
tsSize().width()); |
2025 } | 2022 } |
2026 | 2023 |
2027 TEST_P(ParameterizedWebFrameTest, targetDensityDpiHigh) | 2024 TEST_P(ParameterizedWebFrameTest, targetDensityDpiHigh) |
2028 { | 2025 { |
2029 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); | 2026 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); |
2030 | 2027 |
2031 FixedLayoutTestWebViewClient client; | 2028 FixedLayoutTestWebViewClient client; |
2032 // high-dpi = 240 | 2029 // high-dpi = 240 |
2033 float targetDpi = 240.0f; | 2030 float targetDpi = 240.0f; |
2034 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 2031 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
2035 int viewportWidth = 640; | 2032 int viewportWidth = 640; |
2036 int viewportHeight = 480; | 2033 int viewportHeight = 480; |
2037 | 2034 |
2038 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { | 2035 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { |
2039 float deviceScaleFactor = deviceScaleFactors[i]; | 2036 float deviceScaleFactor = deviceScaleFactors[i]; |
2040 float deviceDpi = deviceScaleFactor * 160.0f; | 2037 float deviceDpi = deviceScaleFactor * 160.0f; |
2041 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; | 2038 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; |
2042 | 2039 |
2043 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2040 FrameTestHelpers::WebViewHelper webViewHelper; |
2044 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-
high.html", true, nullptr, &client, nullptr, enableViewportSettings); | 2041 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-
high.html", true, nullptr, &client, nullptr, enableViewportSettings); |
2045 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2042 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2046 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP
I(true); | 2043 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP
I(true); |
2047 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2044 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2048 | 2045 |
2049 // We need to account for the fact that logical pixels are unconditional
ly multiplied by deviceScaleFactor to produce | 2046 // We need to account for the fact that logical pixels are unconditional
ly multiplied by deviceScaleFactor to produce |
2050 // physical pixels. | 2047 // physical pixels. |
2051 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; | 2048 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; |
2052 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webView(
)->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); | 2049 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webView(
)->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); |
2053 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView
()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); | 2050 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView
()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); |
2054 EXPECT_NEAR(1.0f / densityDpiScaleRatio, webViewHelper.webView()->pageSc
aleFactor(), 0.01f); | 2051 EXPECT_NEAR(1.0f / densityDpiScaleRatio, webViewHelper.webView()->pageSc
aleFactor(), 0.01f); |
2055 } | 2052 } |
2056 } | 2053 } |
2057 | 2054 |
2058 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDevice) | 2055 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDevice) |
2059 { | 2056 { |
2060 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); | 2057 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); |
2061 | 2058 |
2062 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 2059 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
2063 | 2060 |
2064 FixedLayoutTestWebViewClient client; | 2061 FixedLayoutTestWebViewClient client; |
2065 int viewportWidth = 640; | 2062 int viewportWidth = 640; |
2066 int viewportHeight = 480; | 2063 int viewportHeight = 480; |
2067 | 2064 |
2068 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { | 2065 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { |
2069 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; | 2066 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; |
2070 | 2067 |
2071 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2068 FrameTestHelpers::WebViewHelper webViewHelper; |
2072 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-
device.html", true, nullptr, &client, nullptr, enableViewportSettings); | 2069 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-
device.html", true, nullptr, &client, nullptr, enableViewportSettings); |
2073 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2070 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2074 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP
I(true); | 2071 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP
I(true); |
2075 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2072 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2076 | 2073 |
2077 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webVi
ewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); | 2074 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webVi
ewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); |
2078 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webV
iewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); | 2075 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webV
iewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); |
2079 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.
webView()->pageScaleFactor(), 0.01f); | 2076 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.
webView()->pageScaleFactor(), 0.01f); |
2080 } | 2077 } |
2081 } | 2078 } |
2082 | 2079 |
2083 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDeviceAndFixedWidth) | 2080 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDeviceAndFixedWidth) |
2084 { | 2081 { |
2085 registerMockedHttpURLLoad("viewport-target-densitydpi-device-and-fixed-width
.html"); | 2082 registerMockedHttpURLLoad("viewport-target-densitydpi-device-and-fixed-width
.html"); |
2086 | 2083 |
2087 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 2084 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
2088 | 2085 |
2089 FixedLayoutTestWebViewClient client; | 2086 FixedLayoutTestWebViewClient client; |
2090 int viewportWidth = 640; | 2087 int viewportWidth = 640; |
2091 int viewportHeight = 480; | 2088 int viewportHeight = 480; |
2092 | 2089 |
2093 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { | 2090 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { |
2094 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; | 2091 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; |
2095 | 2092 |
2096 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2093 FrameTestHelpers::WebViewHelper webViewHelper; |
2097 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-
device-and-fixed-width.html", true, nullptr, &client, nullptr, enableViewportSet
tings); | 2094 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi-
device-and-fixed-width.html", true, nullptr, &client, nullptr, enableViewportSet
tings); |
2098 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2095 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2099 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP
I(true); | 2096 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP
I(true); |
2100 webViewHelper.webView()->settings()->setUseWideViewport(true); | 2097 webViewHelper.webView()->settings()->setUseWideViewport(true); |
2101 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2098 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2102 | 2099 |
2103 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->fra
meView()->layoutSize().width(), 1.0f); | 2100 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->fra
meView()->layoutSize().width(), 1.0f); |
2104 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutSize().height(), 1.0f); | 2101 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutSize().height(), 1.0f); |
2105 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); | 2102 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); |
2106 } | 2103 } |
2107 } | 2104 } |
2108 | 2105 |
2109 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOne) | 2106 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOne) |
2110 { | 2107 { |
2111 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1.html"); | 2108 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1.html"); |
2112 | 2109 |
2113 FixedLayoutTestWebViewClient client; | 2110 FixedLayoutTestWebViewClient client; |
2114 client.m_screenInfo.deviceScaleFactor = 1.33f; | 2111 client.m_screenInfo.deviceScaleFactor = 1.33f; |
2115 int viewportWidth = 640; | 2112 int viewportWidth = 640; |
2116 int viewportHeight = 480; | 2113 int viewportHeight = 480; |
2117 | 2114 |
2118 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2115 FrameTestHelpers::WebViewHelper webViewHelper; |
2119 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha
n-1.html", true, nullptr, &client, nullptr, enableViewportSettings); | 2116 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha
n-1.html", true, nullptr, &client, nullptr, enableViewportSettings); |
2120 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); | 2117 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); |
2121 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2118 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2122 webViewHelper.webView()->settings()->setUseWideViewport(false); | 2119 webViewHelper.webView()->settings()->setUseWideViewport(false); |
2123 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2120 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2124 | 2121 |
2125 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe
lper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); | 2122 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe
lper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); |
2126 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH
elper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); | 2123 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH
elper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); |
2127 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV
iew()->pageScaleFactor(), 0.01f); | 2124 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV
iew()->pageScaleFactor(), 0.01f); |
2128 } | 2125 } |
2129 | 2126 |
2130 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOneWithDeviceWid
th) | 2127 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOneWithDeviceWid
th) |
2131 { | 2128 { |
2132 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1-device-width.h
tml"); | 2129 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1-device-width.h
tml"); |
2133 | 2130 |
2134 FixedLayoutTestWebViewClient client; | 2131 FixedLayoutTestWebViewClient client; |
2135 client.m_screenInfo.deviceScaleFactor = 1.33f; | 2132 client.m_screenInfo.deviceScaleFactor = 1.33f; |
2136 int viewportWidth = 640; | 2133 int viewportWidth = 640; |
2137 int viewportHeight = 480; | 2134 int viewportHeight = 480; |
2138 | 2135 |
2139 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2136 FrameTestHelpers::WebViewHelper webViewHelper; |
2140 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha
n-1-device-width.html", true, nullptr, &client, nullptr, enableViewportSettings)
; | 2137 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha
n-1-device-width.html", true, nullptr, &client, nullptr, enableViewportSettings)
; |
2141 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); | 2138 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); |
2142 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2139 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2143 webViewHelper.webView()->settings()->setUseWideViewport(false); | 2140 webViewHelper.webView()->settings()->setUseWideViewport(false); |
2144 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2141 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2145 | 2142 |
2146 const float pageZoom = 0.25f; | 2143 const float pageZoom = 0.25f; |
2147 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom
, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1
.0f); | 2144 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom
, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1
.0f); |
2148 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo
m, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().height(),
1.0f); | 2145 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo
m, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().height(),
1.0f); |
2149 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV
iew()->pageScaleFactor(), 0.01f); | 2146 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV
iew()->pageScaleFactor(), 0.01f); |
2150 } | 2147 } |
2151 | 2148 |
2152 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndNoViewportWithInitialPageScal
eOverride) | 2149 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndNoViewportWithInitialPageScal
eOverride) |
2153 { | 2150 { |
2154 registerMockedHttpURLLoad("large-div.html"); | 2151 registerMockedHttpURLLoad("large-div.html"); |
2155 | 2152 |
2156 FixedLayoutTestWebViewClient client; | 2153 FixedLayoutTestWebViewClient client; |
2157 int viewportWidth = 640; | 2154 int viewportWidth = 640; |
2158 int viewportHeight = 480; | 2155 int viewportHeight = 480; |
2159 float enforcedPageScaleFactor = 5.0f; | 2156 float enforcedPageScaleFactor = 5.0f; |
2160 | 2157 |
2161 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2158 FrameTestHelpers::WebViewHelper webViewHelper; |
2162 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr,
&client, nullptr, enableViewportSettings); | 2159 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr,
&client, nullptr, enableViewportSettings); |
2163 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 2160 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
2164 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2161 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2165 webViewHelper.webView()->settings()->setUseWideViewport(false); | 2162 webViewHelper.webView()->settings()->setUseWideViewport(false); |
2166 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); | 2163 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); |
2167 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2164 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2168 | 2165 |
2169 EXPECT_NEAR(viewportWidth / enforcedPageScaleFactor, webViewHelper.webView()
->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); | 2166 EXPECT_NEAR(viewportWidth / enforcedPageScaleFactor, webViewHelper.webView()
->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); |
2170 EXPECT_NEAR(viewportHeight / enforcedPageScaleFactor, webViewHelper.webView(
)->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); | 2167 EXPECT_NEAR(viewportHeight / enforcedPageScaleFactor, webViewHelper.webView(
)->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); |
2171 EXPECT_NEAR(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFacto
r(), 0.01f); | 2168 EXPECT_NEAR(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFacto
r(), 0.01f); |
2172 } | 2169 } |
2173 | 2170 |
2174 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScale) | 2171 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScale) |
2175 { | 2172 { |
2176 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html"
); | 2173 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html"
); |
2177 | 2174 |
2178 FixedLayoutTestWebViewClient client; | 2175 FixedLayoutTestWebViewClient client; |
2179 int viewportWidth = 640; | 2176 int viewportWidth = 640; |
2180 int viewportHeight = 480; | 2177 int viewportHeight = 480; |
2181 | 2178 |
2182 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2179 FrameTestHelpers::WebViewHelper webViewHelper; |
2183 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user
-scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings); | 2180 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user
-scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings); |
2184 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru
e); | 2181 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru
e); |
2185 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2182 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2186 | 2183 |
2187 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutSize().width(), 1.0f); | 2184 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutSize().width(), 1.0f); |
2188 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameV
iew()->layoutSize().height(), 1.0f); | 2185 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameV
iew()->layoutSize().height(), 1.0f); |
2189 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); | 2186 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); |
2190 } | 2187 } |
2191 | 2188 |
2192 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForNonW
ideViewport) | 2189 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForNonW
ideViewport) |
2193 { | 2190 { |
2194 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html"
); | 2191 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html"
); |
2195 | 2192 |
2196 FixedLayoutTestWebViewClient client; | 2193 FixedLayoutTestWebViewClient client; |
2197 client.m_screenInfo.deviceScaleFactor = 1.33f; | 2194 client.m_screenInfo.deviceScaleFactor = 1.33f; |
2198 int viewportWidth = 640; | 2195 int viewportWidth = 640; |
2199 int viewportHeight = 480; | 2196 int viewportHeight = 480; |
2200 | 2197 |
2201 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2198 FrameTestHelpers::WebViewHelper webViewHelper; |
2202 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user
-scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings); | 2199 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user
-scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings); |
2203 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); | 2200 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); |
2204 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru
e); | 2201 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru
e); |
2205 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2202 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2206 webViewHelper.webView()->settings()->setUseWideViewport(false); | 2203 webViewHelper.webView()->settings()->setUseWideViewport(false); |
2207 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2204 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2208 | 2205 |
2209 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe
lper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); | 2206 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe
lper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); |
2210 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH
elper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); | 2207 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH
elper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); |
2211 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV
iew()->pageScaleFactor(), 0.01f); | 2208 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV
iew()->pageScaleFactor(), 0.01f); |
2212 } | 2209 } |
2213 | 2210 |
2214 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForWide
Viewport) | 2211 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForWide
Viewport) |
2215 { | 2212 { |
2216 registerMockedHttpURLLoad("viewport-2x-initial-scale-non-user-scalable.html"
); | 2213 registerMockedHttpURLLoad("viewport-2x-initial-scale-non-user-scalable.html"
); |
2217 | 2214 |
2218 FixedLayoutTestWebViewClient client; | 2215 FixedLayoutTestWebViewClient client; |
2219 int viewportWidth = 640; | 2216 int viewportWidth = 640; |
2220 int viewportHeight = 480; | 2217 int viewportHeight = 480; |
2221 | 2218 |
2222 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2219 FrameTestHelpers::WebViewHelper webViewHelper; |
2223 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale-non-u
ser-scalable.html", true, nullptr, &client, nullptr, enableViewportSettings); | 2220 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale-non-u
ser-scalable.html", true, nullptr, &client, nullptr, enableViewportSettings); |
2224 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru
e); | 2221 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru
e); |
2225 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2222 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2226 webViewHelper.webView()->settings()->setUseWideViewport(true); | 2223 webViewHelper.webView()->settings()->setUseWideViewport(true); |
2227 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2224 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2228 | 2225 |
2229 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutSize().width(), 1.0f); | 2226 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameVi
ew()->layoutSize().width(), 1.0f); |
2230 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameV
iew()->layoutSize().height(), 1.0f); | 2227 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameV
iew()->layoutSize().height(), 1.0f); |
2231 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); | 2228 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); |
2232 } | 2229 } |
2233 | 2230 |
2234 TEST_P(ParameterizedWebFrameTest, DesktopPageCanBeZoomedInWhenWideViewportIsTurn
edOff) | 2231 TEST_P(ParameterizedWebFrameTest, DesktopPageCanBeZoomedInWhenWideViewportIsTurn
edOff) |
2235 { | 2232 { |
2236 registerMockedHttpURLLoad("no_viewport_tag.html"); | 2233 registerMockedHttpURLLoad("no_viewport_tag.html"); |
2237 | 2234 |
2238 FixedLayoutTestWebViewClient client; | 2235 FixedLayoutTestWebViewClient client; |
2239 int viewportWidth = 640; | 2236 int viewportWidth = 640; |
2240 int viewportHeight = 480; | 2237 int viewportHeight = 480; |
2241 | 2238 |
2242 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2239 FrameTestHelpers::WebViewHelper webViewHelper; |
2243 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu
llptr, &client, nullptr, enableViewportSettings); | 2240 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu
llptr, &client, nullptr, enableViewportSettings); |
2244 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 2241 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
2245 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2242 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2246 webViewHelper.webView()->settings()->setUseWideViewport(false); | 2243 webViewHelper.webView()->settings()->setUseWideViewport(false); |
2247 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2244 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2248 | 2245 |
2249 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); | 2246 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); |
2250 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); | 2247 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); |
2251 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); | 2248 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); |
2252 } | 2249 } |
(...skipping 10 matching lines...) Expand all Loading... |
2263 | 2260 |
2264 void testResizeYieldsCorrectScrollAndScale(const char* url, | 2261 void testResizeYieldsCorrectScrollAndScale(const char* url, |
2265 const float initialPageScaleFacto
r, | 2262 const float initialPageScaleFacto
r, |
2266 const WebSize scrollOffset, | 2263 const WebSize scrollOffset, |
2267 const WebSize viewportSize, | 2264 const WebSize viewportSize, |
2268 const bool shouldScaleRelativeToV
iewportWidth) { | 2265 const bool shouldScaleRelativeToV
iewportWidth) { |
2269 registerMockedHttpURLLoad(url); | 2266 registerMockedHttpURLLoad(url); |
2270 | 2267 |
2271 const float aspectRatio = static_cast<float>(viewportSize.width) / viewp
ortSize.height; | 2268 const float aspectRatio = static_cast<float>(viewportSize.width) / viewp
ortSize.height; |
2272 | 2269 |
2273 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2270 FrameTestHelpers::WebViewHelper webViewHelper; |
2274 webViewHelper.initializeAndLoad(m_baseURL + url, true, nullptr, nullptr,
nullptr, enableViewportSettings); | 2271 webViewHelper.initializeAndLoad(m_baseURL + url, true, nullptr, nullptr,
nullptr, enableViewportSettings); |
2275 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 2272 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
2276 | 2273 |
2277 // Origin scrollOffsets preserved under resize. | 2274 // Origin scrollOffsets preserved under resize. |
2278 { | 2275 { |
2279 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height
)); | 2276 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height
)); |
2280 webViewHelper.webView()->setPageScaleFactor(initialPageScaleFactor); | 2277 webViewHelper.webView()->setPageScaleFactor(initialPageScaleFactor); |
2281 ASSERT_EQ(viewportSize, webViewHelper.webView()->size()); | 2278 ASSERT_EQ(viewportSize, webViewHelper.webView()->size()); |
2282 ASSERT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale
Factor()); | 2279 ASSERT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale
Factor()); |
2283 webViewHelper.resize(WebSize(viewportSize.height, viewportSize.width
)); | 2280 webViewHelper.resize(WebSize(viewportSize.height, viewportSize.width
)); |
(...skipping 12 matching lines...) Expand all Loading... |
2296 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height
* 0.8f)); | 2293 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height
* 0.8f)); |
2297 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale
Factor()); | 2294 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale
Factor()); |
2298 EXPECT_EQ(expectedScrollOffset, webViewHelper.webView()->mainFrame()
->scrollOffset()); | 2295 EXPECT_EQ(expectedScrollOffset, webViewHelper.webView()->mainFrame()
->scrollOffset()); |
2299 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height
* 0.8f)); | 2296 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height
* 0.8f)); |
2300 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale
Factor()); | 2297 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale
Factor()); |
2301 EXPECT_EQ(expectedScrollOffset, webViewHelper.webView()->mainFrame()
->scrollOffset()); | 2298 EXPECT_EQ(expectedScrollOffset, webViewHelper.webView()->mainFrame()
->scrollOffset()); |
2302 } | 2299 } |
2303 } | 2300 } |
2304 }; | 2301 }; |
2305 | 2302 |
2306 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values( | 2303 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Bool()); |
2307 FrameTestHelpers::DefaultSettingOverride, | |
2308 FrameTestHelpers::RootLayerScrollsSettingOverride)); | |
2309 | 2304 |
2310 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice
Width) | 2305 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice
Width) |
2311 { | 2306 { |
2312 // With width=device-width, pageScaleFactor is preserved across resizes as | 2307 // With width=device-width, pageScaleFactor is preserved across resizes as |
2313 // long as the content adjusts according to the device-width. | 2308 // long as the content adjusts according to the device-width. |
2314 const char* url = "resize_scroll_mobile.html"; | 2309 const char* url = "resize_scroll_mobile.html"; |
2315 const float initialPageScaleFactor = 1; | 2310 const float initialPageScaleFactor = 1; |
2316 const WebSize scrollOffset(0, 50); | 2311 const WebSize scrollOffset(0, 50); |
2317 const WebSize viewportSize(120, 160); | 2312 const WebSize viewportSize(120, 160); |
2318 const bool shouldScaleRelativeToViewportWidth = true; | 2313 const bool shouldScaleRelativeToViewportWidth = true; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 | 2360 |
2366 TEST_P(ParameterizedWebFrameTest, pageScaleFactorUpdatesScrollbars) | 2361 TEST_P(ParameterizedWebFrameTest, pageScaleFactorUpdatesScrollbars) |
2367 { | 2362 { |
2368 registerMockedHttpURLLoad("fixed_layout.html"); | 2363 registerMockedHttpURLLoad("fixed_layout.html"); |
2369 | 2364 |
2370 FixedLayoutTestWebViewClient client; | 2365 FixedLayoutTestWebViewClient client; |
2371 client.m_screenInfo.deviceScaleFactor = 1; | 2366 client.m_screenInfo.deviceScaleFactor = 1; |
2372 int viewportWidth = 640; | 2367 int viewportWidth = 640; |
2373 int viewportHeight = 480; | 2368 int viewportHeight = 480; |
2374 | 2369 |
2375 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2370 FrameTestHelpers::WebViewHelper webViewHelper; |
2376 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); | 2371 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp
tr, &client, nullptr, enableViewportSettings); |
2377 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2372 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2378 | 2373 |
2379 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); | 2374 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView(); |
2380 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width(
) - view->visibleContentRect().width()); | 2375 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width(
) - view->visibleContentRect().width()); |
2381 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height()
- view->visibleContentRect().height()); | 2376 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height()
- view->visibleContentRect().height()); |
2382 | 2377 |
2383 webViewHelper.webView()->setPageScaleFactor(10); | 2378 webViewHelper.webView()->setPageScaleFactor(10); |
2384 | 2379 |
2385 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width(
) - view->visibleContentRect().width()); | 2380 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width(
) - view->visibleContentRect().width()); |
2386 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height()
- view->visibleContentRect().height()); | 2381 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height()
- view->visibleContentRect().height()); |
2387 } | 2382 } |
2388 | 2383 |
2389 TEST_P(ParameterizedWebFrameTest, CanOverrideScaleLimits) | 2384 TEST_P(ParameterizedWebFrameTest, CanOverrideScaleLimits) |
2390 { | 2385 { |
2391 registerMockedHttpURLLoad("no_scale_for_you.html"); | 2386 registerMockedHttpURLLoad("no_scale_for_you.html"); |
2392 | 2387 |
2393 FixedLayoutTestWebViewClient client; | 2388 FixedLayoutTestWebViewClient client; |
2394 client.m_screenInfo.deviceScaleFactor = 1; | 2389 client.m_screenInfo.deviceScaleFactor = 1; |
2395 int viewportWidth = 640; | 2390 int viewportWidth = 640; |
2396 int viewportHeight = 480; | 2391 int viewportHeight = 480; |
2397 | 2392 |
2398 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2393 FrameTestHelpers::WebViewHelper webViewHelper; |
2399 webViewHelper.initializeAndLoad(m_baseURL + "no_scale_for_you.html", true, n
ullptr, &client, nullptr, enableViewportSettings); | 2394 webViewHelper.initializeAndLoad(m_baseURL + "no_scale_for_you.html", true, n
ullptr, &client, nullptr, enableViewportSettings); |
2400 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 2395 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
2401 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2396 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2402 | 2397 |
2403 EXPECT_EQ(2.0f, webViewHelper.webView()->minimumPageScaleFactor()); | 2398 EXPECT_EQ(2.0f, webViewHelper.webView()->minimumPageScaleFactor()); |
2404 EXPECT_EQ(2.0f, webViewHelper.webView()->maximumPageScaleFactor()); | 2399 EXPECT_EQ(2.0f, webViewHelper.webView()->maximumPageScaleFactor()); |
2405 | 2400 |
2406 webViewHelper.webView()->setIgnoreViewportTagScaleLimits(true); | 2401 webViewHelper.webView()->setIgnoreViewportTagScaleLimits(true); |
2407 webViewHelper.webView()->updateAllLifecyclePhases(); | 2402 webViewHelper.webView()->updateAllLifecyclePhases(); |
2408 | 2403 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2473 } | 2468 } |
2474 | 2469 |
2475 TEST_P(ParameterizedWebFrameTest, DivAutoZoomParamsTest) | 2470 TEST_P(ParameterizedWebFrameTest, DivAutoZoomParamsTest) |
2476 { | 2471 { |
2477 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); | 2472 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
2478 | 2473 |
2479 const float deviceScaleFactor = 2.0f; | 2474 const float deviceScaleFactor = 2.0f; |
2480 int viewportWidth = 640 / deviceScaleFactor; | 2475 int viewportWidth = 640 / deviceScaleFactor; |
2481 int viewportHeight = 1280 / deviceScaleFactor; | 2476 int viewportHeight = 1280 / deviceScaleFactor; |
2482 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2477 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2483 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2478 FrameTestHelpers::WebViewHelper webViewHelper; |
2484 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html", false, nullptr, nullptr, nullptr, configureAndroid); | 2479 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html", false, nullptr, nullptr, nullptr, configureAndroid); |
2485 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2480 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2486 webViewHelper.webView()->setDefaultPageScaleLimits(0.01f, 4); | 2481 webViewHelper.webView()->setDefaultPageScaleLimits(0.01f, 4); |
2487 webViewHelper.webView()->setPageScaleFactor(0.5f); | 2482 webViewHelper.webView()->setPageScaleFactor(0.5f); |
2488 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2483 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2489 | 2484 |
2490 WebRect wideDiv(200, 100, 400, 150); | 2485 WebRect wideDiv(200, 100, 400, 150); |
2491 WebRect tallDiv(200, 300, 400, 800); | 2486 WebRect tallDiv(200, 300, 400, 800); |
2492 WebPoint doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50); | 2487 WebPoint doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50); |
2493 WebPoint doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50); | 2488 WebPoint doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 } | 2520 } |
2526 | 2521 |
2527 TEST_P(ParameterizedWebFrameTest, DivAutoZoomWideDivTest) | 2522 TEST_P(ParameterizedWebFrameTest, DivAutoZoomWideDivTest) |
2528 { | 2523 { |
2529 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); | 2524 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); |
2530 | 2525 |
2531 const float deviceScaleFactor = 2.0f; | 2526 const float deviceScaleFactor = 2.0f; |
2532 int viewportWidth = 640 / deviceScaleFactor; | 2527 int viewportWidth = 640 / deviceScaleFactor; |
2533 int viewportHeight = 1280 / deviceScaleFactor; | 2528 int viewportHeight = 1280 / deviceScaleFactor; |
2534 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2529 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2535 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2530 FrameTestHelpers::WebViewHelper webViewHelper; |
2536 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html", false, nullptr, nullptr, nullptr, configureAndroid); | 2531 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html", false, nullptr, nullptr, nullptr, configureAndroid); |
2537 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2532 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2538 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2533 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2539 webViewHelper.webView()->setPageScaleFactor(1.0f); | 2534 webViewHelper.webView()->setPageScaleFactor(1.0f); |
2540 webViewHelper.webView()->updateAllLifecyclePhases(); | 2535 webViewHelper.webView()->updateAllLifecyclePhases(); |
2541 | 2536 |
2542 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); | 2537 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); |
2543 | 2538 |
2544 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag
eScaleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2539 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag
eScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2545 | 2540 |
(...skipping 11 matching lines...) Expand all Loading... |
2557 TEST_P(ParameterizedWebFrameTest, DivAutoZoomVeryTallTest) | 2552 TEST_P(ParameterizedWebFrameTest, DivAutoZoomVeryTallTest) |
2558 { | 2553 { |
2559 // When a block is taller than the viewport and a zoom targets a lower part | 2554 // When a block is taller than the viewport and a zoom targets a lower part |
2560 // of it, then we should keep the target point onscreen instead of snapping | 2555 // of it, then we should keep the target point onscreen instead of snapping |
2561 // back up the top of the block. | 2556 // back up the top of the block. |
2562 registerMockedHttpURLLoad("very_tall_div.html"); | 2557 registerMockedHttpURLLoad("very_tall_div.html"); |
2563 | 2558 |
2564 const float deviceScaleFactor = 2.0f; | 2559 const float deviceScaleFactor = 2.0f; |
2565 int viewportWidth = 640 / deviceScaleFactor; | 2560 int viewportWidth = 640 / deviceScaleFactor; |
2566 int viewportHeight = 1280 / deviceScaleFactor; | 2561 int viewportHeight = 1280 / deviceScaleFactor; |
2567 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2562 FrameTestHelpers::WebViewHelper webViewHelper; |
2568 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, null
ptr, nullptr, nullptr, configureAndroid); | 2563 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, null
ptr, nullptr, nullptr, configureAndroid); |
2569 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2564 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2570 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2565 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2571 webViewHelper.webView()->setPageScaleFactor(1.0f); | 2566 webViewHelper.webView()->setPageScaleFactor(1.0f); |
2572 webViewHelper.webView()->updateAllLifecyclePhases(); | 2567 webViewHelper.webView()->updateAllLifecyclePhases(); |
2573 | 2568 |
2574 WebRect div(200, 300, 400, 5000); | 2569 WebRect div(200, 300, 400, 5000); |
2575 WebPoint point(div.x + 50, div.y + 3000); | 2570 WebPoint point(div.x + 50, div.y + 3000); |
2576 float scale; | 2571 float scale; |
2577 WebPoint scroll; | 2572 WebPoint scroll; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 2844 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
2850 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 2845 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
2851 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 2846 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
2852 EXPECT_FLOAT_EQ(legibleScale, scale); | 2847 EXPECT_FLOAT_EQ(legibleScale, scale); |
2853 } | 2848 } |
2854 | 2849 |
2855 TEST_P(ParameterizedWebFrameTest, BlockBoundTest) | 2850 TEST_P(ParameterizedWebFrameTest, BlockBoundTest) |
2856 { | 2851 { |
2857 registerMockedHttpURLLoad("block_bound.html"); | 2852 registerMockedHttpURLLoad("block_bound.html"); |
2858 | 2853 |
2859 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2854 FrameTestHelpers::WebViewHelper webViewHelper; |
2860 webViewHelper.initializeAndLoad(m_baseURL + "block_bound.html", false, nullp
tr, nullptr, nullptr, configureAndroid); | 2855 webViewHelper.initializeAndLoad(m_baseURL + "block_bound.html", false, nullp
tr, nullptr, nullptr, configureAndroid); |
2861 | 2856 |
2862 IntRect rectBack = IntRect(0, 0, 200, 200); | 2857 IntRect rectBack = IntRect(0, 0, 200, 200); |
2863 IntRect rectLeftTop = IntRect(10, 10, 80, 80); | 2858 IntRect rectLeftTop = IntRect(10, 10, 80, 80); |
2864 IntRect rectRightBottom = IntRect(110, 110, 80, 80); | 2859 IntRect rectRightBottom = IntRect(110, 110, 80, 80); |
2865 IntRect blockBound; | 2860 IntRect blockBound; |
2866 | 2861 |
2867 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(9,
9), true)); | 2862 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(9,
9), true)); |
2868 EXPECT_RECT_EQ(rectBack, blockBound); | 2863 EXPECT_RECT_EQ(rectBack, blockBound); |
2869 | 2864 |
(...skipping 17 matching lines...) Expand all Loading... |
2887 } | 2882 } |
2888 | 2883 |
2889 TEST_P(ParameterizedWebFrameTest, DivMultipleTargetZoomMultipleDivsTest) | 2884 TEST_P(ParameterizedWebFrameTest, DivMultipleTargetZoomMultipleDivsTest) |
2890 { | 2885 { |
2891 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 2886 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
2892 | 2887 |
2893 const float deviceScaleFactor = 2.0f; | 2888 const float deviceScaleFactor = 2.0f; |
2894 int viewportWidth = 640 / deviceScaleFactor; | 2889 int viewportWidth = 640 / deviceScaleFactor; |
2895 int viewportHeight = 1280 / deviceScaleFactor; | 2890 int viewportHeight = 1280 / deviceScaleFactor; |
2896 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2891 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2897 FrameTestHelpers::WebViewHelper webViewHelper(this); | 2892 FrameTestHelpers::WebViewHelper webViewHelper; |
2898 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); | 2893 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); |
2899 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2894 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2900 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); | 2895 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); |
2901 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2896 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2902 webViewHelper.webView()->setPageScaleFactor(0.5f); | 2897 webViewHelper.webView()->setPageScaleFactor(0.5f); |
2903 webViewHelper.webView()->setMaximumLegibleScale(1.f); | 2898 webViewHelper.webView()->setMaximumLegibleScale(1.f); |
2904 webViewHelper.webView()->updateAllLifecyclePhases(); | 2899 webViewHelper.webView()->updateAllLifecyclePhases(); |
2905 | 2900 |
2906 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); | 2901 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); |
2907 | 2902 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 | 3154 |
3160 // There should be no change at all since the textbox is fully visible alrea
dy. | 3155 // There should be no change at all since the textbox is fully visible alrea
dy. |
3161 EXPECT_EQ(initialScale, scale); | 3156 EXPECT_EQ(initialScale, scale); |
3162 EXPECT_FALSE(needAnimation); | 3157 EXPECT_FALSE(needAnimation); |
3163 } | 3158 } |
3164 | 3159 |
3165 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) | 3160 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) |
3166 { | 3161 { |
3167 registerMockedHttpURLLoad("sometext.html"); | 3162 registerMockedHttpURLLoad("sometext.html"); |
3168 | 3163 |
3169 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3164 FrameTestHelpers::WebViewHelper webViewHelper; |
3170 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); | 3165 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); |
3171 webViewHelper.resize(WebSize(640, 480)); | 3166 webViewHelper.resize(WebSize(640, 480)); |
3172 | 3167 |
3173 webViewHelper.webView()->setPageScaleFactor(2); | 3168 webViewHelper.webView()->setPageScaleFactor(2); |
3174 webViewHelper.webView()->setVisualViewportOffset(WebFloatPoint(50, 60)); | 3169 webViewHelper.webView()->setVisualViewportOffset(WebFloatPoint(50, 60)); |
3175 | 3170 |
3176 WebRect baseRect; | 3171 WebRect baseRect; |
3177 WebRect extentRect; | 3172 WebRect extentRect; |
3178 | 3173 |
3179 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrame()->toWebLocalF
rame(); | 3174 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrame()->toWebLocalF
rame(); |
3180 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388)); | 3175 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388)); |
3181 | 3176 |
3182 EXPECT_EQ(2ul, ix); | 3177 EXPECT_EQ(2ul, ix); |
3183 } | 3178 } |
3184 | 3179 |
3185 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) | 3180 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) |
3186 { | 3181 { |
3187 registerMockedHttpURLLoad("textbox.html"); | 3182 registerMockedHttpURLLoad("textbox.html"); |
3188 | 3183 |
3189 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3184 FrameTestHelpers::WebViewHelper webViewHelper; |
3190 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true); | 3185 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true); |
3191 webViewHelper.resize(WebSize(640, 480)); | 3186 webViewHelper.resize(WebSize(640, 480)); |
3192 | 3187 |
3193 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrame()->toWebLocalF
rame(); | 3188 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrame()->toWebLocalF
rame(); |
3194 mainFrame->executeScript(WebScriptSource("selectRange();")); | 3189 mainFrame->executeScript(WebScriptSource("selectRange();")); |
3195 | 3190 |
3196 WebRect oldRect; | 3191 WebRect oldRect; |
3197 mainFrame->firstRectForCharacterRange(0, 5, oldRect); | 3192 mainFrame->firstRectForCharacterRange(0, 5, oldRect); |
3198 | 3193 |
3199 WebFloatPoint visualOffset(100, 130); | 3194 WebFloatPoint visualOffset(100, 130); |
(...skipping 21 matching lines...) Expand all Loading... |
3221 } | 3216 } |
3222 }; | 3217 }; |
3223 | 3218 |
3224 TEST_P(ParameterizedWebFrameTest, ReloadDoesntSetRedirect) | 3219 TEST_P(ParameterizedWebFrameTest, ReloadDoesntSetRedirect) |
3225 { | 3220 { |
3226 // Test for case in http://crbug.com/73104. Reloading a frame very quickly | 3221 // Test for case in http://crbug.com/73104. Reloading a frame very quickly |
3227 // would sometimes call decidePolicyForNavigation with isRedirect=true | 3222 // would sometimes call decidePolicyForNavigation with isRedirect=true |
3228 registerMockedHttpURLLoad("form.html"); | 3223 registerMockedHttpURLLoad("form.html"); |
3229 | 3224 |
3230 TestReloadDoesntRedirectWebFrameClient webFrameClient; | 3225 TestReloadDoesntRedirectWebFrameClient webFrameClient; |
3231 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3226 FrameTestHelpers::WebViewHelper webViewHelper; |
3232 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); | 3227 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); |
3233 | 3228 |
3234 webViewHelper.webView()->mainFrame()->reload(WebFrameLoadType::ReloadBypassi
ngCache); | 3229 webViewHelper.webView()->mainFrame()->reload(WebFrameLoadType::ReloadBypassi
ngCache); |
3235 // start another reload before request is delivered. | 3230 // start another reload before request is delivered. |
3236 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); | 3231 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
3237 } | 3232 } |
3238 | 3233 |
3239 class ClearScrollStateOnCommitWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { | 3234 class ClearScrollStateOnCommitWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { |
3240 public: | 3235 public: |
3241 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W
ebHistoryCommitType) override | 3236 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W
ebHistoryCommitType) override |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().height); | 3283 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().height); |
3289 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 3284 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
3290 } | 3285 } |
3291 | 3286 |
3292 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) | 3287 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) |
3293 { | 3288 { |
3294 // Test that reloading while the previous load is still pending does not cau
se the initial | 3289 // Test that reloading while the previous load is still pending does not cau
se the initial |
3295 // request to get lost. | 3290 // request to get lost. |
3296 registerMockedHttpURLLoad("fixed_layout.html"); | 3291 registerMockedHttpURLLoad("fixed_layout.html"); |
3297 | 3292 |
3298 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3293 FrameTestHelpers::WebViewHelper webViewHelper; |
3299 webViewHelper.initialize(); | 3294 webViewHelper.initialize(); |
3300 WebURLRequest request; | 3295 WebURLRequest request; |
3301 request.setURL(toKURL(m_baseURL + "fixed_layout.html")); | 3296 request.setURL(toKURL(m_baseURL + "fixed_layout.html")); |
3302 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 3297 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
3303 webViewHelper.webView()->mainFrame()->loadRequest(request); | 3298 webViewHelper.webView()->mainFrame()->loadRequest(request); |
3304 // start reload before first request is delivered. | 3299 // start reload before first request is delivered. |
3305 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); | 3300 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
3306 | 3301 |
3307 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); | 3302 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); |
3308 ASSERT_TRUE(dataSource); | 3303 ASSERT_TRUE(dataSource); |
3309 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), KURL(dataSource->request(
).url())); | 3304 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), KURL(dataSource->request(
).url())); |
3310 } | 3305 } |
3311 | 3306 |
3312 TEST_P(ParameterizedWebFrameTest, AppendRedirects) | 3307 TEST_P(ParameterizedWebFrameTest, AppendRedirects) |
3313 { | 3308 { |
3314 const std::string firstURL = "about:blank"; | 3309 const std::string firstURL = "about:blank"; |
3315 const std::string secondURL = "http://internal.test"; | 3310 const std::string secondURL = "http://internal.test"; |
3316 | 3311 |
3317 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3312 FrameTestHelpers::WebViewHelper webViewHelper; |
3318 webViewHelper.initializeAndLoad(firstURL, true); | 3313 webViewHelper.initializeAndLoad(firstURL, true); |
3319 | 3314 |
3320 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); | 3315 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); |
3321 ASSERT_TRUE(dataSource); | 3316 ASSERT_TRUE(dataSource); |
3322 dataSource->appendRedirect(toKURL(secondURL)); | 3317 dataSource->appendRedirect(toKURL(secondURL)); |
3323 | 3318 |
3324 WebVector<WebURL> redirects; | 3319 WebVector<WebURL> redirects; |
3325 dataSource->redirectChain(redirects); | 3320 dataSource->redirectChain(redirects); |
3326 ASSERT_EQ(2U, redirects.size()); | 3321 ASSERT_EQ(2U, redirects.size()); |
3327 EXPECT_EQ(toKURL(firstURL), KURL(redirects[0])); | 3322 EXPECT_EQ(toKURL(firstURL), KURL(redirects[0])); |
3328 EXPECT_EQ(toKURL(secondURL), KURL(redirects[1])); | 3323 EXPECT_EQ(toKURL(secondURL), KURL(redirects[1])); |
3329 } | 3324 } |
3330 | 3325 |
3331 TEST_P(ParameterizedWebFrameTest, IframeRedirect) | 3326 TEST_P(ParameterizedWebFrameTest, IframeRedirect) |
3332 { | 3327 { |
3333 registerMockedHttpURLLoad("iframe_redirect.html"); | 3328 registerMockedHttpURLLoad("iframe_redirect.html"); |
3334 registerMockedHttpURLLoad("visible_iframe.html"); | 3329 registerMockedHttpURLLoad("visible_iframe.html"); |
3335 | 3330 |
3336 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3331 FrameTestHelpers::WebViewHelper webViewHelper; |
3337 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); | 3332 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); |
3338 // Pump pending requests one more time. The test page loads script that navi
gates. | 3333 // Pump pending requests one more time. The test page loads script that navi
gates. |
3339 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); | 3334 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); |
3340 | 3335 |
3341 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU
TF8("ifr"), nullptr); | 3336 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU
TF8("ifr"), nullptr); |
3342 ASSERT_TRUE(iframe); | 3337 ASSERT_TRUE(iframe); |
3343 WebDataSource* iframeDataSource = iframe->dataSource(); | 3338 WebDataSource* iframeDataSource = iframe->dataSource(); |
3344 ASSERT_TRUE(iframeDataSource); | 3339 ASSERT_TRUE(iframeDataSource); |
3345 WebVector<WebURL> redirects; | 3340 WebVector<WebURL> redirects; |
3346 iframeDataSource->redirectChain(redirects); | 3341 iframeDataSource->redirectChain(redirects); |
3347 ASSERT_EQ(2U, redirects.size()); | 3342 ASSERT_EQ(2U, redirects.size()); |
3348 EXPECT_EQ(toKURL("about:blank"), KURL(redirects[0])); | 3343 EXPECT_EQ(toKURL("about:blank"), KURL(redirects[0])); |
3349 EXPECT_EQ(toKURL("http://internal.test/visible_iframe.html"), KURL(redirects
[1])); | 3344 EXPECT_EQ(toKURL("http://internal.test/visible_iframe.html"), KURL(redirects
[1])); |
3350 } | 3345 } |
3351 | 3346 |
3352 TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) | 3347 TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) |
3353 { | 3348 { |
3354 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); | 3349 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); |
3355 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); | 3350 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); |
3356 | 3351 |
3357 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3352 FrameTestHelpers::WebViewHelper webViewHelper; |
3358 webViewHelper.initializeAndLoad(m_baseURL + "iframe_clear_focused_node_test.
html", true); | 3353 webViewHelper.initializeAndLoad(m_baseURL + "iframe_clear_focused_node_test.
html", true); |
3359 | 3354 |
3360 // Clear the focused node. | 3355 // Clear the focused node. |
3361 webViewHelper.webView()->clearFocusedElement(); | 3356 webViewHelper.webView()->clearFocusedElement(); |
3362 | 3357 |
3363 // Now retrieve the FocusedNode and test it should be null. | 3358 // Now retrieve the FocusedNode and test it should be null. |
3364 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); | 3359 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); |
3365 } | 3360 } |
3366 | 3361 |
3367 // Implementation of WebFrameClient that tracks the v8 contexts that are created | 3362 // Implementation of WebFrameClient that tracks the v8 contexts that are created |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3420 | 3415 |
3421 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload) | 3416 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload) |
3422 { | 3417 { |
3423 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 3418 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
3424 | 3419 |
3425 registerMockedHttpURLLoad("context_notifications_test.html"); | 3420 registerMockedHttpURLLoad("context_notifications_test.html"); |
3426 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 3421 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
3427 | 3422 |
3428 // Load a frame with an iframe, make sure we get the right create notificati
ons. | 3423 // Load a frame with an iframe, make sure we get the right create notificati
ons. |
3429 ContextLifetimeTestWebFrameClient webFrameClient; | 3424 ContextLifetimeTestWebFrameClient webFrameClient; |
3430 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3425 FrameTestHelpers::WebViewHelper webViewHelper; |
3431 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); | 3426 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); |
3432 | 3427 |
3433 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 3428 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
3434 WebFrame* childFrame = mainFrame->firstChild(); | 3429 WebFrame* childFrame = mainFrame->firstChild(); |
3435 | 3430 |
3436 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); | 3431 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); |
3437 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); | 3432 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); |
3438 | 3433 |
3439 auto& firstCreateNotification = webFrameClient.createNotifications[0]; | 3434 auto& firstCreateNotification = webFrameClient.createNotifications[0]; |
3440 auto& secondCreateNotification = webFrameClient.createNotifications[1]; | 3435 auto& secondCreateNotification = webFrameClient.createNotifications[1]; |
(...skipping 18 matching lines...) Expand all Loading... |
3459 } | 3454 } |
3460 | 3455 |
3461 TEST_P(ParameterizedWebFrameTest, ContextNotificationsReload) | 3456 TEST_P(ParameterizedWebFrameTest, ContextNotificationsReload) |
3462 { | 3457 { |
3463 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 3458 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
3464 | 3459 |
3465 registerMockedHttpURLLoad("context_notifications_test.html"); | 3460 registerMockedHttpURLLoad("context_notifications_test.html"); |
3466 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 3461 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
3467 | 3462 |
3468 ContextLifetimeTestWebFrameClient webFrameClient; | 3463 ContextLifetimeTestWebFrameClient webFrameClient; |
3469 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3464 FrameTestHelpers::WebViewHelper webViewHelper; |
3470 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); | 3465 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); |
3471 | 3466 |
3472 // Refresh, we should get two release notifications and two more create noti
fications. | 3467 // Refresh, we should get two release notifications and two more create noti
fications. |
3473 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); | 3468 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
3474 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); | 3469 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); |
3475 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 3470 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
3476 | 3471 |
3477 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. | 3472 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. |
3478 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 3473 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
3479 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( | 3474 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( |
(...skipping 17 matching lines...) Expand all Loading... |
3497 | 3492 |
3498 TEST_P(ParameterizedWebFrameTest, ContextNotificationsIsolatedWorlds) | 3493 TEST_P(ParameterizedWebFrameTest, ContextNotificationsIsolatedWorlds) |
3499 { | 3494 { |
3500 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3495 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
3501 v8::HandleScope handleScope(isolate); | 3496 v8::HandleScope handleScope(isolate); |
3502 | 3497 |
3503 registerMockedHttpURLLoad("context_notifications_test.html"); | 3498 registerMockedHttpURLLoad("context_notifications_test.html"); |
3504 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 3499 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
3505 | 3500 |
3506 ContextLifetimeTestWebFrameClient webFrameClient; | 3501 ContextLifetimeTestWebFrameClient webFrameClient; |
3507 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3502 FrameTestHelpers::WebViewHelper webViewHelper; |
3508 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); | 3503 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); |
3509 | 3504 |
3510 // Add an isolated world. | 3505 // Add an isolated world. |
3511 webFrameClient.reset(); | 3506 webFrameClient.reset(); |
3512 | 3507 |
3513 int isolatedWorldId = 42; | 3508 int isolatedWorldId = 42; |
3514 WebScriptSource scriptSource("hi!"); | 3509 WebScriptSource scriptSource("hi!"); |
3515 int numSources = 1; | 3510 int numSources = 1; |
3516 int extensionGroup = 0; | 3511 int extensionGroup = 0; |
3517 webViewHelper.webView()->mainFrame()->executeScriptInIsolatedWorld(isolatedW
orldId, &scriptSource, numSources, extensionGroup); | 3512 webViewHelper.webView()->mainFrame()->executeScriptInIsolatedWorld(isolatedW
orldId, &scriptSource, numSources, extensionGroup); |
(...skipping 17 matching lines...) Expand all Loading... |
3535 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 3530 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
3536 if (webFrameClient.releaseNotifications[i]->Equals(webFrameClient.create
Notifications[0].get())) | 3531 if (webFrameClient.releaseNotifications[i]->Equals(webFrameClient.create
Notifications[0].get())) |
3537 ++matchCount; | 3532 ++matchCount; |
3538 } | 3533 } |
3539 EXPECT_EQ(1, matchCount); | 3534 EXPECT_EQ(1, matchCount); |
3540 } | 3535 } |
3541 | 3536 |
3542 TEST_P(ParameterizedWebFrameTest, FindInPage) | 3537 TEST_P(ParameterizedWebFrameTest, FindInPage) |
3543 { | 3538 { |
3544 registerMockedHttpURLLoad("find.html"); | 3539 registerMockedHttpURLLoad("find.html"); |
3545 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3540 FrameTestHelpers::WebViewHelper webViewHelper; |
3546 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); | 3541 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); |
3547 ASSERT_TRUE(webViewHelper.webView()->mainFrameImpl()); | 3542 ASSERT_TRUE(webViewHelper.webView()->mainFrameImpl()); |
3548 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); | 3543 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); |
3549 const int findIdentifier = 12345; | 3544 const int findIdentifier = 12345; |
3550 WebFindOptions options; | 3545 WebFindOptions options; |
3551 | 3546 |
3552 // Find in a <div> element. | 3547 // Find in a <div> element. |
3553 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options
, false)); | 3548 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options
, false)); |
3554 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 3549 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
3555 WebRange range = frame->selectionRange(); | 3550 WebRange range = frame->selectionRange(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3592 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false)); | 3587 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false)); |
3593 // If there are any matches, stopFinding will set the selection on the found
text. | 3588 // If there are any matches, stopFinding will set the selection on the found
text. |
3594 // However, we do not expect any matches, so check that the selection is nul
l. | 3589 // However, we do not expect any matches, so check that the selection is nul
l. |
3595 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 3590 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
3596 range = frame->selectionRange(); | 3591 range = frame->selectionRange(); |
3597 ASSERT_TRUE(range.isNull()); | 3592 ASSERT_TRUE(range.isNull()); |
3598 } | 3593 } |
3599 | 3594 |
3600 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) | 3595 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) |
3601 { | 3596 { |
3602 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3597 FrameTestHelpers::WebViewHelper webViewHelper; |
3603 webViewHelper.initializeAndLoad("about:blank", true); | 3598 webViewHelper.initializeAndLoad("about:blank", true); |
3604 // We set the size because it impacts line wrapping, which changes the | 3599 // We set the size because it impacts line wrapping, which changes the |
3605 // resulting text value. | 3600 // resulting text value. |
3606 webViewHelper.resize(WebSize(640, 480)); | 3601 webViewHelper.resize(WebSize(640, 480)); |
3607 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3602 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3608 | 3603 |
3609 // Generate a simple test case. | 3604 // Generate a simple test case. |
3610 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 3605 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
3611 KURL testURL = toKURL("about:blank"); | 3606 KURL testURL = toKURL("about:blank"); |
3612 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3607 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
(...skipping 21 matching lines...) Expand all Loading... |
3634 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); | 3629 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); |
3635 | 3630 |
3636 // Get the frame text where the subframe separator falls on the boundary of | 3631 // Get the frame text where the subframe separator falls on the boundary of |
3637 // what we'll take. There used to be a crash in this case. | 3632 // what we'll take. There used to be a crash in this case. |
3638 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12)
; | 3633 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12)
; |
3639 EXPECT_EQ("Hello world", text.utf8()); | 3634 EXPECT_EQ("Hello world", text.utf8()); |
3640 } | 3635 } |
3641 | 3636 |
3642 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) | 3637 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) |
3643 { | 3638 { |
3644 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3639 FrameTestHelpers::WebViewHelper webViewHelper; |
3645 webViewHelper.initializeAndLoad("about:blank", true); | 3640 webViewHelper.initializeAndLoad("about:blank", true); |
3646 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); | 3641 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); |
3647 | 3642 |
3648 // Generate a simple test case. | 3643 // Generate a simple test case. |
3649 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 3644 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
3650 KURL testURL = toKURL("about:blank"); | 3645 KURL testURL = toKURL("about:blank"); |
3651 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3646 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3652 | 3647 |
3653 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); | 3648 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
3654 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3649 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
(...skipping 24 matching lines...) Expand all Loading... |
3679 { | 3674 { |
3680 frame->executeScript(WebScriptSource("window.history = 'replaced';")); | 3675 frame->executeScript(WebScriptSource("window.history = 'replaced';")); |
3681 } | 3676 } |
3682 }; | 3677 }; |
3683 | 3678 |
3684 TEST_P(ParameterizedWebFrameTest, ExecuteScriptDuringDidCreateScriptContext) | 3679 TEST_P(ParameterizedWebFrameTest, ExecuteScriptDuringDidCreateScriptContext) |
3685 { | 3680 { |
3686 registerMockedHttpURLLoad("hello_world.html"); | 3681 registerMockedHttpURLLoad("hello_world.html"); |
3687 | 3682 |
3688 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; | 3683 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; |
3689 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3684 FrameTestHelpers::WebViewHelper webViewHelper; |
3690 webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFr
ameClient); | 3685 webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFr
ameClient); |
3691 | 3686 |
3692 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); | 3687 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
3693 } | 3688 } |
3694 | 3689 |
3695 class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 3690 class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
3696 public: | 3691 public: |
3697 FindUpdateWebFrameClient() | 3692 FindUpdateWebFrameClient() |
3698 : m_findResultsAreReady(false) | 3693 : m_findResultsAreReady(false) |
3699 , m_count(-1) | 3694 , m_count(-1) |
(...skipping 21 matching lines...) Expand all Loading... |
3721 bool m_findResultsAreReady; | 3716 bool m_findResultsAreReady; |
3722 int m_count; | 3717 int m_count; |
3723 int m_activeIndex; | 3718 int m_activeIndex; |
3724 }; | 3719 }; |
3725 | 3720 |
3726 TEST_P(ParameterizedWebFrameTest, FindInPageMatchRects) | 3721 TEST_P(ParameterizedWebFrameTest, FindInPageMatchRects) |
3727 { | 3722 { |
3728 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3723 registerMockedHttpURLLoad("find_in_page_frame.html"); |
3729 | 3724 |
3730 FindUpdateWebFrameClient client; | 3725 FindUpdateWebFrameClient client; |
3731 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3726 FrameTestHelpers::WebViewHelper webViewHelper; |
3732 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page_frame.html", true,
&client); | 3727 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page_frame.html", true,
&client); |
3733 webViewHelper.resize(WebSize(640, 480)); | 3728 webViewHelper.resize(WebSize(640, 480)); |
3734 webViewHelper.webView()->setMaximumLegibleScale(1.f); | 3729 webViewHelper.webView()->setMaximumLegibleScale(1.f); |
3735 webViewHelper.webView()->updateAllLifecyclePhases(); | 3730 webViewHelper.webView()->updateAllLifecyclePhases(); |
3736 runPendingTasks(); | 3731 runPendingTasks(); |
3737 | 3732 |
3738 // Note that the 'result 19' in the <select> element is not expected to | 3733 // Note that the 'result 19' in the <select> element is not expected to |
3739 // produce a match. Also, results 00 and 01 are in a different frame that is | 3734 // produce a match. Also, results 00 and 01 are in a different frame that is |
3740 // not included in this test. | 3735 // not included in this test. |
3741 const char kFindString[] = "result"; | 3736 const char kFindString[] = "result"; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3834 EXPECT_TRUE(client.findResultsAreReady()); | 3829 EXPECT_TRUE(client.findResultsAreReady()); |
3835 EXPECT_EQ(kActiveIndex, client.activeIndex()); | 3830 EXPECT_EQ(kActiveIndex, client.activeIndex()); |
3836 } | 3831 } |
3837 | 3832 |
3838 TEST_P(ParameterizedWebFrameTest, FindOnDetachedFrame) | 3833 TEST_P(ParameterizedWebFrameTest, FindOnDetachedFrame) |
3839 { | 3834 { |
3840 registerMockedHttpURLLoad("find_in_page.html"); | 3835 registerMockedHttpURLLoad("find_in_page.html"); |
3841 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3836 registerMockedHttpURLLoad("find_in_page_frame.html"); |
3842 | 3837 |
3843 FindUpdateWebFrameClient client; | 3838 FindUpdateWebFrameClient client; |
3844 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3839 FrameTestHelpers::WebViewHelper webViewHelper; |
3845 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3840 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3846 webViewHelper.resize(WebSize(640, 480)); | 3841 webViewHelper.resize(WebSize(640, 480)); |
3847 runPendingTasks(); | 3842 runPendingTasks(); |
3848 | 3843 |
3849 const char kFindString[] = "result"; | 3844 const char kFindString[] = "result"; |
3850 const int kFindIdentifier = 12345; | 3845 const int kFindIdentifier = 12345; |
3851 | 3846 |
3852 WebFindOptions options; | 3847 WebFindOptions options; |
3853 WebString searchText = WebString::fromUTF8(kFindString); | 3848 WebString searchText = WebString::fromUTF8(kFindString); |
3854 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 3849 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
(...skipping 16 matching lines...) Expand all Loading... |
3871 runPendingTasks(); | 3866 runPendingTasks(); |
3872 EXPECT_TRUE(client.findResultsAreReady()); | 3867 EXPECT_TRUE(client.findResultsAreReady()); |
3873 } | 3868 } |
3874 | 3869 |
3875 TEST_P(ParameterizedWebFrameTest, FindDetachFrameBeforeScopeStrings) | 3870 TEST_P(ParameterizedWebFrameTest, FindDetachFrameBeforeScopeStrings) |
3876 { | 3871 { |
3877 registerMockedHttpURLLoad("find_in_page.html"); | 3872 registerMockedHttpURLLoad("find_in_page.html"); |
3878 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3873 registerMockedHttpURLLoad("find_in_page_frame.html"); |
3879 | 3874 |
3880 FindUpdateWebFrameClient client; | 3875 FindUpdateWebFrameClient client; |
3881 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3876 FrameTestHelpers::WebViewHelper webViewHelper; |
3882 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3877 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3883 webViewHelper.resize(WebSize(640, 480)); | 3878 webViewHelper.resize(WebSize(640, 480)); |
3884 runPendingTasks(); | 3879 runPendingTasks(); |
3885 | 3880 |
3886 const char kFindString[] = "result"; | 3881 const char kFindString[] = "result"; |
3887 const int kFindIdentifier = 12345; | 3882 const int kFindIdentifier = 12345; |
3888 | 3883 |
3889 WebFindOptions options; | 3884 WebFindOptions options; |
3890 WebString searchText = WebString::fromUTF8(kFindString); | 3885 WebString searchText = WebString::fromUTF8(kFindString); |
3891 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 3886 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
(...skipping 15 matching lines...) Expand all Loading... |
3907 runPendingTasks(); | 3902 runPendingTasks(); |
3908 EXPECT_TRUE(client.findResultsAreReady()); | 3903 EXPECT_TRUE(client.findResultsAreReady()); |
3909 } | 3904 } |
3910 | 3905 |
3911 TEST_P(ParameterizedWebFrameTest, FindDetachFrameWhileScopingStrings) | 3906 TEST_P(ParameterizedWebFrameTest, FindDetachFrameWhileScopingStrings) |
3912 { | 3907 { |
3913 registerMockedHttpURLLoad("find_in_page.html"); | 3908 registerMockedHttpURLLoad("find_in_page.html"); |
3914 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3909 registerMockedHttpURLLoad("find_in_page_frame.html"); |
3915 | 3910 |
3916 FindUpdateWebFrameClient client; | 3911 FindUpdateWebFrameClient client; |
3917 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3912 FrameTestHelpers::WebViewHelper webViewHelper; |
3918 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3913 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3919 webViewHelper.resize(WebSize(640, 480)); | 3914 webViewHelper.resize(WebSize(640, 480)); |
3920 runPendingTasks(); | 3915 runPendingTasks(); |
3921 | 3916 |
3922 const char kFindString[] = "result"; | 3917 const char kFindString[] = "result"; |
3923 const int kFindIdentifier = 12345; | 3918 const int kFindIdentifier = 12345; |
3924 | 3919 |
3925 WebFindOptions options; | 3920 WebFindOptions options; |
3926 WebString searchText = WebString::fromUTF8(kFindString); | 3921 WebString searchText = WebString::fromUTF8(kFindString); |
3927 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 3922 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
(...skipping 14 matching lines...) Expand all Loading... |
3942 | 3937 |
3943 runPendingTasks(); | 3938 runPendingTasks(); |
3944 EXPECT_TRUE(client.findResultsAreReady()); | 3939 EXPECT_TRUE(client.findResultsAreReady()); |
3945 } | 3940 } |
3946 | 3941 |
3947 TEST_P(ParameterizedWebFrameTest, ResetMatchCount) | 3942 TEST_P(ParameterizedWebFrameTest, ResetMatchCount) |
3948 { | 3943 { |
3949 registerMockedHttpURLLoad("find_in_generated_frame.html"); | 3944 registerMockedHttpURLLoad("find_in_generated_frame.html"); |
3950 | 3945 |
3951 FindUpdateWebFrameClient client; | 3946 FindUpdateWebFrameClient client; |
3952 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3947 FrameTestHelpers::WebViewHelper webViewHelper; |
3953 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html",
true, &client); | 3948 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html",
true, &client); |
3954 webViewHelper.resize(WebSize(640, 480)); | 3949 webViewHelper.resize(WebSize(640, 480)); |
3955 runPendingTasks(); | 3950 runPendingTasks(); |
3956 | 3951 |
3957 const char kFindString[] = "result"; | 3952 const char kFindString[] = "result"; |
3958 const int kFindIdentifier = 12345; | 3953 const int kFindIdentifier = 12345; |
3959 | 3954 |
3960 WebFindOptions options; | 3955 WebFindOptions options; |
3961 WebString searchText = WebString::fromUTF8(kFindString); | 3956 WebString searchText = WebString::fromUTF8(kFindString); |
3962 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 3957 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
3963 | 3958 |
3964 // Check that child frame exists. | 3959 // Check that child frame exists. |
3965 EXPECT_TRUE(!!mainFrame->traverseNext(false)); | 3960 EXPECT_TRUE(!!mainFrame->traverseNext(false)); |
3966 | 3961 |
3967 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3962 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3968 EXPECT_FALSE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText,
options, false)); | 3963 EXPECT_FALSE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText,
options, false)); |
3969 | 3964 |
3970 runPendingTasks(); | 3965 runPendingTasks(); |
3971 EXPECT_FALSE(client.findResultsAreReady()); | 3966 EXPECT_FALSE(client.findResultsAreReady()); |
3972 | 3967 |
3973 mainFrame->ensureTextFinder().resetMatchCount(); | 3968 mainFrame->ensureTextFinder().resetMatchCount(); |
3974 } | 3969 } |
3975 | 3970 |
3976 TEST_P(ParameterizedWebFrameTest, SetTickmarks) | 3971 TEST_P(ParameterizedWebFrameTest, SetTickmarks) |
3977 { | 3972 { |
3978 registerMockedHttpURLLoad("find.html"); | 3973 registerMockedHttpURLLoad("find.html"); |
3979 | 3974 |
3980 FindUpdateWebFrameClient client; | 3975 FindUpdateWebFrameClient client; |
3981 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3976 FrameTestHelpers::WebViewHelper webViewHelper; |
3982 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); | 3977 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); |
3983 webViewHelper.resize(WebSize(640, 480)); | 3978 webViewHelper.resize(WebSize(640, 480)); |
3984 runPendingTasks(); | 3979 runPendingTasks(); |
3985 | 3980 |
3986 const char kFindString[] = "foo"; | 3981 const char kFindString[] = "foo"; |
3987 const int kFindIdentifier = 12345; | 3982 const int kFindIdentifier = 12345; |
3988 | 3983 |
3989 WebFindOptions options; | 3984 WebFindOptions options; |
3990 WebString searchText = WebString::fromUTF8(kFindString); | 3985 WebString searchText = WebString::fromUTF8(kFindString); |
3991 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 3986 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4024 Vector<IntRect> originalTickmarksAfterReset; | 4019 Vector<IntRect> originalTickmarksAfterReset; |
4025 scrollbar->getTickmarks(originalTickmarksAfterReset); | 4020 scrollbar->getTickmarks(originalTickmarksAfterReset); |
4026 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); | 4021 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); |
4027 } | 4022 } |
4028 | 4023 |
4029 TEST_P(ParameterizedWebFrameTest, FindInPageJavaScriptUpdatesDOM) | 4024 TEST_P(ParameterizedWebFrameTest, FindInPageJavaScriptUpdatesDOM) |
4030 { | 4025 { |
4031 registerMockedHttpURLLoad("find.html"); | 4026 registerMockedHttpURLLoad("find.html"); |
4032 | 4027 |
4033 FindUpdateWebFrameClient client; | 4028 FindUpdateWebFrameClient client; |
4034 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4029 FrameTestHelpers::WebViewHelper webViewHelper; |
4035 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); | 4030 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); |
4036 webViewHelper.resize(WebSize(640, 480)); | 4031 webViewHelper.resize(WebSize(640, 480)); |
4037 runPendingTasks(); | 4032 runPendingTasks(); |
4038 | 4033 |
4039 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 4034 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
4040 const int findIdentifier = 12345; | 4035 const int findIdentifier = 12345; |
4041 static const char* kFindString = "foo"; | 4036 static const char* kFindString = "foo"; |
4042 WebString searchText = WebString::fromUTF8(kFindString); | 4037 WebString searchText = WebString::fromUTF8(kFindString); |
4043 WebFindOptions options; | 4038 WebFindOptions options; |
4044 bool activeNow; | 4039 bool activeNow; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4099 | 4094 |
4100 TEST_P(ParameterizedWebFrameTest, SelectRange) | 4095 TEST_P(ParameterizedWebFrameTest, SelectRange) |
4101 { | 4096 { |
4102 WebLocalFrame* frame; | 4097 WebLocalFrame* frame; |
4103 WebRect startWebRect; | 4098 WebRect startWebRect; |
4104 WebRect endWebRect; | 4099 WebRect endWebRect; |
4105 | 4100 |
4106 registerMockedHttpURLLoad("select_range_basic.html"); | 4101 registerMockedHttpURLLoad("select_range_basic.html"); |
4107 registerMockedHttpURLLoad("select_range_scroll.html"); | 4102 registerMockedHttpURLLoad("select_range_scroll.html"); |
4108 | 4103 |
4109 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4104 FrameTestHelpers::WebViewHelper webViewHelper; |
4110 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi
ewHelper); | 4105 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi
ewHelper); |
4111 frame = webViewHelper.webView()->mainFrameImpl(); | 4106 frame = webViewHelper.webView()->mainFrameImpl(); |
4112 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); | 4107 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); |
4113 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4108 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4114 frame->executeCommand(WebString::fromUTF8("Unselect")); | 4109 frame->executeCommand(WebString::fromUTF8("Unselect")); |
4115 EXPECT_EQ("", selectionAsString(frame)); | 4110 EXPECT_EQ("", selectionAsString(frame)); |
4116 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 4111 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
4117 // On some devices, the above bottomRightMinusOne() causes the ending '.' no
t selected. | 4112 // On some devices, the above bottomRightMinusOne() causes the ending '.' no
t selected. |
4118 std::string selectionString = selectionAsString(frame); | 4113 std::string selectionString = selectionAsString(frame); |
4119 EXPECT_TRUE(selectionString == "Some test text for testing." | 4114 EXPECT_TRUE(selectionString == "Some test text for testing." |
(...skipping 14 matching lines...) Expand all Loading... |
4134 | 4129 |
4135 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) | 4130 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) |
4136 { | 4131 { |
4137 WebFrame* frame; | 4132 WebFrame* frame; |
4138 WebRect startWebRect; | 4133 WebRect startWebRect; |
4139 WebRect endWebRect; | 4134 WebRect endWebRect; |
4140 | 4135 |
4141 registerMockedHttpURLLoad("select_range_iframe.html"); | 4136 registerMockedHttpURLLoad("select_range_iframe.html"); |
4142 registerMockedHttpURLLoad("select_range_basic.html"); | 4137 registerMockedHttpURLLoad("select_range_basic.html"); |
4143 | 4138 |
4144 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4139 FrameTestHelpers::WebViewHelper webViewHelper; |
4145 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV
iewHelper); | 4140 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV
iewHelper); |
4146 frame = webViewHelper.webView()->mainFrame(); | 4141 frame = webViewHelper.webView()->mainFrame(); |
4147 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame(); | 4142 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame(); |
4148 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); | 4143 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); |
4149 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4144 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4150 subframe->executeCommand(WebString::fromUTF8("Unselect")); | 4145 subframe->executeCommand(WebString::fromUTF8("Unselect")); |
4151 EXPECT_EQ("", selectionAsString(subframe)); | 4146 EXPECT_EQ("", selectionAsString(subframe)); |
4152 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)
); | 4147 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)
); |
4153 // On some devices, the above bottomRightMinusOne() causes the ending '.' no
t selected. | 4148 // On some devices, the above bottomRightMinusOne() causes the ending '.' no
t selected. |
4154 std::string selectionString = selectionAsString(subframe); | 4149 std::string selectionString = selectionAsString(subframe); |
4155 EXPECT_TRUE(selectionString == "Some test text for testing." | 4150 EXPECT_TRUE(selectionString == "Some test text for testing." |
4156 || selectionString == "Some test text for testing"); | 4151 || selectionString == "Some test text for testing"); |
4157 } | 4152 } |
4158 | 4153 |
4159 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) | 4154 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) |
4160 { | 4155 { |
4161 WebLocalFrame* frame; | 4156 WebLocalFrame* frame; |
4162 WebRect startWebRect; | 4157 WebRect startWebRect; |
4163 WebRect endWebRect; | 4158 WebRect endWebRect; |
4164 | 4159 |
4165 registerMockedHttpURLLoad("select_range_div_editable.html"); | 4160 registerMockedHttpURLLoad("select_range_div_editable.html"); |
4166 | 4161 |
4167 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. | 4162 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. |
4168 // The selection range should be clipped to the bounds of the editable eleme
nt. | 4163 // The selection range should be clipped to the bounds of the editable eleme
nt. |
4169 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4164 FrameTestHelpers::WebViewHelper webViewHelper; |
4170 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); | 4165 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); |
4171 frame = webViewHelper.webView()->mainFrameImpl(); | 4166 frame = webViewHelper.webView()->mainFrameImpl(); |
4172 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4167 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4173 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4168 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4174 | 4169 |
4175 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); | 4170 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
4176 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); | 4171 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); |
4177 | 4172 |
4178 // As above, but extending the selection to the bottom of the document. | 4173 // As above, but extending the selection to the bottom of the document. |
4179 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); | 4174 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); |
(...skipping 14 matching lines...) Expand all Loading... |
4194 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) | 4189 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) |
4195 { | 4190 { |
4196 WebLocalFrame* frame; | 4191 WebLocalFrame* frame; |
4197 WebRect startWebRect; | 4192 WebRect startWebRect; |
4198 WebRect endWebRect; | 4193 WebRect endWebRect; |
4199 | 4194 |
4200 registerMockedHttpURLLoad("select_range_span_editable.html"); | 4195 registerMockedHttpURLLoad("select_range_span_editable.html"); |
4201 | 4196 |
4202 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. | 4197 // Select the middle of an editable element, then try to extend the selectio
n to the top of the document. |
4203 // The selection range should be clipped to the bounds of the editable eleme
nt. | 4198 // The selection range should be clipped to the bounds of the editable eleme
nt. |
4204 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4199 FrameTestHelpers::WebViewHelper webViewHelper; |
4205 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); | 4200 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); |
4206 frame = webViewHelper.webView()->mainFrameImpl(); | 4201 frame = webViewHelper.webView()->mainFrameImpl(); |
4207 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4202 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4208 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4203 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4209 | 4204 |
4210 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); | 4205 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
4211 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); | 4206 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); |
4212 | 4207 |
4213 // As above, but extending the selection to the bottom of the document. | 4208 // As above, but extending the selection to the bottom of the document. |
4214 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); | 4209 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); |
4215 frame = webViewHelper.webView()->mainFrameImpl(); | 4210 frame = webViewHelper.webView()->mainFrameImpl(); |
4216 | 4211 |
4217 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4212 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4218 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 4213 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
4219 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4214 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4220 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4215 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4221 | 4216 |
4222 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4217 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4223 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4218 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4224 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); | 4219 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); |
4225 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); | 4220 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); |
4226 } | 4221 } |
4227 | 4222 |
4228 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) | 4223 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) |
4229 { | 4224 { |
4230 registerMockedHttpURLLoad("text_selection.html"); | 4225 registerMockedHttpURLLoad("text_selection.html"); |
4231 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4226 FrameTestHelpers::WebViewHelper webViewHelper; |
4232 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe
lper); | 4227 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe
lper); |
4233 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); | 4228 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); |
4234 | 4229 |
4235 // Select second span. We can move the start to include the first span. | 4230 // Select second span. We can move the start to include the first span. |
4236 frame->executeScript(WebScriptSource("selectElement('header_2');")); | 4231 frame->executeScript(WebScriptSource("selectElement('header_2');")); |
4237 EXPECT_EQ("Header 2.", selectionAsString(frame)); | 4232 EXPECT_EQ("Header 2.", selectionAsString(frame)); |
4238 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to
pLeft(elementBounds(frame, "header_1"))); | 4233 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to
pLeft(elementBounds(frame, "header_1"))); |
4239 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); | 4234 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); |
4240 | 4235 |
4241 // We can move the start and end together. | 4236 // We can move the start and end together. |
(...skipping 27 matching lines...) Expand all Loading... |
4269 EXPECT_EQ("Editable 2.", selectionAsString(frame)); | 4264 EXPECT_EQ("Editable 2.", selectionAsString(frame)); |
4270 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")),
topLeft(elementBounds(frame, "header_2"))); | 4265 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")),
topLeft(elementBounds(frame, "header_2"))); |
4271 // positionForPoint returns the wrong values for contenteditable spans. See | 4266 // positionForPoint returns the wrong values for contenteditable spans. See |
4272 // http://crbug.com/238334. | 4267 // http://crbug.com/238334. |
4273 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); | 4268 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); |
4274 } | 4269 } |
4275 | 4270 |
4276 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) | 4271 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) |
4277 { | 4272 { |
4278 registerMockedHttpURLLoad("text_selection.html"); | 4273 registerMockedHttpURLLoad("text_selection.html"); |
4279 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4274 FrameTestHelpers::WebViewHelper webViewHelper; |
4280 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe
lper); | 4275 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe
lper); |
4281 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); | 4276 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); |
4282 | 4277 |
4283 // Select first span. We can move the end to include the second span. | 4278 // Select first span. We can move the end to include the second span. |
4284 frame->executeScript(WebScriptSource("selectElement('header_1');")); | 4279 frame->executeScript(WebScriptSource("selectElement('header_1');")); |
4285 EXPECT_EQ("Header 1.", selectionAsString(frame)); | 4280 EXPECT_EQ("Header 1.", selectionAsString(frame)); |
4286 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin
usOne(elementBounds(frame, "header_2"))); | 4281 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin
usOne(elementBounds(frame, "header_2"))); |
4287 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); | 4282 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); |
4288 | 4283 |
4289 // We can move the start and end together. | 4284 // We can move the start and end together. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4322 } | 4317 } |
4323 | 4318 |
4324 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) | 4319 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) |
4325 { | 4320 { |
4326 WebLocalFrameImpl* frame; | 4321 WebLocalFrameImpl* frame; |
4327 WebRect startWebRect; | 4322 WebRect startWebRect; |
4328 WebRect endWebRect; | 4323 WebRect endWebRect; |
4329 | 4324 |
4330 registerMockedHttpURLLoad("move_range_selection_extent.html"); | 4325 registerMockedHttpURLLoad("move_range_selection_extent.html"); |
4331 | 4326 |
4332 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4327 FrameTestHelpers::WebViewHelper webViewHelper; |
4333 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html
", &webViewHelper); | 4328 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html
", &webViewHelper); |
4334 frame = webViewHelper.webView()->mainFrameImpl(); | 4329 frame = webViewHelper.webView()->mainFrameImpl(); |
4335 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4330 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4336 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4331 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4337 | 4332 |
4338 frame->moveRangeSelectionExtent(WebPoint(640, 480)); | 4333 frame->moveRangeSelectionExtent(WebPoint(640, 480)); |
4339 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); | 4334 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); |
4340 | 4335 |
4341 frame->moveRangeSelectionExtent(WebPoint(0, 0)); | 4336 frame->moveRangeSelectionExtent(WebPoint(0, 0)); |
4342 EXPECT_EQ("16-char header. ", selectionAsString(frame)); | 4337 EXPECT_EQ("16-char header. ", selectionAsString(frame)); |
(...skipping 13 matching lines...) Expand all Loading... |
4356 } | 4351 } |
4357 | 4352 |
4358 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentCannotCollapse) | 4353 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentCannotCollapse) |
4359 { | 4354 { |
4360 WebLocalFrameImpl* frame; | 4355 WebLocalFrameImpl* frame; |
4361 WebRect startWebRect; | 4356 WebRect startWebRect; |
4362 WebRect endWebRect; | 4357 WebRect endWebRect; |
4363 | 4358 |
4364 registerMockedHttpURLLoad("move_range_selection_extent.html"); | 4359 registerMockedHttpURLLoad("move_range_selection_extent.html"); |
4365 | 4360 |
4366 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4361 FrameTestHelpers::WebViewHelper webViewHelper; |
4367 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html
", &webViewHelper); | 4362 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html
", &webViewHelper); |
4368 frame = webViewHelper.webView()->mainFrameImpl(); | 4363 frame = webViewHelper.webView()->mainFrameImpl(); |
4369 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4364 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4370 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4365 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4371 | 4366 |
4372 frame->moveRangeSelectionExtent(bottomRightMinusOne(startWebRect)); | 4367 frame->moveRangeSelectionExtent(bottomRightMinusOne(startWebRect)); |
4373 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4368 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4374 | 4369 |
4375 // Reset with swapped base and extent. | 4370 // Reset with swapped base and extent. |
4376 frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect)); | 4371 frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect)); |
4377 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4372 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4378 | 4373 |
4379 frame->moveRangeSelectionExtent(bottomRightMinusOne(endWebRect)); | 4374 frame->moveRangeSelectionExtent(bottomRightMinusOne(endWebRect)); |
4380 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4375 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4381 } | 4376 } |
4382 | 4377 |
4383 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentScollsInputField) | 4378 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentScollsInputField) |
4384 { | 4379 { |
4385 WebLocalFrameImpl* frame; | 4380 WebLocalFrameImpl* frame; |
4386 WebRect startWebRect; | 4381 WebRect startWebRect; |
4387 WebRect endWebRect; | 4382 WebRect endWebRect; |
4388 | 4383 |
4389 registerMockedHttpURLLoad("move_range_selection_extent_input_field.html"); | 4384 registerMockedHttpURLLoad("move_range_selection_extent_input_field.html"); |
4390 | 4385 |
4391 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4386 FrameTestHelpers::WebViewHelper webViewHelper; |
4392 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent_inpu
t_field.html", &webViewHelper); | 4387 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent_inpu
t_field.html", &webViewHelper); |
4393 frame = webViewHelper.webView()->mainFrameImpl(); | 4388 frame = webViewHelper.webView()->mainFrameImpl(); |
4394 EXPECT_EQ("Length", selectionAsString(frame)); | 4389 EXPECT_EQ("Length", selectionAsString(frame)); |
4395 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4390 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4396 | 4391 |
4397 EXPECT_EQ(0, frame->frame()->selection().rootEditableElement()->scrollLeft()
); | 4392 EXPECT_EQ(0, frame->frame()->selection().rootEditableElement()->scrollLeft()
); |
4398 frame->moveRangeSelectionExtent(WebPoint(endWebRect.x + 500, endWebRect.y)); | 4393 frame->moveRangeSelectionExtent(WebPoint(endWebRect.x + 500, endWebRect.y)); |
4399 EXPECT_GE(frame->frame()->selection().rootEditableElement()->scrollLeft(), 1
); | 4394 EXPECT_GE(frame->frame()->selection().rootEditableElement()->scrollLeft(), 1
); |
4400 EXPECT_EQ("Lengthy text goes here.", selectionAsString(frame)); | 4395 EXPECT_EQ("Lengthy text goes here.", selectionAsString(frame)); |
4401 } | 4396 } |
4402 | 4397 |
4403 static int computeOffset(LayoutObject* layoutObject, int x, int y) | 4398 static int computeOffset(LayoutObject* layoutObject, int x, int y) |
4404 { | 4399 { |
4405 return createVisiblePosition(layoutObject->positionForPoint(LayoutPoint(x, y
))).deepEquivalent().computeOffsetInContainerNode(); | 4400 return createVisiblePosition(layoutObject->positionForPoint(LayoutPoint(x, y
))).deepEquivalent().computeOffsetInContainerNode(); |
4406 } | 4401 } |
4407 | 4402 |
4408 // positionForPoint returns the wrong values for contenteditable spans. See | 4403 // positionForPoint returns the wrong values for contenteditable spans. See |
4409 // http://crbug.com/238334. | 4404 // http://crbug.com/238334. |
4410 TEST_P(ParameterizedWebFrameTest, DISABLED_PositionForPointTest) | 4405 TEST_P(ParameterizedWebFrameTest, DISABLED_PositionForPointTest) |
4411 { | 4406 { |
4412 registerMockedHttpURLLoad("select_range_span_editable.html"); | 4407 registerMockedHttpURLLoad("select_range_span_editable.html"); |
4413 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4408 FrameTestHelpers::WebViewHelper webViewHelper; |
4414 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); | 4409 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); |
4415 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 4410 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
4416 LayoutObject* layoutObject = mainFrame->frame()->selection().rootEditableEle
ment()->layoutObject(); | 4411 LayoutObject* layoutObject = mainFrame->frame()->selection().rootEditableEle
ment()->layoutObject(); |
4417 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1)); | 4412 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1)); |
4418 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000)); | 4413 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000)); |
4419 | 4414 |
4420 registerMockedHttpURLLoad("select_range_div_editable.html"); | 4415 registerMockedHttpURLLoad("select_range_div_editable.html"); |
4421 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); | 4416 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); |
4422 mainFrame = webViewHelper.webView()->mainFrameImpl(); | 4417 mainFrame = webViewHelper.webView()->mainFrameImpl(); |
4423 layoutObject = mainFrame->frame()->selection().rootEditableElement()->layout
Object(); | 4418 layoutObject = mainFrame->frame()->selection().rootEditableElement()->layout
Object(); |
4424 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1)); | 4419 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1)); |
4425 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000)); | 4420 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000)); |
4426 } | 4421 } |
4427 | 4422 |
4428 #if !OS(MACOSX) && !OS(LINUX) | 4423 #if !OS(MACOSX) && !OS(LINUX) |
4429 TEST_P(ParameterizedWebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) | 4424 TEST_P(ParameterizedWebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) |
4430 { | 4425 { |
4431 registerMockedHttpURLLoad("move_caret.html"); | 4426 registerMockedHttpURLLoad("move_caret.html"); |
4432 | 4427 |
4433 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4428 FrameTestHelpers::WebViewHelper webViewHelper; |
4434 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); | 4429 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); |
4435 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 4430 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
4436 | 4431 |
4437 WebRect initialStartRect; | 4432 WebRect initialStartRect; |
4438 WebRect initialEndRect; | 4433 WebRect initialEndRect; |
4439 WebRect startRect; | 4434 WebRect startRect; |
4440 WebRect endRect; | 4435 WebRect endRect; |
4441 | 4436 |
4442 frame->executeScript(WebScriptSource("selectRange();")); | 4437 frame->executeScript(WebScriptSource("selectRange();")); |
4443 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); | 4438 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); |
(...skipping 24 matching lines...) Expand all Loading... |
4468 webViewHelper.webView()->selectionBounds(startRect, endRect); | 4463 webViewHelper.webView()->selectionBounds(startRect, endRect); |
4469 EXPECT_EQ(startRect, initialStartRect); | 4464 EXPECT_EQ(startRect, initialStartRect); |
4470 EXPECT_EQ(endRect, initialEndRect); | 4465 EXPECT_EQ(endRect, initialEndRect); |
4471 } | 4466 } |
4472 | 4467 |
4473 TEST_P(ParameterizedWebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) | 4468 TEST_P(ParameterizedWebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) |
4474 { | 4469 { |
4475 WebLocalFrameImpl* frame; | 4470 WebLocalFrameImpl* frame; |
4476 registerMockedHttpURLLoad("move_caret.html"); | 4471 registerMockedHttpURLLoad("move_caret.html"); |
4477 | 4472 |
4478 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4473 FrameTestHelpers::WebViewHelper webViewHelper; |
4479 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); | 4474 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); |
4480 frame = (WebLocalFrameImpl*)webViewHelper.webView()->mainFrame(); | 4475 frame = (WebLocalFrameImpl*)webViewHelper.webView()->mainFrame(); |
4481 | 4476 |
4482 WebRect initialStartRect; | 4477 WebRect initialStartRect; |
4483 WebRect initialEndRect; | 4478 WebRect initialEndRect; |
4484 WebRect startRect; | 4479 WebRect startRect; |
4485 WebRect endRect; | 4480 WebRect endRect; |
4486 | 4481 |
4487 frame->executeScript(WebScriptSource("selectCaret();")); | 4482 frame->executeScript(WebScriptSource("selectCaret();")); |
4488 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); | 4483 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4664 | 4659 |
4665 registerMockedHttpURLLoad("select_range_basic.html"); | 4660 registerMockedHttpURLLoad("select_range_basic.html"); |
4666 registerMockedHttpURLLoad("select_range_scroll.html"); | 4661 registerMockedHttpURLLoad("select_range_scroll.html"); |
4667 | 4662 |
4668 int viewWidth = 500; | 4663 int viewWidth = 500; |
4669 int viewHeight = 500; | 4664 int viewHeight = 500; |
4670 | 4665 |
4671 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; | 4666 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; |
4672 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); | 4667 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); |
4673 | 4668 |
4674 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4669 FrameTestHelpers::WebViewHelper webViewHelper; |
4675 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr
); | 4670 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr
); |
4676 webViewHelper.webView()->settings()->setDefaultFontSize(12); | 4671 webViewHelper.webView()->settings()->setDefaultFontSize(12); |
4677 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); | 4672 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); |
4678 webViewHelper.resize(WebSize(viewWidth, viewHeight)); | 4673 webViewHelper.resize(WebSize(viewWidth, viewHeight)); |
4679 webViewHelper.webView()->setFocus(true); | 4674 webViewHelper.webView()->setFocus(true); |
4680 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "select_range_basic.html"); | 4675 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "select_range_basic.html"); |
4681 | 4676 |
4682 // The frame starts with no selection. | 4677 // The frame starts with no selection. |
4683 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); | 4678 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); |
4684 ASSERT_TRUE(frame->hasSelection()); | 4679 ASSERT_TRUE(frame->hasSelection()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4746 | 4741 |
4747 TEST_P(ParameterizedWebFrameTest, DisambiguationPopup) | 4742 TEST_P(ParameterizedWebFrameTest, DisambiguationPopup) |
4748 { | 4743 { |
4749 const std::string htmlFile = "disambiguation_popup.html"; | 4744 const std::string htmlFile = "disambiguation_popup.html"; |
4750 registerMockedHttpURLLoad(htmlFile); | 4745 registerMockedHttpURLLoad(htmlFile); |
4751 | 4746 |
4752 DisambiguationPopupTestWebViewClient client; | 4747 DisambiguationPopupTestWebViewClient client; |
4753 | 4748 |
4754 // Make sure we initialize to minimum scale, even if the window size | 4749 // Make sure we initialize to minimum scale, even if the window size |
4755 // only becomes available after the load begins. | 4750 // only becomes available after the load begins. |
4756 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4751 FrameTestHelpers::WebViewHelper webViewHelper; |
4757 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); | 4752 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); |
4758 webViewHelper.resize(WebSize(1000, 1000)); | 4753 webViewHelper.resize(WebSize(1000, 1000)); |
4759 | 4754 |
4760 client.resetTriggered(); | 4755 client.resetTriggered(); |
4761 webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); | 4756 webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); |
4762 EXPECT_FALSE(client.triggered()); | 4757 EXPECT_FALSE(client.triggered()); |
4763 | 4758 |
4764 client.resetTriggered(); | 4759 client.resetTriggered(); |
4765 webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); | 4760 webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); |
4766 EXPECT_FALSE(client.triggered()); | 4761 EXPECT_FALSE(client.triggered()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4799 } | 4794 } |
4800 | 4795 |
4801 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupNoContainer) | 4796 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupNoContainer) |
4802 { | 4797 { |
4803 registerMockedHttpURLLoad("disambiguation_popup_no_container.html"); | 4798 registerMockedHttpURLLoad("disambiguation_popup_no_container.html"); |
4804 | 4799 |
4805 DisambiguationPopupTestWebViewClient client; | 4800 DisambiguationPopupTestWebViewClient client; |
4806 | 4801 |
4807 // Make sure we initialize to minimum scale, even if the window size | 4802 // Make sure we initialize to minimum scale, even if the window size |
4808 // only becomes available after the load begins. | 4803 // only becomes available after the load begins. |
4809 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4804 FrameTestHelpers::WebViewHelper webViewHelper; |
4810 webViewHelper.initializeAndLoad(m_baseURL + "disambiguation_popup_no_contain
er.html", true, 0, &client); | 4805 webViewHelper.initializeAndLoad(m_baseURL + "disambiguation_popup_no_contain
er.html", true, 0, &client); |
4811 webViewHelper.resize(WebSize(1000, 1000)); | 4806 webViewHelper.resize(WebSize(1000, 1000)); |
4812 | 4807 |
4813 client.resetTriggered(); | 4808 client.resetTriggered(); |
4814 webViewHelper.webView()->handleInputEvent(fatTap(50, 50)); | 4809 webViewHelper.webView()->handleInputEvent(fatTap(50, 50)); |
4815 EXPECT_FALSE(client.triggered()); | 4810 EXPECT_FALSE(client.triggered()); |
4816 } | 4811 } |
4817 | 4812 |
4818 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupMobileSite) | 4813 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupMobileSite) |
4819 { | 4814 { |
4820 const std::string htmlFile = "disambiguation_popup_mobile_site.html"; | 4815 const std::string htmlFile = "disambiguation_popup_mobile_site.html"; |
4821 registerMockedHttpURLLoad(htmlFile); | 4816 registerMockedHttpURLLoad(htmlFile); |
4822 | 4817 |
4823 DisambiguationPopupTestWebViewClient client; | 4818 DisambiguationPopupTestWebViewClient client; |
4824 | 4819 |
4825 // Make sure we initialize to minimum scale, even if the window size | 4820 // Make sure we initialize to minimum scale, even if the window size |
4826 // only becomes available after the load begins. | 4821 // only becomes available after the load begins. |
4827 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4822 FrameTestHelpers::WebViewHelper webViewHelper; |
4828 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client
, nullptr, enableViewportSettings); | 4823 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client
, nullptr, enableViewportSettings); |
4829 webViewHelper.resize(WebSize(1000, 1000)); | 4824 webViewHelper.resize(WebSize(1000, 1000)); |
4830 | 4825 |
4831 client.resetTriggered(); | 4826 client.resetTriggered(); |
4832 webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); | 4827 webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); |
4833 EXPECT_FALSE(client.triggered()); | 4828 EXPECT_FALSE(client.triggered()); |
4834 | 4829 |
4835 client.resetTriggered(); | 4830 client.resetTriggered(); |
4836 webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); | 4831 webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); |
4837 EXPECT_FALSE(client.triggered()); | 4832 EXPECT_FALSE(client.triggered()); |
(...skipping 13 matching lines...) Expand all Loading... |
4851 | 4846 |
4852 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupViewportSite) | 4847 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupViewportSite) |
4853 { | 4848 { |
4854 const std::string htmlFile = "disambiguation_popup_viewport_site.html"; | 4849 const std::string htmlFile = "disambiguation_popup_viewport_site.html"; |
4855 registerMockedHttpURLLoad(htmlFile); | 4850 registerMockedHttpURLLoad(htmlFile); |
4856 | 4851 |
4857 DisambiguationPopupTestWebViewClient client; | 4852 DisambiguationPopupTestWebViewClient client; |
4858 | 4853 |
4859 // Make sure we initialize to minimum scale, even if the window size | 4854 // Make sure we initialize to minimum scale, even if the window size |
4860 // only becomes available after the load begins. | 4855 // only becomes available after the load begins. |
4861 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4856 FrameTestHelpers::WebViewHelper webViewHelper; |
4862 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client
, nullptr, enableViewportSettings); | 4857 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client
, nullptr, enableViewportSettings); |
4863 webViewHelper.resize(WebSize(1000, 1000)); | 4858 webViewHelper.resize(WebSize(1000, 1000)); |
4864 | 4859 |
4865 client.resetTriggered(); | 4860 client.resetTriggered(); |
4866 webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); | 4861 webViewHelper.webView()->handleInputEvent(fatTap(0, 0)); |
4867 EXPECT_FALSE(client.triggered()); | 4862 EXPECT_FALSE(client.triggered()); |
4868 | 4863 |
4869 client.resetTriggered(); | 4864 client.resetTriggered(); |
4870 webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); | 4865 webViewHelper.webView()->handleInputEvent(fatTap(200, 115)); |
4871 EXPECT_FALSE(client.triggered()); | 4866 EXPECT_FALSE(client.triggered()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4938 const unsigned viewportWidth = 500; | 4933 const unsigned viewportWidth = 500; |
4939 const unsigned viewportHeight = 1000; | 4934 const unsigned viewportHeight = 1000; |
4940 const unsigned divHeight = 100; | 4935 const unsigned divHeight = 100; |
4941 const std::string htmlFile = "disambiguation_popup_blacklist.html"; | 4936 const std::string htmlFile = "disambiguation_popup_blacklist.html"; |
4942 registerMockedHttpURLLoad(htmlFile); | 4937 registerMockedHttpURLLoad(htmlFile); |
4943 | 4938 |
4944 DisambiguationPopupTestWebViewClient client; | 4939 DisambiguationPopupTestWebViewClient client; |
4945 | 4940 |
4946 // Make sure we initialize to minimum scale, even if the window size | 4941 // Make sure we initialize to minimum scale, even if the window size |
4947 // only becomes available after the load begins. | 4942 // only becomes available after the load begins. |
4948 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4943 FrameTestHelpers::WebViewHelper webViewHelper; |
4949 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); | 4944 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); |
4950 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 4945 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
4951 | 4946 |
4952 // Click somewhere where the popup shouldn't appear. | 4947 // Click somewhere where the popup shouldn't appear. |
4953 client.resetTriggered(); | 4948 client.resetTriggered(); |
4954 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, 0)); | 4949 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, 0)); |
4955 EXPECT_FALSE(client.triggered()); | 4950 EXPECT_FALSE(client.triggered()); |
4956 | 4951 |
4957 // Click directly in between two container divs with click handlers, with ch
ildren that don't handle clicks. | 4952 // Click directly in between two container divs with click handlers, with ch
ildren that don't handle clicks. |
4958 client.resetTriggered(); | 4953 client.resetTriggered(); |
4959 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, divHeigh
t)); | 4954 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, divHeigh
t)); |
4960 EXPECT_TRUE(client.triggered()); | 4955 EXPECT_TRUE(client.triggered()); |
4961 | 4956 |
4962 // The third div container should be blacklisted if you click on the link it
contains. | 4957 // The third div container should be blacklisted if you click on the link it
contains. |
4963 client.resetTriggered(); | 4958 client.resetTriggered(); |
4964 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, divHeigh
t * 3.25)); | 4959 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, divHeigh
t * 3.25)); |
4965 EXPECT_FALSE(client.triggered()); | 4960 EXPECT_FALSE(client.triggered()); |
4966 } | 4961 } |
4967 | 4962 |
4968 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupPageScale) | 4963 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupPageScale) |
4969 { | 4964 { |
4970 registerMockedHttpURLLoad("disambiguation_popup_page_scale.html"); | 4965 registerMockedHttpURLLoad("disambiguation_popup_page_scale.html"); |
4971 | 4966 |
4972 DisambiguationPopupTestWebViewClient client; | 4967 DisambiguationPopupTestWebViewClient client; |
4973 | 4968 |
4974 // Make sure we initialize to minimum scale, even if the window size | 4969 // Make sure we initialize to minimum scale, even if the window size |
4975 // only becomes available after the load begins. | 4970 // only becomes available after the load begins. |
4976 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4971 FrameTestHelpers::WebViewHelper webViewHelper; |
4977 webViewHelper.initializeAndLoad(m_baseURL + "disambiguation_popup_page_scale
.html", true, 0, &client); | 4972 webViewHelper.initializeAndLoad(m_baseURL + "disambiguation_popup_page_scale
.html", true, 0, &client); |
4978 webViewHelper.resize(WebSize(1000, 1000)); | 4973 webViewHelper.resize(WebSize(1000, 1000)); |
4979 | 4974 |
4980 client.resetTriggered(); | 4975 client.resetTriggered(); |
4981 webViewHelper.webView()->handleInputEvent(fatTap(80, 80)); | 4976 webViewHelper.webView()->handleInputEvent(fatTap(80, 80)); |
4982 EXPECT_TRUE(client.triggered()); | 4977 EXPECT_TRUE(client.triggered()); |
4983 | 4978 |
4984 client.resetTriggered(); | 4979 client.resetTriggered(); |
4985 webViewHelper.webView()->handleInputEvent(fatTap(230, 190)); | 4980 webViewHelper.webView()->handleInputEvent(fatTap(230, 190)); |
4986 EXPECT_TRUE(client.triggered()); | 4981 EXPECT_TRUE(client.triggered()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5018 bool commitCalled() const { return m_commitCalled; } | 5013 bool commitCalled() const { return m_commitCalled; } |
5019 | 5014 |
5020 private: | 5015 private: |
5021 bool m_commitCalled; | 5016 bool m_commitCalled; |
5022 }; | 5017 }; |
5023 | 5018 |
5024 TEST_P(ParameterizedWebFrameTest, ReplaceNavigationAfterHistoryNavigation) | 5019 TEST_P(ParameterizedWebFrameTest, ReplaceNavigationAfterHistoryNavigation) |
5025 { | 5020 { |
5026 TestSubstituteDataWebFrameClient webFrameClient; | 5021 TestSubstituteDataWebFrameClient webFrameClient; |
5027 | 5022 |
5028 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5023 FrameTestHelpers::WebViewHelper webViewHelper; |
5029 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); | 5024 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); |
5030 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5025 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5031 | 5026 |
5032 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient | 5027 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient |
5033 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. | 5028 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. |
5034 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting | 5029 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting |
5035 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. | 5030 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. |
5036 WebURLError error; | 5031 WebURLError error; |
5037 error.reason = 1337; | 5032 error.reason = 1337; |
5038 error.domain = "WebFrameTest"; | 5033 error.domain = "WebFrameTest"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5075 | 5070 |
5076 int m_numBodies; | 5071 int m_numBodies; |
5077 bool m_didLoad; | 5072 bool m_didLoad; |
5078 }; | 5073 }; |
5079 | 5074 |
5080 TEST_P(ParameterizedWebFrameTest, HTMLDocument) | 5075 TEST_P(ParameterizedWebFrameTest, HTMLDocument) |
5081 { | 5076 { |
5082 registerMockedHttpURLLoad("clipped-body.html"); | 5077 registerMockedHttpURLLoad("clipped-body.html"); |
5083 | 5078 |
5084 TestWillInsertBodyWebFrameClient webFrameClient; | 5079 TestWillInsertBodyWebFrameClient webFrameClient; |
5085 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5080 FrameTestHelpers::WebViewHelper webViewHelper; |
5086 webViewHelper.initializeAndLoad(m_baseURL + "clipped-body.html", false, &web
FrameClient); | 5081 webViewHelper.initializeAndLoad(m_baseURL + "clipped-body.html", false, &web
FrameClient); |
5087 | 5082 |
5088 EXPECT_TRUE(webFrameClient.m_didLoad); | 5083 EXPECT_TRUE(webFrameClient.m_didLoad); |
5089 EXPECT_EQ(1, webFrameClient.m_numBodies); | 5084 EXPECT_EQ(1, webFrameClient.m_numBodies); |
5090 } | 5085 } |
5091 | 5086 |
5092 TEST_P(ParameterizedWebFrameTest, EmptyDocument) | 5087 TEST_P(ParameterizedWebFrameTest, EmptyDocument) |
5093 { | 5088 { |
5094 registerMockedHttpURLLoad("frameserializer/svg/green_rectangle.svg"); | 5089 registerMockedHttpURLLoad("frameserializer/svg/green_rectangle.svg"); |
5095 | 5090 |
5096 TestWillInsertBodyWebFrameClient webFrameClient; | 5091 TestWillInsertBodyWebFrameClient webFrameClient; |
5097 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5092 FrameTestHelpers::WebViewHelper webViewHelper; |
5098 webViewHelper.initialize(false, &webFrameClient); | 5093 webViewHelper.initialize(false, &webFrameClient); |
5099 | 5094 |
5100 EXPECT_FALSE(webFrameClient.m_didLoad); | 5095 EXPECT_FALSE(webFrameClient.m_didLoad); |
5101 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f
rame starts with triggers this. | 5096 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f
rame starts with triggers this. |
5102 } | 5097 } |
5103 | 5098 |
5104 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele
ction) | 5099 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele
ction) |
5105 { | 5100 { |
5106 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5101 FrameTestHelpers::WebViewHelper webViewHelper; |
5107 webViewHelper.initializeAndLoad("about:blank", true); | 5102 webViewHelper.initializeAndLoad("about:blank", true); |
5108 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5103 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5109 | 5104 |
5110 // This test passes if this doesn't crash. | 5105 // This test passes if this doesn't crash. |
5111 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0)); | 5106 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0)); |
5112 } | 5107 } |
5113 | 5108 |
5114 class SpellCheckClient : public WebSpellCheckClient { | 5109 class SpellCheckClient : public WebSpellCheckClient { |
5115 public: | 5110 public: |
5116 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } | 5111 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } |
5117 virtual ~SpellCheckClient() { } | 5112 virtual ~SpellCheckClient() { } |
5118 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con
st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override | 5113 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con
st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override |
5119 { | 5114 { |
5120 ++m_numberOfTimesChecked; | 5115 ++m_numberOfTimesChecked; |
5121 Vector<WebTextCheckingResult> results; | 5116 Vector<WebTextCheckingResult> results; |
5122 const int misspellingStartOffset = 1; | 5117 const int misspellingStartOffset = 1; |
5123 const int misspellingLength = 8; | 5118 const int misspellingLength = 8; |
5124 results.append(WebTextCheckingResult(WebTextDecorationTypeSpelling, miss
pellingStartOffset, misspellingLength, WebString(), m_hash)); | 5119 results.append(WebTextCheckingResult(WebTextDecorationTypeSpelling, miss
pellingStartOffset, misspellingLength, WebString(), m_hash)); |
5125 completion->didFinishCheckingText(results); | 5120 completion->didFinishCheckingText(results); |
5126 } | 5121 } |
5127 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } | 5122 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } |
5128 private: | 5123 private: |
5129 int m_numberOfTimesChecked; | 5124 int m_numberOfTimesChecked; |
5130 uint32_t m_hash; | 5125 uint32_t m_hash; |
5131 }; | 5126 }; |
5132 | 5127 |
5133 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) | 5128 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) |
5134 { | 5129 { |
5135 registerMockedHttpURLLoad("spell.html"); | 5130 registerMockedHttpURLLoad("spell.html"); |
5136 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5131 FrameTestHelpers::WebViewHelper webViewHelper; |
5137 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5132 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5138 SpellCheckClient spellcheck; | 5133 SpellCheckClient spellcheck; |
5139 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5134 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5140 | 5135 |
5141 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5136 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5142 Document* document = frame->frame()->document(); | 5137 Document* document = frame->frame()->document(); |
5143 Element* element = document->getElementById("data"); | 5138 Element* element = document->getElementById("data"); |
5144 | 5139 |
5145 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5140 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
5146 | 5141 |
(...skipping 10 matching lines...) Expand all Loading... |
5157 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); | 5152 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); |
5158 EXPECT_EQ(1U, document->markers().markersInRange(selectionRange, DocumentMar
ker::Spelling).size()); | 5153 EXPECT_EQ(1U, document->markers().markersInRange(selectionRange, DocumentMar
ker::Spelling).size()); |
5159 | 5154 |
5160 frame->replaceMisspelledRange("welcome"); | 5155 frame->replaceMisspelledRange("welcome"); |
5161 EXPECT_EQ("_welcome_.", WebFrameContentDumper::dumpWebViewAsText(webViewHelp
er.webView(), std::numeric_limits<size_t>::max()).utf8()); | 5156 EXPECT_EQ("_welcome_.", WebFrameContentDumper::dumpWebViewAsText(webViewHelp
er.webView(), std::numeric_limits<size_t>::max()).utf8()); |
5162 } | 5157 } |
5163 | 5158 |
5164 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) | 5159 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) |
5165 { | 5160 { |
5166 registerMockedHttpURLLoad("spell.html"); | 5161 registerMockedHttpURLLoad("spell.html"); |
5167 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5162 FrameTestHelpers::WebViewHelper webViewHelper; |
5168 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5163 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5169 SpellCheckClient spellcheck; | 5164 SpellCheckClient spellcheck; |
5170 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5165 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5171 | 5166 |
5172 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5167 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5173 Document* document = frame->frame()->document(); | 5168 Document* document = frame->frame()->document(); |
5174 Element* element = document->getElementById("data"); | 5169 Element* element = document->getElementById("data"); |
5175 | 5170 |
5176 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5171 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
5177 | 5172 |
5178 element->focus(); | 5173 element->focus(); |
5179 NonThrowableExceptionState exceptionState; | 5174 NonThrowableExceptionState exceptionState; |
5180 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); | 5175 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); |
5181 EXPECT_FALSE(exceptionState.hadException()); | 5176 EXPECT_FALSE(exceptionState.hadException()); |
5182 | 5177 |
5183 frame->removeSpellingMarkers(); | 5178 frame->removeSpellingMarkers(); |
5184 | 5179 |
5185 const int allTextBeginOffset = 0; | 5180 const int allTextBeginOffset = 0; |
5186 const int allTextLength = 11; | 5181 const int allTextLength = 11; |
5187 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); | 5182 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); |
5188 EphemeralRange selectionRange = frame->frame()->selection().selection().toNo
rmalizedEphemeralRange(); | 5183 EphemeralRange selectionRange = frame->frame()->selection().selection().toNo
rmalizedEphemeralRange(); |
5189 | 5184 |
5190 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange, DocumentMar
ker::Spelling).size()); | 5185 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange, DocumentMar
ker::Spelling).size()); |
5191 } | 5186 } |
5192 | 5187 |
5193 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) | 5188 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) |
5194 { | 5189 { |
5195 registerMockedHttpURLLoad("spell.html"); | 5190 registerMockedHttpURLLoad("spell.html"); |
5196 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5191 FrameTestHelpers::WebViewHelper webViewHelper; |
5197 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5192 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5198 SpellCheckClient spellcheck; | 5193 SpellCheckClient spellcheck; |
5199 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5194 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5200 | 5195 |
5201 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); | 5196 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); |
5202 Document* document = frame->document(); | 5197 Document* document = frame->document(); |
5203 Element* element = document->getElementById("data"); | 5198 Element* element = document->getElementById("data"); |
5204 | 5199 |
5205 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5200 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
5206 | 5201 |
(...skipping 11 matching lines...) Expand all Loading... |
5218 frame->removeSpellingMarkersUnderWords(words); | 5213 frame->removeSpellingMarkersUnderWords(words); |
5219 | 5214 |
5220 WebVector<uint32_t> documentMarkers2; | 5215 WebVector<uint32_t> documentMarkers2; |
5221 webViewHelper.webView()->spellingMarkers(&documentMarkers2); | 5216 webViewHelper.webView()->spellingMarkers(&documentMarkers2); |
5222 EXPECT_EQ(0U, documentMarkers2.size()); | 5217 EXPECT_EQ(0U, documentMarkers2.size()); |
5223 } | 5218 } |
5224 | 5219 |
5225 TEST_P(ParameterizedWebFrameTest, MarkerHashIdentifiers) | 5220 TEST_P(ParameterizedWebFrameTest, MarkerHashIdentifiers) |
5226 { | 5221 { |
5227 registerMockedHttpURLLoad("spell.html"); | 5222 registerMockedHttpURLLoad("spell.html"); |
5228 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5223 FrameTestHelpers::WebViewHelper webViewHelper; |
5229 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5224 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5230 | 5225 |
5231 static const uint32_t kHash = 42; | 5226 static const uint32_t kHash = 42; |
5232 SpellCheckClient spellcheck(kHash); | 5227 SpellCheckClient spellcheck(kHash); |
5233 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5228 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5234 | 5229 |
5235 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5230 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5236 Document* document = frame->frame()->document(); | 5231 Document* document = frame->frame()->document(); |
5237 Element* element = document->getElementById("data"); | 5232 Element* element = document->getElementById("data"); |
5238 | 5233 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5302 m_completion->didFinishCheckingText(results); | 5297 m_completion->didFinishCheckingText(results); |
5303 m_completion = 0; | 5298 m_completion = 0; |
5304 } | 5299 } |
5305 | 5300 |
5306 WebTextCheckingCompletion* m_completion; | 5301 WebTextCheckingCompletion* m_completion; |
5307 }; | 5302 }; |
5308 | 5303 |
5309 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) | 5304 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) |
5310 { | 5305 { |
5311 registerMockedHttpURLLoad("spell.html"); | 5306 registerMockedHttpURLLoad("spell.html"); |
5312 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5307 FrameTestHelpers::WebViewHelper webViewHelper; |
5313 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5308 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5314 | 5309 |
5315 StubbornSpellCheckClient spellcheck; | 5310 StubbornSpellCheckClient spellcheck; |
5316 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5311 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5317 | 5312 |
5318 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5313 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5319 Document* document = frame->frame()->document(); | 5314 Document* document = frame->frame()->document(); |
5320 Element* element = document->getElementById("data"); | 5315 Element* element = document->getElementById("data"); |
5321 | 5316 |
5322 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5317 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
(...skipping 10 matching lines...) Expand all Loading... |
5333 WebVector<uint32_t> documentMarkers; | 5328 WebVector<uint32_t> documentMarkers; |
5334 webViewHelper.webView()->spellingMarkers(&documentMarkers); | 5329 webViewHelper.webView()->spellingMarkers(&documentMarkers); |
5335 EXPECT_EQ(0U, documentMarkers.size()); | 5330 EXPECT_EQ(0U, documentMarkers.size()); |
5336 } | 5331 } |
5337 | 5332 |
5338 // This test verifies that cancelling spelling request does not cause a | 5333 // This test verifies that cancelling spelling request does not cause a |
5339 // write-after-free when there's no spellcheck client set. | 5334 // write-after-free when there's no spellcheck client set. |
5340 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) | 5335 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) |
5341 { | 5336 { |
5342 registerMockedHttpURLLoad("spell.html"); | 5337 registerMockedHttpURLLoad("spell.html"); |
5343 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5338 FrameTestHelpers::WebViewHelper webViewHelper; |
5344 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5339 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5345 webViewHelper.webView()->setSpellCheckClient(0); | 5340 webViewHelper.webView()->setSpellCheckClient(0); |
5346 | 5341 |
5347 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5342 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5348 Document* document = frame->frame()->document(); | 5343 Document* document = frame->frame()->document(); |
5349 Element* element = document->getElementById("data"); | 5344 Element* element = document->getElementById("data"); |
5350 | 5345 |
5351 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5346 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
5352 | 5347 |
5353 element->focus(); | 5348 element->focus(); |
5354 frame->frame()->editor().replaceSelectionWithText("A", false, false); | 5349 frame->frame()->editor().replaceSelectionWithText("A", false, false); |
5355 frame->frame()->spellChecker().cancelCheck(); | 5350 frame->frame()->spellChecker().cancelCheck(); |
5356 } | 5351 } |
5357 | 5352 |
5358 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) | 5353 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) |
5359 { | 5354 { |
5360 registerMockedHttpURLLoad("spell.html"); | 5355 registerMockedHttpURLLoad("spell.html"); |
5361 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5356 FrameTestHelpers::WebViewHelper webViewHelper; |
5362 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5357 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5363 | 5358 |
5364 StubbornSpellCheckClient spellcheck; | 5359 StubbornSpellCheckClient spellcheck; |
5365 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5360 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5366 | 5361 |
5367 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5362 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5368 Document* document = frame->frame()->document(); | 5363 Document* document = frame->frame()->document(); |
5369 Element* element = document->getElementById("data"); | 5364 Element* element = document->getElementById("data"); |
5370 | 5365 |
5371 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5366 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
(...skipping 11 matching lines...) Expand all Loading... |
5383 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::InvisibleSpellcheck); | 5378 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::InvisibleSpellcheck); |
5384 EXPECT_EQ(3U, document->markers().markers().size()); | 5379 EXPECT_EQ(3U, document->markers().markers().size()); |
5385 | 5380 |
5386 spellcheck.kickNoResults(); | 5381 spellcheck.kickNoResults(); |
5387 EXPECT_EQ(0U, document->markers().markers().size()); | 5382 EXPECT_EQ(0U, document->markers().markers().size()); |
5388 } | 5383 } |
5389 | 5384 |
5390 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) | 5385 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) |
5391 { | 5386 { |
5392 registerMockedHttpURLLoad("spell.html"); | 5387 registerMockedHttpURLLoad("spell.html"); |
5393 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5388 FrameTestHelpers::WebViewHelper webViewHelper; |
5394 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5389 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5395 | 5390 |
5396 StubbornSpellCheckClient spellcheck; | 5391 StubbornSpellCheckClient spellcheck; |
5397 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5392 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5398 | 5393 |
5399 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 5394 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
5400 Document* document = frame->frame()->document(); | 5395 Document* document = frame->frame()->document(); |
5401 Element* element = document->getElementById("data"); | 5396 Element* element = document->getElementById("data"); |
5402 | 5397 |
5403 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 5398 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5444 bool m_didAccessInitialDocument; | 5439 bool m_didAccessInitialDocument; |
5445 }; | 5440 }; |
5446 | 5441 |
5447 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBody) | 5442 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBody) |
5448 { | 5443 { |
5449 // FIXME: Why is this local webViewClient needed instead of the default | 5444 // FIXME: Why is this local webViewClient needed instead of the default |
5450 // WebViewHelper one? With out it there's some mysterious crash in the | 5445 // WebViewHelper one? With out it there's some mysterious crash in the |
5451 // WebViewHelper destructor. | 5446 // WebViewHelper destructor. |
5452 FrameTestHelpers::TestWebViewClient webViewClient; | 5447 FrameTestHelpers::TestWebViewClient webViewClient; |
5453 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5448 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5454 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5449 FrameTestHelpers::WebViewHelper webViewHelper; |
5455 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5450 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5456 runPendingTasks(); | 5451 runPendingTasks(); |
5457 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5452 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5458 | 5453 |
5459 // Create another window that will try to access it. | 5454 // Create another window that will try to access it. |
5460 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5455 FrameTestHelpers::WebViewHelper newWebViewHelper; |
5461 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); | 5456 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5462 runPendingTasks(); | 5457 runPendingTasks(); |
5463 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5458 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5464 | 5459 |
5465 // Access the initial document by modifying the body. | 5460 // Access the initial document by modifying the body. |
5466 newView->mainFrame()->executeScript( | 5461 newView->mainFrame()->executeScript( |
5467 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5462 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
5468 runPendingTasks(); | 5463 runPendingTasks(); |
5469 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5464 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5470 | 5465 |
5471 // Access the initial document again, to ensure we don't notify twice. | 5466 // Access the initial document again, to ensure we don't notify twice. |
5472 newView->mainFrame()->executeScript( | 5467 newView->mainFrame()->executeScript( |
5473 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5468 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
5474 runPendingTasks(); | 5469 runPendingTasks(); |
5475 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5470 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5476 } | 5471 } |
5477 | 5472 |
5478 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentNavigator) | 5473 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentNavigator) |
5479 { | 5474 { |
5480 // FIXME: Why is this local webViewClient needed instead of the default | 5475 // FIXME: Why is this local webViewClient needed instead of the default |
5481 // WebViewHelper one? With out it there's some mysterious crash in the | 5476 // WebViewHelper one? With out it there's some mysterious crash in the |
5482 // WebViewHelper destructor. | 5477 // WebViewHelper destructor. |
5483 FrameTestHelpers::TestWebViewClient webViewClient; | 5478 FrameTestHelpers::TestWebViewClient webViewClient; |
5484 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5479 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5485 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5480 FrameTestHelpers::WebViewHelper webViewHelper; |
5486 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5481 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5487 runPendingTasks(); | 5482 runPendingTasks(); |
5488 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5483 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5489 | 5484 |
5490 // Create another window that will try to access it. | 5485 // Create another window that will try to access it. |
5491 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5486 FrameTestHelpers::WebViewHelper newWebViewHelper; |
5492 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); | 5487 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5493 runPendingTasks(); | 5488 runPendingTasks(); |
5494 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5489 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5495 | 5490 |
5496 // Access the initial document to get to the navigator object. | 5491 // Access the initial document to get to the navigator object. |
5497 newView->mainFrame()->executeScript( | 5492 newView->mainFrame()->executeScript( |
5498 WebScriptSource("console.log(window.opener.navigator);")); | 5493 WebScriptSource("console.log(window.opener.navigator);")); |
5499 runPendingTasks(); | 5494 runPendingTasks(); |
5500 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5495 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5501 } | 5496 } |
5502 | 5497 |
5503 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) | 5498 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) |
5504 { | 5499 { |
5505 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5500 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5506 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5501 FrameTestHelpers::WebViewHelper webViewHelper; |
5507 webViewHelper.initialize(true, &webFrameClient); | 5502 webViewHelper.initialize(true, &webFrameClient); |
5508 runPendingTasks(); | 5503 runPendingTasks(); |
5509 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5504 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5510 | 5505 |
5511 // Access the initial document from a javascript: URL. | 5506 // Access the initial document from a javascript: URL. |
5512 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Modified'))"); | 5507 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Modified'))"); |
5513 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5508 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5514 } | 5509 } |
5515 | 5510 |
5516 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 | 5511 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 |
5517 #if OS(WIN) | 5512 #if OS(WIN) |
5518 TEST_P(ParameterizedWebFrameTest, DISABLED_DidAccessInitialDocumentBodyBeforeMod
alDialog) | 5513 TEST_P(ParameterizedWebFrameTest, DISABLED_DidAccessInitialDocumentBodyBeforeMod
alDialog) |
5519 #else | 5514 #else |
5520 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) | 5515 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) |
5521 #endif | 5516 #endif |
5522 { | 5517 { |
5523 // FIXME: Why is this local webViewClient needed instead of the default | 5518 // FIXME: Why is this local webViewClient needed instead of the default |
5524 // WebViewHelper one? With out it there's some mysterious crash in the | 5519 // WebViewHelper one? With out it there's some mysterious crash in the |
5525 // WebViewHelper destructor. | 5520 // WebViewHelper destructor. |
5526 FrameTestHelpers::TestWebViewClient webViewClient; | 5521 FrameTestHelpers::TestWebViewClient webViewClient; |
5527 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5522 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5528 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5523 FrameTestHelpers::WebViewHelper webViewHelper; |
5529 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5524 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5530 runPendingTasks(); | 5525 runPendingTasks(); |
5531 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5526 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5532 | 5527 |
5533 // Create another window that will try to access it. | 5528 // Create another window that will try to access it. |
5534 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5529 FrameTestHelpers::WebViewHelper newWebViewHelper; |
5535 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); | 5530 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5536 runPendingTasks(); | 5531 runPendingTasks(); |
5537 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5532 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5538 | 5533 |
5539 // Access the initial document by modifying the body. | 5534 // Access the initial document by modifying the body. |
5540 newView->mainFrame()->executeScript( | 5535 newView->mainFrame()->executeScript( |
5541 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5536 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
5542 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5537 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5543 | 5538 |
5544 // Run a modal dialog, which used to run a nested message loop and require | 5539 // Run a modal dialog, which used to run a nested message loop and require |
(...skipping 12 matching lines...) Expand all Loading... |
5557 TEST_P(ParameterizedWebFrameTest, DISABLED_DidWriteToInitialDocumentBeforeModalD
ialog) | 5552 TEST_P(ParameterizedWebFrameTest, DISABLED_DidWriteToInitialDocumentBeforeModalD
ialog) |
5558 #else | 5553 #else |
5559 TEST_P(ParameterizedWebFrameTest, DidWriteToInitialDocumentBeforeModalDialog) | 5554 TEST_P(ParameterizedWebFrameTest, DidWriteToInitialDocumentBeforeModalDialog) |
5560 #endif | 5555 #endif |
5561 { | 5556 { |
5562 // FIXME: Why is this local webViewClient needed instead of the default | 5557 // FIXME: Why is this local webViewClient needed instead of the default |
5563 // WebViewHelper one? With out it there's some mysterious crash in the | 5558 // WebViewHelper one? With out it there's some mysterious crash in the |
5564 // WebViewHelper destructor. | 5559 // WebViewHelper destructor. |
5565 FrameTestHelpers::TestWebViewClient webViewClient; | 5560 FrameTestHelpers::TestWebViewClient webViewClient; |
5566 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5561 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5567 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5562 FrameTestHelpers::WebViewHelper webViewHelper; |
5568 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5563 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5569 runPendingTasks(); | 5564 runPendingTasks(); |
5570 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5565 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5571 | 5566 |
5572 // Create another window that will try to access it. | 5567 // Create another window that will try to access it. |
5573 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5568 FrameTestHelpers::WebViewHelper newWebViewHelper; |
5574 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); | 5569 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5575 runPendingTasks(); | 5570 runPendingTasks(); |
5576 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5571 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5577 | 5572 |
5578 // Access the initial document with document.write, which moves us past the | 5573 // Access the initial document with document.write, which moves us past the |
5579 // initial empty document state of the state machine. | 5574 // initial empty document state of the state machine. |
5580 newView->mainFrame()->executeScript( | 5575 newView->mainFrame()->executeScript( |
5581 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); | 5576 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); |
5582 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5577 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5583 | 5578 |
(...skipping 27 matching lines...) Expand all Loading... |
5611 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 5606 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect |
5612 // which is called from LocalFrame::createView (before the frame is asso
ciated | 5607 // which is called from LocalFrame::createView (before the frame is asso
ciated |
5613 // with the the view). | 5608 // with the the view). |
5614 if (view) | 5609 if (view) |
5615 m_didScrollFrame = true; | 5610 m_didScrollFrame = true; |
5616 } | 5611 } |
5617 private: | 5612 private: |
5618 bool m_didScrollFrame; | 5613 bool m_didScrollFrame; |
5619 }; | 5614 }; |
5620 | 5615 |
5621 TEST_P(ParameterizedWebFrameTest, CompositorScrollIsUserScrollLongPage) | 5616 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) |
5622 { | 5617 { |
5623 registerMockedHttpURLLoad("long_scroll.html"); | 5618 registerMockedHttpURLLoad("long_scroll.html"); |
5624 TestScrolledFrameClient client; | 5619 TestScrolledFrameClient client; |
5625 | 5620 |
5626 // Make sure we initialize to minimum scale, even if the window size | 5621 // Make sure we initialize to minimum scale, even if the window size |
5627 // only becomes available after the load begins. | 5622 // only becomes available after the load begins. |
5628 FrameTestHelpers::WebViewHelper webViewHelper; | 5623 FrameTestHelpers::WebViewHelper webViewHelper; |
5629 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien
t); | 5624 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien
t); |
5630 webViewHelper.resize(WebSize(1000, 1000)); | 5625 webViewHelper.resize(WebSize(1000, 1000)); |
5631 | 5626 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5696 WebURLResponse redirectResponse; | 5691 WebURLResponse redirectResponse; |
5697 redirectResponse.setMIMEType("text/html"); | 5692 redirectResponse.setMIMEType("text/html"); |
5698 redirectResponse.setHTTPStatusCode(302); | 5693 redirectResponse.setHTTPStatusCode(302); |
5699 redirectResponse.setHTTPHeaderField("Location", redirect); | 5694 redirectResponse.setHTTPHeaderField("Location", redirect); |
5700 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec
tResponse, filePath); | 5695 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec
tResponse, filePath); |
5701 | 5696 |
5702 WebURLResponse finalResponse; | 5697 WebURLResponse finalResponse; |
5703 finalResponse.setMIMEType("text/html"); | 5698 finalResponse.setMIMEType("text/html"); |
5704 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin
alResponse, filePath); | 5699 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin
alResponse, filePath); |
5705 | 5700 |
5706 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5701 FrameTestHelpers::WebViewHelper webViewHelper; |
5707 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); | 5702 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); |
5708 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); | 5703 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); |
5709 } | 5704 } |
5710 | 5705 |
5711 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { | 5706 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { |
5712 public: | 5707 public: |
5713 | 5708 |
5714 void didNavigateWithinPage(WebLocalFrame*, const WebHistoryItem&, WebHistory
CommitType, bool) override | 5709 void didNavigateWithinPage(WebLocalFrame*, const WebHistoryItem&, WebHistory
CommitType, bool) override |
5715 { | 5710 { |
5716 EXPECT_TRUE(false); | 5711 EXPECT_TRUE(false); |
5717 } | 5712 } |
5718 }; | 5713 }; |
5719 | 5714 |
5720 TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick) | 5715 TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick) |
5721 { | 5716 { |
5722 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5717 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5723 TestNavigationPolicyWebFrameClient client; | 5718 TestNavigationPolicyWebFrameClient client; |
5724 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5719 FrameTestHelpers::WebViewHelper webViewHelper; |
5725 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); | 5720 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); |
5726 | 5721 |
5727 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); | 5722 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); |
5728 KURL destination = document->url(); | 5723 KURL destination = document->url(); |
5729 destination.setFragmentIdentifier("test"); | 5724 destination.setFragmentIdentifier("test"); |
5730 | 5725 |
5731 Event* event = MouseEvent::create(EventTypeNames::click, false, false, | 5726 Event* event = MouseEvent::create(EventTypeNames::click, false, false, |
5732 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::NoModifiers,
1, 0, nullptr, 0, | 5727 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::NoModifiers,
1, 0, nullptr, 0, |
5733 PlatformMouseEvent::RealOrIndistinguishable, String()); | 5728 PlatformMouseEvent::RealOrIndistinguishable, String()); |
5734 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); | 5729 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
(...skipping 29 matching lines...) Expand all Loading... |
5764 private: | 5759 private: |
5765 int m_decidePolicyCallCount; | 5760 int m_decidePolicyCallCount; |
5766 }; | 5761 }; |
5767 | 5762 |
5768 TEST_P(ParameterizedWebFrameTest, ModifiedClickNewWindow) | 5763 TEST_P(ParameterizedWebFrameTest, ModifiedClickNewWindow) |
5769 { | 5764 { |
5770 registerMockedHttpURLLoad("ctrl_click.html"); | 5765 registerMockedHttpURLLoad("ctrl_click.html"); |
5771 registerMockedHttpURLLoad("hello_world.html"); | 5766 registerMockedHttpURLLoad("hello_world.html"); |
5772 TestNewWindowWebViewClient webViewClient; | 5767 TestNewWindowWebViewClient webViewClient; |
5773 TestNewWindowWebFrameClient webFrameClient; | 5768 TestNewWindowWebFrameClient webFrameClient; |
5774 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5769 FrameTestHelpers::WebViewHelper webViewHelper; |
5775 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); | 5770 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); |
5776 | 5771 |
5777 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); | 5772 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame
())->document(); |
5778 KURL destination = toKURL(m_baseURL + "hello_world.html"); | 5773 KURL destination = toKURL(m_baseURL + "hello_world.html"); |
5779 | 5774 |
5780 // ctrl+click event | 5775 // ctrl+click event |
5781 Event* event = MouseEvent::create(EventTypeNames::click, false, false, | 5776 Event* event = MouseEvent::create(EventTypeNames::click, false, false, |
5782 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::CtrlKey, 0, 0
, nullptr, 0, | 5777 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::CtrlKey, 0, 0
, nullptr, 0, |
5783 PlatformMouseEvent::RealOrIndistinguishable, String()); | 5778 PlatformMouseEvent::RealOrIndistinguishable, String()); |
5784 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); | 5779 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
5785 frameRequest.setTriggeringEvent(event); | 5780 frameRequest.setTriggeringEvent(event); |
5786 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 5781 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
5787 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr
ameRequest); | 5782 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr
ameRequest); |
5788 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); | 5783 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); |
5789 | 5784 |
5790 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 5785 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
5791 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 5786 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
5792 } | 5787 } |
5793 | 5788 |
5794 TEST_P(ParameterizedWebFrameTest, BackToReload) | 5789 TEST_P(ParameterizedWebFrameTest, BackToReload) |
5795 { | 5790 { |
5796 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5791 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5797 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5792 FrameTestHelpers::WebViewHelper webViewHelper; |
5798 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5793 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
5799 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5794 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5800 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); | 5795 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); |
5801 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5796 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); |
5802 EXPECT_TRUE(firstItem); | 5797 EXPECT_TRUE(firstItem); |
5803 | 5798 |
5804 registerMockedHttpURLLoad("white-1x1.png"); | 5799 registerMockedHttpURLLoad("white-1x1.png"); |
5805 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5800 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
5806 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5801 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
5807 | 5802 |
5808 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); | 5803 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); |
5809 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5804 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
5810 | 5805 |
5811 FrameTestHelpers::reloadFrame(frame); | 5806 FrameTestHelpers::reloadFrame(frame); |
5812 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); | 5807 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); |
5813 } | 5808 } |
5814 | 5809 |
5815 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) | 5810 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) |
5816 { | 5811 { |
5817 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 5812 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
5818 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5813 FrameTestHelpers::WebViewHelper webViewHelper; |
5819 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 5814 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
5820 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 5815 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
5821 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); | 5816 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); |
5822 WebFrame* childFrame = mainFrame->firstChild(); | 5817 WebFrame* childFrame = mainFrame->firstChild(); |
5823 ASSERT_TRUE(childFrame); | 5818 ASSERT_TRUE(childFrame); |
5824 | 5819 |
5825 // Start a history navigation, then have a different frame commit a navigati
on. | 5820 // Start a history navigation, then have a different frame commit a navigati
on. |
5826 // In this case, reload an about:blank frame, which will commit synchronousl
y. | 5821 // In this case, reload an about:blank frame, which will commit synchronousl
y. |
5827 // After the history navigation completes, both the appropriate document url
and | 5822 // After the history navigation completes, both the appropriate document url
and |
5828 // the current history item should reflect the history navigation. | 5823 // the current history item should reflect the history navigation. |
5829 registerMockedHttpURLLoad("white-1x1.png"); | 5824 registerMockedHttpURLLoad("white-1x1.png"); |
5830 WebHistoryItem item; | 5825 WebHistoryItem item; |
5831 item.initialize(); | 5826 item.initialize(); |
5832 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 5827 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
5833 item.setURLString(historyURL.string()); | 5828 item.setURLString(historyURL.string()); |
5834 WebURLRequest request = mainFrame->requestFromHistoryItem(item, WebCachePoli
cy::UseProtocolCachePolicy); | 5829 WebURLRequest request = mainFrame->requestFromHistoryItem(item, WebCachePoli
cy::UseProtocolCachePolicy); |
5835 mainFrame->load(request, WebFrameLoadType::BackForward, item); | 5830 mainFrame->load(request, WebFrameLoadType::BackForward, item); |
5836 | 5831 |
5837 FrameTestHelpers::reloadFrame(childFrame); | 5832 FrameTestHelpers::reloadFrame(childFrame); |
5838 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); | 5833 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); |
5839 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); | 5834 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); |
5840 } | 5835 } |
5841 | 5836 |
5842 TEST_P(ParameterizedWebFrameTest, ReloadPost) | 5837 TEST_P(ParameterizedWebFrameTest, ReloadPost) |
5843 { | 5838 { |
5844 registerMockedHttpURLLoad("reload_post.html"); | 5839 registerMockedHttpURLLoad("reload_post.html"); |
5845 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5840 FrameTestHelpers::WebViewHelper webViewHelper; |
5846 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 5841 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
5847 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5842 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5848 | 5843 |
5849 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); | 5844 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); |
5850 // Pump requests one more time after the javascript URL has executed to | 5845 // Pump requests one more time after the javascript URL has executed to |
5851 // trigger the actual POST load request. | 5846 // trigger the actual POST load request. |
5852 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); | 5847 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); |
5853 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); | 5848 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); |
5854 | 5849 |
5855 FrameTestHelpers::reloadFrame(frame); | 5850 FrameTestHelpers::reloadFrame(frame); |
5856 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); | 5851 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); |
5857 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 5852 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
5858 } | 5853 } |
5859 | 5854 |
5860 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) | 5855 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) |
5861 { | 5856 { |
5862 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5857 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5863 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5858 FrameTestHelpers::WebViewHelper webViewHelper; |
5864 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5859 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
5865 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5860 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5866 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); | 5861 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); |
5867 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5862 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); |
5868 EXPECT_TRUE(firstItem); | 5863 EXPECT_TRUE(firstItem); |
5869 | 5864 |
5870 registerMockedHttpURLLoad("white-1x1.png"); | 5865 registerMockedHttpURLLoad("white-1x1.png"); |
5871 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5866 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
5872 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5867 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
5873 | 5868 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5937 }; | 5932 }; |
5938 | 5933 |
5939 TEST_P(ParameterizedWebFrameTest, ReloadIframe) | 5934 TEST_P(ParameterizedWebFrameTest, ReloadIframe) |
5940 { | 5935 { |
5941 registerMockedHttpURLLoad("iframe_reload.html"); | 5936 registerMockedHttpURLLoad("iframe_reload.html"); |
5942 registerMockedHttpURLLoad("visible_iframe.html"); | 5937 registerMockedHttpURLLoad("visible_iframe.html"); |
5943 TestCachePolicyWebFrameClient mainClient(0); | 5938 TestCachePolicyWebFrameClient mainClient(0); |
5944 TestCachePolicyWebFrameClient childClient(&mainClient); | 5939 TestCachePolicyWebFrameClient childClient(&mainClient); |
5945 mainClient.setChildWebFrameClient(&childClient); | 5940 mainClient.setChildWebFrameClient(&childClient); |
5946 | 5941 |
5947 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5942 FrameTestHelpers::WebViewHelper webViewHelper; |
5948 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 5943 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
5949 | 5944 |
5950 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 5945 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
5951 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild())
; | 5946 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild())
; |
5952 ASSERT_EQ(childFrame->client(), &childClient); | 5947 ASSERT_EQ(childFrame->client(), &childClient); |
5953 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 5948 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
5954 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 5949 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
5955 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli
cy); | 5950 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli
cy); |
5956 | 5951 |
5957 FrameTestHelpers::reloadFrame(mainFrame); | 5952 FrameTestHelpers::reloadFrame(mainFrame); |
(...skipping 23 matching lines...) Expand all Loading... |
5981 bool frameLoadTypeReloadMainResourceSeen() const { return m_frameLoadTypeRel
oadMainResourceSeen; } | 5976 bool frameLoadTypeReloadMainResourceSeen() const { return m_frameLoadTypeRel
oadMainResourceSeen; } |
5982 | 5977 |
5983 private: | 5978 private: |
5984 bool m_frameLoadTypeReloadMainResourceSeen; | 5979 bool m_frameLoadTypeReloadMainResourceSeen; |
5985 }; | 5980 }; |
5986 | 5981 |
5987 TEST_P(ParameterizedWebFrameTest, NavigateToSame) | 5982 TEST_P(ParameterizedWebFrameTest, NavigateToSame) |
5988 { | 5983 { |
5989 registerMockedHttpURLLoad("navigate_to_same.html"); | 5984 registerMockedHttpURLLoad("navigate_to_same.html"); |
5990 TestSameDocumentWebFrameClient client; | 5985 TestSameDocumentWebFrameClient client; |
5991 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5986 FrameTestHelpers::WebViewHelper webViewHelper; |
5992 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); | 5987 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); |
5993 EXPECT_FALSE(client.frameLoadTypeReloadMainResourceSeen()); | 5988 EXPECT_FALSE(client.frameLoadTypeReloadMainResourceSeen()); |
5994 | 5989 |
5995 FrameLoadRequest frameRequest(0, ResourceRequest(toLocalFrame(webViewHelper.
webView()->page()->mainFrame())->document()->url())); | 5990 FrameLoadRequest frameRequest(0, ResourceRequest(toLocalFrame(webViewHelper.
webView()->page()->mainFrame())->document()->url())); |
5996 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr
ameRequest); | 5991 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr
ameRequest); |
5997 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); | 5992 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); |
5998 | 5993 |
5999 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen()); | 5994 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen()); |
6000 } | 5995 } |
6001 | 5996 |
(...skipping 16 matching lines...) Expand all Loading... |
6018 | 6013 |
6019 private: | 6014 private: |
6020 int m_numOfImageRequests; | 6015 int m_numOfImageRequests; |
6021 }; | 6016 }; |
6022 | 6017 |
6023 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour
ce) | 6018 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour
ce) |
6024 { | 6019 { |
6025 registerMockedHttpURLLoad("foo_with_image.html"); | 6020 registerMockedHttpURLLoad("foo_with_image.html"); |
6026 registerMockedHttpURLLoad("white-1x1.png"); | 6021 registerMockedHttpURLLoad("white-1x1.png"); |
6027 TestSameDocumentWithImageWebFrameClient client; | 6022 TestSameDocumentWithImageWebFrameClient client; |
6028 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6023 FrameTestHelpers::WebViewHelper webViewHelper; |
6029 webViewHelper.initializeAndLoad(m_baseURL + "foo_with_image.html", true, &cl
ient, nullptr, nullptr, &configureLoadsImagesAutomatically); | 6024 webViewHelper.initializeAndLoad(m_baseURL + "foo_with_image.html", true, &cl
ient, nullptr, nullptr, &configureLoadsImagesAutomatically); |
6030 | 6025 |
6031 WebCache::clear(); | 6026 WebCache::clear(); |
6032 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "foo_with_image.html"); | 6027 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "foo_with_image.html"); |
6033 | 6028 |
6034 // 2 images are requested, and each triggers 2 willSendRequest() calls, | 6029 // 2 images are requested, and each triggers 2 willSendRequest() calls, |
6035 // once for preloading and once for the real request. | 6030 // once for preloading and once for the real request. |
6036 EXPECT_EQ(client.numOfImageRequests(), 4); | 6031 EXPECT_EQ(client.numOfImageRequests(), 4); |
6037 } | 6032 } |
6038 | 6033 |
6039 TEST_P(ParameterizedWebFrameTest, WebNodeImageContents) | 6034 TEST_P(ParameterizedWebFrameTest, WebNodeImageContents) |
6040 { | 6035 { |
6041 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6036 FrameTestHelpers::WebViewHelper webViewHelper; |
6042 webViewHelper.initializeAndLoad("about:blank", true); | 6037 webViewHelper.initializeAndLoad("about:blank", true); |
6043 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6038 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6044 | 6039 |
6045 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; | 6040 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
6046 | 6041 |
6047 // Load up the image and test that we can extract the contents. | 6042 // Load up the image and test that we can extract the contents. |
6048 KURL testURL = toKURL("about:blank"); | 6043 KURL testURL = toKURL("about:blank"); |
6049 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); | 6044 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); |
6050 | 6045 |
6051 WebNode node = frame->document().body().firstChild(); | 6046 WebNode node = frame->document().body().firstChild(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6092 private: | 6087 private: |
6093 int m_startLoadingCount; | 6088 int m_startLoadingCount; |
6094 int m_stopLoadingCount; | 6089 int m_stopLoadingCount; |
6095 int m_differentDocumentStartCount; | 6090 int m_differentDocumentStartCount; |
6096 }; | 6091 }; |
6097 | 6092 |
6098 TEST_P(ParameterizedWebFrameTest, PushStateStartsAndStops) | 6093 TEST_P(ParameterizedWebFrameTest, PushStateStartsAndStops) |
6099 { | 6094 { |
6100 registerMockedHttpURLLoad("push_state.html"); | 6095 registerMockedHttpURLLoad("push_state.html"); |
6101 TestStartStopCallbackWebFrameClient client; | 6096 TestStartStopCallbackWebFrameClient client; |
6102 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6097 FrameTestHelpers::WebViewHelper webViewHelper; |
6103 webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client
); | 6098 webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client
); |
6104 | 6099 |
6105 EXPECT_EQ(client.startLoadingCount(), 2); | 6100 EXPECT_EQ(client.startLoadingCount(), 2); |
6106 EXPECT_EQ(client.stopLoadingCount(), 2); | 6101 EXPECT_EQ(client.stopLoadingCount(), 2); |
6107 EXPECT_EQ(client.differentDocumentStartCount(), 1); | 6102 EXPECT_EQ(client.differentDocumentStartCount(), 1); |
6108 } | 6103 } |
6109 | 6104 |
6110 class TestDidNavigateCommitTypeWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { | 6105 class TestDidNavigateCommitTypeWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { |
6111 public: | 6106 public: |
6112 TestDidNavigateCommitTypeWebFrameClient() | 6107 TestDidNavigateCommitTypeWebFrameClient() |
6113 : m_lastCommitType(WebHistoryInertCommit) | 6108 : m_lastCommitType(WebHistoryInertCommit) |
6114 { | 6109 { |
6115 } | 6110 } |
6116 | 6111 |
6117 void didNavigateWithinPage(WebLocalFrame*, const WebHistoryItem&, WebHistory
CommitType type, bool) override | 6112 void didNavigateWithinPage(WebLocalFrame*, const WebHistoryItem&, WebHistory
CommitType type, bool) override |
6118 { | 6113 { |
6119 m_lastCommitType = type; | 6114 m_lastCommitType = type; |
6120 } | 6115 } |
6121 | 6116 |
6122 WebHistoryCommitType lastCommitType() const { return m_lastCommitType; } | 6117 WebHistoryCommitType lastCommitType() const { return m_lastCommitType; } |
6123 | 6118 |
6124 private: | 6119 private: |
6125 WebHistoryCommitType m_lastCommitType; | 6120 WebHistoryCommitType m_lastCommitType; |
6126 }; | 6121 }; |
6127 | 6122 |
6128 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) | 6123 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) |
6129 { | 6124 { |
6130 registerMockedHttpURLLoad("push_state.html"); | 6125 registerMockedHttpURLLoad("push_state.html"); |
6131 TestDidNavigateCommitTypeWebFrameClient client; | 6126 TestDidNavigateCommitTypeWebFrameClient client; |
6132 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6127 FrameTestHelpers::WebViewHelper webViewHelper; |
6133 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); | 6128 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); |
6134 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame()
)->loader().currentItem(); | 6129 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame()
)->loader().currentItem(); |
6135 runPendingTasks(); | 6130 runPendingTasks(); |
6136 | 6131 |
6137 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(FrameLoadReque
st(nullptr, FrameLoader::resourceRequestFromHistoryItem(item.get(), WebCachePoli
cy::UseProtocolCachePolicy)), FrameLoadTypeBackForward, item.get(), HistorySameD
ocumentLoad); | 6132 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(FrameLoadReque
st(nullptr, FrameLoader::resourceRequestFromHistoryItem(item.get(), WebCachePoli
cy::UseProtocolCachePolicy)), FrameLoadTypeBackForward, item.get(), HistorySameD
ocumentLoad); |
6138 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 6133 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
6139 } | 6134 } |
6140 | 6135 |
6141 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 6136 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
6142 public: | 6137 public: |
(...skipping 18 matching lines...) Expand all Loading... |
6161 WebFrame* m_frame; | 6156 WebFrame* m_frame; |
6162 }; | 6157 }; |
6163 | 6158 |
6164 // Tests that the first navigation in an initially blank subframe will result in | 6159 // Tests that the first navigation in an initially blank subframe will result in |
6165 // a history entry being replaced and not a new one being added. | 6160 // a history entry being replaced and not a new one being added. |
6166 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) | 6161 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) |
6167 { | 6162 { |
6168 registerMockedHttpURLLoad("history.html"); | 6163 registerMockedHttpURLLoad("history.html"); |
6169 registerMockedHttpURLLoad("find.html"); | 6164 registerMockedHttpURLLoad("find.html"); |
6170 | 6165 |
6171 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6166 FrameTestHelpers::WebViewHelper webViewHelper; |
6172 TestHistoryWebFrameClient client; | 6167 TestHistoryWebFrameClient client; |
6173 webViewHelper.initializeAndLoad("about:blank", true, &client); | 6168 webViewHelper.initializeAndLoad("about:blank", true, &client); |
6174 | 6169 |
6175 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6170 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6176 | 6171 |
6177 frame->executeScript(WebScriptSource(WebString::fromUTF8( | 6172 frame->executeScript(WebScriptSource(WebString::fromUTF8( |
6178 "document.body.appendChild(document.createElement('iframe'))"))); | 6173 "document.body.appendChild(document.createElement('iframe'))"))); |
6179 | 6174 |
6180 WebFrame* iframe = frame->firstChild(); | 6175 WebFrame* iframe = frame->firstChild(); |
6181 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); | 6176 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); |
(...skipping 12 matching lines...) Expand all Loading... |
6194 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 6189 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
6195 } | 6190 } |
6196 | 6191 |
6197 // Tests that a navigation in a frame with a non-blank initial URL will create | 6192 // Tests that a navigation in a frame with a non-blank initial URL will create |
6198 // a new history item, unlike the case above. | 6193 // a new history item, unlike the case above. |
6199 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) | 6194 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) |
6200 { | 6195 { |
6201 registerMockedHttpURLLoad("history.html"); | 6196 registerMockedHttpURLLoad("history.html"); |
6202 registerMockedHttpURLLoad("find.html"); | 6197 registerMockedHttpURLLoad("find.html"); |
6203 | 6198 |
6204 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6199 FrameTestHelpers::WebViewHelper webViewHelper; |
6205 TestHistoryWebFrameClient client; | 6200 TestHistoryWebFrameClient client; |
6206 webViewHelper.initializeAndLoad("about:blank", true, &client); | 6201 webViewHelper.initializeAndLoad("about:blank", true, &client); |
6207 | 6202 |
6208 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6203 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6209 | 6204 |
6210 std::string url1 = m_baseURL + "history.html"; | 6205 std::string url1 = m_baseURL + "history.html"; |
6211 FrameTestHelpers::loadFrame(frame, | 6206 FrameTestHelpers::loadFrame(frame, |
6212 "javascript:var f = document.createElement('iframe'); " | 6207 "javascript:var f = document.createElement('iframe'); " |
6213 "f.src = '" + url1 + "';" | 6208 "f.src = '" + url1 + "';" |
6214 "document.body.appendChild(f)"); | 6209 "document.body.appendChild(f)"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6251 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 6246 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
6252 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 6247 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
6253 } | 6248 } |
6254 | 6249 |
6255 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 6250 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. |
6256 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) | 6251 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) |
6257 { | 6252 { |
6258 registerMockedHttpURLLoad("fixed_layout.html"); | 6253 registerMockedHttpURLLoad("fixed_layout.html"); |
6259 std::string url = m_baseURL + "fixed_layout.html"; | 6254 std::string url = m_baseURL + "fixed_layout.html"; |
6260 | 6255 |
6261 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6256 FrameTestHelpers::WebViewHelper webViewHelper; |
6262 webViewHelper.initialize(); | 6257 webViewHelper.initialize(); |
6263 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6258 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6264 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); | 6259 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl(
)->frame()->loader(); |
6265 WebURLRequest request; | 6260 WebURLRequest request; |
6266 request.setURL(toKURL(url)); | 6261 request.setURL(toKURL(url)); |
6267 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 6262 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
6268 frame->loadRequest(request); | 6263 frame->loadRequest(request); |
6269 | 6264 |
6270 // Before commit, there is no history item. | 6265 // Before commit, there is no history item. |
6271 EXPECT_FALSE(mainFrameLoader.currentItem()); | 6266 EXPECT_FALSE(mainFrameLoader.currentItem()); |
(...skipping 20 matching lines...) Expand all Loading... |
6292 | 6287 |
6293 private: | 6288 private: |
6294 int m_callCount; | 6289 int m_callCount; |
6295 }; | 6290 }; |
6296 | 6291 |
6297 // Test that we don't crash if WebFrameClient::createChildFrame() fails. | 6292 // Test that we don't crash if WebFrameClient::createChildFrame() fails. |
6298 TEST_P(ParameterizedWebFrameTest, CreateChildFrameFailure) | 6293 TEST_P(ParameterizedWebFrameTest, CreateChildFrameFailure) |
6299 { | 6294 { |
6300 registerMockedHttpURLLoad("create_child_frame_fail.html"); | 6295 registerMockedHttpURLLoad("create_child_frame_fail.html"); |
6301 FailCreateChildFrame client; | 6296 FailCreateChildFrame client; |
6302 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6297 FrameTestHelpers::WebViewHelper webViewHelper; |
6303 webViewHelper.initializeAndLoad(m_baseURL + "create_child_frame_fail.html",
true, &client); | 6298 webViewHelper.initializeAndLoad(m_baseURL + "create_child_frame_fail.html",
true, &client); |
6304 | 6299 |
6305 EXPECT_EQ(1, client.callCount()); | 6300 EXPECT_EQ(1, client.callCount()); |
6306 } | 6301 } |
6307 | 6302 |
6308 TEST_P(ParameterizedWebFrameTest, fixedPositionInFixedViewport) | 6303 TEST_P(ParameterizedWebFrameTest, fixedPositionInFixedViewport) |
6309 { | 6304 { |
6310 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); | 6305 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); |
6311 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6306 FrameTestHelpers::WebViewHelper webViewHelper; |
6312 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor
t.html", true, nullptr, nullptr, nullptr, enableViewportSettings); | 6307 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor
t.html", true, nullptr, nullptr, nullptr, enableViewportSettings); |
6313 | 6308 |
6314 WebViewImpl* webView = webViewHelper.webView(); | 6309 WebViewImpl* webView = webViewHelper.webView(); |
6315 webViewHelper.resize(WebSize(100, 100)); | 6310 webViewHelper.resize(WebSize(100, 100)); |
6316 | 6311 |
6317 Document* document = webView->mainFrameImpl()->frame()->document(); | 6312 Document* document = webView->mainFrameImpl()->frame()->document(); |
6318 Element* bottomFixed = document->getElementById("bottom-fixed"); | 6313 Element* bottomFixed = document->getElementById("bottom-fixed"); |
6319 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); | 6314 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); |
6320 Element* rightFixed = document->getElementById("right-fixed"); | 6315 Element* rightFixed = document->getElementById("right-fixed"); |
6321 Element* leftRightFixed = document->getElementById("left-right-fixed"); | 6316 Element* leftRightFixed = document->getElementById("left-right-fixed"); |
6322 | 6317 |
6323 // The layout viewport will hit the min-scale limit of 0.25, so it'll be 400
x800. | 6318 // The layout viewport will hit the min-scale limit of 0.25, so it'll be 400
x800. |
6324 webViewHelper.resize(WebSize(100, 200)); | 6319 webViewHelper.resize(WebSize(100, 200)); |
6325 EXPECT_EQ(800, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); | 6320 EXPECT_EQ(800, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); |
6326 EXPECT_EQ(800, topBottomFixed->offsetHeight()); | 6321 EXPECT_EQ(800, topBottomFixed->offsetHeight()); |
6327 | 6322 |
6328 // Now the layout viewport hits the content width limit of 500px so it'll be
500x500. | 6323 // Now the layout viewport hits the content width limit of 500px so it'll be
500x500. |
6329 webViewHelper.resize(WebSize(200, 200)); | 6324 webViewHelper.resize(WebSize(200, 200)); |
6330 EXPECT_EQ(500, rightFixed->offsetLeft() + rightFixed->offsetWidth()); | 6325 EXPECT_EQ(500, rightFixed->offsetLeft() + rightFixed->offsetWidth()); |
6331 EXPECT_EQ(500, leftRightFixed->offsetWidth()); | 6326 EXPECT_EQ(500, leftRightFixed->offsetWidth()); |
6332 } | 6327 } |
6333 | 6328 |
6334 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) | 6329 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) |
6335 { | 6330 { |
6336 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6331 FrameTestHelpers::WebViewHelper webViewHelper; |
6337 webViewHelper.initializeAndLoad("about:blank"); | 6332 webViewHelper.initializeAndLoad("about:blank"); |
6338 webViewHelper.resize(WebSize(200, 200)); | 6333 webViewHelper.resize(WebSize(200, 200)); |
6339 webViewHelper.webView()->updateAllLifecyclePhases(); | 6334 webViewHelper.webView()->updateAllLifecyclePhases(); |
6340 | 6335 |
6341 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView()
; | 6336 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView()
; |
6342 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); | 6337 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); |
6343 frameView->setFrameRect(IntRect(100, 100, 200, 200)); | 6338 frameView->setFrameRect(IntRect(100, 100, 200, 200)); |
6344 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); | 6339 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); |
6345 } | 6340 } |
6346 | 6341 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6424 webViewHelper.webView()->updateAllLifecyclePhases(); | 6419 webViewHelper.webView()->updateAllLifecyclePhases(); |
6425 | 6420 |
6426 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView()
; | 6421 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView()
; |
6427 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); | 6422 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); |
6428 } | 6423 } |
6429 | 6424 |
6430 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) | 6425 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) |
6431 { | 6426 { |
6432 FakeCompositingWebViewClient client; | 6427 FakeCompositingWebViewClient client; |
6433 registerMockedHttpURLLoad("fullscreen_div.html"); | 6428 registerMockedHttpURLLoad("fullscreen_div.html"); |
6434 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6429 FrameTestHelpers::WebViewHelper webViewHelper; |
6435 int viewportWidth = 640; | 6430 int viewportWidth = 640; |
6436 int viewportHeight = 480; | 6431 int viewportHeight = 480; |
6437 client.m_screenInfo.rect.width = viewportWidth; | 6432 client.m_screenInfo.rect.width = viewportWidth; |
6438 client.m_screenInfo.rect.height = viewportHeight; | 6433 client.m_screenInfo.rect.height = viewportHeight; |
6439 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); | 6434 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); |
6440 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6435 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6441 webViewImpl->updateAllLifecyclePhases(); | 6436 webViewImpl->updateAllLifecyclePhases(); |
6442 | 6437 |
6443 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 6438 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
6444 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6439 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6497 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal()); | 6492 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal()); |
6498 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical()); | 6493 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical()); |
6499 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal()); | 6494 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal()); |
6500 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical()); | 6495 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical()); |
6501 } | 6496 } |
6502 | 6497 |
6503 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) | 6498 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) |
6504 { | 6499 { |
6505 FakeCompositingWebViewClient client; | 6500 FakeCompositingWebViewClient client; |
6506 registerMockedHttpURLLoad("fullscreen_div.html"); | 6501 registerMockedHttpURLLoad("fullscreen_div.html"); |
6507 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6502 FrameTestHelpers::WebViewHelper webViewHelper; |
6508 int viewportWidth = 640; | 6503 int viewportWidth = 640; |
6509 int viewportHeight = 480; | 6504 int viewportHeight = 480; |
6510 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); | 6505 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); |
6511 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6506 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6512 webViewImpl->updateAllLifecyclePhases(); | 6507 webViewImpl->updateAllLifecyclePhases(); |
6513 | 6508 |
6514 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 6509 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
6515 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6510 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
6516 Fullscreen::from(*document).requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest); | 6511 Fullscreen::from(*document).requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest); |
6517 webViewImpl->didEnterFullscreen(); | 6512 webViewImpl->didEnterFullscreen(); |
(...skipping 11 matching lines...) Expand all Loading... |
6529 ASSERT_TRUE(webScrollLayer->scrollable()); | 6524 ASSERT_TRUE(webScrollLayer->scrollable()); |
6530 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 6525 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
6531 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 6526 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
6532 } | 6527 } |
6533 | 6528 |
6534 TEST_P(ParameterizedWebFrameTest, FullscreenSubframe) | 6529 TEST_P(ParameterizedWebFrameTest, FullscreenSubframe) |
6535 { | 6530 { |
6536 FakeCompositingWebViewClient client; | 6531 FakeCompositingWebViewClient client; |
6537 registerMockedHttpURLLoad("fullscreen_iframe.html"); | 6532 registerMockedHttpURLLoad("fullscreen_iframe.html"); |
6538 registerMockedHttpURLLoad("fullscreen_div.html"); | 6533 registerMockedHttpURLLoad("fullscreen_div.html"); |
6539 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6534 FrameTestHelpers::WebViewHelper webViewHelper; |
6540 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_iframe.html", true, nullptr, &client, nullptr, configureAndroid); | 6535 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_iframe.html", true, nullptr, &client, nullptr, configureAndroid); |
6541 int viewportWidth = 640; | 6536 int viewportWidth = 640; |
6542 int viewportHeight = 480; | 6537 int viewportHeight = 480; |
6543 client.m_screenInfo.rect.width = viewportWidth; | 6538 client.m_screenInfo.rect.width = viewportWidth; |
6544 client.m_screenInfo.rect.height = viewportHeight; | 6539 client.m_screenInfo.rect.height = viewportHeight; |
6545 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6540 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6546 webViewImpl->updateAllLifecyclePhases(); | 6541 webViewImpl->updateAllLifecyclePhases(); |
6547 | 6542 |
6548 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame(
)->firstChild())->frame()->document(); | 6543 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame(
)->firstChild())->frame()->document(); |
6549 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6544 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
(...skipping 13 matching lines...) Expand all Loading... |
6563 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); | 6558 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); |
6564 webViewImpl->updateAllLifecyclePhases(); | 6559 webViewImpl->updateAllLifecyclePhases(); |
6565 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); | 6560 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); |
6566 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); | 6561 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); |
6567 } | 6562 } |
6568 | 6563 |
6569 TEST_P(ParameterizedWebFrameTest, FullscreenWithTinyViewport) | 6564 TEST_P(ParameterizedWebFrameTest, FullscreenWithTinyViewport) |
6570 { | 6565 { |
6571 FakeCompositingWebViewClient client; | 6566 FakeCompositingWebViewClient client; |
6572 registerMockedHttpURLLoad("viewport-tiny.html"); | 6567 registerMockedHttpURLLoad("viewport-tiny.html"); |
6573 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6568 FrameTestHelpers::WebViewHelper webViewHelper; |
6574 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view
port-tiny.html", true, nullptr, &client, nullptr, configureAndroid); | 6569 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view
port-tiny.html", true, nullptr, &client, nullptr, configureAndroid); |
6575 int viewportWidth = 384; | 6570 int viewportWidth = 384; |
6576 int viewportHeight = 640; | 6571 int viewportHeight = 640; |
6577 client.m_screenInfo.rect.width = viewportWidth; | 6572 client.m_screenInfo.rect.width = viewportWidth; |
6578 client.m_screenInfo.rect.height = viewportHeight; | 6573 client.m_screenInfo.rect.height = viewportHeight; |
6579 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6574 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6580 webViewImpl->updateAllLifecyclePhases(); | 6575 webViewImpl->updateAllLifecyclePhases(); |
6581 | 6576 |
6582 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutViewItem(); | 6577 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutViewItem(); |
6583 EXPECT_EQ(320, layoutViewItem.logicalWidth().floor()); | 6578 EXPECT_EQ(320, layoutViewItem.logicalWidth().floor()); |
(...skipping 19 matching lines...) Expand all Loading... |
6603 EXPECT_EQ(533, layoutViewItem.logicalHeight().floor()); | 6598 EXPECT_EQ(533, layoutViewItem.logicalHeight().floor()); |
6604 EXPECT_FLOAT_EQ(1.2, webViewImpl->pageScaleFactor()); | 6599 EXPECT_FLOAT_EQ(1.2, webViewImpl->pageScaleFactor()); |
6605 EXPECT_FLOAT_EQ(1.2, webViewImpl->minimumPageScaleFactor()); | 6600 EXPECT_FLOAT_EQ(1.2, webViewImpl->minimumPageScaleFactor()); |
6606 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); | 6601 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); |
6607 } | 6602 } |
6608 | 6603 |
6609 TEST_P(ParameterizedWebFrameTest, FullscreenResizeWithTinyViewport) | 6604 TEST_P(ParameterizedWebFrameTest, FullscreenResizeWithTinyViewport) |
6610 { | 6605 { |
6611 FakeCompositingWebViewClient client; | 6606 FakeCompositingWebViewClient client; |
6612 registerMockedHttpURLLoad("viewport-tiny.html"); | 6607 registerMockedHttpURLLoad("viewport-tiny.html"); |
6613 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6608 FrameTestHelpers::WebViewHelper webViewHelper; |
6614 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view
port-tiny.html", true, nullptr, &client, nullptr, configureAndroid); | 6609 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view
port-tiny.html", true, nullptr, &client, nullptr, configureAndroid); |
6615 int viewportWidth = 384; | 6610 int viewportWidth = 384; |
6616 int viewportHeight = 640; | 6611 int viewportHeight = 640; |
6617 client.m_screenInfo.rect.width = viewportWidth; | 6612 client.m_screenInfo.rect.width = viewportWidth; |
6618 client.m_screenInfo.rect.height = viewportHeight; | 6613 client.m_screenInfo.rect.height = viewportHeight; |
6619 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6614 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6620 webViewImpl->updateAllLifecyclePhases(); | 6615 webViewImpl->updateAllLifecyclePhases(); |
6621 | 6616 |
6622 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutViewItem(); | 6617 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutViewItem(); |
6623 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 6618 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6657 // The purpose of this test is to more precisely simulate the sequence of | 6652 // The purpose of this test is to more precisely simulate the sequence of |
6658 // resize and switching fullscreen state operations on WebView, with the | 6653 // resize and switching fullscreen state operations on WebView, with the |
6659 // interference from Android status bars like a real device does. | 6654 // interference from Android status bars like a real device does. |
6660 // This verifies we handle the transition and restore states correctly. | 6655 // This verifies we handle the transition and restore states correctly. |
6661 WebSize screenSizeMinusStatusBarsMinusUrlBar(598, 303); | 6656 WebSize screenSizeMinusStatusBarsMinusUrlBar(598, 303); |
6662 WebSize screenSizeMinusStatusBars(598, 359); | 6657 WebSize screenSizeMinusStatusBars(598, 359); |
6663 WebSize screenSize(640, 384); | 6658 WebSize screenSize(640, 384); |
6664 | 6659 |
6665 FakeCompositingWebViewClient client; | 6660 FakeCompositingWebViewClient client; |
6666 registerMockedHttpURLLoad("fullscreen_restore_scale_factor.html"); | 6661 registerMockedHttpURLLoad("fullscreen_restore_scale_factor.html"); |
6667 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6662 FrameTestHelpers::WebViewHelper webViewHelper; |
6668 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_restore_scale_factor.html", true, nullptr, &client, nullptr, &configureAn
droid); | 6663 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_restore_scale_factor.html", true, nullptr, &client, nullptr, &configureAn
droid); |
6669 client.m_screenInfo.rect.width = screenSizeMinusStatusBarsMinusUrlBar.width; | 6664 client.m_screenInfo.rect.width = screenSizeMinusStatusBarsMinusUrlBar.width; |
6670 client.m_screenInfo.rect.height = screenSizeMinusStatusBarsMinusUrlBar.heigh
t; | 6665 client.m_screenInfo.rect.height = screenSizeMinusStatusBarsMinusUrlBar.heigh
t; |
6671 webViewHelper.resize(screenSizeMinusStatusBarsMinusUrlBar); | 6666 webViewHelper.resize(screenSizeMinusStatusBarsMinusUrlBar); |
6672 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutViewItem(); | 6667 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr
ameView()->layoutViewItem(); |
6673 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.width, layoutViewItem.logical
Width().floor()); | 6668 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.width, layoutViewItem.logical
Width().floor()); |
6674 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.height, layoutViewItem.logica
lHeight().floor()); | 6669 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.height, layoutViewItem.logica
lHeight().floor()); |
6675 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); | 6670 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); |
6676 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); | 6671 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); |
6677 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); | 6672 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6709 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); | 6704 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); |
6710 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); | 6705 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); |
6711 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); | 6706 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); |
6712 } | 6707 } |
6713 | 6708 |
6714 // Tests that leaving fullscreen by navigating to a new page resets the | 6709 // Tests that leaving fullscreen by navigating to a new page resets the |
6715 // fullscreen page scale constraints. | 6710 // fullscreen page scale constraints. |
6716 TEST_P(ParameterizedWebFrameTest, ClearFullscreenConstraintsOnNavigation) | 6711 TEST_P(ParameterizedWebFrameTest, ClearFullscreenConstraintsOnNavigation) |
6717 { | 6712 { |
6718 registerMockedHttpURLLoad("viewport-tiny.html"); | 6713 registerMockedHttpURLLoad("viewport-tiny.html"); |
6719 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6714 FrameTestHelpers::WebViewHelper webViewHelper; |
6720 int viewportWidth = 100; | 6715 int viewportWidth = 100; |
6721 int viewportHeight = 200; | 6716 int viewportHeight = 200; |
6722 | 6717 |
6723 WebViewImpl* webViewImpl = | 6718 WebViewImpl* webViewImpl = |
6724 webViewHelper.initializeAndLoad( | 6719 webViewHelper.initializeAndLoad( |
6725 m_baseURL + "viewport-tiny.html", | 6720 m_baseURL + "viewport-tiny.html", |
6726 true, | 6721 true, |
6727 nullptr, | 6722 nullptr, |
6728 nullptr, | 6723 nullptr, |
6729 nullptr, | 6724 nullptr, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6772 webViewImpl->mainFrameImpl()->frameView()->layoutViewItem(); | 6767 webViewImpl->mainFrameImpl()->frameView()->layoutViewItem(); |
6773 EXPECT_EQ(200, layoutViewItem.logicalWidth().floor()); | 6768 EXPECT_EQ(200, layoutViewItem.logicalWidth().floor()); |
6774 EXPECT_EQ(400, layoutViewItem.logicalHeight().floor()); | 6769 EXPECT_EQ(400, layoutViewItem.logicalHeight().floor()); |
6775 EXPECT_FLOAT_EQ(0.5, webViewImpl->minimumPageScaleFactor()); | 6770 EXPECT_FLOAT_EQ(0.5, webViewImpl->minimumPageScaleFactor()); |
6776 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); | 6771 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); |
6777 } | 6772 } |
6778 | 6773 |
6779 TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants) | 6774 TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants) |
6780 { | 6775 { |
6781 registerMockedHttpURLLoad("percent-height-descendants.html"); | 6776 registerMockedHttpURLLoad("percent-height-descendants.html"); |
6782 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6777 FrameTestHelpers::WebViewHelper webViewHelper; |
6783 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); | 6778 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); |
6784 | 6779 |
6785 WebViewImpl* webView = webViewHelper.webView(); | 6780 WebViewImpl* webView = webViewHelper.webView(); |
6786 webViewHelper.resize(WebSize(800, 800)); | 6781 webViewHelper.resize(WebSize(800, 800)); |
6787 webView->updateAllLifecyclePhases(); | 6782 webView->updateAllLifecyclePhases(); |
6788 | 6783 |
6789 Document* document = webView->mainFrameImpl()->frame()->document(); | 6784 Document* document = webView->mainFrameImpl()->frame()->document(); |
6790 LayoutBlock* container = toLayoutBlock(document->getElementById("container")
->layoutObject()); | 6785 LayoutBlock* container = toLayoutBlock(document->getElementById("container")
->layoutObject()); |
6791 LayoutBox* percentHeightInAnonymous = toLayoutBox(document->getElementById("
percent-height-in-anonymous")->layoutObject()); | 6786 LayoutBox* percentHeightInAnonymous = toLayoutBox(document->getElementById("
percent-height-in-anonymous")->layoutObject()); |
6792 LayoutBox* percentHeightDirectChild = toLayoutBox(document->getElementById("
percent-height-direct-child")->layoutObject()); | 6787 LayoutBox* percentHeightDirectChild = toLayoutBox(document->getElementById("
percent-height-direct-child")->layoutObject()); |
6793 | 6788 |
6794 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightInAnonymous))
; | 6789 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightInAnonymous))
; |
6795 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightDirectChild))
; | 6790 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightDirectChild))
; |
6796 | 6791 |
6797 ASSERT_TRUE(container->percentHeightDescendants()); | 6792 ASSERT_TRUE(container->percentHeightDescendants()); |
6798 ASSERT_TRUE(container->hasPercentHeightDescendants()); | 6793 ASSERT_TRUE(container->hasPercentHeightDescendants()); |
6799 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); | 6794 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); |
6800 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); | 6795 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); |
6801 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); | 6796 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); |
6802 | 6797 |
6803 LayoutBlock* anonymousBlock = percentHeightInAnonymous->containingBlock(); | 6798 LayoutBlock* anonymousBlock = percentHeightInAnonymous->containingBlock(); |
6804 EXPECT_TRUE(anonymousBlock->isAnonymous()); | 6799 EXPECT_TRUE(anonymousBlock->isAnonymous()); |
6805 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); | 6800 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); |
6806 } | 6801 } |
6807 | 6802 |
6808 TEST_P(ParameterizedWebFrameTest, HasVisibleContentOnVisibleFrames) | 6803 TEST_P(ParameterizedWebFrameTest, HasVisibleContentOnVisibleFrames) |
6809 { | 6804 { |
6810 registerMockedHttpURLLoad("visible_frames.html"); | 6805 registerMockedHttpURLLoad("visible_frames.html"); |
6811 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6806 FrameTestHelpers::WebViewHelper webViewHelper; |
6812 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "visi
ble_frames.html"); | 6807 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "visi
ble_frames.html"); |
6813 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { | 6808 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { |
6814 EXPECT_TRUE(frame->hasVisibleContent()); | 6809 EXPECT_TRUE(frame->hasVisibleContent()); |
6815 } | 6810 } |
6816 } | 6811 } |
6817 | 6812 |
6818 TEST_P(ParameterizedWebFrameTest, HasVisibleContentOnHiddenFrames) | 6813 TEST_P(ParameterizedWebFrameTest, HasVisibleContentOnHiddenFrames) |
6819 { | 6814 { |
6820 registerMockedHttpURLLoad("hidden_frames.html"); | 6815 registerMockedHttpURLLoad("hidden_frames.html"); |
6821 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6816 FrameTestHelpers::WebViewHelper webViewHelper; |
6822 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "hidd
en_frames.html"); | 6817 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "hidd
en_frames.html"); |
6823 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { | 6818 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { |
6824 EXPECT_FALSE(frame->hasVisibleContent()); | 6819 EXPECT_FALSE(frame->hasVisibleContent()); |
6825 } | 6820 } |
6826 } | 6821 } |
6827 | 6822 |
6828 class ManifestChangeWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ | 6823 class ManifestChangeWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ |
6829 public: | 6824 public: |
6830 ManifestChangeWebFrameClient() : m_manifestChangeCount(0) { } | 6825 ManifestChangeWebFrameClient() : m_manifestChangeCount(0) { } |
6831 void didChangeManifest() override | 6826 void didChangeManifest() override |
6832 { | 6827 { |
6833 ++m_manifestChangeCount; | 6828 ++m_manifestChangeCount; |
6834 } | 6829 } |
6835 | 6830 |
6836 int manifestChangeCount() { return m_manifestChangeCount; } | 6831 int manifestChangeCount() { return m_manifestChangeCount; } |
6837 | 6832 |
6838 private: | 6833 private: |
6839 int m_manifestChangeCount; | 6834 int m_manifestChangeCount; |
6840 }; | 6835 }; |
6841 | 6836 |
6842 TEST_P(ParameterizedWebFrameTest, NotifyManifestChange) | 6837 TEST_P(ParameterizedWebFrameTest, NotifyManifestChange) |
6843 { | 6838 { |
6844 registerMockedHttpURLLoad("link-manifest-change.html"); | 6839 registerMockedHttpURLLoad("link-manifest-change.html"); |
6845 | 6840 |
6846 ManifestChangeWebFrameClient webFrameClient; | 6841 ManifestChangeWebFrameClient webFrameClient; |
6847 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6842 FrameTestHelpers::WebViewHelper webViewHelper; |
6848 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); | 6843 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); |
6849 | 6844 |
6850 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); | 6845 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); |
6851 } | 6846 } |
6852 | 6847 |
6853 static Resource* fetchManifest(Document* document, const KURL& url) | 6848 static Resource* fetchManifest(Document* document, const KURL& url) |
6854 { | 6849 { |
6855 FetchRequest fetchRequest = FetchRequest(ResourceRequest(url), FetchInitiato
rInfo()); | 6850 FetchRequest fetchRequest = FetchRequest(ResourceRequest(url), FetchInitiato
rInfo()); |
6856 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::Reque
stContextManifest); | 6851 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::Reque
stContextManifest); |
6857 | 6852 |
6858 return RawResource::fetchSynchronously(fetchRequest, document->fetcher()); | 6853 return RawResource::fetchSynchronously(fetchRequest, document->fetcher()); |
6859 } | 6854 } |
6860 | 6855 |
6861 TEST_P(ParameterizedWebFrameTest, ManifestFetch) | 6856 TEST_P(ParameterizedWebFrameTest, ManifestFetch) |
6862 { | 6857 { |
6863 registerMockedHttpURLLoad("foo.html"); | 6858 registerMockedHttpURLLoad("foo.html"); |
6864 registerMockedHttpURLLoad("link-manifest-fetch.json"); | 6859 registerMockedHttpURLLoad("link-manifest-fetch.json"); |
6865 | 6860 |
6866 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6861 FrameTestHelpers::WebViewHelper webViewHelper; |
6867 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6862 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6868 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); | 6863 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); |
6869 | 6864 |
6870 Resource* resource = fetchManifest(document, toKURL(m_baseURL + "link-manife
st-fetch.json")); | 6865 Resource* resource = fetchManifest(document, toKURL(m_baseURL + "link-manife
st-fetch.json")); |
6871 | 6866 |
6872 EXPECT_TRUE(resource->isLoaded()); | 6867 EXPECT_TRUE(resource->isLoaded()); |
6873 } | 6868 } |
6874 | 6869 |
6875 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) | 6870 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) |
6876 { | 6871 { |
6877 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); | 6872 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); |
6878 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); | 6873 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); |
6879 | 6874 |
6880 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6875 FrameTestHelpers::WebViewHelper webViewHelper; |
6881 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6876 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6882 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); | 6877 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); |
6883 | 6878 |
6884 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); | 6879 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); |
6885 | 6880 |
6886 EXPECT_TRUE(resource->isLoaded()); | 6881 EXPECT_TRUE(resource->isLoaded()); |
6887 } | 6882 } |
6888 | 6883 |
6889 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) | 6884 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) |
6890 { | 6885 { |
6891 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); | 6886 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); |
6892 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); | 6887 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); |
6893 | 6888 |
6894 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6889 FrameTestHelpers::WebViewHelper webViewHelper; |
6895 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6890 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6896 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); | 6891 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); |
6897 | 6892 |
6898 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); | 6893 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); |
6899 | 6894 |
6900 EXPECT_EQ(0, resource); // Fetching resource wasn't allowed. | 6895 EXPECT_EQ(0, resource); // Fetching resource wasn't allowed. |
6901 } | 6896 } |
6902 | 6897 |
6903 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) | 6898 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) |
6904 { | 6899 { |
6905 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); | 6900 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); |
6906 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", /* repor
t only */ true); | 6901 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", /* repor
t only */ true); |
6907 | 6902 |
6908 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6903 FrameTestHelpers::WebViewHelper webViewHelper; |
6909 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6904 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6910 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); | 6905 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu
ment(); |
6911 | 6906 |
6912 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); | 6907 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); |
6913 | 6908 |
6914 EXPECT_TRUE(resource->isLoaded()); | 6909 EXPECT_TRUE(resource->isLoaded()); |
6915 } | 6910 } |
6916 | 6911 |
6917 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) | 6912 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) |
6918 { | 6913 { |
6919 // Check that a reload ignoring cache on a frame will result in the cache | 6914 // Check that a reload ignoring cache on a frame will result in the cache |
6920 // policy of the request being set to ReloadBypassingCache. | 6915 // policy of the request being set to ReloadBypassingCache. |
6921 registerMockedHttpURLLoad("foo.html"); | 6916 registerMockedHttpURLLoad("foo.html"); |
6922 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6917 FrameTestHelpers::WebViewHelper webViewHelper; |
6923 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 6918 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
6924 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6919 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6925 FrameTestHelpers::reloadFrameIgnoringCache(frame); | 6920 FrameTestHelpers::reloadFrameIgnoringCache(frame); |
6926 EXPECT_EQ(WebCachePolicy::BypassingCache, frame->dataSource()->request().get
CachePolicy()); | 6921 EXPECT_EQ(WebCachePolicy::BypassingCache, frame->dataSource()->request().get
CachePolicy()); |
6927 } | 6922 } |
6928 | 6923 |
6929 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) | 6924 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) |
6930 { | 6925 { |
6931 // Prepare the reference bitmap. | 6926 // Prepare the reference bitmap. |
6932 SkBitmap bitmap; | 6927 SkBitmap bitmap; |
6933 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh
t()); | 6928 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh
t()); |
6934 SkCanvas canvas(bitmap); | 6929 SkCanvas canvas(bitmap); |
6935 canvas.drawColor(SK_ColorGREEN); | 6930 canvas.drawColor(SK_ColorGREEN); |
6936 | 6931 |
6937 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); | 6932 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); |
6938 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); | 6933 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); |
6939 const SkBitmap& dragBitmap = dragImage->bitmap(); | 6934 const SkBitmap& dragBitmap = dragImage->bitmap(); |
6940 SkAutoLockPixels lockPixel(dragBitmap); | 6935 SkAutoLockPixels lockPixel(dragBitmap); |
6941 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi
ze())); | 6936 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi
ze())); |
6942 } | 6937 } |
6943 | 6938 |
6944 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant) | 6939 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant) |
6945 { | 6940 { |
6946 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6941 FrameTestHelpers::WebViewHelper webViewHelper; |
6947 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-3dtransform-descendant")); | 6942 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-3dtransform-descendant")); |
6948 EXPECT_TRUE(dragImage); | 6943 EXPECT_TRUE(dragImage); |
6949 | 6944 |
6950 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); | 6945 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
6951 } | 6946 } |
6952 | 6947 |
6953 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransform) | 6948 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransform) |
6954 { | 6949 { |
6955 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6950 FrameTestHelpers::WebViewHelper webViewHelper; |
6956 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-transform")); | 6951 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-transform")); |
6957 EXPECT_TRUE(dragImage); | 6952 EXPECT_TRUE(dragImage); |
6958 | 6953 |
6959 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); | 6954 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
6960 } | 6955 } |
6961 | 6956 |
6962 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSS3DTransform) | 6957 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSS3DTransform) |
6963 { | 6958 { |
6964 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6959 FrameTestHelpers::WebViewHelper webViewHelper; |
6965 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-3dtransform")); | 6960 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-3dtransform")); |
6966 EXPECT_TRUE(dragImage); | 6961 EXPECT_TRUE(dragImage); |
6967 | 6962 |
6968 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); | 6963 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
6969 } | 6964 } |
6970 | 6965 |
6971 TEST_P(ParameterizedWebFrameTest, NodeImageTestInlineBlock) | 6966 TEST_P(ParameterizedWebFrameTest, NodeImageTestInlineBlock) |
6972 { | 6967 { |
6973 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6968 FrameTestHelpers::WebViewHelper webViewHelper; |
6974 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-inlineblock")); | 6969 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-inlineblock")); |
6975 EXPECT_TRUE(dragImage); | 6970 EXPECT_TRUE(dragImage); |
6976 | 6971 |
6977 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); | 6972 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
6978 } | 6973 } |
6979 | 6974 |
6980 TEST_P(ParameterizedWebFrameTest, NodeImageTestFloatLeft) | 6975 TEST_P(ParameterizedWebFrameTest, NodeImageTestFloatLeft) |
6981 { | 6976 { |
6982 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6977 FrameTestHelpers::WebViewHelper webViewHelper; |
6983 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-float-left-overflow-hidden")); | 6978 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-float-left-overflow-hidden")); |
6984 EXPECT_TRUE(dragImage); | 6979 EXPECT_TRUE(dragImage); |
6985 | 6980 |
6986 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); | 6981 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
6987 } | 6982 } |
6988 | 6983 |
6989 // Crashes on Android: http://crbug.com/403804 | 6984 // Crashes on Android: http://crbug.com/403804 |
6990 #if OS(ANDROID) | 6985 #if OS(ANDROID) |
6991 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic) | 6986 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic) |
6992 #else | 6987 #else |
6993 TEST_P(ParameterizedWebFrameTest, PrintingBasic) | 6988 TEST_P(ParameterizedWebFrameTest, PrintingBasic) |
6994 #endif | 6989 #endif |
6995 { | 6990 { |
6996 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6991 FrameTestHelpers::WebViewHelper webViewHelper; |
6997 webViewHelper.initializeAndLoad("data:text/html,Hello, world."); | 6992 webViewHelper.initializeAndLoad("data:text/html,Hello, world."); |
6998 | 6993 |
6999 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6994 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7000 | 6995 |
7001 WebPrintParams printParams; | 6996 WebPrintParams printParams; |
7002 printParams.printContentArea.width = 500; | 6997 printParams.printContentArea.width = 500; |
7003 printParams.printContentArea.height = 500; | 6998 printParams.printContentArea.height = 500; |
7004 | 6999 |
7005 int pageCount = frame->printBegin(printParams); | 7000 int pageCount = frame->printBegin(printParams); |
7006 EXPECT_EQ(1, pageCount); | 7001 EXPECT_EQ(1, pageCount); |
(...skipping 22 matching lines...) Expand all Loading... |
7029 { | 7024 { |
7030 m_didNotify = true; | 7025 m_didNotify = true; |
7031 } | 7026 } |
7032 | 7027 |
7033 bool m_didNotify; | 7028 bool m_didNotify; |
7034 }; | 7029 }; |
7035 | 7030 |
7036 TEST_P(ParameterizedWebFrameTest, ThemeColor) | 7031 TEST_P(ParameterizedWebFrameTest, ThemeColor) |
7037 { | 7032 { |
7038 registerMockedHttpURLLoad("theme_color_test.html"); | 7033 registerMockedHttpURLLoad("theme_color_test.html"); |
7039 FrameTestHelpers::WebViewHelper webViewHelper(this); | 7034 FrameTestHelpers::WebViewHelper webViewHelper; |
7040 ThemeColorTestWebFrameClient client; | 7035 ThemeColorTestWebFrameClient client; |
7041 webViewHelper.initializeAndLoad(m_baseURL + "theme_color_test.html", true, &
client); | 7036 webViewHelper.initializeAndLoad(m_baseURL + "theme_color_test.html", true, &
client); |
7042 EXPECT_TRUE(client.didNotify()); | 7037 EXPECT_TRUE(client.didNotify()); |
7043 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 7038 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
7044 EXPECT_EQ(0xff0000ff, frame->document().themeColor()); | 7039 EXPECT_EQ(0xff0000ff, frame->document().themeColor()); |
7045 // Change color by rgb. | 7040 // Change color by rgb. |
7046 client.reset(); | 7041 client.reset(); |
7047 frame->executeScript(WebScriptSource("document.getElementById('tc1').setAttr
ibute('content', 'rgb(0, 0, 0)');")); | 7042 frame->executeScript(WebScriptSource("document.getElementById('tc1').setAttr
ibute('content', 'rgb(0, 0, 0)');")); |
7048 EXPECT_TRUE(client.didNotify()); | 7043 EXPECT_TRUE(client.didNotify()); |
7049 EXPECT_EQ(0xff000000, frame->document().themeColor()); | 7044 EXPECT_EQ(0xff000000, frame->document().themeColor()); |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7862 bool failed() { return m_failed; } | 7857 bool failed() { return m_failed; } |
7863 | 7858 |
7864 bool m_failed; | 7859 bool m_failed; |
7865 }; | 7860 }; |
7866 | 7861 |
7867 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it | 7862 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it |
7868 // requires spin-up of a frame. It may be possible to remove that requirement | 7863 // requires spin-up of a frame. It may be possible to remove that requirement |
7869 // and convert it to a unittest. | 7864 // and convert it to a unittest. |
7870 TEST_P(ParameterizedWebFrameTest, LoaderOriginAccess) | 7865 TEST_P(ParameterizedWebFrameTest, LoaderOriginAccess) |
7871 { | 7866 { |
7872 FrameTestHelpers::WebViewHelper webViewHelper(this); | 7867 FrameTestHelpers::WebViewHelper webViewHelper; |
7873 webViewHelper.initializeAndLoad("about:blank"); | 7868 webViewHelper.initializeAndLoad("about:blank"); |
7874 | 7869 |
7875 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); | 7870 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); |
7876 | 7871 |
7877 // Cross-origin request. | 7872 // Cross-origin request. |
7878 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); | 7873 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); |
7879 ResourceRequest request(resourceUrl); | 7874 ResourceRequest request(resourceUrl); |
7880 request.setRequestContext(WebURLRequest::RequestContextObject); | 7875 request.setRequestContext(WebURLRequest::RequestContextObject); |
7881 registerMockedChromeURLLoad("test.pdf"); | 7876 registerMockedChromeURLLoad("test.pdf"); |
7882 | 7877 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7921 } | 7916 } |
7922 | 7917 |
7923 Vector<WebConsoleMessage> messages; | 7918 Vector<WebConsoleMessage> messages; |
7924 }; | 7919 }; |
7925 | 7920 |
7926 TEST_P(ParameterizedWebFrameTest, CrossDomainAccessErrorsUseCallingWindow) | 7921 TEST_P(ParameterizedWebFrameTest, CrossDomainAccessErrorsUseCallingWindow) |
7927 { | 7922 { |
7928 registerMockedHttpURLLoad("hidden_frames.html"); | 7923 registerMockedHttpURLLoad("hidden_frames.html"); |
7929 registerMockedChromeURLLoad("hello_world.html"); | 7924 registerMockedChromeURLLoad("hello_world.html"); |
7930 | 7925 |
7931 FrameTestHelpers::WebViewHelper webViewHelper(this); | 7926 FrameTestHelpers::WebViewHelper webViewHelper; |
7932 TestConsoleMessageWebFrameClient webFrameClient; | 7927 TestConsoleMessageWebFrameClient webFrameClient; |
7933 FrameTestHelpers::TestWebViewClient webViewClient; | 7928 FrameTestHelpers::TestWebViewClient webViewClient; |
7934 webViewHelper.initializeAndLoad(m_baseURL + "hidden_frames.html", true, &web
FrameClient, &webViewClient); | 7929 webViewHelper.initializeAndLoad(m_baseURL + "hidden_frames.html", true, &web
FrameClient, &webViewClient); |
7935 | 7930 |
7936 // Create another window with a cross-origin page, and point its opener to | 7931 // Create another window with a cross-origin page, and point its opener to |
7937 // first window. | 7932 // first window. |
7938 FrameTestHelpers::WebViewHelper popupWebViewHelper(this); | 7933 FrameTestHelpers::WebViewHelper popupWebViewHelper; |
7939 TestConsoleMessageWebFrameClient popupWebFrameClient; | 7934 TestConsoleMessageWebFrameClient popupWebFrameClient; |
7940 WebView* popupView = popupWebViewHelper.initializeAndLoad(m_chromeURL + "hel
lo_world.html", true, &popupWebFrameClient); | 7935 WebView* popupView = popupWebViewHelper.initializeAndLoad(m_chromeURL + "hel
lo_world.html", true, &popupWebFrameClient); |
7941 popupView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | 7936 popupView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); |
7942 | 7937 |
7943 // Attempt a blocked navigation of an opener's subframe, and ensure that | 7938 // Attempt a blocked navigation of an opener's subframe, and ensure that |
7944 // the error shows up on the popup (calling) window's console, rather than | 7939 // the error shows up on the popup (calling) window's console, rather than |
7945 // the target window. | 7940 // the target window. |
7946 popupView->mainFrame()->executeScript(WebScriptSource("opener.frames[1].loca
tion.href='data:text/html,foo'")); | 7941 popupView->mainFrame()->executeScript(WebScriptSource("opener.frames[1].loca
tion.href='data:text/html,foo'")); |
7947 EXPECT_TRUE(webFrameClient.messages.isEmpty()); | 7942 EXPECT_TRUE(webFrameClient.messages.isEmpty()); |
7948 ASSERT_EQ(1u, popupWebFrameClient.messages.size()); | 7943 ASSERT_EQ(1u, popupWebFrameClient.messages.size()); |
7949 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[0].text.utf8()
.find("Unsafe JavaScript attempt to initiate navigation")); | 7944 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[0].text.utf8()
.find("Unsafe JavaScript attempt to initiate navigation")); |
7950 | 7945 |
7951 // Try setting a cross-origin iframe element's source to a javascript: URL, | 7946 // Try setting a cross-origin iframe element's source to a javascript: URL, |
7952 // and check that this error is also printed on the calling window. | 7947 // and check that this error is also printed on the calling window. |
7953 popupView->mainFrame()->executeScript(WebScriptSource("opener.document.query
SelectorAll('iframe')[1].src='javascript:alert()'")); | 7948 popupView->mainFrame()->executeScript(WebScriptSource("opener.document.query
SelectorAll('iframe')[1].src='javascript:alert()'")); |
7954 EXPECT_TRUE(webFrameClient.messages.isEmpty()); | 7949 EXPECT_TRUE(webFrameClient.messages.isEmpty()); |
7955 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); | 7950 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); |
7956 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); | 7951 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); |
7957 | 7952 |
7958 // Manually reset to break WebViewHelpers' dependencies on the stack | 7953 // Manually reset to break WebViewHelpers' dependencies on the stack |
7959 // allocated WebFrameClients. | 7954 // allocated WebFrameClients. |
7960 webViewHelper.reset(); | 7955 webViewHelper.reset(); |
7961 popupWebViewHelper.reset(); | 7956 popupWebViewHelper.reset(); |
7962 } | 7957 } |
7963 | 7958 |
7964 class DeviceEmulationTest : public ParameterizedWebFrameTest { | 7959 class DeviceEmulationTest : public ParameterizedWebFrameTest { |
7965 protected: | 7960 protected: |
7966 DeviceEmulationTest() | 7961 DeviceEmulationTest() |
7967 : m_webViewHelper(this) | |
7968 { | 7962 { |
7969 registerMockedHttpURLLoad("device_emulation.html"); | 7963 registerMockedHttpURLLoad("device_emulation.html"); |
7970 m_client.m_screenInfo.deviceScaleFactor = 1; | 7964 m_client.m_screenInfo.deviceScaleFactor = 1; |
7971 m_webViewHelper.initializeAndLoad(m_baseURL + "device_emulation.html", t
rue, 0, &m_client); | 7965 m_webViewHelper.initializeAndLoad(m_baseURL + "device_emulation.html", t
rue, 0, &m_client); |
7972 } | 7966 } |
7973 | 7967 |
7974 void testResize(const WebSize size, const String& expectedSize) | 7968 void testResize(const WebSize size, const String& expectedSize) |
7975 { | 7969 { |
7976 m_client.m_screenInfo.rect = WebRect(0, 0, size.width, size.height); | 7970 m_client.m_screenInfo.rect = WebRect(0, 0, size.width, size.height); |
7977 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect; | 7971 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect; |
7978 m_webViewHelper.resize(size); | 7972 m_webViewHelper.resize(size); |
7979 EXPECT_EQ(expectedSize, dumpSize("test")); | 7973 EXPECT_EQ(expectedSize, dumpSize("test")); |
7980 } | 7974 } |
7981 | 7975 |
7982 String dumpSize(const String& id) | 7976 String dumpSize(const String& id) |
7983 { | 7977 { |
7984 String code = "dumpSize('" + id + "')"; | 7978 String code = "dumpSize('" + id + "')"; |
7985 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7979 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7986 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()->
mainFrame()->mainWorldScriptContext()); | 7980 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()->
mainFrame()->mainWorldScriptContext()); |
7987 m_webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndRetur
nValue(WebScriptSource(WebString(code)), false, &callbackHelper); | 7981 m_webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndRetur
nValue(WebScriptSource(WebString(code)), false, &callbackHelper); |
7988 runPendingTasks(); | 7982 runPendingTasks(); |
7989 EXPECT_TRUE(callbackHelper.didComplete()); | 7983 EXPECT_TRUE(callbackHelper.didComplete()); |
7990 return callbackHelper.stringValue(); | 7984 return callbackHelper.stringValue(); |
7991 } | 7985 } |
7992 | 7986 |
7993 FixedLayoutTestWebViewClient m_client; | 7987 FixedLayoutTestWebViewClient m_client; |
7994 FrameTestHelpers::WebViewHelper m_webViewHelper; | 7988 FrameTestHelpers::WebViewHelper m_webViewHelper; |
7995 }; | 7989 }; |
7996 | 7990 |
7997 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Values( | 7991 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Bool()); |
7998 FrameTestHelpers::DefaultSettingOverride, | |
7999 FrameTestHelpers::RootLayerScrollsSettingOverride)); | |
8000 | 7992 |
8001 TEST_P(DeviceEmulationTest, DeviceSizeInvalidatedOnResize) | 7993 TEST_P(DeviceEmulationTest, DeviceSizeInvalidatedOnResize) |
8002 { | 7994 { |
8003 WebDeviceEmulationParams params; | 7995 WebDeviceEmulationParams params; |
8004 params.screenPosition = WebDeviceEmulationParams::Mobile; | 7996 params.screenPosition = WebDeviceEmulationParams::Mobile; |
8005 m_webViewHelper.webView()->enableDeviceEmulation(params); | 7997 m_webViewHelper.webView()->enableDeviceEmulation(params); |
8006 | 7998 |
8007 testResize(WebSize(700, 500), "300x300"); | 7999 testResize(WebSize(700, 500), "300x300"); |
8008 testResize(WebSize(710, 500), "400x300"); | 8000 testResize(WebSize(710, 500), "400x300"); |
8009 testResize(WebSize(690, 500), "200x300"); | 8001 testResize(WebSize(690, 500), "200x300"); |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8917 client.addExpectedRequest(toKURL("http://internal.test/priorities/injected.j
s"), WebURLRequest::PriorityLow); | 8909 client.addExpectedRequest(toKURL("http://internal.test/priorities/injected.j
s"), WebURLRequest::PriorityLow); |
8918 client.addExpectedRequest(toKURL("http://internal.test/priorities/injected-a
sync.js"), WebURLRequest::PriorityLow); | 8910 client.addExpectedRequest(toKURL("http://internal.test/priorities/injected-a
sync.js"), WebURLRequest::PriorityLow); |
8919 client.addExpectedRequest(toKURL("http://internal.test/priorities/body.js"),
WebURLRequest::PriorityHigh); | 8911 client.addExpectedRequest(toKURL("http://internal.test/priorities/body.js"),
WebURLRequest::PriorityHigh); |
8920 | 8912 |
8921 FrameTestHelpers::WebViewHelper helper; | 8913 FrameTestHelpers::WebViewHelper helper; |
8922 helper.initializeAndLoad(m_baseURL + "script_priority.html", true, &client); | 8914 helper.initializeAndLoad(m_baseURL + "script_priority.html", true, &client); |
8923 client.verifyAllRequests(); | 8915 client.verifyAllRequests(); |
8924 } | 8916 } |
8925 | 8917 |
8926 } // namespace blink | 8918 } // namespace blink |
OLD | NEW |