| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 #include "web/tests/FrameTestHelpers.h" | 98 #include "web/tests/FrameTestHelpers.h" |
| 99 #include "web/tests/URLTestHelpers.h" | 99 #include "web/tests/URLTestHelpers.h" |
| 100 #include "wtf/Forward.h" | 100 #include "wtf/Forward.h" |
| 101 #include "wtf/dtoa/utils.h" | 101 #include "wtf/dtoa/utils.h" |
| 102 #include <gmock/gmock.h> | 102 #include <gmock/gmock.h> |
| 103 #include <gtest/gtest.h> | 103 #include <gtest/gtest.h> |
| 104 #include <map> | 104 #include <map> |
| 105 #include <v8.h> | 105 #include <v8.h> |
| 106 | 106 |
| 107 using namespace blink; | 107 using namespace blink; |
| 108 using WebCore::Document; | 108 using blink::Document; |
| 109 using WebCore::DocumentMarker; | 109 using blink::DocumentMarker; |
| 110 using WebCore::Element; | 110 using blink::Element; |
| 111 using WebCore::FloatRect; | 111 using blink::FloatRect; |
| 112 using WebCore::HitTestRequest; | 112 using blink::HitTestRequest; |
| 113 using WebCore::Range; | 113 using blink::Range; |
| 114 using blink::URLTestHelpers::toKURL; | 114 using blink::URLTestHelpers::toKURL; |
| 115 using blink::FrameTestHelpers::runPendingTasks; | 115 using blink::FrameTestHelpers::runPendingTasks; |
| 116 | 116 |
| 117 namespace { | 117 namespace { |
| 118 | 118 |
| 119 const int touchPointPadding = 32; | 119 const int touchPointPadding = 32; |
| 120 | 120 |
| 121 #define EXPECT_EQ_RECT(a, b) \ | 121 #define EXPECT_EQ_RECT(a, b) \ |
| 122 EXPECT_EQ(a.x(), b.x()); \ | 122 EXPECT_EQ(a.x(), b.x()); \ |
| 123 EXPECT_EQ(a.y(), b.y()); \ | 123 EXPECT_EQ(a.y(), b.y()); \ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 147 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 147 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void registerMockedChromeURLLoad(const std::string& fileName) | 150 void registerMockedChromeURLLoad(const std::string& fileName) |
| 151 { | 151 { |
| 152 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 152 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) | 155 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) |
| 156 { | 156 { |
| 157 RefPtrWillBeRawPtr<WebCore::StyleSheetContents> styleSheet = WebCore::St
yleSheetContents::create(WebCore::CSSParserContext(WebCore::UASheetMode, 0)); | 157 RefPtrWillBeRawPtr<blink::StyleSheetContents> styleSheet = blink::StyleS
heetContents::create(blink::CSSParserContext(blink::UASheetMode, 0)); |
| 158 styleSheet->parseString(String(WebCore::viewportAndroidCss, sizeof(WebCo
re::viewportAndroidCss))); | 158 styleSheet->parseString(String(blink::viewportAndroidCss, sizeof(blink::
viewportAndroidCss))); |
| 159 OwnPtrWillBeRawPtr<WebCore::RuleSet> ruleSet = WebCore::RuleSet::create(
); | 159 OwnPtrWillBeRawPtr<blink::RuleSet> ruleSet = blink::RuleSet::create(); |
| 160 ruleSet->addRulesFromSheet(styleSheet.get(), WebCore::MediaQueryEvaluato
r("screen")); | 160 ruleSet->addRulesFromSheet(styleSheet.get(), blink::MediaQueryEvaluator(
"screen")); |
| 161 | 161 |
| 162 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); | 162 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); |
| 163 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), WebCore::ViewportStyleResolver::UserAgentOrigin); | 163 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), blink::ViewportStyleResolver::UserAgentOrigin); |
| 164 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 164 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 static void configueCompositingWebView(WebSettings* settings) | 167 static void configueCompositingWebView(WebSettings* settings) |
| 168 { | 168 { |
| 169 settings->setAcceleratedCompositingEnabled(true); | 169 settings->setAcceleratedCompositingEnabled(true); |
| 170 settings->setAcceleratedCompositingForFixedPositionEnabled(true); | 170 settings->setAcceleratedCompositingForFixedPositionEnabled(true); |
| 171 settings->setAcceleratedCompositingForOverflowScrollEnabled(true); | 171 settings->setAcceleratedCompositingForOverflowScrollEnabled(true); |
| 172 settings->setCompositedScrollingForFramesEnabled(true); | 172 settings->setCompositedScrollingForFramesEnabled(true); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) | 175 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) |
| 176 { | 176 { |
| 177 webViewHelper->initializeAndLoad(url, true); | 177 webViewHelper->initializeAndLoad(url, true); |
| 178 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 178 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
| 179 webViewHelper->webView()->resize(WebSize(640, 480)); | 179 webViewHelper->webView()->resize(WebSize(640, 480)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 PassOwnPtr<WebCore::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewH
elper* webViewHelper, const std::string& testcase) | 182 PassOwnPtr<blink::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHel
per* webViewHelper, const std::string& testcase) |
| 183 { | 183 { |
| 184 registerMockedHttpURLLoad("nodeimage.html"); | 184 registerMockedHttpURLLoad("nodeimage.html"); |
| 185 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); | 185 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); |
| 186 webViewHelper->webView()->resize(WebSize(640, 480)); | 186 webViewHelper->webView()->resize(WebSize(640, 480)); |
| 187 webViewHelper->webView()->layout(); | 187 webViewHelper->webView()->layout(); |
| 188 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper->webViewI
mpl()->page()->mainFrame()); | 188 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper->webViewImp
l()->page()->mainFrame()); |
| 189 WebCore::Element* element = frame->document()->getElementById(testcase.c
_str()); | 189 blink::Element* element = frame->document()->getElementById(testcase.c_s
tr()); |
| 190 return frame->nodeImage(*element); | 190 return frame->nodeImage(*element); |
| 191 } | 191 } |
| 192 | 192 |
| 193 std::string m_baseURL; | 193 std::string m_baseURL; |
| 194 std::string m_chromeURL; | 194 std::string m_chromeURL; |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 class UseMockScrollbarSettings { | 197 class UseMockScrollbarSettings { |
| 198 public: | 198 public: |
| 199 UseMockScrollbarSettings() | 199 UseMockScrollbarSettings() |
| 200 { | 200 { |
| 201 WebCore::Settings::setMockScrollbarsEnabled(true); | 201 blink::Settings::setMockScrollbarsEnabled(true); |
| 202 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); | 202 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); |
| 203 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); | 203 EXPECT_TRUE(blink::ScrollbarTheme::theme()->usesOverlayScrollbars()); |
| 204 } | 204 } |
| 205 | 205 |
| 206 ~UseMockScrollbarSettings() | 206 ~UseMockScrollbarSettings() |
| 207 { | 207 { |
| 208 WebCore::Settings::setMockScrollbarsEnabled(false); | 208 blink::Settings::setMockScrollbarsEnabled(false); |
| 209 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); | 209 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); |
| 210 } | 210 } |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 TEST_F(WebFrameTest, ContentText) | 213 TEST_F(WebFrameTest, ContentText) |
| 214 { | 214 { |
| 215 registerMockedHttpURLLoad("iframes_test.html"); | 215 registerMockedHttpURLLoad("iframes_test.html"); |
| 216 registerMockedHttpURLLoad("visible_iframe.html"); | 216 registerMockedHttpURLLoad("visible_iframe.html"); |
| 217 registerMockedHttpURLLoad("invisible_iframe.html"); | 217 registerMockedHttpURLLoad("invisible_iframe.html"); |
| 218 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 218 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
| 219 | 219 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 634 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
| 635 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 635 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
| 636 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 636 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
| 637 } | 637 } |
| 638 | 638 |
| 639 TEST_F(WebFrameTest, PostMessageThenDetach) | 639 TEST_F(WebFrameTest, PostMessageThenDetach) |
| 640 { | 640 { |
| 641 FrameTestHelpers::WebViewHelper webViewHelper; | 641 FrameTestHelpers::WebViewHelper webViewHelper; |
| 642 webViewHelper.initializeAndLoad("about:blank"); | 642 webViewHelper.initializeAndLoad("about:blank"); |
| 643 | 643 |
| 644 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()
->page()->mainFrame()); | 644 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->
page()->mainFrame()); |
| 645 WebCore::NonThrowableExceptionState exceptionState; | 645 blink::NonThrowableExceptionState exceptionState; |
| 646 frame->domWindow()->postMessage(WebCore::SerializedScriptValue::create("mess
age"), 0, "*", frame->domWindow(), exceptionState); | 646 frame->domWindow()->postMessage(blink::SerializedScriptValue::create("messag
e"), 0, "*", frame->domWindow(), exceptionState); |
| 647 webViewHelper.reset(); | 647 webViewHelper.reset(); |
| 648 EXPECT_FALSE(exceptionState.hadException()); | 648 EXPECT_FALSE(exceptionState.hadException()); |
| 649 | 649 |
| 650 // Success is not crashing. | 650 // Success is not crashing. |
| 651 runPendingTasks(); | 651 runPendingTasks(); |
| 652 } | 652 } |
| 653 | 653 |
| 654 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 654 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
| 655 public: | 655 public: |
| 656 virtual WebScreenInfo screenInfo() OVERRIDE { return m_screenInfo; } | 656 virtual WebScreenInfo screenInfo() OVERRIDE { return m_screenInfo; } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 676 int viewportWidth = 640; | 676 int viewportWidth = 640; |
| 677 int viewportHeight = 480; | 677 int viewportHeight = 480; |
| 678 | 678 |
| 679 // 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 |
| 680 // only becomes available after the load begins. | 680 // only becomes available after the load begins. |
| 681 FrameTestHelpers::WebViewHelper webViewHelper; | 681 FrameTestHelpers::WebViewHelper webViewHelper; |
| 682 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); |
| 683 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 683 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 684 webViewHelper.webView()->layout(); | 684 webViewHelper.webView()->layout(); |
| 685 | 685 |
| 686 webViewHelper.webViewImpl()->setFixedLayoutSize(WebCore::IntSize(100, 100)); | 686 webViewHelper.webViewImpl()->setFixedLayoutSize(blink::IntSize(100, 100)); |
| 687 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); | 687 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); |
| 688 | 688 |
| 689 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie
w()->layoutCount(); | 689 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie
w()->layoutCount(); |
| 690 webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebC
ore::IntRect(0, 0, 641, 481)); | 690 webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(blin
k::IntRect(0, 0, 641, 481)); |
| 691 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView()->layoutCount()); | 691 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView()->layoutCount()); |
| 692 | 692 |
| 693 webViewHelper.webViewImpl()->layout(); | 693 webViewHelper.webViewImpl()->layout(); |
| 694 } | 694 } |
| 695 | 695 |
| 696 // 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. |
| 697 static bool checkOrSetTextAutosizingMultiplier(Document* document, float multipl
ier, bool setMultiplier) | 697 static bool checkOrSetTextAutosizingMultiplier(Document* document, float multipl
ier, bool setMultiplier) |
| 698 { | 698 { |
| 699 bool multiplierCheckedOrSetAtLeastOnce = false; | 699 bool multiplierCheckedOrSetAtLeastOnce = false; |
| 700 for (WebCore::RenderObject* renderer = document->renderView(); renderer; ren
derer = renderer->nextInPreOrder()) { | 700 for (blink::RenderObject* renderer = document->renderView(); renderer; rende
rer = renderer->nextInPreOrder()) { |
| 701 if (renderer->style()) { | 701 if (renderer->style()) { |
| 702 if (setMultiplier) | 702 if (setMultiplier) |
| 703 renderer->style()->setTextAutosizingMultiplier(multiplier); | 703 renderer->style()->setTextAutosizingMultiplier(multiplier); |
| 704 EXPECT_EQ(multiplier, renderer->style()->textAutosizingMultiplier())
; | 704 EXPECT_EQ(multiplier, renderer->style()->textAutosizingMultiplier())
; |
| 705 multiplierCheckedOrSetAtLeastOnce = true; | 705 multiplierCheckedOrSetAtLeastOnce = true; |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 return multiplierCheckedOrSetAtLeastOnce; | 708 return multiplierCheckedOrSetAtLeastOnce; |
| 709 | 709 |
| 710 } | 710 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 724 UseMockScrollbarSettings mockScrollbarSettings; | 724 UseMockScrollbarSettings mockScrollbarSettings; |
| 725 registerMockedHttpURLLoad("fixed_layout.html"); | 725 registerMockedHttpURLLoad("fixed_layout.html"); |
| 726 | 726 |
| 727 FixedLayoutTestWebViewClient client; | 727 FixedLayoutTestWebViewClient client; |
| 728 int viewportWidth = 640; | 728 int viewportWidth = 640; |
| 729 int viewportHeight = 480; | 729 int viewportHeight = 480; |
| 730 | 730 |
| 731 FrameTestHelpers::WebViewHelper webViewHelper; | 731 FrameTestHelpers::WebViewHelper webViewHelper; |
| 732 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); |
| 733 | 733 |
| 734 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); | 734 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); |
| 735 document->settings()->setTextAutosizingEnabled(true); | 735 document->settings()->setTextAutosizingEnabled(true); |
| 736 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 736 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
| 737 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 737 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
| 738 webViewHelper.webViewImpl()->layout(); | 738 webViewHelper.webViewImpl()->layout(); |
| 739 | 739 |
| 740 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); | 740 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); |
| 741 | 741 |
| 742 WebCore::ViewportDescription description = document->viewportDescription(); | 742 blink::ViewportDescription description = document->viewportDescription(); |
| 743 // 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. |
| 744 description.minWidth = WebCore::Length(100, WebCore::Fixed); | 744 description.minWidth = blink::Length(100, blink::Fixed); |
| 745 description.maxWidth = WebCore::Length(100, WebCore::Fixed); | 745 description.maxWidth = blink::Length(100, blink::Fixed); |
| 746 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); | 746 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); |
| 747 | 747 |
| 748 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); | 748 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); |
| 749 } | 749 } |
| 750 | 750 |
| 751 TEST_F(WebFrameTest, SetFrameRectInvalidatesTextAutosizingMultipliers) | 751 TEST_F(WebFrameTest, SetFrameRectInvalidatesTextAutosizingMultipliers) |
| 752 { | 752 { |
| 753 UseMockScrollbarSettings mockScrollbarSettings; | 753 UseMockScrollbarSettings mockScrollbarSettings; |
| 754 registerMockedHttpURLLoad("iframe_reload.html"); | 754 registerMockedHttpURLLoad("iframe_reload.html"); |
| 755 registerMockedHttpURLLoad("visible_iframe.html"); | 755 registerMockedHttpURLLoad("visible_iframe.html"); |
| 756 | 756 |
| 757 FixedLayoutTestWebViewClient client; | 757 FixedLayoutTestWebViewClient client; |
| 758 int viewportWidth = 640; | 758 int viewportWidth = 640; |
| 759 int viewportHeight = 480; | 759 int viewportHeight = 480; |
| 760 | 760 |
| 761 FrameTestHelpers::WebViewHelper webViewHelper; | 761 FrameTestHelpers::WebViewHelper webViewHelper; |
| 762 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); | 762 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); |
| 763 | 763 |
| 764 WebCore::LocalFrame* mainFrame = toLocalFrame(webViewHelper.webViewImpl()->p
age()->mainFrame()); | 764 blink::LocalFrame* mainFrame = toLocalFrame(webViewHelper.webViewImpl()->pag
e()->mainFrame()); |
| 765 WebCore::Document* document = mainFrame->document(); | 765 blink::Document* document = mainFrame->document(); |
| 766 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 766 blink::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->
frameView(); |
| 767 document->settings()->setTextAutosizingEnabled(true); | 767 document->settings()->setTextAutosizingEnabled(true); |
| 768 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 768 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
| 769 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 769 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
| 770 webViewHelper.webViewImpl()->layout(); | 770 webViewHelper.webViewImpl()->layout(); |
| 771 | 771 |
| 772 for (WebCore::Frame* frame = mainFrame; frame; frame = frame->tree().travers
eNext()) { | 772 for (blink::Frame* frame = mainFrame; frame; frame = frame->tree().traverseN
ext()) { |
| 773 if (!frame->isLocalFrame()) | 773 if (!frame->isLocalFrame()) |
| 774 continue; | 774 continue; |
| 775 EXPECT_TRUE(setTextAutosizingMultiplier(toLocalFrame(frame)->document(),
2)); | 775 EXPECT_TRUE(setTextAutosizingMultiplier(toLocalFrame(frame)->document(),
2)); |
| 776 for (WebCore::RenderObject* renderer = toLocalFrame(frame)->document()->
renderView(); renderer; renderer = renderer->nextInPreOrder()) { | 776 for (blink::RenderObject* renderer = toLocalFrame(frame)->document()->re
nderView(); renderer; renderer = renderer->nextInPreOrder()) { |
| 777 if (renderer->isText()) | 777 if (renderer->isText()) |
| 778 EXPECT_FALSE(renderer->needsLayout()); | 778 EXPECT_FALSE(renderer->needsLayout()); |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 | 781 |
| 782 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); | 782 frameView->setFrameRect(blink::IntRect(0, 0, 200, 200)); |
| 783 for (WebCore::Frame* frame = mainFrame; frame; frame = frame->tree().travers
eNext()) { | 783 for (blink::Frame* frame = mainFrame; frame; frame = frame->tree().traverseN
ext()) { |
| 784 if (!frame->isLocalFrame()) | 784 if (!frame->isLocalFrame()) |
| 785 continue; | 785 continue; |
| 786 for (WebCore::RenderObject* renderer = toLocalFrame(frame)->document()->
renderView(); renderer; renderer = renderer->nextInPreOrder()) { | 786 for (blink::RenderObject* renderer = toLocalFrame(frame)->document()->re
nderView(); renderer; renderer = renderer->nextInPreOrder()) { |
| 787 if (renderer->isText()) | 787 if (renderer->isText()) |
| 788 EXPECT_TRUE(renderer->needsLayout()); | 788 EXPECT_TRUE(renderer->needsLayout()); |
| 789 } | 789 } |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 | 792 |
| 793 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) | 793 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) |
| 794 { | 794 { |
| 795 UseMockScrollbarSettings mockScrollbarSettings; | 795 UseMockScrollbarSettings mockScrollbarSettings; |
| 796 registerMockedHttpURLLoad("fixed_layout.html"); | 796 registerMockedHttpURLLoad("fixed_layout.html"); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 client.m_screenInfo.deviceScaleFactor = 1; | 1043 client.m_screenInfo.deviceScaleFactor = 1; |
| 1044 int viewportWidth = 640; | 1044 int viewportWidth = 640; |
| 1045 int viewportHeight = 480; | 1045 int viewportHeight = 480; |
| 1046 | 1046 |
| 1047 FrameTestHelpers::WebViewHelper webViewHelper; | 1047 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1048 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); |
| 1049 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1049 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1050 | 1050 |
| 1051 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); | 1051 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); |
| 1052 | 1052 |
| 1053 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); | 1053 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); |
| 1054 WebCore::ViewportDescription description = document->viewportDescription(); | 1054 blink::ViewportDescription description = document->viewportDescription(); |
| 1055 description.zoom = 2; | 1055 description.zoom = 2; |
| 1056 document->setViewportDescription(description); | 1056 document->setViewportDescription(description); |
| 1057 webViewHelper.webView()->layout(); | 1057 webViewHelper.webView()->layout(); |
| 1058 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); | 1058 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) | 1061 TEST_F(WebFrameTest, setLoadWithOverviewModeToFalse) |
| 1062 { | 1062 { |
| 1063 UseMockScrollbarSettings mockScrollbarSettings; | 1063 UseMockScrollbarSettings mockScrollbarSettings; |
| 1064 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1064 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 | 1446 |
| 1447 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); | 1447 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); |
| 1448 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1448 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1449 | 1449 |
| 1450 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1450 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
| 1451 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1451 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
| 1452 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1452 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
| 1453 | 1453 |
| 1454 // The magic number to snap to device-width is 320, so test that 321 is | 1454 // The magic number to snap to device-width is 320, so test that 321 is |
| 1455 // respected. | 1455 // respected. |
| 1456 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); | 1456 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); |
| 1457 WebCore::ViewportDescription description = document->viewportDescription(); | 1457 blink::ViewportDescription description = document->viewportDescription(); |
| 1458 description.minWidth = WebCore::Length(321, WebCore::Fixed); | 1458 description.minWidth = blink::Length(321, blink::Fixed); |
| 1459 description.maxWidth = WebCore::Length(321, WebCore::Fixed); | 1459 description.maxWidth = blink::Length(321, blink::Fixed); |
| 1460 document->setViewportDescription(description); | 1460 document->setViewportDescription(description); |
| 1461 webViewHelper.webView()->layout(); | 1461 webViewHelper.webView()->layout(); |
| 1462 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1462 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
| 1463 | 1463 |
| 1464 description.minWidth = WebCore::Length(320, WebCore::Fixed); | 1464 description.minWidth = blink::Length(320, blink::Fixed); |
| 1465 description.maxWidth = WebCore::Length(320, WebCore::Fixed); | 1465 description.maxWidth = blink::Length(320, blink::Fixed); |
| 1466 document->setViewportDescription(description); | 1466 document->setViewportDescription(description); |
| 1467 webViewHelper.webView()->layout(); | 1467 webViewHelper.webView()->layout(); |
| 1468 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1468 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
| 1469 | 1469 |
| 1470 description = document->viewportDescription(); | 1470 description = document->viewportDescription(); |
| 1471 description.maxHeight = WebCore::Length(1000, WebCore::Fixed); | 1471 description.maxHeight = blink::Length(1000, blink::Fixed); |
| 1472 document->setViewportDescription(description); | 1472 document->setViewportDescription(description); |
| 1473 webViewHelper.webView()->layout(); | 1473 webViewHelper.webView()->layout(); |
| 1474 EXPECT_EQ(1000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l
ayoutSize().height()); | 1474 EXPECT_EQ(1000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l
ayoutSize().height()); |
| 1475 | 1475 |
| 1476 description.maxHeight = WebCore::Length(320, WebCore::Fixed); | 1476 description.maxHeight = blink::Length(320, blink::Fixed); |
| 1477 document->setViewportDescription(description); | 1477 document->setViewportDescription(description); |
| 1478 webViewHelper.webView()->layout(); | 1478 webViewHelper.webView()->layout(); |
| 1479 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1479 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 TEST_F(WebFrameTest, ZeroValuesQuirk) | 1482 TEST_F(WebFrameTest, ZeroValuesQuirk) |
| 1483 { | 1483 { |
| 1484 UseMockScrollbarSettings mockScrollbarSettings; | 1484 UseMockScrollbarSettings mockScrollbarSettings; |
| 1485 registerMockedHttpURLLoad("viewport-zero-values.html"); | 1485 registerMockedHttpURLLoad("viewport-zero-values.html"); |
| 1486 | 1486 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1513 FixedLayoutTestWebViewClient client; | 1513 FixedLayoutTestWebViewClient client; |
| 1514 client.m_screenInfo.deviceScaleFactor = 1; | 1514 client.m_screenInfo.deviceScaleFactor = 1; |
| 1515 int viewportWidth = 640; | 1515 int viewportWidth = 640; |
| 1516 int viewportHeight = 480; | 1516 int viewportHeight = 480; |
| 1517 | 1517 |
| 1518 FrameTestHelpers::WebViewHelper webViewHelper; | 1518 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1519 webViewHelper.initialize(true, 0, &client); | 1519 webViewHelper.initialize(true, 0, &client); |
| 1520 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1520 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
| 1521 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1521 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1522 | 1522 |
| 1523 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 1523 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 1524 EXPECT_FALSE(view->userInputScrollable(WebCore::VerticalScrollbar)); | 1524 EXPECT_FALSE(view->userInputScrollable(blink::VerticalScrollbar)); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) | 1527 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) |
| 1528 { | 1528 { |
| 1529 registerMockedHttpURLLoad("body-overflow-hidden.html"); | 1529 registerMockedHttpURLLoad("body-overflow-hidden.html"); |
| 1530 | 1530 |
| 1531 FixedLayoutTestWebViewClient client; | 1531 FixedLayoutTestWebViewClient client; |
| 1532 client.m_screenInfo.deviceScaleFactor = 1; | 1532 client.m_screenInfo.deviceScaleFactor = 1; |
| 1533 int viewportWidth = 640; | 1533 int viewportWidth = 640; |
| 1534 int viewportHeight = 480; | 1534 int viewportHeight = 480; |
| 1535 | 1535 |
| 1536 FrameTestHelpers::WebViewHelper webViewHelper; | 1536 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1537 webViewHelper.initialize(true, 0, &client); | 1537 webViewHelper.initialize(true, 0, &client); |
| 1538 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t
rue); | 1538 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t
rue); |
| 1539 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1539 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
| 1540 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1540 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1541 | 1541 |
| 1542 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 1542 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 1543 EXPECT_TRUE(view->userInputScrollable(WebCore::VerticalScrollbar)); | 1543 EXPECT_TRUE(view->userInputScrollable(blink::VerticalScrollbar)); |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 TEST_F(WebFrameTest, NonZeroValuesNoQuirk) | 1546 TEST_F(WebFrameTest, NonZeroValuesNoQuirk) |
| 1547 { | 1547 { |
| 1548 UseMockScrollbarSettings mockScrollbarSettings; | 1548 UseMockScrollbarSettings mockScrollbarSettings; |
| 1549 registerMockedHttpURLLoad("viewport-nonzero-values.html"); | 1549 registerMockedHttpURLLoad("viewport-nonzero-values.html"); |
| 1550 | 1550 |
| 1551 FixedLayoutTestWebViewClient client; | 1551 FixedLayoutTestWebViewClient client; |
| 1552 client.m_screenInfo.deviceScaleFactor = 1; | 1552 client.m_screenInfo.deviceScaleFactor = 1; |
| 1553 int viewportWidth = 640; | 1553 int viewportWidth = 640; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 client.m_screenInfo.deviceScaleFactor = 1; | 1663 client.m_screenInfo.deviceScaleFactor = 1; |
| 1664 // Small viewport to ensure there are always scrollbars. | 1664 // Small viewport to ensure there are always scrollbars. |
| 1665 int viewportWidth = 64; | 1665 int viewportWidth = 64; |
| 1666 int viewportHeight = 48; | 1666 int viewportHeight = 48; |
| 1667 | 1667 |
| 1668 FrameTestHelpers::WebViewHelper webViewHelper; | 1668 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1669 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &clie
nt, enableViewportSettings); | 1669 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, 0, &clie
nt, enableViewportSettings); |
| 1670 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1670 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1671 webViewHelper.webView()->layout(); | 1671 webViewHelper.webView()->layout(); |
| 1672 | 1672 |
| 1673 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 1673 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 1674 int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()
->isOverlayScrollbar() ? 0 : 15); | 1674 int viewportWidthMinusScrollbar = viewportWidth - (view->verticalScrollbar()
->isOverlayScrollbar() ? 0 : 15); |
| 1675 int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollb
ar()->isOverlayScrollbar() ? 0 : 15); | 1675 int viewportHeightMinusScrollbar = viewportHeight - (view->horizontalScrollb
ar()->isOverlayScrollbar() ? 0 : 15); |
| 1676 | 1676 |
| 1677 webViewHelper.webView()->setPageScaleFactor(2); | 1677 webViewHelper.webView()->setPageScaleFactor(2); |
| 1678 | 1678 |
| 1679 WebCore::IntSize unscaledSize = view->unscaledVisibleContentSize(WebCore::In
cludeScrollbars); | 1679 blink::IntSize unscaledSize = view->unscaledVisibleContentSize(blink::Includ
eScrollbars); |
| 1680 EXPECT_EQ(viewportWidth, unscaledSize.width()); | 1680 EXPECT_EQ(viewportWidth, unscaledSize.width()); |
| 1681 EXPECT_EQ(viewportHeight, unscaledSize.height()); | 1681 EXPECT_EQ(viewportHeight, unscaledSize.height()); |
| 1682 | 1682 |
| 1683 WebCore::IntSize unscaledSizeMinusScrollbar = view->unscaledVisibleContentSi
ze(WebCore::ExcludeScrollbars); | 1683 blink::IntSize unscaledSizeMinusScrollbar = view->unscaledVisibleContentSize
(blink::ExcludeScrollbars); |
| 1684 EXPECT_EQ(viewportWidthMinusScrollbar, unscaledSizeMinusScrollbar.width()); | 1684 EXPECT_EQ(viewportWidthMinusScrollbar, unscaledSizeMinusScrollbar.width()); |
| 1685 EXPECT_EQ(viewportHeightMinusScrollbar, unscaledSizeMinusScrollbar.height())
; | 1685 EXPECT_EQ(viewportHeightMinusScrollbar, unscaledSizeMinusScrollbar.height())
; |
| 1686 | 1686 |
| 1687 WebCore::IntSize scaledSize = view->visibleContentRect().size(); | 1687 blink::IntSize scaledSize = view->visibleContentRect().size(); |
| 1688 EXPECT_EQ(ceil(viewportWidthMinusScrollbar / 2.0), scaledSize.width()); | 1688 EXPECT_EQ(ceil(viewportWidthMinusScrollbar / 2.0), scaledSize.width()); |
| 1689 EXPECT_EQ(ceil(viewportHeightMinusScrollbar / 2.0), scaledSize.height()); | 1689 EXPECT_EQ(ceil(viewportHeightMinusScrollbar / 2.0), scaledSize.height()); |
| 1690 } | 1690 } |
| 1691 | 1691 |
| 1692 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) | 1692 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform) |
| 1693 { | 1693 { |
| 1694 UseMockScrollbarSettings mockScrollbarSettings; | 1694 UseMockScrollbarSettings mockScrollbarSettings; |
| 1695 registerMockedHttpURLLoad("fixed_layout.html"); | 1695 registerMockedHttpURLLoad("fixed_layout.html"); |
| 1696 | 1696 |
| 1697 FixedLayoutTestWebViewClient client; | 1697 FixedLayoutTestWebViewClient client; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1946 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1947 | 1947 |
| 1948 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); | 1948 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); |
| 1949 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); | 1949 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); |
| 1950 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); | 1950 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); |
| 1951 } | 1951 } |
| 1952 | 1952 |
| 1953 class WebFrameResizeTest : public WebFrameTest { | 1953 class WebFrameResizeTest : public WebFrameTest { |
| 1954 protected: | 1954 protected: |
| 1955 | 1955 |
| 1956 static WebCore::FloatSize computeRelativeOffset(const WebCore::IntPoint& abs
oluteOffset, const WebCore::LayoutRect& rect) | 1956 static blink::FloatSize computeRelativeOffset(const blink::IntPoint& absolut
eOffset, const blink::LayoutRect& rect) |
| 1957 { | 1957 { |
| 1958 WebCore::FloatSize relativeOffset = WebCore::FloatPoint(absoluteOffset)
- rect.location(); | 1958 blink::FloatSize relativeOffset = blink::FloatPoint(absoluteOffset) - re
ct.location(); |
| 1959 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); | 1959 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); |
| 1960 return relativeOffset; | 1960 return relativeOffset; |
| 1961 } | 1961 } |
| 1962 | 1962 |
| 1963 void testResizeYieldsCorrectScrollAndScale(const char* url, | 1963 void testResizeYieldsCorrectScrollAndScale(const char* url, |
| 1964 const float initialPageScaleFacto
r, | 1964 const float initialPageScaleFacto
r, |
| 1965 const WebSize scrollOffset, | 1965 const WebSize scrollOffset, |
| 1966 const WebSize viewportSize, | 1966 const WebSize viewportSize, |
| 1967 const bool shouldScaleRelativeToV
iewportWidth) { | 1967 const bool shouldScaleRelativeToV
iewportWidth) { |
| 1968 UseMockScrollbarSettings mockScrollbarSettings; | 1968 UseMockScrollbarSettings mockScrollbarSettings; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2003 // Generic resize preserves scrollOffset relative to anchor node located | 2003 // Generic resize preserves scrollOffset relative to anchor node located |
| 2004 // the top center of the screen. | 2004 // the top center of the screen. |
| 2005 { | 2005 { |
| 2006 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); | 2006 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); |
| 2007 float pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor
(); | 2007 float pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor
(); |
| 2008 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); | 2008 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); |
| 2009 float expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelati
veToViewportWidth ? aspectRatio : 1); | 2009 float expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelati
veToViewportWidth ? aspectRatio : 1); |
| 2010 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); | 2010 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); |
| 2011 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs
et); | 2011 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs
et); |
| 2012 | 2012 |
| 2013 WebCore::IntPoint anchorPoint = WebCore::IntPoint(scrollOffset) + We
bCore::IntPoint(viewportSize.width / 2, 0); | 2013 blink::IntPoint anchorPoint = blink::IntPoint(scrollOffset) + blink:
:IntPoint(viewportSize.width / 2, 0); |
| 2014 RefPtrWillBeRawPtr<WebCore::Node> anchorNode = webViewHelper.webView
Impl()->mainFrameImpl()->frame()->eventHandler().hitTestResultAtPoint(anchorPoin
t, HitTestRequest::ReadOnly | HitTestRequest::Active).innerNode(); | 2014 RefPtrWillBeRawPtr<blink::Node> anchorNode = webViewHelper.webViewIm
pl()->mainFrameImpl()->frame()->eventHandler().hitTestResultAtPoint(anchorPoint,
HitTestRequest::ReadOnly | HitTestRequest::Active).innerNode(); |
| 2015 ASSERT(anchorNode); | 2015 ASSERT(anchorNode); |
| 2016 | 2016 |
| 2017 pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor(); | 2017 pageScaleFactor = webViewHelper.webViewImpl()->pageScaleFactor(); |
| 2018 const WebCore::FloatSize preResizeRelativeOffset | 2018 const blink::FloatSize preResizeRelativeOffset |
| 2019 = computeRelativeOffset(anchorPoint, anchorNode->boundingBox()); | 2019 = computeRelativeOffset(anchorPoint, anchorNode->boundingBox()); |
| 2020 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); | 2020 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); |
| 2021 WebCore::IntPoint newAnchorPoint = WebCore::IntPoint(webViewHelper.w
ebViewImpl()->mainFrame()->scrollOffset()) + WebCore::IntPoint(viewportSize.heig
ht / 2, 0); | 2021 blink::IntPoint newAnchorPoint = blink::IntPoint(webViewHelper.webVi
ewImpl()->mainFrame()->scrollOffset()) + blink::IntPoint(viewportSize.height / 2
, 0); |
| 2022 const WebCore::FloatSize postResizeRelativeOffset | 2022 const blink::FloatSize postResizeRelativeOffset |
| 2023 = computeRelativeOffset(newAnchorPoint, anchorNode->boundingBox(
)); | 2023 = computeRelativeOffset(newAnchorPoint, anchorNode->boundingBox(
)); |
| 2024 EXPECT_NEAR(preResizeRelativeOffset.width(), postResizeRelativeOffse
t.width(), 0.15f); | 2024 EXPECT_NEAR(preResizeRelativeOffset.width(), postResizeRelativeOffse
t.width(), 0.15f); |
| 2025 expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelativeToVi
ewportWidth ? 1 / aspectRatio : 1); | 2025 expectedPageScaleFactor = pageScaleFactor * (shouldScaleRelativeToVi
ewportWidth ? 1 / aspectRatio : 1); |
| 2026 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); | 2026 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); |
| 2027 } | 2027 } |
| 2028 } | 2028 } |
| 2029 }; | 2029 }; |
| 2030 | 2030 |
| 2031 TEST_F(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice
Width) | 2031 TEST_F(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice
Width) |
| 2032 { | 2032 { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 | 2089 |
| 2090 // Set <1 page scale so that the clip rect should be larger than | 2090 // Set <1 page scale so that the clip rect should be larger than |
| 2091 // the viewport size as passed into resize(). | 2091 // the viewport size as passed into resize(). |
| 2092 webViewHelper.webView()->setPageScaleFactor(0.5); | 2092 webViewHelper.webView()->setPageScaleFactor(0.5); |
| 2093 | 2093 |
| 2094 SkBitmap bitmap; | 2094 SkBitmap bitmap; |
| 2095 ASSERT_TRUE(bitmap.allocN32Pixels(200, 200)); | 2095 ASSERT_TRUE(bitmap.allocN32Pixels(200, 200)); |
| 2096 bitmap.eraseColor(0); | 2096 bitmap.eraseColor(0); |
| 2097 SkCanvas canvas(bitmap); | 2097 SkCanvas canvas(bitmap); |
| 2098 | 2098 |
| 2099 WebCore::GraphicsContext context(&canvas); | 2099 blink::GraphicsContext context(&canvas); |
| 2100 context.setTrackOpaqueRegion(true); | 2100 context.setTrackOpaqueRegion(true); |
| 2101 | 2101 |
| 2102 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()
); | 2102 EXPECT_EQ_RECT(blink::IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); |
| 2103 | 2103 |
| 2104 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 2104 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 2105 WebCore::IntRect paintRect(0, 0, 200, 200); | 2105 blink::IntRect paintRect(0, 0, 200, 200); |
| 2106 view->paint(&context, paintRect); | 2106 view->paint(&context, paintRect); |
| 2107 | 2107 |
| 2108 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient | 2108 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient |
| 2109 // to return a non-null layerTreeView, which is what all our shipping config
urations do, | 2109 // to return a non-null layerTreeView, which is what all our shipping config
urations do, |
| 2110 // so this is just exposing an existing bug. | 2110 // so this is just exposing an existing bug. |
| 2111 // crbug.com/365812 | 2111 // crbug.com/365812 |
| 2112 #ifndef NDEBUG | 2112 #ifndef NDEBUG |
| 2113 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); | 2113 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); |
| 2114 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); | 2114 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); |
| 2115 WebCore::IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewport
HeightMinusScrollbar * 2); | 2115 blink::IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHe
ightMinusScrollbar * 2); |
| 2116 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); | 2116 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); |
| 2117 #endif | 2117 #endif |
| 2118 } | 2118 } |
| 2119 | 2119 |
| 2120 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) | 2120 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) |
| 2121 { | 2121 { |
| 2122 UseMockScrollbarSettings mockScrollbarSettings; | 2122 UseMockScrollbarSettings mockScrollbarSettings; |
| 2123 registerMockedHttpURLLoad("fixed_layout.html"); | 2123 registerMockedHttpURLLoad("fixed_layout.html"); |
| 2124 | 2124 |
| 2125 FixedLayoutTestWebViewClient client; | 2125 FixedLayoutTestWebViewClient client; |
| 2126 client.m_screenInfo.deviceScaleFactor = 1; | 2126 client.m_screenInfo.deviceScaleFactor = 1; |
| 2127 int viewportWidth = 640; | 2127 int viewportWidth = 640; |
| 2128 int viewportHeight = 480; | 2128 int viewportHeight = 480; |
| 2129 | 2129 |
| 2130 FrameTestHelpers::WebViewHelper webViewHelper; | 2130 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2131 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 2131 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
| 2132 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2132 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2133 webViewHelper.webView()->layout(); | 2133 webViewHelper.webView()->layout(); |
| 2134 | 2134 |
| 2135 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 2135 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 2136 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); | 2136 EXPECT_EQ(view->scrollSize(blink::HorizontalScrollbar), view->contentsSize()
.width() - view->visibleContentRect().width()); |
| 2137 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); | 2137 EXPECT_EQ(view->scrollSize(blink::VerticalScrollbar), view->contentsSize().h
eight() - view->visibleContentRect().height()); |
| 2138 | 2138 |
| 2139 webViewHelper.webView()->setPageScaleFactor(10); | 2139 webViewHelper.webView()->setPageScaleFactor(10); |
| 2140 | 2140 |
| 2141 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); | 2141 EXPECT_EQ(view->scrollSize(blink::HorizontalScrollbar), view->contentsSize()
.width() - view->visibleContentRect().width()); |
| 2142 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); | 2142 EXPECT_EQ(view->scrollSize(blink::VerticalScrollbar), view->contentsSize().h
eight() - view->visibleContentRect().height()); |
| 2143 } | 2143 } |
| 2144 | 2144 |
| 2145 TEST_F(WebFrameTest, CanOverrideScaleLimits) | 2145 TEST_F(WebFrameTest, CanOverrideScaleLimits) |
| 2146 { | 2146 { |
| 2147 UseMockScrollbarSettings mockScrollbarSettings; | 2147 UseMockScrollbarSettings mockScrollbarSettings; |
| 2148 | 2148 |
| 2149 registerMockedHttpURLLoad("no_scale_for_you.html"); | 2149 registerMockedHttpURLLoad("no_scale_for_you.html"); |
| 2150 | 2150 |
| 2151 FixedLayoutTestWebViewClient client; | 2151 FixedLayoutTestWebViewClient client; |
| 2152 client.m_screenInfo.deviceScaleFactor = 1; | 2152 client.m_screenInfo.deviceScaleFactor = 1; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2183 int viewHeight = 500; | 2183 int viewHeight = 500; |
| 2184 | 2184 |
| 2185 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 2185 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
| 2186 FrameTestHelpers::WebViewHelper webViewHelper; | 2186 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2187 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 2187 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
| 2188 | 2188 |
| 2189 webViewHelper.webView()->setPageScaleFactorLimits(1, 1); | 2189 webViewHelper.webView()->setPageScaleFactorLimits(1, 1); |
| 2190 webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); | 2190 webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); |
| 2191 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); | 2191 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); |
| 2192 | 2192 |
| 2193 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 2193 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 2194 EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar())
; | 2194 EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar())
; |
| 2195 EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2195 EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
| 2196 | 2196 |
| 2197 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); | 2197 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); |
| 2198 webViewHelper.webView()->layout(); | 2198 webViewHelper.webView()->layout(); |
| 2199 EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()
); | 2199 EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()
); |
| 2200 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2200 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
| 2201 } | 2201 } |
| 2202 | 2202 |
| 2203 void setScaleAndScrollAndLayout(blink::WebView* webView, WebPoint scroll, float
scale) | 2203 void setScaleAndScrollAndLayout(blink::WebView* webView, WebPoint scroll, float
scale) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2261 EXPECT_NEAR(tallDiv.y, scroll.y, 20); | 2261 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
| 2262 | 2262 |
| 2263 // Test for Non-doubletap scaling | 2263 // Test for Non-doubletap scaling |
| 2264 // Test zooming into div. | 2264 // Test zooming into div. |
| 2265 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); | 2265 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2266 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 2266 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 2267 } | 2267 } |
| 2268 | 2268 |
| 2269 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2269 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
| 2270 { | 2270 { |
| 2271 WebCore::IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPosi
tionForTesting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 2271 blink::IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositi
onForTesting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 2272 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | 2272 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
| 2273 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); | 2273 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); |
| 2274 scale = webViewImpl->pageScaleFactor(); | 2274 scale = webViewImpl->pageScaleFactor(); |
| 2275 } | 2275 } |
| 2276 | 2276 |
| 2277 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) | 2277 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) |
| 2278 { | 2278 { |
| 2279 if (webViewImpl->zoomToMultipleTargetsRect(rect)) | 2279 if (webViewImpl->zoomToMultipleTargetsRect(rect)) |
| 2280 simulatePageScale(webViewImpl, scale); | 2280 simulatePageScale(webViewImpl, scale); |
| 2281 } | 2281 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2595 // Test scrolling the focused node | 2595 // Test scrolling the focused node |
| 2596 // The edit box is shorter and narrower than the viewport when legible. | 2596 // The edit box is shorter and narrower than the viewport when legible. |
| 2597 webViewHelper.webView()->advanceFocus(false); | 2597 webViewHelper.webView()->advanceFocus(false); |
| 2598 // Set the caret to the end of the input box. | 2598 // Set the caret to the end of the input box. |
| 2599 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); | 2599 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); |
| 2600 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); | 2600 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); |
| 2601 WebRect rect, caret; | 2601 WebRect rect, caret; |
| 2602 webViewHelper.webViewImpl()->selectionBounds(caret, rect); | 2602 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 2603 | 2603 |
| 2604 float scale; | 2604 float scale; |
| 2605 WebCore::IntPoint scroll; | 2605 blink::IntPoint scroll; |
| 2606 bool needAnimation; | 2606 bool needAnimation; |
| 2607 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2607 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2608 EXPECT_TRUE(needAnimation); | 2608 EXPECT_TRUE(needAnimation); |
| 2609 // The edit box should be left aligned with a margin for possible label. | 2609 // The edit box should be left aligned with a margin for possible label. |
| 2610 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; | 2610 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; |
| 2611 EXPECT_NEAR(hScroll, scroll.x(), 1); | 2611 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2612 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; | 2612 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
| 2613 EXPECT_NEAR(vScroll, scroll.y(), 1); | 2613 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2614 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2614 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| 2615 | 2615 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2667 FrameTestHelpers::WebViewHelper webViewHelper; | 2667 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2668 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); | 2668 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); |
| 2669 | 2669 |
| 2670 webViewHelper.webView()->mainFrame()->reload(true); | 2670 webViewHelper.webView()->mainFrame()->reload(true); |
| 2671 // start another reload before request is delivered. | 2671 // start another reload before request is delivered. |
| 2672 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); | 2672 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
| 2673 } | 2673 } |
| 2674 | 2674 |
| 2675 class ReloadWithOverrideURLTask : public WebThread::Task { | 2675 class ReloadWithOverrideURLTask : public WebThread::Task { |
| 2676 public: | 2676 public: |
| 2677 ReloadWithOverrideURLTask(WebFrame* frame, const WebCore::KURL& url, bool ig
noreCache) | 2677 ReloadWithOverrideURLTask(WebFrame* frame, const blink::KURL& url, bool igno
reCache) |
| 2678 : m_frame(frame), m_url(url), m_ignoreCache(ignoreCache) | 2678 : m_frame(frame), m_url(url), m_ignoreCache(ignoreCache) |
| 2679 { | 2679 { |
| 2680 } | 2680 } |
| 2681 | 2681 |
| 2682 virtual void run() OVERRIDE | 2682 virtual void run() OVERRIDE |
| 2683 { | 2683 { |
| 2684 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); | 2684 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); |
| 2685 } | 2685 } |
| 2686 | 2686 |
| 2687 private: | 2687 private: |
| 2688 WebFrame* const m_frame; | 2688 WebFrame* const m_frame; |
| 2689 const WebCore::KURL m_url; | 2689 const blink::KURL m_url; |
| 2690 const bool m_ignoreCache; | 2690 const bool m_ignoreCache; |
| 2691 }; | 2691 }; |
| 2692 | 2692 |
| 2693 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) | 2693 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) |
| 2694 { | 2694 { |
| 2695 const std::string firstURL = "find.html"; | 2695 const std::string firstURL = "find.html"; |
| 2696 const std::string secondURL = "form.html"; | 2696 const std::string secondURL = "form.html"; |
| 2697 const std::string thirdURL = "history.html"; | 2697 const std::string thirdURL = "history.html"; |
| 2698 const float pageScaleFactor = 1.1684f; | 2698 const float pageScaleFactor = 1.1684f; |
| 2699 const int pageWidth = 640; | 2699 const int pageWidth = 640; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3045 { | 3045 { |
| 3046 FrameTestHelpers::WebViewHelper webViewHelper; | 3046 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3047 webViewHelper.initializeAndLoad("about:blank", true); | 3047 webViewHelper.initializeAndLoad("about:blank", true); |
| 3048 // We set the size because it impacts line wrapping, which changes the | 3048 // We set the size because it impacts line wrapping, which changes the |
| 3049 // resulting text value. | 3049 // resulting text value. |
| 3050 webViewHelper.webView()->resize(WebSize(640, 480)); | 3050 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3051 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3051 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 3052 | 3052 |
| 3053 // Generate a simple test case. | 3053 // Generate a simple test case. |
| 3054 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 3054 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
| 3055 WebCore::KURL testURL = toKURL("about:blank"); | 3055 blink::KURL testURL = toKURL("about:blank"); |
| 3056 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3056 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
| 3057 | 3057 |
| 3058 // Make sure it comes out OK. | 3058 // Make sure it comes out OK. |
| 3059 const std::string expected("Foo bar\nbaz"); | 3059 const std::string expected("Foo bar\nbaz"); |
| 3060 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3060 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 3061 EXPECT_EQ(expected, text.utf8()); | 3061 EXPECT_EQ(expected, text.utf8()); |
| 3062 | 3062 |
| 3063 // Try reading the same one with clipping of the text. | 3063 // Try reading the same one with clipping of the text. |
| 3064 const int length = 5; | 3064 const int length = 5; |
| 3065 text = frame->contentAsText(length); | 3065 text = frame->contentAsText(length); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3084 } | 3084 } |
| 3085 | 3085 |
| 3086 TEST_F(WebFrameTest, GetFullHtmlOfPage) | 3086 TEST_F(WebFrameTest, GetFullHtmlOfPage) |
| 3087 { | 3087 { |
| 3088 FrameTestHelpers::WebViewHelper webViewHelper; | 3088 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3089 webViewHelper.initializeAndLoad("about:blank", true); | 3089 webViewHelper.initializeAndLoad("about:blank", true); |
| 3090 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3090 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 3091 | 3091 |
| 3092 // Generate a simple test case. | 3092 // Generate a simple test case. |
| 3093 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 3093 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
| 3094 WebCore::KURL testURL = toKURL("about:blank"); | 3094 blink::KURL testURL = toKURL("about:blank"); |
| 3095 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); | 3095 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
| 3096 | 3096 |
| 3097 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3097 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 3098 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3098 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
| 3099 | 3099 |
| 3100 const std::string html = frame->contentAsMarkup().utf8(); | 3100 const std::string html = frame->contentAsMarkup().utf8(); |
| 3101 | 3101 |
| 3102 // Load again with the output html. | 3102 // Load again with the output html. |
| 3103 FrameTestHelpers::loadHTMLString(frame, html, testURL); | 3103 FrameTestHelpers::loadHTMLString(frame, html, testURL); |
| 3104 | 3104 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3326 webViewHelper.webView()->layout(); | 3326 webViewHelper.webView()->layout(); |
| 3327 runPendingTasks(); | 3327 runPendingTasks(); |
| 3328 | 3328 |
| 3329 static const char* kFindString = "result"; | 3329 static const char* kFindString = "result"; |
| 3330 static const int kFindIdentifier = 12345; | 3330 static const int kFindIdentifier = 12345; |
| 3331 | 3331 |
| 3332 WebFindOptions options; | 3332 WebFindOptions options; |
| 3333 WebString searchText = WebString::fromUTF8(kFindString); | 3333 WebString searchText = WebString::fromUTF8(kFindString); |
| 3334 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3334 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3335 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); | 3335 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); |
| 3336 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3336 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); |
| 3337 | 3337 |
| 3338 // Detach the frame before finding. | 3338 // Detach the frame before finding. |
| 3339 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3339 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
| 3340 | 3340 |
| 3341 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3341 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3342 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); | 3342 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); |
| 3343 | 3343 |
| 3344 runPendingTasks(); | 3344 runPendingTasks(); |
| 3345 EXPECT_FALSE(client.findResultsAreReady()); | 3345 EXPECT_FALSE(client.findResultsAreReady()); |
| 3346 | 3346 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3367 webViewHelper.webView()->layout(); | 3367 webViewHelper.webView()->layout(); |
| 3368 runPendingTasks(); | 3368 runPendingTasks(); |
| 3369 | 3369 |
| 3370 static const char* kFindString = "result"; | 3370 static const char* kFindString = "result"; |
| 3371 static const int kFindIdentifier = 12345; | 3371 static const int kFindIdentifier = 12345; |
| 3372 | 3372 |
| 3373 WebFindOptions options; | 3373 WebFindOptions options; |
| 3374 WebString searchText = WebString::fromUTF8(kFindString); | 3374 WebString searchText = WebString::fromUTF8(kFindString); |
| 3375 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3375 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3376 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | 3376 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
| 3377 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3377 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); |
| 3378 | 3378 |
| 3379 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3379 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3380 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3380 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3381 | 3381 |
| 3382 runPendingTasks(); | 3382 runPendingTasks(); |
| 3383 EXPECT_FALSE(client.findResultsAreReady()); | 3383 EXPECT_FALSE(client.findResultsAreReady()); |
| 3384 | 3384 |
| 3385 // Detach the frame between finding and scoping. | 3385 // Detach the frame between finding and scoping. |
| 3386 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3386 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
| 3387 | 3387 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3408 webViewHelper.webView()->layout(); | 3408 webViewHelper.webView()->layout(); |
| 3409 runPendingTasks(); | 3409 runPendingTasks(); |
| 3410 | 3410 |
| 3411 static const char* kFindString = "result"; | 3411 static const char* kFindString = "result"; |
| 3412 static const int kFindIdentifier = 12345; | 3412 static const int kFindIdentifier = 12345; |
| 3413 | 3413 |
| 3414 WebFindOptions options; | 3414 WebFindOptions options; |
| 3415 WebString searchText = WebString::fromUTF8(kFindString); | 3415 WebString searchText = WebString::fromUTF8(kFindString); |
| 3416 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3416 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3417 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | 3417 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
| 3418 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3418 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); |
| 3419 | 3419 |
| 3420 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3420 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3421 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3421 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3422 | 3422 |
| 3423 runPendingTasks(); | 3423 runPendingTasks(); |
| 3424 EXPECT_FALSE(client.findResultsAreReady()); | 3424 EXPECT_FALSE(client.findResultsAreReady()); |
| 3425 | 3425 |
| 3426 mainFrame->resetMatchCount(); | 3426 mainFrame->resetMatchCount(); |
| 3427 | 3427 |
| 3428 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3428 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3487 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3488 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3488 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3489 | 3489 |
| 3490 mainFrame->resetMatchCount(); | 3490 mainFrame->resetMatchCount(); |
| 3491 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3491 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3492 | 3492 |
| 3493 runPendingTasks(); | 3493 runPendingTasks(); |
| 3494 EXPECT_TRUE(client.findResultsAreReady()); | 3494 EXPECT_TRUE(client.findResultsAreReady()); |
| 3495 | 3495 |
| 3496 // Get the tickmarks for the original find request. | 3496 // Get the tickmarks for the original find request. |
| 3497 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 3497 blink::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->
frameView(); |
| 3498 RefPtr<WebCore::Scrollbar> scrollbar = frameView->createScrollbar(WebCore::H
orizontalScrollbar); | 3498 RefPtr<blink::Scrollbar> scrollbar = frameView->createScrollbar(blink::Horiz
ontalScrollbar); |
| 3499 Vector<WebCore::IntRect> originalTickmarks; | 3499 Vector<blink::IntRect> originalTickmarks; |
| 3500 scrollbar->getTickmarks(originalTickmarks); | 3500 scrollbar->getTickmarks(originalTickmarks); |
| 3501 EXPECT_EQ(4u, originalTickmarks.size()); | 3501 EXPECT_EQ(4u, originalTickmarks.size()); |
| 3502 | 3502 |
| 3503 // Override the tickmarks. | 3503 // Override the tickmarks. |
| 3504 Vector<WebCore::IntRect> overridingTickmarksExpected; | 3504 Vector<blink::IntRect> overridingTickmarksExpected; |
| 3505 overridingTickmarksExpected.append(WebCore::IntRect(0, 0, 100, 100)); | 3505 overridingTickmarksExpected.append(blink::IntRect(0, 0, 100, 100)); |
| 3506 overridingTickmarksExpected.append(WebCore::IntRect(0, 20, 100, 100)); | 3506 overridingTickmarksExpected.append(blink::IntRect(0, 20, 100, 100)); |
| 3507 overridingTickmarksExpected.append(WebCore::IntRect(0, 30, 100, 100)); | 3507 overridingTickmarksExpected.append(blink::IntRect(0, 30, 100, 100)); |
| 3508 mainFrame->setTickmarks(overridingTickmarksExpected); | 3508 mainFrame->setTickmarks(overridingTickmarksExpected); |
| 3509 | 3509 |
| 3510 // Check the tickmarks are overriden correctly. | 3510 // Check the tickmarks are overriden correctly. |
| 3511 Vector<WebCore::IntRect> overridingTickmarksActual; | 3511 Vector<blink::IntRect> overridingTickmarksActual; |
| 3512 scrollbar->getTickmarks(overridingTickmarksActual); | 3512 scrollbar->getTickmarks(overridingTickmarksActual); |
| 3513 EXPECT_EQ(overridingTickmarksExpected, overridingTickmarksActual); | 3513 EXPECT_EQ(overridingTickmarksExpected, overridingTickmarksActual); |
| 3514 | 3514 |
| 3515 // Reset the tickmark behavior. | 3515 // Reset the tickmark behavior. |
| 3516 Vector<WebCore::IntRect> resetTickmarks; | 3516 Vector<blink::IntRect> resetTickmarks; |
| 3517 mainFrame->setTickmarks(resetTickmarks); | 3517 mainFrame->setTickmarks(resetTickmarks); |
| 3518 | 3518 |
| 3519 // Check that the original tickmarks are returned | 3519 // Check that the original tickmarks are returned |
| 3520 Vector<WebCore::IntRect> originalTickmarksAfterReset; | 3520 Vector<blink::IntRect> originalTickmarksAfterReset; |
| 3521 scrollbar->getTickmarks(originalTickmarksAfterReset); | 3521 scrollbar->getTickmarks(originalTickmarksAfterReset); |
| 3522 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); | 3522 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); |
| 3523 } | 3523 } |
| 3524 | 3524 |
| 3525 static WebPoint topLeft(const WebRect& rect) | 3525 static WebPoint topLeft(const WebRect& rect) |
| 3526 { | 3526 { |
| 3527 return WebPoint(rect.x, rect.y); | 3527 return WebPoint(rect.x, rect.y); |
| 3528 } | 3528 } |
| 3529 | 3529 |
| 3530 static WebPoint bottomRightMinusOne(const WebRect& rect) | 3530 static WebPoint bottomRightMinusOne(const WebRect& rect) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 | 3754 |
| 3755 // If the selection is editable text, we can't extend it into non-editable t
ext. | 3755 // If the selection is editable text, we can't extend it into non-editable t
ext. |
| 3756 frame->executeScript(WebScriptSource("selectElement('editable_1');")); | 3756 frame->executeScript(WebScriptSource("selectElement('editable_1');")); |
| 3757 EXPECT_EQ("Editable 1.", selectionAsString(frame)); | 3757 EXPECT_EQ("Editable 1.", selectionAsString(frame)); |
| 3758 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightM
inusOne(elementBounds(frame, "footer_1"))); | 3758 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightM
inusOne(elementBounds(frame, "footer_1"))); |
| 3759 // positionForPoint returns the wrong values for contenteditable spans. See | 3759 // positionForPoint returns the wrong values for contenteditable spans. See |
| 3760 // http://crbug.com/238334. | 3760 // http://crbug.com/238334. |
| 3761 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); | 3761 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); |
| 3762 } | 3762 } |
| 3763 | 3763 |
| 3764 static int computeOffset(WebCore::RenderObject* renderer, int x, int y) | 3764 static int computeOffset(blink::RenderObject* renderer, int x, int y) |
| 3765 { | 3765 { |
| 3766 return WebCore::VisiblePosition(renderer->positionForPoint(WebCore::LayoutPo
int(x, y))).deepEquivalent().computeOffsetInContainerNode(); | 3766 return blink::VisiblePosition(renderer->positionForPoint(blink::LayoutPoint(
x, y))).deepEquivalent().computeOffsetInContainerNode(); |
| 3767 } | 3767 } |
| 3768 | 3768 |
| 3769 // positionForPoint returns the wrong values for contenteditable spans. See | 3769 // positionForPoint returns the wrong values for contenteditable spans. See |
| 3770 // http://crbug.com/238334. | 3770 // http://crbug.com/238334. |
| 3771 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) | 3771 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) |
| 3772 { | 3772 { |
| 3773 registerMockedHttpURLLoad("select_range_span_editable.html"); | 3773 registerMockedHttpURLLoad("select_range_span_editable.html"); |
| 3774 FrameTestHelpers::WebViewHelper webViewHelper; | 3774 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3775 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); | 3775 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); |
| 3776 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3776 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3777 WebCore::RenderObject* renderer = mainFrame->frame()->selection().rootEditab
leElement()->renderer(); | 3777 blink::RenderObject* renderer = mainFrame->frame()->selection().rootEditable
Element()->renderer(); |
| 3778 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 3778 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
| 3779 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 3779 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
| 3780 | 3780 |
| 3781 registerMockedHttpURLLoad("select_range_div_editable.html"); | 3781 registerMockedHttpURLLoad("select_range_div_editable.html"); |
| 3782 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); | 3782 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); |
| 3783 mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); | 3783 mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
| 3784 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; | 3784 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; |
| 3785 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 3785 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
| 3786 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 3786 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
| 3787 } | 3787 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3917 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } | 3917 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } |
| 3918 | 3918 |
| 3919 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } | 3919 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } |
| 3920 | 3920 |
| 3921 private: | 3921 private: |
| 3922 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; | 3922 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; |
| 3923 }; | 3923 }; |
| 3924 | 3924 |
| 3925 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) | 3925 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
| 3926 { | 3926 { |
| 3927 WebCore::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); | 3927 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); |
| 3928 | 3928 |
| 3929 registerMockedHttpURLLoad("select_range_basic.html"); | 3929 registerMockedHttpURLLoad("select_range_basic.html"); |
| 3930 registerMockedHttpURLLoad("select_range_scroll.html"); | 3930 registerMockedHttpURLLoad("select_range_scroll.html"); |
| 3931 | 3931 |
| 3932 int viewWidth = 500; | 3932 int viewWidth = 500; |
| 3933 int viewHeight = 500; | 3933 int viewHeight = 500; |
| 3934 | 3934 |
| 3935 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; | 3935 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; |
| 3936 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); | 3936 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); |
| 3937 | 3937 |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4776 } | 4776 } |
| 4777 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } | 4777 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } |
| 4778 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } | 4778 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } |
| 4779 | 4779 |
| 4780 // WebFrameClient: | 4780 // WebFrameClient: |
| 4781 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE | 4781 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE |
| 4782 { | 4782 { |
| 4783 if (frame->parent()) | 4783 if (frame->parent()) |
| 4784 return; | 4784 return; |
| 4785 EXPECT_FALSE(m_didScrollMainFrame); | 4785 EXPECT_FALSE(m_didScrollMainFrame); |
| 4786 WebCore::FrameView* view = toWebLocalFrameImpl(frame)->frameView(); | 4786 blink::FrameView* view = toWebLocalFrameImpl(frame)->frameView(); |
| 4787 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 4787 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect |
| 4788 // which is called from LocalFrame::createView (before the frame is asso
ciated | 4788 // which is called from LocalFrame::createView (before the frame is asso
ciated |
| 4789 // with the the view). | 4789 // with the the view). |
| 4790 if (view) { | 4790 if (view) { |
| 4791 m_didScrollMainFrame = true; | 4791 m_didScrollMainFrame = true; |
| 4792 m_wasProgrammaticScroll = view->inProgrammaticScroll(); | 4792 m_wasProgrammaticScroll = view->inProgrammaticScroll(); |
| 4793 } | 4793 } |
| 4794 } | 4794 } |
| 4795 private: | 4795 private: |
| 4796 bool m_didScrollMainFrame; | 4796 bool m_didScrollMainFrame; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4907 } | 4907 } |
| 4908 }; | 4908 }; |
| 4909 | 4909 |
| 4910 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) | 4910 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) |
| 4911 { | 4911 { |
| 4912 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4912 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 4913 TestNavigationPolicyWebFrameClient client; | 4913 TestNavigationPolicyWebFrameClient client; |
| 4914 FrameTestHelpers::WebViewHelper webViewHelper; | 4914 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4915 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); | 4915 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); |
| 4916 | 4916 |
| 4917 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); | 4917 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); |
| 4918 WebCore::KURL destination = document->url(); | 4918 blink::KURL destination = document->url(); |
| 4919 destination.setFragmentIdentifier("test"); | 4919 destination.setFragmentIdentifier("test"); |
| 4920 | 4920 |
| 4921 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, | 4921 RefPtrWillBeRawPtr<blink::Event> event = blink::MouseEvent::create(blink::Ev
entTypeNames::click, false, false, |
| 4922 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); | 4922 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); |
| 4923 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); | 4923 blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destin
ation)); |
| 4924 frameRequest.setTriggeringEvent(event); | 4924 frameRequest.setTriggeringEvent(event); |
| 4925 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 4925 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
| 4926 } | 4926 } |
| 4927 | 4927 |
| 4928 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { | 4928 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 4929 public: | 4929 public: |
| 4930 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, | 4930 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, |
| 4931 const WebString&, WebNavigationPolicy, bool) OVERRIDE | 4931 const WebString&, WebNavigationPolicy, bool) OVERRIDE |
| 4932 { | 4932 { |
| 4933 EXPECT_TRUE(false); | 4933 EXPECT_TRUE(false); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4956 | 4956 |
| 4957 TEST_F(WebFrameTest, ModifiedClickNewWindow) | 4957 TEST_F(WebFrameTest, ModifiedClickNewWindow) |
| 4958 { | 4958 { |
| 4959 registerMockedHttpURLLoad("ctrl_click.html"); | 4959 registerMockedHttpURLLoad("ctrl_click.html"); |
| 4960 registerMockedHttpURLLoad("hello_world.html"); | 4960 registerMockedHttpURLLoad("hello_world.html"); |
| 4961 TestNewWindowWebViewClient webViewClient; | 4961 TestNewWindowWebViewClient webViewClient; |
| 4962 TestNewWindowWebFrameClient webFrameClient; | 4962 TestNewWindowWebFrameClient webFrameClient; |
| 4963 FrameTestHelpers::WebViewHelper webViewHelper; | 4963 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4964 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); | 4964 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); |
| 4965 | 4965 |
| 4966 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page
()->mainFrame())->document(); | 4966 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()
->mainFrame())->document(); |
| 4967 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); | 4967 blink::KURL destination = toKURL(m_baseURL + "hello_world.html"); |
| 4968 | 4968 |
| 4969 // ctrl+click event | 4969 // ctrl+click event |
| 4970 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, | 4970 RefPtrWillBeRawPtr<blink::Event> event = blink::MouseEvent::create(blink::Ev
entTypeNames::click, false, false, |
| 4971 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); | 4971 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); |
| 4972 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); | 4972 blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destin
ation)); |
| 4973 frameRequest.setTriggeringEvent(event); | 4973 frameRequest.setTriggeringEvent(event); |
| 4974 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 4974 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); |
| 4975 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 4975 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
| 4976 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 4976 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
| 4977 | 4977 |
| 4978 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 4978 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
| 4979 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 4979 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
| 4980 } | 4980 } |
| 4981 | 4981 |
| 4982 TEST_F(WebFrameTest, BackToReload) | 4982 TEST_F(WebFrameTest, BackToReload) |
| 4983 { | 4983 { |
| 4984 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4984 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 4985 FrameTestHelpers::WebViewHelper webViewHelper; | 4985 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4986 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 4986 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
| 4987 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4987 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 4988 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4988 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); |
| 4989 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 4989 RefPtr<blink::HistoryItem> firstItem = mainFrameLoader.currentItem(); |
| 4990 EXPECT_TRUE(firstItem); | 4990 EXPECT_TRUE(firstItem); |
| 4991 | 4991 |
| 4992 registerMockedHttpURLLoad("white-1x1.png"); | 4992 registerMockedHttpURLLoad("white-1x1.png"); |
| 4993 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 4993 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
| 4994 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 4994 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
| 4995 | 4995 |
| 4996 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 4996 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
| 4997 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 4997 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
| 4998 | 4998 |
| 4999 FrameTestHelpers::reloadFrame(frame); | 4999 FrameTestHelpers::reloadFrame(frame); |
| 5000 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5000 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
| 5001 } | 5001 } |
| 5002 | 5002 |
| 5003 TEST_F(WebFrameTest, BackDuringChildFrameReload) | 5003 TEST_F(WebFrameTest, BackDuringChildFrameReload) |
| 5004 { | 5004 { |
| 5005 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 5005 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
| 5006 FrameTestHelpers::WebViewHelper webViewHelper; | 5006 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5007 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 5007 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
| 5008 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 5008 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
| 5009 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 5009 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); |
| 5010 WebFrame* childFrame = mainFrame->firstChild(); | 5010 WebFrame* childFrame = mainFrame->firstChild(); |
| 5011 ASSERT_TRUE(childFrame); | 5011 ASSERT_TRUE(childFrame); |
| 5012 | 5012 |
| 5013 // Start a history navigation, then have a different frame commit a navigati
on. | 5013 // Start a history navigation, then have a different frame commit a navigati
on. |
| 5014 // In this case, reload an about:blank frame, which will commit synchronousl
y. | 5014 // In this case, reload an about:blank frame, which will commit synchronousl
y. |
| 5015 // After the history navigation completes, both the appropriate document url
and | 5015 // After the history navigation completes, both the appropriate document url
and |
| 5016 // the current history item should reflect the history navigation. | 5016 // the current history item should reflect the history navigation. |
| 5017 registerMockedHttpURLLoad("white-1x1.png"); | 5017 registerMockedHttpURLLoad("white-1x1.png"); |
| 5018 WebHistoryItem item; | 5018 WebHistoryItem item; |
| 5019 item.initialize(); | 5019 item.initialize(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5043 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5043 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
| 5044 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 5044 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
| 5045 } | 5045 } |
| 5046 | 5046 |
| 5047 TEST_F(WebFrameTest, LoadHistoryItemReload) | 5047 TEST_F(WebFrameTest, LoadHistoryItemReload) |
| 5048 { | 5048 { |
| 5049 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5049 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 5050 FrameTestHelpers::WebViewHelper webViewHelper; | 5050 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5051 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5051 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
| 5052 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5052 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5053 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 5053 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); |
| 5054 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5054 RefPtr<blink::HistoryItem> firstItem = mainFrameLoader.currentItem(); |
| 5055 EXPECT_TRUE(firstItem); | 5055 EXPECT_TRUE(firstItem); |
| 5056 | 5056 |
| 5057 registerMockedHttpURLLoad("white-1x1.png"); | 5057 registerMockedHttpURLLoad("white-1x1.png"); |
| 5058 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5058 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
| 5059 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5059 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
| 5060 | 5060 |
| 5061 // Cache policy overrides should take. | 5061 // Cache policy overrides should take. |
| 5062 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); | 5062 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); |
| 5063 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5063 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
| 5064 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5064 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5154 | 5154 |
| 5155 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { | 5155 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { |
| 5156 public: | 5156 public: |
| 5157 TestSameDocumentWebFrameClient() | 5157 TestSameDocumentWebFrameClient() |
| 5158 : m_frameLoadTypeSameSeen(false) | 5158 : m_frameLoadTypeSameSeen(false) |
| 5159 { | 5159 { |
| 5160 } | 5160 } |
| 5161 | 5161 |
| 5162 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) | 5162 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) |
| 5163 { | 5163 { |
| 5164 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == WebCore:
:FrameLoadTypeSame) | 5164 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == blink::F
rameLoadTypeSame) |
| 5165 m_frameLoadTypeSameSeen = true; | 5165 m_frameLoadTypeSameSeen = true; |
| 5166 } | 5166 } |
| 5167 | 5167 |
| 5168 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } | 5168 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } |
| 5169 | 5169 |
| 5170 private: | 5170 private: |
| 5171 bool m_frameLoadTypeSameSeen; | 5171 bool m_frameLoadTypeSameSeen; |
| 5172 }; | 5172 }; |
| 5173 | 5173 |
| 5174 TEST_F(WebFrameTest, NavigateToSame) | 5174 TEST_F(WebFrameTest, NavigateToSame) |
| 5175 { | 5175 { |
| 5176 registerMockedHttpURLLoad("navigate_to_same.html"); | 5176 registerMockedHttpURLLoad("navigate_to_same.html"); |
| 5177 TestSameDocumentWebFrameClient client; | 5177 TestSameDocumentWebFrameClient client; |
| 5178 FrameTestHelpers::WebViewHelper webViewHelper; | 5178 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5179 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); | 5179 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); |
| 5180 EXPECT_FALSE(client.frameLoadTypeSameSeen()); | 5180 EXPECT_FALSE(client.frameLoadTypeSameSeen()); |
| 5181 | 5181 |
| 5182 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(toLocalFr
ame(webViewHelper.webViewImpl()->page()->mainFrame())->document()->url())); | 5182 blink::FrameLoadRequest frameRequest(0, blink::ResourceRequest(toLocalFrame(
webViewHelper.webViewImpl()->page()->mainFrame())->document()->url())); |
| 5183 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 5183 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
| 5184 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 5184 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
| 5185 | 5185 |
| 5186 EXPECT_TRUE(client.frameLoadTypeSameSeen()); | 5186 EXPECT_TRUE(client.frameLoadTypeSameSeen()); |
| 5187 } | 5187 } |
| 5188 | 5188 |
| 5189 TEST_F(WebFrameTest, WebNodeImageContents) | 5189 TEST_F(WebFrameTest, WebNodeImageContents) |
| 5190 { | 5190 { |
| 5191 FrameTestHelpers::WebViewHelper webViewHelper; | 5191 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5192 webViewHelper.initializeAndLoad("about:blank", true); | 5192 webViewHelper.initializeAndLoad("about:blank", true); |
| 5193 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5193 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5194 | 5194 |
| 5195 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; | 5195 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
| 5196 | 5196 |
| 5197 // Load up the image and test that we can extract the contents. | 5197 // Load up the image and test that we can extract the contents. |
| 5198 WebCore::KURL testURL = toKURL("about:blank"); | 5198 blink::KURL testURL = toKURL("about:blank"); |
| 5199 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); | 5199 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); |
| 5200 | 5200 |
| 5201 WebNode node = frame->document().body().firstChild(); | 5201 WebNode node = frame->document().body().firstChild(); |
| 5202 EXPECT_TRUE(node.isElementNode()); | 5202 EXPECT_TRUE(node.isElementNode()); |
| 5203 WebElement element = node.to<WebElement>(); | 5203 WebElement element = node.to<WebElement>(); |
| 5204 WebImage image = element.imageContents(); | 5204 WebImage image = element.imageContents(); |
| 5205 ASSERT_FALSE(image.isNull()); | 5205 ASSERT_FALSE(image.isNull()); |
| 5206 EXPECT_EQ(image.size().width, 10); | 5206 EXPECT_EQ(image.size().width, 10); |
| 5207 EXPECT_EQ(image.size().height, 10); | 5207 EXPECT_EQ(image.size().height, 10); |
| 5208 // FIXME: The rest of this test is disabled since the ImageDecodeCache state
may be inconsistent when this test runs. | 5208 // 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... |
| 5274 private: | 5274 private: |
| 5275 WebHistoryCommitType m_lastCommitType; | 5275 WebHistoryCommitType m_lastCommitType; |
| 5276 }; | 5276 }; |
| 5277 | 5277 |
| 5278 TEST_F(WebFrameTest, SameDocumentHistoryNavigationCommitType) | 5278 TEST_F(WebFrameTest, SameDocumentHistoryNavigationCommitType) |
| 5279 { | 5279 { |
| 5280 registerMockedHttpURLLoad("push_state.html"); | 5280 registerMockedHttpURLLoad("push_state.html"); |
| 5281 TestDidNavigateCommitTypeWebFrameClient client; | 5281 TestDidNavigateCommitTypeWebFrameClient client; |
| 5282 FrameTestHelpers::WebViewHelper webViewHelper; | 5282 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5283 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); | 5283 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); |
| 5284 RefPtr<WebCore::HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFr
ame())->loader().currentItem(); | 5284 RefPtr<blink::HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFram
e())->loader().currentItem(); |
| 5285 runPendingTasks(); | 5285 runPendingTasks(); |
| 5286 | 5286 |
| 5287 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), WebCore::HistorySameDocumentLoad); | 5287 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), blink::HistorySameDocumentLoad); |
| 5288 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 5288 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
| 5289 } | 5289 } |
| 5290 | 5290 |
| 5291 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 5291 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 5292 public: | 5292 public: |
| 5293 TestHistoryWebFrameClient() | 5293 TestHistoryWebFrameClient() |
| 5294 { | 5294 { |
| 5295 m_replacesCurrentHistoryItem = false; | 5295 m_replacesCurrentHistoryItem = false; |
| 5296 m_frame = 0; | 5296 m_frame = 0; |
| 5297 } | 5297 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5363 { | 5363 { |
| 5364 registerMockedHttpURLLoad("non-scrollable.html"); | 5364 registerMockedHttpURLLoad("non-scrollable.html"); |
| 5365 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 5365 TestMainFrameUserOrProgrammaticScrollFrameClient client; |
| 5366 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 5366 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
| 5367 FrameTestHelpers::WebViewHelper webViewHelper; | 5367 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5368 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 5368 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
| 5369 | 5369 |
| 5370 webViewHelper.webView()->resize(WebSize(100, 100)); | 5370 webViewHelper.webView()->resize(WebSize(100, 100)); |
| 5371 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); | 5371 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); |
| 5372 | 5372 |
| 5373 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); | 5373 blink::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->com
positor(); |
| 5374 ASSERT_TRUE(compositor->scrollLayer()); | 5374 ASSERT_TRUE(compositor->scrollLayer()); |
| 5375 | 5375 |
| 5376 // Verify that the WebLayer is not scrollable initially. | 5376 // Verify that the WebLayer is not scrollable initially. |
| 5377 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); | 5377 blink::GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
| 5378 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 5378 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| 5379 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 5379 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
| 5380 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | 5380 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); |
| 5381 | 5381 |
| 5382 // Call javascript to make the layer scrollable, and verify it. | 5382 // Call javascript to make the layer scrollable, and verify it. |
| 5383 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); | 5383 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); |
| 5384 frame->executeScript(WebScriptSource("allowScroll();")); | 5384 frame->executeScript(WebScriptSource("allowScroll();")); |
| 5385 webViewHelper.webView()->layout(); | 5385 webViewHelper.webView()->layout(); |
| 5386 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 5386 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
| 5387 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 5387 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| 5388 } | 5388 } |
| 5389 | 5389 |
| 5390 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 5390 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. |
| 5391 TEST_F(WebFrameTest, CurrentHistoryItem) | 5391 TEST_F(WebFrameTest, CurrentHistoryItem) |
| 5392 { | 5392 { |
| 5393 registerMockedHttpURLLoad("fixed_layout.html"); | 5393 registerMockedHttpURLLoad("fixed_layout.html"); |
| 5394 std::string url = m_baseURL + "fixed_layout.html"; | 5394 std::string url = m_baseURL + "fixed_layout.html"; |
| 5395 | 5395 |
| 5396 FrameTestHelpers::WebViewHelper webViewHelper; | 5396 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5397 webViewHelper.initialize(); | 5397 webViewHelper.initialize(); |
| 5398 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5398 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5399 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 5399 const blink::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mai
nFrameImpl()->frame()->loader(); |
| 5400 WebURLRequest request; | 5400 WebURLRequest request; |
| 5401 request.initialize(); | 5401 request.initialize(); |
| 5402 request.setURL(toKURL(url)); | 5402 request.setURL(toKURL(url)); |
| 5403 frame->loadRequest(request); | 5403 frame->loadRequest(request); |
| 5404 | 5404 |
| 5405 // Before commit, there is no history item. | 5405 // Before commit, there is no history item. |
| 5406 EXPECT_FALSE(mainFrameLoader.currentItem()); | 5406 EXPECT_FALSE(mainFrameLoader.currentItem()); |
| 5407 | 5407 |
| 5408 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); | 5408 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
| 5409 | 5409 |
| 5410 // After commit, there is. | 5410 // After commit, there is. |
| 5411 WebCore::HistoryItem* item = mainFrameLoader.currentItem(); | 5411 blink::HistoryItem* item = mainFrameLoader.currentItem(); |
| 5412 ASSERT_TRUE(item); | 5412 ASSERT_TRUE(item); |
| 5413 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 5413 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
| 5414 } | 5414 } |
| 5415 | 5415 |
| 5416 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 5416 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
| 5417 public: | 5417 public: |
| 5418 FailCreateChildFrame() : m_callCount(0) { } | 5418 FailCreateChildFrame() : m_callCount(0) { } |
| 5419 | 5419 |
| 5420 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE | 5420 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE |
| 5421 { | 5421 { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5476 EXPECT_EQ(220, topBottomFixed->offsetHeight()); | 5476 EXPECT_EQ(220, topBottomFixed->offsetHeight()); |
| 5477 EXPECT_EQ(200, rightFixed->offsetLeft() + rightFixed->offsetWidth()); | 5477 EXPECT_EQ(200, rightFixed->offsetLeft() + rightFixed->offsetWidth()); |
| 5478 EXPECT_EQ(200, leftRightFixed->offsetWidth()); | 5478 EXPECT_EQ(200, leftRightFixed->offsetWidth()); |
| 5479 } | 5479 } |
| 5480 | 5480 |
| 5481 TEST_F(WebFrameTest, FrameViewSetFrameRect) | 5481 TEST_F(WebFrameTest, FrameViewSetFrameRect) |
| 5482 { | 5482 { |
| 5483 FrameTestHelpers::WebViewHelper webViewHelper; | 5483 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5484 webViewHelper.initializeAndLoad("about:blank"); | 5484 webViewHelper.initializeAndLoad("about:blank"); |
| 5485 | 5485 |
| 5486 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 5486 blink::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->
frameView(); |
| 5487 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); | 5487 frameView->setFrameRect(blink::IntRect(0, 0, 200, 200)); |
| 5488 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); | 5488 EXPECT_EQ_RECT(blink::IntRect(0, 0, 200, 200), frameView->frameRect()); |
| 5489 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); | 5489 frameView->setFrameRect(blink::IntRect(100, 100, 200, 200)); |
| 5490 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect())
; | 5490 EXPECT_EQ_RECT(blink::IntRect(100, 100, 200, 200), frameView->frameRect()); |
| 5491 } | 5491 } |
| 5492 | 5492 |
| 5493 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) | 5493 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
| 5494 { | 5494 { |
| 5495 FakeCompositingWebViewClient client; | 5495 FakeCompositingWebViewClient client; |
| 5496 registerMockedHttpURLLoad("fullscreen_div.html"); | 5496 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 5497 FrameTestHelpers::WebViewHelper webViewHelper; | 5497 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5498 int viewportWidth = 640; | 5498 int viewportWidth = 640; |
| 5499 int viewportHeight = 480; | 5499 int viewportHeight = 480; |
| 5500 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5500 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
| 5501 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 5501 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 5502 webViewImpl->layout(); | 5502 webViewImpl->layout(); |
| 5503 | 5503 |
| 5504 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 5504 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
| 5505 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 5505 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); |
| 5506 Element* divFullscreen = document->getElementById("div1"); | 5506 Element* divFullscreen = document->getElementById("div1"); |
| 5507 divFullscreen->webkitRequestFullscreen(); | 5507 divFullscreen->webkitRequestFullscreen(); |
| 5508 webViewImpl->willEnterFullScreen(); | 5508 webViewImpl->willEnterFullScreen(); |
| 5509 webViewImpl->didEnterFullScreen(); | 5509 webViewImpl->didEnterFullScreen(); |
| 5510 webViewImpl->layout(); | 5510 webViewImpl->layout(); |
| 5511 | 5511 |
| 5512 // Verify that the main frame is not scrollable. | 5512 // Verify that the main frame is not scrollable. |
| 5513 ASSERT_TRUE(WebCore::FullscreenElementStack::isFullScreen(*document)); | 5513 ASSERT_TRUE(blink::FullscreenElementStack::isFullScreen(*document)); |
| 5514 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 5514 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
| 5515 ASSERT_FALSE(webScrollLayer->scrollable()); | 5515 ASSERT_FALSE(webScrollLayer->scrollable()); |
| 5516 | 5516 |
| 5517 // Verify that the main frame is scrollable upon exiting fullscreen. | 5517 // Verify that the main frame is scrollable upon exiting fullscreen. |
| 5518 webViewImpl->willExitFullScreen(); | 5518 webViewImpl->willExitFullScreen(); |
| 5519 webViewImpl->didExitFullScreen(); | 5519 webViewImpl->didExitFullScreen(); |
| 5520 webViewImpl->layout(); | 5520 webViewImpl->layout(); |
| 5521 ASSERT_FALSE(WebCore::FullscreenElementStack::isFullScreen(*document)); | 5521 ASSERT_FALSE(blink::FullscreenElementStack::isFullScreen(*document)); |
| 5522 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); | 5522 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
| 5523 ASSERT_TRUE(webScrollLayer->scrollable()); | 5523 ASSERT_TRUE(webScrollLayer->scrollable()); |
| 5524 } | 5524 } |
| 5525 | 5525 |
| 5526 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) | 5526 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
| 5527 { | 5527 { |
| 5528 FakeCompositingWebViewClient client; | 5528 FakeCompositingWebViewClient client; |
| 5529 registerMockedHttpURLLoad("fullscreen_div.html"); | 5529 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 5530 FrameTestHelpers::WebViewHelper webViewHelper; | 5530 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5531 int viewportWidth = 640; | 5531 int viewportWidth = 640; |
| 5532 int viewportHeight = 480; | 5532 int viewportHeight = 480; |
| 5533 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5533 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
| 5534 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 5534 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 5535 webViewImpl->layout(); | 5535 webViewImpl->layout(); |
| 5536 | 5536 |
| 5537 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 5537 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
| 5538 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 5538 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); |
| 5539 document->documentElement()->webkitRequestFullscreen(); | 5539 document->documentElement()->webkitRequestFullscreen(); |
| 5540 webViewImpl->willEnterFullScreen(); | 5540 webViewImpl->willEnterFullScreen(); |
| 5541 webViewImpl->didEnterFullScreen(); | 5541 webViewImpl->didEnterFullScreen(); |
| 5542 webViewImpl->layout(); | 5542 webViewImpl->layout(); |
| 5543 | 5543 |
| 5544 // Verify that the main frame is still scrollable. | 5544 // Verify that the main frame is still scrollable. |
| 5545 ASSERT_TRUE(WebCore::FullscreenElementStack::isFullScreen(*document)); | 5545 ASSERT_TRUE(blink::FullscreenElementStack::isFullScreen(*document)); |
| 5546 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 5546 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
| 5547 ASSERT_TRUE(webScrollLayer->scrollable()); | 5547 ASSERT_TRUE(webScrollLayer->scrollable()); |
| 5548 } | 5548 } |
| 5549 | 5549 |
| 5550 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) | 5550 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) |
| 5551 { | 5551 { |
| 5552 registerMockedHttpURLLoad("percent-height-descendants.html"); | 5552 registerMockedHttpURLLoad("percent-height-descendants.html"); |
| 5553 FrameTestHelpers::WebViewHelper webViewHelper; | 5553 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5554 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); | 5554 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); |
| 5555 | 5555 |
| 5556 WebView* webView = webViewHelper.webView(); | 5556 WebView* webView = webViewHelper.webView(); |
| 5557 webView->resize(WebSize(800, 800)); | 5557 webView->resize(WebSize(800, 800)); |
| 5558 webView->layout(); | 5558 webView->layout(); |
| 5559 | 5559 |
| 5560 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); | 5560 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); |
| 5561 WebCore::RenderBlock* container = WebCore::toRenderBlock(document->getElemen
tById("container")->renderer()); | 5561 blink::RenderBlock* container = blink::toRenderBlock(document->getElementByI
d("container")->renderer()); |
| 5562 WebCore::RenderBox* percentHeightInAnonymous = WebCore::toRenderBox(document
->getElementById("percent-height-in-anonymous")->renderer()); | 5562 blink::RenderBox* percentHeightInAnonymous = blink::toRenderBox(document->ge
tElementById("percent-height-in-anonymous")->renderer()); |
| 5563 WebCore::RenderBox* percentHeightDirectChild = WebCore::toRenderBox(document
->getElementById("percent-height-direct-child")->renderer()); | 5563 blink::RenderBox* percentHeightDirectChild = blink::toRenderBox(document->ge
tElementById("percent-height-direct-child")->renderer()); |
| 5564 | 5564 |
| 5565 EXPECT_TRUE(WebCore::RenderBlock::hasPercentHeightDescendant(percentHeightIn
Anonymous)); | 5565 EXPECT_TRUE(blink::RenderBlock::hasPercentHeightDescendant(percentHeightInAn
onymous)); |
| 5566 EXPECT_TRUE(WebCore::RenderBlock::hasPercentHeightDescendant(percentHeightDi
rectChild)); | 5566 EXPECT_TRUE(blink::RenderBlock::hasPercentHeightDescendant(percentHeightDire
ctChild)); |
| 5567 | 5567 |
| 5568 ASSERT_TRUE(container->percentHeightDescendants()); | 5568 ASSERT_TRUE(container->percentHeightDescendants()); |
| 5569 ASSERT_TRUE(container->hasPercentHeightDescendants()); | 5569 ASSERT_TRUE(container->hasPercentHeightDescendants()); |
| 5570 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); | 5570 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); |
| 5571 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); | 5571 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); |
| 5572 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); | 5572 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); |
| 5573 | 5573 |
| 5574 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); | 5574 blink::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingBlo
ck(); |
| 5575 EXPECT_TRUE(anonymousBlock->isAnonymous()); | 5575 EXPECT_TRUE(anonymousBlock->isAnonymous()); |
| 5576 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); | 5576 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); |
| 5577 } | 5577 } |
| 5578 | 5578 |
| 5579 TEST_F(WebFrameTest, HasVisibleContentOnVisibleFrames) | 5579 TEST_F(WebFrameTest, HasVisibleContentOnVisibleFrames) |
| 5580 { | 5580 { |
| 5581 registerMockedHttpURLLoad("visible_frames.html"); | 5581 registerMockedHttpURLLoad("visible_frames.html"); |
| 5582 FrameTestHelpers::WebViewHelper webViewHelper; | 5582 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5583 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "visi
ble_frames.html"); | 5583 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "visi
ble_frames.html"); |
| 5584 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr
ame; frame = frame->traverseNext(false)) { | 5584 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... |
| 5626 // Check that a reload ignoring cache on a frame will result in the cache | 5626 // Check that a reload ignoring cache on a frame will result in the cache |
| 5627 // policy of the request being set to ReloadBypassingCache. | 5627 // policy of the request being set to ReloadBypassingCache. |
| 5628 registerMockedHttpURLLoad("foo.html"); | 5628 registerMockedHttpURLLoad("foo.html"); |
| 5629 FrameTestHelpers::WebViewHelper webViewHelper; | 5629 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5630 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 5630 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
| 5631 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5631 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5632 FrameTestHelpers::reloadFrameIgnoringCache(frame); | 5632 FrameTestHelpers::reloadFrameIgnoringCache(frame); |
| 5633 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request(
).cachePolicy()); | 5633 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request(
).cachePolicy()); |
| 5634 } | 5634 } |
| 5635 | 5635 |
| 5636 static void nodeImageTestValidation(const WebCore::IntSize& referenceBitmapSize,
WebCore::DragImage* dragImage) | 5636 static void nodeImageTestValidation(const blink::IntSize& referenceBitmapSize, b
link::DragImage* dragImage) |
| 5637 { | 5637 { |
| 5638 // Prepare the reference bitmap. | 5638 // Prepare the reference bitmap. |
| 5639 SkBitmap bitmap; | 5639 SkBitmap bitmap; |
| 5640 ASSERT_TRUE(bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitm
apSize.height())); | 5640 ASSERT_TRUE(bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitm
apSize.height())); |
| 5641 SkCanvas canvas(bitmap); | 5641 SkCanvas canvas(bitmap); |
| 5642 canvas.drawColor(SK_ColorGREEN); | 5642 canvas.drawColor(SK_ColorGREEN); |
| 5643 | 5643 |
| 5644 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); | 5644 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); |
| 5645 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); | 5645 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); |
| 5646 const SkBitmap& dragBitmap = dragImage->bitmap(); | 5646 const SkBitmap& dragBitmap = dragImage->bitmap(); |
| 5647 SkAutoLockPixels lockPixel(dragBitmap); | 5647 SkAutoLockPixels lockPixel(dragBitmap); |
| 5648 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi
ze())); | 5648 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi
ze())); |
| 5649 } | 5649 } |
| 5650 | 5650 |
| 5651 TEST_F(WebFrameTest, NodeImageTestCSSTransform) | 5651 TEST_F(WebFrameTest, NodeImageTestCSSTransform) |
| 5652 { | 5652 { |
| 5653 FrameTestHelpers::WebViewHelper webViewHelper; | 5653 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5654 OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-transform")); | 5654 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-css-transform")); |
| 5655 EXPECT_TRUE(dragImage); | 5655 EXPECT_TRUE(dragImage); |
| 5656 | 5656 |
| 5657 nodeImageTestValidation(WebCore::IntSize(40, 40), dragImage.get()); | 5657 nodeImageTestValidation(blink::IntSize(40, 40), dragImage.get()); |
| 5658 } | 5658 } |
| 5659 | 5659 |
| 5660 TEST_F(WebFrameTest, NodeImageTestCSS3DTransform) | 5660 TEST_F(WebFrameTest, NodeImageTestCSS3DTransform) |
| 5661 { | 5661 { |
| 5662 FrameTestHelpers::WebViewHelper webViewHelper; | 5662 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5663 OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-css-3dtransform")); | 5663 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-css-3dtransform")); |
| 5664 EXPECT_TRUE(dragImage); | 5664 EXPECT_TRUE(dragImage); |
| 5665 | 5665 |
| 5666 nodeImageTestValidation(WebCore::IntSize(20, 40), dragImage.get()); | 5666 nodeImageTestValidation(blink::IntSize(20, 40), dragImage.get()); |
| 5667 } | 5667 } |
| 5668 | 5668 |
| 5669 TEST_F(WebFrameTest, NodeImageTestInlineBlock) | 5669 TEST_F(WebFrameTest, NodeImageTestInlineBlock) |
| 5670 { | 5670 { |
| 5671 FrameTestHelpers::WebViewHelper webViewHelper; | 5671 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5672 OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-inlineblock")); | 5672 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-inlineblock")); |
| 5673 EXPECT_TRUE(dragImage); | 5673 EXPECT_TRUE(dragImage); |
| 5674 | 5674 |
| 5675 nodeImageTestValidation(WebCore::IntSize(40, 40), dragImage.get()); | 5675 nodeImageTestValidation(blink::IntSize(40, 40), dragImage.get()); |
| 5676 } | 5676 } |
| 5677 | 5677 |
| 5678 TEST_F(WebFrameTest, NodeImageTestFloatLeft) | 5678 TEST_F(WebFrameTest, NodeImageTestFloatLeft) |
| 5679 { | 5679 { |
| 5680 FrameTestHelpers::WebViewHelper webViewHelper; | 5680 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5681 OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st
d::string("case-float-left-overflow-hidden")); | 5681 OwnPtr<blink::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std:
:string("case-float-left-overflow-hidden")); |
| 5682 EXPECT_TRUE(dragImage); | 5682 EXPECT_TRUE(dragImage); |
| 5683 | 5683 |
| 5684 nodeImageTestValidation(WebCore::IntSize(40, 40), dragImage.get()); | 5684 nodeImageTestValidation(blink::IntSize(40, 40), dragImage.get()); |
| 5685 } | 5685 } |
| 5686 | 5686 |
| 5687 class ThemeColorTestWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ | 5687 class ThemeColorTestWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ |
| 5688 public: | 5688 public: |
| 5689 ThemeColorTestWebFrameClient() | 5689 ThemeColorTestWebFrameClient() |
| 5690 : m_didNotify(false) | 5690 : m_didNotify(false) |
| 5691 { | 5691 { |
| 5692 } | 5692 } |
| 5693 | 5693 |
| 5694 void reset() | 5694 void reset() |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5860 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 5860 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 5861 std::string content = localFrame->contentAsText(1024).utf8(); | 5861 std::string content = localFrame->contentAsText(1024).utf8(); |
| 5862 EXPECT_EQ("hello", content); | 5862 EXPECT_EQ("hello", content); |
| 5863 | 5863 |
| 5864 // Manually reset to break WebViewHelper's dependency on the stack allocated | 5864 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 5865 // TestWebFrameClient. | 5865 // TestWebFrameClient. |
| 5866 reset(); | 5866 reset(); |
| 5867 remoteFrame->close(); | 5867 remoteFrame->close(); |
| 5868 } | 5868 } |
| 5869 | 5869 |
| 5870 class MockDocumentThreadableLoaderClient : public WebCore::DocumentThreadableLoa
derClient { | 5870 class MockDocumentThreadableLoaderClient : public blink::DocumentThreadableLoade
rClient { |
| 5871 public: | 5871 public: |
| 5872 MockDocumentThreadableLoaderClient() : m_failed(false) { } | 5872 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
| 5873 virtual void didFail(const WebCore::ResourceError&) OVERRIDE { m_failed = tr
ue;} | 5873 virtual void didFail(const blink::ResourceError&) OVERRIDE { m_failed = true
;} |
| 5874 | 5874 |
| 5875 void reset() { m_failed = false; } | 5875 void reset() { m_failed = false; } |
| 5876 bool failed() { return m_failed; } | 5876 bool failed() { return m_failed; } |
| 5877 | 5877 |
| 5878 bool m_failed; | 5878 bool m_failed; |
| 5879 }; | 5879 }; |
| 5880 | 5880 |
| 5881 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it | 5881 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it |
| 5882 // requires spin-up of a frame. It may be possible to remove that requirement | 5882 // requires spin-up of a frame. It may be possible to remove that requirement |
| 5883 // and convert it to a unittest. | 5883 // and convert it to a unittest. |
| 5884 TEST_F(WebFrameTest, LoaderOriginAccess) | 5884 TEST_F(WebFrameTest, LoaderOriginAccess) |
| 5885 { | 5885 { |
| 5886 FrameTestHelpers::WebViewHelper webViewHelper; | 5886 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5887 webViewHelper.initializeAndLoad("about:blank"); | 5887 webViewHelper.initializeAndLoad("about:blank"); |
| 5888 | 5888 |
| 5889 WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); | 5889 blink::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); |
| 5890 | 5890 |
| 5891 // Cross-origin request. | 5891 // Cross-origin request. |
| 5892 WebCore::KURL resourceUrl(WebCore::ParsedURLString, "chrome://test.pdf"); | 5892 blink::KURL resourceUrl(blink::ParsedURLString, "chrome://test.pdf"); |
| 5893 registerMockedChromeURLLoad("test.pdf"); | 5893 registerMockedChromeURLLoad("test.pdf"); |
| 5894 | 5894 |
| 5895 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()
->page()->mainFrame()); | 5895 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->
page()->mainFrame()); |
| 5896 | 5896 |
| 5897 MockDocumentThreadableLoaderClient client; | 5897 MockDocumentThreadableLoaderClient client; |
| 5898 WebCore::ThreadableLoaderOptions options; | 5898 blink::ThreadableLoaderOptions options; |
| 5899 | 5899 |
| 5900 // First try to load the request with regular access. Should fail. | 5900 // First try to load the request with regular access. Should fail. |
| 5901 options.crossOriginRequestPolicy = WebCore::UseAccessControl; | 5901 options.crossOriginRequestPolicy = blink::UseAccessControl; |
| 5902 WebCore::ResourceLoaderOptions resourceLoaderOptions; | 5902 blink::ResourceLoaderOptions resourceLoaderOptions; |
| 5903 WebCore::DocumentThreadableLoader::loadResourceSynchronously( | 5903 blink::DocumentThreadableLoader::loadResourceSynchronously( |
| 5904 *frame->document(), WebCore::ResourceRequest(resourceUrl), client, optio
ns, resourceLoaderOptions); | 5904 *frame->document(), blink::ResourceRequest(resourceUrl), client, options
, resourceLoaderOptions); |
| 5905 EXPECT_TRUE(client.failed()); | 5905 EXPECT_TRUE(client.failed()); |
| 5906 | 5906 |
| 5907 client.reset(); | 5907 client.reset(); |
| 5908 // Try to load the request with cross origin access. Should succeed. | 5908 // Try to load the request with cross origin access. Should succeed. |
| 5909 options.crossOriginRequestPolicy = WebCore::AllowCrossOriginRequests; | 5909 options.crossOriginRequestPolicy = blink::AllowCrossOriginRequests; |
| 5910 WebCore::DocumentThreadableLoader::loadResourceSynchronously( | 5910 blink::DocumentThreadableLoader::loadResourceSynchronously( |
| 5911 *frame->document(), WebCore::ResourceRequest(resourceUrl), client, optio
ns, resourceLoaderOptions); | 5911 *frame->document(), blink::ResourceRequest(resourceUrl), client, options
, resourceLoaderOptions); |
| 5912 EXPECT_FALSE(client.failed()); | 5912 EXPECT_FALSE(client.failed()); |
| 5913 } | 5913 } |
| 5914 | 5914 |
| 5915 } // namespace | 5915 } // namespace |
| OLD | NEW |