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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 143 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
144 } | 144 } |
145 | 145 |
146 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) | 146 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) |
147 { | 147 { |
148 RefPtrWillBeRawPtr<WebCore::StyleSheetContents> styleSheet = WebCore::St
yleSheetContents::create(WebCore::CSSParserContext(WebCore::UASheetMode, 0)); | 148 RefPtrWillBeRawPtr<WebCore::StyleSheetContents> styleSheet = WebCore::St
yleSheetContents::create(WebCore::CSSParserContext(WebCore::UASheetMode, 0)); |
149 styleSheet->parseString(String(WebCore::viewportAndroidUserAgentStyleShe
et, sizeof(WebCore::viewportAndroidUserAgentStyleSheet))); | 149 styleSheet->parseString(String(WebCore::viewportAndroidUserAgentStyleShe
et, sizeof(WebCore::viewportAndroidUserAgentStyleSheet))); |
150 OwnPtrWillBeRawPtr<WebCore::RuleSet> ruleSet = WebCore::RuleSet::create(
); | 150 OwnPtrWillBeRawPtr<WebCore::RuleSet> ruleSet = WebCore::RuleSet::create(
); |
151 ruleSet->addRulesFromSheet(styleSheet.get(), WebCore::MediaQueryEvaluato
r("screen")); | 151 ruleSet->addRulesFromSheet(styleSheet.get(), WebCore::MediaQueryEvaluato
r("screen")); |
152 | 152 |
153 Document* document = webViewHelper->webViewImpl()->page()->mainFrame()->
document(); | 153 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); |
154 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), WebCore::ViewportStyleResolver::UserAgentOrigin); | 154 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), WebCore::ViewportStyleResolver::UserAgentOrigin); |
155 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 155 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
156 } | 156 } |
157 | 157 |
158 static void configueCompositingWebView(WebSettings* settings) | 158 static void configueCompositingWebView(WebSettings* settings) |
159 { | 159 { |
160 settings->setAcceleratedCompositingEnabled(true); | 160 settings->setAcceleratedCompositingEnabled(true); |
161 settings->setAcceleratedCompositingForFixedPositionEnabled(true); | 161 settings->setAcceleratedCompositingForFixedPositionEnabled(true); |
162 settings->setAcceleratedCompositingForOverflowScrollEnabled(true); | 162 settings->setAcceleratedCompositingForOverflowScrollEnabled(true); |
163 settings->setCompositedScrollingForFramesEnabled(true); | 163 settings->setCompositedScrollingForFramesEnabled(true); |
164 } | 164 } |
165 | 165 |
166 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) | 166 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) |
167 { | 167 { |
168 webViewHelper->initializeAndLoad(url, true); | 168 webViewHelper->initializeAndLoad(url, true); |
169 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 169 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
170 webViewHelper->webView()->resize(WebSize(640, 480)); | 170 webViewHelper->webView()->resize(WebSize(640, 480)); |
171 } | 171 } |
172 | 172 |
173 PassOwnPtr<WebCore::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewH
elper* webViewHelper, const std::string& testcase) | 173 PassOwnPtr<WebCore::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewH
elper* webViewHelper, const std::string& testcase) |
174 { | 174 { |
175 registerMockedHttpURLLoad("nodeimage.html"); | 175 registerMockedHttpURLLoad("nodeimage.html"); |
176 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); | 176 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); |
177 webViewHelper->webView()->resize(WebSize(640, 480)); | 177 webViewHelper->webView()->resize(WebSize(640, 480)); |
178 webViewHelper->webView()->layout(); | 178 webViewHelper->webView()->layout(); |
179 RefPtr<WebCore::LocalFrame> frame = webViewHelper->webViewImpl()->page()
->mainFrame(); | 179 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper->webViewI
mpl()->page()->mainFrame()); |
180 WebCore::Element* element = frame->document()->getElementById(testcase.c
_str()); | 180 WebCore::Element* element = frame->document()->getElementById(testcase.c
_str()); |
181 return frame->nodeImage(*element); | 181 return frame->nodeImage(*element); |
182 } | 182 } |
183 | 183 |
184 std::string m_baseURL; | 184 std::string m_baseURL; |
185 std::string m_chromeURL; | 185 std::string m_chromeURL; |
186 }; | 186 }; |
187 | 187 |
188 class UseMockScrollbarSettings { | 188 class UseMockScrollbarSettings { |
189 public: | 189 public: |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 625 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
626 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 626 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
627 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 627 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
628 } | 628 } |
629 | 629 |
630 TEST_F(WebFrameTest, PostMessageThenDetach) | 630 TEST_F(WebFrameTest, PostMessageThenDetach) |
631 { | 631 { |
632 FrameTestHelpers::WebViewHelper webViewHelper; | 632 FrameTestHelpers::WebViewHelper webViewHelper; |
633 webViewHelper.initializeAndLoad("about:blank"); | 633 webViewHelper.initializeAndLoad("about:blank"); |
634 | 634 |
635 RefPtr<WebCore::LocalFrame> frame = webViewHelper.webViewImpl()->page()->mai
nFrame(); | 635 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()
->page()->mainFrame()); |
636 WebCore::NonThrowableExceptionState exceptionState; | 636 WebCore::NonThrowableExceptionState exceptionState; |
637 frame->domWindow()->postMessage(WebCore::SerializedScriptValue::create("mess
age"), 0, "*", frame->domWindow(), exceptionState); | 637 frame->domWindow()->postMessage(WebCore::SerializedScriptValue::create("mess
age"), 0, "*", frame->domWindow(), exceptionState); |
638 webViewHelper.reset(); | 638 webViewHelper.reset(); |
639 EXPECT_FALSE(exceptionState.hadException()); | 639 EXPECT_FALSE(exceptionState.hadException()); |
640 | 640 |
641 // Success is not crashing. | 641 // Success is not crashing. |
642 runPendingTasks(); | 642 runPendingTasks(); |
643 } | 643 } |
644 | 644 |
645 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 645 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 UseMockScrollbarSettings mockScrollbarSettings; | 715 UseMockScrollbarSettings mockScrollbarSettings; |
716 registerMockedHttpURLLoad("fixed_layout.html"); | 716 registerMockedHttpURLLoad("fixed_layout.html"); |
717 | 717 |
718 FixedLayoutTestWebViewClient client; | 718 FixedLayoutTestWebViewClient client; |
719 int viewportWidth = 640; | 719 int viewportWidth = 640; |
720 int viewportHeight = 480; | 720 int viewportHeight = 480; |
721 | 721 |
722 FrameTestHelpers::WebViewHelper webViewHelper; | 722 FrameTestHelpers::WebViewHelper webViewHelper; |
723 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 723 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
724 | 724 |
725 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 725 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); |
726 document->settings()->setTextAutosizingEnabled(true); | 726 document->settings()->setTextAutosizingEnabled(true); |
727 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 727 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
728 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 728 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
729 webViewHelper.webViewImpl()->layout(); | 729 webViewHelper.webViewImpl()->layout(); |
730 | 730 |
731 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); | 731 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); |
732 | 732 |
733 WebCore::ViewportDescription description = document->viewportDescription(); | 733 WebCore::ViewportDescription description = document->viewportDescription(); |
734 // Choose a width that's not going match the viewport width of the loaded do
cument. | 734 // Choose a width that's not going match the viewport width of the loaded do
cument. |
735 description.minWidth = WebCore::Length(100, WebCore::Fixed); | 735 description.minWidth = WebCore::Length(100, WebCore::Fixed); |
736 description.maxWidth = WebCore::Length(100, WebCore::Fixed); | 736 description.maxWidth = WebCore::Length(100, WebCore::Fixed); |
737 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); | 737 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); |
738 | 738 |
739 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); | 739 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); |
740 } | 740 } |
741 | 741 |
742 TEST_F(WebFrameTest, SetFrameRectInvalidatesTextAutosizingMultipliers) | 742 TEST_F(WebFrameTest, SetFrameRectInvalidatesTextAutosizingMultipliers) |
743 { | 743 { |
744 UseMockScrollbarSettings mockScrollbarSettings; | 744 UseMockScrollbarSettings mockScrollbarSettings; |
745 registerMockedHttpURLLoad("iframe_reload.html"); | 745 registerMockedHttpURLLoad("iframe_reload.html"); |
746 registerMockedHttpURLLoad("visible_iframe.html"); | 746 registerMockedHttpURLLoad("visible_iframe.html"); |
747 | 747 |
748 FixedLayoutTestWebViewClient client; | 748 FixedLayoutTestWebViewClient client; |
749 int viewportWidth = 640; | 749 int viewportWidth = 640; |
750 int viewportHeight = 480; | 750 int viewportHeight = 480; |
751 | 751 |
752 FrameTestHelpers::WebViewHelper webViewHelper; | 752 FrameTestHelpers::WebViewHelper webViewHelper; |
753 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); | 753 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); |
754 | 754 |
755 WebCore::LocalFrame* mainFrame = webViewHelper.webViewImpl()->page()->mainFr
ame(); | 755 WebCore::LocalFrame* mainFrame = toLocalFrame(webViewHelper.webViewImpl()->p
age()->mainFrame()); |
756 WebCore::Document* document = mainFrame->document(); | 756 WebCore::Document* document = mainFrame->document(); |
757 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 757 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); |
758 document->settings()->setTextAutosizingEnabled(true); | 758 document->settings()->setTextAutosizingEnabled(true); |
759 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 759 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
760 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 760 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
761 webViewHelper.webViewImpl()->layout(); | 761 webViewHelper.webViewImpl()->layout(); |
762 | 762 |
763 for (WebCore::Frame* frame = mainFrame; frame; frame = frame->tree().travers
eNext()) { | 763 for (WebCore::Frame* frame = mainFrame; frame; frame = frame->tree().travers
eNext()) { |
764 if (!frame->isLocalFrame()) | 764 if (!frame->isLocalFrame()) |
765 continue; | 765 continue; |
(...skipping 25 matching lines...) Expand all Loading... |
791 | 791 |
792 int fixedLayoutWidth = viewportWidth / 2; | 792 int fixedLayoutWidth = viewportWidth / 2; |
793 int fixedLayoutHeight = viewportHeight / 2; | 793 int fixedLayoutHeight = viewportHeight / 2; |
794 | 794 |
795 FrameTestHelpers::WebViewHelper webViewHelper; | 795 FrameTestHelpers::WebViewHelper webViewHelper; |
796 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, 0,
enableViewportSettings); | 796 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, 0,
enableViewportSettings); |
797 webViewHelper.webView()->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedL
ayoutHeight)); | 797 webViewHelper.webView()->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedL
ayoutHeight)); |
798 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 798 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
799 webViewHelper.webView()->layout(); | 799 webViewHelper.webView()->layout(); |
800 | 800 |
801 EXPECT_EQ(fixedLayoutWidth, webViewHelper.webViewImpl()->page()->mainFrame()
->view()->layoutSize().width()); | 801 EXPECT_EQ(fixedLayoutWidth, toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->view()->layoutSize().width()); |
802 EXPECT_EQ(fixedLayoutHeight, webViewHelper.webViewImpl()->page()->mainFrame(
)->view()->layoutSize().height()); | 802 EXPECT_EQ(fixedLayoutHeight, toLocalFrame(webViewHelper.webViewImpl()->page(
)->mainFrame())->view()->layoutSize().height()); |
803 } | 803 } |
804 | 804 |
805 TEST_F(WebFrameTest, FixedLayoutSizePreventsResizeFromChangingPageScale) | 805 TEST_F(WebFrameTest, FixedLayoutSizePreventsResizeFromChangingPageScale) |
806 { | 806 { |
807 UseMockScrollbarSettings mockScrollbarSettings; | 807 UseMockScrollbarSettings mockScrollbarSettings; |
808 registerMockedHttpURLLoad("fixed_layout.html"); | 808 registerMockedHttpURLLoad("fixed_layout.html"); |
809 | 809 |
810 int viewportWidth = 640; | 810 int viewportWidth = 640; |
811 int viewportHeight = 480; | 811 int viewportHeight = 480; |
812 | 812 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 client.m_screenInfo.deviceScaleFactor = 1; | 1034 client.m_screenInfo.deviceScaleFactor = 1; |
1035 int viewportWidth = 640; | 1035 int viewportWidth = 640; |
1036 int viewportHeight = 480; | 1036 int viewportHeight = 480; |
1037 | 1037 |
1038 FrameTestHelpers::WebViewHelper webViewHelper; | 1038 FrameTestHelpers::WebViewHelper webViewHelper; |
1039 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, 0, &client, enableViewportSettings); | 1039 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, 0, &client, enableViewportSettings); |
1040 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1040 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1041 | 1041 |
1042 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); | 1042 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); |
1043 | 1043 |
1044 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 1044 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); |
1045 WebCore::ViewportDescription description = document->viewportDescription(); | 1045 WebCore::ViewportDescription description = document->viewportDescription(); |
1046 description.zoom = 2; | 1046 description.zoom = 2; |
1047 document->setViewportDescription(description); | 1047 document->setViewportDescription(description); |
1048 webViewHelper.webView()->layout(); | 1048 webViewHelper.webView()->layout(); |
1049 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); | 1049 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); |
1050 } | 1050 } |
1051 | 1051 |
1052 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) | 1052 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) |
1053 { | 1053 { |
1054 UseMockScrollbarSettings mockScrollbarSettings; | 1054 UseMockScrollbarSettings mockScrollbarSettings; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1437 |
1438 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); | 1438 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); |
1439 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1439 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1440 | 1440 |
1441 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1441 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
1442 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1442 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
1443 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1443 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
1444 | 1444 |
1445 // The magic number to snap to device-width is 320, so test that 321 is | 1445 // The magic number to snap to device-width is 320, so test that 321 is |
1446 // respected. | 1446 // respected. |
1447 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 1447 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); |
1448 WebCore::ViewportDescription description = document->viewportDescription(); | 1448 WebCore::ViewportDescription description = document->viewportDescription(); |
1449 description.minWidth = WebCore::Length(321, WebCore::Fixed); | 1449 description.minWidth = WebCore::Length(321, WebCore::Fixed); |
1450 description.maxWidth = WebCore::Length(321, WebCore::Fixed); | 1450 description.maxWidth = WebCore::Length(321, WebCore::Fixed); |
1451 document->setViewportDescription(description); | 1451 document->setViewportDescription(description); |
1452 webViewHelper.webView()->layout(); | 1452 webViewHelper.webView()->layout(); |
1453 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1453 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
1454 | 1454 |
1455 description.minWidth = WebCore::Length(320, WebCore::Fixed); | 1455 description.minWidth = WebCore::Length(320, WebCore::Fixed); |
1456 description.maxWidth = WebCore::Length(320, WebCore::Fixed); | 1456 description.maxWidth = WebCore::Length(320, WebCore::Fixed); |
1457 document->setViewportDescription(description); | 1457 document->setViewportDescription(description); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 client.m_screenInfo.deviceScaleFactor = 1; | 1615 client.m_screenInfo.deviceScaleFactor = 1; |
1616 int viewportWidth = 640; | 1616 int viewportWidth = 640; |
1617 int viewportHeight = 480; | 1617 int viewportHeight = 480; |
1618 | 1618 |
1619 FrameTestHelpers::WebViewHelper webViewHelper; | 1619 FrameTestHelpers::WebViewHelper webViewHelper; |
1620 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 1620 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
1621 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1621 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1622 webViewHelper.webView()->layout(); | 1622 webViewHelper.webView()->layout(); |
1623 | 1623 |
1624 webViewHelper.webView()->setPageScaleFactor(3); | 1624 webViewHelper.webView()->setPageScaleFactor(3); |
1625 EXPECT_EQ(3, webViewHelper.webViewImpl()->page()->mainFrame()->loader().curr
entItem()->pageScaleFactor()); | 1625 EXPECT_EQ(3, toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())-
>loader().currentItem()->pageScaleFactor()); |
1626 } | 1626 } |
1627 | 1627 |
1628 TEST_F(WebFrameTest, initialScaleWrittenToHistoryItem) | 1628 TEST_F(WebFrameTest, initialScaleWrittenToHistoryItem) |
1629 { | 1629 { |
1630 UseMockScrollbarSettings mockScrollbarSettings; | 1630 UseMockScrollbarSettings mockScrollbarSettings; |
1631 registerMockedHttpURLLoad("fixed_layout.html"); | 1631 registerMockedHttpURLLoad("fixed_layout.html"); |
1632 | 1632 |
1633 FixedLayoutTestWebViewClient client; | 1633 FixedLayoutTestWebViewClient client; |
1634 client.m_screenInfo.deviceScaleFactor = 1; | 1634 client.m_screenInfo.deviceScaleFactor = 1; |
1635 int viewportWidth = 640; | 1635 int viewportWidth = 640; |
1636 int viewportHeight = 480; | 1636 int viewportHeight = 480; |
1637 | 1637 |
1638 FrameTestHelpers::WebViewHelper webViewHelper; | 1638 FrameTestHelpers::WebViewHelper webViewHelper; |
1639 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 1639 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
1640 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1640 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1641 webViewHelper.webView()->layout(); | 1641 webViewHelper.webView()->layout(); |
1642 | 1642 |
1643 int defaultFixedLayoutWidth = 980; | 1643 int defaultFixedLayoutWidth = 980; |
1644 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; | 1644 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid
th; |
1645 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->page()->mainF
rame()->loader().currentItem()->pageScaleFactor()); | 1645 EXPECT_EQ(minimumPageScaleFactor, toLocalFrame(webViewHelper.webViewImpl()->
page()->mainFrame())->loader().currentItem()->pageScaleFactor()); |
1646 } | 1646 } |
1647 | 1647 |
1648 TEST_F(WebFrameTest, pageScaleFactorShrinksViewport) | 1648 TEST_F(WebFrameTest, pageScaleFactorShrinksViewport) |
1649 { | 1649 { |
1650 UseMockScrollbarSettings mockScrollbarSettings; | 1650 UseMockScrollbarSettings mockScrollbarSettings; |
1651 registerMockedHttpURLLoad("large-div.html"); | 1651 registerMockedHttpURLLoad("large-div.html"); |
1652 | 1652 |
1653 FixedLayoutTestWebViewClient client; | 1653 FixedLayoutTestWebViewClient client; |
1654 client.m_screenInfo.deviceScaleFactor = 1; | 1654 client.m_screenInfo.deviceScaleFactor = 1; |
1655 // Small viewport to ensure there are always scrollbars. | 1655 // Small viewport to ensure there are always scrollbars. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 int viewportWidth = 640; | 1690 int viewportWidth = 640; |
1691 int viewportHeight = 480; | 1691 int viewportHeight = 480; |
1692 | 1692 |
1693 FrameTestHelpers::WebViewHelper webViewHelper; | 1693 FrameTestHelpers::WebViewHelper webViewHelper; |
1694 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 1694 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
1695 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1695 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1696 webViewHelper.webView()->layout(); | 1696 webViewHelper.webView()->layout(); |
1697 | 1697 |
1698 webViewHelper.webView()->setPageScaleFactor(2); | 1698 webViewHelper.webView()->setPageScaleFactor(2); |
1699 | 1699 |
1700 EXPECT_EQ(980, webViewHelper.webViewImpl()->page()->mainFrame()->contentRend
erer()->unscaledDocumentRect().width()); | 1700 EXPECT_EQ(980, toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame()
)->contentRenderer()->unscaledDocumentRect().width()); |
1701 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); | 1701 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); |
1702 } | 1702 } |
1703 | 1703 |
1704 TEST_F(WebFrameTest, targetDensityDpiHigh) | 1704 TEST_F(WebFrameTest, targetDensityDpiHigh) |
1705 { | 1705 { |
1706 UseMockScrollbarSettings mockScrollbarSettings; | 1706 UseMockScrollbarSettings mockScrollbarSettings; |
1707 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); | 1707 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); |
1708 | 1708 |
1709 FixedLayoutTestWebViewClient client; | 1709 FixedLayoutTestWebViewClient client; |
1710 // high-dpi = 240 | 1710 // high-dpi = 240 |
(...skipping 3071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4782 } | 4782 } |
4783 }; | 4783 }; |
4784 | 4784 |
4785 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) | 4785 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) |
4786 { | 4786 { |
4787 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4787 registerMockedHttpURLLoad("fragment_middle_click.html"); |
4788 TestNavigationPolicyWebFrameClient client; | 4788 TestNavigationPolicyWebFrameClient client; |
4789 FrameTestHelpers::WebViewHelper webViewHelper; | 4789 FrameTestHelpers::WebViewHelper webViewHelper; |
4790 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); | 4790 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); |
4791 | 4791 |
4792 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 4792 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); |
4793 WebCore::KURL destination = document->url(); | 4793 WebCore::KURL destination = document->url(); |
4794 destination.setFragmentIdentifier("test"); | 4794 destination.setFragmentIdentifier("test"); |
4795 | 4795 |
4796 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, | 4796 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, |
4797 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); | 4797 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); |
4798 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); | 4798 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); |
4799 frameRequest.setTriggeringEvent(event); | 4799 frameRequest.setTriggeringEvent(event); |
4800 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 4800 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
4801 } | 4801 } |
4802 | 4802 |
4803 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { | 4803 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { |
4804 public: | 4804 public: |
4805 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, | 4805 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, |
4806 const WebString&, WebNavigationPolicy, bool) OVERRIDE | 4806 const WebString&, WebNavigationPolicy, bool) OVERRIDE |
4807 { | 4807 { |
4808 EXPECT_TRUE(false); | 4808 EXPECT_TRUE(false); |
4809 return 0; | 4809 return 0; |
4810 } | 4810 } |
(...skipping 21 matching lines...) Expand all Loading... |
4832 | 4832 |
4833 TEST_F(WebFrameTest, ModifiedClickNewWindow) | 4833 TEST_F(WebFrameTest, ModifiedClickNewWindow) |
4834 { | 4834 { |
4835 registerMockedHttpURLLoad("ctrl_click.html"); | 4835 registerMockedHttpURLLoad("ctrl_click.html"); |
4836 registerMockedHttpURLLoad("hello_world.html"); | 4836 registerMockedHttpURLLoad("hello_world.html"); |
4837 TestNewWindowWebViewClient webViewClient; | 4837 TestNewWindowWebViewClient webViewClient; |
4838 TestNewWindowWebFrameClient webFrameClient; | 4838 TestNewWindowWebFrameClient webFrameClient; |
4839 FrameTestHelpers::WebViewHelper webViewHelper; | 4839 FrameTestHelpers::WebViewHelper webViewHelper; |
4840 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); | 4840 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); |
4841 | 4841 |
4842 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 4842 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); |
4843 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); | 4843 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); |
4844 | 4844 |
4845 // ctrl+click event | 4845 // ctrl+click event |
4846 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, | 4846 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, |
4847 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); | 4847 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); |
4848 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); | 4848 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); |
4849 frameRequest.setTriggeringEvent(event); | 4849 frameRequest.setTriggeringEvent(event); |
4850 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 4850 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); |
4851 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 4851 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
4852 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 4852 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
4853 | 4853 |
4854 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 4854 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
4855 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 4855 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
4856 } | 4856 } |
4857 | 4857 |
4858 TEST_F(WebFrameTest, BackToReload) | 4858 TEST_F(WebFrameTest, BackToReload) |
4859 { | 4859 { |
4860 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4860 registerMockedHttpURLLoad("fragment_middle_click.html"); |
4861 FrameTestHelpers::WebViewHelper webViewHelper; | 4861 FrameTestHelpers::WebViewHelper webViewHelper; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5048 }; | 5048 }; |
5049 | 5049 |
5050 TEST_F(WebFrameTest, NavigateToSame) | 5050 TEST_F(WebFrameTest, NavigateToSame) |
5051 { | 5051 { |
5052 registerMockedHttpURLLoad("navigate_to_same.html"); | 5052 registerMockedHttpURLLoad("navigate_to_same.html"); |
5053 TestSameDocumentWebFrameClient client; | 5053 TestSameDocumentWebFrameClient client; |
5054 FrameTestHelpers::WebViewHelper webViewHelper; | 5054 FrameTestHelpers::WebViewHelper webViewHelper; |
5055 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); | 5055 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); |
5056 EXPECT_FALSE(client.frameLoadTypeSameSeen()); | 5056 EXPECT_FALSE(client.frameLoadTypeSameSeen()); |
5057 | 5057 |
5058 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewHe
lper.webViewImpl()->page()->mainFrame()->document()->url())); | 5058 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(toLocalFr
ame(webViewHelper.webViewImpl()->page()->mainFrame())->document()->url())); |
5059 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 5059 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
5060 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 5060 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
5061 | 5061 |
5062 EXPECT_TRUE(client.frameLoadTypeSameSeen()); | 5062 EXPECT_TRUE(client.frameLoadTypeSameSeen()); |
5063 } | 5063 } |
5064 | 5064 |
5065 TEST_F(WebFrameTest, WebNodeImageContents) | 5065 TEST_F(WebFrameTest, WebNodeImageContents) |
5066 { | 5066 { |
5067 FrameTestHelpers::WebViewHelper webViewHelper; | 5067 FrameTestHelpers::WebViewHelper webViewHelper; |
5068 webViewHelper.initializeAndLoad("about:blank", true); | 5068 webViewHelper.initializeAndLoad("about:blank", true); |
5069 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5069 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5150 private: | 5150 private: |
5151 WebHistoryCommitType m_lastCommitType; | 5151 WebHistoryCommitType m_lastCommitType; |
5152 }; | 5152 }; |
5153 | 5153 |
5154 TEST_F(WebFrameTest, SameDocumentHistoryNavigationCommitType) | 5154 TEST_F(WebFrameTest, SameDocumentHistoryNavigationCommitType) |
5155 { | 5155 { |
5156 registerMockedHttpURLLoad("push_state.html"); | 5156 registerMockedHttpURLLoad("push_state.html"); |
5157 TestDidNavigateCommitTypeWebFrameClient client; | 5157 TestDidNavigateCommitTypeWebFrameClient client; |
5158 FrameTestHelpers::WebViewHelper webViewHelper; | 5158 FrameTestHelpers::WebViewHelper webViewHelper; |
5159 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); | 5159 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); |
5160 RefPtr<WebCore::HistoryItem> item = webViewImpl->page()->mainFrame()->loader
().currentItem(); | 5160 RefPtr<WebCore::HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFr
ame())->loader().currentItem(); |
5161 runPendingTasks(); | 5161 runPendingTasks(); |
5162 | 5162 |
5163 webViewImpl->page()->mainFrame()->loader().loadHistoryItem(item.get(), WebCo
re::HistorySameDocumentLoad); | 5163 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), WebCore::HistorySameDocumentLoad); |
5164 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 5164 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
5165 } | 5165 } |
5166 | 5166 |
5167 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 5167 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
5168 public: | 5168 public: |
5169 TestHistoryWebFrameClient() | 5169 TestHistoryWebFrameClient() |
5170 { | 5170 { |
5171 m_replacesCurrentHistoryItem = false; | 5171 m_replacesCurrentHistoryItem = false; |
5172 m_frame = 0; | 5172 m_frame = 0; |
5173 } | 5173 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5577 { | 5577 { |
5578 registerMockedHttpURLLoad("brand_color_test.html"); | 5578 registerMockedHttpURLLoad("brand_color_test.html"); |
5579 FrameTestHelpers::WebViewHelper webViewHelper; | 5579 FrameTestHelpers::WebViewHelper webViewHelper; |
5580 BrandColorTestWebFrameClient client; | 5580 BrandColorTestWebFrameClient client; |
5581 webViewHelper.initializeAndLoad(m_baseURL + "brand_color_test.html", false,
&client); | 5581 webViewHelper.initializeAndLoad(m_baseURL + "brand_color_test.html", false,
&client); |
5582 EXPECT_TRUE(client.didNotify()); | 5582 EXPECT_TRUE(client.didNotify()); |
5583 EXPECT_EQ(0xff0000ff, client.brandColor()); | 5583 EXPECT_EQ(0xff0000ff, client.brandColor()); |
5584 } | 5584 } |
5585 | 5585 |
5586 } // namespace | 5586 } // namespace |
OLD | NEW |