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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 #include "web/WebLocalFrameImpl.h" | 100 #include "web/WebLocalFrameImpl.h" |
101 #include "web/WebViewImpl.h" | 101 #include "web/WebViewImpl.h" |
102 #include "web/tests/FrameTestHelpers.h" | 102 #include "web/tests/FrameTestHelpers.h" |
103 #include "wtf/Forward.h" | 103 #include "wtf/Forward.h" |
104 #include "wtf/dtoa/utils.h" | 104 #include "wtf/dtoa/utils.h" |
105 #include <gmock/gmock.h> | 105 #include <gmock/gmock.h> |
106 #include <gtest/gtest.h> | 106 #include <gtest/gtest.h> |
107 #include <map> | 107 #include <map> |
108 #include <v8.h> | 108 #include <v8.h> |
109 | 109 |
110 using namespace blink; | 110 namespace { |
111 using blink::Document; | 111 |
112 using blink::DocumentMarker; | |
113 using blink::Element; | |
114 using blink::FloatRect; | |
115 using blink::HitTestRequest; | |
116 using blink::Range; | |
117 using blink::URLTestHelpers::toKURL; | 112 using blink::URLTestHelpers::toKURL; |
118 using blink::FrameTestHelpers::runPendingTasks; | 113 using blink::FrameTestHelpers::runPendingTasks; |
119 | 114 using namespace blink; |
120 namespace { | |
121 | 115 |
122 const int touchPointPadding = 32; | 116 const int touchPointPadding = 32; |
123 | 117 |
124 #define EXPECT_EQ_RECT(a, b) \ | 118 #define EXPECT_EQ_RECT(a, b) \ |
125 EXPECT_EQ(a.x(), b.x()); \ | 119 EXPECT_EQ(a.x(), b.x()); \ |
126 EXPECT_EQ(a.y(), b.y()); \ | 120 EXPECT_EQ(a.y(), b.y()); \ |
127 EXPECT_EQ(a.width(), b.width()); \ | 121 EXPECT_EQ(a.width(), b.width()); \ |
128 EXPECT_EQ(a.height(), b.height()); | 122 EXPECT_EQ(a.height(), b.height()); |
129 | 123 |
130 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 124 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
(...skipping 19 matching lines...) Expand all Loading... |
150 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 144 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
151 } | 145 } |
152 | 146 |
153 void registerMockedChromeURLLoad(const std::string& fileName) | 147 void registerMockedChromeURLLoad(const std::string& fileName) |
154 { | 148 { |
155 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 149 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
156 } | 150 } |
157 | 151 |
158 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) | 152 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) |
159 { | 153 { |
160 RefPtrWillBeRawPtr<blink::StyleSheetContents> styleSheet = blink::StyleS
heetContents::create(blink::CSSParserContext(blink::UASheetMode, 0)); | 154 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::
create(CSSParserContext(UASheetMode, 0)); |
161 styleSheet->parseString(String(blink::viewportAndroidCss, sizeof(blink::
viewportAndroidCss))); | 155 styleSheet->parseString(String(blink::viewportAndroidCss, sizeof(blink::
viewportAndroidCss))); |
162 OwnPtrWillBeRawPtr<blink::RuleSet> ruleSet = blink::RuleSet::create(); | 156 OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create(); |
163 ruleSet->addRulesFromSheet(styleSheet.get(), blink::MediaQueryEvaluator(
"screen")); | 157 ruleSet->addRulesFromSheet(styleSheet.get(), MediaQueryEvaluator("screen
")); |
164 | 158 |
165 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); | 159 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); |
166 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), blink::ViewportStyleResolver::UserAgentOrigin); | 160 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); |
167 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 161 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
168 } | 162 } |
169 | 163 |
170 static void configueCompositingWebView(WebSettings* settings) | 164 static void configueCompositingWebView(WebSettings* settings) |
171 { | 165 { |
172 settings->setAcceleratedCompositingEnabled(true); | 166 settings->setAcceleratedCompositingEnabled(true); |
173 settings->setPreferCompositingToLCDTextEnabled(true); | 167 settings->setPreferCompositingToLCDTextEnabled(true); |
174 } | 168 } |
175 | 169 |
176 static void configureLoadsImagesAutomatically(WebSettings* settings) | 170 static void configureLoadsImagesAutomatically(WebSettings* settings) |
177 { | 171 { |
178 settings->setLoadsImagesAutomatically(true); | 172 settings->setLoadsImagesAutomatically(true); |
179 } | 173 } |
180 | 174 |
181 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) | 175 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) |
182 { | 176 { |
183 webViewHelper->initializeAndLoad(url, true); | 177 webViewHelper->initializeAndLoad(url, true); |
184 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 178 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
185 webViewHelper->webView()->resize(WebSize(640, 480)); | 179 webViewHelper->webView()->resize(WebSize(640, 480)); |
186 } | 180 } |
187 | 181 |
188 PassOwnPtr<blink::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHel
per* webViewHelper, const std::string& testcase) | 182 PassOwnPtr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelper* we
bViewHelper, const std::string& testcase) |
189 { | 183 { |
190 registerMockedHttpURLLoad("nodeimage.html"); | 184 registerMockedHttpURLLoad("nodeimage.html"); |
191 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); | 185 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); |
192 webViewHelper->webView()->resize(WebSize(640, 480)); | 186 webViewHelper->webView()->resize(WebSize(640, 480)); |
193 webViewHelper->webView()->layout(); | 187 webViewHelper->webView()->layout(); |
194 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper->webViewImp
l()->page()->mainFrame()); | 188 RefPtr<LocalFrame> frame = toLocalFrame(webViewHelper->webViewImpl()->pa
ge()->mainFrame()); |
195 blink::Element* element = frame->document()->getElementById(testcase.c_s
tr()); | 189 Element* element = frame->document()->getElementById(testcase.c_str()); |
196 return frame->nodeImage(*element); | 190 return frame->nodeImage(*element); |
197 } | 191 } |
198 | 192 |
199 std::string m_baseURL; | 193 std::string m_baseURL; |
200 std::string m_chromeURL; | 194 std::string m_chromeURL; |
201 }; | 195 }; |
202 | 196 |
203 class UseMockScrollbarSettings { | 197 class UseMockScrollbarSettings { |
204 public: | 198 public: |
205 UseMockScrollbarSettings() | 199 UseMockScrollbarSettings() |
206 { | 200 { |
207 blink::Settings::setMockScrollbarsEnabled(true); | 201 Settings::setMockScrollbarsEnabled(true); |
208 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); | 202 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); |
209 EXPECT_TRUE(blink::ScrollbarTheme::theme()->usesOverlayScrollbars()); | 203 EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars()); |
210 } | 204 } |
211 | 205 |
212 ~UseMockScrollbarSettings() | 206 ~UseMockScrollbarSettings() |
213 { | 207 { |
214 blink::Settings::setMockScrollbarsEnabled(false); | 208 Settings::setMockScrollbarsEnabled(false); |
215 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); | 209 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); |
216 } | 210 } |
217 }; | 211 }; |
218 | 212 |
219 TEST_F(WebFrameTest, ContentText) | 213 TEST_F(WebFrameTest, ContentText) |
220 { | 214 { |
221 registerMockedHttpURLLoad("iframes_test.html"); | 215 registerMockedHttpURLLoad("iframes_test.html"); |
222 registerMockedHttpURLLoad("visible_iframe.html"); | 216 registerMockedHttpURLLoad("visible_iframe.html"); |
223 registerMockedHttpURLLoad("invisible_iframe.html"); | 217 registerMockedHttpURLLoad("invisible_iframe.html"); |
224 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 218 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
225 | 219 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 634 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
641 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 635 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
642 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 636 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
643 } | 637 } |
644 | 638 |
645 TEST_F(WebFrameTest, PostMessageThenDetach) | 639 TEST_F(WebFrameTest, PostMessageThenDetach) |
646 { | 640 { |
647 FrameTestHelpers::WebViewHelper webViewHelper; | 641 FrameTestHelpers::WebViewHelper webViewHelper; |
648 webViewHelper.initializeAndLoad("about:blank"); | 642 webViewHelper.initializeAndLoad("about:blank"); |
649 | 643 |
650 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->
page()->mainFrame()); | 644 RefPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); |
651 blink::NonThrowableExceptionState exceptionState; | 645 NonThrowableExceptionState exceptionState; |
652 frame->domWindow()->postMessage(blink::SerializedScriptValue::create("messag
e"), 0, "*", frame->domWindow(), exceptionState); | 646 frame->domWindow()->postMessage(SerializedScriptValue::create("message"), 0,
"*", frame->domWindow(), exceptionState); |
653 webViewHelper.reset(); | 647 webViewHelper.reset(); |
654 EXPECT_FALSE(exceptionState.hadException()); | 648 EXPECT_FALSE(exceptionState.hadException()); |
655 | 649 |
656 // Success is not crashing. | 650 // Success is not crashing. |
657 runPendingTasks(); | 651 runPendingTasks(); |
658 } | 652 } |
659 | 653 |
660 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 654 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
661 public: | 655 public: |
662 virtual WebScreenInfo screenInfo() OVERRIDE { return m_screenInfo; } | 656 virtual WebScreenInfo screenInfo() OVERRIDE { return m_screenInfo; } |
(...skipping 19 matching lines...) Expand all Loading... |
682 int viewportWidth = 640; | 676 int viewportWidth = 640; |
683 int viewportHeight = 480; | 677 int viewportHeight = 480; |
684 | 678 |
685 // Make sure we initialize to minimum scale, even if the window size | 679 // Make sure we initialize to minimum scale, even if the window size |
686 // only becomes available after the load begins. | 680 // only becomes available after the load begins. |
687 FrameTestHelpers::WebViewHelper webViewHelper; | 681 FrameTestHelpers::WebViewHelper webViewHelper; |
688 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 682 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
689 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 683 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
690 webViewHelper.webView()->layout(); | 684 webViewHelper.webView()->layout(); |
691 | 685 |
692 webViewHelper.webViewImpl()->setFixedLayoutSize(blink::IntSize(100, 100)); | 686 webViewHelper.webViewImpl()->setFixedLayoutSize(IntSize(100, 100)); |
693 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); | 687 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); |
694 | 688 |
695 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie
w()->layoutCount(); | 689 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie
w()->layoutCount(); |
696 webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(blin
k::IntRect(0, 0, 641, 481)); | 690 webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(IntR
ect(0, 0, 641, 481)); |
697 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView()->layoutCount()); | 691 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView()->layoutCount()); |
698 | 692 |
699 webViewHelper.webViewImpl()->layout(); | 693 webViewHelper.webViewImpl()->layout(); |
700 } | 694 } |
701 | 695 |
702 // Helper function to check or set text autosizing multipliers on a document. | 696 // Helper function to check or set text autosizing multipliers on a document. |
703 static bool checkOrSetTextAutosizingMultiplier(Document* document, float multipl
ier, bool setMultiplier) | 697 static bool checkOrSetTextAutosizingMultiplier(Document* document, float multipl
ier, bool setMultiplier) |
704 { | 698 { |
705 bool multiplierCheckedOrSetAtLeastOnce = false; | 699 bool multiplierCheckedOrSetAtLeastOnce = false; |
706 for (blink::RenderObject* renderer = document->renderView(); renderer; rende
rer = renderer->nextInPreOrder()) { | 700 for (RenderObject* renderer = document->renderView(); renderer; renderer = r
enderer->nextInPreOrder()) { |
707 if (renderer->style()) { | 701 if (renderer->style()) { |
708 if (setMultiplier) | 702 if (setMultiplier) |
709 renderer->style()->setTextAutosizingMultiplier(multiplier); | 703 renderer->style()->setTextAutosizingMultiplier(multiplier); |
710 EXPECT_EQ(multiplier, renderer->style()->textAutosizingMultiplier())
; | 704 EXPECT_EQ(multiplier, renderer->style()->textAutosizingMultiplier())
; |
711 multiplierCheckedOrSetAtLeastOnce = true; | 705 multiplierCheckedOrSetAtLeastOnce = true; |
712 } | 706 } |
713 } | 707 } |
714 return multiplierCheckedOrSetAtLeastOnce; | 708 return multiplierCheckedOrSetAtLeastOnce; |
715 | 709 |
716 } | 710 } |
(...skipping 13 matching lines...) Expand all Loading... |
730 UseMockScrollbarSettings mockScrollbarSettings; | 724 UseMockScrollbarSettings mockScrollbarSettings; |
731 registerMockedHttpURLLoad("fixed_layout.html"); | 725 registerMockedHttpURLLoad("fixed_layout.html"); |
732 | 726 |
733 FixedLayoutTestWebViewClient client; | 727 FixedLayoutTestWebViewClient client; |
734 int viewportWidth = 640; | 728 int viewportWidth = 640; |
735 int viewportHeight = 480; | 729 int viewportHeight = 480; |
736 | 730 |
737 FrameTestHelpers::WebViewHelper webViewHelper; | 731 FrameTestHelpers::WebViewHelper webViewHelper; |
738 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 732 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
739 | 733 |
740 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); | 734 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
741 document->settings()->setTextAutosizingEnabled(true); | 735 document->settings()->setTextAutosizingEnabled(true); |
742 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 736 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
743 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 737 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
744 webViewHelper.webViewImpl()->layout(); | 738 webViewHelper.webViewImpl()->layout(); |
745 | 739 |
746 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); | 740 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); |
747 | 741 |
748 blink::ViewportDescription description = document->viewportDescription(); | 742 ViewportDescription description = document->viewportDescription(); |
749 // Choose a width that's not going match the viewport width of the loaded do
cument. | 743 // Choose a width that's not going match the viewport width of the loaded do
cument. |
750 description.minWidth = blink::Length(100, blink::Fixed); | 744 description.minWidth = Length(100, blink::Fixed); |
751 description.maxWidth = blink::Length(100, blink::Fixed); | 745 description.maxWidth = Length(100, blink::Fixed); |
752 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); | 746 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); |
753 | 747 |
754 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); | 748 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); |
755 } | 749 } |
756 | 750 |
757 TEST_F(WebFrameTest, SetFrameRectInvalidatesTextAutosizingMultipliers) | 751 TEST_F(WebFrameTest, SetFrameRectInvalidatesTextAutosizingMultipliers) |
758 { | 752 { |
759 UseMockScrollbarSettings mockScrollbarSettings; | 753 UseMockScrollbarSettings mockScrollbarSettings; |
760 registerMockedHttpURLLoad("iframe_reload.html"); | 754 registerMockedHttpURLLoad("iframe_reload.html"); |
761 registerMockedHttpURLLoad("visible_iframe.html"); | 755 registerMockedHttpURLLoad("visible_iframe.html"); |
762 | 756 |
763 FixedLayoutTestWebViewClient client; | 757 FixedLayoutTestWebViewClient client; |
764 int viewportWidth = 640; | 758 int viewportWidth = 640; |
765 int viewportHeight = 480; | 759 int viewportHeight = 480; |
766 | 760 |
767 FrameTestHelpers::WebViewHelper webViewHelper; | 761 FrameTestHelpers::WebViewHelper webViewHelper; |
768 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); | 762 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); |
769 | 763 |
770 blink::LocalFrame* mainFrame = toLocalFrame(webViewHelper.webViewImpl()->pag
e()->mainFrame()); | 764 LocalFrame* mainFrame = toLocalFrame(webViewHelper.webViewImpl()->page()->ma
inFrame()); |
771 blink::Document* document = mainFrame->document(); | 765 Document* document = mainFrame->document(); |
772 blink::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->
frameView(); | 766 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
773 document->settings()->setTextAutosizingEnabled(true); | 767 document->settings()->setTextAutosizingEnabled(true); |
774 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 768 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
775 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 769 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
776 webViewHelper.webViewImpl()->layout(); | 770 webViewHelper.webViewImpl()->layout(); |
777 | 771 |
778 for (blink::Frame* frame = mainFrame; frame; frame = frame->tree().traverseN
ext()) { | 772 for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext())
{ |
779 if (!frame->isLocalFrame()) | 773 if (!frame->isLocalFrame()) |
780 continue; | 774 continue; |
781 EXPECT_TRUE(setTextAutosizingMultiplier(toLocalFrame(frame)->document(),
2)); | 775 EXPECT_TRUE(setTextAutosizingMultiplier(toLocalFrame(frame)->document(),
2)); |
782 for (blink::RenderObject* renderer = toLocalFrame(frame)->document()->re
nderView(); renderer; renderer = renderer->nextInPreOrder()) { | 776 for (RenderObject* renderer = toLocalFrame(frame)->document()->renderVie
w(); renderer; renderer = renderer->nextInPreOrder()) { |
783 if (renderer->isText()) | 777 if (renderer->isText()) |
784 EXPECT_FALSE(renderer->needsLayout()); | 778 EXPECT_FALSE(renderer->needsLayout()); |
785 } | 779 } |
786 } | 780 } |
787 | 781 |
788 frameView->setFrameRect(blink::IntRect(0, 0, 200, 200)); | 782 frameView->setFrameRect(IntRect(0, 0, 200, 200)); |
789 for (blink::Frame* frame = mainFrame; frame; frame = frame->tree().traverseN
ext()) { | 783 for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext())
{ |
790 if (!frame->isLocalFrame()) | 784 if (!frame->isLocalFrame()) |
791 continue; | 785 continue; |
792 for (blink::RenderObject* renderer = toLocalFrame(frame)->document()->re
nderView(); renderer; renderer = renderer->nextInPreOrder()) { | 786 for (RenderObject* renderer = toLocalFrame(frame)->document()->renderVie
w(); renderer; renderer = renderer->nextInPreOrder()) { |
793 if (renderer->isText()) | 787 if (renderer->isText()) |
794 EXPECT_TRUE(renderer->needsLayout()); | 788 EXPECT_TRUE(renderer->needsLayout()); |
795 } | 789 } |
796 } | 790 } |
797 } | 791 } |
798 | 792 |
799 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) | 793 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) |
800 { | 794 { |
801 UseMockScrollbarSettings mockScrollbarSettings; | 795 UseMockScrollbarSettings mockScrollbarSettings; |
802 registerMockedHttpURLLoad("fixed_layout.html"); | 796 registerMockedHttpURLLoad("fixed_layout.html"); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 client.m_screenInfo.deviceScaleFactor = 1; | 1043 client.m_screenInfo.deviceScaleFactor = 1; |
1050 int viewportWidth = 640; | 1044 int viewportWidth = 640; |
1051 int viewportHeight = 480; | 1045 int viewportHeight = 480; |
1052 | 1046 |
1053 FrameTestHelpers::WebViewHelper webViewHelper; | 1047 FrameTestHelpers::WebViewHelper webViewHelper; |
1054 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, 0, &client, enableViewportSettings); | 1048 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm
l", true, 0, &client, enableViewportSettings); |
1055 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1049 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1056 | 1050 |
1057 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); | 1051 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); |
1058 | 1052 |
1059 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); | 1053 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
1060 blink::ViewportDescription description = document->viewportDescription(); | 1054 ViewportDescription description = document->viewportDescription(); |
1061 description.zoom = 2; | 1055 description.zoom = 2; |
1062 document->setViewportDescription(description); | 1056 document->setViewportDescription(description); |
1063 webViewHelper.webView()->layout(); | 1057 webViewHelper.webView()->layout(); |
1064 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); | 1058 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); |
1065 } | 1059 } |
1066 | 1060 |
1067 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) | 1061 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) |
1068 { | 1062 { |
1069 UseMockScrollbarSettings mockScrollbarSettings; | 1063 UseMockScrollbarSettings mockScrollbarSettings; |
1070 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1064 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 | 1526 |
1533 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); | 1527 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); |
1534 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1528 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1535 | 1529 |
1536 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1530 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
1537 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1531 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
1538 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1532 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
1539 | 1533 |
1540 // The magic number to snap to device-width is 320, so test that 321 is | 1534 // The magic number to snap to device-width is 320, so test that 321 is |
1541 // respected. | 1535 // respected. |
1542 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); | 1536 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
1543 blink::ViewportDescription description = document->viewportDescription(); | 1537 ViewportDescription description = document->viewportDescription(); |
1544 description.minWidth = blink::Length(321, blink::Fixed); | 1538 description.minWidth = Length(321, blink::Fixed); |
1545 description.maxWidth = blink::Length(321, blink::Fixed); | 1539 description.maxWidth = Length(321, blink::Fixed); |
1546 document->setViewportDescription(description); | 1540 document->setViewportDescription(description); |
1547 webViewHelper.webView()->layout(); | 1541 webViewHelper.webView()->layout(); |
1548 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1542 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
1549 | 1543 |
1550 description.minWidth = blink::Length(320, blink::Fixed); | 1544 description.minWidth = Length(320, blink::Fixed); |
1551 description.maxWidth = blink::Length(320, blink::Fixed); | 1545 description.maxWidth = Length(320, blink::Fixed); |
1552 document->setViewportDescription(description); | 1546 document->setViewportDescription(description); |
1553 webViewHelper.webView()->layout(); | 1547 webViewHelper.webView()->layout(); |
1554 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1548 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
1555 | 1549 |
1556 description = document->viewportDescription(); | 1550 description = document->viewportDescription(); |
1557 description.maxHeight = blink::Length(1000, blink::Fixed); | 1551 description.maxHeight = Length(1000, blink::Fixed); |
1558 document->setViewportDescription(description); | 1552 document->setViewportDescription(description); |
1559 webViewHelper.webView()->layout(); | 1553 webViewHelper.webView()->layout(); |
1560 EXPECT_EQ(1000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l
ayoutSize().height()); | 1554 EXPECT_EQ(1000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l
ayoutSize().height()); |
1561 | 1555 |
1562 description.maxHeight = blink::Length(320, blink::Fixed); | 1556 description.maxHeight = Length(320, blink::Fixed); |
1563 document->setViewportDescription(description); | 1557 document->setViewportDescription(description); |
1564 webViewHelper.webView()->layout(); | 1558 webViewHelper.webView()->layout(); |
1565 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1559 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
1566 } | 1560 } |
1567 | 1561 |
1568 TEST_F(WebFrameTest, ZeroValuesQuirk) | 1562 TEST_F(WebFrameTest, ZeroValuesQuirk) |
1569 { | 1563 { |
1570 UseMockScrollbarSettings mockScrollbarSettings; | 1564 UseMockScrollbarSettings mockScrollbarSettings; |
1571 registerMockedHttpURLLoad("viewport-zero-values.html"); | 1565 registerMockedHttpURLLoad("viewport-zero-values.html"); |
1572 | 1566 |
(...skipping 26 matching lines...) Expand all Loading... |
1599 FixedLayoutTestWebViewClient client; | 1593 FixedLayoutTestWebViewClient client; |
1600 client.m_screenInfo.deviceScaleFactor = 1; | 1594 client.m_screenInfo.deviceScaleFactor = 1; |
1601 int viewportWidth = 640; | 1595 int viewportWidth = 640; |
1602 int viewportHeight = 480; | 1596 int viewportHeight = 480; |
1603 | 1597 |
1604 FrameTestHelpers::WebViewHelper webViewHelper; | 1598 FrameTestHelpers::WebViewHelper webViewHelper; |
1605 webViewHelper.initialize(true, 0, &client); | 1599 webViewHelper.initialize(true, 0, &client); |
1606 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1600 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
1607 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1601 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1608 | 1602 |
1609 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 1603 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
1610 EXPECT_FALSE(view->userInputScrollable(blink::VerticalScrollbar)); | 1604 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); |
1611 } | 1605 } |
1612 | 1606 |
1613 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) | 1607 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) |
1614 { | 1608 { |
1615 registerMockedHttpURLLoad("body-overflow-hidden.html"); | 1609 registerMockedHttpURLLoad("body-overflow-hidden.html"); |
1616 | 1610 |
1617 FixedLayoutTestWebViewClient client; | 1611 FixedLayoutTestWebViewClient client; |
1618 client.m_screenInfo.deviceScaleFactor = 1; | 1612 client.m_screenInfo.deviceScaleFactor = 1; |
1619 int viewportWidth = 640; | 1613 int viewportWidth = 640; |
1620 int viewportHeight = 480; | 1614 int viewportHeight = 480; |
1621 | 1615 |
1622 FrameTestHelpers::WebViewHelper webViewHelper; | 1616 FrameTestHelpers::WebViewHelper webViewHelper; |
1623 webViewHelper.initialize(true, 0, &client); | 1617 webViewHelper.initialize(true, 0, &client); |
1624 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t
rue); | 1618 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t
rue); |
1625 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1619 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
1626 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1620 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1627 | 1621 |
1628 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 1622 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
1629 EXPECT_TRUE(view->userInputScrollable(blink::VerticalScrollbar)); | 1623 EXPECT_TRUE(view->userInputScrollable(VerticalScrollbar)); |
1630 } | 1624 } |
1631 | 1625 |
1632 TEST_F(WebFrameTest, NonZeroValuesNoQuirk) | 1626 TEST_F(WebFrameTest, NonZeroValuesNoQuirk) |
1633 { | 1627 { |
1634 UseMockScrollbarSettings mockScrollbarSettings; | 1628 UseMockScrollbarSettings mockScrollbarSettings; |
1635 registerMockedHttpURLLoad("viewport-nonzero-values.html"); | 1629 registerMockedHttpURLLoad("viewport-nonzero-values.html"); |
1636 | 1630 |
1637 FixedLayoutTestWebViewClient client; | 1631 FixedLayoutTestWebViewClient client; |
1638 client.m_screenInfo.deviceScaleFactor = 1; | 1632 client.m_screenInfo.deviceScaleFactor = 1; |
1639 int viewportWidth = 640; | 1633 int viewportWidth = 640; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 client.m_screenInfo.deviceScaleFactor = 1; | 1743 client.m_screenInfo.deviceScaleFactor = 1; |
1750 // Small viewport to ensure there are always scrollbars. | 1744 // Small viewport to ensure there are always scrollbars. |
1751 int viewportWidth = 64; | 1745 int viewportWidth = 64; |
1752 int viewportHeight = 48; | 1746 int viewportHeight = 48; |
1753 | 1747 |
1754 FrameTestHelpers::WebViewHelper webViewHelper; | 1748 FrameTestHelpers::WebViewHelper webViewHelper; |
1755 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &clie
nt, enableViewportSettings); | 1749 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &clie
nt, enableViewportSettings); |
1756 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1750 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1757 webViewHelper.webView()->layout(); | 1751 webViewHelper.webView()->layout(); |
1758 | 1752 |
1759 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 1753 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
1760 int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()
->isOverlayScrollbar() ? 0 : 15); | 1754 int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()
->isOverlayScrollbar() ? 0 : 15); |
1761 int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollb
ar()->isOverlayScrollbar() ? 0 : 15); | 1755 int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollb
ar()->isOverlayScrollbar() ? 0 : 15); |
1762 | 1756 |
1763 webViewHelper.webView()->setPageScaleFactor(2); | 1757 webViewHelper.webView()->setPageScaleFactor(2); |
1764 | 1758 |
1765 blink::IntSize unscaledSize = view->unscaledVisibleContentSize(blink::Includ
eScrollbars); | 1759 IntSize unscaledSize = view->unscaledVisibleContentSize(IncludeScrollbars); |
1766 EXPECT_EQ(viewportWidth, unscaledSize.width()); | 1760 EXPECT_EQ(viewportWidth, unscaledSize.width()); |
1767 EXPECT_EQ(viewportHeight, unscaledSize.height()); | 1761 EXPECT_EQ(viewportHeight, unscaledSize.height()); |
1768 | 1762 |
1769 blink::IntSize unscaledSizeMinusScrollbar = view->unscaledVisibleContentSize
(blink::ExcludeScrollbars); | 1763 IntSize unscaledSizeMinusScrollbar = view->unscaledVisibleContentSize(Exclud
eScrollbars); |
1770 EXPECT_EQ(viewportWidthMinusScrollbar, unscaledSizeMinusScrollbar.width()); | 1764 EXPECT_EQ(viewportWidthMinusScrollbar, unscaledSizeMinusScrollbar.width()); |
1771 EXPECT_EQ(viewportHeightMinusScrollbar, unscaledSizeMinusScrollbar.height())
; | 1765 EXPECT_EQ(viewportHeightMinusScrollbar, unscaledSizeMinusScrollbar.height())
; |
1772 | 1766 |
1773 blink::IntSize scaledSize = view->visibleContentRect().size(); | 1767 IntSize scaledSize = view->visibleContentRect().size(); |
1774 EXPECT_EQ(ceil(viewportWidthMinusScrollbar / 2.0), scaledSize.width()); | 1768 EXPECT_EQ(ceil(viewportWidthMinusScrollbar / 2.0), scaledSize.width()); |
1775 EXPECT_EQ(ceil(viewportHeightMinusScrollbar / 2.0), scaledSize.height()); | 1769 EXPECT_EQ(ceil(viewportHeightMinusScrollbar / 2.0), scaledSize.height()); |
1776 } | 1770 } |
1777 | 1771 |
1778 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) | 1772 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) |
1779 { | 1773 { |
1780 UseMockScrollbarSettings mockScrollbarSettings; | 1774 UseMockScrollbarSettings mockScrollbarSettings; |
1781 registerMockedHttpURLLoad("fixed_layout.html"); | 1775 registerMockedHttpURLLoad("fixed_layout.html"); |
1782 | 1776 |
1783 FixedLayoutTestWebViewClient client; | 1777 FixedLayoutTestWebViewClient client; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2026 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2033 | 2027 |
2034 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); | 2028 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); |
2035 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); | 2029 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); |
2036 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); | 2030 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); |
2037 } | 2031 } |
2038 | 2032 |
2039 class WebFrameResizeTest : public WebFrameTest { | 2033 class WebFrameResizeTest : public WebFrameTest { |
2040 protected: | 2034 protected: |
2041 | 2035 |
2042 static blink::FloatSize computeRelativeOffset(const blink::IntPoint& absolut
eOffset, const blink::LayoutRect& rect) | 2036 static FloatSize computeRelativeOffset(const IntPoint& absoluteOffset, const
LayoutRect& rect) |
2043 { | 2037 { |
2044 blink::FloatSize relativeOffset = blink::FloatPoint(absoluteOffset) - re
ct.location(); | 2038 FloatSize relativeOffset = FloatPoint(absoluteOffset) - rect.location(); |
2045 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); | 2039 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); |
2046 return relativeOffset; | 2040 return relativeOffset; |
2047 } | 2041 } |
2048 | 2042 |
2049 void testResizeYieldsCorrectScrollAndScale(const char* url, | 2043 void testResizeYieldsCorrectScrollAndScale(const char* url, |
2050 const float initialPageScaleFacto
r, | 2044 const float initialPageScaleFacto
r, |
2051 const WebSize scrollOffset, | 2045 const WebSize scrollOffset, |
2052 const WebSize viewportSize, | 2046 const WebSize viewportSize, |
2053 const bool shouldScaleRelativeToV
iewportWidth) { | 2047 const bool shouldScaleRelativeToV
iewportWidth) { |
2054 UseMockScrollbarSettings mockScrollbarSettings; | 2048 UseMockScrollbarSettings mockScrollbarSettings; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 // Generic resize preserves scrollOffset relative to anchor node located | 2083 // Generic resize preserves scrollOffset relative to anchor node located |
2090 // the top center of the screen. | 2084 // the top center of the screen. |
2091 { | 2085 { |
2092 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); | 2086 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); |
2093 float pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor
(); | 2087 float pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor
(); |
2094 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); | 2088 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); |
2095 float expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelati
veToViewportWidth ? aspectRatio : 1); | 2089 float expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelati
veToViewportWidth ? aspectRatio : 1); |
2096 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); | 2090 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); |
2097 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs
et); | 2091 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs
et); |
2098 | 2092 |
2099 blink::IntPoint anchorPoint = blink::IntPoint(scrollOffset) + blink:
:IntPoint(viewportSize.width / 2, 0); | 2093 IntPoint anchorPoint = IntPoint(scrollOffset) + IntPoint(viewportSiz
e.width / 2, 0); |
2100 RefPtrWillBeRawPtr<blink::Node> anchorNode = webViewHelper.webViewIm
pl()->mainFrameImpl()->frame()->eventHandler().hitTestResultAtPoint(anchorPoint,
HitTestRequest::ReadOnly | HitTestRequest::Active).innerNode(); | 2094 RefPtrWillBeRawPtr<Node> anchorNode = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->eventHandler().hitTestResultAtPoint(anchorPoint, HitTes
tRequest::ReadOnly | HitTestRequest::Active).innerNode(); |
2101 ASSERT(anchorNode); | 2095 ASSERT(anchorNode); |
2102 | 2096 |
2103 pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor(); | 2097 pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor(); |
2104 const blink::FloatSize preResizeRelativeOffset | 2098 const FloatSize preResizeRelativeOffset |
2105 = computeRelativeOffset(anchorPoint, anchorNode->boundingBox()); | 2099 = computeRelativeOffset(anchorPoint, anchorNode->boundingBox()); |
2106 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); | 2100 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); |
2107 blink::IntPoint newAnchorPoint = blink::IntPoint(webViewHelper.webVi
ewImpl()->mainFrame()->scrollOffset()) + blink::IntPoint(viewportSize.height / 2
, 0); | 2101 IntPoint newAnchorPoint = IntPoint(webViewHelper.webViewImpl()->main
Frame()->scrollOffset()) + IntPoint(viewportSize.height / 2, 0); |
2108 const blink::FloatSize postResizeRelativeOffset | 2102 const FloatSize postResizeRelativeOffset |
2109 = computeRelativeOffset(newAnchorPoint, anchorNode->boundingBox(
)); | 2103 = computeRelativeOffset(newAnchorPoint, anchorNode->boundingBox(
)); |
2110 EXPECT_NEAR(preResizeRelativeOffset.width(), postResizeRelativeOffse
t.width(), 0.15f); | 2104 EXPECT_NEAR(preResizeRelativeOffset.width(), postResizeRelativeOffse
t.width(), 0.15f); |
2111 expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelativeToVi
ewportWidth ? 1 / aspectRatio : 1); | 2105 expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelativeToVi
ewportWidth ? 1 / aspectRatio : 1); |
2112 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); | 2106 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); |
2113 } | 2107 } |
2114 } | 2108 } |
2115 }; | 2109 }; |
2116 | 2110 |
2117 TEST_F(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice
Width) | 2111 TEST_F(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice
Width) |
2118 { | 2112 { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 | 2185 |
2192 // Set <1 page scale so that the clip rect should be larger than | 2186 // Set <1 page scale so that the clip rect should be larger than |
2193 // the viewport size as passed into resize(). | 2187 // the viewport size as passed into resize(). |
2194 webViewHelper.webView()->setPageScaleFactor(0.5); | 2188 webViewHelper.webView()->setPageScaleFactor(0.5); |
2195 | 2189 |
2196 SkBitmap bitmap; | 2190 SkBitmap bitmap; |
2197 ASSERT_TRUE(bitmap.allocN32Pixels(200, 200)); | 2191 ASSERT_TRUE(bitmap.allocN32Pixels(200, 200)); |
2198 bitmap.eraseColor(0); | 2192 bitmap.eraseColor(0); |
2199 SkCanvas canvas(bitmap); | 2193 SkCanvas canvas(bitmap); |
2200 | 2194 |
2201 blink::GraphicsContext context(&canvas); | 2195 GraphicsContext context(&canvas); |
2202 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); | 2196 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
2203 | 2197 |
2204 EXPECT_EQ_RECT(blink::IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); | 2198 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); |
2205 | 2199 |
2206 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2200 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
2207 blink::IntRect paintRect(0, 0, 200, 200); | 2201 IntRect paintRect(0, 0, 200, 200); |
2208 view->paint(&context, paintRect); | 2202 view->paint(&context, paintRect); |
2209 | 2203 |
2210 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient | 2204 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient |
2211 // to return a non-null layerTreeView, which is what all our shipping config
urations do, | 2205 // to return a non-null layerTreeView, which is what all our shipping config
urations do, |
2212 // so this is just exposing an existing bug. | 2206 // so this is just exposing an existing bug. |
2213 // crbug.com/365812 | 2207 // crbug.com/365812 |
2214 #ifndef NDEBUG | 2208 #ifndef NDEBUG |
2215 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); | 2209 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); |
2216 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); | 2210 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); |
2217 blink::IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHe
ightMinusScrollbar * 2); | 2211 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); |
2218 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); | 2212 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); |
2219 #endif | 2213 #endif |
2220 } | 2214 } |
2221 | 2215 |
2222 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) | 2216 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) |
2223 { | 2217 { |
2224 UseMockScrollbarSettings mockScrollbarSettings; | 2218 UseMockScrollbarSettings mockScrollbarSettings; |
2225 registerMockedHttpURLLoad("fixed_layout.html"); | 2219 registerMockedHttpURLLoad("fixed_layout.html"); |
2226 | 2220 |
2227 FixedLayoutTestWebViewClient client; | 2221 FixedLayoutTestWebViewClient client; |
2228 client.m_screenInfo.deviceScaleFactor = 1; | 2222 client.m_screenInfo.deviceScaleFactor = 1; |
2229 int viewportWidth = 640; | 2223 int viewportWidth = 640; |
2230 int viewportHeight = 480; | 2224 int viewportHeight = 480; |
2231 | 2225 |
2232 FrameTestHelpers::WebViewHelper webViewHelper; | 2226 FrameTestHelpers::WebViewHelper webViewHelper; |
2233 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 2227 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
2234 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2228 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2235 webViewHelper.webView()->layout(); | 2229 webViewHelper.webView()->layout(); |
2236 | 2230 |
2237 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2231 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
2238 EXPECT_EQ(view->scrollSize(blink::HorizontalScrollbar), view->contentsSize()
.width() - view->visibleContentRect().width()); | 2232 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width(
) - view->visibleContentRect().width()); |
2239 EXPECT_EQ(view->scrollSize(blink::VerticalScrollbar), view->contentsSize().h
eight() - view->visibleContentRect().height()); | 2233 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height()
- view->visibleContentRect().height()); |
2240 | 2234 |
2241 webViewHelper.webView()->setPageScaleFactor(10); | 2235 webViewHelper.webView()->setPageScaleFactor(10); |
2242 | 2236 |
2243 EXPECT_EQ(view->scrollSize(blink::HorizontalScrollbar), view->contentsSize()
.width() - view->visibleContentRect().width()); | 2237 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width(
) - view->visibleContentRect().width()); |
2244 EXPECT_EQ(view->scrollSize(blink::VerticalScrollbar), view->contentsSize().h
eight() - view->visibleContentRect().height()); | 2238 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height()
- view->visibleContentRect().height()); |
2245 } | 2239 } |
2246 | 2240 |
2247 TEST_F(WebFrameTest, CanOverrideScaleLimits) | 2241 TEST_F(WebFrameTest, CanOverrideScaleLimits) |
2248 { | 2242 { |
2249 UseMockScrollbarSettings mockScrollbarSettings; | 2243 UseMockScrollbarSettings mockScrollbarSettings; |
2250 | 2244 |
2251 registerMockedHttpURLLoad("no_scale_for_you.html"); | 2245 registerMockedHttpURLLoad("no_scale_for_you.html"); |
2252 | 2246 |
2253 FixedLayoutTestWebViewClient client; | 2247 FixedLayoutTestWebViewClient client; |
2254 client.m_screenInfo.deviceScaleFactor = 1; | 2248 client.m_screenInfo.deviceScaleFactor = 1; |
(...skipping 30 matching lines...) Expand all Loading... |
2285 int viewHeight = 500; | 2279 int viewHeight = 500; |
2286 | 2280 |
2287 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 2281 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
2288 FrameTestHelpers::WebViewHelper webViewHelper; | 2282 FrameTestHelpers::WebViewHelper webViewHelper; |
2289 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 2283 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
2290 | 2284 |
2291 webViewHelper.webView()->setPageScaleFactorLimits(1, 1); | 2285 webViewHelper.webView()->setPageScaleFactorLimits(1, 1); |
2292 webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); | 2286 webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); |
2293 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); | 2287 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); |
2294 | 2288 |
2295 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2289 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
2296 EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar())
; | 2290 EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar())
; |
2297 EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2291 EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
2298 | 2292 |
2299 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); | 2293 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); |
2300 webViewHelper.webView()->layout(); | 2294 webViewHelper.webView()->layout(); |
2301 EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()
); | 2295 EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()
); |
2302 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2296 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
2303 } | 2297 } |
2304 | 2298 |
2305 void setScaleAndScrollAndLayout(blink::WebView* webView, WebPoint scroll, float
scale) | 2299 void setScaleAndScrollAndLayout(WebView* webView, WebPoint scroll, float scale) |
2306 { | 2300 { |
2307 webView->setPageScaleFactor(scale); | 2301 webView->setPageScaleFactor(scale); |
2308 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); | 2302 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); |
2309 webView->layout(); | 2303 webView->layout(); |
2310 } | 2304 } |
2311 | 2305 |
2312 TEST_F(WebFrameTest, DivAutoZoomParamsTest) | 2306 TEST_F(WebFrameTest, DivAutoZoomParamsTest) |
2313 { | 2307 { |
2314 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); | 2308 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
2315 | 2309 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 EXPECT_NEAR(tallDiv.y, scroll.y, 20); | 2357 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
2364 | 2358 |
2365 // Test for Non-doubletap scaling | 2359 // Test for Non-doubletap scaling |
2366 // Test zooming into div. | 2360 // Test zooming into div. |
2367 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); | 2361 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); |
2368 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 2362 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
2369 } | 2363 } |
2370 | 2364 |
2371 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2365 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
2372 { | 2366 { |
2373 blink::IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositi
onForTesting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 2367 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
2374 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | 2368 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
2375 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); | 2369 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); |
2376 scale = webViewImpl->pageScaleFactor(); | 2370 scale = webViewImpl->pageScaleFactor(); |
2377 } | 2371 } |
2378 | 2372 |
2379 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) | 2373 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) |
2380 { | 2374 { |
2381 if (webViewImpl->zoomToMultipleTargetsRect(rect)) | 2375 if (webViewImpl->zoomToMultipleTargetsRect(rect)) |
2382 simulatePageScale(webViewImpl, scale); | 2376 simulatePageScale(webViewImpl, scale); |
2383 } | 2377 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2697 // Test scrolling the focused node | 2691 // Test scrolling the focused node |
2698 // The edit box is shorter and narrower than the viewport when legible. | 2692 // The edit box is shorter and narrower than the viewport when legible. |
2699 webViewHelper.webView()->advanceFocus(false); | 2693 webViewHelper.webView()->advanceFocus(false); |
2700 // Set the caret to the end of the input box. | 2694 // Set the caret to the end of the input box. |
2701 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); | 2695 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); |
2702 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); | 2696 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); |
2703 WebRect rect, caret; | 2697 WebRect rect, caret; |
2704 webViewHelper.webViewImpl()->selectionBounds(caret, rect); | 2698 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
2705 | 2699 |
2706 float scale; | 2700 float scale; |
2707 blink::IntPoint scroll; | 2701 IntPoint scroll; |
2708 bool needAnimation; | 2702 bool needAnimation; |
2709 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2703 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
2710 EXPECT_TRUE(needAnimation); | 2704 EXPECT_TRUE(needAnimation); |
2711 // The edit box should be left aligned with a margin for possible label. | 2705 // The edit box should be left aligned with a margin for possible label. |
2712 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; | 2706 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; |
2713 EXPECT_NEAR(hScroll, scroll.x(), 1); | 2707 EXPECT_NEAR(hScroll, scroll.x(), 1); |
2714 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; | 2708 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
2715 EXPECT_NEAR(vScroll, scroll.y(), 1); | 2709 EXPECT_NEAR(vScroll, scroll.y(), 1); |
2716 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2710 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
2717 | 2711 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2769 FrameTestHelpers::WebViewHelper webViewHelper; | 2763 FrameTestHelpers::WebViewHelper webViewHelper; |
2770 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); | 2764 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); |
2771 | 2765 |
2772 webViewHelper.webView()->mainFrame()->reload(true); | 2766 webViewHelper.webView()->mainFrame()->reload(true); |
2773 // start another reload before request is delivered. | 2767 // start another reload before request is delivered. |
2774 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); | 2768 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
2775 } | 2769 } |
2776 | 2770 |
2777 class ReloadWithOverrideURLTask : public WebThread::Task { | 2771 class ReloadWithOverrideURLTask : public WebThread::Task { |
2778 public: | 2772 public: |
2779 ReloadWithOverrideURLTask(WebFrame* frame, const blink::KURL& url, bool igno
reCache) | 2773 ReloadWithOverrideURLTask(WebFrame* frame, const KURL& url, bool ignoreCache
) |
2780 : m_frame(frame), m_url(url), m_ignoreCache(ignoreCache) | 2774 : m_frame(frame), m_url(url), m_ignoreCache(ignoreCache) |
2781 { | 2775 { |
2782 } | 2776 } |
2783 | 2777 |
2784 virtual void run() OVERRIDE | 2778 virtual void run() OVERRIDE |
2785 { | 2779 { |
2786 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); | 2780 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); |
2787 } | 2781 } |
2788 | 2782 |
2789 private: | 2783 private: |
2790 WebFrame* const m_frame; | 2784 WebFrame* const m_frame; |
2791 const blink::KURL m_url; | 2785 const KURL m_url; |
2792 const bool m_ignoreCache; | 2786 const bool m_ignoreCache; |
2793 }; | 2787 }; |
2794 | 2788 |
2795 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) | 2789 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) |
2796 { | 2790 { |
2797 const std::string firstURL = "find.html"; | 2791 const std::string firstURL = "find.html"; |
2798 const std::string secondURL = "form.html"; | 2792 const std::string secondURL = "form.html"; |
2799 const std::string thirdURL = "history.html"; | 2793 const std::string thirdURL = "history.html"; |
2800 const float pageScaleFactor = 1.1684f; | 2794 const float pageScaleFactor = 1.1684f; |
2801 const int pageWidth = 640; | 2795 const int pageWidth = 640; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 { | 3141 { |
3148 FrameTestHelpers::WebViewHelper webViewHelper; | 3142 FrameTestHelpers::WebViewHelper webViewHelper; |
3149 webViewHelper.initializeAndLoad("about:blank", true); | 3143 webViewHelper.initializeAndLoad("about:blank", true); |
3150 // We set the size because it impacts line wrapping, which changes the | 3144 // We set the size because it impacts line wrapping, which changes the |
3151 // resulting text value. | 3145 // resulting text value. |
3152 webViewHelper.webView()->resize(WebSize(640, 480)); | 3146 webViewHelper.webView()->resize(WebSize(640, 480)); |
3153 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3147 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3154 | 3148 |
3155 // Generate a simple test case. | 3149 // Generate a simple test case. |
3156 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 3150 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
3157 blink::KURL testURL = toKURL("about:blank"); | 3151 KURL testURL = toKURL("about:blank"); |
3158 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3152 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3159 | 3153 |
3160 // Make sure it comes out OK. | 3154 // Make sure it comes out OK. |
3161 const std::string expected("Foo bar\nbaz"); | 3155 const std::string expected("Foo bar\nbaz"); |
3162 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3156 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
3163 EXPECT_EQ(expected, text.utf8()); | 3157 EXPECT_EQ(expected, text.utf8()); |
3164 | 3158 |
3165 // Try reading the same one with clipping of the text. | 3159 // Try reading the same one with clipping of the text. |
3166 const int length = 5; | 3160 const int length = 5; |
3167 text = frame->contentAsText(length); | 3161 text = frame->contentAsText(length); |
(...skipping 18 matching lines...) Expand all Loading... |
3186 } | 3180 } |
3187 | 3181 |
3188 TEST_F(WebFrameTest, GetFullHtmlOfPage) | 3182 TEST_F(WebFrameTest, GetFullHtmlOfPage) |
3189 { | 3183 { |
3190 FrameTestHelpers::WebViewHelper webViewHelper; | 3184 FrameTestHelpers::WebViewHelper webViewHelper; |
3191 webViewHelper.initializeAndLoad("about:blank", true); | 3185 webViewHelper.initializeAndLoad("about:blank", true); |
3192 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3186 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3193 | 3187 |
3194 // Generate a simple test case. | 3188 // Generate a simple test case. |
3195 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 3189 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
3196 blink::KURL testURL = toKURL("about:blank"); | 3190 KURL testURL = toKURL("about:blank"); |
3197 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3191 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3198 | 3192 |
3199 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3193 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
3200 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3194 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
3201 | 3195 |
3202 const std::string html = frame->contentAsMarkup().utf8(); | 3196 const std::string html = frame->contentAsMarkup().utf8(); |
3203 | 3197 |
3204 // Load again with the output html. | 3198 // Load again with the output html. |
3205 FrameTestHelpers::loadHTMLString(frame, html, testURL); | 3199 FrameTestHelpers::loadHTMLString(frame, html, testURL); |
3206 | 3200 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3428 webViewHelper.webView()->layout(); | 3422 webViewHelper.webView()->layout(); |
3429 runPendingTasks(); | 3423 runPendingTasks(); |
3430 | 3424 |
3431 static const char* kFindString = "result"; | 3425 static const char* kFindString = "result"; |
3432 static const int kFindIdentifier = 12345; | 3426 static const int kFindIdentifier = 12345; |
3433 | 3427 |
3434 WebFindOptions options; | 3428 WebFindOptions options; |
3435 WebString searchText = WebString::fromUTF8(kFindString); | 3429 WebString searchText = WebString::fromUTF8(kFindString); |
3436 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3430 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3437 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); | 3431 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); |
3438 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3432 RefPtr<LocalFrame> holdSecondFrame = secondFrame->frame(); |
3439 | 3433 |
3440 // Detach the frame before finding. | 3434 // Detach the frame before finding. |
3441 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3435 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
3442 | 3436 |
3443 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3437 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
3444 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); | 3438 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); |
3445 | 3439 |
3446 runPendingTasks(); | 3440 runPendingTasks(); |
3447 EXPECT_FALSE(client.findResultsAreReady()); | 3441 EXPECT_FALSE(client.findResultsAreReady()); |
3448 | 3442 |
(...skipping 20 matching lines...) Expand all Loading... |
3469 webViewHelper.webView()->layout(); | 3463 webViewHelper.webView()->layout(); |
3470 runPendingTasks(); | 3464 runPendingTasks(); |
3471 | 3465 |
3472 static const char* kFindString = "result"; | 3466 static const char* kFindString = "result"; |
3473 static const int kFindIdentifier = 12345; | 3467 static const int kFindIdentifier = 12345; |
3474 | 3468 |
3475 WebFindOptions options; | 3469 WebFindOptions options; |
3476 WebString searchText = WebString::fromUTF8(kFindString); | 3470 WebString searchText = WebString::fromUTF8(kFindString); |
3477 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3471 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3478 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | 3472 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
3479 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3473 RefPtr<LocalFrame> holdSecondFrame = secondFrame->frame(); |
3480 | 3474 |
3481 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3475 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3482 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3476 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
3483 | 3477 |
3484 runPendingTasks(); | 3478 runPendingTasks(); |
3485 EXPECT_FALSE(client.findResultsAreReady()); | 3479 EXPECT_FALSE(client.findResultsAreReady()); |
3486 | 3480 |
3487 // Detach the frame between finding and scoping. | 3481 // Detach the frame between finding and scoping. |
3488 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3482 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
3489 | 3483 |
(...skipping 20 matching lines...) Expand all Loading... |
3510 webViewHelper.webView()->layout(); | 3504 webViewHelper.webView()->layout(); |
3511 runPendingTasks(); | 3505 runPendingTasks(); |
3512 | 3506 |
3513 static const char* kFindString = "result"; | 3507 static const char* kFindString = "result"; |
3514 static const int kFindIdentifier = 12345; | 3508 static const int kFindIdentifier = 12345; |
3515 | 3509 |
3516 WebFindOptions options; | 3510 WebFindOptions options; |
3517 WebString searchText = WebString::fromUTF8(kFindString); | 3511 WebString searchText = WebString::fromUTF8(kFindString); |
3518 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3512 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3519 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | 3513 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
3520 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3514 RefPtr<LocalFrame> holdSecondFrame = secondFrame->frame(); |
3521 | 3515 |
3522 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3516 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3523 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3517 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
3524 | 3518 |
3525 runPendingTasks(); | 3519 runPendingTasks(); |
3526 EXPECT_FALSE(client.findResultsAreReady()); | 3520 EXPECT_FALSE(client.findResultsAreReady()); |
3527 | 3521 |
3528 mainFrame->resetMatchCount(); | 3522 mainFrame->resetMatchCount(); |
3529 | 3523 |
3530 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3524 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3589 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3583 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3590 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3584 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
3591 | 3585 |
3592 mainFrame->resetMatchCount(); | 3586 mainFrame->resetMatchCount(); |
3593 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3587 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
3594 | 3588 |
3595 runPendingTasks(); | 3589 runPendingTasks(); |
3596 EXPECT_TRUE(client.findResultsAreReady()); | 3590 EXPECT_TRUE(client.findResultsAreReady()); |
3597 | 3591 |
3598 // Get the tickmarks for the original find request. | 3592 // Get the tickmarks for the original find request. |
3599 blink::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->
frameView(); | 3593 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
3600 RefPtr<blink::Scrollbar> scrollbar = frameView->createScrollbar(blink::Horiz
ontalScrollbar); | 3594 RefPtr<Scrollbar> scrollbar = frameView->createScrollbar(HorizontalScrollbar
); |
3601 Vector<blink::IntRect> originalTickmarks; | 3595 Vector<IntRect> originalTickmarks; |
3602 scrollbar->getTickmarks(originalTickmarks); | 3596 scrollbar->getTickmarks(originalTickmarks); |
3603 EXPECT_EQ(4u, originalTickmarks.size()); | 3597 EXPECT_EQ(4u, originalTickmarks.size()); |
3604 | 3598 |
3605 // Override the tickmarks. | 3599 // Override the tickmarks. |
3606 Vector<blink::IntRect> overridingTickmarksExpected; | 3600 Vector<IntRect> overridingTickmarksExpected; |
3607 overridingTickmarksExpected.append(blink::IntRect(0, 0, 100, 100)); | 3601 overridingTickmarksExpected.append(IntRect(0, 0, 100, 100)); |
3608 overridingTickmarksExpected.append(blink::IntRect(0, 20, 100, 100)); | 3602 overridingTickmarksExpected.append(IntRect(0, 20, 100, 100)); |
3609 overridingTickmarksExpected.append(blink::IntRect(0, 30, 100, 100)); | 3603 overridingTickmarksExpected.append(IntRect(0, 30, 100, 100)); |
3610 mainFrame->setTickmarks(overridingTickmarksExpected); | 3604 mainFrame->setTickmarks(overridingTickmarksExpected); |
3611 | 3605 |
3612 // Check the tickmarks are overriden correctly. | 3606 // Check the tickmarks are overriden correctly. |
3613 Vector<blink::IntRect> overridingTickmarksActual; | 3607 Vector<IntRect> overridingTickmarksActual; |
3614 scrollbar->getTickmarks(overridingTickmarksActual); | 3608 scrollbar->getTickmarks(overridingTickmarksActual); |
3615 EXPECT_EQ(overridingTickmarksExpected, overridingTickmarksActual); | 3609 EXPECT_EQ(overridingTickmarksExpected, overridingTickmarksActual); |
3616 | 3610 |
3617 // Reset the tickmark behavior. | 3611 // Reset the tickmark behavior. |
3618 Vector<blink::IntRect> resetTickmarks; | 3612 Vector<IntRect> resetTickmarks; |
3619 mainFrame->setTickmarks(resetTickmarks); | 3613 mainFrame->setTickmarks(resetTickmarks); |
3620 | 3614 |
3621 // Check that the original tickmarks are returned | 3615 // Check that the original tickmarks are returned |
3622 Vector<blink::IntRect> originalTickmarksAfterReset; | 3616 Vector<IntRect> originalTickmarksAfterReset; |
3623 scrollbar->getTickmarks(originalTickmarksAfterReset); | 3617 scrollbar->getTickmarks(originalTickmarksAfterReset); |
3624 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); | 3618 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); |
3625 } | 3619 } |
3626 | 3620 |
3627 static WebPoint topLeft(const WebRect& rect) | 3621 static WebPoint topLeft(const WebRect& rect) |
3628 { | 3622 { |
3629 return WebPoint(rect.x, rect.y); | 3623 return WebPoint(rect.x, rect.y); |
3630 } | 3624 } |
3631 | 3625 |
3632 static WebPoint bottomRightMinusOne(const WebRect& rect) | 3626 static WebPoint bottomRightMinusOne(const WebRect& rect) |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3856 | 3850 |
3857 // If the selection is editable text, we can't extend it into non-editable t
ext. | 3851 // If the selection is editable text, we can't extend it into non-editable t
ext. |
3858 frame->executeScript(WebScriptSource("selectElement('editable_1');")); | 3852 frame->executeScript(WebScriptSource("selectElement('editable_1');")); |
3859 EXPECT_EQ("Editable 1.", selectionAsString(frame)); | 3853 EXPECT_EQ("Editable 1.", selectionAsString(frame)); |
3860 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightM
inusOne(elementBounds(frame, "footer_1"))); | 3854 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightM
inusOne(elementBounds(frame, "footer_1"))); |
3861 // positionForPoint returns the wrong values for contenteditable spans. See | 3855 // positionForPoint returns the wrong values for contenteditable spans. See |
3862 // http://crbug.com/238334. | 3856 // http://crbug.com/238334. |
3863 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); | 3857 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); |
3864 } | 3858 } |
3865 | 3859 |
3866 static int computeOffset(blink::RenderObject* renderer, int x, int y) | 3860 static int computeOffset(RenderObject* renderer, int x, int y) |
3867 { | 3861 { |
3868 return blink::VisiblePosition(renderer->positionForPoint(blink::LayoutPoint(
x, y))).deepEquivalent().computeOffsetInContainerNode(); | 3862 return VisiblePosition(renderer->positionForPoint(LayoutPoint(x, y))).deepEq
uivalent().computeOffsetInContainerNode(); |
3869 } | 3863 } |
3870 | 3864 |
3871 // positionForPoint returns the wrong values for contenteditable spans. See | 3865 // positionForPoint returns the wrong values for contenteditable spans. See |
3872 // http://crbug.com/238334. | 3866 // http://crbug.com/238334. |
3873 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) | 3867 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) |
3874 { | 3868 { |
3875 registerMockedHttpURLLoad("select_range_span_editable.html"); | 3869 registerMockedHttpURLLoad("select_range_span_editable.html"); |
3876 FrameTestHelpers::WebViewHelper webViewHelper; | 3870 FrameTestHelpers::WebViewHelper webViewHelper; |
3877 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); | 3871 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); |
3878 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3872 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3879 blink::RenderObject* renderer = mainFrame->frame()->selection().rootEditable
Element()->renderer(); | 3873 RenderObject* renderer = mainFrame->frame()->selection().rootEditableElement
()->renderer(); |
3880 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 3874 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
3881 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 3875 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
3882 | 3876 |
3883 registerMockedHttpURLLoad("select_range_div_editable.html"); | 3877 registerMockedHttpURLLoad("select_range_div_editable.html"); |
3884 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); | 3878 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); |
3885 mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); | 3879 mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
3886 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; | 3880 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; |
3887 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 3881 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
3888 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 3882 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
3889 } | 3883 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4019 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } | 4013 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } |
4020 | 4014 |
4021 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } | 4015 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } |
4022 | 4016 |
4023 private: | 4017 private: |
4024 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; | 4018 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; |
4025 }; | 4019 }; |
4026 | 4020 |
4027 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) | 4021 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
4028 { | 4022 { |
4029 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); | 4023 RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); |
4030 | 4024 |
4031 registerMockedHttpURLLoad("select_range_basic.html"); | 4025 registerMockedHttpURLLoad("select_range_basic.html"); |
4032 registerMockedHttpURLLoad("select_range_scroll.html"); | 4026 registerMockedHttpURLLoad("select_range_scroll.html"); |
4033 | 4027 |
4034 int viewWidth = 500; | 4028 int viewWidth = 500; |
4035 int viewHeight = 500; | 4029 int viewHeight = 500; |
4036 | 4030 |
4037 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; | 4031 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; |
4038 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); | 4032 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); |
4039 | 4033 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 EXPECT_FALSE(transitionElement.isNull()); | 4437 EXPECT_FALSE(transitionElement.isNull()); |
4444 | 4438 |
4445 // Check that the inline script was not executed. | 4439 // Check that the inline script was not executed. |
4446 EXPECT_FALSE(transitionElement.hasAttribute("dir")); | 4440 EXPECT_FALSE(transitionElement.hasAttribute("dir")); |
4447 } | 4441 } |
4448 | 4442 |
4449 class SpellCheckClient : public WebSpellCheckClient { | 4443 class SpellCheckClient : public WebSpellCheckClient { |
4450 public: | 4444 public: |
4451 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } | 4445 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } |
4452 virtual ~SpellCheckClient() { } | 4446 virtual ~SpellCheckClient() { } |
4453 virtual void requestCheckingOfText(const blink::WebString&, const blink::Web
Vector<uint32_t>&, const blink::WebVector<unsigned>&, blink::WebTextCheckingComp
letion* completion) OVERRIDE | 4447 virtual void requestCheckingOfText(const WebString&, const WebVector<uint32_
t>&, const WebVector<unsigned>&, WebTextCheckingCompletion* completion) OVERRIDE |
4454 { | 4448 { |
4455 ++m_numberOfTimesChecked; | 4449 ++m_numberOfTimesChecked; |
4456 Vector<WebTextCheckingResult> results; | 4450 Vector<WebTextCheckingResult> results; |
4457 const int misspellingStartOffset = 1; | 4451 const int misspellingStartOffset = 1; |
4458 const int misspellingLength = 8; | 4452 const int misspellingLength = 8; |
4459 results.append(WebTextCheckingResult(WebTextDecorationTypeSpelling, miss
pellingStartOffset, misspellingLength, WebString(), m_hash)); | 4453 results.append(WebTextCheckingResult(WebTextDecorationTypeSpelling, miss
pellingStartOffset, misspellingLength, WebString(), m_hash)); |
4460 completion->didFinishCheckingText(results); | 4454 completion->didFinishCheckingText(results); |
4461 } | 4455 } |
4462 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } | 4456 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } |
4463 private: | 4457 private: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4582 EXPECT_EQ(1U, documentMarkers.size()); | 4576 EXPECT_EQ(1U, documentMarkers.size()); |
4583 EXPECT_EQ(kHash, documentMarkers[0]); | 4577 EXPECT_EQ(kHash, documentMarkers[0]); |
4584 } | 4578 } |
4585 | 4579 |
4586 class StubbornSpellCheckClient : public WebSpellCheckClient { | 4580 class StubbornSpellCheckClient : public WebSpellCheckClient { |
4587 public: | 4581 public: |
4588 StubbornSpellCheckClient() : m_completion(0) { } | 4582 StubbornSpellCheckClient() : m_completion(0) { } |
4589 virtual ~StubbornSpellCheckClient() { } | 4583 virtual ~StubbornSpellCheckClient() { } |
4590 | 4584 |
4591 virtual void requestCheckingOfText( | 4585 virtual void requestCheckingOfText( |
4592 const blink::WebString&, | 4586 const WebString&, |
4593 const blink::WebVector<uint32_t>&, | 4587 const WebVector<uint32_t>&, |
4594 const blink::WebVector<unsigned>&, | 4588 const WebVector<unsigned>&, |
4595 blink::WebTextCheckingCompletion* completion) OVERRIDE | 4589 WebTextCheckingCompletion* completion) OVERRIDE |
4596 { | 4590 { |
4597 m_completion = completion; | 4591 m_completion = completion; |
4598 } | 4592 } |
4599 | 4593 |
4600 void kickNoResults() | 4594 void kickNoResults() |
4601 { | 4595 { |
4602 kick(-1, -1, WebTextDecorationTypeSpelling); | 4596 kick(-1, -1, WebTextDecorationTypeSpelling); |
4603 } | 4597 } |
4604 | 4598 |
4605 void kick() | 4599 void kick() |
(...skipping 16 matching lines...) Expand all Loading... |
4622 { | 4616 { |
4623 if (!m_completion) | 4617 if (!m_completion) |
4624 return; | 4618 return; |
4625 Vector<WebTextCheckingResult> results; | 4619 Vector<WebTextCheckingResult> results; |
4626 if (misspellingStartOffset >= 0 && misspellingLength > 0) | 4620 if (misspellingStartOffset >= 0 && misspellingLength > 0) |
4627 results.append(WebTextCheckingResult(type, misspellingStartOffset, m
isspellingLength)); | 4621 results.append(WebTextCheckingResult(type, misspellingStartOffset, m
isspellingLength)); |
4628 m_completion->didFinishCheckingText(results); | 4622 m_completion->didFinishCheckingText(results); |
4629 m_completion = 0; | 4623 m_completion = 0; |
4630 } | 4624 } |
4631 | 4625 |
4632 blink::WebTextCheckingCompletion* m_completion; | 4626 WebTextCheckingCompletion* m_completion; |
4633 }; | 4627 }; |
4634 | 4628 |
4635 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) | 4629 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) |
4636 { | 4630 { |
4637 registerMockedHttpURLLoad("spell.html"); | 4631 registerMockedHttpURLLoad("spell.html"); |
4638 FrameTestHelpers::WebViewHelper webViewHelper; | 4632 FrameTestHelpers::WebViewHelper webViewHelper; |
4639 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4633 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
4640 | 4634 |
4641 StubbornSpellCheckClient spellcheck; | 4635 StubbornSpellCheckClient spellcheck; |
4642 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4636 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4931 } | 4925 } |
4932 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } | 4926 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } |
4933 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } | 4927 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } |
4934 | 4928 |
4935 // WebFrameClient: | 4929 // WebFrameClient: |
4936 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE | 4930 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE |
4937 { | 4931 { |
4938 if (frame->parent()) | 4932 if (frame->parent()) |
4939 return; | 4933 return; |
4940 EXPECT_FALSE(m_didScrollMainFrame); | 4934 EXPECT_FALSE(m_didScrollMainFrame); |
4941 blink::FrameView* view = toWebLocalFrameImpl(frame)->frameView(); | 4935 FrameView* view = toWebLocalFrameImpl(frame)->frameView(); |
4942 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 4936 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect |
4943 // which is called from LocalFrame::createView (before the frame is asso
ciated | 4937 // which is called from LocalFrame::createView (before the frame is asso
ciated |
4944 // with the the view). | 4938 // with the the view). |
4945 if (view) { | 4939 if (view) { |
4946 m_didScrollMainFrame = true; | 4940 m_didScrollMainFrame = true; |
4947 m_wasProgrammaticScroll = view->inProgrammaticScroll(); | 4941 m_wasProgrammaticScroll = view->inProgrammaticScroll(); |
4948 } | 4942 } |
4949 } | 4943 } |
4950 private: | 4944 private: |
4951 bool m_didScrollMainFrame; | 4945 bool m_didScrollMainFrame; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5062 } | 5056 } |
5063 }; | 5057 }; |
5064 | 5058 |
5065 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) | 5059 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) |
5066 { | 5060 { |
5067 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5061 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5068 TestNavigationPolicyWebFrameClient client; | 5062 TestNavigationPolicyWebFrameClient client; |
5069 FrameTestHelpers::WebViewHelper webViewHelper; | 5063 FrameTestHelpers::WebViewHelper webViewHelper; |
5070 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); | 5064 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); |
5071 | 5065 |
5072 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); | 5066 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
5073 blink::KURL destination = document->url(); | 5067 KURL destination = document->url(); |
5074 destination.setFragmentIdentifier("test"); | 5068 destination.setFragmentIdentifier("test"); |
5075 | 5069 |
5076 RefPtrWillBeRawPtr<blink::Event> event = blink::MouseEvent::create(blink::Ev
entTypeNames::click, false, false, | 5070 RefPtrWillBeRawPtr<Event> event = MouseEvent::create(EventTypeNames::click,
false, false, |
5077 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); | 5071 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); |
5078 blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destin
ation)); | 5072 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
5079 frameRequest.setTriggeringEvent(event); | 5073 frameRequest.setTriggeringEvent(event); |
5080 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 5074 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
5081 } | 5075 } |
5082 | 5076 |
5083 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { | 5077 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { |
5084 public: | 5078 public: |
5085 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, | 5079 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, |
5086 const WebString&, WebNavigationPolicy, bool) OVERRIDE | 5080 const WebString&, WebNavigationPolicy, bool) OVERRIDE |
5087 { | 5081 { |
5088 EXPECT_TRUE(false); | 5082 EXPECT_TRUE(false); |
(...skipping 22 matching lines...) Expand all Loading... |
5111 | 5105 |
5112 TEST_F(WebFrameTest, ModifiedClickNewWindow) | 5106 TEST_F(WebFrameTest, ModifiedClickNewWindow) |
5113 { | 5107 { |
5114 registerMockedHttpURLLoad("ctrl_click.html"); | 5108 registerMockedHttpURLLoad("ctrl_click.html"); |
5115 registerMockedHttpURLLoad("hello_world.html"); | 5109 registerMockedHttpURLLoad("hello_world.html"); |
5116 TestNewWindowWebViewClient webViewClient; | 5110 TestNewWindowWebViewClient webViewClient; |
5117 TestNewWindowWebFrameClient webFrameClient; | 5111 TestNewWindowWebFrameClient webFrameClient; |
5118 FrameTestHelpers::WebViewHelper webViewHelper; | 5112 FrameTestHelpers::WebViewHelper webViewHelper; |
5119 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); | 5113 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); |
5120 | 5114 |
5121 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); | 5115 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
5122 blink::KURL destination = toKURL(m_baseURL + "hello_world.html"); | 5116 KURL destination = toKURL(m_baseURL + "hello_world.html"); |
5123 | 5117 |
5124 // ctrl+click event | 5118 // ctrl+click event |
5125 RefPtrWillBeRawPtr<blink::Event> event = blink::MouseEvent::create(blink::Ev
entTypeNames::click, false, false, | 5119 RefPtrWillBeRawPtr<Event> event = MouseEvent::create(EventTypeNames::click,
false, false, |
5126 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); | 5120 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); |
5127 blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destin
ation)); | 5121 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
5128 frameRequest.setTriggeringEvent(event); | 5122 frameRequest.setTriggeringEvent(event); |
5129 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); | 5123 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
5130 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 5124 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
5131 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 5125 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
5132 | 5126 |
5133 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 5127 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
5134 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 5128 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
5135 } | 5129 } |
5136 | 5130 |
5137 TEST_F(WebFrameTest, BackToReload) | 5131 TEST_F(WebFrameTest, BackToReload) |
5138 { | 5132 { |
5139 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5133 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5140 FrameTestHelpers::WebViewHelper webViewHelper; | 5134 FrameTestHelpers::WebViewHelper webViewHelper; |
5141 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5135 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
5142 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5136 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5143 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); | 5137 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
5144 RefPtr<blink::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5138 RefPtr<HistoryItem> firstItem = mainFrameLoader.currentItem(); |
5145 EXPECT_TRUE(firstItem); | 5139 EXPECT_TRUE(firstItem); |
5146 | 5140 |
5147 registerMockedHttpURLLoad("white-1x1.png"); | 5141 registerMockedHttpURLLoad("white-1x1.png"); |
5148 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5142 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
5149 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5143 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
5150 | 5144 |
5151 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 5145 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
5152 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5146 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
5153 | 5147 |
5154 FrameTestHelpers::reloadFrame(frame); | 5148 FrameTestHelpers::reloadFrame(frame); |
5155 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5149 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
5156 } | 5150 } |
5157 | 5151 |
5158 TEST_F(WebFrameTest, BackDuringChildFrameReload) | 5152 TEST_F(WebFrameTest, BackDuringChildFrameReload) |
5159 { | 5153 { |
5160 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 5154 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
5161 FrameTestHelpers::WebViewHelper webViewHelper; | 5155 FrameTestHelpers::WebViewHelper webViewHelper; |
5162 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 5156 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
5163 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 5157 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
5164 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); | 5158 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
5165 WebFrame* childFrame = mainFrame->firstChild(); | 5159 WebFrame* childFrame = mainFrame->firstChild(); |
5166 ASSERT_TRUE(childFrame); | 5160 ASSERT_TRUE(childFrame); |
5167 | 5161 |
5168 // Start a history navigation, then have a different frame commit a navigati
on. | 5162 // Start a history navigation, then have a different frame commit a navigati
on. |
5169 // In this case, reload an about:blank frame, which will commit synchronousl
y. | 5163 // In this case, reload an about:blank frame, which will commit synchronousl
y. |
5170 // After the history navigation completes, both the appropriate document url
and | 5164 // After the history navigation completes, both the appropriate document url
and |
5171 // the current history item should reflect the history navigation. | 5165 // the current history item should reflect the history navigation. |
5172 registerMockedHttpURLLoad("white-1x1.png"); | 5166 registerMockedHttpURLLoad("white-1x1.png"); |
5173 WebHistoryItem item; | 5167 WebHistoryItem item; |
5174 item.initialize(); | 5168 item.initialize(); |
(...skipping 23 matching lines...) Expand all Loading... |
5198 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5192 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
5199 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 5193 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
5200 } | 5194 } |
5201 | 5195 |
5202 TEST_F(WebFrameTest, LoadHistoryItemReload) | 5196 TEST_F(WebFrameTest, LoadHistoryItemReload) |
5203 { | 5197 { |
5204 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5198 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5205 FrameTestHelpers::WebViewHelper webViewHelper; | 5199 FrameTestHelpers::WebViewHelper webViewHelper; |
5206 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5200 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
5207 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5201 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5208 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); | 5202 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
5209 RefPtr<blink::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5203 RefPtr<HistoryItem> firstItem = mainFrameLoader.currentItem(); |
5210 EXPECT_TRUE(firstItem); | 5204 EXPECT_TRUE(firstItem); |
5211 | 5205 |
5212 registerMockedHttpURLLoad("white-1x1.png"); | 5206 registerMockedHttpURLLoad("white-1x1.png"); |
5213 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5207 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
5214 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5208 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
5215 | 5209 |
5216 // Cache policy overrides should take. | 5210 // Cache policy overrides should take. |
5217 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); | 5211 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); |
5218 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5212 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
5219 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5213 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5309 | 5303 |
5310 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { | 5304 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { |
5311 public: | 5305 public: |
5312 TestSameDocumentWebFrameClient() | 5306 TestSameDocumentWebFrameClient() |
5313 : m_frameLoadTypeSameSeen(false) | 5307 : m_frameLoadTypeSameSeen(false) |
5314 { | 5308 { |
5315 } | 5309 } |
5316 | 5310 |
5317 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) | 5311 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) |
5318 { | 5312 { |
5319 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == blink::F
rameLoadTypeSame) | 5313 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == FrameLoa
dTypeSame) |
5320 m_frameLoadTypeSameSeen = true; | 5314 m_frameLoadTypeSameSeen = true; |
5321 } | 5315 } |
5322 | 5316 |
5323 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } | 5317 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } |
5324 | 5318 |
5325 private: | 5319 private: |
5326 bool m_frameLoadTypeSameSeen; | 5320 bool m_frameLoadTypeSameSeen; |
5327 }; | 5321 }; |
5328 | 5322 |
5329 TEST_F(WebFrameTest, NavigateToSame) | 5323 TEST_F(WebFrameTest, NavigateToSame) |
5330 { | 5324 { |
5331 registerMockedHttpURLLoad("navigate_to_same.html"); | 5325 registerMockedHttpURLLoad("navigate_to_same.html"); |
5332 TestSameDocumentWebFrameClient client; | 5326 TestSameDocumentWebFrameClient client; |
5333 FrameTestHelpers::WebViewHelper webViewHelper; | 5327 FrameTestHelpers::WebViewHelper webViewHelper; |
5334 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); | 5328 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); |
5335 EXPECT_FALSE(client.frameLoadTypeSameSeen()); | 5329 EXPECT_FALSE(client.frameLoadTypeSameSeen()); |
5336 | 5330 |
5337 blink::FrameLoadRequest frameRequest(0, blink::ResourceRequest(toLocalFrame(
webViewHelper.webViewImpl()->page()->mainFrame())->document()->url())); | 5331 FrameLoadRequest frameRequest(0, ResourceRequest(toLocalFrame(webViewHelper.
webViewImpl()->page()->mainFrame())->document()->url())); |
5338 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 5332 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
5339 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 5333 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
5340 | 5334 |
5341 EXPECT_TRUE(client.frameLoadTypeSameSeen()); | 5335 EXPECT_TRUE(client.frameLoadTypeSameSeen()); |
5342 } | 5336 } |
5343 | 5337 |
5344 class TestSameDocumentWithImageWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { | 5338 class TestSameDocumentWithImageWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { |
5345 public: | 5339 public: |
5346 TestSameDocumentWithImageWebFrameClient() | 5340 TestSameDocumentWithImageWebFrameClient() |
5347 : m_numOfImageRequests(0) | 5341 : m_numOfImageRequests(0) |
(...skipping 30 matching lines...) Expand all Loading... |
5378 | 5372 |
5379 TEST_F(WebFrameTest, WebNodeImageContents) | 5373 TEST_F(WebFrameTest, WebNodeImageContents) |
5380 { | 5374 { |
5381 FrameTestHelpers::WebViewHelper webViewHelper; | 5375 FrameTestHelpers::WebViewHelper webViewHelper; |
5382 webViewHelper.initializeAndLoad("about:blank", true); | 5376 webViewHelper.initializeAndLoad("about:blank", true); |
5383 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5377 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5384 | 5378 |
5385 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; | 5379 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
5386 | 5380 |
5387 // Load up the image and test that we can extract the contents. | 5381 // Load up the image and test that we can extract the contents. |
5388 blink::KURL testURL = toKURL("about:blank"); | 5382 KURL testURL = toKURL("about:blank"); |
5389 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); | 5383 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); |
5390 | 5384 |
5391 WebNode node = frame->document().body().firstChild(); | 5385 WebNode node = frame->document().body().firstChild(); |
5392 EXPECT_TRUE(node.isElementNode()); | 5386 EXPECT_TRUE(node.isElementNode()); |
5393 WebElement element = node.to<WebElement>(); | 5387 WebElement element = node.to<WebElement>(); |
5394 WebImage image = element.imageContents(); | 5388 WebImage image = element.imageContents(); |
5395 ASSERT_FALSE(image.isNull()); | 5389 ASSERT_FALSE(image.isNull()); |
5396 EXPECT_EQ(image.size().width, 10); | 5390 EXPECT_EQ(image.size().width, 10); |
5397 EXPECT_EQ(image.size().height, 10); | 5391 EXPECT_EQ(image.size().height, 10); |
5398 // FIXME: The rest of this test is disabled since the ImageDecodeCache state
may be inconsistent when this test runs. | 5392 // FIXME: The rest of this test is disabled since the ImageDecodeCache state
may be inconsistent when this test runs. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5464 private: | 5458 private: |
5465 WebHistoryCommitType m_lastCommitType; | 5459 WebHistoryCommitType m_lastCommitType; |
5466 }; | 5460 }; |
5467 | 5461 |
5468 TEST_F(WebFrameTest, SameDocumentHistoryNavigationCommitType) | 5462 TEST_F(WebFrameTest, SameDocumentHistoryNavigationCommitType) |
5469 { | 5463 { |
5470 registerMockedHttpURLLoad("push_state.html"); | 5464 registerMockedHttpURLLoad("push_state.html"); |
5471 TestDidNavigateCommitTypeWebFrameClient client; | 5465 TestDidNavigateCommitTypeWebFrameClient client; |
5472 FrameTestHelpers::WebViewHelper webViewHelper; | 5466 FrameTestHelpers::WebViewHelper webViewHelper; |
5473 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); | 5467 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); |
5474 RefPtr<blink::HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFram
e())->loader().currentItem(); | 5468 RefPtr<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame())->l
oader().currentItem(); |
5475 runPendingTasks(); | 5469 runPendingTasks(); |
5476 | 5470 |
5477 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), blink::HistorySameDocumentLoad); | 5471 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), HistorySameDocumentLoad); |
5478 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 5472 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
5479 } | 5473 } |
5480 | 5474 |
5481 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 5475 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
5482 public: | 5476 public: |
5483 TestHistoryWebFrameClient() | 5477 TestHistoryWebFrameClient() |
5484 { | 5478 { |
5485 m_replacesCurrentHistoryItem = false; | 5479 m_replacesCurrentHistoryItem = false; |
5486 m_frame = 0; | 5480 m_frame = 0; |
5487 } | 5481 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5553 { | 5547 { |
5554 registerMockedHttpURLLoad("non-scrollable.html"); | 5548 registerMockedHttpURLLoad("non-scrollable.html"); |
5555 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 5549 TestMainFrameUserOrProgrammaticScrollFrameClient client; |
5556 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 5550 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
5557 FrameTestHelpers::WebViewHelper webViewHelper; | 5551 FrameTestHelpers::WebViewHelper webViewHelper; |
5558 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 5552 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
5559 | 5553 |
5560 webViewHelper.webView()->resize(WebSize(100, 100)); | 5554 webViewHelper.webView()->resize(WebSize(100, 100)); |
5561 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); | 5555 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); |
5562 | 5556 |
5563 blink::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->com
positor(); | 5557 RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor
(); |
5564 ASSERT_TRUE(compositor->scrollLayer()); | 5558 ASSERT_TRUE(compositor->scrollLayer()); |
5565 | 5559 |
5566 // Verify that the WebLayer is not scrollable initially. | 5560 // Verify that the WebLayer is not scrollable initially. |
5567 blink::GraphicsLayer* scrollLayer = compositor->scrollLayer(); | 5561 GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
5568 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 5562 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
5569 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 5563 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
5570 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | 5564 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); |
5571 | 5565 |
5572 // Call javascript to make the layer scrollable, and verify it. | 5566 // Call javascript to make the layer scrollable, and verify it. |
5573 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); | 5567 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); |
5574 frame->executeScript(WebScriptSource("allowScroll();")); | 5568 frame->executeScript(WebScriptSource("allowScroll();")); |
5575 webViewHelper.webView()->layout(); | 5569 webViewHelper.webView()->layout(); |
5576 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 5570 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
5577 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 5571 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
5578 } | 5572 } |
5579 | 5573 |
5580 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 5574 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. |
5581 TEST_F(WebFrameTest, CurrentHistoryItem) | 5575 TEST_F(WebFrameTest, CurrentHistoryItem) |
5582 { | 5576 { |
5583 registerMockedHttpURLLoad("fixed_layout.html"); | 5577 registerMockedHttpURLLoad("fixed_layout.html"); |
5584 std::string url = m_baseURL + "fixed_layout.html"; | 5578 std::string url = m_baseURL + "fixed_layout.html"; |
5585 | 5579 |
5586 FrameTestHelpers::WebViewHelper webViewHelper; | 5580 FrameTestHelpers::WebViewHelper webViewHelper; |
5587 webViewHelper.initialize(); | 5581 webViewHelper.initialize(); |
5588 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5582 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5589 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); | 5583 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
5590 WebURLRequest request; | 5584 WebURLRequest request; |
5591 request.initialize(); | 5585 request.initialize(); |
5592 request.setURL(toKURL(url)); | 5586 request.setURL(toKURL(url)); |
5593 frame->loadRequest(request); | 5587 frame->loadRequest(request); |
5594 | 5588 |
5595 // Before commit, there is no history item. | 5589 // Before commit, there is no history item. |
5596 EXPECT_FALSE(mainFrameLoader.currentItem()); | 5590 EXPECT_FALSE(mainFrameLoader.currentItem()); |
5597 | 5591 |
5598 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); | 5592 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
5599 | 5593 |
5600 // After commit, there is. | 5594 // After commit, there is. |
5601 blink::HistoryItem* item = mainFrameLoader.currentItem(); | 5595 HistoryItem* item = mainFrameLoader.currentItem(); |
5602 ASSERT_TRUE(item); | 5596 ASSERT_TRUE(item); |
5603 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 5597 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
5604 } | 5598 } |
5605 | 5599 |
5606 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 5600 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
5607 public: | 5601 public: |
5608 FailCreateChildFrame() : m_callCount(0) { } | 5602 FailCreateChildFrame() : m_callCount(0) { } |
5609 | 5603 |
5610 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE | 5604 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE |
5611 { | 5605 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5666 EXPECT_EQ(220, topBottomFixed->offsetHeight()); | 5660 EXPECT_EQ(220, topBottomFixed->offsetHeight()); |
5667 EXPECT_EQ(200, rightFixed->offsetLeft() + rightFixed->offsetWidth()); | 5661 EXPECT_EQ(200, rightFixed->offsetLeft() + rightFixed->offsetWidth()); |
5668 EXPECT_EQ(200, leftRightFixed->offsetWidth()); | 5662 EXPECT_EQ(200, leftRightFixed->offsetWidth()); |
5669 } | 5663 } |
5670 | 5664 |
5671 TEST_F(WebFrameTest, FrameViewSetFrameRect) | 5665 TEST_F(WebFrameTest, FrameViewSetFrameRect) |
5672 { | 5666 { |
5673 FrameTestHelpers::WebViewHelper webViewHelper; | 5667 FrameTestHelpers::WebViewHelper webViewHelper; |
5674 webViewHelper.initializeAndLoad("about:blank"); | 5668 webViewHelper.initializeAndLoad("about:blank"); |
5675 | 5669 |
5676 blink::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->
frameView(); | 5670 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
5677 frameView->setFrameRect(blink::IntRect(0, 0, 200, 200)); | 5671 frameView->setFrameRect(IntRect(0, 0, 200, 200)); |
5678 EXPECT_EQ_RECT(blink::IntRect(0, 0, 200, 200), frameView->frameRect()); | 5672 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect()); |
5679 frameView->setFrameRect(blink::IntRect(100, 100, 200, 200)); | 5673 frameView->setFrameRect(IntRect(100, 100, 200, 200)); |
5680 EXPECT_EQ_RECT(blink::IntRect(100, 100, 200, 200), frameView->frameRect()); | 5674 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect()); |
5681 } | 5675 } |
5682 | 5676 |
5683 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) | 5677 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
5684 { | 5678 { |
5685 FakeCompositingWebViewClient client; | 5679 FakeCompositingWebViewClient client; |
5686 registerMockedHttpURLLoad("fullscreen_div.html"); | 5680 registerMockedHttpURLLoad("fullscreen_div.html"); |
5687 FrameTestHelpers::WebViewHelper webViewHelper; | 5681 FrameTestHelpers::WebViewHelper webViewHelper; |
5688 int viewportWidth = 640; | 5682 int viewportWidth = 640; |
5689 int viewportHeight = 480; | 5683 int viewportHeight = 480; |
5690 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5684 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
5691 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 5685 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
5692 webViewImpl->layout(); | 5686 webViewImpl->layout(); |
5693 | 5687 |
5694 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 5688 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
5695 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); | 5689 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
5696 Element* divFullscreen = document->getElementById("div1"); | 5690 Element* divFullscreen = document->getElementById("div1"); |
5697 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | 5691 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); |
5698 webViewImpl->didEnterFullScreen(); | 5692 webViewImpl->didEnterFullScreen(); |
5699 webViewImpl->layout(); | 5693 webViewImpl->layout(); |
5700 | 5694 |
5701 // Verify that the main frame is not scrollable. | 5695 // Verify that the main frame is not scrollable. |
5702 ASSERT_TRUE(blink::Fullscreen::isFullScreen(*document)); | 5696 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
5703 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 5697 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
5704 ASSERT_FALSE(webScrollLayer->scrollable()); | 5698 ASSERT_FALSE(webScrollLayer->scrollable()); |
5705 | 5699 |
5706 // Verify that the main frame is scrollable upon exiting fullscreen. | 5700 // Verify that the main frame is scrollable upon exiting fullscreen. |
5707 webViewImpl->didExitFullScreen(); | 5701 webViewImpl->didExitFullScreen(); |
5708 webViewImpl->layout(); | 5702 webViewImpl->layout(); |
5709 ASSERT_FALSE(blink::Fullscreen::isFullScreen(*document)); | 5703 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); |
5710 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); | 5704 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
5711 ASSERT_TRUE(webScrollLayer->scrollable()); | 5705 ASSERT_TRUE(webScrollLayer->scrollable()); |
5712 } | 5706 } |
5713 | 5707 |
5714 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) | 5708 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
5715 { | 5709 { |
5716 FakeCompositingWebViewClient client; | 5710 FakeCompositingWebViewClient client; |
5717 registerMockedHttpURLLoad("fullscreen_div.html"); | 5711 registerMockedHttpURLLoad("fullscreen_div.html"); |
5718 FrameTestHelpers::WebViewHelper webViewHelper; | 5712 FrameTestHelpers::WebViewHelper webViewHelper; |
5719 int viewportWidth = 640; | 5713 int viewportWidth = 640; |
5720 int viewportHeight = 480; | 5714 int viewportHeight = 480; |
5721 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5715 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
5722 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 5716 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
5723 webViewImpl->layout(); | 5717 webViewImpl->layout(); |
5724 | 5718 |
5725 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 5719 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
5726 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); | 5720 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
5727 Fullscreen::from(*document).requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest); | 5721 Fullscreen::from(*document).requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest); |
5728 webViewImpl->didEnterFullScreen(); | 5722 webViewImpl->didEnterFullScreen(); |
5729 webViewImpl->layout(); | 5723 webViewImpl->layout(); |
5730 | 5724 |
5731 // Verify that the main frame is still scrollable. | 5725 // Verify that the main frame is still scrollable. |
5732 ASSERT_TRUE(blink::Fullscreen::isFullScreen(*document)); | 5726 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
5733 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 5727 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
5734 ASSERT_TRUE(webScrollLayer->scrollable()); | 5728 ASSERT_TRUE(webScrollLayer->scrollable()); |
5735 } | 5729 } |
5736 | 5730 |
5737 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) | 5731 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) |
5738 { | 5732 { |
5739 registerMockedHttpURLLoad("percent-height-descendants.html"); | 5733 registerMockedHttpURLLoad("percent-height-descendants.html"); |
5740 FrameTestHelpers::WebViewHelper webViewHelper; | 5734 FrameTestHelpers::WebViewHelper webViewHelper; |
5741 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); | 5735 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); |
5742 | 5736 |
5743 WebView* webView = webViewHelper.webView(); | 5737 WebView* webView = webViewHelper.webView(); |
5744 webView->resize(WebSize(800, 800)); | 5738 webView->resize(WebSize(800, 800)); |
5745 webView->layout(); | 5739 webView->layout(); |
5746 | 5740 |
5747 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); | 5741 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); |
5748 blink::RenderBlock* container = blink::toRenderBlock(document->getElementByI
d("container")->renderer()); | 5742 RenderBlock* container = toRenderBlock(document->getElementById("container")
->renderer()); |
5749 blink::RenderBox* percentHeightInAnonymous = blink::toRenderBox(document->ge
tElementById("percent-height-in-anonymous")->renderer()); | 5743 RenderBox* percentHeightInAnonymous = toRenderBox(document->getElementById("
percent-height-in-anonymous")->renderer()); |
5750 blink::RenderBox* percentHeightDirectChild = blink::toRenderBox(document->ge
tElementById("percent-height-direct-child")->renderer()); | 5744 RenderBox* percentHeightDirectChild = toRenderBox(document->getElementById("
percent-height-direct-child")->renderer()); |
5751 | 5745 |
5752 EXPECT_TRUE(blink::RenderBlock::hasPercentHeightDescendant(percentHeightInAn
onymous)); | 5746 EXPECT_TRUE(RenderBlock::hasPercentHeightDescendant(percentHeightInAnonymous
)); |
5753 EXPECT_TRUE(blink::RenderBlock::hasPercentHeightDescendant(percentHeightDire
ctChild)); | 5747 EXPECT_TRUE(RenderBlock::hasPercentHeightDescendant(percentHeightDirectChild
)); |
5754 | 5748 |
5755 ASSERT_TRUE(container->percentHeightDescendants()); | 5749 ASSERT_TRUE(container->percentHeightDescendants()); |
5756 ASSERT_TRUE(container->hasPercentHeightDescendants()); | 5750 ASSERT_TRUE(container->hasPercentHeightDescendants()); |
5757 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); | 5751 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); |
5758 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); | 5752 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); |
5759 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); | 5753 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); |
5760 | 5754 |
5761 blink::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingBlo
ck(); | 5755 RenderBlock* anonymousBlock = percentHeightInAnonymous->containingBlock(); |
5762 EXPECT_TRUE(anonymousBlock->isAnonymous()); | 5756 EXPECT_TRUE(anonymousBlock->isAnonymous()); |
5763 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); | 5757 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); |
5764 } | 5758 } |
5765 | 5759 |
5766 TEST_F(WebFrameTest, HasVisibleContentOnVisibleFrames) | 5760 TEST_F(WebFrameTest, HasVisibleContentOnVisibleFrames) |
5767 { | 5761 { |
5768 registerMockedHttpURLLoad("visible_frames.html"); | 5762 registerMockedHttpURLLoad("visible_frames.html"); |
5769 FrameTestHelpers::WebViewHelper webViewHelper; | 5763 FrameTestHelpers::WebViewHelper webViewHelper; |
5770 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "visi
ble_frames.html"); | 5764 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "visi
ble_frames.html"); |
5771 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { | 5765 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5813 // Check that a reload ignoring cache on a frame will result in the cache | 5807 // Check that a reload ignoring cache on a frame will result in the cache |
5814 // policy of the request being set to ReloadBypassingCache. | 5808 // policy of the request being set to ReloadBypassingCache. |
5815 registerMockedHttpURLLoad("foo.html"); | 5809 registerMockedHttpURLLoad("foo.html"); |
5816 FrameTestHelpers::WebViewHelper webViewHelper; | 5810 FrameTestHelpers::WebViewHelper webViewHelper; |
5817 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 5811 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
5818 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5812 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5819 FrameTestHelpers::reloadFrameIgnoringCache(frame); | 5813 FrameTestHelpers::reloadFrameIgnoringCache(frame); |
5820 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request(
).cachePolicy()); | 5814 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request(
).cachePolicy()); |
5821 } | 5815 } |
5822 | 5816 |
5823 static void nodeImageTestValidation(const blink::IntSize& referenceBitmapSize, b
link::DragImage* dragImage) | 5817 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) |
5824 { | 5818 { |
5825 // Prepare the reference bitmap. | 5819 // Prepare the reference bitmap. |
5826 SkBitmap bitmap; | 5820 SkBitmap bitmap; |
5827 ASSERT_TRUE(bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitm
apSize.height())); | 5821 ASSERT_TRUE(bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitm
apSize.height())); |
5828 SkCanvas canvas(bitmap); | 5822 SkCanvas canvas(bitmap); |
5829 canvas.drawColor(SK_ColorGREEN); | 5823 canvas.drawColor(SK_ColorGREEN); |
5830 | 5824 |
5831 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); | 5825 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); |
5832 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); | 5826 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); |
5833 const SkBitmap& dragBitmap = dragImage->bitmap(); | 5827 const SkBitmap& dragBitmap = dragImage->bitmap(); |
5834 SkAutoLockPixels lockPixel(dragBitmap); | 5828 SkAutoLockPixels lockPixel(dragBitmap); |
5835 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi
ze())); | 5829 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi
ze())); |
5836 } | 5830 } |
5837 | 5831 |
5838 TEST_F(WebFrameTest, NodeImageTestCSSTransform) | 5832 TEST_F(WebFrameTest, NodeImageTestCSSTransform) |
5839 { | 5833 { |
5840 FrameTestHelpers::WebViewHelper webViewHelper; | 5834 FrameTestHelpers::WebViewHelper webViewHelper; |
5841 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-css-transform")); | 5835 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string
("case-css-transform")); |
5842 EXPECT_TRUE(dragImage); | 5836 EXPECT_TRUE(dragImage); |
5843 | 5837 |
5844 nodeImageTestValidation(blink::IntSize(40, 40), dragImage.get()); | 5838 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
5845 } | 5839 } |
5846 | 5840 |
5847 TEST_F(WebFrameTest, NodeImageTestCSS3DTransform) | 5841 TEST_F(WebFrameTest, NodeImageTestCSS3DTransform) |
5848 { | 5842 { |
5849 FrameTestHelpers::WebViewHelper webViewHelper; | 5843 FrameTestHelpers::WebViewHelper webViewHelper; |
5850 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-css-3dtransform")); | 5844 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string
("case-css-3dtransform")); |
5851 EXPECT_TRUE(dragImage); | 5845 EXPECT_TRUE(dragImage); |
5852 | 5846 |
5853 nodeImageTestValidation(blink::IntSize(20, 40), dragImage.get()); | 5847 nodeImageTestValidation(IntSize(20, 40), dragImage.get()); |
5854 } | 5848 } |
5855 | 5849 |
5856 TEST_F(WebFrameTest, NodeImageTestInlineBlock) | 5850 TEST_F(WebFrameTest, NodeImageTestInlineBlock) |
5857 { | 5851 { |
5858 FrameTestHelpers::WebViewHelper webViewHelper; | 5852 FrameTestHelpers::WebViewHelper webViewHelper; |
5859 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-inlineblock")); | 5853 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string
("case-inlineblock")); |
5860 EXPECT_TRUE(dragImage); | 5854 EXPECT_TRUE(dragImage); |
5861 | 5855 |
5862 nodeImageTestValidation(blink::IntSize(40, 40), dragImage.get()); | 5856 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
5863 } | 5857 } |
5864 | 5858 |
5865 TEST_F(WebFrameTest, NodeImageTestFloatLeft) | 5859 TEST_F(WebFrameTest, NodeImageTestFloatLeft) |
5866 { | 5860 { |
5867 FrameTestHelpers::WebViewHelper webViewHelper; | 5861 FrameTestHelpers::WebViewHelper webViewHelper; |
5868 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-float-left-overflow-hidden")); | 5862 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string
("case-float-left-overflow-hidden")); |
5869 EXPECT_TRUE(dragImage); | 5863 EXPECT_TRUE(dragImage); |
5870 | 5864 |
5871 nodeImageTestValidation(blink::IntSize(40, 40), dragImage.get()); | 5865 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); |
5872 } | 5866 } |
5873 | 5867 |
5874 // Crashes on Android: http://crbug.com/403804 | 5868 // Crashes on Android: http://crbug.com/403804 |
5875 #if OS(ANDROID) | 5869 #if OS(ANDROID) |
5876 TEST_F(WebFrameTest, DISABLED_PrintingBasic) | 5870 TEST_F(WebFrameTest, DISABLED_PrintingBasic) |
5877 #else | 5871 #else |
5878 TEST_F(WebFrameTest, PrintingBasic) | 5872 TEST_F(WebFrameTest, PrintingBasic) |
5879 #endif | 5873 #endif |
5880 { | 5874 { |
5881 FrameTestHelpers::WebViewHelper webViewHelper; | 5875 FrameTestHelpers::WebViewHelper webViewHelper; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6068 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 6062 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
6069 std::string content = localFrame->contentAsText(1024).utf8(); | 6063 std::string content = localFrame->contentAsText(1024).utf8(); |
6070 EXPECT_EQ("hello", content); | 6064 EXPECT_EQ("hello", content); |
6071 | 6065 |
6072 // Manually reset to break WebViewHelper's dependency on the stack allocated | 6066 // Manually reset to break WebViewHelper's dependency on the stack allocated |
6073 // TestWebFrameClient. | 6067 // TestWebFrameClient. |
6074 reset(); | 6068 reset(); |
6075 remoteFrame->close(); | 6069 remoteFrame->close(); |
6076 } | 6070 } |
6077 | 6071 |
6078 class MockDocumentThreadableLoaderClient : public blink::DocumentThreadableLoade
rClient { | 6072 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient
{ |
6079 public: | 6073 public: |
6080 MockDocumentThreadableLoaderClient() : m_failed(false) { } | 6074 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
6081 virtual void didFail(const blink::ResourceError&) OVERRIDE { m_failed = true
;} | 6075 virtual void didFail(const ResourceError&) OVERRIDE { m_failed = true;} |
6082 | 6076 |
6083 void reset() { m_failed = false; } | 6077 void reset() { m_failed = false; } |
6084 bool failed() { return m_failed; } | 6078 bool failed() { return m_failed; } |
6085 | 6079 |
6086 bool m_failed; | 6080 bool m_failed; |
6087 }; | 6081 }; |
6088 | 6082 |
6089 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it | 6083 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it |
6090 // requires spin-up of a frame. It may be possible to remove that requirement | 6084 // requires spin-up of a frame. It may be possible to remove that requirement |
6091 // and convert it to a unittest. | 6085 // and convert it to a unittest. |
6092 TEST_F(WebFrameTest, LoaderOriginAccess) | 6086 TEST_F(WebFrameTest, LoaderOriginAccess) |
6093 { | 6087 { |
6094 FrameTestHelpers::WebViewHelper webViewHelper; | 6088 FrameTestHelpers::WebViewHelper webViewHelper; |
6095 webViewHelper.initializeAndLoad("about:blank"); | 6089 webViewHelper.initializeAndLoad("about:blank"); |
6096 | 6090 |
6097 blink::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); | 6091 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); |
6098 | 6092 |
6099 // Cross-origin request. | 6093 // Cross-origin request. |
6100 blink::KURL resourceUrl(blink::ParsedURLString, "chrome://test.pdf"); | 6094 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); |
6101 registerMockedChromeURLLoad("test.pdf"); | 6095 registerMockedChromeURLLoad("test.pdf"); |
6102 | 6096 |
6103 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->
page()->mainFrame()); | 6097 RefPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); |
6104 | 6098 |
6105 MockDocumentThreadableLoaderClient client; | 6099 MockDocumentThreadableLoaderClient client; |
6106 blink::ThreadableLoaderOptions options; | 6100 ThreadableLoaderOptions options; |
6107 | 6101 |
6108 // First try to load the request with regular access. Should fail. | 6102 // First try to load the request with regular access. Should fail. |
6109 options.crossOriginRequestPolicy = blink::UseAccessControl; | 6103 options.crossOriginRequestPolicy = UseAccessControl; |
6110 blink::ResourceLoaderOptions resourceLoaderOptions; | 6104 ResourceLoaderOptions resourceLoaderOptions; |
6111 blink::DocumentThreadableLoader::loadResourceSynchronously( | 6105 DocumentThreadableLoader::loadResourceSynchronously( |
6112 *frame->document(), blink::ResourceRequest(resourceUrl), client, options
, resourceLoaderOptions); | 6106 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); |
6113 EXPECT_TRUE(client.failed()); | 6107 EXPECT_TRUE(client.failed()); |
6114 | 6108 |
6115 client.reset(); | 6109 client.reset(); |
6116 // Try to load the request with cross origin access. Should succeed. | 6110 // Try to load the request with cross origin access. Should succeed. |
6117 options.crossOriginRequestPolicy = blink::AllowCrossOriginRequests; | 6111 options.crossOriginRequestPolicy = AllowCrossOriginRequests; |
6118 blink::DocumentThreadableLoader::loadResourceSynchronously( | 6112 DocumentThreadableLoader::loadResourceSynchronously( |
6119 *frame->document(), blink::ResourceRequest(resourceUrl), client, options
, resourceLoaderOptions); | 6113 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); |
6120 EXPECT_FALSE(client.failed()); | 6114 EXPECT_FALSE(client.failed()); |
6121 } | 6115 } |
6122 | 6116 |
6123 class NavigationTransitionCallbackWebFrameClient : public FrameTestHelpers::Test
WebFrameClient { | 6117 class NavigationTransitionCallbackWebFrameClient : public FrameTestHelpers::Test
WebFrameClient { |
6124 public: | 6118 public: |
6125 NavigationTransitionCallbackWebFrameClient() | 6119 NavigationTransitionCallbackWebFrameClient() |
6126 : m_navigationalDataReceivedCount(0) | 6120 : m_navigationalDataReceivedCount(0) |
6127 , m_provisionalLoadCount(0) | 6121 , m_provisionalLoadCount(0) |
6128 , m_wasLastProvisionalLoadATransition(false) { } | 6122 , m_wasLastProvisionalLoadATransition(false) { } |
6129 | 6123 |
(...skipping 13 matching lines...) Expand all Loading... |
6143 bool wasLastProvisionalLoadATransition() const { return m_wasLastProvisional
LoadATransition; } | 6137 bool wasLastProvisionalLoadATransition() const { return m_wasLastProvisional
LoadATransition; } |
6144 | 6138 |
6145 private: | 6139 private: |
6146 unsigned m_navigationalDataReceivedCount; | 6140 unsigned m_navigationalDataReceivedCount; |
6147 unsigned m_provisionalLoadCount; | 6141 unsigned m_provisionalLoadCount; |
6148 bool m_wasLastProvisionalLoadATransition; | 6142 bool m_wasLastProvisionalLoadATransition; |
6149 }; | 6143 }; |
6150 | 6144 |
6151 TEST_F(WebFrameTest, NavigationTransitionCallbacks) | 6145 TEST_F(WebFrameTest, NavigationTransitionCallbacks) |
6152 { | 6146 { |
6153 blink::RuntimeEnabledFeatures::setNavigationTransitionsEnabled(true); | 6147 RuntimeEnabledFeatures::setNavigationTransitionsEnabled(true); |
6154 FrameTestHelpers::WebViewHelper viewHelper; | 6148 FrameTestHelpers::WebViewHelper viewHelper; |
6155 NavigationTransitionCallbackWebFrameClient frameClient; | 6149 NavigationTransitionCallbackWebFrameClient frameClient; |
6156 WebLocalFrame* localFrame = viewHelper.initialize(true, &frameClient)->mainF
rame()->toWebLocalFrame(); | 6150 WebLocalFrame* localFrame = viewHelper.initialize(true, &frameClient)->mainF
rame()->toWebLocalFrame(); |
6157 | 6151 |
6158 const char* transitionHTMLString = | 6152 const char* transitionHTMLString = |
6159 "<!DOCTYPE html>" | 6153 "<!DOCTYPE html>" |
6160 "<meta name='transition-elements' content='#foo;*'>" | 6154 "<meta name='transition-elements' content='#foo;*'>" |
6161 "<div id='foo'>"; | 6155 "<div id='foo'>"; |
6162 | 6156 |
6163 // Initial document load should not be a transition. | 6157 // Initial document load should not be a transition. |
(...skipping 15 matching lines...) Expand all Loading... |
6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6173 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6180 | 6174 |
6181 // Neither should a page reload. | 6175 // Neither should a page reload. |
6182 localFrame->reload(); | 6176 localFrame->reload(); |
6183 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6177 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6184 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6178 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6185 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6186 } | 6180 } |
6187 | 6181 |
6188 } // namespace | 6182 } // namespace |
OLD | NEW |