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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 { | 318 { |
319 registerMockedHttpURLLoad("iframes_test.html"); | 319 registerMockedHttpURLLoad("iframes_test.html"); |
320 registerMockedHttpURLLoad("visible_iframe.html"); | 320 registerMockedHttpURLLoad("visible_iframe.html"); |
321 registerMockedHttpURLLoad("invisible_iframe.html"); | 321 registerMockedHttpURLLoad("invisible_iframe.html"); |
322 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 322 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
323 | 323 |
324 FrameTestHelpers::WebViewHelper webViewHelper(this); | 324 FrameTestHelpers::WebViewHelper webViewHelper(this); |
325 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html"); | 325 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html"); |
326 | 326 |
327 // Now retrieve the frames text and test it only includes visible elements. | 327 // Now retrieve the frames text and test it only includes visible elements. |
328 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(webViewHelp
er.webView()->mainFrame()->toWebLocalFrame(), 1024).utf8(); | 328 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
329 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); | 329 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); |
330 EXPECT_NE(std::string::npos, content.find(" visible iframe")); | 330 EXPECT_NE(std::string::npos, content.find(" visible iframe")); |
331 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); | 331 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); |
332 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); | 332 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); |
333 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); | 333 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); |
334 } | 334 } |
335 | 335 |
336 TEST_P(ParameterizedWebFrameTest, FrameForEnteredContext) | 336 TEST_P(ParameterizedWebFrameTest, FrameForEnteredContext) |
337 { | 337 { |
338 registerMockedHttpURLLoad("iframes_test.html"); | 338 registerMockedHttpURLLoad("iframes_test.html"); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 { | 447 { |
448 registerMockedChromeURLLoad("history.html"); | 448 registerMockedChromeURLLoad("history.html"); |
449 | 449 |
450 // Pass true to enable JavaScript. | 450 // Pass true to enable JavaScript. |
451 FrameTestHelpers::WebViewHelper webViewHelper(this); | 451 FrameTestHelpers::WebViewHelper webViewHelper(this); |
452 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); | 452 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); |
453 | 453 |
454 // Try to run JS against the chrome-style URL. | 454 // Try to run JS against the chrome-style URL. |
455 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); | 455 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); |
456 | 456 |
457 // Required to see any updates in contentAsText. | |
458 webViewHelper.webView()->updateAllLifecyclePhases(); | |
459 | |
460 // Now retrieve the frame's text and ensure it was modified by running javas
cript. | 457 // Now retrieve the frame's text and ensure it was modified by running javas
cript. |
461 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(webViewHelp
er.webView()->mainFrame()->toWebLocalFrame(), 1024).utf8(); | 458 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
462 EXPECT_NE(std::string::npos, content.find("Clobbered")); | 459 EXPECT_NE(std::string::npos, content.find("Clobbered")); |
463 } | 460 } |
464 | 461 |
465 TEST_P(ParameterizedWebFrameTest, ChromePageNoJavascript) | 462 TEST_P(ParameterizedWebFrameTest, ChromePageNoJavascript) |
466 { | 463 { |
467 registerMockedChromeURLLoad("history.html"); | 464 registerMockedChromeURLLoad("history.html"); |
468 | 465 |
469 /// Pass true to enable JavaScript. | 466 /// Pass true to enable JavaScript. |
470 FrameTestHelpers::WebViewHelper webViewHelper(this); | 467 FrameTestHelpers::WebViewHelper webViewHelper(this); |
471 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); | 468 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); |
472 | 469 |
473 // Try to run JS against the chrome-style URL after prohibiting it. | 470 // Try to run JS against the chrome-style URL after prohibiting it. |
474 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); | 471 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); |
475 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); | 472 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Clobbered'))"); |
476 | 473 |
477 // Required to see any updates in contentAsText. | |
478 webViewHelper.webView()->updateAllLifecyclePhases(); | |
479 | |
480 // Now retrieve the frame's text and ensure it wasn't modified by running ja
vascript. | 474 // Now retrieve the frame's text and ensure it wasn't modified by running ja
vascript. |
481 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(webViewHelp
er.webView()->mainFrame()->toWebLocalFrame(), 1024).utf8(); | 475 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
482 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 476 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
483 } | 477 } |
484 | 478 |
485 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) | 479 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) |
486 { | 480 { |
487 std::string fileName = "print-location-href.html"; | 481 std::string fileName = "print-location-href.html"; |
488 registerMockedHttpURLLoad(fileName); | 482 registerMockedHttpURLLoad(fileName); |
489 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); | 483 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); |
490 | 484 |
491 FrameTestHelpers::WebViewHelper webViewHelper(this); | 485 FrameTestHelpers::WebViewHelper webViewHelper(this); |
492 | 486 |
493 /// Pass true to enable JavaScript. | 487 /// Pass true to enable JavaScript. |
494 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 488 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
495 | 489 |
496 // Setting host to "hostname:" should be treated as "hostname:0". | 490 // Setting host to "hostname:" should be treated as "hostname:0". |
497 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.host = 'internal.test:'; void 0;"); | 491 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.host = 'internal.test:'; void 0;"); |
498 | 492 |
499 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); | 493 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); |
500 | 494 |
501 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(webViewHelp
er.webView()->mainFrame()->toWebLocalFrame(), 1024).utf8(); | 495 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
502 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 496 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
503 } | 497 } |
504 | 498 |
505 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) | 499 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) |
506 { | 500 { |
507 std::string fileName = "print-location-href.html"; | 501 std::string fileName = "print-location-href.html"; |
508 registerMockedHttpURLLoad(fileName); | 502 registerMockedHttpURLLoad(fileName); |
509 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); | 503 URLTestHelpers::registerMockedURLLoad(toKURL("http://internal.test:0/" + fil
eName), WebString::fromUTF8(fileName)); |
510 | 504 |
511 FrameTestHelpers::WebViewHelper webViewHelper(this); | 505 FrameTestHelpers::WebViewHelper webViewHelper(this); |
512 | 506 |
513 /// Pass true to enable JavaScript. | 507 /// Pass true to enable JavaScript. |
514 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 508 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
515 | 509 |
516 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.port = ''; void 0;"); | 510 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.port = ''; void 0;"); |
517 | 511 |
518 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); | 512 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); |
519 | 513 |
520 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(webViewHelp
er.webView()->mainFrame()->toWebLocalFrame(), 1024).utf8(); | 514 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
521 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 515 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
522 } | 516 } |
523 | 517 |
524 class EvaluateOnLoadWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ | 518 class EvaluateOnLoadWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ |
525 public: | 519 public: |
526 EvaluateOnLoadWebFrameClient() : m_executing(false), m_wasExecuted(false) {
} | 520 EvaluateOnLoadWebFrameClient() : m_executing(false), m_wasExecuted(false) {
} |
527 | 521 |
528 void didClearWindowObject(WebLocalFrame* frame) override | 522 void didClearWindowObject(WebLocalFrame* frame) override |
529 { | 523 { |
530 EXPECT_FALSE(m_executing); | 524 EXPECT_FALSE(m_executing); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))
); | 820 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))
); |
827 WebDocument document = webViewHelper.webView()->mainFrame()->document(); | 821 WebDocument document = webViewHelper.webView()->mainFrame()->document(); |
828 WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); | 822 WebSerializedScriptValue data(WebSerializedScriptValue::fromString("foo")); |
829 WebDOMMessageEvent message(data, "http://origin.com"); | 823 WebDOMMessageEvent message(data, "http://origin.com"); |
830 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(co
rrectOrigin, message); | 824 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(co
rrectOrigin, message); |
831 | 825 |
832 // Send another message with incorrect origin. | 826 // Send another message with incorrect origin. |
833 WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create(toKURL(m_chromeU
RL))); | 827 WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create(toKURL(m_chromeU
RL))); |
834 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(in
correctOrigin, message); | 828 webViewHelper.webView()->mainFrame()->dispatchMessageEventWithOriginCheck(in
correctOrigin, message); |
835 | 829 |
836 // Required to see any updates in contentAsText. | |
837 webViewHelper.webView()->updateAllLifecyclePhases(); | |
838 | |
839 // Verify that only the first addition is in the body of the page. | 830 // Verify that only the first addition is in the body of the page. |
840 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(webViewHelp
er.webView()->mainFrame()->toWebLocalFrame(), 1024).utf8(); | 831 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
841 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 832 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
842 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 833 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
843 } | 834 } |
844 | 835 |
845 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) | 836 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) |
846 { | 837 { |
847 FrameTestHelpers::WebViewHelper webViewHelper(this); | 838 FrameTestHelpers::WebViewHelper webViewHelper(this); |
848 webViewHelper.initializeAndLoad("about:blank"); | 839 webViewHelper.initializeAndLoad("about:blank"); |
849 | 840 |
850 RawPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); | 841 RawPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 | 1019 |
1029 EXPECT_EQ(2, webViewHelper.webViewImpl()->page()->deviceScaleFactor()); | 1020 EXPECT_EQ(2, webViewHelper.webViewImpl()->page()->deviceScaleFactor()); |
1030 | 1021 |
1031 // Device scale factor should be independent of page scale. | 1022 // Device scale factor should be independent of page scale. |
1032 webViewHelper.webView()->setDefaultPageScaleLimits(1, 2); | 1023 webViewHelper.webView()->setDefaultPageScaleLimits(1, 2); |
1033 webViewHelper.webView()->setPageScaleFactor(0.5); | 1024 webViewHelper.webView()->setPageScaleFactor(0.5); |
1034 webViewHelper.webView()->updateAllLifecyclePhases(); | 1025 webViewHelper.webView()->updateAllLifecyclePhases(); |
1035 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1026 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
1036 | 1027 |
1037 // Force the layout to happen before leaving the test. | 1028 // Force the layout to happen before leaving the test. |
1038 WebFrameContentDumper::dumpFrameTreeAsText(webViewHelper.webView()->mainFram
e()->toWebLocalFrame(), 1024).utf8(); | 1029 webViewHelper.webView()->updateAllLifecyclePhases(); |
1039 } | 1030 } |
1040 | 1031 |
1041 TEST_P(ParameterizedWebFrameTest, FixedLayoutInitializeAtMinimumScale) | 1032 TEST_P(ParameterizedWebFrameTest, FixedLayoutInitializeAtMinimumScale) |
1042 { | 1033 { |
1043 registerMockedHttpURLLoad("fixed_layout.html"); | 1034 registerMockedHttpURLLoad("fixed_layout.html"); |
1044 | 1035 |
1045 FixedLayoutTestWebViewClient client; | 1036 FixedLayoutTestWebViewClient client; |
1046 client.m_screenInfo.deviceScaleFactor = 1; | 1037 client.m_screenInfo.deviceScaleFactor = 1; |
1047 int viewportWidth = 640; | 1038 int viewportWidth = 640; |
1048 int viewportHeight = 480; | 1039 int viewportHeight = 480; |
(...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3602 webViewHelper.resize(WebSize(640, 480)); | 3593 webViewHelper.resize(WebSize(640, 480)); |
3603 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3594 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3604 | 3595 |
3605 // Generate a simple test case. | 3596 // Generate a simple test case. |
3606 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 3597 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
3607 KURL testURL = toKURL("about:blank"); | 3598 KURL testURL = toKURL("about:blank"); |
3608 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3599 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3609 | 3600 |
3610 // Make sure it comes out OK. | 3601 // Make sure it comes out OK. |
3611 const std::string expected("Foo bar\nbaz"); | 3602 const std::string expected("Foo bar\nbaz"); |
3612 WebString text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLoca
lFrame(), std::numeric_limits<size_t>::max()); | 3603 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
3613 EXPECT_EQ(expected, text.utf8()); | 3604 EXPECT_EQ(expected, text.utf8()); |
3614 | 3605 |
3615 // Try reading the same one with clipping of the text. | 3606 // Try reading the same one with clipping of the text. |
3616 const int length = 5; | 3607 const int length = 5; |
3617 text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLocalFrame(),
length); | 3608 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), len
gth); |
3618 EXPECT_EQ(expected.substr(0, length), text.utf8()); | 3609 EXPECT_EQ(expected.substr(0, length), text.utf8()); |
3619 | 3610 |
3620 // Now do a new test with a subframe. | 3611 // Now do a new test with a subframe. |
3621 const char outerFrameSource[] = "Hello<iframe></iframe> world"; | 3612 const char outerFrameSource[] = "Hello<iframe></iframe> world"; |
3622 FrameTestHelpers::loadHTMLString(frame, outerFrameSource, testURL); | 3613 FrameTestHelpers::loadHTMLString(frame, outerFrameSource, testURL); |
3623 | 3614 |
3624 // Load something into the subframe. | 3615 // Load something into the subframe. |
3625 WebFrame* subframe = frame->firstChild(); | 3616 WebFrame* subframe = frame->firstChild(); |
3626 ASSERT_TRUE(subframe); | 3617 ASSERT_TRUE(subframe); |
3627 FrameTestHelpers::loadHTMLString(subframe, "sub<p>text", testURL); | 3618 FrameTestHelpers::loadHTMLString(subframe, "sub<p>text", testURL); |
3628 | 3619 |
3629 text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLocalFrame(),
std::numeric_limits<size_t>::max()); | 3620 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std
::numeric_limits<size_t>::max()); |
3630 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); | 3621 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); |
3631 | 3622 |
3632 // Get the frame text where the subframe separator falls on the boundary of | 3623 // Get the frame text where the subframe separator falls on the boundary of |
3633 // what we'll take. There used to be a crash in this case. | 3624 // what we'll take. There used to be a crash in this case. |
3634 text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLocalFrame(),
12); | 3625 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12)
; |
3635 EXPECT_EQ("Hello world", text.utf8()); | 3626 EXPECT_EQ("Hello world", text.utf8()); |
3636 } | 3627 } |
3637 | 3628 |
3638 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) | 3629 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) |
3639 { | 3630 { |
3640 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3631 FrameTestHelpers::WebViewHelper webViewHelper(this); |
3641 webViewHelper.initializeAndLoad("about:blank", true); | 3632 webViewHelper.initializeAndLoad("about:blank", true); |
3642 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3633 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3643 | 3634 |
3644 // Generate a simple test case. | 3635 // Generate a simple test case. |
3645 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 3636 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
3646 KURL testURL = toKURL("about:blank"); | 3637 KURL testURL = toKURL("about:blank"); |
3647 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3638 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3648 | 3639 |
3649 WebString text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLoca
lFrame(), std::numeric_limits<size_t>::max()); | 3640 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
3650 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3641 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
3651 | 3642 |
3652 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame->toWebLoc
alFrame()).utf8(); | 3643 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame->toWebLoc
alFrame()).utf8(); |
3653 | 3644 |
3654 // Load again with the output html. | 3645 // Load again with the output html. |
3655 FrameTestHelpers::loadHTMLString(frame, html, testURL); | 3646 FrameTestHelpers::loadHTMLString(frame, html, testURL); |
3656 | 3647 |
3657 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame->toWebLocalFrame()
).utf8()); | 3648 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame->toWebLocalFrame()
).utf8()); |
3658 | 3649 |
3659 text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLocalFrame(),
std::numeric_limits<size_t>::max()); | 3650 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std
::numeric_limits<size_t>::max()); |
3660 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3651 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
3661 | 3652 |
3662 // Test selection check | 3653 // Test selection check |
3663 EXPECT_FALSE(frame->hasSelection()); | 3654 EXPECT_FALSE(frame->hasSelection()); |
3664 frame->executeCommand(WebString::fromUTF8("SelectAll")); | 3655 frame->executeCommand(WebString::fromUTF8("SelectAll")); |
3665 EXPECT_TRUE(frame->hasSelection()); | 3656 EXPECT_TRUE(frame->hasSelection()); |
3666 frame->executeCommand(WebString::fromUTF8("Unselect")); | 3657 frame->executeCommand(WebString::fromUTF8("Unselect")); |
3667 EXPECT_FALSE(frame->hasSelection()); | 3658 EXPECT_FALSE(frame->hasSelection()); |
3668 WebString selectionHtml = frame->selectionAsMarkup(); | 3659 WebString selectionHtml = frame->selectionAsMarkup(); |
3669 EXPECT_TRUE(selectionHtml.isEmpty()); | 3660 EXPECT_TRUE(selectionHtml.isEmpty()); |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5124 WebURLResponse response; | 5115 WebURLResponse response; |
5125 response.initialize(); | 5116 response.initialize(); |
5126 response.setURL(URLTestHelpers::toKURL(errorURL)); | 5117 response.setURL(URLTestHelpers::toKURL(errorURL)); |
5127 response.setMIMEType("text/html"); | 5118 response.setMIMEType("text/html"); |
5128 response.setHTTPStatusCode(500); | 5119 response.setHTTPStatusCode(500); |
5129 WebHistoryItem errorHistoryItem; | 5120 WebHistoryItem errorHistoryItem; |
5130 errorHistoryItem.initialize(); | 5121 errorHistoryItem.initialize(); |
5131 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); | 5122 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); |
5132 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper
s::toKURL(errorURL), response, error); | 5123 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper
s::toKURL(errorURL), response, error); |
5133 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 5124 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
5134 | 5125 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
5135 WebString text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLoca
lFrame(), std::numeric_limits<size_t>::max()); | |
5136 EXPECT_EQ("This should appear", text.utf8()); | 5126 EXPECT_EQ("This should appear", text.utf8()); |
5137 EXPECT_TRUE(webFrameClient.commitCalled()); | 5127 EXPECT_TRUE(webFrameClient.commitCalled()); |
5138 } | 5128 } |
5139 | 5129 |
5140 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 5130 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
5141 public: | 5131 public: |
5142 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) | 5132 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) |
5143 { | 5133 { |
5144 } | 5134 } |
5145 | 5135 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5238 | 5228 |
5239 const int allTextBeginOffset = 0; | 5229 const int allTextBeginOffset = 0; |
5240 const int allTextLength = 11; | 5230 const int allTextLength = 11; |
5241 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al
lTextLength)); | 5231 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al
lTextLength)); |
5242 EphemeralRange selectionRange = frame->frame()->selection().selection().toNo
rmalizedEphemeralRange(); | 5232 EphemeralRange selectionRange = frame->frame()->selection().selection().toNo
rmalizedEphemeralRange(); |
5243 | 5233 |
5244 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); | 5234 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); |
5245 EXPECT_EQ(1U, document->markers().markersInRange(selectionRange, DocumentMar
ker::Spelling).size()); | 5235 EXPECT_EQ(1U, document->markers().markersInRange(selectionRange, DocumentMar
ker::Spelling).size()); |
5246 | 5236 |
5247 frame->replaceMisspelledRange("welcome"); | 5237 frame->replaceMisspelledRange("welcome"); |
5248 EXPECT_EQ("_welcome_.", WebFrameContentDumper::dumpFrameTreeAsText(frame, st
d::numeric_limits<size_t>::max()).utf8()); | 5238 EXPECT_EQ("_welcome_.", WebFrameContentDumper::dumpWebViewAsText(webViewHelp
er.webView(), std::numeric_limits<size_t>::max()).utf8()); |
5249 } | 5239 } |
5250 | 5240 |
5251 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) | 5241 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) |
5252 { | 5242 { |
5253 registerMockedHttpURLLoad("spell.html"); | 5243 registerMockedHttpURLLoad("spell.html"); |
5254 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5244 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5255 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5245 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
5256 SpellCheckClient spellcheck; | 5246 SpellCheckClient spellcheck; |
5257 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 5247 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
5258 | 5248 |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7042 registerMockedHttpURLLoad("subframe-a.html"); | 7032 registerMockedHttpURLLoad("subframe-a.html"); |
7043 registerMockedHttpURLLoad("subframe-b.html"); | 7033 registerMockedHttpURLLoad("subframe-b.html"); |
7044 registerMockedHttpURLLoad("subframe-c.html"); | 7034 registerMockedHttpURLLoad("subframe-c.html"); |
7045 registerMockedHttpURLLoad("subframe-hello.html"); | 7035 registerMockedHttpURLLoad("subframe-hello.html"); |
7046 | 7036 |
7047 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true); | 7037 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true); |
7048 } | 7038 } |
7049 | 7039 |
7050 void reset() { m_webViewHelper.reset(); } | 7040 void reset() { m_webViewHelper.reset(); } |
7051 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} | 7041 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} |
| 7042 WebView* webView() const { return m_webViewHelper.webView(); } |
7052 | 7043 |
7053 private: | 7044 private: |
7054 FrameTestHelpers::WebViewHelper m_webViewHelper; | 7045 FrameTestHelpers::WebViewHelper m_webViewHelper; |
7055 }; | 7046 }; |
7056 | 7047 |
7057 TEST_F(WebFrameSwapTest, SwapMainFrame) | 7048 TEST_F(WebFrameSwapTest, SwapMainFrame) |
7058 { | 7049 { |
7059 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); | 7050 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); |
7060 mainFrame()->swap(remoteFrame); | 7051 mainFrame()->swap(remoteFrame); |
7061 | 7052 |
7062 FrameTestHelpers::TestWebFrameClient client; | 7053 FrameTestHelpers::TestWebFrameClient client; |
7063 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7054 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
7064 remoteFrame->swap(localFrame); | 7055 remoteFrame->swap(localFrame); |
7065 | 7056 |
7066 // Finally, make sure an embedder triggered load in the local frame swapped | 7057 // Finally, make sure an embedder triggered load in the local frame swapped |
7067 // back in works. | 7058 // back in works. |
7068 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7059 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7069 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(localFrame,
1024).utf8(); | 7060 |
| 7061 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7070 EXPECT_EQ("hello", content); | 7062 EXPECT_EQ("hello", content); |
7071 | 7063 |
7072 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7064 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7073 // TestWebFrameClient. | 7065 // TestWebFrameClient. |
7074 reset(); | 7066 reset(); |
7075 remoteFrame->close(); | 7067 remoteFrame->close(); |
7076 } | 7068 } |
7077 | 7069 |
7078 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) | 7070 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) |
7079 { | 7071 { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7161 | 7153 |
7162 FrameTestHelpers::TestWebFrameClient client; | 7154 FrameTestHelpers::TestWebFrameClient client; |
7163 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7155 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
7164 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; | 7156 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; |
7165 | 7157 |
7166 // FIXME: This almost certainly fires more load events on the iframe element | 7158 // FIXME: This almost certainly fires more load events on the iframe element |
7167 // than it should. | 7159 // than it should. |
7168 // Finally, make sure an embedder triggered load in the local frame swapped | 7160 // Finally, make sure an embedder triggered load in the local frame swapped |
7169 // back in works. | 7161 // back in works. |
7170 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7162 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7171 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(localFrame,
1024).utf8(); | 7163 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7172 EXPECT_EQ("hello", content); | 7164 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content); |
7173 | 7165 |
7174 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7166 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7175 // TestWebFrameClient. | 7167 // TestWebFrameClient. |
7176 reset(); | 7168 reset(); |
7177 remoteFrame->close(); | 7169 remoteFrame->close(); |
7178 } | 7170 } |
7179 | 7171 |
7180 void swapAndVerifyMiddleChildConsistency(const char* const message, WebFrame* pa
rent, WebFrame* newChild) | 7172 void swapAndVerifyMiddleChildConsistency(const char* const message, WebFrame* pa
rent, WebFrame* newChild) |
7181 { | 7173 { |
7182 SCOPED_TRACE(message); | 7174 SCOPED_TRACE(message); |
(...skipping 16 matching lines...) Expand all Loading... |
7199 | 7191 |
7200 FrameTestHelpers::TestWebFrameClient client; | 7192 FrameTestHelpers::TestWebFrameClient client; |
7201 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7193 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
7202 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); | 7194 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); |
7203 | 7195 |
7204 // FIXME: This almost certainly fires more load events on the iframe element | 7196 // FIXME: This almost certainly fires more load events on the iframe element |
7205 // than it should. | 7197 // than it should. |
7206 // Finally, make sure an embedder triggered load in the local frame swapped | 7198 // Finally, make sure an embedder triggered load in the local frame swapped |
7207 // back in works. | 7199 // back in works. |
7208 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7200 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7209 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(localFrame,
1024).utf8(); | 7201 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7210 EXPECT_EQ("hello", content); | 7202 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); |
7211 | 7203 |
7212 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7204 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7213 // TestWebFrameClient. | 7205 // TestWebFrameClient. |
7214 reset(); | 7206 reset(); |
7215 remoteFrame->close(); | 7207 remoteFrame->close(); |
7216 } | 7208 } |
7217 | 7209 |
7218 void swapAndVerifyLastChildConsistency(const char* const message, WebFrame* pare
nt, WebFrame* newChild) | 7210 void swapAndVerifyLastChildConsistency(const char* const message, WebFrame* pare
nt, WebFrame* newChild) |
7219 { | 7211 { |
7220 SCOPED_TRACE(message); | 7212 SCOPED_TRACE(message); |
(...skipping 13 matching lines...) Expand all Loading... |
7234 | 7226 |
7235 FrameTestHelpers::TestWebFrameClient client; | 7227 FrameTestHelpers::TestWebFrameClient client; |
7236 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7228 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
7237 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); | 7229 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
7238 | 7230 |
7239 // FIXME: This almost certainly fires more load events on the iframe element | 7231 // FIXME: This almost certainly fires more load events on the iframe element |
7240 // than it should. | 7232 // than it should. |
7241 // Finally, make sure an embedder triggered load in the local frame swapped | 7233 // Finally, make sure an embedder triggered load in the local frame swapped |
7242 // back in works. | 7234 // back in works. |
7243 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7235 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7244 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(localFrame,
1024).utf8(); | 7236 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7245 EXPECT_EQ("hello", content); | 7237 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content); |
7246 | 7238 |
7247 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7239 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7248 // TestWebFrameClient. | 7240 // TestWebFrameClient. |
7249 reset(); | 7241 reset(); |
7250 remoteFrame->close(); | 7242 remoteFrame->close(); |
7251 } | 7243 } |
7252 | 7244 |
7253 void swapAndVerifySubframeConsistency(const char* const message, WebFrame* oldFr
ame, WebFrame* newFrame) | 7245 void swapAndVerifySubframeConsistency(const char* const message, WebFrame* oldFr
ame, WebFrame* newFrame) |
7254 { | 7246 { |
7255 SCOPED_TRACE(message); | 7247 SCOPED_TRACE(message); |
(...skipping 22 matching lines...) Expand all Loading... |
7278 | 7270 |
7279 FrameTestHelpers::TestWebFrameClient client; | 7271 FrameTestHelpers::TestWebFrameClient client; |
7280 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7272 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
7281 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); | 7273 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
7282 | 7274 |
7283 // FIXME: This almost certainly fires more load events on the iframe element | 7275 // FIXME: This almost certainly fires more load events on the iframe element |
7284 // than it should. | 7276 // than it should. |
7285 // Finally, make sure an embedder triggered load in the local frame swapped | 7277 // Finally, make sure an embedder triggered load in the local frame swapped |
7286 // back in works. | 7278 // back in works. |
7287 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7279 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7288 std::string content = WebFrameContentDumper::dumpFrameTreeAsText(localFrame,
1024).utf8(); | 7280 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7289 EXPECT_EQ("hello", content); | 7281 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); |
7290 | 7282 |
7291 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7283 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7292 // TestWebFrameClient. | 7284 // TestWebFrameClient. |
7293 reset(); | 7285 reset(); |
7294 remoteFrame->close(); | 7286 remoteFrame->close(); |
7295 childRemoteFrame->close(); | 7287 childRemoteFrame->close(); |
7296 } | 7288 } |
7297 | 7289 |
7298 TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext) | 7290 TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext) |
7299 { | 7291 { |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8499 } | 8491 } |
8500 | 8492 |
8501 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) | 8493 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
8502 { | 8494 { |
8503 swapLocalFrameToRemoteFrame(); | 8495 swapLocalFrameToRemoteFrame(); |
8504 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); | 8496 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); |
8505 EXPECT_FALSE(remoteFrameClient()->isVisible()); | 8497 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
8506 } | 8498 } |
8507 | 8499 |
8508 } // namespace blink | 8500 } // namespace blink |
OLD | NEW |