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