Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2165573003: Simplify tests by using Web*Impl types directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType )); 217 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType ));
218 } 218 }
219 219
220 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp er) 220 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp er)
221 { 221 {
222 StyleSheetContents* styleSheet = StyleSheetContents::create(CSSParserCon text(UASheetMode, nullptr)); 222 StyleSheetContents* styleSheet = StyleSheetContents::create(CSSParserCon text(UASheetMode, nullptr));
223 styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css") ); 223 styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css") );
224 RuleSet* ruleSet = RuleSet::create(); 224 RuleSet* ruleSet = RuleSet::create();
225 ruleSet->addRulesFromSheet(styleSheet, MediaQueryEvaluator("screen")); 225 ruleSet->addRulesFromSheet(styleSheet, MediaQueryEvaluator("screen"));
226 226
227 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()-> mainFrame())->document(); 227 Document* document = toLocalFrame(webViewHelper->webView()->page()->main Frame())->document();
228 document->ensureStyleResolver().viewportStyleResolver()->collectViewport Rules(ruleSet, ViewportStyleResolver::UserAgentOrigin); 228 document->ensureStyleResolver().viewportStyleResolver()->collectViewport Rules(ruleSet, ViewportStyleResolver::UserAgentOrigin);
229 document->ensureStyleResolver().viewportStyleResolver()->resolve(); 229 document->ensureStyleResolver().viewportStyleResolver()->resolve();
230 } 230 }
231 231
232 static void configueCompositingWebView(WebSettings* settings) 232 static void configueCompositingWebView(WebSettings* settings)
233 { 233 {
234 settings->setAcceleratedCompositingEnabled(true); 234 settings->setAcceleratedCompositingEnabled(true);
235 settings->setPreferCompositingToLCDTextEnabled(true); 235 settings->setPreferCompositingToLCDTextEnabled(true);
236 } 236 }
237 237
(...skipping 15 matching lines...) Expand all
253 webViewHelper->initializeAndLoad(url, true); 253 webViewHelper->initializeAndLoad(url, true);
254 webViewHelper->webView()->settings()->setDefaultFontSize(12); 254 webViewHelper->webView()->settings()->setDefaultFontSize(12);
255 webViewHelper->resize(WebSize(640, 480)); 255 webViewHelper->resize(WebSize(640, 480));
256 } 256 }
257 257
258 std::unique_ptr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelpe r* webViewHelper, const std::string& testcase) 258 std::unique_ptr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelpe r* webViewHelper, const std::string& testcase)
259 { 259 {
260 registerMockedHttpURLLoad("nodeimage.html"); 260 registerMockedHttpURLLoad("nodeimage.html");
261 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); 261 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html");
262 webViewHelper->resize(WebSize(640, 480)); 262 webViewHelper->resize(WebSize(640, 480));
263 LocalFrame* frame = toLocalFrame(webViewHelper->webViewImpl()->page()->m ainFrame()); 263 LocalFrame* frame = toLocalFrame(webViewHelper->webView()->page()->mainF rame());
264 DCHECK(frame); 264 DCHECK(frame);
265 Element* element = frame->document()->getElementById(testcase.c_str()); 265 Element* element = frame->document()->getElementById(testcase.c_str());
266 return frame->nodeImage(*element); 266 return frame->nodeImage(*element);
267 } 267 }
268 268
269 void removeElementById(WebLocalFrameImpl* frame, const AtomicString& id) 269 void removeElementById(WebLocalFrameImpl* frame, const AtomicString& id)
270 { 270 {
271 Element* element = frame->frame()->document()->getElementById(id); 271 Element* element = frame->frame()->document()->getElementById(id);
272 DCHECK(element); 272 DCHECK(element);
273 element->remove(); 273 element->remove();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 registerMockedHttpURLLoad("foo.html"); 372 registerMockedHttpURLLoad("foo.html");
373 registerMockedHttpURLLoad("bar.html"); 373 registerMockedHttpURLLoad("bar.html");
374 374
375 FrameTestHelpers::WebViewHelper webViewHelper(this); 375 FrameTestHelpers::WebViewHelper webViewHelper(this);
376 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); 376 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true);
377 377
378 v8::HandleScope scope(v8::Isolate::GetCurrent()); 378 v8::HandleScope scope(v8::Isolate::GetCurrent());
379 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr ame()->mainWorldScriptContext()); 379 ScriptExecutionCallbackHelper callbackHelper(webViewHelper.webView()->mainFr ame()->mainWorldScriptContext());
380 380
381 // Suspend scheduled tasks so the script doesn't run. 381 // Suspend scheduled tasks so the script doesn't run.
382 toWebLocalFrameImpl(webViewHelper.webView()->mainFrame())->frame()->document ()->suspendScheduledTasks(); 382 webViewHelper.webView()->mainFrameImpl()->frame()->document()->suspendSchedu ledTasks();
383 webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecuteScrip tAndReturnValue(WebScriptSource(WebString("'hello';")), false, &callbackHelper); 383 webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndReturnValue (WebScriptSource(WebString("'hello';")), false, &callbackHelper);
384 runPendingTasks(); 384 runPendingTasks();
385 EXPECT_FALSE(callbackHelper.didComplete()); 385 EXPECT_FALSE(callbackHelper.didComplete());
386 386
387 // If the frame navigates, pending scripts should be removed, but the callba ck should always be ran. 387 // If the frame navigates, pending scripts should be removed, but the callba ck should always be ran.
388 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "bar.html"); 388 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "bar.html");
389 EXPECT_TRUE(callbackHelper.didComplete()); 389 EXPECT_TRUE(callbackHelper.didComplete());
390 EXPECT_EQ(String(), callbackHelper.stringValue()); 390 EXPECT_EQ(String(), callbackHelper.stringValue());
391 } 391 }
392 392
393 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) 393 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf)
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper .webView(), 1024).utf8(); 811 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper .webView(), 1024).utf8();
812 EXPECT_NE(std::string::npos, content.find("Message 1.")); 812 EXPECT_NE(std::string::npos, content.find("Message 1."));
813 EXPECT_EQ(std::string::npos, content.find("Message 2.")); 813 EXPECT_EQ(std::string::npos, content.find("Message 2."));
814 } 814 }
815 815
816 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) 816 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach)
817 { 817 {
818 FrameTestHelpers::WebViewHelper webViewHelper(this); 818 FrameTestHelpers::WebViewHelper webViewHelper(this);
819 webViewHelper.initializeAndLoad("about:blank"); 819 webViewHelper.initializeAndLoad("about:blank");
820 820
821 LocalFrame* frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame()); 821 LocalFrame* frame = toLocalFrame(webViewHelper.webView()->page()->mainFrame( ));
822 NonThrowableExceptionState exceptionState; 822 NonThrowableExceptionState exceptionState;
823 MessagePortArray messagePorts; 823 MessagePortArray messagePorts;
824 frame->domWindow()->postMessage(SerializedScriptValue::serialize("message"), messagePorts, "*", frame->localDOMWindow(), exceptionState); 824 frame->domWindow()->postMessage(SerializedScriptValue::serialize("message"), messagePorts, "*", frame->localDOMWindow(), exceptionState);
825 webViewHelper.reset(); 825 webViewHelper.reset();
826 EXPECT_FALSE(exceptionState.hadException()); 826 EXPECT_FALSE(exceptionState.hadException());
827 827
828 // Success is not crashing. 828 // Success is not crashing.
829 runPendingTasks(); 829 runPendingTasks();
830 } 830 }
831 831
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 { 884 {
885 registerMockedHttpURLLoad("fixed_layout.html"); 885 registerMockedHttpURLLoad("fixed_layout.html");
886 886
887 FixedLayoutTestWebViewClient client; 887 FixedLayoutTestWebViewClient client;
888 int viewportWidth = 640; 888 int viewportWidth = 640;
889 int viewportHeight = 480; 889 int viewportHeight = 480;
890 890
891 FrameTestHelpers::WebViewHelper webViewHelper(this); 891 FrameTestHelpers::WebViewHelper webViewHelper(this);
892 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings); 892 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings);
893 893
894 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 894 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
895 document->settings()->setTextAutosizingEnabled(true); 895 document->settings()->setTextAutosizingEnabled(true);
896 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); 896 EXPECT_TRUE(document->settings()->textAutosizingEnabled());
897 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 897 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
898 898
899 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); 899 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2));
900 900
901 ViewportDescription description = document->viewportDescription(); 901 ViewportDescription description = document->viewportDescription();
902 // Choose a width that's not going match the viewport width of the loaded do cument. 902 // Choose a width that's not going match the viewport width of the loaded do cument.
903 description.minWidth = Length(100, blink::Fixed); 903 description.minWidth = Length(100, blink::Fixed);
904 description.maxWidth = Length(100, blink::Fixed); 904 description.maxWidth = Length(100, blink::Fixed);
905 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio n); 905 webViewHelper.webView()->updatePageDefinedViewportConstraints(description);
906 906
907 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); 907 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1));
908 } 908 }
909 909
910 TEST_P(ParameterizedWebFrameTest, WorkingTextAutosizingMultipliers_VirtualViewpo rt) 910 TEST_P(ParameterizedWebFrameTest, WorkingTextAutosizingMultipliers_VirtualViewpo rt)
911 { 911 {
912 const std::string htmlFile = "fixed_layout.html"; 912 const std::string htmlFile = "fixed_layout.html";
913 registerMockedHttpURLLoad(htmlFile); 913 registerMockedHttpURLLoad(htmlFile);
914 914
915 FixedLayoutTestWebViewClient client; 915 FixedLayoutTestWebViewClient client;
916 916
917 FrameTestHelpers::WebViewHelper webViewHelper(this); 917 FrameTestHelpers::WebViewHelper webViewHelper(this);
918 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client , nullptr, configureAndroid); 918 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client , nullptr, configureAndroid);
919 919
920 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 920 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
921 document->settings()->setTextAutosizingEnabled(true); 921 document->settings()->setTextAutosizingEnabled(true);
922 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); 922 EXPECT_TRUE(document->settings()->textAutosizingEnabled());
923 923
924 webViewHelper.resize(WebSize(490, 800)); 924 webViewHelper.resize(WebSize(490, 800));
925 925
926 // Multiplier: 980 / 490 = 2.0 926 // Multiplier: 980 / 490 = 2.0
927 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 2.0)); 927 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 2.0));
928 } 928 }
929 929
930 TEST_P(ParameterizedWebFrameTest, VisualViewportSetSizeInvalidatesTextAutosizing Multipliers) 930 TEST_P(ParameterizedWebFrameTest, VisualViewportSetSizeInvalidatesTextAutosizing Multipliers)
931 { 931 {
932 registerMockedHttpURLLoad("iframe_reload.html"); 932 registerMockedHttpURLLoad("iframe_reload.html");
933 registerMockedHttpURLLoad("visible_iframe.html"); 933 registerMockedHttpURLLoad("visible_iframe.html");
934 934
935 FixedLayoutTestWebViewClient client; 935 FixedLayoutTestWebViewClient client;
936 int viewportWidth = 640; 936 int viewportWidth = 640;
937 int viewportHeight = 480; 937 int viewportHeight = 480;
938 938
939 FrameTestHelpers::WebViewHelper webViewHelper(this); 939 FrameTestHelpers::WebViewHelper webViewHelper(this);
940 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, null ptr, &client, nullptr, enableViewportSettings); 940 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, null ptr, &client, nullptr, enableViewportSettings);
941 941
942 LocalFrame* mainFrame = toLocalFrame(webViewHelper.webViewImpl()->page()->ma inFrame()); 942 LocalFrame* mainFrame = toLocalFrame(webViewHelper.webView()->page()->mainFr ame());
943 Document* document = mainFrame->document(); 943 Document* document = mainFrame->document();
944 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 944 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView() ;
945 document->settings()->setTextAutosizingEnabled(true); 945 document->settings()->setTextAutosizingEnabled(true);
946 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); 946 EXPECT_TRUE(document->settings()->textAutosizingEnabled());
947 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 947 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
948 948
949 for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext()) { 949 for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext()) {
950 if (!frame->isLocalFrame()) 950 if (!frame->isLocalFrame())
951 continue; 951 continue;
952 EXPECT_TRUE(setTextAutosizingMultiplier(toLocalFrame(frame)->document(), 2)); 952 EXPECT_TRUE(setTextAutosizingMultiplier(toLocalFrame(frame)->document(), 2));
953 for (LayoutItem layoutItem = toLocalFrame(frame)->document()->layoutView Item(); !layoutItem.isNull(); layoutItem = layoutItem.nextInPreOrder()) { 953 for (LayoutItem layoutItem = toLocalFrame(frame)->document()->layoutView Item(); !layoutItem.isNull(); layoutItem = layoutItem.nextInPreOrder()) {
954 if (layoutItem.isText()) 954 if (layoutItem.isText())
(...skipping 17 matching lines...) Expand all
972 { 972 {
973 FixedLayoutTestWebViewClient client; 973 FixedLayoutTestWebViewClient client;
974 client.m_screenInfo.deviceScaleFactor = 1; 974 client.m_screenInfo.deviceScaleFactor = 1;
975 int viewportWidth = 1280; 975 int viewportWidth = 1280;
976 int viewportHeight = 0; 976 int viewportHeight = 0;
977 977
978 FrameTestHelpers::WebViewHelper webViewHelper(this); 978 FrameTestHelpers::WebViewHelper webViewHelper(this);
979 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 979 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
980 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 980 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
981 981
982 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width()); 982 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->layoutSize().width());
983 EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height()); 983 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie w()->layoutSize().height());
984 } 984 }
985 985
986 TEST_P(ParameterizedWebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag ) 986 TEST_P(ParameterizedWebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag )
987 { 987 {
988 registerMockedHttpURLLoad("no_viewport_tag.html"); 988 registerMockedHttpURLLoad("no_viewport_tag.html");
989 989
990 int viewportWidth = 640; 990 int viewportWidth = 640;
991 int viewportHeight = 480; 991 int viewportHeight = 480;
992 992
993 FixedLayoutTestWebViewClient client; 993 FixedLayoutTestWebViewClient client;
994 client.m_screenInfo.deviceScaleFactor = 2; 994 client.m_screenInfo.deviceScaleFactor = 2;
995 995
996 FrameTestHelpers::WebViewHelper webViewHelper(this); 996 FrameTestHelpers::WebViewHelper webViewHelper(this);
997 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu llptr, &client, nullptr, enableViewportSettings); 997 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu llptr, &client, nullptr, enableViewportSettings);
998 998
999 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 999 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1000 1000
1001 EXPECT_EQ(2, webViewHelper.webViewImpl()->page()->deviceScaleFactor()); 1001 EXPECT_EQ(2, webViewHelper.webView()->page()->deviceScaleFactor());
1002 1002
1003 // Device scale factor should be independent of page scale. 1003 // Device scale factor should be independent of page scale.
1004 webViewHelper.webView()->setDefaultPageScaleLimits(1, 2); 1004 webViewHelper.webView()->setDefaultPageScaleLimits(1, 2);
1005 webViewHelper.webView()->setPageScaleFactor(0.5); 1005 webViewHelper.webView()->setPageScaleFactor(0.5);
1006 webViewHelper.webView()->updateAllLifecyclePhases(); 1006 webViewHelper.webView()->updateAllLifecyclePhases();
1007 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); 1007 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor());
1008 1008
1009 // Force the layout to happen before leaving the test. 1009 // Force the layout to happen before leaving the test.
1010 webViewHelper.webView()->updateAllLifecyclePhases(); 1010 webViewHelper.webView()->updateAllLifecyclePhases();
1011 } 1011 }
(...skipping 10 matching lines...) Expand all
1022 // Make sure we initialize to minimum scale, even if the window size 1022 // Make sure we initialize to minimum scale, even if the window size
1023 // only becomes available after the load begins. 1023 // only becomes available after the load begins.
1024 FrameTestHelpers::WebViewHelper webViewHelper(this); 1024 FrameTestHelpers::WebViewHelper webViewHelper(this);
1025 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 1025 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
1026 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 1026 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
1027 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html"); 1027 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html");
1028 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1028 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1029 1029
1030 int defaultFixedLayoutWidth = 980; 1030 int defaultFixedLayoutWidth = 980;
1031 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid th; 1031 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid th;
1032 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFact or()); 1032 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor() );
1033 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->minimumPageSc aleFactor()); 1033 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF actor());
1034 1034
1035 // Assume the user has pinch zoomed to page scale factor 2. 1035 // Assume the user has pinch zoomed to page scale factor 2.
1036 float userPinchPageScaleFactor = 2; 1036 float userPinchPageScaleFactor = 2;
1037 webViewHelper.webView()->setPageScaleFactor(userPinchPageScaleFactor); 1037 webViewHelper.webView()->setPageScaleFactor(userPinchPageScaleFactor);
1038 webViewHelper.webView()->updateAllLifecyclePhases(); 1038 webViewHelper.webView()->updateAllLifecyclePhases();
1039 1039
1040 // Make sure we don't reset to initial scale if the page continues to load. 1040 // Make sure we don't reset to initial scale if the page continues to load.
1041 webViewHelper.webViewImpl()->didCommitLoad(false, false); 1041 webViewHelper.webView()->didCommitLoad(false, false);
1042 webViewHelper.webViewImpl()->didChangeContentsSize(); 1042 webViewHelper.webView()->didChangeContentsSize();
1043 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ()); 1043 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ());
1044 1044
1045 // Make sure we don't reset to initial scale if the viewport size changes. 1045 // Make sure we don't reset to initial scale if the viewport size changes.
1046 webViewHelper.resize(WebSize(viewportWidth, viewportHeight + 100)); 1046 webViewHelper.resize(WebSize(viewportWidth, viewportHeight + 100));
1047 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ()); 1047 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ());
1048 } 1048 }
1049 1049
1050 TEST_P(ParameterizedWebFrameTest, WideDocumentInitializeAtMinimumScale) 1050 TEST_P(ParameterizedWebFrameTest, WideDocumentInitializeAtMinimumScale)
1051 { 1051 {
1052 registerMockedHttpURLLoad("wide_document.html"); 1052 registerMockedHttpURLLoad("wide_document.html");
1053 1053
1054 FixedLayoutTestWebViewClient client; 1054 FixedLayoutTestWebViewClient client;
1055 client.m_screenInfo.deviceScaleFactor = 1; 1055 client.m_screenInfo.deviceScaleFactor = 1;
1056 int viewportWidth = 640; 1056 int viewportWidth = 640;
1057 int viewportHeight = 480; 1057 int viewportHeight = 480;
1058 1058
1059 // Make sure we initialize to minimum scale, even if the window size 1059 // Make sure we initialize to minimum scale, even if the window size
1060 // only becomes available after the load begins. 1060 // only becomes available after the load begins.
1061 FrameTestHelpers::WebViewHelper webViewHelper(this); 1061 FrameTestHelpers::WebViewHelper webViewHelper(this);
1062 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 1062 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
1063 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 1063 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
1064 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "wide_document.html"); 1064 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "wide_document.html");
1065 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1065 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1066 1066
1067 int wideDocumentWidth = 1500; 1067 int wideDocumentWidth = 1500;
1068 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; 1068 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth;
1069 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFact or()); 1069 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor() );
1070 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->minimumPageSc aleFactor()); 1070 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF actor());
1071 1071
1072 // Assume the user has pinch zoomed to page scale factor 2. 1072 // Assume the user has pinch zoomed to page scale factor 2.
1073 float userPinchPageScaleFactor = 2; 1073 float userPinchPageScaleFactor = 2;
1074 webViewHelper.webView()->setPageScaleFactor(userPinchPageScaleFactor); 1074 webViewHelper.webView()->setPageScaleFactor(userPinchPageScaleFactor);
1075 webViewHelper.webView()->updateAllLifecyclePhases(); 1075 webViewHelper.webView()->updateAllLifecyclePhases();
1076 1076
1077 // Make sure we don't reset to initial scale if the page continues to load. 1077 // Make sure we don't reset to initial scale if the page continues to load.
1078 webViewHelper.webViewImpl()->didCommitLoad(false, false); 1078 webViewHelper.webView()->didCommitLoad(false, false);
1079 webViewHelper.webViewImpl()->didChangeContentsSize(); 1079 webViewHelper.webView()->didChangeContentsSize();
1080 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ()); 1080 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ());
1081 1081
1082 // Make sure we don't reset to initial scale if the viewport size changes. 1082 // Make sure we don't reset to initial scale if the viewport size changes.
1083 webViewHelper.resize(WebSize(viewportWidth, viewportHeight + 100)); 1083 webViewHelper.resize(WebSize(viewportWidth, viewportHeight + 100));
1084 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ()); 1084 EXPECT_EQ(userPinchPageScaleFactor, webViewHelper.webView()->pageScaleFactor ());
1085 } 1085 }
1086 1086
1087 TEST_P(ParameterizedWebFrameTest, DelayedViewportInitialScale) 1087 TEST_P(ParameterizedWebFrameTest, DelayedViewportInitialScale)
1088 { 1088 {
1089 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); 1089 registerMockedHttpURLLoad("viewport-auto-initial-scale.html");
1090 1090
1091 FixedLayoutTestWebViewClient client; 1091 FixedLayoutTestWebViewClient client;
1092 client.m_screenInfo.deviceScaleFactor = 1; 1092 client.m_screenInfo.deviceScaleFactor = 1;
1093 int viewportWidth = 640; 1093 int viewportWidth = 640;
1094 int viewportHeight = 480; 1094 int viewportHeight = 480;
1095 1095
1096 FrameTestHelpers::WebViewHelper webViewHelper(this); 1096 FrameTestHelpers::WebViewHelper webViewHelper(this);
1097 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm l", true, nullptr, &client, nullptr, enableViewportSettings); 1097 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm l", true, nullptr, &client, nullptr, enableViewportSettings);
1098 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1098 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1099 1099
1100 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor()); 1100 EXPECT_EQ(0.25f, webViewHelper.webView()->pageScaleFactor());
1101 1101
1102 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 1102 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
1103 ViewportDescription description = document->viewportDescription(); 1103 ViewportDescription description = document->viewportDescription();
1104 description.zoom = 2; 1104 description.zoom = 2;
1105 document->setViewportDescription(description); 1105 document->setViewportDescription(description);
1106 webViewHelper.webView()->updateAllLifecyclePhases(); 1106 webViewHelper.webView()->updateAllLifecyclePhases();
1107 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor()); 1107 EXPECT_EQ(2, webViewHelper.webView()->pageScaleFactor());
1108 } 1108 }
1109 1109
1110 TEST_P(ParameterizedWebFrameTest, setLoadWithOverviewModeToFalse) 1110 TEST_P(ParameterizedWebFrameTest, setLoadWithOverviewModeToFalse)
1111 { 1111 {
1112 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); 1112 registerMockedHttpURLLoad("viewport-auto-initial-scale.html");
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 int viewportWidth = 640; 1155 int viewportWidth = 640;
1156 int viewportHeight = 480; 1156 int viewportHeight = 480;
1157 1157
1158 FrameTestHelpers::WebViewHelper webViewHelper(this); 1158 FrameTestHelpers::WebViewHelper webViewHelper(this);
1159 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm l", true, nullptr, &client, nullptr, enableViewportSettings); 1159 webViewHelper.initializeAndLoad(m_baseURL + "viewport-auto-initial-scale.htm l", true, nullptr, &client, nullptr, enableViewportSettings);
1160 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1160 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1161 webViewHelper.webView()->settings()->setUseWideViewport(false); 1161 webViewHelper.webView()->settings()->setUseWideViewport(false);
1162 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1162 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1163 1163
1164 // The page sets viewport width to 3000, but with UseWideViewport == false i s must be ignored. 1164 // The page sets viewport width to 3000, but with UseWideViewport == false i s must be ignored.
1165 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->contentsSize().width()); 1165 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->contentsSize().width());
1166 EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->contentsSize().height()); 1166 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie w()->contentsSize().height());
1167 } 1167 }
1168 1168
1169 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccou ntsScale) 1169 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidthButAccou ntsScale)
1170 { 1170 {
1171 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); 1171 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html");
1172 1172
1173 FixedLayoutTestWebViewClient client; 1173 FixedLayoutTestWebViewClient client;
1174 client.m_screenInfo.deviceScaleFactor = 1; 1174 client.m_screenInfo.deviceScaleFactor = 1;
1175 int viewportWidth = 640; 1175 int viewportWidth = 640;
1176 int viewportHeight = 480; 1176 int viewportHeight = 480;
1177 1177
1178 FrameTestHelpers::WebViewHelper webViewHelper(this); 1178 FrameTestHelpers::WebViewHelper webViewHelper(this);
1179 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale. html", true, nullptr, &client, nullptr, enableViewportSettings); 1179 webViewHelper.initializeAndLoad(m_baseURL + "viewport-wide-2x-initial-scale. html", true, nullptr, &client, nullptr, enableViewportSettings);
1180 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1180 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1181 webViewHelper.webView()->settings()->setUseWideViewport(false); 1181 webViewHelper.webView()->settings()->setUseWideViewport(false);
1182 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1182 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1183 1183
1184 // The page sets viewport width to 3000, but with UseWideViewport == false i t must be ignored. 1184 // The page sets viewport width to 3000, but with UseWideViewport == false i t must be ignored.
1185 // While the initial scale specified by the page must be accounted. 1185 // While the initial scale specified by the page must be accounted.
1186 EXPECT_EQ(viewportWidth / 2, webViewHelper.webViewImpl()->mainFrameImpl()->f rameView()->contentsSize().width()); 1186 EXPECT_EQ(viewportWidth / 2, webViewHelper.webView()->mainFrameImpl()->frame View()->contentsSize().width());
1187 EXPECT_EQ(viewportHeight / 2, webViewHelper.webViewImpl()->mainFrameImpl()-> frameView()->contentsSize().height()); 1187 EXPECT_EQ(viewportHeight / 2, webViewHelper.webView()->mainFrameImpl()->fram eView()->contentsSize().height());
1188 } 1188 }
1189 1189
1190 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithoutViewportTag) 1190 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithoutViewportTag)
1191 { 1191 {
1192 registerMockedHttpURLLoad("no_viewport_tag.html"); 1192 registerMockedHttpURLLoad("no_viewport_tag.html");
1193 1193
1194 FixedLayoutTestWebViewClient client; 1194 FixedLayoutTestWebViewClient client;
1195 client.m_screenInfo.deviceScaleFactor = 1; 1195 client.m_screenInfo.deviceScaleFactor = 1;
1196 int viewportWidth = 640; 1196 int viewportWidth = 640;
1197 int viewportHeight = 480; 1197 int viewportHeight = 480;
1198 1198
1199 FrameTestHelpers::WebViewHelper webViewHelper(this); 1199 FrameTestHelpers::WebViewHelper webViewHelper(this);
1200 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu llptr, &client, nullptr, enableViewportSettings); 1200 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu llptr, &client, nullptr, enableViewportSettings);
1201 applyViewportStyleOverride(&webViewHelper); 1201 applyViewportStyleOverride(&webViewHelper);
1202 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1202 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1203 webViewHelper.webView()->settings()->setUseWideViewport(true); 1203 webViewHelper.webView()->settings()->setUseWideViewport(true);
1204 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1204 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1205 1205
1206 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co ntentsSize().width()); 1206 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten tsSize().width());
1207 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl( )->mainFrameImpl()->frameView()->contentsSize().height()); 1207 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webView()->m ainFrameImpl()->frameView()->contentsSize().height());
1208 } 1208 }
1209 1209
1210 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithXhtmlMp) 1210 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithXhtmlMp)
1211 { 1211 {
1212 registerMockedHttpURLLoad("viewport/viewport-legacy-xhtmlmp.html"); 1212 registerMockedHttpURLLoad("viewport/viewport-legacy-xhtmlmp.html");
1213 1213
1214 FixedLayoutTestWebViewClient client; 1214 FixedLayoutTestWebViewClient client;
1215 client.m_screenInfo.deviceScaleFactor = 1; 1215 client.m_screenInfo.deviceScaleFactor = 1;
1216 int viewportWidth = 640; 1216 int viewportWidth = 640;
1217 int viewportHeight = 480; 1217 int viewportHeight = 480;
1218 1218
1219 FrameTestHelpers::WebViewHelper webViewHelper(this); 1219 FrameTestHelpers::WebViewHelper webViewHelper(this);
1220 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 1220 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
1221 applyViewportStyleOverride(&webViewHelper); 1221 applyViewportStyleOverride(&webViewHelper);
1222 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1222 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1223 webViewHelper.webView()->settings()->setUseWideViewport(true); 1223 webViewHelper.webView()->settings()->setUseWideViewport(true);
1224 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport/viewport-legacy-xhtmlmp.html"); 1224 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport/viewport-legacy-xhtmlmp.html");
1225 1225
1226 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1226 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1227 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->contentsSize().width()); 1227 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->contentsSize().width());
1228 EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->contentsSize().height()); 1228 EXPECT_EQ(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie w()->contentsSize().height());
1229 } 1229 }
1230 1230
1231 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndHeightInMeta) 1231 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndHeightInMeta)
1232 { 1232 {
1233 registerMockedHttpURLLoad("viewport-height-1000.html"); 1233 registerMockedHttpURLLoad("viewport-height-1000.html");
1234 1234
1235 FixedLayoutTestWebViewClient client; 1235 FixedLayoutTestWebViewClient client;
1236 client.m_screenInfo.deviceScaleFactor = 1; 1236 client.m_screenInfo.deviceScaleFactor = 1;
1237 int viewportWidth = 640; 1237 int viewportWidth = 640;
1238 int viewportHeight = 480; 1238 int viewportHeight = 480;
1239 1239
1240 FrameTestHelpers::WebViewHelper webViewHelper(this); 1240 FrameTestHelpers::WebViewHelper webViewHelper(this);
1241 webViewHelper.initializeAndLoad(m_baseURL + "viewport-height-1000.html", tru e, nullptr, &client, nullptr, enableViewportSettings); 1241 webViewHelper.initializeAndLoad(m_baseURL + "viewport-height-1000.html", tru e, nullptr, &client, nullptr, enableViewportSettings);
1242 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1242 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1243 webViewHelper.webView()->settings()->setUseWideViewport(false); 1243 webViewHelper.webView()->settings()->setUseWideViewport(false);
1244 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1244 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1245 1245
1246 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->contentsSize().width()); 1246 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->contentsSize().width());
1247 } 1247 }
1248 1248
1249 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithAutoWidth) 1249 TEST_P(ParameterizedWebFrameTest, WideViewportSetsTo980WithAutoWidth)
1250 { 1250 {
1251 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); 1251 registerMockedHttpURLLoad("viewport-2x-initial-scale.html");
1252 1252
1253 FixedLayoutTestWebViewClient client; 1253 FixedLayoutTestWebViewClient client;
1254 client.m_screenInfo.deviceScaleFactor = 1; 1254 client.m_screenInfo.deviceScaleFactor = 1;
1255 int viewportWidth = 640; 1255 int viewportWidth = 640;
1256 int viewportHeight = 480; 1256 int viewportHeight = 480;
1257 1257
1258 FrameTestHelpers::WebViewHelper webViewHelper(this); 1258 FrameTestHelpers::WebViewHelper webViewHelper(this);
1259 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html" , true, nullptr, &client, nullptr, enableViewportSettings); 1259 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html" , true, nullptr, &client, nullptr, enableViewportSettings);
1260 applyViewportStyleOverride(&webViewHelper); 1260 applyViewportStyleOverride(&webViewHelper);
1261 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1261 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1262 webViewHelper.webView()->settings()->setUseWideViewport(true); 1262 webViewHelper.webView()->settings()->setUseWideViewport(true);
1263 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1263 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1264 1264
1265 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co ntentsSize().width()); 1265 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten tsSize().width());
1266 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl( )->mainFrameImpl()->frameView()->contentsSize().height()); 1266 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webView()->m ainFrameImpl()->frameView()->contentsSize().height());
1267 } 1267 }
1268 1268
1269 TEST_P(ParameterizedWebFrameTest, PageViewportInitialScaleOverridesLoadWithOverv iewMode) 1269 TEST_P(ParameterizedWebFrameTest, PageViewportInitialScaleOverridesLoadWithOverv iewMode)
1270 { 1270 {
1271 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); 1271 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html");
1272 1272
1273 FixedLayoutTestWebViewClient client; 1273 FixedLayoutTestWebViewClient client;
1274 client.m_screenInfo.deviceScaleFactor = 1; 1274 client.m_screenInfo.deviceScaleFactor = 1;
1275 int viewportWidth = 640; 1275 int viewportWidth = 640;
1276 int viewportHeight = 480; 1276 int viewportHeight = 480;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 float enforcedPageScaleFactor = 0.5; 1394 float enforcedPageScaleFactor = 0.5;
1395 1395
1396 FrameTestHelpers::WebViewHelper webViewHelper(this); 1396 FrameTestHelpers::WebViewHelper webViewHelper(this);
1397 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings); 1397 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings);
1398 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1398 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1399 webViewHelper.webView()->settings()->setUseWideViewport(false); 1399 webViewHelper.webView()->settings()->setUseWideViewport(false);
1400 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); 1400 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false);
1401 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor ); 1401 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor );
1402 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1402 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1403 1403
1404 EXPECT_EQ(viewportWidth / enforcedPageScaleFactor, webViewHelper.webViewImpl ()->mainFrameImpl()->frameView()->contentsSize().width()); 1404 EXPECT_EQ(viewportWidth / enforcedPageScaleFactor, webViewHelper.webView()-> mainFrameImpl()->frameView()->contentsSize().width());
1405 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor( )); 1405 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor( ));
1406 } 1406 }
1407 1407
1408 TEST_P(ParameterizedWebFrameTest, DocumentElementClientHeightWorksWithWrapConten tMode) 1408 TEST_P(ParameterizedWebFrameTest, DocumentElementClientHeightWorksWithWrapConten tMode)
1409 { 1409 {
1410 registerMockedHttpURLLoad("0-by-0.html"); 1410 registerMockedHttpURLLoad("0-by-0.html");
1411 1411
1412 FixedLayoutTestWebViewClient client; 1412 FixedLayoutTestWebViewClient client;
1413 client.m_screenInfo.deviceScaleFactor = 1; 1413 client.m_screenInfo.deviceScaleFactor = 1;
1414 int viewportWidth = 640; 1414 int viewportWidth = 640;
1415 int viewportHeight = 480; 1415 int viewportHeight = 480;
1416 1416
1417 FrameTestHelpers::WebViewHelper webViewHelper(this); 1417 FrameTestHelpers::WebViewHelper webViewHelper(this);
1418 1418
1419 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c lient, nullptr, configureAndroid); 1419 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c lient, nullptr, configureAndroid);
1420 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); 1420 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1421 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1421 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1422 1422
1423 LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame(); 1423 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame();
1424 Document* document = frame->document(); 1424 Document* document = frame->document();
1425 EXPECT_EQ(viewportHeight, document->documentElement()->clientHeight()); 1425 EXPECT_EQ(viewportHeight, document->documentElement()->clientHeight());
1426 EXPECT_EQ(viewportWidth, document->documentElement()->clientWidth()); 1426 EXPECT_EQ(viewportWidth, document->documentElement()->clientWidth());
1427 } 1427 }
1428 1428
1429 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksWithWrapContentMo de) 1429 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksWithWrapContentMo de)
1430 { 1430 {
1431 registerMockedHttpURLLoad("0-by-0.html"); 1431 registerMockedHttpURLLoad("0-by-0.html");
1432 1432
1433 FixedLayoutTestWebViewClient client; 1433 FixedLayoutTestWebViewClient client;
1434 client.m_screenInfo.deviceScaleFactor = 1; 1434 client.m_screenInfo.deviceScaleFactor = 1;
1435 int viewportWidth = 640; 1435 int viewportWidth = 640;
1436 int viewportHeight = 480; 1436 int viewportHeight = 480;
1437 1437
1438 FrameTestHelpers::WebViewHelper webViewHelper(this); 1438 FrameTestHelpers::WebViewHelper webViewHelper(this);
1439 1439
1440 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c lient, nullptr, configureAndroid); 1440 webViewHelper.initializeAndLoad(m_baseURL + "0-by-0.html", true, nullptr, &c lient, nullptr, configureAndroid);
1441 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); 1441 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1442 PaintLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor() ; 1442 PaintLayerCompositor* compositor = webViewHelper.webView()->compositor();
1443 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().width()); 1443 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().width());
1444 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1444 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1445 EXPECT_EQ(0.0, compositor->containerLayer()->size().width()); 1445 EXPECT_EQ(0.0, compositor->containerLayer()->size().width());
1446 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); 1446 EXPECT_EQ(0.0, compositor->containerLayer()->size().height());
1447 1447
1448 webViewHelper.resize(WebSize(viewportWidth, 0)); 1448 webViewHelper.resize(WebSize(viewportWidth, 0));
1449 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width()); 1449 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->layoutSize().width());
1450 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1450 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1451 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); 1451 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width());
1452 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); 1452 EXPECT_EQ(0.0, compositor->containerLayer()->size().height());
1453 1453
1454 // The flag ForceZeroLayoutHeight will cause the following resize of viewpor t 1454 // The flag ForceZeroLayoutHeight will cause the following resize of viewpor t
1455 // height to be ignored by the outer viewport (the container layer of 1455 // height to be ignored by the outer viewport (the container layer of
1456 // LayerCompositor). The height of the visualViewport, however, is not affec ted. 1456 // LayerCompositor). The height of the visualViewport, however, is not affec ted.
1457 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1457 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1458 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout()); 1458 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay out());
1459 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width()); 1459 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->layoutSize().width());
1460 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1460 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1461 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); 1461 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width());
1462 EXPECT_EQ(viewportHeight, compositor->containerLayer()->size().height()); 1462 EXPECT_EQ(viewportHeight, compositor->containerLayer()->size().height());
1463 1463
1464 LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame(); 1464 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame();
1465 VisualViewport& visualViewport = frame->page()->frameHost().visualViewport() ; 1465 VisualViewport& visualViewport = frame->page()->frameHost().visualViewport() ;
1466 EXPECT_EQ(viewportHeight, visualViewport.containerLayer()->size().height()); 1466 EXPECT_EQ(viewportHeight, visualViewport.containerLayer()->size().height());
1467 EXPECT_TRUE(visualViewport.containerLayer()->platformLayer()->masksToBounds( )); 1467 EXPECT_TRUE(visualViewport.containerLayer()->platformLayer()->masksToBounds( ));
1468 EXPECT_FALSE(compositor->containerLayer()->platformLayer()->masksToBounds()) ; 1468 EXPECT_FALSE(compositor->containerLayer()->platformLayer()->masksToBounds()) ;
1469 } 1469 }
1470 1470
1471 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeight) 1471 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeight)
1472 { 1472 {
1473 registerMockedHttpURLLoad("200-by-300.html"); 1473 registerMockedHttpURLLoad("200-by-300.html");
1474 1474
1475 FixedLayoutTestWebViewClient client; 1475 FixedLayoutTestWebViewClient client;
1476 client.m_screenInfo.deviceScaleFactor = 1; 1476 client.m_screenInfo.deviceScaleFactor = 1;
1477 int viewportWidth = 640; 1477 int viewportWidth = 640;
1478 int viewportHeight = 480; 1478 int viewportHeight = 480;
1479 1479
1480 FrameTestHelpers::WebViewHelper webViewHelper(this); 1480 FrameTestHelpers::WebViewHelper webViewHelper(this);
1481 1481
1482 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr , &client, nullptr, enableViewportSettings); 1482 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr , &client, nullptr, enableViewportSettings);
1483 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1483 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1484 1484
1485 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height()); 1485 EXPECT_LE(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie w()->layoutSize().height());
1486 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); 1486 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1487 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs Layout()); 1487 EXPECT_TRUE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLayo ut());
1488 1488
1489 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1489 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1490 1490
1491 webViewHelper.resize(WebSize(viewportWidth, viewportHeight * 2)); 1491 webViewHelper.resize(WebSize(viewportWidth, viewportHeight * 2));
1492 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout()); 1492 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay out());
1493 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1493 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1494 1494
1495 webViewHelper.resize(WebSize(viewportWidth * 2, viewportHeight)); 1495 webViewHelper.resize(WebSize(viewportWidth * 2, viewportHeight));
1496 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1496 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1497 1497
1498 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false); 1498 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false);
1499 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height()); 1499 EXPECT_LE(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameVie w()->layoutSize().height());
1500 } 1500 }
1501 1501
1502 TEST_F(WebFrameTest, ToggleViewportMetaOnOff) 1502 TEST_F(WebFrameTest, ToggleViewportMetaOnOff)
1503 { 1503 {
1504 registerMockedHttpURLLoad("viewport-device-width.html"); 1504 registerMockedHttpURLLoad("viewport-device-width.html");
1505 1505
1506 FixedLayoutTestWebViewClient client; 1506 FixedLayoutTestWebViewClient client;
1507 client.m_screenInfo.deviceScaleFactor = 1; 1507 client.m_screenInfo.deviceScaleFactor = 1;
1508 int viewportWidth = 640; 1508 int viewportWidth = 640;
1509 int viewportHeight = 480; 1509 int viewportHeight = 480;
1510 1510
1511 FrameTestHelpers::WebViewHelper webViewHelper; 1511 FrameTestHelpers::WebViewHelper webViewHelper;
1512 webViewHelper.initializeAndLoad(m_baseURL + "viewport-device-width.html", tr ue, 0, &client); 1512 webViewHelper.initializeAndLoad(m_baseURL + "viewport-device-width.html", tr ue, 0, &client);
1513 WebSettings* settings = webViewHelper.webView()->settings(); 1513 WebSettings* settings = webViewHelper.webView()->settings();
1514 settings->setViewportMetaEnabled(false); 1514 settings->setViewportMetaEnabled(false);
1515 settings->setViewportEnabled(true); 1515 settings->setViewportEnabled(true);
1516 settings->setMainFrameResizesAreOrientationChanges(true); 1516 settings->setMainFrameResizesAreOrientationChanges(true);
1517 settings->setShrinksViewportContentToFit(true); 1517 settings->setShrinksViewportContentToFit(true);
1518 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1518 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1519 1519
1520 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 1520 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
1521 EXPECT_FALSE(document->viewportDescription().isLegacyViewportType()); 1521 EXPECT_FALSE(document->viewportDescription().isLegacyViewportType());
1522 1522
1523 settings->setViewportMetaEnabled(true); 1523 settings->setViewportMetaEnabled(true);
1524 EXPECT_TRUE(document->viewportDescription().isLegacyViewportType()); 1524 EXPECT_TRUE(document->viewportDescription().isLegacyViewportType());
1525 1525
1526 settings->setViewportMetaEnabled(false); 1526 settings->setViewportMetaEnabled(false);
1527 EXPECT_FALSE(document->viewportDescription().isLegacyViewportType()); 1527 EXPECT_FALSE(document->viewportDescription().isLegacyViewportType());
1528 } 1528 }
1529 1529
1530 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged ) 1530 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged )
(...skipping 17 matching lines...) Expand all
1548 // set view height to zero so that if the height of the view is not 1548 // set view height to zero so that if the height of the view is not
1549 // successfully updated during later resizes touch events will fail 1549 // successfully updated during later resizes touch events will fail
1550 // (as in not hit content included in the view) 1550 // (as in not hit content included in the view)
1551 webViewHelper.resize(WebSize(viewportWidth, 0)); 1551 webViewHelper.resize(WebSize(viewportWidth, 0));
1552 1552
1553 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); 1553 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1554 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1554 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1555 1555
1556 IntPoint hitPoint = IntPoint(30, 30); // button size is 100x100 1556 IntPoint hitPoint = IntPoint(30, 30); // button size is 100x100
1557 1557
1558 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 1558 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
1559 Document* document = frame->frame()->document(); 1559 Document* document = frame->frame()->document();
1560 Element* element = document->getElementById("tap_button"); 1560 Element* element = document->getElementById("tap_button");
1561 1561
1562 ASSERT_NE(nullptr, element); 1562 ASSERT_NE(nullptr, element);
1563 EXPECT_EQ(String("oldValue"), element->innerText()); 1563 EXPECT_EQ(String("oldValue"), element->innerText());
1564 1564
1565 PlatformGestureEvent gestureEvent(PlatformEvent::EventType::GestureTap, hitP oint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers, PlatformGestureSou rceTouchscreen); 1565 PlatformGestureEvent gestureEvent(PlatformEvent::EventType::GestureTap, hitP oint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers, PlatformGestureSou rceTouchscreen);
1566 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); 1566 webViewHelper.webView()->mainFrameImpl()->frame()->eventHandler().handleGest ureEvent(gestureEvent);
1567 // when pressed, the button changes its own text to "updatedValue" 1567 // when pressed, the button changes its own text to "updatedValue"
1568 EXPECT_EQ(String("updatedValue"), element->innerText()); 1568 EXPECT_EQ(String("updatedValue"), element->innerText());
1569 } 1569 }
1570 1570
1571 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin) 1571 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin)
1572 { 1572 {
1573 FrameTestHelpers::TestWebViewClient viewClient; 1573 FrameTestHelpers::TestWebViewClient viewClient;
1574 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 1574 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1575 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); 1575 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible);
1576 view->settings()->setJavaScriptEnabled(true); 1576 view->settings()->setJavaScriptEnabled(true);
1577 view->setMainFrame(remoteClient.frame()); 1577 view->setMainFrame(remoteClient.frame());
1578 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 1578 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1579 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 1579 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1580 1580
1581 WebFrameOwnerProperties properties; 1581 WebFrameOwnerProperties properties;
1582 properties.marginWidth = 11; 1582 properties.marginWidth = 11;
1583 properties.marginHeight = 22; 1583 properties.marginHeight = 22;
1584 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, nullptr, properties); 1584 WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild(root, "fr ameName", nullptr, nullptr, nullptr, properties);
1585 1585
1586 registerMockedHttpURLLoad("frame_owner_properties.html"); 1586 registerMockedHttpURLLoad("frame_owner_properties.html");
1587 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); 1587 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1588 1588
1589 // Check if the LocalFrame has seen the marginwidth and marginheight 1589 // Check if the LocalFrame has seen the marginwidth and marginheight
1590 // properties. 1590 // properties.
1591 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); 1591 Document* childDocument = localFrame->frame()->document();
1592 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr)); 1592 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr));
1593 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr)); 1593 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr));
1594 1594
1595 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); 1595 FrameView* frameView = localFrame->frameView();
1596 // Expect scrollbars to be enabled by default. 1596 // Expect scrollbars to be enabled by default.
1597 EXPECT_NE(nullptr, frameView->horizontalScrollbar()); 1597 EXPECT_NE(nullptr, frameView->horizontalScrollbar());
1598 EXPECT_NE(nullptr, frameView->verticalScrollbar()); 1598 EXPECT_NE(nullptr, frameView->verticalScrollbar());
1599 1599
1600 view->close(); 1600 view->close();
1601 } 1601 }
1602 1602
1603 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling) 1603 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling)
1604 { 1604 {
1605 FrameTestHelpers::TestWebViewClient viewClient; 1605 FrameTestHelpers::TestWebViewClient viewClient;
1606 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 1606 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1607 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); 1607 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible);
1608 view->settings()->setJavaScriptEnabled(true); 1608 view->settings()->setJavaScriptEnabled(true);
1609 view->setMainFrame(remoteClient.frame()); 1609 view->setMainFrame(remoteClient.frame());
1610 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 1610 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1611 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 1611 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1612 1612
1613 WebFrameOwnerProperties properties; 1613 WebFrameOwnerProperties properties;
1614 // Turn off scrolling in the subframe. 1614 // Turn off scrolling in the subframe.
1615 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ; 1615 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ;
1616 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, nullptr, properties); 1616 WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild(root, "fr ameName", nullptr, nullptr, nullptr, properties);
1617 1617
1618 registerMockedHttpURLLoad("frame_owner_properties.html"); 1618 registerMockedHttpURLLoad("frame_owner_properties.html");
1619 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); 1619 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1620 1620
1621 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); 1621 Document* childDocument = localFrame->frame()->document();
1622 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr)); 1622 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr));
1623 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr)); 1623 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr));
1624 1624
1625 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w(); 1625 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1626 EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); 1626 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
1627 EXPECT_EQ(nullptr, frameView->verticalScrollbar()); 1627 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
1628 1628
1629 view->close(); 1629 view->close();
1630 } 1630 }
1631 1631
(...skipping 10 matching lines...) Expand all
1642 1642
1643 FrameTestHelpers::WebViewHelper webViewHelper(this); 1643 FrameTestHelpers::WebViewHelper webViewHelper(this);
1644 1644
1645 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr , &client, nullptr, enableViewportSettings); 1645 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr , &client, nullptr, enableViewportSettings);
1646 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); 1646 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1647 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1647 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1648 1648
1649 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html"); 1649 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html");
1650 webViewHelper.webView()->updateAllLifecyclePhases(); 1650 webViewHelper.webView()->updateAllLifecyclePhases();
1651 1651
1652 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1652 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1653 } 1653 }
1654 1654
1655 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWithWideViewportQuirk) 1655 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWithWideViewportQuirk)
1656 { 1656 {
1657 registerMockedHttpURLLoad("200-by-300.html"); 1657 registerMockedHttpURLLoad("200-by-300.html");
1658 1658
1659 FixedLayoutTestWebViewClient client; 1659 FixedLayoutTestWebViewClient client;
1660 client.m_screenInfo.deviceScaleFactor = 1; 1660 client.m_screenInfo.deviceScaleFactor = 1;
1661 int viewportWidth = 640; 1661 int viewportWidth = 640;
1662 int viewportHeight = 480; 1662 int viewportHeight = 480;
1663 1663
1664 FrameTestHelpers::WebViewHelper webViewHelper(this); 1664 FrameTestHelpers::WebViewHelper webViewHelper(this);
1665 1665
1666 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr , &client, nullptr, enableViewportSettings); 1666 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, nullptr , &client, nullptr, enableViewportSettings);
1667 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1667 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1668 webViewHelper.webView()->settings()->setUseWideViewport(true); 1668 webViewHelper.webView()->settings()->setUseWideViewport(true);
1669 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); 1669 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1670 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1670 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1671 1671
1672 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1672 EXPECT_EQ(0, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSi ze().height());
1673 } 1673 }
1674 1674
1675 TEST_P(ParameterizedWebFrameTest, WideViewportAndWideContentWithInitialScale) 1675 TEST_P(ParameterizedWebFrameTest, WideViewportAndWideContentWithInitialScale)
1676 { 1676 {
1677 registerMockedHttpURLLoad("wide_document_width_viewport.html"); 1677 registerMockedHttpURLLoad("wide_document_width_viewport.html");
1678 registerMockedHttpURLLoad("white-1x1.png"); 1678 registerMockedHttpURLLoad("white-1x1.png");
1679 1679
1680 FixedLayoutTestWebViewClient client; 1680 FixedLayoutTestWebViewClient client;
1681 client.m_screenInfo.deviceScaleFactor = 1; 1681 client.m_screenInfo.deviceScaleFactor = 1;
1682 int viewportWidth = 600; 1682 int viewportWidth = 600;
1683 int viewportHeight = 800; 1683 int viewportHeight = 800;
1684 1684
1685 FrameTestHelpers::WebViewHelper webViewHelper(this); 1685 FrameTestHelpers::WebViewHelper webViewHelper(this);
1686 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings); 1686 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings);
1687 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1687 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1688 webViewHelper.webView()->settings()->setUseWideViewport(true); 1688 webViewHelper.webView()->settings()->setUseWideViewport(true);
1689 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); 1689 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true);
1690 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1690 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1691 1691
1692 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "wide_document_width_viewport.html"); 1692 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "wide_document_width_viewport.html");
1693 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1693 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1694 1694
1695 int wideDocumentWidth = 800; 1695 int wideDocumentWidth = 800;
1696 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; 1696 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth;
1697 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->pageScaleFact or()); 1697 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor() );
1698 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webViewImpl()->minimumPageSc aleFactor()); 1698 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF actor());
1699 } 1699 }
1700 1700
1701 TEST_P(ParameterizedWebFrameTest, WideViewportQuirkClobbersHeight) 1701 TEST_P(ParameterizedWebFrameTest, WideViewportQuirkClobbersHeight)
1702 { 1702 {
1703 registerMockedHttpURLLoad("viewport-height-1000.html"); 1703 registerMockedHttpURLLoad("viewport-height-1000.html");
1704 1704
1705 FixedLayoutTestWebViewClient client; 1705 FixedLayoutTestWebViewClient client;
1706 client.m_screenInfo.deviceScaleFactor = 1; 1706 client.m_screenInfo.deviceScaleFactor = 1;
1707 int viewportWidth = 600; 1707 int viewportWidth = 600;
1708 int viewportHeight = 800; 1708 int viewportHeight = 800;
1709 1709
1710 FrameTestHelpers::WebViewHelper webViewHelper(this); 1710 FrameTestHelpers::WebViewHelper webViewHelper(this);
1711 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings); 1711 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings);
1712 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1712 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1713 webViewHelper.webView()->settings()->setUseWideViewport(false); 1713 webViewHelper.webView()->settings()->setUseWideViewport(false);
1714 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); 1714 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true);
1715 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1715 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1716 1716
1717 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-height-1000.html"); 1717 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-height-1000.html");
1718 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1718 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1719 1719
1720 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la youtSize().height()); 1720 EXPECT_EQ(800, webViewHelper.webView()->mainFrameImpl()->frameView()->layout Size().height());
1721 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); 1721 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor());
1722 } 1722 }
1723 1723
1724 TEST_P(ParameterizedWebFrameTest, LayoutSize320Quirk) 1724 TEST_P(ParameterizedWebFrameTest, LayoutSize320Quirk)
1725 { 1725 {
1726 registerMockedHttpURLLoad("viewport/viewport-30.html"); 1726 registerMockedHttpURLLoad("viewport/viewport-30.html");
1727 1727
1728 FixedLayoutTestWebViewClient client; 1728 FixedLayoutTestWebViewClient client;
1729 client.m_screenInfo.deviceScaleFactor = 1; 1729 client.m_screenInfo.deviceScaleFactor = 1;
1730 int viewportWidth = 600; 1730 int viewportWidth = 600;
1731 int viewportHeight = 800; 1731 int viewportHeight = 800;
1732 1732
1733 FrameTestHelpers::WebViewHelper webViewHelper(this); 1733 FrameTestHelpers::WebViewHelper webViewHelper(this);
1734 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings); 1734 webViewHelper.initializeAndLoad("about:blank", true, nullptr, &client, nullp tr, enableViewportSettings);
1735 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1735 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1736 webViewHelper.webView()->settings()->setUseWideViewport(true); 1736 webViewHelper.webView()->settings()->setUseWideViewport(true);
1737 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); 1737 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true);
1738 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1738 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1739 1739
1740 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport/viewport-30.html"); 1740 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport/viewport-30.html");
1741 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1741 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1742 1742
1743 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la youtSize().width()); 1743 EXPECT_EQ(600, webViewHelper.webView()->mainFrameImpl()->frameView()->layout Size().width());
1744 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la youtSize().height()); 1744 EXPECT_EQ(800, webViewHelper.webView()->mainFrameImpl()->frameView()->layout Size().height());
1745 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); 1745 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor());
1746 1746
1747 // The magic number to snap to device-width is 320, so test that 321 is 1747 // The magic number to snap to device-width is 320, so test that 321 is
1748 // respected. 1748 // respected.
1749 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 1749 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
1750 ViewportDescription description = document->viewportDescription(); 1750 ViewportDescription description = document->viewportDescription();
1751 description.minWidth = Length(321, blink::Fixed); 1751 description.minWidth = Length(321, blink::Fixed);
1752 description.maxWidth = Length(321, blink::Fixed); 1752 description.maxWidth = Length(321, blink::Fixed);
1753 document->setViewportDescription(description); 1753 document->setViewportDescription(description);
1754 webViewHelper.webView()->updateAllLifecyclePhases(); 1754 webViewHelper.webView()->updateAllLifecyclePhases();
1755 EXPECT_EQ(321, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la youtSize().width()); 1755 EXPECT_EQ(321, webViewHelper.webView()->mainFrameImpl()->frameView()->layout Size().width());
1756 1756
1757 description.minWidth = Length(320, blink::Fixed); 1757 description.minWidth = Length(320, blink::Fixed);
1758 description.maxWidth = Length(320, blink::Fixed); 1758 description.maxWidth = Length(320, blink::Fixed);
1759 document->setViewportDescription(description); 1759 document->setViewportDescription(description);
1760 webViewHelper.webView()->updateAllLifecyclePhases(); 1760 webViewHelper.webView()->updateAllLifecyclePhases();
1761 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la youtSize().width()); 1761 EXPECT_EQ(600, webViewHelper.webView()->mainFrameImpl()->frameView()->layout Size().width());
1762 1762
1763 description = document->viewportDescription(); 1763 description = document->viewportDescription();
1764 description.maxHeight = Length(1000, blink::Fixed); 1764 description.maxHeight = Length(1000, blink::Fixed);
1765 document->setViewportDescription(description); 1765 document->setViewportDescription(description);
1766 webViewHelper.webView()->updateAllLifecyclePhases(); 1766 webViewHelper.webView()->updateAllLifecyclePhases();
1767 EXPECT_EQ(1000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l ayoutSize().height()); 1767 EXPECT_EQ(1000, webViewHelper.webView()->mainFrameImpl()->frameView()->layou tSize().height());
1768 1768
1769 description.maxHeight = Length(320, blink::Fixed); 1769 description.maxHeight = Length(320, blink::Fixed);
1770 document->setViewportDescription(description); 1770 document->setViewportDescription(description);
1771 webViewHelper.webView()->updateAllLifecyclePhases(); 1771 webViewHelper.webView()->updateAllLifecyclePhases();
1772 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la youtSize().height()); 1772 EXPECT_EQ(800, webViewHelper.webView()->mainFrameImpl()->frameView()->layout Size().height());
1773 } 1773 }
1774 1774
1775 TEST_P(ParameterizedWebFrameTest, ZeroValuesQuirk) 1775 TEST_P(ParameterizedWebFrameTest, ZeroValuesQuirk)
1776 { 1776 {
1777 registerMockedHttpURLLoad("viewport-zero-values.html"); 1777 registerMockedHttpURLLoad("viewport-zero-values.html");
1778 1778
1779 FixedLayoutTestWebViewClient client; 1779 FixedLayoutTestWebViewClient client;
1780 client.m_screenInfo.deviceScaleFactor = 1; 1780 client.m_screenInfo.deviceScaleFactor = 1;
1781 int viewportWidth = 640; 1781 int viewportWidth = 640;
1782 int viewportHeight = 480; 1782 int viewportHeight = 480;
1783 1783
1784 FrameTestHelpers::WebViewHelper webViewHelper(this); 1784 FrameTestHelpers::WebViewHelper webViewHelper(this);
1785 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 1785 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
1786 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); 1786 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true);
1787 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1787 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1788 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); 1788 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true);
1789 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-zero-values.html"); 1789 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-zero-values.html");
1790 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1790 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1791 1791
1792 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width()); 1792 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->layoutSize().width());
1793 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); 1793 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor());
1794 1794
1795 webViewHelper.webView()->settings()->setUseWideViewport(true); 1795 webViewHelper.webView()->settings()->setUseWideViewport(true);
1796 webViewHelper.webView()->updateAllLifecyclePhases(); 1796 webViewHelper.webView()->updateAllLifecyclePhases();
1797 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width()); 1797 EXPECT_EQ(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameView ()->layoutSize().width());
1798 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); 1798 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor());
1799 } 1799 }
1800 1800
1801 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrolling) 1801 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrolling)
1802 { 1802 {
1803 registerMockedHttpURLLoad("body-overflow-hidden.html"); 1803 registerMockedHttpURLLoad("body-overflow-hidden.html");
1804 1804
1805 FixedLayoutTestWebViewClient client; 1805 FixedLayoutTestWebViewClient client;
1806 client.m_screenInfo.deviceScaleFactor = 1; 1806 client.m_screenInfo.deviceScaleFactor = 1;
1807 int viewportWidth = 640; 1807 int viewportWidth = 640;
1808 int viewportHeight = 480; 1808 int viewportHeight = 480;
1809 1809
1810 FrameTestHelpers::WebViewHelper webViewHelper(this); 1810 FrameTestHelpers::WebViewHelper webViewHelper(this);
1811 webViewHelper.initialize(true, nullptr, &client, nullptr); 1811 webViewHelper.initialize(true, nullptr, &client, nullptr);
1812 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html"); 1812 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html");
1813 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1813 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1814 1814
1815 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 1815 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
1816 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); 1816 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar));
1817 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); 1817 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar));
1818 } 1818 }
1819 1819
1820 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrollingWithSetCanHaveS crollbars) 1820 TEST_P(ParameterizedWebFrameTest, OverflowHiddenDisablesScrollingWithSetCanHaveS crollbars)
1821 { 1821 {
1822 registerMockedHttpURLLoad("body-overflow-hidden-short.html"); 1822 registerMockedHttpURLLoad("body-overflow-hidden-short.html");
1823 1823
1824 FixedLayoutTestWebViewClient client; 1824 FixedLayoutTestWebViewClient client;
1825 client.m_screenInfo.deviceScaleFactor = 1; 1825 client.m_screenInfo.deviceScaleFactor = 1;
1826 int viewportWidth = 640; 1826 int viewportWidth = 640;
1827 int viewportHeight = 480; 1827 int viewportHeight = 480;
1828 1828
1829 FrameTestHelpers::WebViewHelper webViewHelper(this); 1829 FrameTestHelpers::WebViewHelper webViewHelper(this);
1830 webViewHelper.initialize(true, nullptr, &client, nullptr); 1830 webViewHelper.initialize(true, nullptr, &client, nullptr);
1831 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden-short.html"); 1831 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden-short.html");
1832 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1832 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1833 1833
1834 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 1834 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
1835 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); 1835 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar));
1836 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); 1836 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar));
1837 1837
1838 webViewHelper.webViewImpl()->mainFrameImpl()->setCanHaveScrollbars(true); 1838 webViewHelper.webView()->mainFrameImpl()->setCanHaveScrollbars(true);
1839 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar)); 1839 EXPECT_FALSE(view->userInputScrollable(VerticalScrollbar));
1840 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar)); 1840 EXPECT_FALSE(view->userInputScrollable(HorizontalScrollbar));
1841 } 1841 }
1842 1842
1843 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) 1843 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk)
1844 { 1844 {
1845 registerMockedHttpURLLoad("body-overflow-hidden.html"); 1845 registerMockedHttpURLLoad("body-overflow-hidden.html");
1846 1846
1847 FixedLayoutTestWebViewClient client; 1847 FixedLayoutTestWebViewClient client;
1848 client.m_screenInfo.deviceScaleFactor = 1; 1848 client.m_screenInfo.deviceScaleFactor = 1;
1849 int viewportWidth = 640; 1849 int viewportWidth = 640;
1850 int viewportHeight = 480; 1850 int viewportHeight = 480;
1851 1851
1852 FrameTestHelpers::WebViewHelper webViewHelper; 1852 FrameTestHelpers::WebViewHelper webViewHelper;
1853 webViewHelper.initialize(true, nullptr, &client, nullptr); 1853 webViewHelper.initialize(true, nullptr, &client, nullptr);
1854 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t rue); 1854 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t rue);
1855 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html"); 1855 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html");
1856 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1856 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1857 1857
1858 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 1858 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
1859 EXPECT_TRUE(view->userInputScrollable(VerticalScrollbar)); 1859 EXPECT_TRUE(view->userInputScrollable(VerticalScrollbar));
1860 } 1860 }
1861 1861
1862 TEST_P(ParameterizedWebFrameTest, NonZeroValuesNoQuirk) 1862 TEST_P(ParameterizedWebFrameTest, NonZeroValuesNoQuirk)
1863 { 1863 {
1864 registerMockedHttpURLLoad("viewport-nonzero-values.html"); 1864 registerMockedHttpURLLoad("viewport-nonzero-values.html");
1865 1865
1866 FixedLayoutTestWebViewClient client; 1866 FixedLayoutTestWebViewClient client;
1867 client.m_screenInfo.deviceScaleFactor = 1; 1867 client.m_screenInfo.deviceScaleFactor = 1;
1868 int viewportWidth = 640; 1868 int viewportWidth = 640;
1869 int viewportHeight = 480; 1869 int viewportHeight = 480;
1870 float expectedPageScaleFactor = 0.5f; 1870 float expectedPageScaleFactor = 0.5f;
1871 1871
1872 FrameTestHelpers::WebViewHelper webViewHelper(this); 1872 FrameTestHelpers::WebViewHelper webViewHelper(this);
1873 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 1873 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
1874 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); 1874 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true);
1875 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 1875 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1876 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-nonzero-values.html"); 1876 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-nonzero-values.html");
1877 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1877 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1878 1878
1879 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl ()->mainFrameImpl()->frameView()->layoutSize().width()); 1879 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webView()-> mainFrameImpl()->frameView()->layoutSize().width());
1880 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor( )); 1880 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor( ));
1881 1881
1882 webViewHelper.webView()->settings()->setUseWideViewport(true); 1882 webViewHelper.webView()->settings()->setUseWideViewport(true);
1883 webViewHelper.webView()->updateAllLifecyclePhases(); 1883 webViewHelper.webView()->updateAllLifecyclePhases();
1884 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl ()->mainFrameImpl()->frameView()->layoutSize().width()); 1884 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webView()-> mainFrameImpl()->frameView()->layoutSize().width());
1885 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor( )); 1885 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor( ));
1886 } 1886 }
1887 1887
1888 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorDoesNotLayout) 1888 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorDoesNotLayout)
1889 { 1889 {
1890 registerMockedHttpURLLoad("fixed_layout.html"); 1890 registerMockedHttpURLLoad("fixed_layout.html");
1891 1891
1892 FixedLayoutTestWebViewClient client; 1892 FixedLayoutTestWebViewClient client;
1893 client.m_screenInfo.deviceScaleFactor = 1; 1893 client.m_screenInfo.deviceScaleFactor = 1;
1894 // Small viewport to ensure there are always scrollbars. 1894 // Small viewport to ensure there are always scrollbars.
1895 int viewportWidth = 64; 1895 int viewportWidth = 64;
1896 int viewportHeight = 48; 1896 int viewportHeight = 48;
1897 1897
1898 FrameTestHelpers::WebViewHelper webViewHelper(this); 1898 FrameTestHelpers::WebViewHelper webViewHelper(this);
1899 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings); 1899 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings);
1900 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1900 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1901 1901
1902 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie w()->layoutCount(); 1902 int prevLayoutCount = webViewHelper.webView()->mainFrameImpl()->frameView()- >layoutCount();
1903 webViewHelper.webViewImpl()->setPageScaleFactor(3); 1903 webViewHelper.webView()->setPageScaleFactor(3);
1904 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout()); 1904 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay out());
1905 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutCount()); 1905 EXPECT_EQ(prevLayoutCount, webViewHelper.webView()->mainFrameImpl()->frameVi ew()->layoutCount());
1906 } 1906 }
1907 1907
1908 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNot Layout) 1908 TEST_P(ParameterizedWebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNot Layout)
1909 { 1909 {
1910 registerMockedHttpURLLoad("fixed_layout.html"); 1910 registerMockedHttpURLLoad("fixed_layout.html");
1911 1911
1912 FixedLayoutTestWebViewClient client; 1912 FixedLayoutTestWebViewClient client;
1913 client.m_screenInfo.deviceScaleFactor = 1; 1913 client.m_screenInfo.deviceScaleFactor = 1;
1914 int viewportWidth = 640; 1914 int viewportWidth = 640;
1915 int viewportHeight = 480; 1915 int viewportHeight = 480;
1916 1916
1917 FrameTestHelpers::WebViewHelper webViewHelper(this); 1917 FrameTestHelpers::WebViewHelper webViewHelper(this);
1918 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings); 1918 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings);
1919 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1919 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1920 1920
1921 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie w()->layoutCount(); 1921 int prevLayoutCount = webViewHelper.webView()->mainFrameImpl()->frameView()- >layoutCount();
1922 webViewHelper.webViewImpl()->setPageScaleFactor(30); 1922 webViewHelper.webView()->setPageScaleFactor(30);
1923 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout()); 1923 EXPECT_FALSE(webViewHelper.webView()->mainFrameImpl()->frameView()->needsLay out());
1924 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutCount()); 1924 EXPECT_EQ(prevLayoutCount, webViewHelper.webView()->mainFrameImpl()->frameVi ew()->layoutCount());
1925 1925
1926 } 1926 }
1927 1927
1928 TEST_P(ParameterizedWebFrameTest, pageScaleFactorWrittenToHistoryItem) 1928 TEST_P(ParameterizedWebFrameTest, pageScaleFactorWrittenToHistoryItem)
1929 { 1929 {
1930 registerMockedHttpURLLoad("fixed_layout.html"); 1930 registerMockedHttpURLLoad("fixed_layout.html");
1931 1931
1932 FixedLayoutTestWebViewClient client; 1932 FixedLayoutTestWebViewClient client;
1933 client.m_screenInfo.deviceScaleFactor = 1; 1933 client.m_screenInfo.deviceScaleFactor = 1;
1934 int viewportWidth = 640; 1934 int viewportWidth = 640;
1935 int viewportHeight = 480; 1935 int viewportHeight = 480;
1936 1936
1937 FrameTestHelpers::WebViewHelper webViewHelper(this); 1937 FrameTestHelpers::WebViewHelper webViewHelper(this);
1938 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings); 1938 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings);
1939 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1939 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1940 1940
1941 webViewHelper.webView()->setPageScaleFactor(3); 1941 webViewHelper.webView()->setPageScaleFactor(3);
1942 EXPECT_EQ(3, toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())- >loader().currentItem()->pageScaleFactor()); 1942 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loa der().currentItem()->pageScaleFactor());
1943 } 1943 }
1944 1944
1945 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) 1945 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem)
1946 { 1946 {
1947 registerMockedHttpURLLoad("fixed_layout.html"); 1947 registerMockedHttpURLLoad("fixed_layout.html");
1948 1948
1949 FixedLayoutTestWebViewClient client; 1949 FixedLayoutTestWebViewClient client;
1950 client.m_screenInfo.deviceScaleFactor = 1; 1950 client.m_screenInfo.deviceScaleFactor = 1;
1951 int viewportWidth = 640; 1951 int viewportWidth = 640;
1952 int viewportHeight = 480; 1952 int viewportHeight = 480;
1953 1953
1954 FrameTestHelpers::WebViewHelper webViewHelper(this); 1954 FrameTestHelpers::WebViewHelper webViewHelper(this);
1955 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings); 1955 webViewHelper.initialize(true, nullptr, &client, nullptr, enableViewportSett ings);
1956 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 1956 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
1957 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html"); 1957 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html");
1958 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1958 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1959 1959
1960 int defaultFixedLayoutWidth = 980; 1960 int defaultFixedLayoutWidth = 980;
1961 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid th; 1961 float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWid th;
1962 EXPECT_EQ(minimumPageScaleFactor, toLocalFrame(webViewHelper.webViewImpl()-> page()->mainFrame())->loader().currentItem()->pageScaleFactor()); 1962 EXPECT_EQ(minimumPageScaleFactor, toLocalFrame(webViewHelper.webView()->page ()->mainFrame())->loader().currentItem()->pageScaleFactor());
1963 } 1963 }
1964 1964
1965 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) 1965 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView)
1966 { 1966 {
1967 registerMockedHttpURLLoad("large-div.html"); 1967 registerMockedHttpURLLoad("large-div.html");
1968 1968
1969 FixedLayoutTestWebViewClient client; 1969 FixedLayoutTestWebViewClient client;
1970 client.m_screenInfo.deviceScaleFactor = 1; 1970 client.m_screenInfo.deviceScaleFactor = 1;
1971 // Small viewport to ensure there are always scrollbars. 1971 // Small viewport to ensure there are always scrollbars.
1972 int viewportWidth = 64; 1972 int viewportWidth = 64;
1973 int viewportHeight = 48; 1973 int viewportHeight = 48;
1974 1974
1975 FrameTestHelpers::WebViewHelper webViewHelper(this); 1975 FrameTestHelpers::WebViewHelper webViewHelper(this);
1976 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr, &client, nullptr, enableViewportSettings); 1976 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr, &client, nullptr, enableViewportSettings);
1977 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 1977 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1978 1978
1979 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 1979 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
1980 int viewportWidthMinusScrollbar = viewportWidth; 1980 int viewportWidthMinusScrollbar = viewportWidth;
1981 int viewportHeightMinusScrollbar = viewportHeight; 1981 int viewportHeightMinusScrollbar = viewportHeight;
1982 1982
1983 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScroll bar()) 1983 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScroll bar())
1984 viewportWidthMinusScrollbar -= 15; 1984 viewportWidthMinusScrollbar -= 15;
1985 1985
1986 if (view->horizontalScrollbar() && !view->horizontalScrollbar()->isOverlaySc rollbar()) 1986 if (view->horizontalScrollbar() && !view->horizontalScrollbar()->isOverlaySc rollbar())
1987 viewportHeightMinusScrollbar -= 15; 1987 viewportHeightMinusScrollbar -= 15;
1988 1988
1989 webViewHelper.webView()->setPageScaleFactor(2); 1989 webViewHelper.webView()->setPageScaleFactor(2);
(...skipping 19 matching lines...) Expand all
2009 client.m_screenInfo.deviceScaleFactor = 1; 2009 client.m_screenInfo.deviceScaleFactor = 1;
2010 int viewportWidth = 640; 2010 int viewportWidth = 640;
2011 int viewportHeight = 480; 2011 int viewportHeight = 480;
2012 2012
2013 FrameTestHelpers::WebViewHelper webViewHelper(this); 2013 FrameTestHelpers::WebViewHelper webViewHelper(this);
2014 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings); 2014 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings);
2015 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2015 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2016 2016
2017 webViewHelper.webView()->setPageScaleFactor(2); 2017 webViewHelper.webView()->setPageScaleFactor(2);
2018 2018
2019 EXPECT_EQ(980, toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame() )->contentLayoutItem().documentRect().width()); 2019 EXPECT_EQ(980, toLocalFrame(webViewHelper.webView()->page()->mainFrame())->c ontentLayoutItem().documentRect().width());
2020 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co ntentsSize().width()); 2020 EXPECT_EQ(980, webViewHelper.webView()->mainFrameImpl()->frameView()->conten tsSize().width());
2021 } 2021 }
2022 2022
2023 TEST_P(ParameterizedWebFrameTest, targetDensityDpiHigh) 2023 TEST_P(ParameterizedWebFrameTest, targetDensityDpiHigh)
2024 { 2024 {
2025 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); 2025 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html");
2026 2026
2027 FixedLayoutTestWebViewClient client; 2027 FixedLayoutTestWebViewClient client;
2028 // high-dpi = 240 2028 // high-dpi = 240
2029 float targetDpi = 240.0f; 2029 float targetDpi = 240.0f;
2030 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; 2030 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f };
2031 int viewportWidth = 640; 2031 int viewportWidth = 640;
2032 int viewportHeight = 480; 2032 int viewportHeight = 480;
2033 2033
2034 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { 2034 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) {
2035 float deviceScaleFactor = deviceScaleFactors[i]; 2035 float deviceScaleFactor = deviceScaleFactors[i];
2036 float deviceDpi = deviceScaleFactor * 160.0f; 2036 float deviceDpi = deviceScaleFactor * 160.0f;
2037 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; 2037 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor;
2038 2038
2039 FrameTestHelpers::WebViewHelper webViewHelper(this); 2039 FrameTestHelpers::WebViewHelper webViewHelper(this);
2040 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi- high.html", true, nullptr, &client, nullptr, enableViewportSettings); 2040 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi- high.html", true, nullptr, &client, nullptr, enableViewportSettings);
2041 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2041 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2042 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP I(true); 2042 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP I(true);
2043 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2043 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2044 2044
2045 // We need to account for the fact that logical pixels are unconditional ly multiplied by deviceScaleFactor to produce 2045 // We need to account for the fact that logical pixels are unconditional ly multiplied by deviceScaleFactor to produce
2046 // physical pixels. 2046 // physical pixels.
2047 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; 2047 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi;
2048 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webViewI mpl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); 2048 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webView( )->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
2049 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView Impl()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); 2049 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView ()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
2050 EXPECT_NEAR(1.0f / densityDpiScaleRatio, webViewHelper.webView()->pageSc aleFactor(), 0.01f); 2050 EXPECT_NEAR(1.0f / densityDpiScaleRatio, webViewHelper.webView()->pageSc aleFactor(), 0.01f);
2051 } 2051 }
2052 } 2052 }
2053 2053
2054 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDevice) 2054 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDevice)
2055 { 2055 {
2056 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); 2056 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html");
2057 2057
2058 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; 2058 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f };
2059 2059
2060 FixedLayoutTestWebViewClient client; 2060 FixedLayoutTestWebViewClient client;
2061 int viewportWidth = 640; 2061 int viewportWidth = 640;
2062 int viewportHeight = 480; 2062 int viewportHeight = 480;
2063 2063
2064 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { 2064 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) {
2065 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; 2065 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i];
2066 2066
2067 FrameTestHelpers::WebViewHelper webViewHelper(this); 2067 FrameTestHelpers::WebViewHelper webViewHelper(this);
2068 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi- device.html", true, nullptr, &client, nullptr, enableViewportSettings); 2068 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi- device.html", true, nullptr, &client, nullptr, enableViewportSettings);
2069 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2069 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2070 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP I(true); 2070 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP I(true);
2071 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2071 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2072 2072
2073 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webVi ewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f ); 2073 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webVi ewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
2074 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webV iewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height(), 1. 0f); 2074 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webV iewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
2075 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper. webView()->pageScaleFactor(), 0.01f); 2075 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper. webView()->pageScaleFactor(), 0.01f);
2076 } 2076 }
2077 } 2077 }
2078 2078
2079 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDeviceAndFixedWidth) 2079 TEST_P(ParameterizedWebFrameTest, targetDensityDpiDeviceAndFixedWidth)
2080 { 2080 {
2081 registerMockedHttpURLLoad("viewport-target-densitydpi-device-and-fixed-width .html"); 2081 registerMockedHttpURLLoad("viewport-target-densitydpi-device-and-fixed-width .html");
2082 2082
2083 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; 2083 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f };
2084 2084
2085 FixedLayoutTestWebViewClient client; 2085 FixedLayoutTestWebViewClient client;
2086 int viewportWidth = 640; 2086 int viewportWidth = 640;
2087 int viewportHeight = 480; 2087 int viewportHeight = 480;
2088 2088
2089 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) { 2089 for (size_t i = 0; i < WTF_ARRAY_LENGTH(deviceScaleFactors); ++i) {
2090 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; 2090 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i];
2091 2091
2092 FrameTestHelpers::WebViewHelper webViewHelper(this); 2092 FrameTestHelpers::WebViewHelper webViewHelper(this);
2093 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi- device-and-fixed-width.html", true, nullptr, &client, nullptr, enableViewportSet tings); 2093 webViewHelper.initializeAndLoad(m_baseURL + "viewport-target-densitydpi- device-and-fixed-width.html", true, nullptr, &client, nullptr, enableViewportSet tings);
2094 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2094 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2095 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP I(true); 2095 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDP I(true);
2096 webViewHelper.webView()->settings()->setUseWideViewport(true); 2096 webViewHelper.webView()->settings()->setUseWideViewport(true);
2097 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2097 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2098 2098
2099 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()- >frameView()->layoutSize().width(), 1.0f); 2099 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f);
2100 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl() ->frameView()->layoutSize().height(), 1.0f); 2100 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f);
2101 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); 2101 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
2102 } 2102 }
2103 } 2103 }
2104 2104
2105 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOne) 2105 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOne)
2106 { 2106 {
2107 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1.html"); 2107 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1.html");
2108 2108
2109 FixedLayoutTestWebViewClient client; 2109 FixedLayoutTestWebViewClient client;
2110 client.m_screenInfo.deviceScaleFactor = 1.33f; 2110 client.m_screenInfo.deviceScaleFactor = 1.33f;
2111 int viewportWidth = 640; 2111 int viewportWidth = 640;
2112 int viewportHeight = 480; 2112 int viewportHeight = 480;
2113 2113
2114 FrameTestHelpers::WebViewHelper webViewHelper(this); 2114 FrameTestHelpers::WebViewHelper webViewHelper(this);
2115 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha n-1.html", true, nullptr, &client, nullptr, enableViewportSettings); 2115 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha n-1.html", true, nullptr, &client, nullptr, enableViewportSettings);
2116 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue); 2116 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue);
2117 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2117 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2118 webViewHelper.webView()->settings()->setUseWideViewport(false); 2118 webViewHelper.webView()->settings()->setUseWideViewport(false);
2119 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2119 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2120 2120
2121 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe lper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); 2121 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe lper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
2122 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH elper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); 2122 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH elper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
2123 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f); 2123 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
2124 } 2124 }
2125 2125
2126 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOneWithDeviceWid th) 2126 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndScaleLessThanOneWithDeviceWid th)
2127 { 2127 {
2128 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1-device-width.h tml"); 2128 registerMockedHttpURLLoad("viewport-initial-scale-less-than-1-device-width.h tml");
2129 2129
2130 FixedLayoutTestWebViewClient client; 2130 FixedLayoutTestWebViewClient client;
2131 client.m_screenInfo.deviceScaleFactor = 1.33f; 2131 client.m_screenInfo.deviceScaleFactor = 1.33f;
2132 int viewportWidth = 640; 2132 int viewportWidth = 640;
2133 int viewportHeight = 480; 2133 int viewportHeight = 480;
2134 2134
2135 FrameTestHelpers::WebViewHelper webViewHelper(this); 2135 FrameTestHelpers::WebViewHelper webViewHelper(this);
2136 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha n-1-device-width.html", true, nullptr, &client, nullptr, enableViewportSettings) ; 2136 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-less-tha n-1-device-width.html", true, nullptr, &client, nullptr, enableViewportSettings) ;
2137 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue); 2137 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue);
2138 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2138 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2139 webViewHelper.webView()->settings()->setUseWideViewport(false); 2139 webViewHelper.webView()->settings()->setUseWideViewport(false);
2140 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2140 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2141 2141
2142 const float pageZoom = 0.25f; 2142 const float pageZoom = 0.25f;
2143 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom , webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width( ), 1.0f); 2143 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom , webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1 .0f);
2144 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo m, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().heigh t(), 1.0f); 2144 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo m, webViewHelper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
2145 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f); 2145 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
2146 } 2146 }
2147 2147
2148 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndNoViewportWithInitialPageScal eOverride) 2148 TEST_P(ParameterizedWebFrameTest, NoWideViewportAndNoViewportWithInitialPageScal eOverride)
2149 { 2149 {
2150 registerMockedHttpURLLoad("large-div.html"); 2150 registerMockedHttpURLLoad("large-div.html");
2151 2151
2152 FixedLayoutTestWebViewClient client; 2152 FixedLayoutTestWebViewClient client;
2153 int viewportWidth = 640; 2153 int viewportWidth = 640;
2154 int viewportHeight = 480; 2154 int viewportHeight = 480;
2155 float enforcedPageScaleFactor = 5.0f; 2155 float enforcedPageScaleFactor = 5.0f;
2156 2156
2157 FrameTestHelpers::WebViewHelper webViewHelper(this); 2157 FrameTestHelpers::WebViewHelper webViewHelper(this);
2158 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr, &client, nullptr, enableViewportSettings); 2158 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr, &client, nullptr, enableViewportSettings);
2159 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 2159 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
2160 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2160 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2161 webViewHelper.webView()->settings()->setUseWideViewport(false); 2161 webViewHelper.webView()->settings()->setUseWideViewport(false);
2162 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor ); 2162 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor );
2163 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2163 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2164 2164
2165 EXPECT_NEAR(viewportWidth / enforcedPageScaleFactor, webViewHelper.webViewIm pl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); 2165 EXPECT_NEAR(viewportWidth / enforcedPageScaleFactor, webViewHelper.webView() ->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
2166 EXPECT_NEAR(viewportHeight / enforcedPageScaleFactor, webViewHelper.webViewI mpl()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); 2166 EXPECT_NEAR(viewportHeight / enforcedPageScaleFactor, webViewHelper.webView( )->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
2167 EXPECT_NEAR(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFacto r(), 0.01f); 2167 EXPECT_NEAR(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFacto r(), 0.01f);
2168 } 2168 }
2169 2169
2170 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScale) 2170 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScale)
2171 { 2171 {
2172 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" ); 2172 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" );
2173 2173
2174 FixedLayoutTestWebViewClient client; 2174 FixedLayoutTestWebViewClient client;
2175 int viewportWidth = 640; 2175 int viewportWidth = 640;
2176 int viewportHeight = 480; 2176 int viewportHeight = 480;
2177 2177
2178 FrameTestHelpers::WebViewHelper webViewHelper(this); 2178 FrameTestHelpers::WebViewHelper webViewHelper(this);
2179 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings); 2179 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings);
2180 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e); 2180 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
2181 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2181 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2182 2182
2183 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f); 2183 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameVi ew()->layoutSize().width(), 1.0f);
2184 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f); 2184 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameV iew()->layoutSize().height(), 1.0f);
2185 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); 2185 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
2186 } 2186 }
2187 2187
2188 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForNonW ideViewport) 2188 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForNonW ideViewport)
2189 { 2189 {
2190 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" ); 2190 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" );
2191 2191
2192 FixedLayoutTestWebViewClient client; 2192 FixedLayoutTestWebViewClient client;
2193 client.m_screenInfo.deviceScaleFactor = 1.33f; 2193 client.m_screenInfo.deviceScaleFactor = 1.33f;
2194 int viewportWidth = 640; 2194 int viewportWidth = 640;
2195 int viewportHeight = 480; 2195 int viewportHeight = 480;
2196 2196
2197 FrameTestHelpers::WebViewHelper webViewHelper(this); 2197 FrameTestHelpers::WebViewHelper webViewHelper(this);
2198 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings); 2198 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, nullptr, &client, nullptr, enableViewportSettings);
2199 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue); 2199 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue);
2200 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e); 2200 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
2201 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2201 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2202 webViewHelper.webView()->settings()->setUseWideViewport(false); 2202 webViewHelper.webView()->settings()->setUseWideViewport(false);
2203 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2203 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2204 2204
2205 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe lper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f); 2205 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe lper.webView()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
2206 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH elper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f); 2206 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH elper.webView()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
2207 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f); 2207 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
2208 } 2208 }
2209 2209
2210 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForWide Viewport) 2210 TEST_P(ParameterizedWebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForWide Viewport)
2211 { 2211 {
2212 registerMockedHttpURLLoad("viewport-2x-initial-scale-non-user-scalable.html" ); 2212 registerMockedHttpURLLoad("viewport-2x-initial-scale-non-user-scalable.html" );
2213 2213
2214 FixedLayoutTestWebViewClient client; 2214 FixedLayoutTestWebViewClient client;
2215 int viewportWidth = 640; 2215 int viewportWidth = 640;
2216 int viewportHeight = 480; 2216 int viewportHeight = 480;
2217 2217
2218 FrameTestHelpers::WebViewHelper webViewHelper(this); 2218 FrameTestHelpers::WebViewHelper webViewHelper(this);
2219 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale-non-u ser-scalable.html", true, nullptr, &client, nullptr, enableViewportSettings); 2219 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale-non-u ser-scalable.html", true, nullptr, &client, nullptr, enableViewportSettings);
2220 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e); 2220 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
2221 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2221 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2222 webViewHelper.webView()->settings()->setUseWideViewport(true); 2222 webViewHelper.webView()->settings()->setUseWideViewport(true);
2223 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2223 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2224 2224
2225 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f); 2225 EXPECT_NEAR(viewportWidth, webViewHelper.webView()->mainFrameImpl()->frameVi ew()->layoutSize().width(), 1.0f);
2226 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f); 2226 EXPECT_NEAR(viewportHeight, webViewHelper.webView()->mainFrameImpl()->frameV iew()->layoutSize().height(), 1.0f);
2227 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); 2227 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
2228 } 2228 }
2229 2229
2230 TEST_P(ParameterizedWebFrameTest, DesktopPageCanBeZoomedInWhenWideViewportIsTurn edOff) 2230 TEST_P(ParameterizedWebFrameTest, DesktopPageCanBeZoomedInWhenWideViewportIsTurn edOff)
2231 { 2231 {
2232 registerMockedHttpURLLoad("no_viewport_tag.html"); 2232 registerMockedHttpURLLoad("no_viewport_tag.html");
2233 2233
2234 FixedLayoutTestWebViewClient client; 2234 FixedLayoutTestWebViewClient client;
2235 int viewportWidth = 640; 2235 int viewportWidth = 640;
2236 int viewportHeight = 480; 2236 int viewportHeight = 480;
2237 2237
2238 FrameTestHelpers::WebViewHelper webViewHelper(this); 2238 FrameTestHelpers::WebViewHelper webViewHelper(this);
2239 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu llptr, &client, nullptr, enableViewportSettings); 2239 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, nu llptr, &client, nullptr, enableViewportSettings);
2240 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 2240 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
2241 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2241 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2242 webViewHelper.webView()->settings()->setUseWideViewport(false); 2242 webViewHelper.webView()->settings()->setUseWideViewport(false);
2243 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2243 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2244 2244
2245 EXPECT_NEAR(1.0f, webViewHelper.webViewImpl()->pageScaleFactor(), 0.01f); 2245 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
2246 EXPECT_NEAR(1.0f, webViewHelper.webViewImpl()->minimumPageScaleFactor(), 0.0 1f); 2246 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f);
2247 EXPECT_NEAR(5.0f, webViewHelper.webViewImpl()->maximumPageScaleFactor(), 0.0 1f); 2247 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f);
2248 } 2248 }
2249 2249
2250 class WebFrameResizeTest : public ParameterizedWebFrameTest { 2250 class WebFrameResizeTest : public ParameterizedWebFrameTest {
2251 protected: 2251 protected:
2252 2252
2253 static FloatSize computeRelativeOffset(const IntPoint& absoluteOffset, const LayoutRect& rect) 2253 static FloatSize computeRelativeOffset(const IntPoint& absoluteOffset, const LayoutRect& rect)
2254 { 2254 {
2255 FloatSize relativeOffset = FloatPoint(absoluteOffset) - FloatPoint(rect. location()); 2255 FloatSize relativeOffset = FloatPoint(absoluteOffset) - FloatPoint(rect. location());
2256 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); 2256 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height());
2257 return relativeOffset; 2257 return relativeOffset;
2258 } 2258 }
2259 2259
2260 void testResizeYieldsCorrectScrollAndScale(const char* url, 2260 void testResizeYieldsCorrectScrollAndScale(const char* url,
2261 const float initialPageScaleFacto r, 2261 const float initialPageScaleFacto r,
2262 const WebSize scrollOffset, 2262 const WebSize scrollOffset,
2263 const WebSize viewportSize, 2263 const WebSize viewportSize,
2264 const bool shouldScaleRelativeToV iewportWidth) { 2264 const bool shouldScaleRelativeToV iewportWidth) {
2265 registerMockedHttpURLLoad(url); 2265 registerMockedHttpURLLoad(url);
2266 2266
2267 const float aspectRatio = static_cast<float>(viewportSize.width) / viewp ortSize.height; 2267 const float aspectRatio = static_cast<float>(viewportSize.width) / viewp ortSize.height;
2268 2268
2269 FrameTestHelpers::WebViewHelper webViewHelper(this); 2269 FrameTestHelpers::WebViewHelper webViewHelper(this);
2270 webViewHelper.initializeAndLoad(m_baseURL + url, true, nullptr, nullptr, nullptr, enableViewportSettings); 2270 webViewHelper.initializeAndLoad(m_baseURL + url, true, nullptr, nullptr, nullptr, enableViewportSettings);
2271 webViewHelper.webViewImpl()->setDefaultPageScaleLimits(0.25f, 5); 2271 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
2272 2272
2273 // Origin scrollOffsets preserved under resize. 2273 // Origin scrollOffsets preserved under resize.
2274 { 2274 {
2275 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height )); 2275 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height ));
2276 webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFact or); 2276 webViewHelper.webView()->setPageScaleFactor(initialPageScaleFactor);
2277 ASSERT_EQ(viewportSize, webViewHelper.webViewImpl()->size()); 2277 ASSERT_EQ(viewportSize, webViewHelper.webView()->size());
2278 ASSERT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor()); 2278 ASSERT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale Factor());
2279 webViewHelper.resize(WebSize(viewportSize.height, viewportSize.width )); 2279 webViewHelper.resize(WebSize(viewportSize.height, viewportSize.width ));
2280 float expectedPageScaleFactor = initialPageScaleFactor * (shouldScal eRelativeToViewportWidth ? 1 / aspectRatio : 1); 2280 float expectedPageScaleFactor = initialPageScaleFactor * (shouldScal eRelativeToViewportWidth ? 1 / aspectRatio : 1);
2281 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa geScaleFactor(), 0.05f); 2281 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webView()->pageSc aleFactor(), 0.05f);
2282 EXPECT_EQ(WebSize(), webViewHelper.webViewImpl()->mainFrame()->scrol lOffset()); 2282 EXPECT_EQ(WebSize(), webViewHelper.webView()->mainFrame()->scrollOff set());
2283 } 2283 }
2284 2284
2285 // Resizing just the height should not affect pageScaleFactor or scrollO ffset. 2285 // Resizing just the height should not affect pageScaleFactor or scrollO ffset.
2286 { 2286 {
2287 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height )); 2287 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height ));
2288 webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFact or); 2288 webViewHelper.webView()->setPageScaleFactor(initialPageScaleFactor);
2289 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs et); 2289 webViewHelper.webView()->mainFrame()->setScrollOffset(scrollOffset);
2290 webViewHelper.webViewImpl()->updateAllLifecyclePhases(); 2290 webViewHelper.webView()->updateAllLifecyclePhases();
2291 const WebSize expectedScrollOffset = webViewHelper.webViewImpl()->ma inFrame()->scrollOffset(); 2291 const WebSize expectedScrollOffset = webViewHelper.webView()->mainFr ame()->scrollOffset();
2292 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); 2292 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height * 0.8f));
2293 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor()); 2293 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale Factor());
2294 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset()); 2294 EXPECT_EQ(expectedScrollOffset, webViewHelper.webView()->mainFrame() ->scrollOffset());
2295 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); 2295 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height * 0.8f));
2296 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor()); 2296 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webView()->pageScale Factor());
2297 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset()); 2297 EXPECT_EQ(expectedScrollOffset, webViewHelper.webView()->mainFrame() ->scrollOffset());
2298 } 2298 }
2299 } 2299 }
2300 }; 2300 };
2301 2301
2302 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values( 2302 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values(
2303 FrameTestHelpers::DefaultSettingOverride, 2303 FrameTestHelpers::DefaultSettingOverride,
2304 FrameTestHelpers::RootLayerScrollsSettingOverride)); 2304 FrameTestHelpers::RootLayerScrollsSettingOverride));
2305 2305
2306 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice Width) 2306 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice Width)
2307 { 2307 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 2365
2366 FixedLayoutTestWebViewClient client; 2366 FixedLayoutTestWebViewClient client;
2367 client.m_screenInfo.deviceScaleFactor = 1; 2367 client.m_screenInfo.deviceScaleFactor = 1;
2368 int viewportWidth = 640; 2368 int viewportWidth = 640;
2369 int viewportHeight = 480; 2369 int viewportHeight = 480;
2370 2370
2371 FrameTestHelpers::WebViewHelper webViewHelper(this); 2371 FrameTestHelpers::WebViewHelper webViewHelper(this);
2372 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings); 2372 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, nullp tr, &client, nullptr, enableViewportSettings);
2373 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2373 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2374 2374
2375 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 2375 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
2376 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width( ) - view->visibleContentRect().width()); 2376 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width( ) - view->visibleContentRect().width());
2377 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height() - view->visibleContentRect().height()); 2377 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height() - view->visibleContentRect().height());
2378 2378
2379 webViewHelper.webView()->setPageScaleFactor(10); 2379 webViewHelper.webView()->setPageScaleFactor(10);
2380 2380
2381 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width( ) - view->visibleContentRect().width()); 2381 EXPECT_EQ(view->scrollSize(HorizontalScrollbar), view->contentsSize().width( ) - view->visibleContentRect().width());
2382 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height() - view->visibleContentRect().height()); 2382 EXPECT_EQ(view->scrollSize(VerticalScrollbar), view->contentsSize().height() - view->visibleContentRect().height());
2383 } 2383 }
2384 2384
2385 TEST_P(ParameterizedWebFrameTest, CanOverrideScaleLimits) 2385 TEST_P(ParameterizedWebFrameTest, CanOverrideScaleLimits)
2386 { 2386 {
2387 registerMockedHttpURLLoad("no_scale_for_you.html"); 2387 registerMockedHttpURLLoad("no_scale_for_you.html");
2388 2388
2389 FixedLayoutTestWebViewClient client; 2389 FixedLayoutTestWebViewClient client;
2390 client.m_screenInfo.deviceScaleFactor = 1; 2390 client.m_screenInfo.deviceScaleFactor = 1;
2391 int viewportWidth = 640; 2391 int viewportWidth = 640;
2392 int viewportHeight = 480; 2392 int viewportHeight = 480;
2393 2393
2394 FrameTestHelpers::WebViewHelper webViewHelper(this); 2394 FrameTestHelpers::WebViewHelper webViewHelper(this);
2395 webViewHelper.initializeAndLoad(m_baseURL + "no_scale_for_you.html", true, n ullptr, &client, nullptr, enableViewportSettings); 2395 webViewHelper.initializeAndLoad(m_baseURL + "no_scale_for_you.html", true, n ullptr, &client, nullptr, enableViewportSettings);
2396 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 2396 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
2397 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2397 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2398 2398
2399 EXPECT_EQ(2.0f, webViewHelper.webViewImpl()->minimumPageScaleFactor()); 2399 EXPECT_EQ(2.0f, webViewHelper.webView()->minimumPageScaleFactor());
2400 EXPECT_EQ(2.0f, webViewHelper.webViewImpl()->maximumPageScaleFactor()); 2400 EXPECT_EQ(2.0f, webViewHelper.webView()->maximumPageScaleFactor());
2401 2401
2402 webViewHelper.webView()->setIgnoreViewportTagScaleLimits(true); 2402 webViewHelper.webView()->setIgnoreViewportTagScaleLimits(true);
2403 webViewHelper.webView()->updateAllLifecyclePhases(); 2403 webViewHelper.webView()->updateAllLifecyclePhases();
2404 2404
2405 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->minimumPageScaleFactor()); 2405 EXPECT_EQ(1.0f, webViewHelper.webView()->minimumPageScaleFactor());
2406 EXPECT_EQ(5.0f, webViewHelper.webViewImpl()->maximumPageScaleFactor()); 2406 EXPECT_EQ(5.0f, webViewHelper.webView()->maximumPageScaleFactor());
2407 2407
2408 webViewHelper.webView()->setIgnoreViewportTagScaleLimits(false); 2408 webViewHelper.webView()->setIgnoreViewportTagScaleLimits(false);
2409 webViewHelper.webView()->updateAllLifecyclePhases(); 2409 webViewHelper.webView()->updateAllLifecyclePhases();
2410 2410
2411 EXPECT_EQ(2.0f, webViewHelper.webViewImpl()->minimumPageScaleFactor()); 2411 EXPECT_EQ(2.0f, webViewHelper.webView()->minimumPageScaleFactor());
2412 EXPECT_EQ(2.0f, webViewHelper.webViewImpl()->maximumPageScaleFactor()); 2412 EXPECT_EQ(2.0f, webViewHelper.webView()->maximumPageScaleFactor());
2413 } 2413 }
2414 2414
2415 // Android doesn't have scrollbars on the main FrameView 2415 // Android doesn't have scrollbars on the main FrameView
2416 #if OS(ANDROID) 2416 #if OS(ANDROID)
2417 TEST_F(WebFrameTest, DISABLED_updateOverlayScrollbarLayers) 2417 TEST_F(WebFrameTest, DISABLED_updateOverlayScrollbarLayers)
2418 #else 2418 #else
2419 TEST_F(WebFrameTest, updateOverlayScrollbarLayers) 2419 TEST_F(WebFrameTest, updateOverlayScrollbarLayers)
2420 #endif 2420 #endif
2421 { 2421 {
2422 registerMockedHttpURLLoad("large-div.html"); 2422 registerMockedHttpURLLoad("large-div.html");
2423 2423
2424 int viewWidth = 500; 2424 int viewWidth = 500;
2425 int viewHeight = 500; 2425 int viewHeight = 500;
2426 2426
2427 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient()); 2427 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient());
2428 FrameTestHelpers::WebViewHelper webViewHelper; 2428 FrameTestHelpers::WebViewHelper webViewHelper;
2429 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView); 2429 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView);
2430 2430
2431 webViewHelper.resize(WebSize(viewWidth, viewHeight)); 2431 webViewHelper.resize(WebSize(viewWidth, viewHeight));
2432 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html"); 2432 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html");
2433 2433
2434 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 2434 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
2435 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForHorizontalScrollbar ()); 2435 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForHorizontalScrollbar ());
2436 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForVerticalScrollbar() ); 2436 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForVerticalScrollbar() );
2437 2437
2438 webViewHelper.resize(WebSize(viewWidth * 10, viewHeight * 10)); 2438 webViewHelper.resize(WebSize(viewWidth * 10, viewHeight * 10));
2439 EXPECT_FALSE(view->layoutViewItem().compositor()->layerForHorizontalScrollba r()); 2439 EXPECT_FALSE(view->layoutViewItem().compositor()->layerForHorizontalScrollba r());
2440 EXPECT_FALSE(view->layoutViewItem().compositor()->layerForVerticalScrollbar( )); 2440 EXPECT_FALSE(view->layoutViewItem().compositor()->layerForVerticalScrollbar( ));
2441 } 2441 }
2442 2442
2443 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca le) 2443 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca le)
2444 { 2444 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 webViewHelper.webView()->setPageScaleFactor(0.5f); 2483 webViewHelper.webView()->setPageScaleFactor(0.5f);
2484 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2484 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2485 2485
2486 WebRect wideDiv(200, 100, 400, 150); 2486 WebRect wideDiv(200, 100, 400, 150);
2487 WebRect tallDiv(200, 300, 400, 800); 2487 WebRect tallDiv(200, 300, 400, 800);
2488 WebPoint doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50); 2488 WebPoint doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50);
2489 WebPoint doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50); 2489 WebPoint doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50);
2490 float scale; 2490 float scale;
2491 WebPoint scroll; 2491 WebPoint scroll;
2492 2492
2493 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; 2493 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag eScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
2494 2494
2495 // Test double-tap zooming into wide div. 2495 // Test double-tap zooming into wide div.
2496 WebRect wideBlockBound = webViewHelper.webViewImpl()->computeBlockBound(doub leTapPointWide, false); 2496 WebRect wideBlockBound = webViewHelper.webView()->computeBlockBound(doubleTa pPointWide, false);
2497 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub leTapPointWide.x, doubleTapPointWide.y), wideBlockBound, touchPointPadding, doub leTapZoomAlreadyLegibleScale, scale, scroll); 2497 webViewHelper.webView()->computeScaleAndScrollForBlockRect(WebPoint(doubleTa pPointWide.x, doubleTapPointWide.y), wideBlockBound, touchPointPadding, doubleTa pZoomAlreadyLegibleScale, scale, scroll);
2498 // The div should horizontally fill the screen (modulo margins), and 2498 // The div should horizontally fill the screen (modulo margins), and
2499 // vertically centered (modulo integer rounding). 2499 // vertically centered (modulo integer rounding).
2500 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); 2500 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
2501 EXPECT_NEAR(wideDiv.x, scroll.x, 20); 2501 EXPECT_NEAR(wideDiv.x, scroll.x, 20);
2502 EXPECT_EQ(0, scroll.y); 2502 EXPECT_EQ(0, scroll.y);
2503 2503
2504 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); 2504 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, scale);
2505 2505
2506 // Test zoom out back to minimum scale. 2506 // Test zoom out back to minimum scale.
2507 wideBlockBound = webViewHelper.webViewImpl()->computeBlockBound(doubleTapPoi ntWide, false); 2507 wideBlockBound = webViewHelper.webView()->computeBlockBound(doubleTapPointWi de, false);
2508 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub leTapPointWide.x, doubleTapPointWide.y), wideBlockBound, touchPointPadding, doub leTapZoomAlreadyLegibleScale, scale, scroll); 2508 webViewHelper.webView()->computeScaleAndScrollForBlockRect(WebPoint(doubleTa pPointWide.x, doubleTapPointWide.y), wideBlockBound, touchPointPadding, doubleTa pZoomAlreadyLegibleScale, scale, scroll);
2509 // FIXME: Looks like we are missing EXPECTs here. 2509 // FIXME: Looks like we are missing EXPECTs here.
2510 2510
2511 scale = webViewHelper.webViewImpl()->minimumPageScaleFactor(); 2511 scale = webViewHelper.webView()->minimumPageScaleFactor();
2512 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), scal e); 2512 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), scale);
2513 2513
2514 // Test double-tap zooming into tall div. 2514 // Test double-tap zooming into tall div.
2515 WebRect tallBlockBound = webViewHelper.webViewImpl()->computeBlockBound(doub leTapPointTall, false); 2515 WebRect tallBlockBound = webViewHelper.webView()->computeBlockBound(doubleTa pPointTall, false);
2516 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub leTapPointTall.x, doubleTapPointTall.y), tallBlockBound, touchPointPadding, doub leTapZoomAlreadyLegibleScale, scale, scroll); 2516 webViewHelper.webView()->computeScaleAndScrollForBlockRect(WebPoint(doubleTa pPointTall.x, doubleTapPointTall.y), tallBlockBound, touchPointPadding, doubleTa pZoomAlreadyLegibleScale, scale, scroll);
2517 // The div should start at the top left of the viewport. 2517 // The div should start at the top left of the viewport.
2518 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); 2518 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1);
2519 EXPECT_NEAR(tallDiv.x, scroll.x, 20); 2519 EXPECT_NEAR(tallDiv.x, scroll.x, 20);
2520 EXPECT_NEAR(tallDiv.y, scroll.y, 20); 2520 EXPECT_NEAR(tallDiv.y, scroll.y, 20);
2521 } 2521 }
2522 2522
2523 TEST_P(ParameterizedWebFrameTest, DivAutoZoomWideDivTest) 2523 TEST_P(ParameterizedWebFrameTest, DivAutoZoomWideDivTest)
2524 { 2524 {
2525 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); 2525 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html");
2526 2526
2527 const float deviceScaleFactor = 2.0f; 2527 const float deviceScaleFactor = 2.0f;
2528 int viewportWidth = 640 / deviceScaleFactor; 2528 int viewportWidth = 640 / deviceScaleFactor;
2529 int viewportHeight = 1280 / deviceScaleFactor; 2529 int viewportHeight = 1280 / deviceScaleFactor;
2530 float doubleTapZoomAlreadyLegibleRatio = 1.2f; 2530 float doubleTapZoomAlreadyLegibleRatio = 1.2f;
2531 FrameTestHelpers::WebViewHelper webViewHelper(this); 2531 FrameTestHelpers::WebViewHelper webViewHelper(this);
2532 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test .html", false, nullptr, nullptr, nullptr, configureAndroid); 2532 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test .html", false, nullptr, nullptr, nullptr, configureAndroid);
2533 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2533 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2534 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); 2534 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor);
2535 webViewHelper.webView()->setPageScaleFactor(1.0f); 2535 webViewHelper.webView()->setPageScaleFactor(1.0f);
2536 webViewHelper.webView()->updateAllLifecyclePhases(); 2536 webViewHelper.webView()->updateAllLifecyclePhases();
2537 2537
2538 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2538 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2539 2539
2540 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; 2540 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag eScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
2541 2541
2542 WebRect div(0, 100, viewportWidth, 150); 2542 WebRect div(0, 100, viewportWidth, 150);
2543 WebPoint point(div.x + 50, div.y + 50); 2543 WebPoint point(div.x + 50, div.y + 50);
2544 float scale; 2544 float scale;
2545 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2545 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2546 2546
2547 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); 2547 simulateDoubleTap(webViewHelper.webView(), point, scale);
2548 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2548 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2549 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); 2549 simulateDoubleTap(webViewHelper.webView(), point, scale);
2550 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2550 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2551 } 2551 }
2552 2552
2553 TEST_P(ParameterizedWebFrameTest, DivAutoZoomVeryTallTest) 2553 TEST_P(ParameterizedWebFrameTest, DivAutoZoomVeryTallTest)
2554 { 2554 {
2555 // When a block is taller than the viewport and a zoom targets a lower part 2555 // When a block is taller than the viewport and a zoom targets a lower part
2556 // of it, then we should keep the target point onscreen instead of snapping 2556 // of it, then we should keep the target point onscreen instead of snapping
2557 // back up the top of the block. 2557 // back up the top of the block.
2558 registerMockedHttpURLLoad("very_tall_div.html"); 2558 registerMockedHttpURLLoad("very_tall_div.html");
2559 2559
2560 const float deviceScaleFactor = 2.0f; 2560 const float deviceScaleFactor = 2.0f;
2561 int viewportWidth = 640 / deviceScaleFactor; 2561 int viewportWidth = 640 / deviceScaleFactor;
2562 int viewportHeight = 1280 / deviceScaleFactor; 2562 int viewportHeight = 1280 / deviceScaleFactor;
2563 FrameTestHelpers::WebViewHelper webViewHelper(this); 2563 FrameTestHelpers::WebViewHelper webViewHelper(this);
2564 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, null ptr, nullptr, nullptr, configureAndroid); 2564 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, null ptr, nullptr, nullptr, configureAndroid);
2565 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2565 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2566 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); 2566 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor);
2567 webViewHelper.webView()->setPageScaleFactor(1.0f); 2567 webViewHelper.webView()->setPageScaleFactor(1.0f);
2568 webViewHelper.webView()->updateAllLifecyclePhases(); 2568 webViewHelper.webView()->updateAllLifecyclePhases();
2569 2569
2570 WebRect div(200, 300, 400, 5000); 2570 WebRect div(200, 300, 400, 5000);
2571 WebPoint point(div.x + 50, div.y + 3000); 2571 WebPoint point(div.x + 50, div.y + 3000);
2572 float scale; 2572 float scale;
2573 WebPoint scroll; 2573 WebPoint scroll;
2574 2574
2575 WebRect blockBound = webViewHelper.webViewImpl()->computeBlockBound(point, t rue); 2575 WebRect blockBound = webViewHelper.webView()->computeBlockBound(point, true) ;
2576 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB ound, 0, 1.0f, scale, scroll); 2576 webViewHelper.webView()->computeScaleAndScrollForBlockRect(point, blockBound , 0, 1.0f, scale, scroll);
2577 EXPECT_EQ(scale, 1.0f); 2577 EXPECT_EQ(scale, 1.0f);
2578 EXPECT_EQ(scroll.y, 2660); 2578 EXPECT_EQ(scroll.y, 2660);
2579 } 2579 }
2580 2580
2581 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) 2581 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest)
2582 { 2582 {
2583 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); 2583 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
2584 2584
2585 const float deviceScaleFactor = 2.0f; 2585 const float deviceScaleFactor = 2.0f;
2586 int viewportWidth = 640 / deviceScaleFactor; 2586 int viewportWidth = 640 / deviceScaleFactor;
2587 int viewportHeight = 1280 / deviceScaleFactor; 2587 int viewportHeight = 1280 / deviceScaleFactor;
2588 float doubleTapZoomAlreadyLegibleRatio = 1.2f; 2588 float doubleTapZoomAlreadyLegibleRatio = 1.2f;
2589 FrameTestHelpers::WebViewHelper webViewHelper; 2589 FrameTestHelpers::WebViewHelper webViewHelper;
2590 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom _test.html", false, nullptr, nullptr, nullptr, configureAndroid); 2590 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom _test.html", false, nullptr, nullptr, nullptr, configureAndroid);
2591 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2591 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2592 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); 2592 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4);
2593 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); 2593 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor);
2594 webViewHelper.webView()->setPageScaleFactor(0.5f); 2594 webViewHelper.webView()->setPageScaleFactor(0.5f);
2595 webViewHelper.webView()->setMaximumLegibleScale(1.f); 2595 webViewHelper.webView()->setMaximumLegibleScale(1.f);
2596 webViewHelper.webView()->updateAllLifecyclePhases(); 2596 webViewHelper.webView()->updateAllLifecyclePhases();
2597 2597
2598 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2598 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2599 2599
2600 WebRect topDiv(200, 100, 200, 150); 2600 WebRect topDiv(200, 100, 200, 150);
2601 WebRect bottomDiv(200, 300, 200, 150); 2601 WebRect bottomDiv(200, 300, 200, 150);
2602 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); 2602 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50);
2603 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); 2603 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50);
2604 float scale; 2604 float scale;
2605 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2605 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2606 2606
2607 // Test double tap on two different divs 2607 // Test double tap on two different divs
2608 // After first zoom, we should go back to minimum page scale with a second d ouble tap. 2608 // After first zoom, we should go back to minimum page scale with a second d ouble tap.
2609 simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); 2609 simulateDoubleTap(webViewHelper.webView(), topPoint, scale);
2610 EXPECT_FLOAT_EQ(1, scale); 2610 EXPECT_FLOAT_EQ(1, scale);
2611 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); 2611 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale);
2612 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2612 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2613 2613
2614 // If the user pinch zooms after double tap, a second double tap should zoom back to the div. 2614 // If the user pinch zooms after double tap, a second double tap should zoom back to the div.
2615 simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); 2615 simulateDoubleTap(webViewHelper.webView(), topPoint, scale);
2616 EXPECT_FLOAT_EQ(1, scale); 2616 EXPECT_FLOAT_EQ(1, scale);
2617 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 0.6f, 0); 2617 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 0.6f, 0);
2618 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); 2618 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale);
2619 EXPECT_FLOAT_EQ(1, scale); 2619 EXPECT_FLOAT_EQ(1, scale);
2620 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); 2620 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale);
2621 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2621 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2622 2622
2623 // If we didn't yet get an auto-zoom update and a second double-tap arrives, should go back to minimum scale. 2623 // If we didn't yet get an auto-zoom update and a second double-tap arrives, should go back to minimum scale.
2624 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2624 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2625 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); 2625 webViewHelper.webView()->animateDoubleTapZoom(topPoint);
2626 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes ting()); 2626 EXPECT_TRUE(webViewHelper.webView()->fakeDoubleTapAnimationPendingForTesting ());
2627 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); 2627 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale);
2628 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2628 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2629 } 2629 }
2630 2630
2631 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) 2631 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest)
2632 { 2632 {
2633 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); 2633 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
2634 2634
2635 int viewportWidth = 320; 2635 int viewportWidth = 320;
2636 int viewportHeight = 480; 2636 int viewportHeight = 480;
2637 float doubleTapZoomAlreadyLegibleRatio = 1.2f; 2637 float doubleTapZoomAlreadyLegibleRatio = 1.2f;
2638 FrameTestHelpers::WebViewHelper webViewHelper; 2638 FrameTestHelpers::WebViewHelper webViewHelper;
2639 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto _zoom_test.html", false, nullptr, nullptr, nullptr, configureAndroid); 2639 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto _zoom_test.html", false, nullptr, nullptr, nullptr, configureAndroid);
2640 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2640 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2641 webViewHelper.webView()->setDeviceScaleFactor(1.5f); 2641 webViewHelper.webView()->setDeviceScaleFactor(1.5f);
2642 webViewHelper.webView()->setMaximumLegibleScale(1.f); 2642 webViewHelper.webView()->setMaximumLegibleScale(1.f);
2643 webViewHelper.webView()->updateAllLifecyclePhases(); 2643 webViewHelper.webView()->updateAllLifecyclePhases();
2644 2644
2645 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2645 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2646 2646
2647 WebRect div(200, 100, 200, 150); 2647 WebRect div(200, 100, 200, 150);
2648 WebPoint doubleTapPoint(div.x + 50, div.y + 50); 2648 WebPoint doubleTapPoint(div.x + 50, div.y + 50);
2649 float scale; 2649 float scale;
2650 2650
2651 // Test double tap scale bounds. 2651 // Test double tap scale bounds.
2652 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 2652 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1
2653 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); 2653 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4);
2654 webViewHelper.webView()->updateAllLifecyclePhases(); 2654 webViewHelper.webView()->updateAllLifecyclePhases();
2655 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; 2655 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag eScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
2656 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2656 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2657 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2657 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2658 EXPECT_FLOAT_EQ(1, scale); 2658 EXPECT_FLOAT_EQ(1, scale);
2659 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2659 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2660 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2660 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2661 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2661 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2662 EXPECT_FLOAT_EQ(1, scale); 2662 EXPECT_FLOAT_EQ(1, scale);
2663 2663
2664 // Zoom in to reset double_tap_zoom_in_effect flag. 2664 // Zoom in to reset double_tap_zoom_in_effect flag.
2665 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2665 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2666 // 1 < minimumPageScale < doubleTapZoomAlreadyLegibleScale 2666 // 1 < minimumPageScale < doubleTapZoomAlreadyLegibleScale
2667 webViewHelper.webView()->setDefaultPageScaleLimits(1.1f, 4); 2667 webViewHelper.webView()->setDefaultPageScaleLimits(1.1f, 4);
2668 webViewHelper.webView()->updateAllLifecyclePhases(); 2668 webViewHelper.webView()->updateAllLifecyclePhases();
2669 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2669 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2670 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2670 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2671 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2671 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2672 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2672 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2673 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2673 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2674 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2674 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2675 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2675 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2676 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2676 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2677 2677
2678 // Zoom in to reset double_tap_zoom_in_effect flag. 2678 // Zoom in to reset double_tap_zoom_in_effect flag.
2679 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2679 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2680 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale 2680 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale
2681 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); 2681 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4);
2682 webViewHelper.webView()->updateAllLifecyclePhases(); 2682 webViewHelper.webView()->updateAllLifecyclePhases();
2683 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2683 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2684 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2684 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2685 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2685 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2686 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2686 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2687 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2687 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2688 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2688 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2689 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2689 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2690 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2690 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2691 } 2691 }
2692 2692
2693 TEST_F(WebFrameTest, DivAutoZoomScaleLegibleScaleTest) 2693 TEST_F(WebFrameTest, DivAutoZoomScaleLegibleScaleTest)
2694 { 2694 {
2695 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); 2695 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
2696 2696
2697 int viewportWidth = 320; 2697 int viewportWidth = 320;
2698 int viewportHeight = 480; 2698 int viewportHeight = 480;
2699 float doubleTapZoomAlreadyLegibleRatio = 1.2f; 2699 float doubleTapZoomAlreadyLegibleRatio = 1.2f;
2700 float maximumLegibleScaleFactor = 1.13f; 2700 float maximumLegibleScaleFactor = 1.13f;
2701 FrameTestHelpers::WebViewHelper webViewHelper; 2701 FrameTestHelpers::WebViewHelper webViewHelper;
2702 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto _zoom_test.html", false, nullptr, nullptr, nullptr, configureAndroid); 2702 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto _zoom_test.html", false, nullptr, nullptr, nullptr, configureAndroid);
2703 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2703 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2704 webViewHelper.webView()->setMaximumLegibleScale(maximumLegibleScaleFactor); 2704 webViewHelper.webView()->setMaximumLegibleScale(maximumLegibleScaleFactor);
2705 webViewHelper.webView()->updateAllLifecyclePhases(); 2705 webViewHelper.webView()->updateAllLifecyclePhases();
2706 2706
2707 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2707 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2708 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(tru e); 2708 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(true);
2709 2709
2710 WebRect div(200, 100, 200, 150); 2710 WebRect div(200, 100, 200, 150);
2711 WebPoint doubleTapPoint(div.x + 50, div.y + 50); 2711 WebPoint doubleTapPoint(div.x + 50, div.y + 50);
2712 float scale; 2712 float scale;
2713 2713
2714 // Test double tap scale bounds. 2714 // Test double tap scale bounds.
2715 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < maximumLegibleS caleFactor 2715 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < maximumLegibleS caleFactor
2716 float legibleScale = maximumLegibleScaleFactor; 2716 float legibleScale = maximumLegibleScaleFactor;
2717 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2717 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2718 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; 2718 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag eScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
2719 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); 2719 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4);
2720 webViewHelper.webView()->updateAllLifecyclePhases(); 2720 webViewHelper.webView()->updateAllLifecyclePhases();
2721 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2721 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2722 EXPECT_FLOAT_EQ(legibleScale, scale); 2722 EXPECT_FLOAT_EQ(legibleScale, scale);
2723 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2723 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2724 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2724 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2725 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2725 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2726 EXPECT_FLOAT_EQ(legibleScale, scale); 2726 EXPECT_FLOAT_EQ(legibleScale, scale);
2727 2727
2728 // Zoom in to reset double_tap_zoom_in_effect flag. 2728 // Zoom in to reset double_tap_zoom_in_effect flag.
2729 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2729 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2730 // 1 < maximumLegibleScaleFactor < minimumPageScale < doubleTapZoomAlreadyLe gibleScale 2730 // 1 < maximumLegibleScaleFactor < minimumPageScale < doubleTapZoomAlreadyLe gibleScale
2731 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4); 2731 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4);
2732 webViewHelper.webView()->updateAllLifecyclePhases(); 2732 webViewHelper.webView()->updateAllLifecyclePhases();
2733 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2733 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2734 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2734 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2735 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2735 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2736 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2736 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2737 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2737 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2738 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2738 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2739 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2739 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2740 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2740 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2741 2741
2742 // Zoom in to reset double_tap_zoom_in_effect flag. 2742 // Zoom in to reset double_tap_zoom_in_effect flag.
2743 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2743 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2744 // minimumPageScale < 1 < maximumLegibleScaleFactor < doubleTapZoomAlreadyLe gibleScale 2744 // minimumPageScale < 1 < maximumLegibleScaleFactor < doubleTapZoomAlreadyLe gibleScale
2745 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); 2745 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4);
2746 webViewHelper.webView()->updateAllLifecyclePhases(); 2746 webViewHelper.webView()->updateAllLifecyclePhases();
2747 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2747 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2748 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2748 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2749 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2749 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2750 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2750 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2751 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2751 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2752 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2752 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2753 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2753 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2754 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2754 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2755 2755
2756 // Zoom in to reset double_tap_zoom_in_effect flag. 2756 // Zoom in to reset double_tap_zoom_in_effect flag.
2757 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2757 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2758 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < maximumLegibleS caleFactor 2758 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < maximumLegibleS caleFactor
2759 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4); 2759 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4);
2760 webViewHelper.webView()->updateAllLifecyclePhases(); 2760 webViewHelper.webView()->updateAllLifecyclePhases();
2761 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2761 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2762 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2762 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2763 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2763 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2764 EXPECT_FLOAT_EQ(legibleScale, scale); 2764 EXPECT_FLOAT_EQ(legibleScale, scale);
2765 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2765 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2766 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2766 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2767 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2767 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2768 EXPECT_FLOAT_EQ(legibleScale, scale); 2768 EXPECT_FLOAT_EQ(legibleScale, scale);
2769 } 2769 }
2770 2770
2771 2771
2772 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) 2772 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest)
2773 { 2773 {
2774 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); 2774 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
2775 2775
2776 int viewportWidth = 320; 2776 int viewportWidth = 320;
2777 int viewportHeight = 480; 2777 int viewportHeight = 480;
2778 float doubleTapZoomAlreadyLegibleRatio = 1.2f; 2778 float doubleTapZoomAlreadyLegibleRatio = 1.2f;
2779 float accessibilityFontScaleFactor = 1.13f; 2779 float accessibilityFontScaleFactor = 1.13f;
2780 FrameTestHelpers::WebViewHelper webViewHelper; 2780 FrameTestHelpers::WebViewHelper webViewHelper;
2781 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto _zoom_test.html", false, nullptr, nullptr, nullptr, configureAndroid); 2781 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto _zoom_test.html", false, nullptr, nullptr, nullptr, configureAndroid);
2782 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2782 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2783 webViewHelper.webView()->setMaximumLegibleScale(1.f); 2783 webViewHelper.webView()->setMaximumLegibleScale(1.f);
2784 webViewHelper.webView()->updateAllLifecyclePhases(); 2784 webViewHelper.webView()->updateAllLifecyclePhases();
2785 2785
2786 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2786 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2787 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(tru e); 2787 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(true);
2788 webViewHelper.webViewImpl()->page()->settings().setAccessibilityFontScaleFac tor(accessibilityFontScaleFactor); 2788 webViewHelper.webView()->page()->settings().setAccessibilityFontScaleFactor( accessibilityFontScaleFactor);
2789 2789
2790 WebRect div(200, 100, 200, 150); 2790 WebRect div(200, 100, 200, 150);
2791 WebPoint doubleTapPoint(div.x + 50, div.y + 50); 2791 WebPoint doubleTapPoint(div.x + 50, div.y + 50);
2792 float scale; 2792 float scale;
2793 2793
2794 // Test double tap scale bounds. 2794 // Test double tap scale bounds.
2795 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < accessibilityFo ntScaleFactor 2795 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < accessibilityFo ntScaleFactor
2796 float legibleScale = accessibilityFontScaleFactor; 2796 float legibleScale = accessibilityFontScaleFactor;
2797 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2797 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2798 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; 2798 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPag eScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
2799 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); 2799 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4);
2800 webViewHelper.webView()->updateAllLifecyclePhases(); 2800 webViewHelper.webView()->updateAllLifecyclePhases();
2801 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2801 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2802 EXPECT_FLOAT_EQ(legibleScale, scale); 2802 EXPECT_FLOAT_EQ(legibleScale, scale);
2803 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2803 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2804 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2804 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2805 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2805 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2806 EXPECT_FLOAT_EQ(legibleScale, scale); 2806 EXPECT_FLOAT_EQ(legibleScale, scale);
2807 2807
2808 // Zoom in to reset double_tap_zoom_in_effect flag. 2808 // Zoom in to reset double_tap_zoom_in_effect flag.
2809 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2809 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2810 // 1 < accessibilityFontScaleFactor < minimumPageScale < doubleTapZoomAlread yLegibleScale 2810 // 1 < accessibilityFontScaleFactor < minimumPageScale < doubleTapZoomAlread yLegibleScale
2811 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4); 2811 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4);
2812 webViewHelper.webView()->updateAllLifecyclePhases(); 2812 webViewHelper.webView()->updateAllLifecyclePhases();
2813 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2813 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2814 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2814 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2815 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2815 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2816 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2816 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2817 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2817 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2818 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2818 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2819 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2819 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2820 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2820 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2821 2821
2822 // Zoom in to reset double_tap_zoom_in_effect flag. 2822 // Zoom in to reset double_tap_zoom_in_effect flag.
2823 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2823 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2824 // minimumPageScale < 1 < accessibilityFontScaleFactor < doubleTapZoomAlread yLegibleScale 2824 // minimumPageScale < 1 < accessibilityFontScaleFactor < doubleTapZoomAlread yLegibleScale
2825 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); 2825 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4);
2826 webViewHelper.webView()->updateAllLifecyclePhases(); 2826 webViewHelper.webView()->updateAllLifecyclePhases();
2827 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2827 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2828 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2828 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2829 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2829 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2830 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2830 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2831 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2831 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2832 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2832 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2833 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2833 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2834 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); 2834 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
2835 2835
2836 // Zoom in to reset double_tap_zoom_in_effect flag. 2836 // Zoom in to reset double_tap_zoom_in_effect flag.
2837 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.1f, 0); 2837 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.1f, 0);
2838 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < accessibilityFo ntScaleFactor 2838 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < accessibilityFo ntScaleFactor
2839 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4); 2839 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4);
2840 webViewHelper.webView()->updateAllLifecyclePhases(); 2840 webViewHelper.webView()->updateAllLifecyclePhases();
2841 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS caleFactor() * doubleTapZoomAlreadyLegibleRatio; 2841 doubleTapZoomAlreadyLegibleScale = webViewHelper.webView()->minimumPageScale Factor() * doubleTapZoomAlreadyLegibleRatio;
2842 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2842 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2843 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2843 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2844 EXPECT_FLOAT_EQ(legibleScale, scale); 2844 EXPECT_FLOAT_EQ(legibleScale, scale);
2845 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2845 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2846 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale ); 2846 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale);
2847 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); 2847 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale);
2848 EXPECT_FLOAT_EQ(legibleScale, scale); 2848 EXPECT_FLOAT_EQ(legibleScale, scale);
2849 } 2849 }
2850 2850
2851 TEST_P(ParameterizedWebFrameTest, BlockBoundTest) 2851 TEST_P(ParameterizedWebFrameTest, BlockBoundTest)
2852 { 2852 {
2853 registerMockedHttpURLLoad("block_bound.html"); 2853 registerMockedHttpURLLoad("block_bound.html");
2854 2854
2855 FrameTestHelpers::WebViewHelper webViewHelper(this); 2855 FrameTestHelpers::WebViewHelper webViewHelper(this);
2856 webViewHelper.initializeAndLoad(m_baseURL + "block_bound.html", false, nullp tr, nullptr, nullptr, configureAndroid); 2856 webViewHelper.initializeAndLoad(m_baseURL + "block_bound.html", false, nullp tr, nullptr, nullptr, configureAndroid);
2857 2857
2858 IntRect rectBack = IntRect(0, 0, 200, 200); 2858 IntRect rectBack = IntRect(0, 0, 200, 200);
2859 IntRect rectLeftTop = IntRect(10, 10, 80, 80); 2859 IntRect rectLeftTop = IntRect(10, 10, 80, 80);
2860 IntRect rectRightBottom = IntRect(110, 110, 80, 80); 2860 IntRect rectRightBottom = IntRect(110, 110, 80, 80);
2861 IntRect blockBound; 2861 IntRect blockBound;
2862 2862
2863 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (9, 9), true)); 2863 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(9, 9), true));
2864 EXPECT_RECT_EQ(rectBack, blockBound); 2864 EXPECT_RECT_EQ(rectBack, blockBound);
2865 2865
2866 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (10, 10), true)); 2866 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(10, 10), true));
2867 EXPECT_RECT_EQ(rectLeftTop, blockBound); 2867 EXPECT_RECT_EQ(rectLeftTop, blockBound);
2868 2868
2869 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (50, 50), true)); 2869 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(50, 50), true));
2870 EXPECT_RECT_EQ(rectLeftTop, blockBound); 2870 EXPECT_RECT_EQ(rectLeftTop, blockBound);
2871 2871
2872 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (89, 89), true)); 2872 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(89, 89), true));
2873 EXPECT_RECT_EQ(rectLeftTop, blockBound); 2873 EXPECT_RECT_EQ(rectLeftTop, blockBound);
2874 2874
2875 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (90, 90), true)); 2875 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(90, 90), true));
2876 EXPECT_RECT_EQ(rectBack, blockBound); 2876 EXPECT_RECT_EQ(rectBack, blockBound);
2877 2877
2878 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (109, 109), true)); 2878 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(109 , 109), true));
2879 EXPECT_RECT_EQ(rectBack, blockBound); 2879 EXPECT_RECT_EQ(rectBack, blockBound);
2880 2880
2881 blockBound = IntRect(webViewHelper.webViewImpl()->computeBlockBound(WebPoint (110, 110), true)); 2881 blockBound = IntRect(webViewHelper.webView()->computeBlockBound(WebPoint(110 , 110), true));
2882 EXPECT_RECT_EQ(rectRightBottom, blockBound); 2882 EXPECT_RECT_EQ(rectRightBottom, blockBound);
2883 } 2883 }
2884 2884
2885 TEST_P(ParameterizedWebFrameTest, DivMultipleTargetZoomMultipleDivsTest) 2885 TEST_P(ParameterizedWebFrameTest, DivMultipleTargetZoomMultipleDivsTest)
2886 { 2886 {
2887 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); 2887 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
2888 2888
2889 const float deviceScaleFactor = 2.0f; 2889 const float deviceScaleFactor = 2.0f;
2890 int viewportWidth = 640 / deviceScaleFactor; 2890 int viewportWidth = 640 / deviceScaleFactor;
2891 int viewportHeight = 1280 / deviceScaleFactor; 2891 int viewportHeight = 1280 / deviceScaleFactor;
2892 float doubleTapZoomAlreadyLegibleRatio = 1.2f; 2892 float doubleTapZoomAlreadyLegibleRatio = 1.2f;
2893 FrameTestHelpers::WebViewHelper webViewHelper(this); 2893 FrameTestHelpers::WebViewHelper webViewHelper(this);
2894 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom _test.html"); 2894 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom _test.html");
2895 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2895 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2896 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); 2896 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4);
2897 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); 2897 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor);
2898 webViewHelper.webView()->setPageScaleFactor(0.5f); 2898 webViewHelper.webView()->setPageScaleFactor(0.5f);
2899 webViewHelper.webView()->setMaximumLegibleScale(1.f); 2899 webViewHelper.webView()->setMaximumLegibleScale(1.f);
2900 webViewHelper.webView()->updateAllLifecyclePhases(); 2900 webViewHelper.webView()->updateAllLifecyclePhases();
2901 2901
2902 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2902 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2903 2903
2904 WebRect viewportRect(0, 0, viewportWidth, viewportHeight); 2904 WebRect viewportRect(0, 0, viewportWidth, viewportHeight);
2905 WebRect topDiv(200, 100, 200, 150); 2905 WebRect topDiv(200, 100, 200, 150);
2906 WebRect bottomDiv(200, 300, 200, 150); 2906 WebRect bottomDiv(200, 300, 200, 150);
2907 float scale; 2907 float scale;
2908 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL egibleRatio) / 2); 2908 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), (webView Helper.webView()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRa tio) / 2);
2909 2909
2910 simulateMultiTargetZoom(webViewHelper.webViewImpl(), topDiv, scale); 2910 simulateMultiTargetZoom(webViewHelper.webView(), topDiv, scale);
2911 EXPECT_FLOAT_EQ(1, scale); 2911 EXPECT_FLOAT_EQ(1, scale);
2912 simulateMultiTargetZoom(webViewHelper.webViewImpl(), bottomDiv, scale); 2912 simulateMultiTargetZoom(webViewHelper.webView(), bottomDiv, scale);
2913 EXPECT_FLOAT_EQ(1, scale); 2913 EXPECT_FLOAT_EQ(1, scale);
2914 simulateMultiTargetZoom(webViewHelper.webViewImpl(), viewportRect, scale); 2914 simulateMultiTargetZoom(webViewHelper.webView(), viewportRect, scale);
2915 EXPECT_FLOAT_EQ(1, scale); 2915 EXPECT_FLOAT_EQ(1, scale);
2916 webViewHelper.webViewImpl()->setPageScaleFactor(webViewHelper.webViewImpl()- >minimumPageScaleFactor()); 2916 webViewHelper.webView()->setPageScaleFactor(webViewHelper.webView()->minimum PageScaleFactor());
2917 simulateMultiTargetZoom(webViewHelper.webViewImpl(), topDiv, scale); 2917 simulateMultiTargetZoom(webViewHelper.webView(), topDiv, scale);
2918 EXPECT_FLOAT_EQ(1, scale); 2918 EXPECT_FLOAT_EQ(1, scale);
2919 } 2919 }
2920 2920
2921 TEST_F(WebFrameTest, DontZoomInOnFocusedInTouchAction) 2921 TEST_F(WebFrameTest, DontZoomInOnFocusedInTouchAction)
2922 { 2922 {
2923 registerMockedHttpURLLoad("textbox_in_touch_action.html"); 2923 registerMockedHttpURLLoad("textbox_in_touch_action.html");
2924 2924
2925 int viewportWidth = 600; 2925 int viewportWidth = 600;
2926 int viewportHeight = 1000; 2926 int viewportHeight = 1000;
2927 2927
2928 FrameTestHelpers::WebViewHelper webViewHelper; 2928 FrameTestHelpers::WebViewHelper webViewHelper;
2929 webViewHelper.initializeAndLoad(m_baseURL + "textbox_in_touch_action.html"); 2929 webViewHelper.initializeAndLoad(m_baseURL + "textbox_in_touch_action.html");
2930 webViewHelper.webViewImpl()->setDefaultPageScaleLimits(0.25f, 4); 2930 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4);
2931 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2931 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2932 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal se); 2932 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(false);
2933 webViewHelper.webViewImpl()->settings()->setAutoZoomFocusedNodeToLegibleScal e(true); 2933 webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(tr ue);
2934 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2934 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2935 2935
2936 float initialScale = webViewHelper.webViewImpl()->pageScaleFactor(); 2936 float initialScale = webViewHelper.webView()->pageScaleFactor();
2937 2937
2938 // Focus the first textbox that's in a touch-action: pan-x ancestor, this 2938 // Focus the first textbox that's in a touch-action: pan-x ancestor, this
2939 // shouldn't cause an autozoom since pan-x disables pinch-zoom. 2939 // shouldn't cause an autozoom since pan-x disables pinch-zoom.
2940 webViewHelper.webViewImpl()->advanceFocus(false); 2940 webViewHelper.webView()->advanceFocus(false);
2941 webViewHelper.webViewImpl()->scrollFocusedEditableElementIntoRect(WebRect()) ; 2941 webViewHelper.webView()->scrollFocusedEditableElementIntoRect(WebRect());
2942 EXPECT_EQ(webViewHelper.webViewImpl()->fakePageScaleAnimationPageScaleForTes ting(), 0); 2942 EXPECT_EQ(webViewHelper.webView()->fakePageScaleAnimationPageScaleForTesting (), 0);
2943 2943
2944 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init ialScale); 2944 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS cale);
2945 ASSERT_EQ(initialScale, webViewHelper.webViewImpl()->pageScaleFactor()); 2945 ASSERT_EQ(initialScale, webViewHelper.webView()->pageScaleFactor());
2946 2946
2947 // Focus the second textbox that's in a touch-action: manipulation ancestor, 2947 // Focus the second textbox that's in a touch-action: manipulation ancestor,
2948 // this should cause an autozoom since it allows pinch-zoom. 2948 // this should cause an autozoom since it allows pinch-zoom.
2949 webViewHelper.webViewImpl()->advanceFocus(false); 2949 webViewHelper.webView()->advanceFocus(false);
2950 webViewHelper.webViewImpl()->scrollFocusedEditableElementIntoRect(WebRect()) ; 2950 webViewHelper.webView()->scrollFocusedEditableElementIntoRect(WebRect());
2951 EXPECT_GT(webViewHelper.webViewImpl()->fakePageScaleAnimationPageScaleForTes ting(), initialScale); 2951 EXPECT_GT(webViewHelper.webView()->fakePageScaleAnimationPageScaleForTesting (), initialScale);
2952 2952
2953 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init ialScale); 2953 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS cale);
2954 ASSERT_EQ(initialScale, webViewHelper.webViewImpl()->pageScaleFactor()); 2954 ASSERT_EQ(initialScale, webViewHelper.webView()->pageScaleFactor());
2955 2955
2956 // Focus the third textbox that has a touch-action: pan-x ancestor, this 2956 // Focus the third textbox that has a touch-action: pan-x ancestor, this
2957 // should cause an autozoom since it's seperated from the node with the 2957 // should cause an autozoom since it's seperated from the node with the
2958 // touch-action by an overflow:scroll element. 2958 // touch-action by an overflow:scroll element.
2959 webViewHelper.webView()->advanceFocus(false); 2959 webViewHelper.webView()->advanceFocus(false);
2960 webViewHelper.webViewImpl()->scrollFocusedEditableElementIntoRect(WebRect()) ; 2960 webViewHelper.webView()->scrollFocusedEditableElementIntoRect(WebRect());
2961 EXPECT_GT(webViewHelper.webViewImpl()->fakePageScaleAnimationPageScaleForTes ting(), initialScale); 2961 EXPECT_GT(webViewHelper.webView()->fakePageScaleAnimationPageScaleForTesting (), initialScale);
2962 } 2962 }
2963 2963
2964 2964
2965 TEST_F(WebFrameTest, DivScrollIntoEditableTest) 2965 TEST_F(WebFrameTest, DivScrollIntoEditableTest)
2966 { 2966 {
2967 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); 2967 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html");
2968 2968
2969 const bool autoZoomToLegibleScale = true; 2969 const bool autoZoomToLegibleScale = true;
2970 int viewportWidth = 450; 2970 int viewportWidth = 450;
2971 int viewportHeight = 300; 2971 int viewportHeight = 300;
2972 float leftBoxRatio = 0.3f; 2972 float leftBoxRatio = 0.3f;
2973 int caretPadding = 10; 2973 int caretPadding = 10;
2974 float minReadableCaretHeight = 16.0f; 2974 float minReadableCaretHeight = 16.0f;
2975 FrameTestHelpers::WebViewHelper webViewHelper; 2975 FrameTestHelpers::WebViewHelper webViewHelper;
2976 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl e_test.html"); 2976 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl e_test.html");
2977 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal se); 2977 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(false);
2978 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2978 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2979 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); 2979 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4);
2980 2980
2981 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 2981 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
2982 2982
2983 WebRect editBoxWithText(200, 200, 250, 20); 2983 WebRect editBoxWithText(200, 200, 250, 20);
2984 WebRect editBoxWithNoText(200, 250, 250, 20); 2984 WebRect editBoxWithNoText(200, 250, 250, 20);
2985 2985
2986 // Test scrolling the focused node 2986 // Test scrolling the focused node
2987 // The edit box is shorter and narrower than the viewport when legible. 2987 // The edit box is shorter and narrower than the viewport when legible.
2988 webViewHelper.webView()->advanceFocus(false); 2988 webViewHelper.webView()->advanceFocus(false);
2989 // Set the caret to the end of the input box. 2989 // Set the caret to the end of the input box.
2990 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith Text").to<WebInputElement>().setSelectionRange(1000, 1000); 2990 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith Text").to<WebInputElement>().setSelectionRange(1000, 1000);
2991 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); 2991 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1);
2992 WebRect rect, caret; 2992 WebRect rect, caret;
2993 webViewHelper.webViewImpl()->selectionBounds(caret, rect); 2993 webViewHelper.webView()->selectionBounds(caret, rect);
2994 2994
2995 // Set the page scale to be smaller than the minimal readable scale. 2995 // Set the page scale to be smaller than the minimal readable scale.
2996 float initialScale = minReadableCaretHeight / caret.height * 0.5f; 2996 float initialScale = minReadableCaretHeight / caret.height * 0.5f;
2997 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init ialScale); 2997 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS cale);
2998 2998
2999 float scale; 2999 float scale;
3000 IntPoint scroll; 3000 IntPoint scroll;
3001 bool needAnimation; 3001 bool needAnimation;
3002 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3002 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3003 EXPECT_TRUE(needAnimation); 3003 EXPECT_TRUE(needAnimation);
3004 // The edit box should be left aligned with a margin for possible label. 3004 // The edit box should be left aligned with a margin for possible label.
3005 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; 3005 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale;
3006 EXPECT_NEAR(hScroll, scroll.x(), 2); 3006 EXPECT_NEAR(hScroll, scroll.x(), 2);
3007 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText. height) / 2; 3007 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText. height) / 2;
3008 EXPECT_NEAR(vScroll, scroll.y(), 2); 3008 EXPECT_NEAR(vScroll, scroll.y(), 2);
3009 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); 3009 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1);
3010 3010
3011 // The edit box is wider than the viewport when legible. 3011 // The edit box is wider than the viewport when legible.
3012 viewportWidth = 200; 3012 viewportWidth = 200;
3013 viewportHeight = 150; 3013 viewportHeight = 150;
3014 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 3014 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
3015 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init ialScale); 3015 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS cale);
3016 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3016 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3017 EXPECT_TRUE(needAnimation); 3017 EXPECT_TRUE(needAnimation);
3018 // The caret should be right aligned since the caret would be offscreen when the edit box is left aligned. 3018 // The caret should be right aligned since the caret would be offscreen when the edit box is left aligned.
3019 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; 3019 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale;
3020 EXPECT_NEAR(hScroll, scroll.x(), 2); 3020 EXPECT_NEAR(hScroll, scroll.x(), 2);
3021 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); 3021 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1);
3022 3022
3023 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init ialScale); 3023 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS cale);
3024 // Move focus to edit box with text. 3024 // Move focus to edit box with text.
3025 webViewHelper.webView()->advanceFocus(false); 3025 webViewHelper.webView()->advanceFocus(false);
3026 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3026 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3027 EXPECT_TRUE(needAnimation); 3027 EXPECT_TRUE(needAnimation);
3028 // The edit box should be left aligned. 3028 // The edit box should be left aligned.
3029 hScroll = editBoxWithNoText.x; 3029 hScroll = editBoxWithNoText.x;
3030 EXPECT_NEAR(hScroll, scroll.x(), 2); 3030 EXPECT_NEAR(hScroll, scroll.x(), 2);
3031 vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoText. height) / 2; 3031 vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoText. height) / 2;
3032 EXPECT_NEAR(vScroll, scroll.y(), 2); 3032 EXPECT_NEAR(vScroll, scroll.y(), 2);
3033 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); 3033 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1);
3034 3034
3035 // Move focus back to the first edit box. 3035 // Move focus back to the first edit box.
3036 webViewHelper.webView()->advanceFocus(true); 3036 webViewHelper.webView()->advanceFocus(true);
3037 // Zoom out slightly. 3037 // Zoom out slightly.
3038 const float withinToleranceScale = scale * 0.9f; 3038 const float withinToleranceScale = scale * 0.9f;
3039 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, withinTolera nceScale); 3039 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, withinToleranceS cale);
3040 // Move focus back to the second edit box. 3040 // Move focus back to the second edit box.
3041 webViewHelper.webView()->advanceFocus(false); 3041 webViewHelper.webView()->advanceFocus(false);
3042 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3042 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3043 // The scale should not be adjusted as the zoomed out scale was sufficiently close to the previously focused scale. 3043 // The scale should not be adjusted as the zoomed out scale was sufficiently close to the previously focused scale.
3044 EXPECT_FALSE(needAnimation); 3044 EXPECT_FALSE(needAnimation);
3045 } 3045 }
3046 3046
3047 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) 3047 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest)
3048 { 3048 {
3049 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); 3049 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html");
3050 3050
3051 const bool autoZoomToLegibleScale = true; 3051 const bool autoZoomToLegibleScale = true;
3052 const int viewportWidth = 450; 3052 const int viewportWidth = 450;
3053 const int viewportHeight = 300; 3053 const int viewportHeight = 300;
3054 const float minReadableCaretHeight = 16.0f; 3054 const float minReadableCaretHeight = 16.0f;
3055 FrameTestHelpers::WebViewHelper webViewHelper; 3055 FrameTestHelpers::WebViewHelper webViewHelper;
3056 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl e_test.html"); 3056 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl e_test.html");
3057 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal se); 3057 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(false);
3058 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 3058 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
3059 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 3059 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
3060 3060
3061 const WebRect editBoxWithText(200, 200, 250, 20); 3061 const WebRect editBoxWithText(200, 200, 250, 20);
3062 3062
3063 webViewHelper.webView()->advanceFocus(false); 3063 webViewHelper.webView()->advanceFocus(false);
3064 // Set the caret to the begining of the input box. 3064 // Set the caret to the begining of the input box.
3065 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith Text").to<WebInputElement>().setSelectionRange(0, 0); 3065 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith Text").to<WebInputElement>().setSelectionRange(0, 0);
3066 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); 3066 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1);
3067 WebRect rect, caret; 3067 WebRect rect, caret;
3068 webViewHelper.webViewImpl()->selectionBounds(caret, rect); 3068 webViewHelper.webView()->selectionBounds(caret, rect);
3069 3069
3070 // Set the page scale to be twice as large as the minimal readable scale. 3070 // Set the page scale to be twice as large as the minimal readable scale.
3071 float newScale = minReadableCaretHeight / caret.height * 2.0; 3071 float newScale = minReadableCaretHeight / caret.height * 2.0;
3072 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), newS cale); 3072 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), newScale );
3073 3073
3074 float scale; 3074 float scale;
3075 IntPoint scroll; 3075 IntPoint scroll;
3076 bool needAnimation; 3076 bool needAnimation;
3077 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3077 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3078 EXPECT_TRUE(needAnimation); 3078 EXPECT_TRUE(needAnimation);
3079 // Edit box and caret should be left alinged 3079 // Edit box and caret should be left alinged
3080 int hScroll = editBoxWithText.x; 3080 int hScroll = editBoxWithText.x;
3081 EXPECT_NEAR(hScroll, scroll.x(), 1); 3081 EXPECT_NEAR(hScroll, scroll.x(), 1);
3082 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText. height) / 2; 3082 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText. height) / 2;
3083 EXPECT_NEAR(vScroll, scroll.y(), 1); 3083 EXPECT_NEAR(vScroll, scroll.y(), 1);
3084 // Page scale have to be unchanged 3084 // Page scale have to be unchanged
3085 EXPECT_EQ(newScale, scale); 3085 EXPECT_EQ(newScale, scale);
3086 3086
3087 // Set page scale and scroll such that edit box will be under the screen 3087 // Set page scale and scroll such that edit box will be under the screen
3088 newScale = 3.0; 3088 newScale = 3.0;
3089 hScroll = 200; 3089 hScroll = 200;
3090 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(hScroll, 0) , newScale); 3090 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(hScroll, 0), ne wScale);
3091 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3091 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3092 EXPECT_TRUE(needAnimation); 3092 EXPECT_TRUE(needAnimation);
3093 // Horizontal scroll have to be the same 3093 // Horizontal scroll have to be the same
3094 EXPECT_NEAR(hScroll, scroll.x(), 1); 3094 EXPECT_NEAR(hScroll, scroll.x(), 1);
3095 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig ht) / 2; 3095 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig ht) / 2;
3096 EXPECT_NEAR(vScroll, scroll.y(), 1); 3096 EXPECT_NEAR(vScroll, scroll.y(), 1);
3097 // Page scale have to be unchanged 3097 // Page scale have to be unchanged
3098 EXPECT_EQ(newScale, scale); 3098 EXPECT_EQ(newScale, scale);
3099 } 3099 }
3100 3100
3101 // Tests the scroll into view functionality when autoZoomeFocusedNodeToLegibleSc ale set 3101 // Tests the scroll into view functionality when autoZoomeFocusedNodeToLegibleSc ale set
3102 // to false. i.e. The path non-Android platforms take. 3102 // to false. i.e. The path non-Android platforms take.
3103 TEST_F(WebFrameTest, DivScrollIntoEditableTestZoomToLegibleScaleDisabled) 3103 TEST_F(WebFrameTest, DivScrollIntoEditableTestZoomToLegibleScaleDisabled)
3104 { 3104 {
3105 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); 3105 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html");
3106 3106
3107 const bool autoZoomToLegibleScale = false; 3107 const bool autoZoomToLegibleScale = false;
3108 int viewportWidth = 100; 3108 int viewportWidth = 100;
3109 int viewportHeight = 100; 3109 int viewportHeight = 100;
3110 float leftBoxRatio = 0.3f; 3110 float leftBoxRatio = 0.3f;
3111 FrameTestHelpers::WebViewHelper webViewHelper; 3111 FrameTestHelpers::WebViewHelper webViewHelper;
3112 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl e_test.html"); 3112 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl e_test.html");
3113 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal se); 3113 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(false);
3114 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 3114 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
3115 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); 3115 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4);
3116 3116
3117 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); 3117 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true);
3118 3118
3119 WebRect editBoxWithText(200, 200, 250, 20); 3119 WebRect editBoxWithText(200, 200, 250, 20);
3120 WebRect editBoxWithNoText(200, 250, 250, 20); 3120 WebRect editBoxWithNoText(200, 250, 250, 20);
3121 3121
3122 // Test scrolling the focused node 3122 // Test scrolling the focused node
3123 // Since we're zoomed out, the caret is considered too small to be legible a nd so we'd 3123 // Since we're zoomed out, the caret is considered too small to be legible a nd so we'd
3124 // normally zoom in. Make sure we don't change scale since the auto-zoom set ting is off. 3124 // normally zoom in. Make sure we don't change scale since the auto-zoom set ting is off.
3125 3125
3126 // Focus the second empty textbox. 3126 // Focus the second empty textbox.
3127 webViewHelper.webView()->advanceFocus(false); 3127 webViewHelper.webView()->advanceFocus(false);
3128 webViewHelper.webView()->advanceFocus(false); 3128 webViewHelper.webView()->advanceFocus(false);
3129 3129
3130 // Set the page scale to be smaller than the minimal readable scale. 3130 // Set the page scale to be smaller than the minimal readable scale.
3131 float initialScale = 0.25f; 3131 float initialScale = 0.25f;
3132 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init ialScale); 3132 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS cale);
3133 3133
3134 float scale; 3134 float scale;
3135 IntPoint scroll; 3135 IntPoint scroll;
3136 bool needAnimation; 3136 bool needAnimation;
3137 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3137 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3138 3138
3139 // There should be no change in page scale. 3139 // There should be no change in page scale.
3140 EXPECT_EQ(initialScale, scale); 3140 EXPECT_EQ(initialScale, scale);
3141 // The edit box should be left aligned with a margin for possible label. 3141 // The edit box should be left aligned with a margin for possible label.
3142 EXPECT_TRUE(needAnimation); 3142 EXPECT_TRUE(needAnimation);
3143 int hScroll = editBoxWithNoText.x - leftBoxRatio * viewportWidth / scale; 3143 int hScroll = editBoxWithNoText.x - leftBoxRatio * viewportWidth / scale;
3144 EXPECT_NEAR(hScroll, scroll.x(), 2); 3144 EXPECT_NEAR(hScroll, scroll.x(), 2);
3145 int vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoT ext.height) / 2; 3145 int vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoT ext.height) / 2;
3146 EXPECT_NEAR(vScroll, scroll.y(), 2); 3146 EXPECT_NEAR(vScroll, scroll.y(), 2);
3147 3147
3148 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); 3148 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, scale);
3149 3149
3150 // Select the first textbox. 3150 // Select the first textbox.
3151 webViewHelper.webView()->advanceFocus(true); 3151 webViewHelper.webView()->advanceFocus(true);
3152 WebRect rect, caret; 3152 WebRect rect, caret;
3153 webViewHelper.webViewImpl()->selectionBounds(caret, rect); 3153 webViewHelper.webView()->selectionBounds(caret, rect);
3154 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA nimation); 3154 webViewHelper.webView()->computeScaleAndScrollForFocusedNode(webViewHelper.w ebView()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needAnimation );
3155 3155
3156 // There should be no change at all since the textbox is fully visible alrea dy. 3156 // There should be no change at all since the textbox is fully visible alrea dy.
3157 EXPECT_EQ(initialScale, scale); 3157 EXPECT_EQ(initialScale, scale);
3158 EXPECT_FALSE(needAnimation); 3158 EXPECT_FALSE(needAnimation);
3159 } 3159 }
3160 3160
3161 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) 3161 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom)
3162 { 3162 {
3163 registerMockedHttpURLLoad("sometext.html"); 3163 registerMockedHttpURLLoad("sometext.html");
3164 3164
3165 FrameTestHelpers::WebViewHelper webViewHelper(this); 3165 FrameTestHelpers::WebViewHelper webViewHelper(this);
3166 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); 3166 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html");
3167 webViewHelper.resize(WebSize(640, 480)); 3167 webViewHelper.resize(WebSize(640, 480));
3168 3168
3169 webViewHelper.webViewImpl()->setPageScaleFactor(2); 3169 webViewHelper.webView()->setPageScaleFactor(2);
3170 webViewHelper.webViewImpl()->setVisualViewportOffset(WebFloatPoint(50, 60)); 3170 webViewHelper.webView()->setVisualViewportOffset(WebFloatPoint(50, 60));
3171 3171
3172 WebRect baseRect; 3172 WebRect baseRect;
3173 WebRect extentRect; 3173 WebRect extentRect;
3174 3174
3175 WebLocalFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame()->toWebLo calFrame(); 3175 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrame()->toWebLocalF rame();
3176 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388)); 3176 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388));
3177 3177
3178 EXPECT_EQ(2ul, ix); 3178 EXPECT_EQ(2ul, ix);
3179 } 3179 }
3180 3180
3181 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) 3181 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom)
3182 { 3182 {
3183 registerMockedHttpURLLoad("textbox.html"); 3183 registerMockedHttpURLLoad("textbox.html");
3184 3184
3185 FrameTestHelpers::WebViewHelper webViewHelper(this); 3185 FrameTestHelpers::WebViewHelper webViewHelper(this);
3186 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true); 3186 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true);
3187 webViewHelper.resize(WebSize(640, 480)); 3187 webViewHelper.resize(WebSize(640, 480));
3188 3188
3189 WebLocalFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame()->toWebLo calFrame(); 3189 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrame()->toWebLocalF rame();
3190 mainFrame->executeScript(WebScriptSource("selectRange();")); 3190 mainFrame->executeScript(WebScriptSource("selectRange();"));
3191 3191
3192 WebRect oldRect; 3192 WebRect oldRect;
3193 mainFrame->firstRectForCharacterRange(0, 5, oldRect); 3193 mainFrame->firstRectForCharacterRange(0, 5, oldRect);
3194 3194
3195 WebFloatPoint visualOffset(100, 130); 3195 WebFloatPoint visualOffset(100, 130);
3196 float scale = 2; 3196 float scale = 2;
3197 webViewHelper.webViewImpl()->setPageScaleFactor(scale); 3197 webViewHelper.webView()->setPageScaleFactor(scale);
3198 webViewHelper.webViewImpl()->setVisualViewportOffset(visualOffset); 3198 webViewHelper.webView()->setVisualViewportOffset(visualOffset);
3199 3199
3200 WebRect baseRect; 3200 WebRect baseRect;
3201 WebRect extentRect; 3201 WebRect extentRect;
3202 3202
3203 WebRect rect; 3203 WebRect rect;
3204 mainFrame->firstRectForCharacterRange(0, 5, rect); 3204 mainFrame->firstRectForCharacterRange(0, 5, rect);
3205 3205
3206 EXPECT_EQ((oldRect.x - visualOffset.x) * scale, rect.x); 3206 EXPECT_EQ((oldRect.x - visualOffset.x) * scale, rect.x);
3207 EXPECT_EQ((oldRect.y - visualOffset.y) * scale, rect.y); 3207 EXPECT_EQ((oldRect.y - visualOffset.y) * scale, rect.y);
3208 EXPECT_EQ(oldRect.width*scale, rect.width); 3208 EXPECT_EQ(oldRect.width*scale, rect.width);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 const int pageHeight = 100; 3250 const int pageHeight = 100;
3251 3251
3252 registerMockedHttpURLLoad(firstURL); 3252 registerMockedHttpURLLoad(firstURL);
3253 registerMockedHttpURLLoad(secondURL); 3253 registerMockedHttpURLLoad(secondURL);
3254 registerMockedHttpURLLoad(thirdURL); 3254 registerMockedHttpURLLoad(thirdURL);
3255 3255
3256 FrameTestHelpers::WebViewHelper webViewHelper; 3256 FrameTestHelpers::WebViewHelper webViewHelper;
3257 ClearScrollStateOnCommitWebFrameClient client; 3257 ClearScrollStateOnCommitWebFrameClient client;
3258 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client); 3258 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client);
3259 webViewHelper.resize(WebSize(pageWidth, pageHeight)); 3259 webViewHelper.resize(WebSize(pageWidth, pageHeight));
3260 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4)); 3260 webViewHelper.webView()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4));
3261 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); 3261 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor);
3262 3262
3263 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff set(); 3263 WebSize previousOffset = webViewHelper.webView()->mainFrame()->scrollOffset( );
3264 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); 3264 float previousScale = webViewHelper.webView()->pageScaleFactor();
3265 3265
3266 // Reload the page and end up at the same url. State should be propagated. 3266 // Reload the page and end up at the same url. State should be propagated.
3267 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas eURL + firstURL), WebFrameLoadType::Reload); 3267 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + firstURL), WebFrameLoadType::Reload);
3268 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webViewImp l()->mainFrame()); 3268 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
3269 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width); 3269 EXPECT_EQ(previousOffset.width, webViewHelper.webView()->mainFrame()->scroll Offset().width);
3270 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height); 3270 EXPECT_EQ(previousOffset.height, webViewHelper.webView()->mainFrame()->scrol lOffset().height);
3271 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); 3271 EXPECT_EQ(previousScale, webViewHelper.webView()->pageScaleFactor());
3272 3272
3273 // Reload the page using the cache. State should not be propagated. 3273 // Reload the page using the cache. State should not be propagated.
3274 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas eURL + secondURL), WebFrameLoadType::Reload); 3274 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondURL), WebFrameLoadType::Reload);
3275 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webViewImp l()->mainFrame()); 3275 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
3276 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width) ; 3276 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().width);
3277 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height ); 3277 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().height);
3278 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor()); 3278 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor());
3279 3279
3280 // Reload the page while ignoring the cache. State should not be propagated. 3280 // Reload the page while ignoring the cache. State should not be propagated.
3281 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas eURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); 3281 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache);
3282 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webViewImp l()->mainFrame()); 3282 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
3283 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width) ; 3283 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().width);
3284 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height ); 3284 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().height);
3285 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor()); 3285 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor());
3286 } 3286 }
3287 3287
3288 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) 3288 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional)
3289 { 3289 {
3290 // Test that reloading while the previous load is still pending does not cau se the initial 3290 // Test that reloading while the previous load is still pending does not cau se the initial
3291 // request to get lost. 3291 // request to get lost.
3292 registerMockedHttpURLLoad("fixed_layout.html"); 3292 registerMockedHttpURLLoad("fixed_layout.html");
3293 3293
3294 FrameTestHelpers::WebViewHelper webViewHelper(this); 3294 FrameTestHelpers::WebViewHelper webViewHelper(this);
3295 webViewHelper.initialize(); 3295 webViewHelper.initialize();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 TEST_P(ParameterizedWebFrameTest, IframeRedirect) 3327 TEST_P(ParameterizedWebFrameTest, IframeRedirect)
3328 { 3328 {
3329 registerMockedHttpURLLoad("iframe_redirect.html"); 3329 registerMockedHttpURLLoad("iframe_redirect.html");
3330 registerMockedHttpURLLoad("visible_iframe.html"); 3330 registerMockedHttpURLLoad("visible_iframe.html");
3331 3331
3332 FrameTestHelpers::WebViewHelper webViewHelper(this); 3332 FrameTestHelpers::WebViewHelper webViewHelper(this);
3333 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); 3333 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true);
3334 // Pump pending requests one more time. The test page loads script that navi gates. 3334 // Pump pending requests one more time. The test page loads script that navi gates.
3335 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame()); 3335 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
3336 3336
3337 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU TF8("ifr")); 3337 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU TF8("ifr"), nullptr);
tkent 2016/07/20 04:51:01 Do you need to add nullptr argument in this CL?
dcheng 2016/07/20 06:18:07 findFrameByName has a default argument on WebView
tkent 2016/07/20 06:31:53 ok, I understand.
3338 ASSERT_TRUE(iframe); 3338 ASSERT_TRUE(iframe);
3339 WebDataSource* iframeDataSource = iframe->dataSource(); 3339 WebDataSource* iframeDataSource = iframe->dataSource();
3340 ASSERT_TRUE(iframeDataSource); 3340 ASSERT_TRUE(iframeDataSource);
3341 WebVector<WebURL> redirects; 3341 WebVector<WebURL> redirects;
3342 iframeDataSource->redirectChain(redirects); 3342 iframeDataSource->redirectChain(redirects);
3343 ASSERT_EQ(2U, redirects.size()); 3343 ASSERT_EQ(2U, redirects.size());
3344 EXPECT_EQ(toKURL("about:blank"), KURL(redirects[0])); 3344 EXPECT_EQ(toKURL("about:blank"), KURL(redirects[0]));
3345 EXPECT_EQ(toKURL("http://internal.test/visible_iframe.html"), KURL(redirects [1])); 3345 EXPECT_EQ(toKURL("http://internal.test/visible_iframe.html"), KURL(redirects [1]));
3346 } 3346 }
3347 3347
3348 TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) 3348 TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest)
3349 { 3349 {
3350 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); 3350 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html");
3351 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); 3351 registerMockedHttpURLLoad("autofocus_input_field_iframe.html");
3352 3352
3353 FrameTestHelpers::WebViewHelper webViewHelper(this); 3353 FrameTestHelpers::WebViewHelper webViewHelper(this);
3354 webViewHelper.initializeAndLoad(m_baseURL + "iframe_clear_focused_node_test. html", true); 3354 webViewHelper.initializeAndLoad(m_baseURL + "iframe_clear_focused_node_test. html", true);
3355 3355
3356 // Clear the focused node. 3356 // Clear the focused node.
3357 webViewHelper.webView()->clearFocusedElement(); 3357 webViewHelper.webView()->clearFocusedElement();
3358 3358
3359 // Now retrieve the FocusedNode and test it should be null. 3359 // Now retrieve the FocusedNode and test it should be null.
3360 EXPECT_EQ(0, webViewHelper.webViewImpl()->focusedElement()); 3360 EXPECT_EQ(0, webViewHelper.webView()->focusedElement());
3361 } 3361 }
3362 3362
3363 // Implementation of WebFrameClient that tracks the v8 contexts that are created 3363 // Implementation of WebFrameClient that tracks the v8 contexts that are created
3364 // and destroyed for verification. 3364 // and destroyed for verification.
3365 class ContextLifetimeTestWebFrameClient : public FrameTestHelpers::TestWebFrameC lient { 3365 class ContextLifetimeTestWebFrameClient : public FrameTestHelpers::TestWebFrameC lient {
3366 public: 3366 public:
3367 struct Notification { 3367 struct Notification {
3368 public: 3368 public:
3369 Notification(WebLocalFrame* frame, v8::Local<v8::Context> context, int w orldId) 3369 Notification(WebLocalFrame* frame, v8::Local<v8::Context> context, int w orldId)
3370 : frame(frame) 3370 : frame(frame)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3533 ++matchCount; 3533 ++matchCount;
3534 } 3534 }
3535 EXPECT_EQ(1, matchCount); 3535 EXPECT_EQ(1, matchCount);
3536 } 3536 }
3537 3537
3538 TEST_P(ParameterizedWebFrameTest, FindInPage) 3538 TEST_P(ParameterizedWebFrameTest, FindInPage)
3539 { 3539 {
3540 registerMockedHttpURLLoad("find.html"); 3540 registerMockedHttpURLLoad("find.html");
3541 FrameTestHelpers::WebViewHelper webViewHelper(this); 3541 FrameTestHelpers::WebViewHelper webViewHelper(this);
3542 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); 3542 webViewHelper.initializeAndLoad(m_baseURL + "find.html");
3543 ASSERT_TRUE(webViewHelper.webView()->mainFrame()->isWebLocalFrame()); 3543 ASSERT_TRUE(webViewHelper.webView()->mainFrameImpl());
3544 webViewHelper.webView()->setFocus(true); 3544 webViewHelper.webView()->setFocus(true);
3545 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame (); 3545 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
3546 const int findIdentifier = 12345; 3546 const int findIdentifier = 12345;
3547 WebFindOptions options; 3547 WebFindOptions options;
3548 3548
3549 // Find in a <div> element. 3549 // Find in a <div> element.
3550 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options , false, 0)); 3550 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options , false, 0));
3551 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); 3551 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection);
3552 WebRange range = frame->selectionRange(); 3552 WebRange range = frame->selectionRange();
3553 EXPECT_EQ(5, range.startOffset()); 3553 EXPECT_EQ(5, range.startOffset());
3554 EXPECT_EQ(9, range.endOffset()); 3554 EXPECT_EQ(9, range.endOffset());
3555 EXPECT_TRUE(frame->document().focusedElement().isNull()); 3555 EXPECT_TRUE(frame->document().focusedElement().isNull());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3633 // Get the frame text where the subframe separator falls on the boundary of 3633 // Get the frame text where the subframe separator falls on the boundary of
3634 // what we'll take. There used to be a crash in this case. 3634 // what we'll take. There used to be a crash in this case.
3635 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ; 3635 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ;
3636 EXPECT_EQ("Hello world", text.utf8()); 3636 EXPECT_EQ("Hello world", text.utf8());
3637 } 3637 }
3638 3638
3639 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) 3639 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage)
3640 { 3640 {
3641 FrameTestHelpers::WebViewHelper webViewHelper(this); 3641 FrameTestHelpers::WebViewHelper webViewHelper(this);
3642 webViewHelper.initializeAndLoad("about:blank", true); 3642 webViewHelper.initializeAndLoad("about:blank", true);
3643 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame (); 3643 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
3644 3644
3645 // Generate a simple test case. 3645 // Generate a simple test case.
3646 const char simpleSource[] = "<p>Hello</p><p>World</p>"; 3646 const char simpleSource[] = "<p>Hello</p><p>World</p>";
3647 KURL testURL = toKURL("about:blank"); 3647 KURL testURL = toKURL("about:blank");
3648 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); 3648 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL);
3649 3649
3650 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max()); 3650 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max());
3651 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3651 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3652 3652
3653 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame).utf8(); 3653 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame).utf8();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3735 3735
3736 // Note that the 'result 19' in the <select> element is not expected to 3736 // Note that the 'result 19' in the <select> element is not expected to
3737 // produce a match. Also, results 00 and 01 are in a different frame that is 3737 // produce a match. Also, results 00 and 01 are in a different frame that is
3738 // not included in this test. 3738 // not included in this test.
3739 const char kFindString[] = "result"; 3739 const char kFindString[] = "result";
3740 const int kFindIdentifier = 12345; 3740 const int kFindIdentifier = 12345;
3741 const int kNumResults = 17; 3741 const int kNumResults = 17;
3742 3742
3743 WebFindOptions options; 3743 WebFindOptions options;
3744 WebString searchText = WebString::fromUTF8(kFindString); 3744 WebString searchText = WebString::fromUTF8(kFindString);
3745 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3745 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
3746 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; 3746 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
3747 3747
3748 mainFrame->resetMatchCount(); 3748 mainFrame->resetMatchCount();
3749 3749
3750 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3750 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3751 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText , options, true); 3751 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText , options, true);
3752 3752
3753 runPendingTasks(); 3753 runPendingTasks();
3754 EXPECT_TRUE(client.findResultsAreReady()); 3754 EXPECT_TRUE(client.findResultsAreReady());
3755 3755
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3795 webViewHelper.webView()->resize(WebSize(640, 480)); 3795 webViewHelper.webView()->resize(WebSize(640, 480));
3796 webViewHelper.webView()->setFocus(true); 3796 webViewHelper.webView()->setFocus(true);
3797 runPendingTasks(); 3797 runPendingTasks();
3798 3798
3799 const char* kFindString = "a"; 3799 const char* kFindString = "a";
3800 const int kFindIdentifier = 7777; 3800 const int kFindIdentifier = 7777;
3801 const int kActiveIndex = 1; 3801 const int kActiveIndex = 1;
3802 3802
3803 WebFindOptions options; 3803 WebFindOptions options;
3804 WebString searchText = WebString::fromUTF8(kFindString); 3804 WebString searchText = WebString::fromUTF8(kFindString);
3805 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3805 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
3806 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; 3806 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
3807 mainFrame->resetMatchCount(); 3807 mainFrame->resetMatchCount();
3808 3808
3809 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3809 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3810 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText , options, true); 3810 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText , options, true);
3811 3811
3812 runPendingTasks(); 3812 runPendingTasks();
3813 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; 3813 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
3814 mainFrame->stopFinding(WebLocalFrame::StopFindActionClearSelection); 3814 mainFrame->stopFinding(WebLocalFrame::StopFindActionClearSelection);
3815 3815
(...skipping 28 matching lines...) Expand all
3844 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt); 3844 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt);
3845 webViewHelper.resize(WebSize(640, 480)); 3845 webViewHelper.resize(WebSize(640, 480));
3846 webViewHelper.webView()->setFocus(true); 3846 webViewHelper.webView()->setFocus(true);
3847 runPendingTasks(); 3847 runPendingTasks();
3848 3848
3849 const char kFindString[] = "result"; 3849 const char kFindString[] = "result";
3850 const int kFindIdentifier = 12345; 3850 const int kFindIdentifier = 12345;
3851 3851
3852 WebFindOptions options; 3852 WebFindOptions options;
3853 WebString searchText = WebString::fromUTF8(kFindString); 3853 WebString searchText = WebString::fromUTF8(kFindString);
3854 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3854 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
3855 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); 3855 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false));
3856 3856
3857 // Detach the frame before finding. 3857 // Detach the frame before finding.
3858 removeElementById(mainFrame, "frame"); 3858 removeElementById(mainFrame, "frame");
3859 3859
3860 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; 3860 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
3861 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0)); 3861 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0));
3862 3862
3863 runPendingTasks(); 3863 runPendingTasks();
3864 EXPECT_FALSE(client.findResultsAreReady()); 3864 EXPECT_FALSE(client.findResultsAreReady());
(...skipping 17 matching lines...) Expand all
3882 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt); 3882 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt);
3883 webViewHelper.resize(WebSize(640, 480)); 3883 webViewHelper.resize(WebSize(640, 480));
3884 webViewHelper.webView()->setFocus(true); 3884 webViewHelper.webView()->setFocus(true);
3885 runPendingTasks(); 3885 runPendingTasks();
3886 3886
3887 const char kFindString[] = "result"; 3887 const char kFindString[] = "result";
3888 const int kFindIdentifier = 12345; 3888 const int kFindIdentifier = 12345;
3889 3889
3890 WebFindOptions options; 3890 WebFindOptions options;
3891 WebString searchText = WebString::fromUTF8(kFindString); 3891 WebString searchText = WebString::fromUTF8(kFindString);
3892 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3892 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
3893 3893
3894 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) { 3894 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) {
3895 webViewHelper.webView()->setFocusedFrame(frame); 3895 webViewHelper.webView()->setFocusedFrame(frame);
3896 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, options, false, 0)); 3896 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, options, false, 0));
3897 } 3897 }
3898 3898
3899 runPendingTasks(); 3899 runPendingTasks();
3900 EXPECT_FALSE(client.findResultsAreReady()); 3900 EXPECT_FALSE(client.findResultsAreReady());
3901 3901
3902 // Detach the frame between finding and scoping. 3902 // Detach the frame between finding and scoping.
(...skipping 18 matching lines...) Expand all
3921 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt); 3921 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt);
3922 webViewHelper.resize(WebSize(640, 480)); 3922 webViewHelper.resize(WebSize(640, 480));
3923 webViewHelper.webView()->setFocus(true); 3923 webViewHelper.webView()->setFocus(true);
3924 runPendingTasks(); 3924 runPendingTasks();
3925 3925
3926 const char kFindString[] = "result"; 3926 const char kFindString[] = "result";
3927 const int kFindIdentifier = 12345; 3927 const int kFindIdentifier = 12345;
3928 3928
3929 WebFindOptions options; 3929 WebFindOptions options;
3930 WebString searchText = WebString::fromUTF8(kFindString); 3930 WebString searchText = WebString::fromUTF8(kFindString);
3931 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3931 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
3932 3932
3933 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) { 3933 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) {
3934 webViewHelper.webView()->setFocusedFrame(frame); 3934 webViewHelper.webView()->setFocusedFrame(frame);
3935 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, options, false, 0)); 3935 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, options, false, 0));
3936 } 3936 }
3937 3937
3938 runPendingTasks(); 3938 runPendingTasks();
3939 EXPECT_FALSE(client.findResultsAreReady()); 3939 EXPECT_FALSE(client.findResultsAreReady());
3940 3940
3941 mainFrame->resetMatchCount(); 3941 mainFrame->resetMatchCount();
(...skipping 17 matching lines...) Expand all
3959 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html", true, &client); 3959 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html", true, &client);
3960 webViewHelper.resize(WebSize(640, 480)); 3960 webViewHelper.resize(WebSize(640, 480));
3961 webViewHelper.webView()->setFocus(true); 3961 webViewHelper.webView()->setFocus(true);
3962 runPendingTasks(); 3962 runPendingTasks();
3963 3963
3964 const char kFindString[] = "result"; 3964 const char kFindString[] = "result";
3965 const int kFindIdentifier = 12345; 3965 const int kFindIdentifier = 12345;
3966 3966
3967 WebFindOptions options; 3967 WebFindOptions options;
3968 WebString searchText = WebString::fromUTF8(kFindString); 3968 WebString searchText = WebString::fromUTF8(kFindString);
3969 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3969 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
3970 3970
3971 // Check that child frame exists. 3971 // Check that child frame exists.
3972 EXPECT_TRUE(!!mainFrame->traverseNext(false)); 3972 EXPECT_TRUE(!!mainFrame->traverseNext(false));
3973 3973
3974 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3974 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3975 EXPECT_FALSE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, options, false, 0)); 3975 EXPECT_FALSE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, options, false, 0));
3976 3976
3977 runPendingTasks(); 3977 runPendingTasks();
3978 EXPECT_FALSE(client.findResultsAreReady()); 3978 EXPECT_FALSE(client.findResultsAreReady());
3979 3979
3980 mainFrame->resetMatchCount(); 3980 mainFrame->resetMatchCount();
3981 } 3981 }
3982 3982
3983 TEST_P(ParameterizedWebFrameTest, SetTickmarks) 3983 TEST_P(ParameterizedWebFrameTest, SetTickmarks)
3984 { 3984 {
3985 registerMockedHttpURLLoad("find.html"); 3985 registerMockedHttpURLLoad("find.html");
3986 3986
3987 FindUpdateWebFrameClient client; 3987 FindUpdateWebFrameClient client;
3988 FrameTestHelpers::WebViewHelper webViewHelper(this); 3988 FrameTestHelpers::WebViewHelper webViewHelper(this);
3989 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); 3989 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client);
3990 webViewHelper.resize(WebSize(640, 480)); 3990 webViewHelper.resize(WebSize(640, 480));
3991 webViewHelper.webView()->setFocus(true); 3991 webViewHelper.webView()->setFocus(true);
3992 runPendingTasks(); 3992 runPendingTasks();
3993 3993
3994 const char kFindString[] = "foo"; 3994 const char kFindString[] = "foo";
3995 const int kFindIdentifier = 12345; 3995 const int kFindIdentifier = 12345;
3996 3996
3997 WebFindOptions options; 3997 WebFindOptions options;
3998 WebString searchText = WebString::fromUTF8(kFindString); 3998 WebString searchText = WebString::fromUTF8(kFindString);
3999 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3999 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
4000 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; 4000 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
4001 4001
4002 mainFrame->resetMatchCount(); 4002 mainFrame->resetMatchCount();
4003 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); 4003 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true);
4004 4004
4005 runPendingTasks(); 4005 runPendingTasks();
4006 EXPECT_TRUE(client.findResultsAreReady()); 4006 EXPECT_TRUE(client.findResultsAreReady());
4007 4007
4008 // Get the tickmarks for the original find request. 4008 // Get the tickmarks for the original find request.
4009 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 4009 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView() ;
4010 Scrollbar* scrollbar = frameView->createScrollbar(HorizontalScrollbar); 4010 Scrollbar* scrollbar = frameView->createScrollbar(HorizontalScrollbar);
4011 Vector<IntRect> originalTickmarks; 4011 Vector<IntRect> originalTickmarks;
4012 scrollbar->getTickmarks(originalTickmarks); 4012 scrollbar->getTickmarks(originalTickmarks);
4013 EXPECT_EQ(4u, originalTickmarks.size()); 4013 EXPECT_EQ(4u, originalTickmarks.size());
4014 4014
4015 // Override the tickmarks. 4015 // Override the tickmarks.
4016 Vector<IntRect> overridingTickmarksExpected; 4016 Vector<IntRect> overridingTickmarksExpected;
4017 overridingTickmarksExpected.append(IntRect(0, 0, 100, 100)); 4017 overridingTickmarksExpected.append(IntRect(0, 0, 100, 100));
4018 overridingTickmarksExpected.append(IntRect(0, 20, 100, 100)); 4018 overridingTickmarksExpected.append(IntRect(0, 20, 100, 100));
4019 overridingTickmarksExpected.append(IntRect(0, 30, 100, 100)); 4019 overridingTickmarksExpected.append(IntRect(0, 30, 100, 100));
(...skipping 18 matching lines...) Expand all
4038 { 4038 {
4039 registerMockedHttpURLLoad("find.html"); 4039 registerMockedHttpURLLoad("find.html");
4040 4040
4041 FindUpdateWebFrameClient client; 4041 FindUpdateWebFrameClient client;
4042 FrameTestHelpers::WebViewHelper webViewHelper(this); 4042 FrameTestHelpers::WebViewHelper webViewHelper(this);
4043 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); 4043 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client);
4044 webViewHelper.resize(WebSize(640, 480)); 4044 webViewHelper.resize(WebSize(640, 480));
4045 webViewHelper.webView()->setFocus(true); 4045 webViewHelper.webView()->setFocus(true);
4046 runPendingTasks(); 4046 runPendingTasks();
4047 4047
4048 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame (); 4048 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
4049 const int findIdentifier = 12345; 4049 const int findIdentifier = 12345;
4050 static const char* kFindString = "foo"; 4050 static const char* kFindString = "foo";
4051 WebString searchText = WebString::fromUTF8(kFindString); 4051 WebString searchText = WebString::fromUTF8(kFindString);
4052 WebFindOptions options; 4052 WebFindOptions options;
4053 bool activeNow; 4053 bool activeNow;
4054 4054
4055 frame->resetMatchCount(); 4055 frame->resetMatchCount();
4056 frame->scopeStringMatches(findIdentifier, searchText, options, true); 4056 frame->scopeStringMatches(findIdentifier, searchText, options, true);
4057 runPendingTasks(); 4057 runPendingTasks();
4058 EXPECT_TRUE(client.findResultsAreReady()); 4058 EXPECT_TRUE(client.findResultsAreReady());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 { 4110 {
4111 WebLocalFrame* frame; 4111 WebLocalFrame* frame;
4112 WebRect startWebRect; 4112 WebRect startWebRect;
4113 WebRect endWebRect; 4113 WebRect endWebRect;
4114 4114
4115 registerMockedHttpURLLoad("select_range_basic.html"); 4115 registerMockedHttpURLLoad("select_range_basic.html");
4116 registerMockedHttpURLLoad("select_range_scroll.html"); 4116 registerMockedHttpURLLoad("select_range_scroll.html");
4117 4117
4118 FrameTestHelpers::WebViewHelper webViewHelper(this); 4118 FrameTestHelpers::WebViewHelper webViewHelper(this);
4119 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper); 4119 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper);
4120 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4120 frame = webViewHelper.webView()->mainFrameImpl();
4121 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); 4121 EXPECT_EQ("Some test text for testing.", selectionAsString(frame));
4122 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4122 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4123 frame->executeCommand(WebString::fromUTF8("Unselect")); 4123 frame->executeCommand(WebString::fromUTF8("Unselect"));
4124 EXPECT_EQ("", selectionAsString(frame)); 4124 EXPECT_EQ("", selectionAsString(frame));
4125 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4125 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4126 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4126 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4127 std::string selectionString = selectionAsString(frame); 4127 std::string selectionString = selectionAsString(frame);
4128 EXPECT_TRUE(selectionString == "Some test text for testing." 4128 EXPECT_TRUE(selectionString == "Some test text for testing."
4129 || selectionString == "Some test text for testing"); 4129 || selectionString == "Some test text for testing");
4130 4130
4131 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper); 4131 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper);
4132 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4132 frame = webViewHelper.webView()->mainFrameImpl();
4133 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ; 4133 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ;
4134 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4134 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4135 frame->executeCommand(WebString::fromUTF8("Unselect")); 4135 frame->executeCommand(WebString::fromUTF8("Unselect"));
4136 EXPECT_EQ("", selectionAsString(frame)); 4136 EXPECT_EQ("", selectionAsString(frame));
4137 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4137 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4138 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4138 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4139 selectionString = selectionAsString(frame); 4139 selectionString = selectionAsString(frame);
4140 EXPECT_TRUE(selectionString == "Some offscreen test text for testing." 4140 EXPECT_TRUE(selectionString == "Some offscreen test text for testing."
4141 || selectionString == "Some offscreen test text for testing"); 4141 || selectionString == "Some offscreen test text for testing");
4142 } 4142 }
(...skipping 27 matching lines...) Expand all
4170 WebLocalFrame* frame; 4170 WebLocalFrame* frame;
4171 WebRect startWebRect; 4171 WebRect startWebRect;
4172 WebRect endWebRect; 4172 WebRect endWebRect;
4173 4173
4174 registerMockedHttpURLLoad("select_range_div_editable.html"); 4174 registerMockedHttpURLLoad("select_range_div_editable.html");
4175 4175
4176 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4176 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4177 // The selection range should be clipped to the bounds of the editable eleme nt. 4177 // The selection range should be clipped to the bounds of the editable eleme nt.
4178 FrameTestHelpers::WebViewHelper webViewHelper(this); 4178 FrameTestHelpers::WebViewHelper webViewHelper(this);
4179 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4179 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4180 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4180 frame = webViewHelper.webView()->mainFrameImpl();
4181 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4181 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4182 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4182 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4183 4183
4184 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4184 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4185 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4185 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4186 4186
4187 // As above, but extending the selection to the bottom of the document. 4187 // As above, but extending the selection to the bottom of the document.
4188 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4188 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4189 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4189 frame = webViewHelper.webView()->mainFrameImpl();
4190 4190
4191 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4191 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4192 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4192 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4193 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4193 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4194 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4194 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4195 4195
4196 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4196 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4197 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4197 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4198 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4198 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4199 } 4199 }
4200 4200
4201 // positionForPoint returns the wrong values for contenteditable spans. See 4201 // positionForPoint returns the wrong values for contenteditable spans. See
4202 // http://crbug.com/238334. 4202 // http://crbug.com/238334.
4203 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) 4203 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable)
4204 { 4204 {
4205 WebLocalFrame* frame; 4205 WebLocalFrame* frame;
4206 WebRect startWebRect; 4206 WebRect startWebRect;
4207 WebRect endWebRect; 4207 WebRect endWebRect;
4208 4208
4209 registerMockedHttpURLLoad("select_range_span_editable.html"); 4209 registerMockedHttpURLLoad("select_range_span_editable.html");
4210 4210
4211 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4211 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4212 // The selection range should be clipped to the bounds of the editable eleme nt. 4212 // The selection range should be clipped to the bounds of the editable eleme nt.
4213 FrameTestHelpers::WebViewHelper webViewHelper(this); 4213 FrameTestHelpers::WebViewHelper webViewHelper(this);
4214 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4214 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4215 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4215 frame = webViewHelper.webView()->mainFrameImpl();
4216 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4216 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4217 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4217 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4218 4218
4219 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4219 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4220 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4220 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4221 4221
4222 // As above, but extending the selection to the bottom of the document. 4222 // As above, but extending the selection to the bottom of the document.
4223 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4223 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4224 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4224 frame = webViewHelper.webView()->mainFrameImpl();
4225 4225
4226 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4226 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4227 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4227 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4228 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4228 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4229 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4229 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4230 4230
4231 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4231 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4232 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4232 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4233 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4233 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4234 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4234 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4235 } 4235 }
4236 4236
4237 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) 4237 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart)
4238 { 4238 {
4239 registerMockedHttpURLLoad("text_selection.html"); 4239 registerMockedHttpURLLoad("text_selection.html");
4240 FrameTestHelpers::WebViewHelper webViewHelper(this); 4240 FrameTestHelpers::WebViewHelper webViewHelper(this);
4241 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4241 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4242 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame (); 4242 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
4243 4243
4244 // Select second span. We can move the start to include the first span. 4244 // Select second span. We can move the start to include the first span.
4245 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4245 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4246 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4246 EXPECT_EQ("Header 2.", selectionAsString(frame));
4247 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1"))); 4247 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1")));
4248 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4248 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4249 4249
4250 // We can move the start and end together. 4250 // We can move the start and end together.
4251 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4251 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4252 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4252 EXPECT_EQ("Header 1.", selectionAsString(frame));
(...skipping 27 matching lines...) Expand all
4280 // positionForPoint returns the wrong values for contenteditable spans. See 4280 // positionForPoint returns the wrong values for contenteditable spans. See
4281 // http://crbug.com/238334. 4281 // http://crbug.com/238334.
4282 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); 4282 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame));
4283 } 4283 }
4284 4284
4285 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) 4285 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd)
4286 { 4286 {
4287 registerMockedHttpURLLoad("text_selection.html"); 4287 registerMockedHttpURLLoad("text_selection.html");
4288 FrameTestHelpers::WebViewHelper webViewHelper(this); 4288 FrameTestHelpers::WebViewHelper webViewHelper(this);
4289 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4289 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4290 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame (); 4290 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
4291 4291
4292 // Select first span. We can move the end to include the second span. 4292 // Select first span. We can move the end to include the second span.
4293 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4293 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4294 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4294 EXPECT_EQ("Header 1.", selectionAsString(frame));
4295 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2"))); 4295 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2")));
4296 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4296 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4297 4297
4298 // We can move the start and end together. 4298 // We can move the start and end together.
4299 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4299 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4300 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4300 EXPECT_EQ("Header 2.", selectionAsString(frame));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4333 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) 4333 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent)
4334 { 4334 {
4335 WebLocalFrameImpl* frame; 4335 WebLocalFrameImpl* frame;
4336 WebRect startWebRect; 4336 WebRect startWebRect;
4337 WebRect endWebRect; 4337 WebRect endWebRect;
4338 4338
4339 registerMockedHttpURLLoad("move_range_selection_extent.html"); 4339 registerMockedHttpURLLoad("move_range_selection_extent.html");
4340 4340
4341 FrameTestHelpers::WebViewHelper webViewHelper(this); 4341 FrameTestHelpers::WebViewHelper webViewHelper(this);
4342 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html ", &webViewHelper); 4342 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html ", &webViewHelper);
4343 frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); 4343 frame = webViewHelper.webView()->mainFrameImpl();
4344 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4344 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4345 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4345 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4346 4346
4347 frame->moveRangeSelectionExtent(WebPoint(640, 480)); 4347 frame->moveRangeSelectionExtent(WebPoint(640, 480));
4348 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4348 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4349 4349
4350 frame->moveRangeSelectionExtent(WebPoint(0, 0)); 4350 frame->moveRangeSelectionExtent(WebPoint(0, 0));
4351 EXPECT_EQ("16-char header. ", selectionAsString(frame)); 4351 EXPECT_EQ("16-char header. ", selectionAsString(frame));
4352 4352
4353 // Reset with swapped base and extent. 4353 // Reset with swapped base and extent.
(...skipping 13 matching lines...) Expand all
4367 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentCannotCollapse) 4367 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentCannotCollapse)
4368 { 4368 {
4369 WebLocalFrameImpl* frame; 4369 WebLocalFrameImpl* frame;
4370 WebRect startWebRect; 4370 WebRect startWebRect;
4371 WebRect endWebRect; 4371 WebRect endWebRect;
4372 4372
4373 registerMockedHttpURLLoad("move_range_selection_extent.html"); 4373 registerMockedHttpURLLoad("move_range_selection_extent.html");
4374 4374
4375 FrameTestHelpers::WebViewHelper webViewHelper(this); 4375 FrameTestHelpers::WebViewHelper webViewHelper(this);
4376 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html ", &webViewHelper); 4376 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html ", &webViewHelper);
4377 frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); 4377 frame = webViewHelper.webView()->mainFrameImpl();
4378 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4378 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4379 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4379 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4380 4380
4381 frame->moveRangeSelectionExtent(bottomRightMinusOne(startWebRect)); 4381 frame->moveRangeSelectionExtent(bottomRightMinusOne(startWebRect));
4382 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4382 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4383 4383
4384 // Reset with swapped base and extent. 4384 // Reset with swapped base and extent.
4385 frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect)); 4385 frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect));
4386 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4386 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4387 4387
4388 frame->moveRangeSelectionExtent(bottomRightMinusOne(endWebRect)); 4388 frame->moveRangeSelectionExtent(bottomRightMinusOne(endWebRect));
4389 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4389 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4390 } 4390 }
4391 4391
4392 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentScollsInputField) 4392 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentScollsInputField)
4393 { 4393 {
4394 WebLocalFrameImpl* frame; 4394 WebLocalFrameImpl* frame;
4395 WebRect startWebRect; 4395 WebRect startWebRect;
4396 WebRect endWebRect; 4396 WebRect endWebRect;
4397 4397
4398 registerMockedHttpURLLoad("move_range_selection_extent_input_field.html"); 4398 registerMockedHttpURLLoad("move_range_selection_extent_input_field.html");
4399 4399
4400 FrameTestHelpers::WebViewHelper webViewHelper(this); 4400 FrameTestHelpers::WebViewHelper webViewHelper(this);
4401 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent_inpu t_field.html", &webViewHelper); 4401 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent_inpu t_field.html", &webViewHelper);
4402 frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); 4402 frame = webViewHelper.webView()->mainFrameImpl();
4403 EXPECT_EQ("Length", selectionAsString(frame)); 4403 EXPECT_EQ("Length", selectionAsString(frame));
4404 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4404 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4405 4405
4406 EXPECT_EQ(0, frame->frame()->selection().rootEditableElement()->scrollLeft() ); 4406 EXPECT_EQ(0, frame->frame()->selection().rootEditableElement()->scrollLeft() );
4407 frame->moveRangeSelectionExtent(WebPoint(endWebRect.x + 500, endWebRect.y)); 4407 frame->moveRangeSelectionExtent(WebPoint(endWebRect.x + 500, endWebRect.y));
4408 EXPECT_GE(frame->frame()->selection().rootEditableElement()->scrollLeft(), 1 ); 4408 EXPECT_GE(frame->frame()->selection().rootEditableElement()->scrollLeft(), 1 );
4409 EXPECT_EQ("Lengthy text goes here.", selectionAsString(frame)); 4409 EXPECT_EQ("Lengthy text goes here.", selectionAsString(frame));
4410 } 4410 }
4411 4411
4412 static int computeOffset(LayoutObject* layoutObject, int x, int y) 4412 static int computeOffset(LayoutObject* layoutObject, int x, int y)
4413 { 4413 {
4414 return createVisiblePosition(layoutObject->positionForPoint(LayoutPoint(x, y ))).deepEquivalent().computeOffsetInContainerNode(); 4414 return createVisiblePosition(layoutObject->positionForPoint(LayoutPoint(x, y ))).deepEquivalent().computeOffsetInContainerNode();
4415 } 4415 }
4416 4416
4417 // positionForPoint returns the wrong values for contenteditable spans. See 4417 // positionForPoint returns the wrong values for contenteditable spans. See
4418 // http://crbug.com/238334. 4418 // http://crbug.com/238334.
4419 TEST_P(ParameterizedWebFrameTest, DISABLED_PositionForPointTest) 4419 TEST_P(ParameterizedWebFrameTest, DISABLED_PositionForPointTest)
4420 { 4420 {
4421 registerMockedHttpURLLoad("select_range_span_editable.html"); 4421 registerMockedHttpURLLoad("select_range_span_editable.html");
4422 FrameTestHelpers::WebViewHelper webViewHelper(this); 4422 FrameTestHelpers::WebViewHelper webViewHelper(this);
4423 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4423 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4424 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 4424 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
4425 LayoutObject* layoutObject = mainFrame->frame()->selection().rootEditableEle ment()->layoutObject(); 4425 LayoutObject* layoutObject = mainFrame->frame()->selection().rootEditableEle ment()->layoutObject();
4426 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1)); 4426 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1));
4427 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000)); 4427 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000));
4428 4428
4429 registerMockedHttpURLLoad("select_range_div_editable.html"); 4429 registerMockedHttpURLLoad("select_range_div_editable.html");
4430 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4430 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4431 mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); 4431 mainFrame = webViewHelper.webView()->mainFrameImpl();
4432 layoutObject = mainFrame->frame()->selection().rootEditableElement()->layout Object(); 4432 layoutObject = mainFrame->frame()->selection().rootEditableElement()->layout Object();
4433 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1)); 4433 EXPECT_EQ(0, computeOffset(layoutObject, -1, -1));
4434 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000)); 4434 EXPECT_EQ(64, computeOffset(layoutObject, 1000, 1000));
4435 } 4435 }
4436 4436
4437 #if !OS(MACOSX) && !OS(LINUX) 4437 #if !OS(MACOSX) && !OS(LINUX)
4438 TEST_P(ParameterizedWebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) 4438 TEST_P(ParameterizedWebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved)
4439 { 4439 {
4440 registerMockedHttpURLLoad("move_caret.html"); 4440 registerMockedHttpURLLoad("move_caret.html");
4441 4441
4442 FrameTestHelpers::WebViewHelper webViewHelper(this); 4442 FrameTestHelpers::WebViewHelper webViewHelper(this);
4443 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper ); 4443 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper );
4444 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 4444 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
4445 4445
4446 WebRect initialStartRect; 4446 WebRect initialStartRect;
4447 WebRect initialEndRect; 4447 WebRect initialEndRect;
4448 WebRect startRect; 4448 WebRect startRect;
4449 WebRect endRect; 4449 WebRect endRect;
4450 4450
4451 frame->executeScript(WebScriptSource("selectRange();")); 4451 frame->executeScript(WebScriptSource("selectRange();"));
4452 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); 4452 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect);
4453 WebPoint movedStart(topLeft(initialStartRect)); 4453 WebPoint movedStart(topLeft(initialStartRect));
4454 4454
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4573 registerMockedHttpURLLoad(testFile); 4573 registerMockedHttpURLLoad(testFile);
4574 m_webViewHelper.webView()->setFocus(true); 4574 m_webViewHelper.webView()->setFocus(true);
4575 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba seURL + testFile); 4575 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba seURL + testFile);
4576 m_webViewHelper.webView()->updateAllLifecyclePhases(); 4576 m_webViewHelper.webView()->updateAllLifecyclePhases();
4577 4577
4578 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection() ; 4578 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection() ;
4579 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star t(); 4579 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star t();
4580 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); 4580 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end();
4581 4581
4582 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); 4582 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
4583 v8::Local<v8::Value> result = m_webViewHelper.webView()->mainFrame()->to WebLocalFrame()->executeScriptAndReturnValue(WebScriptSource("expectedResult")); 4583 v8::Local<v8::Value> result = m_webViewHelper.webView()->mainFrameImpl() ->executeScriptAndReturnValue(WebScriptSource("expectedResult"));
4584 if (result.IsEmpty() || (*result)->IsUndefined()) { 4584 if (result.IsEmpty() || (*result)->IsUndefined()) {
4585 EXPECT_FALSE(selection); 4585 EXPECT_FALSE(selection);
4586 EXPECT_FALSE(selectStart); 4586 EXPECT_FALSE(selectStart);
4587 EXPECT_FALSE(selectEnd); 4587 EXPECT_FALSE(selectEnd);
4588 return; 4588 return;
4589 } 4589 }
4590 4590
4591 ASSERT_TRUE(selection); 4591 ASSERT_TRUE(selection);
4592 ASSERT_TRUE(selectStart); 4592 ASSERT_TRUE(selectStart);
4593 ASSERT_TRUE(selectEnd); 4593 ASSERT_TRUE(selectEnd);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 4682
4683 FrameTestHelpers::WebViewHelper webViewHelper(this); 4683 FrameTestHelpers::WebViewHelper webViewHelper(this);
4684 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr ); 4684 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr );
4685 webViewHelper.webView()->settings()->setDefaultFontSize(12); 4685 webViewHelper.webView()->settings()->setDefaultFontSize(12);
4686 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); 4686 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1);
4687 webViewHelper.resize(WebSize(viewWidth, viewHeight)); 4687 webViewHelper.resize(WebSize(viewWidth, viewHeight));
4688 webViewHelper.webView()->setFocus(true); 4688 webViewHelper.webView()->setFocus(true);
4689 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html"); 4689 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html");
4690 4690
4691 // The frame starts with no selection. 4691 // The frame starts with no selection.
4692 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame (); 4692 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
4693 ASSERT_TRUE(frame->hasSelection()); 4693 ASSERT_TRUE(frame->hasSelection());
4694 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4694 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4695 4695
4696 // The selection cleared notification should be triggered upon layout. 4696 // The selection cleared notification should be triggered upon layout.
4697 frame->executeCommand(WebString::fromUTF8("Unselect")); 4697 frame->executeCommand(WebString::fromUTF8("Unselect"));
4698 ASSERT_FALSE(frame->hasSelection()); 4698 ASSERT_FALSE(frame->hasSelection());
4699 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4699 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4700 webViewHelper.webView()->updateAllLifecyclePhases(); 4700 webViewHelper.webView()->updateAllLifecyclePhases();
4701 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4701 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4702 4702
4703 frame->executeCommand(WebString::fromUTF8("SelectAll")); 4703 frame->executeCommand(WebString::fromUTF8("SelectAll"));
4704 webViewHelper.webView()->updateAllLifecyclePhases(); 4704 webViewHelper.webView()->updateAllLifecyclePhases();
4705 ASSERT_TRUE(frame->hasSelection()); 4705 ASSERT_TRUE(frame->hasSelection());
4706 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4706 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4707 4707
4708 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_scroll.html"); 4708 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_scroll.html");
4709 ASSERT_TRUE(frame->hasSelection()); 4709 ASSERT_TRUE(frame->hasSelection());
4710 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4710 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4711 4711
4712 // Transitions between non-empty selections should not trigger a clearing. 4712 // Transitions between non-empty selections should not trigger a clearing.
4713 WebRect startWebRect; 4713 WebRect startWebRect;
4714 WebRect endWebRect; 4714 WebRect endWebRect;
4715 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect); 4715 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4716 WebPoint movedEnd(bottomRightMinusOne(endWebRect)); 4716 WebPoint movedEnd(bottomRightMinusOne(endWebRect));
4717 endWebRect.x -= 20; 4717 endWebRect.x -= 20;
4718 frame->selectRange(topLeft(startWebRect), movedEnd); 4718 frame->selectRange(topLeft(startWebRect), movedEnd);
4719 webViewHelper.webView()->updateAllLifecyclePhases(); 4719 webViewHelper.webView()->updateAllLifecyclePhases();
4720 ASSERT_TRUE(frame->hasSelection()); 4720 ASSERT_TRUE(frame->hasSelection());
4721 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4721 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4722 4722
4723 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame(); 4723 frame = webViewHelper.webView()->mainFrameImpl();
4724 frame->executeCommand(WebString::fromUTF8("Unselect")); 4724 frame->executeCommand(WebString::fromUTF8("Unselect"));
4725 webViewHelper.webView()->updateAllLifecyclePhases(); 4725 webViewHelper.webView()->updateAllLifecyclePhases();
4726 ASSERT_FALSE(frame->hasSelection()); 4726 ASSERT_FALSE(frame->hasSelection());
4727 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4727 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4728 } 4728 }
4729 4729
4730 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient { 4730 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient {
4731 public: 4731 public:
4732 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override 4732 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override
4733 { 4733 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
4895 TEST_F(WebFrameTest, DisambiguationPopupVisualViewport) 4895 TEST_F(WebFrameTest, DisambiguationPopupVisualViewport)
4896 { 4896 {
4897 const std::string htmlFile = "disambiguation_popup_200_by_800.html"; 4897 const std::string htmlFile = "disambiguation_popup_200_by_800.html";
4898 registerMockedHttpURLLoad(htmlFile); 4898 registerMockedHttpURLLoad(htmlFile);
4899 4899
4900 DisambiguationPopupTestWebViewClient client; 4900 DisambiguationPopupTestWebViewClient client;
4901 4901
4902 FrameTestHelpers::WebViewHelper webViewHelper; 4902 FrameTestHelpers::WebViewHelper webViewHelper;
4903 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client , nullptr, configureAndroid); 4903 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, nullptr, &client , nullptr, configureAndroid);
4904 4904
4905 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); 4905 WebViewImpl* webViewImpl = webViewHelper.webView();
4906 ASSERT_TRUE(webViewImpl); 4906 ASSERT_TRUE(webViewImpl);
4907 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); 4907 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame();
4908 ASSERT_TRUE(frame); 4908 ASSERT_TRUE(frame);
4909 4909
4910 webViewHelper.resize(WebSize(100, 200)); 4910 webViewHelper.resize(WebSize(100, 200));
4911 4911
4912 // Scroll main frame to the bottom of the document 4912 // Scroll main frame to the bottom of the document
4913 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 400)); 4913 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 400));
4914 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); 4914 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition());
4915 4915
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5140 }; 5140 };
5141 5141
5142 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) 5142 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange)
5143 { 5143 {
5144 registerMockedHttpURLLoad("spell.html"); 5144 registerMockedHttpURLLoad("spell.html");
5145 FrameTestHelpers::WebViewHelper webViewHelper(this); 5145 FrameTestHelpers::WebViewHelper webViewHelper(this);
5146 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5146 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5147 SpellCheckClient spellcheck; 5147 SpellCheckClient spellcheck;
5148 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5148 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5149 5149
5150 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5150 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5151 Document* document = frame->frame()->document(); 5151 Document* document = frame->frame()->document();
5152 Element* element = document->getElementById("data"); 5152 Element* element = document->getElementById("data");
5153 5153
5154 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5154 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5155 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5155 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5156 5156
5157 element->focus(); 5157 element->focus();
5158 NonThrowableExceptionState exceptionState; 5158 NonThrowableExceptionState exceptionState;
5159 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); 5159 document->execCommand("InsertText", false, "_wellcome_.", exceptionState);
5160 EXPECT_FALSE(exceptionState.hadException()); 5160 EXPECT_FALSE(exceptionState.hadException());
(...skipping 11 matching lines...) Expand all
5172 } 5172 }
5173 5173
5174 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) 5174 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers)
5175 { 5175 {
5176 registerMockedHttpURLLoad("spell.html"); 5176 registerMockedHttpURLLoad("spell.html");
5177 FrameTestHelpers::WebViewHelper webViewHelper(this); 5177 FrameTestHelpers::WebViewHelper webViewHelper(this);
5178 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5178 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5179 SpellCheckClient spellcheck; 5179 SpellCheckClient spellcheck;
5180 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5180 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5181 5181
5182 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5182 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5183 Document* document = frame->frame()->document(); 5183 Document* document = frame->frame()->document();
5184 Element* element = document->getElementById("data"); 5184 Element* element = document->getElementById("data");
5185 5185
5186 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5186 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5187 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5187 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5188 5188
5189 element->focus(); 5189 element->focus();
5190 NonThrowableExceptionState exceptionState; 5190 NonThrowableExceptionState exceptionState;
5191 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); 5191 document->execCommand("InsertText", false, "_wellcome_.", exceptionState);
5192 EXPECT_FALSE(exceptionState.hadException()); 5192 EXPECT_FALSE(exceptionState.hadException());
5193 5193
5194 frame->removeSpellingMarkers(); 5194 frame->removeSpellingMarkers();
5195 5195
5196 const int allTextBeginOffset = 0; 5196 const int allTextBeginOffset = 0;
5197 const int allTextLength = 11; 5197 const int allTextLength = 11;
5198 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength)); 5198 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength));
5199 EphemeralRange selectionRange = frame->frame()->selection().selection().toNo rmalizedEphemeralRange(); 5199 EphemeralRange selectionRange = frame->frame()->selection().selection().toNo rmalizedEphemeralRange();
5200 5200
5201 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange, DocumentMar ker::Spelling).size()); 5201 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange, DocumentMar ker::Spelling).size());
5202 } 5202 }
5203 5203
5204 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) 5204 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords)
5205 { 5205 {
5206 registerMockedHttpURLLoad("spell.html"); 5206 registerMockedHttpURLLoad("spell.html");
5207 FrameTestHelpers::WebViewHelper webViewHelper(this); 5207 FrameTestHelpers::WebViewHelper webViewHelper(this);
5208 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5208 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5209 SpellCheckClient spellcheck; 5209 SpellCheckClient spellcheck;
5210 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5210 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5211 5211
5212 LocalFrame* frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame() )->frame(); 5212 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame();
5213 Document* document = frame->document(); 5213 Document* document = frame->document();
5214 Element* element = document->getElementById("data"); 5214 Element* element = document->getElementById("data");
5215 5215
5216 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5216 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5217 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5217 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5218 5218
5219 element->focus(); 5219 element->focus();
5220 NonThrowableExceptionState exceptionState; 5220 NonThrowableExceptionState exceptionState;
5221 document->execCommand("InsertText", false, " wellcome ", exceptionState); 5221 document->execCommand("InsertText", false, " wellcome ", exceptionState);
5222 EXPECT_FALSE(exceptionState.hadException()); 5222 EXPECT_FALSE(exceptionState.hadException());
(...skipping 14 matching lines...) Expand all
5237 TEST_P(ParameterizedWebFrameTest, MarkerHashIdentifiers) 5237 TEST_P(ParameterizedWebFrameTest, MarkerHashIdentifiers)
5238 { 5238 {
5239 registerMockedHttpURLLoad("spell.html"); 5239 registerMockedHttpURLLoad("spell.html");
5240 FrameTestHelpers::WebViewHelper webViewHelper(this); 5240 FrameTestHelpers::WebViewHelper webViewHelper(this);
5241 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5241 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5242 5242
5243 static const uint32_t kHash = 42; 5243 static const uint32_t kHash = 42;
5244 SpellCheckClient spellcheck(kHash); 5244 SpellCheckClient spellcheck(kHash);
5245 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5245 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5246 5246
5247 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5247 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5248 Document* document = frame->frame()->document(); 5248 Document* document = frame->frame()->document();
5249 Element* element = document->getElementById("data"); 5249 Element* element = document->getElementById("data");
5250 5250
5251 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5251 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5252 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5252 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5253 5253
5254 element->focus(); 5254 element->focus();
5255 NonThrowableExceptionState exceptionState; 5255 NonThrowableExceptionState exceptionState;
5256 document->execCommand("InsertText", false, "wellcome.", exceptionState); 5256 document->execCommand("InsertText", false, "wellcome.", exceptionState);
5257 EXPECT_FALSE(exceptionState.hadException()); 5257 EXPECT_FALSE(exceptionState.hadException());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5313 5313
5314 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) 5314 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition)
5315 { 5315 {
5316 registerMockedHttpURLLoad("spell.html"); 5316 registerMockedHttpURLLoad("spell.html");
5317 FrameTestHelpers::WebViewHelper webViewHelper(this); 5317 FrameTestHelpers::WebViewHelper webViewHelper(this);
5318 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5318 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5319 5319
5320 StubbornSpellCheckClient spellcheck; 5320 StubbornSpellCheckClient spellcheck;
5321 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5321 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5322 5322
5323 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5323 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5324 Document* document = frame->frame()->document(); 5324 Document* document = frame->frame()->document();
5325 Element* element = document->getElementById("data"); 5325 Element* element = document->getElementById("data");
5326 5326
5327 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5327 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5328 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5328 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5329 5329
5330 element->focus(); 5330 element->focus();
5331 NonThrowableExceptionState exceptionState; 5331 NonThrowableExceptionState exceptionState;
5332 document->execCommand("InsertText", false, "wellcome ", exceptionState); 5332 document->execCommand("InsertText", false, "wellcome ", exceptionState);
5333 EXPECT_FALSE(exceptionState.hadException()); 5333 EXPECT_FALSE(exceptionState.hadException());
5334 document->execCommand("InsertText", false, "he", exceptionState); 5334 document->execCommand("InsertText", false, "he", exceptionState);
5335 EXPECT_FALSE(exceptionState.hadException()); 5335 EXPECT_FALSE(exceptionState.hadException());
5336 5336
5337 spellcheck.kick(); 5337 spellcheck.kick();
5338 5338
5339 WebVector<uint32_t> documentMarkers; 5339 WebVector<uint32_t> documentMarkers;
5340 webViewHelper.webView()->spellingMarkers(&documentMarkers); 5340 webViewHelper.webView()->spellingMarkers(&documentMarkers);
5341 EXPECT_EQ(0U, documentMarkers.size()); 5341 EXPECT_EQ(0U, documentMarkers.size());
5342 } 5342 }
5343 5343
5344 // This test verifies that cancelling spelling request does not cause a 5344 // This test verifies that cancelling spelling request does not cause a
5345 // write-after-free when there's no spellcheck client set. 5345 // write-after-free when there's no spellcheck client set.
5346 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) 5346 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash)
5347 { 5347 {
5348 registerMockedHttpURLLoad("spell.html"); 5348 registerMockedHttpURLLoad("spell.html");
5349 FrameTestHelpers::WebViewHelper webViewHelper(this); 5349 FrameTestHelpers::WebViewHelper webViewHelper(this);
5350 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5350 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5351 webViewHelper.webView()->setSpellCheckClient(0); 5351 webViewHelper.webView()->setSpellCheckClient(0);
5352 5352
5353 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5353 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5354 Document* document = frame->frame()->document(); 5354 Document* document = frame->frame()->document();
5355 Element* element = document->getElementById("data"); 5355 Element* element = document->getElementById("data");
5356 5356
5357 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5357 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5358 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5358 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5359 5359
5360 element->focus(); 5360 element->focus();
5361 frame->frame()->editor().replaceSelectionWithText("A", false, false); 5361 frame->frame()->editor().replaceSelectionWithText("A", false, false);
5362 frame->frame()->spellChecker().cancelCheck(); 5362 frame->frame()->spellChecker().cancelCheck();
5363 } 5363 }
5364 5364
5365 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) 5365 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers)
5366 { 5366 {
5367 registerMockedHttpURLLoad("spell.html"); 5367 registerMockedHttpURLLoad("spell.html");
5368 FrameTestHelpers::WebViewHelper webViewHelper(this); 5368 FrameTestHelpers::WebViewHelper webViewHelper(this);
5369 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5369 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5370 5370
5371 StubbornSpellCheckClient spellcheck; 5371 StubbornSpellCheckClient spellcheck;
5372 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5372 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5373 5373
5374 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5374 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5375 Document* document = frame->frame()->document(); 5375 Document* document = frame->frame()->document();
5376 Element* element = document->getElementById("data"); 5376 Element* element = document->getElementById("data");
5377 5377
5378 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5378 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5379 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5379 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5380 5380
5381 element->focus(); 5381 element->focus();
5382 NonThrowableExceptionState exceptionState; 5382 NonThrowableExceptionState exceptionState;
5383 document->execCommand("InsertText", false, "welcome ", exceptionState); 5383 document->execCommand("InsertText", false, "welcome ", exceptionState);
5384 EXPECT_FALSE(exceptionState.hadException()); 5384 EXPECT_FALSE(exceptionState.hadException());
5385 auto range = EphemeralRange::rangeOfContents(*element); 5385 auto range = EphemeralRange::rangeOfContents(*element);
5386 document->markers().addMarker(range.startPosition(), range.endPosition(), Do cumentMarker::Spelling); 5386 document->markers().addMarker(range.startPosition(), range.endPosition(), Do cumentMarker::Spelling);
5387 document->markers().addMarker(range.startPosition(), range.endPosition(), Do cumentMarker::Grammar); 5387 document->markers().addMarker(range.startPosition(), range.endPosition(), Do cumentMarker::Grammar);
5388 document->markers().addMarker(range.startPosition(), range.endPosition(), Do cumentMarker::InvisibleSpellcheck); 5388 document->markers().addMarker(range.startPosition(), range.endPosition(), Do cumentMarker::InvisibleSpellcheck);
5389 EXPECT_EQ(3U, document->markers().markers().size()); 5389 EXPECT_EQ(3U, document->markers().markers().size());
5390 5390
5391 spellcheck.kickNoResults(); 5391 spellcheck.kickNoResults();
5392 EXPECT_EQ(0U, document->markers().markers().size()); 5392 EXPECT_EQ(0U, document->markers().markers().size());
5393 } 5393 }
5394 5394
5395 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) 5395 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument)
5396 { 5396 {
5397 registerMockedHttpURLLoad("spell.html"); 5397 registerMockedHttpURLLoad("spell.html");
5398 FrameTestHelpers::WebViewHelper webViewHelper(this); 5398 FrameTestHelpers::WebViewHelper webViewHelper(this);
5399 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 5399 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
5400 5400
5401 StubbornSpellCheckClient spellcheck; 5401 StubbornSpellCheckClient spellcheck;
5402 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 5402 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
5403 5403
5404 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 5404 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
5405 Document* document = frame->frame()->document(); 5405 Document* document = frame->frame()->document();
5406 Element* element = document->getElementById("data"); 5406 Element* element = document->getElementById("data");
5407 5407
5408 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 5408 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
5409 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 5409 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
5410 5410
5411 element->focus(); 5411 element->focus();
5412 NonThrowableExceptionState exceptionState; 5412 NonThrowableExceptionState exceptionState;
5413 document->execCommand("InsertText", false, "wellcome ", exceptionState); 5413 document->execCommand("InsertText", false, "wellcome ", exceptionState);
5414 EXPECT_FALSE(exceptionState.hadException()); 5414 EXPECT_FALSE(exceptionState.hadException());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
5628 { 5628 {
5629 registerMockedHttpURLLoad("long_scroll.html"); 5629 registerMockedHttpURLLoad("long_scroll.html");
5630 TestScrolledFrameClient client; 5630 TestScrolledFrameClient client;
5631 5631
5632 // Make sure we initialize to minimum scale, even if the window size 5632 // Make sure we initialize to minimum scale, even if the window size
5633 // only becomes available after the load begins. 5633 // only becomes available after the load begins.
5634 FrameTestHelpers::WebViewHelper webViewHelper; 5634 FrameTestHelpers::WebViewHelper webViewHelper;
5635 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien t); 5635 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien t);
5636 webViewHelper.resize(WebSize(1000, 1000)); 5636 webViewHelper.resize(WebSize(1000, 1000));
5637 5637
5638 WebLocalFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); 5638 WebLocalFrameImpl* frameImpl = webViewHelper.webView()->mainFrameImpl();
5639 DocumentLoader::InitialScrollState& initialScrollState = 5639 DocumentLoader::InitialScrollState& initialScrollState =
5640 frameImpl->frame()->loader().documentLoader()->initialScrollState(); 5640 frameImpl->frame()->loader().documentLoader()->initialScrollState();
5641 GraphicsLayer* frameViewLayer = frameImpl->frameView()->layerForScrolling(); 5641 GraphicsLayer* frameViewLayer = frameImpl->frameView()->layerForScrolling();
5642 5642
5643 EXPECT_FALSE(client.wasFrameScrolled()); 5643 EXPECT_FALSE(client.wasFrameScrolled());
5644 EXPECT_FALSE(initialScrollState.wasScrolledByUser); 5644 EXPECT_FALSE(initialScrollState.wasScrolledByUser);
5645 5645
5646 // Do a compositor scroll, verify that this is counted as a user scroll. 5646 // Do a compositor scroll, verify that this is counted as a user scroll.
5647 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(0, 1 )); 5647 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(0, 1 ));
5648 frameViewLayer->didScroll(); 5648 frameViewLayer->didScroll();
5649 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.7f, 0); 5649 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.7f, 0);
5650 EXPECT_TRUE(client.wasFrameScrolled()); 5650 EXPECT_TRUE(client.wasFrameScrolled());
5651 EXPECT_TRUE(initialScrollState.wasScrolledByUser); 5651 EXPECT_TRUE(initialScrollState.wasScrolledByUser);
5652 5652
5653 client.reset(); 5653 client.reset();
5654 initialScrollState.wasScrolledByUser = false; 5654 initialScrollState.wasScrolledByUser = false;
5655 5655
5656 // The page scale 1.0f and scroll. 5656 // The page scale 1.0f and scroll.
5657 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(0, 2 )); 5657 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(0, 2 ));
5658 frameViewLayer->didScroll(); 5658 frameViewLayer->didScroll();
5659 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.0f, 0); 5659 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 0);
5660 EXPECT_TRUE(client.wasFrameScrolled()); 5660 EXPECT_TRUE(client.wasFrameScrolled());
5661 EXPECT_TRUE(initialScrollState.wasScrolledByUser); 5661 EXPECT_TRUE(initialScrollState.wasScrolledByUser);
5662 client.reset(); 5662 client.reset();
5663 initialScrollState.wasScrolledByUser = false; 5663 initialScrollState.wasScrolledByUser = false;
5664 5664
5665 // No scroll event if there is no scroll delta. 5665 // No scroll event if there is no scroll delta.
5666 frameViewLayer->didScroll(); 5666 frameViewLayer->didScroll();
5667 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 1.0f, 0); 5667 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 0);
5668 EXPECT_FALSE(client.wasFrameScrolled()); 5668 EXPECT_FALSE(client.wasFrameScrolled());
5669 EXPECT_FALSE(initialScrollState.wasScrolledByUser); 5669 EXPECT_FALSE(initialScrollState.wasScrolledByUser);
5670 client.reset(); 5670 client.reset();
5671 5671
5672 // Non zero page scale and scroll. 5672 // Non zero page scale and scroll.
5673 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(9, 1 5)); 5673 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(9, 1 5));
5674 frameViewLayer->didScroll(); 5674 frameViewLayer->didScroll();
5675 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz e(), WebFloatSize(), 0.6f, 0); 5675 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 0.6f, 0);
5676 EXPECT_TRUE(client.wasFrameScrolled()); 5676 EXPECT_TRUE(client.wasFrameScrolled());
5677 EXPECT_TRUE(initialScrollState.wasScrolledByUser); 5677 EXPECT_TRUE(initialScrollState.wasScrolledByUser);
5678 client.reset(); 5678 client.reset();
5679 initialScrollState.wasScrolledByUser = false; 5679 initialScrollState.wasScrolledByUser = false;
5680 5680
5681 // Programmatic scroll. 5681 // Programmatic scroll.
5682 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); 5682 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);"));
5683 EXPECT_TRUE(client.wasFrameScrolled()); 5683 EXPECT_TRUE(client.wasFrameScrolled());
5684 EXPECT_FALSE(initialScrollState.wasScrolledByUser); 5684 EXPECT_FALSE(initialScrollState.wasScrolledByUser);
5685 client.reset(); 5685 client.reset();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5723 } 5723 }
5724 }; 5724 };
5725 5725
5726 TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick) 5726 TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick)
5727 { 5727 {
5728 registerMockedHttpURLLoad("fragment_middle_click.html"); 5728 registerMockedHttpURLLoad("fragment_middle_click.html");
5729 TestNavigationPolicyWebFrameClient client; 5729 TestNavigationPolicyWebFrameClient client;
5730 FrameTestHelpers::WebViewHelper webViewHelper(this); 5730 FrameTestHelpers::WebViewHelper webViewHelper(this);
5731 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue, &client); 5731 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue, &client);
5732 5732
5733 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 5733 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
5734 KURL destination = document->url(); 5734 KURL destination = document->url();
5735 destination.setFragmentIdentifier("test"); 5735 destination.setFragmentIdentifier("test");
5736 5736
5737 Event* event = MouseEvent::create(EventTypeNames::click, false, false, 5737 Event* event = MouseEvent::create(EventTypeNames::click, false, false,
5738 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::NoModifiers, 1, 0, nullptr, 0, 5738 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::NoModifiers, 1, 0, nullptr, 0,
5739 PlatformMouseEvent::RealOrIndistinguishable, String()); 5739 PlatformMouseEvent::RealOrIndistinguishable, String());
5740 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); 5740 FrameLoadRequest frameRequest(document, ResourceRequest(destination));
5741 frameRequest.setTriggeringEvent(event); 5741 frameRequest.setTriggeringEvent(event);
5742 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 5742 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr ameRequest);
5743 } 5743 }
5744 5744
5745 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { 5745 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient {
5746 public: 5746 public:
5747 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW indowFeatures&, 5747 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW indowFeatures&,
5748 const WebString&, WebNavigationPolicy, bool) override 5748 const WebString&, WebNavigationPolicy, bool) override
5749 { 5749 {
5750 EXPECT_TRUE(false); 5750 EXPECT_TRUE(false);
5751 return 0; 5751 return 0;
5752 } 5752 }
(...skipping 20 matching lines...) Expand all
5773 5773
5774 TEST_P(ParameterizedWebFrameTest, ModifiedClickNewWindow) 5774 TEST_P(ParameterizedWebFrameTest, ModifiedClickNewWindow)
5775 { 5775 {
5776 registerMockedHttpURLLoad("ctrl_click.html"); 5776 registerMockedHttpURLLoad("ctrl_click.html");
5777 registerMockedHttpURLLoad("hello_world.html"); 5777 registerMockedHttpURLLoad("hello_world.html");
5778 TestNewWindowWebViewClient webViewClient; 5778 TestNewWindowWebViewClient webViewClient;
5779 TestNewWindowWebFrameClient webFrameClient; 5779 TestNewWindowWebFrameClient webFrameClient;
5780 FrameTestHelpers::WebViewHelper webViewHelper(this); 5780 FrameTestHelpers::WebViewHelper webViewHelper(this);
5781 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra meClient, &webViewClient); 5781 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra meClient, &webViewClient);
5782 5782
5783 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document(); 5783 Document* document = toLocalFrame(webViewHelper.webView()->page()->mainFrame ())->document();
5784 KURL destination = toKURL(m_baseURL + "hello_world.html"); 5784 KURL destination = toKURL(m_baseURL + "hello_world.html");
5785 5785
5786 // ctrl+click event 5786 // ctrl+click event
5787 Event* event = MouseEvent::create(EventTypeNames::click, false, false, 5787 Event* event = MouseEvent::create(EventTypeNames::click, false, false,
5788 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::CtrlKey, 0, 0 , nullptr, 0, 5788 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::CtrlKey, 0, 0 , nullptr, 0,
5789 PlatformMouseEvent::RealOrIndistinguishable, String()); 5789 PlatformMouseEvent::RealOrIndistinguishable, String());
5790 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); 5790 FrameLoadRequest frameRequest(document, ResourceRequest(destination));
5791 frameRequest.setTriggeringEvent(event); 5791 frameRequest.setTriggeringEvent(event);
5792 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 5792 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
5793 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 5793 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr ameRequest);
5794 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame()); 5794 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
5795 5795
5796 // decidePolicyForNavigation should be called both for the original request and the ctrl+click. 5796 // decidePolicyForNavigation should be called both for the original request and the ctrl+click.
5797 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); 5797 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount());
5798 } 5798 }
5799 5799
5800 TEST_P(ParameterizedWebFrameTest, BackToReload) 5800 TEST_P(ParameterizedWebFrameTest, BackToReload)
5801 { 5801 {
5802 registerMockedHttpURLLoad("fragment_middle_click.html"); 5802 registerMockedHttpURLLoad("fragment_middle_click.html");
5803 FrameTestHelpers::WebViewHelper webViewHelper(this); 5803 FrameTestHelpers::WebViewHelper webViewHelper(this);
5804 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue); 5804 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue);
5805 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5805 WebFrame* frame = webViewHelper.webView()->mainFrame();
5806 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 5806 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl( )->frame()->loader();
5807 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); 5807 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem();
5808 EXPECT_TRUE(firstItem); 5808 EXPECT_TRUE(firstItem);
5809 5809
5810 registerMockedHttpURLLoad("white-1x1.png"); 5810 registerMockedHttpURLLoad("white-1x1.png");
5811 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); 5811 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png");
5812 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); 5812 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem());
5813 5813
5814 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We bHistoryDifferentDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); 5814 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We bHistoryDifferentDocumentLoad, WebCachePolicy::UseProtocolCachePolicy);
5815 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); 5815 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem());
5816 5816
5817 FrameTestHelpers::reloadFrame(frame); 5817 FrameTestHelpers::reloadFrame(frame);
5818 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy()); 5818 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy());
5819 } 5819 }
5820 5820
5821 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) 5821 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload)
5822 { 5822 {
5823 registerMockedHttpURLLoad("page_with_blank_iframe.html"); 5823 registerMockedHttpURLLoad("page_with_blank_iframe.html");
5824 FrameTestHelpers::WebViewHelper webViewHelper(this); 5824 FrameTestHelpers::WebViewHelper webViewHelper(this);
5825 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t rue); 5825 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t rue);
5826 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); 5826 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrameImpl();
5827 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 5827 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl( )->frame()->loader();
5828 WebFrame* childFrame = mainFrame->firstChild(); 5828 WebFrame* childFrame = mainFrame->firstChild();
5829 ASSERT_TRUE(childFrame); 5829 ASSERT_TRUE(childFrame);
5830 5830
5831 // Start a history navigation, then have a different frame commit a navigati on. 5831 // Start a history navigation, then have a different frame commit a navigati on.
5832 // In this case, reload an about:blank frame, which will commit synchronousl y. 5832 // In this case, reload an about:blank frame, which will commit synchronousl y.
5833 // After the history navigation completes, both the appropriate document url and 5833 // After the history navigation completes, both the appropriate document url and
5834 // the current history item should reflect the history navigation. 5834 // the current history item should reflect the history navigation.
5835 registerMockedHttpURLLoad("white-1x1.png"); 5835 registerMockedHttpURLLoad("white-1x1.png");
5836 WebHistoryItem item; 5836 WebHistoryItem item;
5837 item.initialize(); 5837 item.initialize();
5838 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); 5838 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png"));
5839 item.setURLString(historyURL.string()); 5839 item.setURLString(historyURL.string());
5840 WebURLRequest request = mainFrame->toWebLocalFrame()->requestFromHistoryItem (item, WebCachePolicy::UseProtocolCachePolicy); 5840 WebURLRequest request = mainFrame->requestFromHistoryItem(item, WebCachePoli cy::UseProtocolCachePolicy);
5841 mainFrame->toWebLocalFrame()->load(request, WebFrameLoadType::BackForward, i tem); 5841 mainFrame->load(request, WebFrameLoadType::BackForward, item);
5842 5842
5843 FrameTestHelpers::reloadFrame(childFrame); 5843 FrameTestHelpers::reloadFrame(childFrame);
5844 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); 5844 EXPECT_EQ(item.urlString(), mainFrame->document().url().string());
5845 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri ng())); 5845 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri ng()));
5846 } 5846 }
5847 5847
5848 TEST_P(ParameterizedWebFrameTest, ReloadPost) 5848 TEST_P(ParameterizedWebFrameTest, ReloadPost)
5849 { 5849 {
5850 registerMockedHttpURLLoad("reload_post.html"); 5850 registerMockedHttpURLLoad("reload_post.html");
5851 FrameTestHelpers::WebViewHelper webViewHelper(this); 5851 FrameTestHelpers::WebViewHelper webViewHelper(this);
(...skipping 10 matching lines...) Expand all
5862 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy()); 5862 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy());
5863 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT ype()); 5863 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT ype());
5864 } 5864 }
5865 5865
5866 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) 5866 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload)
5867 { 5867 {
5868 registerMockedHttpURLLoad("fragment_middle_click.html"); 5868 registerMockedHttpURLLoad("fragment_middle_click.html");
5869 FrameTestHelpers::WebViewHelper webViewHelper(this); 5869 FrameTestHelpers::WebViewHelper webViewHelper(this);
5870 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue); 5870 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue);
5871 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5871 WebFrame* frame = webViewHelper.webView()->mainFrame();
5872 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 5872 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl( )->frame()->loader();
5873 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); 5873 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem();
5874 EXPECT_TRUE(firstItem); 5874 EXPECT_TRUE(firstItem);
5875 5875
5876 registerMockedHttpURLLoad("white-1x1.png"); 5876 registerMockedHttpURLLoad("white-1x1.png");
5877 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); 5877 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png");
5878 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); 5878 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem());
5879 5879
5880 // Cache policy overrides should take. 5880 // Cache policy overrides should take.
5881 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto ryDifferentDocumentLoad, WebCachePolicy::ValidatingCacheData); 5881 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto ryDifferentDocumentLoad, WebCachePolicy::ValidatingCacheData);
5882 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); 5882 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
5946 { 5946 {
5947 registerMockedHttpURLLoad("iframe_reload.html"); 5947 registerMockedHttpURLLoad("iframe_reload.html");
5948 registerMockedHttpURLLoad("visible_iframe.html"); 5948 registerMockedHttpURLLoad("visible_iframe.html");
5949 TestCachePolicyWebFrameClient mainClient(0); 5949 TestCachePolicyWebFrameClient mainClient(0);
5950 TestCachePolicyWebFrameClient childClient(&mainClient); 5950 TestCachePolicyWebFrameClient childClient(&mainClient);
5951 mainClient.setChildWebFrameClient(&childClient); 5951 mainClient.setChildWebFrameClient(&childClient);
5952 5952
5953 FrameTestHelpers::WebViewHelper webViewHelper(this); 5953 FrameTestHelpers::WebViewHelper webViewHelper(this);
5954 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai nClient); 5954 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai nClient);
5955 5955
5956 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); 5956 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
5957 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild()) ; 5957 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild()) ;
5958 ASSERT_EQ(childFrame->client(), &childClient); 5958 ASSERT_EQ(childFrame->client(), &childClient);
5959 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); 5959 EXPECT_EQ(mainClient.childFrameCreationCount(), 1);
5960 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); 5960 EXPECT_EQ(childClient.willSendRequestCallCount(), 1);
5961 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli cy); 5961 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli cy);
5962 5962
5963 FrameTestHelpers::reloadFrame(mainFrame); 5963 FrameTestHelpers::reloadFrame(mainFrame);
5964 5964
5965 // A new WebFrame should have been created, but the child WebFrameClient sho uld be reused. 5965 // A new WebFrame should have been created, but the child WebFrameClient sho uld be reused.
5966 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); 5966 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild()));
(...skipping 24 matching lines...) Expand all
5991 }; 5991 };
5992 5992
5993 TEST_P(ParameterizedWebFrameTest, NavigateToSame) 5993 TEST_P(ParameterizedWebFrameTest, NavigateToSame)
5994 { 5994 {
5995 registerMockedHttpURLLoad("navigate_to_same.html"); 5995 registerMockedHttpURLLoad("navigate_to_same.html");
5996 TestSameDocumentWebFrameClient client; 5996 TestSameDocumentWebFrameClient client;
5997 FrameTestHelpers::WebViewHelper webViewHelper(this); 5997 FrameTestHelpers::WebViewHelper webViewHelper(this);
5998 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, & client); 5998 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, & client);
5999 EXPECT_FALSE(client.frameLoadTypeReloadMainResourceSeen()); 5999 EXPECT_FALSE(client.frameLoadTypeReloadMainResourceSeen());
6000 6000
6001 FrameLoadRequest frameRequest(0, ResourceRequest(toLocalFrame(webViewHelper. webViewImpl()->page()->mainFrame())->document()->url())); 6001 FrameLoadRequest frameRequest(0, ResourceRequest(toLocalFrame(webViewHelper. webView()->page()->mainFrame())->document()->url()));
6002 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 6002 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->loader().load(fr ameRequest);
6003 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame()); 6003 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
6004 6004
6005 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen()); 6005 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen());
6006 } 6006 }
6007 6007
6008 class TestSameDocumentWithImageWebFrameClient : public FrameTestHelpers::TestWeb FrameClient { 6008 class TestSameDocumentWithImageWebFrameClient : public FrameTestHelpers::TestWeb FrameClient {
6009 public: 6009 public:
6010 TestSameDocumentWithImageWebFrameClient() 6010 TestSameDocumentWithImageWebFrameClient()
6011 : m_numOfImageRequests(0) 6011 : m_numOfImageRequests(0)
6012 { 6012 {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
6234 TEST_F(WebFrameTest, overflowHiddenRewrite) 6234 TEST_F(WebFrameTest, overflowHiddenRewrite)
6235 { 6235 {
6236 registerMockedHttpURLLoad("non-scrollable.html"); 6236 registerMockedHttpURLLoad("non-scrollable.html");
6237 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient()); 6237 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient());
6238 FrameTestHelpers::WebViewHelper webViewHelper; 6238 FrameTestHelpers::WebViewHelper webViewHelper;
6239 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView); 6239 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView);
6240 6240
6241 webViewHelper.resize(WebSize(100, 100)); 6241 webViewHelper.resize(WebSize(100, 100));
6242 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html"); 6242 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html");
6243 6243
6244 PaintLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor( ); 6244 PaintLayerCompositor* compositor = webViewHelper.webView()->compositor();
6245 ASSERT_TRUE(compositor->scrollLayer()); 6245 ASSERT_TRUE(compositor->scrollLayer());
6246 6246
6247 // Verify that the WebLayer is not scrollable initially. 6247 // Verify that the WebLayer is not scrollable initially.
6248 GraphicsLayer* scrollLayer = compositor->scrollLayer(); 6248 GraphicsLayer* scrollLayer = compositor->scrollLayer();
6249 WebLayer* webScrollLayer = scrollLayer->platformLayer(); 6249 WebLayer* webScrollLayer = scrollLayer->platformLayer();
6250 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); 6250 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal());
6251 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); 6251 ASSERT_FALSE(webScrollLayer->userScrollableVertical());
6252 6252
6253 // Call javascript to make the layer scrollable, and verify it. 6253 // Call javascript to make the layer scrollable, and verify it.
6254 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main Frame(); 6254 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main Frame();
6255 frame->executeScript(WebScriptSource("allowScroll();")); 6255 frame->executeScript(WebScriptSource("allowScroll();"));
6256 webViewHelper.webView()->updateAllLifecyclePhases(); 6256 webViewHelper.webView()->updateAllLifecyclePhases();
6257 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 6257 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
6258 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 6258 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
6259 } 6259 }
6260 6260
6261 // Test that currentHistoryItem reflects the current page, not the provisional l oad. 6261 // Test that currentHistoryItem reflects the current page, not the provisional l oad.
6262 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) 6262 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem)
6263 { 6263 {
6264 registerMockedHttpURLLoad("fixed_layout.html"); 6264 registerMockedHttpURLLoad("fixed_layout.html");
6265 std::string url = m_baseURL + "fixed_layout.html"; 6265 std::string url = m_baseURL + "fixed_layout.html";
6266 6266
6267 FrameTestHelpers::WebViewHelper webViewHelper(this); 6267 FrameTestHelpers::WebViewHelper webViewHelper(this);
6268 webViewHelper.initialize(); 6268 webViewHelper.initialize();
6269 WebFrame* frame = webViewHelper.webView()->mainFrame(); 6269 WebFrame* frame = webViewHelper.webView()->mainFrame();
6270 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 6270 const FrameLoader& mainFrameLoader = webViewHelper.webView()->mainFrameImpl( )->frame()->loader();
6271 WebURLRequest request; 6271 WebURLRequest request;
6272 request.setURL(toKURL(url)); 6272 request.setURL(toKURL(url));
6273 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); 6273 request.setRequestorOrigin(WebSecurityOrigin::createUnique());
6274 frame->loadRequest(request); 6274 frame->loadRequest(request);
6275 6275
6276 // Before commit, there is no history item. 6276 // Before commit, there is no history item.
6277 EXPECT_FALSE(mainFrameLoader.currentItem()); 6277 EXPECT_FALSE(mainFrameLoader.currentItem());
6278 6278
6279 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(frame); 6279 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(frame);
6280 6280
(...skipping 29 matching lines...) Expand all
6310 6310
6311 EXPECT_EQ(1, client.callCount()); 6311 EXPECT_EQ(1, client.callCount());
6312 } 6312 }
6313 6313
6314 TEST_P(ParameterizedWebFrameTest, fixedPositionInFixedViewport) 6314 TEST_P(ParameterizedWebFrameTest, fixedPositionInFixedViewport)
6315 { 6315 {
6316 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); 6316 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html");
6317 FrameTestHelpers::WebViewHelper webViewHelper(this); 6317 FrameTestHelpers::WebViewHelper webViewHelper(this);
6318 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor t.html", true, nullptr, nullptr, nullptr, enableViewportSettings); 6318 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor t.html", true, nullptr, nullptr, nullptr, enableViewportSettings);
6319 6319
6320 WebView* webView = webViewHelper.webView(); 6320 WebViewImpl* webView = webViewHelper.webView();
6321 webViewHelper.resize(WebSize(100, 100)); 6321 webViewHelper.resize(WebSize(100, 100));
6322 6322
6323 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc ument(); 6323 Document* document = webView->mainFrameImpl()->frame()->document();
6324 Element* bottomFixed = document->getElementById("bottom-fixed"); 6324 Element* bottomFixed = document->getElementById("bottom-fixed");
6325 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); 6325 Element* topBottomFixed = document->getElementById("top-bottom-fixed");
6326 Element* rightFixed = document->getElementById("right-fixed"); 6326 Element* rightFixed = document->getElementById("right-fixed");
6327 Element* leftRightFixed = document->getElementById("left-right-fixed"); 6327 Element* leftRightFixed = document->getElementById("left-right-fixed");
6328 6328
6329 // The layout viewport will hit the min-scale limit of 0.25, so it'll be 400 x800. 6329 // The layout viewport will hit the min-scale limit of 0.25, so it'll be 400 x800.
6330 webViewHelper.resize(WebSize(100, 200)); 6330 webViewHelper.resize(WebSize(100, 200));
6331 EXPECT_EQ(800, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); 6331 EXPECT_EQ(800, bottomFixed->offsetTop() + bottomFixed->offsetHeight());
6332 EXPECT_EQ(800, topBottomFixed->offsetHeight()); 6332 EXPECT_EQ(800, topBottomFixed->offsetHeight());
6333 6333
6334 // Now the layout viewport hits the content width limit of 500px so it'll be 500x500. 6334 // Now the layout viewport hits the content width limit of 500px so it'll be 500x500.
6335 webViewHelper.resize(WebSize(200, 200)); 6335 webViewHelper.resize(WebSize(200, 200));
6336 EXPECT_EQ(500, rightFixed->offsetLeft() + rightFixed->offsetWidth()); 6336 EXPECT_EQ(500, rightFixed->offsetLeft() + rightFixed->offsetWidth());
6337 EXPECT_EQ(500, leftRightFixed->offsetWidth()); 6337 EXPECT_EQ(500, leftRightFixed->offsetWidth());
6338 } 6338 }
6339 6339
6340 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) 6340 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect)
6341 { 6341 {
6342 FrameTestHelpers::WebViewHelper webViewHelper(this); 6342 FrameTestHelpers::WebViewHelper webViewHelper(this);
6343 webViewHelper.initializeAndLoad("about:blank"); 6343 webViewHelper.initializeAndLoad("about:blank");
6344 webViewHelper.resize(WebSize(200, 200)); 6344 webViewHelper.resize(WebSize(200, 200));
6345 webViewHelper.webViewImpl()->updateAllLifecyclePhases(); 6345 webViewHelper.webView()->updateAllLifecyclePhases();
6346 6346
6347 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6347 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView() ;
6348 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); 6348 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect());
6349 frameView->setFrameRect(IntRect(100, 100, 200, 200)); 6349 frameView->setFrameRect(IntRect(100, 100, 200, 200));
6350 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); 6350 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect());
6351 } 6351 }
6352 6352
6353 TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls) 6353 TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls)
6354 { 6354 {
6355 FakeCompositingWebViewClient client; 6355 FakeCompositingWebViewClient client;
6356 registerMockedHttpURLLoad("long_scroll.html"); 6356 registerMockedHttpURLLoad("long_scroll.html");
6357 FrameTestHelpers::WebViewHelper webViewHelper; 6357 FrameTestHelpers::WebViewHelper webViewHelper;
6358 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, nullpt r, &client, nullptr, configureAndroid); 6358 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, nullpt r, &client, nullptr, configureAndroid);
6359 6359
6360 WebViewImpl* webView = webViewHelper.webViewImpl(); 6360 WebViewImpl* webView = webViewHelper.webView();
6361 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6361 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView() ;
6362 6362
6363 float topControlsHeight = 40; 6363 float topControlsHeight = 40;
6364 webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false); 6364 webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false);
6365 webView->setPageScaleFactor(2.0f); 6365 webView->setPageScaleFactor(2.0f);
6366 webView->updateAllLifecyclePhases(); 6366 webView->updateAllLifecyclePhases();
6367 6367
6368 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); 6368 webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
6369 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); 6369 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset()));
6370 6370
6371 // Simulate the top controls showing by 20px, thus shrinking the viewport 6371 // Simulate the top controls showing by 20px, thus shrinking the viewport
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6422 6422
6423 FrameTestHelpers::WebViewHelper webViewHelper; 6423 FrameTestHelpers::WebViewHelper webViewHelper;
6424 webViewHelper.initializeAndLoad(m_baseURL + "rtl-overview-mode.html", true, nullptr, &client, nullptr, enableViewportSettings); 6424 webViewHelper.initializeAndLoad(m_baseURL + "rtl-overview-mode.html", true, nullptr, &client, nullptr, enableViewportSettings);
6425 webViewHelper.webView()->setInitialPageScaleOverride(-1); 6425 webViewHelper.webView()->setInitialPageScaleOverride(-1);
6426 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 6426 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
6427 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true); 6427 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true);
6428 webViewHelper.webView()->settings()->setUseWideViewport(true); 6428 webViewHelper.webView()->settings()->setUseWideViewport(true);
6429 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 6429 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
6430 webViewHelper.webView()->updateAllLifecyclePhases(); 6430 webViewHelper.webView()->updateAllLifecyclePhases();
6431 6431
6432 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6432 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView() ;
6433 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); 6433 EXPECT_LT(frameView->maximumScrollPosition().x(), 0);
6434 } 6434 }
6435 6435
6436 TEST_F(WebFrameTest, FullscreenCleanTopLayerAndFullscreenStack) 6436 TEST_F(WebFrameTest, FullscreenCleanTopLayerAndFullscreenStack)
6437 { 6437 {
6438 FakeCompositingWebViewClient client; 6438 FakeCompositingWebViewClient client;
6439 registerMockedHttpURLLoad("fullscreen_div.html"); 6439 registerMockedHttpURLLoad("fullscreen_div.html");
6440 FrameTestHelpers::WebViewHelper webViewHelper; 6440 FrameTestHelpers::WebViewHelper webViewHelper;
6441 int viewportWidth = 640; 6441 int viewportWidth = 640;
6442 int viewportHeight = 480; 6442 int viewportHeight = 480;
6443 client.m_screenInfo.rect.width = viewportWidth; 6443 client.m_screenInfo.rect.width = viewportWidth;
6444 client.m_screenInfo.rect.height = viewportHeight; 6444 client.m_screenInfo.rect.height = viewportHeight;
6445 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( 6445 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
6446 m_baseURL + "fullscreen_div.html", true, 0, &client, nullptr, configureA ndroid); 6446 m_baseURL + "fullscreen_div.html", true, 0, &client, nullptr, configureA ndroid);
6447 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); 6447 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6448 webViewImpl->updateAllLifecyclePhases(); 6448 webViewImpl->updateAllLifecyclePhases();
6449 6449
6450 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6450 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6451 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6451 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6452 Fullscreen& fullscreen = Fullscreen::from(*document); 6452 Fullscreen& fullscreen = Fullscreen::from(*document);
6453 6453
6454 Element* divFullscreen = document->getElementById("div1"); 6454 Element* divFullscreen = document->getElementById("div1");
6455 fullscreen.requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); 6455 fullscreen.requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
6456 webViewImpl->didEnterFullscreen(); 6456 webViewImpl->didEnterFullscreen();
6457 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6457 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6458 6458
6459 // Sanity check. We should have both in our stack. 6459 // Sanity check. We should have both in our stack.
6460 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 1UL); 6460 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 1UL);
6461 ASSERT_EQ(document->topLayerElements().size(), 2UL); 6461 ASSERT_EQ(document->topLayerElements().size(), 2UL);
(...skipping 11 matching lines...) Expand all
6473 registerMockedHttpURLLoad("fullscreen_div.html"); 6473 registerMockedHttpURLLoad("fullscreen_div.html");
6474 FrameTestHelpers::WebViewHelper webViewHelper(this); 6474 FrameTestHelpers::WebViewHelper webViewHelper(this);
6475 int viewportWidth = 640; 6475 int viewportWidth = 640;
6476 int viewportHeight = 480; 6476 int viewportHeight = 480;
6477 client.m_screenInfo.rect.width = viewportWidth; 6477 client.m_screenInfo.rect.width = viewportWidth;
6478 client.m_screenInfo.rect.height = viewportHeight; 6478 client.m_screenInfo.rect.height = viewportHeight;
6479 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, nullptr, &client, nullptr, configureAndroid); 6479 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, nullptr, &client, nullptr, configureAndroid);
6480 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 6480 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
6481 webViewImpl->updateAllLifecyclePhases(); 6481 webViewImpl->updateAllLifecyclePhases();
6482 6482
6483 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6483 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6484 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6484 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6485 Element* divFullscreen = document->getElementById("div1"); 6485 Element* divFullscreen = document->getElementById("div1");
6486 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); 6486 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6487 webViewImpl->didEnterFullscreen(); 6487 webViewImpl->didEnterFullscreen();
6488 webViewImpl->updateAllLifecyclePhases(); 6488 webViewImpl->updateAllLifecyclePhases();
6489 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6489 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6490 6490
6491 // Verify that the element is sized to the viewport. 6491 // Verify that the element is sized to the viewport.
6492 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum ent); 6492 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum ent);
6493 LayoutBox* fullscreenLayoutObject = toLayoutBox(fullscreenElement->layoutObj ect()); 6493 LayoutBox* fullscreenLayoutObject = toLayoutBox(fullscreenElement->layoutObj ect());
(...skipping 13 matching lines...) Expand all
6507 { 6507 {
6508 FakeCompositingWebViewClient client; 6508 FakeCompositingWebViewClient client;
6509 registerMockedHttpURLLoad("fullscreen_div.html"); 6509 registerMockedHttpURLLoad("fullscreen_div.html");
6510 FrameTestHelpers::WebViewHelper webViewHelper; 6510 FrameTestHelpers::WebViewHelper webViewHelper;
6511 int viewportWidth = 640; 6511 int viewportWidth = 640;
6512 int viewportHeight = 480; 6512 int viewportHeight = 480;
6513 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, nullptr, &client, nullptr, configureAndroid); 6513 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, nullptr, &client, nullptr, configureAndroid);
6514 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 6514 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
6515 webViewImpl->updateAllLifecyclePhases(); 6515 webViewImpl->updateAllLifecyclePhases();
6516 6516
6517 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6517 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6518 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6518 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6519 Element* divFullscreen = document->getElementById("div1"); 6519 Element* divFullscreen = document->getElementById("div1");
6520 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); 6520 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6521 webViewImpl->didEnterFullscreen(); 6521 webViewImpl->didEnterFullscreen();
6522 webViewImpl->updateAllLifecyclePhases(); 6522 webViewImpl->updateAllLifecyclePhases();
6523 6523
6524 // Verify that the viewports are nonscrollable. 6524 // Verify that the viewports are nonscrollable.
6525 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6525 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6526 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6526 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView() ;
6527 WebLayer* layoutViewportScrollLayer = webViewImpl->compositor()->scrollLayer ()->platformLayer(); 6527 WebLayer* layoutViewportScrollLayer = webViewImpl->compositor()->scrollLayer ()->platformLayer();
6528 WebLayer* visualViewportScrollLayer = frameView->page()->frameHost().visualV iewport().scrollLayer()->platformLayer(); 6528 WebLayer* visualViewportScrollLayer = frameView->page()->frameHost().visualV iewport().scrollLayer()->platformLayer();
6529 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableHorizontal()); 6529 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableHorizontal());
6530 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableVertical()); 6530 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableVertical());
6531 ASSERT_FALSE(visualViewportScrollLayer->userScrollableHorizontal()); 6531 ASSERT_FALSE(visualViewportScrollLayer->userScrollableHorizontal());
6532 ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical()); 6532 ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical());
6533 6533
6534 // Verify that the viewports are scrollable upon exiting fullscreen. 6534 // Verify that the viewports are scrollable upon exiting fullscreen.
6535 webViewImpl->didExitFullscreen(); 6535 webViewImpl->didExitFullscreen();
6536 webViewImpl->updateAllLifecyclePhases(); 6536 webViewImpl->updateAllLifecyclePhases();
6537 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); 6537 ASSERT_FALSE(Fullscreen::isFullScreen(*document));
6538 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal()); 6538 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal());
6539 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical()); 6539 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical());
6540 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal()); 6540 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal());
6541 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical()); 6541 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical());
6542 } 6542 }
6543 6543
6544 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) 6544 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame)
6545 { 6545 {
6546 FakeCompositingWebViewClient client; 6546 FakeCompositingWebViewClient client;
6547 registerMockedHttpURLLoad("fullscreen_div.html"); 6547 registerMockedHttpURLLoad("fullscreen_div.html");
6548 FrameTestHelpers::WebViewHelper webViewHelper(this); 6548 FrameTestHelpers::WebViewHelper webViewHelper(this);
6549 int viewportWidth = 640; 6549 int viewportWidth = 640;
6550 int viewportHeight = 480; 6550 int viewportHeight = 480;
6551 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, nullptr, &client, nullptr, configureAndroid); 6551 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, nullptr, &client, nullptr, configureAndroid);
6552 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 6552 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
6553 webViewImpl->updateAllLifecyclePhases(); 6553 webViewImpl->updateAllLifecyclePhases();
6554 6554
6555 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6555 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6556 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6556 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6557 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest); 6557 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest);
6558 webViewImpl->didEnterFullscreen(); 6558 webViewImpl->didEnterFullscreen();
6559 webViewImpl->updateAllLifecyclePhases(); 6559 webViewImpl->updateAllLifecyclePhases();
6560 6560
6561 // Verify that the main frame is still scrollable. 6561 // Verify that the main frame is still scrollable.
6562 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6562 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6563 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); 6563 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer();
6564 ASSERT_TRUE(webScrollLayer->scrollable()); 6564 ASSERT_TRUE(webScrollLayer->scrollable());
6565 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 6565 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
6614 registerMockedHttpURLLoad("viewport-tiny.html"); 6614 registerMockedHttpURLLoad("viewport-tiny.html");
6615 FrameTestHelpers::WebViewHelper webViewHelper(this); 6615 FrameTestHelpers::WebViewHelper webViewHelper(this);
6616 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view port-tiny.html", true, nullptr, &client, nullptr, configureAndroid); 6616 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view port-tiny.html", true, nullptr, &client, nullptr, configureAndroid);
6617 int viewportWidth = 384; 6617 int viewportWidth = 384;
6618 int viewportHeight = 640; 6618 int viewportHeight = 640;
6619 client.m_screenInfo.rect.width = viewportWidth; 6619 client.m_screenInfo.rect.width = viewportWidth;
6620 client.m_screenInfo.rect.height = viewportHeight; 6620 client.m_screenInfo.rect.height = viewportHeight;
6621 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 6621 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
6622 webViewImpl->updateAllLifecyclePhases(); 6622 webViewImpl->updateAllLifecyclePhases();
6623 6623
6624 LayoutViewItem layoutViewItem = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView()->layoutViewItem(); 6624 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr ameView()->layoutViewItem();
6625 EXPECT_EQ(320, layoutViewItem.logicalWidth().floor()); 6625 EXPECT_EQ(320, layoutViewItem.logicalWidth().floor());
6626 EXPECT_EQ(533, layoutViewItem.logicalHeight().floor()); 6626 EXPECT_EQ(533, layoutViewItem.logicalHeight().floor());
6627 EXPECT_FLOAT_EQ(1.2, webViewImpl->pageScaleFactor()); 6627 EXPECT_FLOAT_EQ(1.2, webViewImpl->pageScaleFactor());
6628 EXPECT_FLOAT_EQ(1.2, webViewImpl->minimumPageScaleFactor()); 6628 EXPECT_FLOAT_EQ(1.2, webViewImpl->minimumPageScaleFactor());
6629 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); 6629 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
6630 6630
6631 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6631 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6632 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6632 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6633 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest); 6633 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest);
6634 webViewImpl->didEnterFullscreen(); 6634 webViewImpl->didEnterFullscreen();
6635 webViewImpl->updateAllLifecyclePhases(); 6635 webViewImpl->updateAllLifecyclePhases();
6636 EXPECT_EQ(384, layoutViewItem.logicalWidth().floor()); 6636 EXPECT_EQ(384, layoutViewItem.logicalWidth().floor());
6637 EXPECT_EQ(640, layoutViewItem.logicalHeight().floor()); 6637 EXPECT_EQ(640, layoutViewItem.logicalHeight().floor());
6638 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); 6638 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor());
6639 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); 6639 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor());
6640 EXPECT_FLOAT_EQ(1.0, webViewImpl->maximumPageScaleFactor()); 6640 EXPECT_FLOAT_EQ(1.0, webViewImpl->maximumPageScaleFactor());
6641 6641
(...skipping 12 matching lines...) Expand all
6654 registerMockedHttpURLLoad("viewport-tiny.html"); 6654 registerMockedHttpURLLoad("viewport-tiny.html");
6655 FrameTestHelpers::WebViewHelper webViewHelper(this); 6655 FrameTestHelpers::WebViewHelper webViewHelper(this);
6656 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view port-tiny.html", true, nullptr, &client, nullptr, configureAndroid); 6656 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "view port-tiny.html", true, nullptr, &client, nullptr, configureAndroid);
6657 int viewportWidth = 384; 6657 int viewportWidth = 384;
6658 int viewportHeight = 640; 6658 int viewportHeight = 640;
6659 client.m_screenInfo.rect.width = viewportWidth; 6659 client.m_screenInfo.rect.width = viewportWidth;
6660 client.m_screenInfo.rect.height = viewportHeight; 6660 client.m_screenInfo.rect.height = viewportHeight;
6661 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 6661 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
6662 webViewImpl->updateAllLifecyclePhases(); 6662 webViewImpl->updateAllLifecyclePhases();
6663 6663
6664 LayoutViewItem layoutViewItem = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView()->layoutViewItem(); 6664 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr ameView()->layoutViewItem();
6665 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6665 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6666 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6666 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6667 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest); 6667 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest);
6668 webViewImpl->didEnterFullscreen(); 6668 webViewImpl->didEnterFullscreen();
6669 webViewImpl->updateAllLifecyclePhases(); 6669 webViewImpl->updateAllLifecyclePhases();
6670 EXPECT_EQ(384, layoutViewItem.logicalWidth().floor()); 6670 EXPECT_EQ(384, layoutViewItem.logicalWidth().floor());
6671 EXPECT_EQ(640, layoutViewItem.logicalHeight().floor()); 6671 EXPECT_EQ(640, layoutViewItem.logicalHeight().floor());
6672 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); 6672 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor());
6673 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); 6673 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor());
6674 EXPECT_FLOAT_EQ(1.0, webViewImpl->maximumPageScaleFactor()); 6674 EXPECT_FLOAT_EQ(1.0, webViewImpl->maximumPageScaleFactor());
6675 6675
(...skipping 28 matching lines...) Expand all
6704 WebSize screenSizeMinusStatusBars(598, 359); 6704 WebSize screenSizeMinusStatusBars(598, 359);
6705 WebSize screenSize(640, 384); 6705 WebSize screenSize(640, 384);
6706 6706
6707 FakeCompositingWebViewClient client; 6707 FakeCompositingWebViewClient client;
6708 registerMockedHttpURLLoad("fullscreen_restore_scale_factor.html"); 6708 registerMockedHttpURLLoad("fullscreen_restore_scale_factor.html");
6709 FrameTestHelpers::WebViewHelper webViewHelper(this); 6709 FrameTestHelpers::WebViewHelper webViewHelper(this);
6710 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_restore_scale_factor.html", true, nullptr, &client, nullptr, &configureAn droid); 6710 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_restore_scale_factor.html", true, nullptr, &client, nullptr, &configureAn droid);
6711 client.m_screenInfo.rect.width = screenSizeMinusStatusBarsMinusUrlBar.width; 6711 client.m_screenInfo.rect.width = screenSizeMinusStatusBarsMinusUrlBar.width;
6712 client.m_screenInfo.rect.height = screenSizeMinusStatusBarsMinusUrlBar.heigh t; 6712 client.m_screenInfo.rect.height = screenSizeMinusStatusBarsMinusUrlBar.heigh t;
6713 webViewHelper.resize(screenSizeMinusStatusBarsMinusUrlBar); 6713 webViewHelper.resize(screenSizeMinusStatusBarsMinusUrlBar);
6714 LayoutViewItem layoutViewItem = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView()->layoutViewItem(); 6714 LayoutViewItem layoutViewItem = webViewHelper.webView()->mainFrameImpl()->fr ameView()->layoutViewItem();
6715 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.width, layoutViewItem.logical Width().floor()); 6715 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.width, layoutViewItem.logical Width().floor());
6716 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.height, layoutViewItem.logica lHeight().floor()); 6716 EXPECT_EQ(screenSizeMinusStatusBarsMinusUrlBar.height, layoutViewItem.logica lHeight().floor());
6717 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor()); 6717 EXPECT_FLOAT_EQ(1.0, webViewImpl->pageScaleFactor());
6718 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor()); 6718 EXPECT_FLOAT_EQ(1.0, webViewImpl->minimumPageScaleFactor());
6719 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); 6719 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
6720 6720
6721 { 6721 {
6722 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->fram e()->document(); 6722 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
6723 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6723 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6724 Fullscreen::from(*document).requestFullscreen(*document->body(), Fullscr een::PrefixedRequest); 6724 Fullscreen::from(*document).requestFullscreen(*document->body(), Fullscr een::PrefixedRequest);
6725 } 6725 }
6726 6726
6727 webViewImpl->didEnterFullscreen(); 6727 webViewImpl->didEnterFullscreen();
6728 webViewImpl->updateAllLifecyclePhases(); 6728 webViewImpl->updateAllLifecyclePhases();
6729 client.m_screenInfo.rect.width = screenSizeMinusStatusBars.width; 6729 client.m_screenInfo.rect.width = screenSizeMinusStatusBars.width;
6730 client.m_screenInfo.rect.height = screenSizeMinusStatusBars.height; 6730 client.m_screenInfo.rect.height = screenSizeMinusStatusBars.height;
6731 webViewHelper.resize(screenSizeMinusStatusBars); 6731 webViewHelper.resize(screenSizeMinusStatusBars);
6732 client.m_screenInfo.rect.width = screenSize.width; 6732 client.m_screenInfo.rect.width = screenSize.width;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6777 // viewport-tiny.html specifies a 320px layout width. 6777 // viewport-tiny.html specifies a 320px layout width.
6778 LayoutViewItem layoutViewItem = 6778 LayoutViewItem layoutViewItem =
6779 webViewImpl->mainFrameImpl()->frameView()->layoutViewItem(); 6779 webViewImpl->mainFrameImpl()->frameView()->layoutViewItem();
6780 EXPECT_EQ(320, layoutViewItem.logicalWidth().floor()); 6780 EXPECT_EQ(320, layoutViewItem.logicalWidth().floor());
6781 EXPECT_EQ(640, layoutViewItem.logicalHeight().floor()); 6781 EXPECT_EQ(640, layoutViewItem.logicalHeight().floor());
6782 EXPECT_FLOAT_EQ(0.3125, webViewImpl->pageScaleFactor()); 6782 EXPECT_FLOAT_EQ(0.3125, webViewImpl->pageScaleFactor());
6783 EXPECT_FLOAT_EQ(0.3125, webViewImpl->minimumPageScaleFactor()); 6783 EXPECT_FLOAT_EQ(0.3125, webViewImpl->minimumPageScaleFactor());
6784 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); 6784 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
6785 6785
6786 Document* document = 6786 Document* document =
6787 toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()->document(); 6787 webViewImpl->mainFrameImpl()->frame()->document();
6788 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6788 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6789 Fullscreen::from(*document).requestFullscreen( 6789 Fullscreen::from(*document).requestFullscreen(
6790 *document->documentElement(), Fullscreen::PrefixedRequest); 6790 *document->documentElement(), Fullscreen::PrefixedRequest);
6791 webViewImpl->didEnterFullscreen(); 6791 webViewImpl->didEnterFullscreen();
6792 webViewImpl->updateAllLifecyclePhases(); 6792 webViewImpl->updateAllLifecyclePhases();
6793 6793
6794 // Entering fullscreen causes layout size and page scale limits to be 6794 // Entering fullscreen causes layout size and page scale limits to be
6795 // overridden. 6795 // overridden.
6796 EXPECT_EQ(100, layoutViewItem.logicalWidth().floor()); 6796 EXPECT_EQ(100, layoutViewItem.logicalWidth().floor());
6797 EXPECT_EQ(200, layoutViewItem.logicalHeight().floor()); 6797 EXPECT_EQ(200, layoutViewItem.logicalHeight().floor());
(...skipping 19 matching lines...) Expand all
6817 EXPECT_FLOAT_EQ(0.5, webViewImpl->minimumPageScaleFactor()); 6817 EXPECT_FLOAT_EQ(0.5, webViewImpl->minimumPageScaleFactor());
6818 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); 6818 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
6819 } 6819 }
6820 6820
6821 TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants) 6821 TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants)
6822 { 6822 {
6823 registerMockedHttpURLLoad("percent-height-descendants.html"); 6823 registerMockedHttpURLLoad("percent-height-descendants.html");
6824 FrameTestHelpers::WebViewHelper webViewHelper(this); 6824 FrameTestHelpers::WebViewHelper webViewHelper(this);
6825 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html "); 6825 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html ");
6826 6826
6827 WebView* webView = webViewHelper.webView(); 6827 WebViewImpl* webView = webViewHelper.webView();
6828 webViewHelper.resize(WebSize(800, 800)); 6828 webViewHelper.resize(WebSize(800, 800));
6829 webView->updateAllLifecyclePhases(); 6829 webView->updateAllLifecyclePhases();
6830 6830
6831 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc ument(); 6831 Document* document = webView->mainFrameImpl()->frame()->document();
6832 LayoutBlock* container = toLayoutBlock(document->getElementById("container") ->layoutObject()); 6832 LayoutBlock* container = toLayoutBlock(document->getElementById("container") ->layoutObject());
6833 LayoutBox* percentHeightInAnonymous = toLayoutBox(document->getElementById(" percent-height-in-anonymous")->layoutObject()); 6833 LayoutBox* percentHeightInAnonymous = toLayoutBox(document->getElementById(" percent-height-in-anonymous")->layoutObject());
6834 LayoutBox* percentHeightDirectChild = toLayoutBox(document->getElementById(" percent-height-direct-child")->layoutObject()); 6834 LayoutBox* percentHeightDirectChild = toLayoutBox(document->getElementById(" percent-height-direct-child")->layoutObject());
6835 6835
6836 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightInAnonymous)) ; 6836 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightInAnonymous)) ;
6837 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightDirectChild)) ; 6837 EXPECT_TRUE(container->hasPercentHeightDescendant(percentHeightDirectChild)) ;
6838 6838
6839 ASSERT_TRUE(container->percentHeightDescendants()); 6839 ASSERT_TRUE(container->percentHeightDescendants());
6840 ASSERT_TRUE(container->hasPercentHeightDescendants()); 6840 ASSERT_TRUE(container->hasPercentHeightDescendants());
6841 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); 6841 EXPECT_EQ(2U, container->percentHeightDescendants()->size());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6900 return RawResource::fetchSynchronously(fetchRequest, document->fetcher()); 6900 return RawResource::fetchSynchronously(fetchRequest, document->fetcher());
6901 } 6901 }
6902 6902
6903 TEST_P(ParameterizedWebFrameTest, ManifestFetch) 6903 TEST_P(ParameterizedWebFrameTest, ManifestFetch)
6904 { 6904 {
6905 registerMockedHttpURLLoad("foo.html"); 6905 registerMockedHttpURLLoad("foo.html");
6906 registerMockedHttpURLLoad("link-manifest-fetch.json"); 6906 registerMockedHttpURLLoad("link-manifest-fetch.json");
6907 6907
6908 FrameTestHelpers::WebViewHelper webViewHelper(this); 6908 FrameTestHelpers::WebViewHelper webViewHelper(this);
6909 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); 6909 webViewHelper.initializeAndLoad(m_baseURL + "foo.html");
6910 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr ame())->frame()->document(); 6910 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu ment();
6911 6911
6912 Resource* resource = fetchManifest(document, toKURL(m_baseURL + "link-manife st-fetch.json")); 6912 Resource* resource = fetchManifest(document, toKURL(m_baseURL + "link-manife st-fetch.json"));
6913 6913
6914 EXPECT_TRUE(resource->isLoaded()); 6914 EXPECT_TRUE(resource->isLoaded());
6915 } 6915 }
6916 6916
6917 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) 6917 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow)
6918 { 6918 {
6919 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f etch.json"), "link-manifest-fetch.json"); 6919 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f etch.json"), "link-manifest-fetch.json");
6920 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); 6920 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *");
6921 6921
6922 FrameTestHelpers::WebViewHelper webViewHelper(this); 6922 FrameTestHelpers::WebViewHelper webViewHelper(this);
6923 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); 6923 webViewHelper.initializeAndLoad(m_baseURL + "foo.html");
6924 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr ame())->frame()->document(); 6924 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu ment();
6925 6925
6926 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man ifest-fetch.json")); 6926 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man ifest-fetch.json"));
6927 6927
6928 EXPECT_TRUE(resource->isLoaded()); 6928 EXPECT_TRUE(resource->isLoaded());
6929 } 6929 }
6930 6930
6931 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) 6931 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf)
6932 { 6932 {
6933 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f etch.json"), "link-manifest-fetch.json"); 6933 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f etch.json"), "link-manifest-fetch.json");
6934 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); 6934 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'");
6935 6935
6936 FrameTestHelpers::WebViewHelper webViewHelper(this); 6936 FrameTestHelpers::WebViewHelper webViewHelper(this);
6937 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); 6937 webViewHelper.initializeAndLoad(m_baseURL + "foo.html");
6938 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr ame())->frame()->document(); 6938 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu ment();
6939 6939
6940 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man ifest-fetch.json")); 6940 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man ifest-fetch.json"));
6941 6941
6942 EXPECT_EQ(0, resource); // Fetching resource wasn't allowed. 6942 EXPECT_EQ(0, resource); // Fetching resource wasn't allowed.
6943 } 6943 }
6944 6944
6945 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) 6945 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly)
6946 { 6946 {
6947 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f etch.json"), "link-manifest-fetch.json"); 6947 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f etch.json"), "link-manifest-fetch.json");
6948 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", /* repor t only */ true); 6948 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", /* repor t only */ true);
6949 6949
6950 FrameTestHelpers::WebViewHelper webViewHelper(this); 6950 FrameTestHelpers::WebViewHelper webViewHelper(this);
6951 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); 6951 webViewHelper.initializeAndLoad(m_baseURL + "foo.html");
6952 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr ame())->frame()->document(); 6952 Document* document = webViewHelper.webView()->mainFrameImpl()->frame()->docu ment();
6953 6953
6954 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man ifest-fetch.json")); 6954 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man ifest-fetch.json"));
6955 6955
6956 EXPECT_TRUE(resource->isLoaded()); 6956 EXPECT_TRUE(resource->isLoaded());
6957 } 6957 }
6958 6958
6959 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) 6959 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache)
6960 { 6960 {
6961 // Check that a reload ignoring cache on a frame will result in the cache 6961 // Check that a reload ignoring cache on a frame will result in the cache
6962 // policy of the request being set to ReloadBypassingCache. 6962 // policy of the request being set to ReloadBypassingCache.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
7075 bool m_didNotify; 7075 bool m_didNotify;
7076 }; 7076 };
7077 7077
7078 TEST_P(ParameterizedWebFrameTest, ThemeColor) 7078 TEST_P(ParameterizedWebFrameTest, ThemeColor)
7079 { 7079 {
7080 registerMockedHttpURLLoad("theme_color_test.html"); 7080 registerMockedHttpURLLoad("theme_color_test.html");
7081 FrameTestHelpers::WebViewHelper webViewHelper(this); 7081 FrameTestHelpers::WebViewHelper webViewHelper(this);
7082 ThemeColorTestWebFrameClient client; 7082 ThemeColorTestWebFrameClient client;
7083 webViewHelper.initializeAndLoad(m_baseURL + "theme_color_test.html", true, & client); 7083 webViewHelper.initializeAndLoad(m_baseURL + "theme_color_test.html", true, & client);
7084 EXPECT_TRUE(client.didNotify()); 7084 EXPECT_TRUE(client.didNotify());
7085 WebLocalFrameImpl* frame = webViewHelper.webViewImpl()->mainFrameImpl(); 7085 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
7086 EXPECT_EQ(0xff0000ff, frame->document().themeColor()); 7086 EXPECT_EQ(0xff0000ff, frame->document().themeColor());
7087 // Change color by rgb. 7087 // Change color by rgb.
7088 client.reset(); 7088 client.reset();
7089 frame->executeScript(WebScriptSource("document.getElementById('tc1').setAttr ibute('content', 'rgb(0, 0, 0)');")); 7089 frame->executeScript(WebScriptSource("document.getElementById('tc1').setAttr ibute('content', 'rgb(0, 0, 0)');"));
7090 EXPECT_TRUE(client.didNotify()); 7090 EXPECT_TRUE(client.didNotify());
7091 EXPECT_EQ(0xff000000, frame->document().themeColor()); 7091 EXPECT_EQ(0xff000000, frame->document().themeColor());
7092 // Change color by hsl. 7092 // Change color by hsl.
7093 client.reset(); 7093 client.reset();
7094 frame->executeScript(WebScriptSource("document.getElementById('tc1').setAttr ibute('content', 'hsl(240,100%, 50%)');")); 7094 frame->executeScript(WebScriptSource("document.getElementById('tc1').setAttr ibute('content', 'hsl(240,100%, 50%)');"));
7095 EXPECT_TRUE(client.didNotify()); 7095 EXPECT_TRUE(client.didNotify());
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
7626 TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap) 7626 TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap)
7627 { 7627 {
7628 // Start with a named frame. 7628 // Start with a named frame.
7629 WebFrame* targetFrame = mainFrame()->firstChild(); 7629 WebFrame* targetFrame = mainFrame()->firstChild();
7630 ASSERT_TRUE(targetFrame); 7630 ASSERT_TRUE(targetFrame);
7631 WebString uniqueName = targetFrame->uniqueName(); 7631 WebString uniqueName = targetFrame->uniqueName();
7632 EXPECT_EQ("frame1", uniqueName.utf8()); 7632 EXPECT_EQ("frame1", uniqueName.utf8());
7633 7633
7634 // Swap to a RemoteFrame. 7634 // Swap to a RemoteFrame.
7635 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7635 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7636 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7636 WebRemoteFrameImpl* remoteFrame = WebRemoteFrameImpl::create(WebTreeScopeTyp e::Document, &remoteFrameClient);
7637 targetFrame->swap(remoteFrame); 7637 targetFrame->swap(remoteFrame);
7638 ASSERT_TRUE(mainFrame()->firstChild()); 7638 ASSERT_TRUE(mainFrame()->firstChild());
7639 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7639 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7640 EXPECT_EQ(uniqueName.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame)->fr ame()->tree().uniqueName()).utf8()); 7640 EXPECT_EQ(uniqueName.utf8(), WebString(remoteFrame->frame()->tree().uniqueNa me()).utf8());
7641 7641
7642 // Swap back to a LocalFrame. 7642 // Swap back to a LocalFrame.
7643 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7643 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7644 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None); 7644 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7645 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7645 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7646 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); 7646 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8());
7647 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram e()->loader().currentItem()->target()).utf8()); 7647 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram e()->loader().currentItem()->target()).utf8());
7648 7648
7649 // Repeat with no name on the frame. 7649 // Repeat with no name on the frame.
7650 localFrame->setName(""); 7650 localFrame->setName("");
7651 WebString uniqueName2 = localFrame->uniqueName(); 7651 WebString uniqueName2 = localFrame->uniqueName();
7652 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8()); 7652 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8());
7653 7653
7654 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7654 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7655 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu ment, &remoteFrameClient2); 7655 WebRemoteFrameImpl* remoteFrame2 = WebRemoteFrameImpl::create(WebTreeScopeTy pe::Document, &remoteFrameClient2);
7656 localFrame->swap(remoteFrame2); 7656 localFrame->swap(remoteFrame2);
7657 ASSERT_TRUE(mainFrame()->firstChild()); 7657 ASSERT_TRUE(mainFrame()->firstChild());
7658 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); 7658 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2);
7659 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame2)-> frame()->tree().uniqueName()).utf8()); 7659 EXPECT_EQ(uniqueName2.utf8(), WebString(remoteFrame2->frame()->tree().unique Name()).utf8());
7660 7660
7661 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); 7661 RemoteToLocalSwapWebFrameClient client2(remoteFrame2);
7662 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(&client2, remo teFrame2, WebSandboxFlags::None); 7662 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(&client2, remo teFrame2, WebSandboxFlags::None);
7663 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); 7663 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html");
7664 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); 7664 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8());
7665 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr ame()->loader().currentItem()->target()).utf8()); 7665 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr ame()->loader().currentItem()->target()).utf8());
7666 7666
7667 // Manually reset to break WebViewHelper's dependency on the stack allocated 7667 // Manually reset to break WebViewHelper's dependency on the stack allocated
7668 // TestWebFrameClient. 7668 // TestWebFrameClient.
7669 reset(); 7669 reset();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
7915 webViewHelper.initializeAndLoad("about:blank"); 7915 webViewHelper.initializeAndLoad("about:blank");
7916 7916
7917 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); 7917 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome");
7918 7918
7919 // Cross-origin request. 7919 // Cross-origin request.
7920 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); 7920 KURL resourceUrl(ParsedURLString, "chrome://test.pdf");
7921 ResourceRequest request(resourceUrl); 7921 ResourceRequest request(resourceUrl);
7922 request.setRequestContext(WebURLRequest::RequestContextObject); 7922 request.setRequestContext(WebURLRequest::RequestContextObject);
7923 registerMockedChromeURLLoad("test.pdf"); 7923 registerMockedChromeURLLoad("test.pdf");
7924 7924
7925 LocalFrame* frame(toLocalFrame(webViewHelper.webViewImpl()->page()->mainFram e())); 7925 LocalFrame* frame(toLocalFrame(webViewHelper.webView()->page()->mainFrame()) );
7926 7926
7927 MockDocumentThreadableLoaderClient client; 7927 MockDocumentThreadableLoaderClient client;
7928 ThreadableLoaderOptions options; 7928 ThreadableLoaderOptions options;
7929 7929
7930 // First try to load the request with regular access. Should fail. 7930 // First try to load the request with regular access. Should fail.
7931 options.crossOriginRequestPolicy = UseAccessControl; 7931 options.crossOriginRequestPolicy = UseAccessControl;
7932 ResourceLoaderOptions resourceLoaderOptions; 7932 ResourceLoaderOptions resourceLoaderOptions;
7933 DocumentThreadableLoader::loadResourceSynchronously( 7933 DocumentThreadableLoader::loadResourceSynchronously(
7934 *frame->document(), request, client, options, resourceLoaderOptions); 7934 *frame->document(), request, client, options, resourceLoaderOptions);
7935 EXPECT_TRUE(client.failed()); 7935 EXPECT_TRUE(client.failed());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
8019 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect; 8019 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect;
8020 m_webViewHelper.resize(size); 8020 m_webViewHelper.resize(size);
8021 EXPECT_EQ(expectedSize, dumpSize("test")); 8021 EXPECT_EQ(expectedSize, dumpSize("test"));
8022 } 8022 }
8023 8023
8024 String dumpSize(const String& id) 8024 String dumpSize(const String& id)
8025 { 8025 {
8026 String code = "dumpSize('" + id + "')"; 8026 String code = "dumpSize('" + id + "')";
8027 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8027 v8::HandleScope scope(v8::Isolate::GetCurrent());
8028 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()-> mainFrame()->mainWorldScriptContext()); 8028 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()-> mainFrame()->mainWorldScriptContext());
8029 m_webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecut eScriptAndReturnValue(WebScriptSource(WebString(code)), false, &callbackHelper); 8029 m_webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndRetur nValue(WebScriptSource(WebString(code)), false, &callbackHelper);
8030 runPendingTasks(); 8030 runPendingTasks();
8031 EXPECT_TRUE(callbackHelper.didComplete()); 8031 EXPECT_TRUE(callbackHelper.didComplete());
8032 return callbackHelper.stringValue(); 8032 return callbackHelper.stringValue();
8033 } 8033 }
8034 8034
8035 FixedLayoutTestWebViewClient m_client; 8035 FixedLayoutTestWebViewClient m_client;
8036 FrameTestHelpers::WebViewHelper m_webViewHelper; 8036 FrameTestHelpers::WebViewHelper m_webViewHelper;
8037 }; 8037 };
8038 8038
8039 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Values( 8039 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Values(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
8189 event.y = 100; 8189 event.y = 100;
8190 if (type == WebInputEvent::GestureScrollUpdate) { 8190 if (type == WebInputEvent::GestureScrollUpdate) {
8191 event.data.scrollUpdate.deltaX = deltaX; 8191 event.data.scrollUpdate.deltaX = deltaX;
8192 event.data.scrollUpdate.deltaY = deltaY; 8192 event.data.scrollUpdate.deltaY = deltaY;
8193 } 8193 }
8194 return event; 8194 return event;
8195 } 8195 }
8196 8196
8197 void ScrollBegin(FrameTestHelpers::WebViewHelper* webViewHelper) 8197 void ScrollBegin(FrameTestHelpers::WebViewHelper* webViewHelper)
8198 { 8198 {
8199 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve nt::GestureScrollBegin)); 8199 webViewHelper->webView()->handleInputEvent(generateEvent(WebInputEvent:: GestureScrollBegin));
8200 } 8200 }
8201 8201
8202 void ScrollUpdate(FrameTestHelpers::WebViewHelper* webViewHelper, float delt aX, float deltaY) 8202 void ScrollUpdate(FrameTestHelpers::WebViewHelper* webViewHelper, float delt aX, float deltaY)
8203 { 8203 {
8204 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve nt::GestureScrollUpdate, deltaX, deltaY)); 8204 webViewHelper->webView()->handleInputEvent(generateEvent(WebInputEvent:: GestureScrollUpdate, deltaX, deltaY));
8205 } 8205 }
8206 8206
8207 void ScrollEnd(FrameTestHelpers::WebViewHelper* webViewHelper) 8207 void ScrollEnd(FrameTestHelpers::WebViewHelper* webViewHelper)
8208 { 8208 {
8209 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve nt::GestureScrollEnd)); 8209 webViewHelper->webView()->handleInputEvent(generateEvent(WebInputEvent:: GestureScrollEnd));
8210 } 8210 }
8211 }; 8211 };
8212 8212
8213 INSTANTIATE_TEST_CASE_P(All, WebFrameOverscrollTest, ::testing::Values( 8213 INSTANTIATE_TEST_CASE_P(All, WebFrameOverscrollTest, ::testing::Values(
8214 WebGestureDeviceTouchpad, 8214 WebGestureDeviceTouchpad,
8215 WebGestureDeviceTouchscreen)); 8215 WebGestureDeviceTouchscreen));
8216 8216
8217 TEST_P(WebFrameOverscrollTest, AccumulatedRootOverscrollAndUnsedDeltaValuesOnOve rscroll) 8217 TEST_P(WebFrameOverscrollTest, AccumulatedRootOverscrollAndUnsedDeltaValuesOnOve rscroll)
8218 { 8218 {
8219 OverscrollWebViewClient client; 8219 OverscrollWebViewClient client;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
8461 TEST_F(WebFrameTest, ImageDocumentLoadFinishTime) 8461 TEST_F(WebFrameTest, ImageDocumentLoadFinishTime)
8462 { 8462 {
8463 // Loading an image resource directly generates an ImageDocument with 8463 // Loading an image resource directly generates an ImageDocument with
8464 // the document loader feeding image data into the resource of a generated 8464 // the document loader feeding image data into the resource of a generated
8465 // img tag. We expect the load finish time to be the same for the document 8465 // img tag. We expect the load finish time to be the same for the document
8466 // and the image resource. 8466 // and the image resource.
8467 8467
8468 registerMockedHttpURLLoadWithMimeType("white-1x1.png", "image/png"); 8468 registerMockedHttpURLLoadWithMimeType("white-1x1.png", "image/png");
8469 FrameTestHelpers::WebViewHelper webViewHelper; 8469 FrameTestHelpers::WebViewHelper webViewHelper;
8470 webViewHelper.initializeAndLoad(m_baseURL + "white-1x1.png"); 8470 webViewHelper.initializeAndLoad(m_baseURL + "white-1x1.png");
8471 WebView* webView = webViewHelper.webView(); 8471 WebViewImpl* webView = webViewHelper.webView();
8472 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc ument(); 8472 Document* document = webView->mainFrameImpl()->frame()->document();
8473 8473
8474 EXPECT_TRUE(document); 8474 EXPECT_TRUE(document);
8475 EXPECT_TRUE(document->isImageDocument()); 8475 EXPECT_TRUE(document->isImageDocument());
8476 8476
8477 ImageDocument* imgDocument = toImageDocument(document); 8477 ImageDocument* imgDocument = toImageDocument(document);
8478 ImageResource* resource = imgDocument->cachedImage(); 8478 ImageResource* resource = imgDocument->cachedImage();
8479 8479
8480 EXPECT_TRUE(resource); 8480 EXPECT_TRUE(resource);
8481 EXPECT_NE(0, resource->loadFinishTime()); 8481 EXPECT_NE(0, resource->loadFinishTime());
8482 8482
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
8592 settings->setShouldReuseGlobalForUnownedMainFrame(true); 8592 settings->setShouldReuseGlobalForUnownedMainFrame(true);
8593 } 8593 }
8594 8594
8595 // A main frame with no opener should have a unique security origin. Thus, the 8595 // A main frame with no opener should have a unique security origin. Thus, the
8596 // global should never be reused on the initial navigation. 8596 // global should never be reused on the initial navigation.
8597 TEST(WebFrameGlobalReuseTest, MainFrameWithNoOpener) 8597 TEST(WebFrameGlobalReuseTest, MainFrameWithNoOpener)
8598 { 8598 {
8599 FrameTestHelpers::WebViewHelper helper; 8599 FrameTestHelpers::WebViewHelper helper;
8600 helper.initialize(true); 8600 helper.initialize(true);
8601 8601
8602 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8602 WebLocalFrame* mainFrame = helper.webView()->mainFrameImpl();
8603 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8603 v8::HandleScope scope(v8::Isolate::GetCurrent());
8604 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8604 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8605 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8605 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8606 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8606 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8607 EXPECT_TRUE(result.IsEmpty()); 8607 EXPECT_TRUE(result.IsEmpty());
8608 } 8608 }
8609 8609
8610 // Child frames should never reuse the global on a cross-origin navigation, even 8610 // Child frames should never reuse the global on a cross-origin navigation, even
8611 // if the setting is enabled. It's not safe to since the parent could have 8611 // if the setting is enabled. It's not safe to since the parent could have
8612 // injected script before the initial navigation. 8612 // injected script before the initial navigation.
8613 TEST(WebFrameGlobalReuseTest, ChildFrame) 8613 TEST(WebFrameGlobalReuseTest, ChildFrame)
8614 { 8614 {
8615 FrameTestHelpers::WebViewHelper helper; 8615 FrameTestHelpers::WebViewHelper helper;
8616 helper.initialize(true, nullptr, nullptr, nullptr, enableGlobalReuseForUnown edMainFrames); 8616 helper.initialize(true, nullptr, nullptr, nullptr, enableGlobalReuseForUnown edMainFrames);
8617 8617
8618 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8618 WebLocalFrame* mainFrame = helper.webView()->mainFrameImpl();
8619 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,<iframe></iframe>"); 8619 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,<iframe></iframe>");
8620 8620
8621 WebLocalFrame* childFrame = mainFrame->firstChild()->toWebLocalFrame(); 8621 WebLocalFrame* childFrame = mainFrame->firstChild()->toWebLocalFrame();
8622 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8622 v8::HandleScope scope(v8::Isolate::GetCurrent());
8623 childFrame->executeScript(WebScriptSource("hello = 'world';")); 8623 childFrame->executeScript(WebScriptSource("hello = 'world';"));
8624 FrameTestHelpers::loadFrame(childFrame, "data:text/html,new page"); 8624 FrameTestHelpers::loadFrame(childFrame, "data:text/html,new page");
8625 v8::Local<v8::Value> result = childFrame->executeScriptAndReturnValue(WebScr iptSource("hello")); 8625 v8::Local<v8::Value> result = childFrame->executeScriptAndReturnValue(WebScr iptSource("hello"));
8626 EXPECT_TRUE(result.IsEmpty()); 8626 EXPECT_TRUE(result.IsEmpty());
8627 } 8627 }
8628 8628
8629 // A main frame with an opener should never reuse the global on a cross-origin 8629 // A main frame with an opener should never reuse the global on a cross-origin
8630 // navigation, even if the setting is enabled. It's not safe to since the opener 8630 // navigation, even if the setting is enabled. It's not safe to since the opener
8631 // could have injected script. 8631 // could have injected script.
8632 TEST(WebFrameGlobalReuseTest, MainFrameWithOpener) 8632 TEST(WebFrameGlobalReuseTest, MainFrameWithOpener)
8633 { 8633 {
8634 FrameTestHelpers::TestWebViewClient openerWebViewClient; 8634 FrameTestHelpers::TestWebViewClient openerWebViewClient;
8635 FrameTestHelpers::WebViewHelper openerHelper; 8635 FrameTestHelpers::WebViewHelper openerHelper;
8636 openerHelper.initialize(false, nullptr, &openerWebViewClient, nullptr); 8636 openerHelper.initialize(false, nullptr, &openerWebViewClient, nullptr);
8637 FrameTestHelpers::WebViewHelper helper; 8637 FrameTestHelpers::WebViewHelper helper;
8638 helper.initializeWithOpener(openerHelper.webView()->mainFrame(), true, nullp tr, nullptr, nullptr, enableGlobalReuseForUnownedMainFrames); 8638 helper.initializeWithOpener(openerHelper.webView()->mainFrame(), true, nullp tr, nullptr, nullptr, enableGlobalReuseForUnownedMainFrames);
8639 8639
8640 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8640 WebLocalFrame* mainFrame = helper.webView()->mainFrameImpl();
8641 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8641 v8::HandleScope scope(v8::Isolate::GetCurrent());
8642 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8642 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8643 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8643 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8644 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8644 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8645 EXPECT_TRUE(result.IsEmpty()); 8645 EXPECT_TRUE(result.IsEmpty());
8646 } 8646 }
8647 8647
8648 // A main frame that is unrelated to any other frame /can/ reuse the global if 8648 // A main frame that is unrelated to any other frame /can/ reuse the global if
8649 // the setting is enabled. In this case, it's impossible for any other frames to 8649 // the setting is enabled. In this case, it's impossible for any other frames to
8650 // have touched the global. Only the embedder could have injected script, and 8650 // have touched the global. Only the embedder could have injected script, and
8651 // the embedder enabling this setting is a signal that the injected script needs 8651 // the embedder enabling this setting is a signal that the injected script needs
8652 // to persist on the first navigation away from the initial empty document. 8652 // to persist on the first navigation away from the initial empty document.
8653 TEST(WebFrameGlobalReuseTest, ReuseForMainFrameIfEnabled) 8653 TEST(WebFrameGlobalReuseTest, ReuseForMainFrameIfEnabled)
8654 { 8654 {
8655 FrameTestHelpers::WebViewHelper helper; 8655 FrameTestHelpers::WebViewHelper helper;
8656 helper.initialize(true, nullptr, nullptr, nullptr, enableGlobalReuseForUnown edMainFrames); 8656 helper.initialize(true, nullptr, nullptr, nullptr, enableGlobalReuseForUnown edMainFrames);
8657 8657
8658 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8658 WebLocalFrame* mainFrame = helper.webView()->mainFrameImpl();
8659 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8659 v8::HandleScope scope(v8::Isolate::GetCurrent());
8660 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8660 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8661 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8661 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8662 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8662 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8663 ASSERT_TRUE(result->IsString()); 8663 ASSERT_TRUE(result->IsString());
8664 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); 8664 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked()));
8665 } 8665 }
8666 8666
8667 class SaveImageFromDataURLWebFrameClient : public FrameTestHelpers::TestWebFrame Client { 8667 class SaveImageFromDataURLWebFrameClient : public FrameTestHelpers::TestWebFrame Client {
8668 public: 8668 public:
(...skipping 13 matching lines...) Expand all
8682 std::string url = m_baseURL + "image-with-data-url.html"; 8682 std::string url = m_baseURL + "image-with-data-url.html";
8683 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-with-data-url.html "); 8683 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-with-data-url.html ");
8684 URLTestHelpers::registerMockedURLLoad(toKURL("http://test"), "white-1x1.png" ); 8684 URLTestHelpers::registerMockedURLLoad(toKURL("http://test"), "white-1x1.png" );
8685 8685
8686 FrameTestHelpers::WebViewHelper helper; 8686 FrameTestHelpers::WebViewHelper helper;
8687 SaveImageFromDataURLWebFrameClient client; 8687 SaveImageFromDataURLWebFrameClient client;
8688 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); 8688 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client);
8689 webView->resize(WebSize(400, 400)); 8689 webView->resize(WebSize(400, 400));
8690 webView->updateAllLifecyclePhases(); 8690 webView->updateAllLifecyclePhases();
8691 8691
8692 WebLocalFrame* localFrame = webView->mainFrame()->toWebLocalFrame(); 8692 WebLocalFrame* localFrame = webView->mainFrameImpl();
8693 8693
8694 client.reset(); 8694 client.reset();
8695 localFrame->saveImageAt(WebPoint(1, 1)); 8695 localFrame->saveImageAt(WebPoint(1, 1));
8696 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" 8696 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64"
8697 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8697 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8698 8698
8699 client.reset(); 8699 client.reset();
8700 localFrame->saveImageAt(WebPoint(1, 2)); 8700 localFrame->saveImageAt(WebPoint(1, 2));
8701 EXPECT_EQ(WebString(), client.result()); 8701 EXPECT_EQ(WebString(), client.result());
8702 8702
8703 webView->setPageScaleFactor(4); 8703 webView->setPageScaleFactor(4);
8704 webView->setVisualViewportOffset(WebFloatPoint(1, 1)); 8704 webView->setVisualViewportOffset(WebFloatPoint(1, 1));
8705 8705
8706 client.reset(); 8706 client.reset();
8707 localFrame->saveImageAt(WebPoint(3, 3)); 8707 localFrame->saveImageAt(WebPoint(3, 3));
8708 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" 8708 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64"
8709 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8709 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8710 8710
8711 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient. 8711 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient.
8712 } 8712 }
8713 8713
8714 TEST_F(WebFrameTest, SaveImageWithImageMap) 8714 TEST_F(WebFrameTest, SaveImageWithImageMap)
8715 { 8715 {
8716 std::string url = m_baseURL + "image-map.html"; 8716 std::string url = m_baseURL + "image-map.html";
8717 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); 8717 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html");
8718 8718
8719 FrameTestHelpers::WebViewHelper helper; 8719 FrameTestHelpers::WebViewHelper helper;
8720 SaveImageFromDataURLWebFrameClient client; 8720 SaveImageFromDataURLWebFrameClient client;
8721 WebView* webView = helper.initializeAndLoad(url, true, &client); 8721 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client);
8722 webView->resize(WebSize(400, 400)); 8722 webView->resize(WebSize(400, 400));
8723 8723
8724 WebLocalFrame* localFrame = webView->mainFrame()->toWebLocalFrame(); 8724 WebLocalFrame* localFrame = webView->mainFrameImpl();
8725 8725
8726 client.reset(); 8726 client.reset();
8727 localFrame->saveImageAt(WebPoint(25, 25)); 8727 localFrame->saveImageAt(WebPoint(25, 25));
8728 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" 8728 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64"
8729 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8729 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8730 8730
8731 client.reset(); 8731 client.reset();
8732 localFrame->saveImageAt(WebPoint(75, 25)); 8732 localFrame->saveImageAt(WebPoint(75, 25));
8733 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" 8733 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64"
8734 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8734 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8735 8735
8736 client.reset(); 8736 client.reset();
8737 localFrame->saveImageAt(WebPoint(125, 25)); 8737 localFrame->saveImageAt(WebPoint(125, 25));
8738 EXPECT_EQ(WebString(), client.result()); 8738 EXPECT_EQ(WebString(), client.result());
8739 8739
8740 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient. 8740 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient.
8741 } 8741 }
8742 8742
8743 TEST_F(WebFrameTest, CopyImageAt) 8743 TEST_F(WebFrameTest, CopyImageAt)
8744 { 8744 {
8745 std::string url = m_baseURL + "canvas-copy-image.html"; 8745 std::string url = m_baseURL + "canvas-copy-image.html";
8746 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html") ; 8746 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html") ;
8747 8747
8748 FrameTestHelpers::WebViewHelper helper; 8748 FrameTestHelpers::WebViewHelper helper;
8749 WebView* webView = helper.initializeAndLoad(url, true, 0); 8749 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0);
8750 webView->resize(WebSize(400, 400)); 8750 webView->resize(WebSize(400, 400));
8751 8751
8752 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard); 8752 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard);
8753 8753
8754 WebLocalFrame* localFrame = webView->mainFrame()->toWebLocalFrame(); 8754 WebLocalFrame* localFrame = webView->mainFrameImpl();
8755 localFrame->copyImageAt(WebPoint(50, 50)); 8755 localFrame->copyImageAt(WebPoint(50, 50));
8756 8756
8757 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard)); 8757 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard));
8758 8758
8759 WebImage image = static_cast<WebMockClipboard*>(Platform::current()->clipboa rd())->readRawImage(WebClipboard::Buffer()); 8759 WebImage image = static_cast<WebMockClipboard*>(Platform::current()->clipboa rd())->readRawImage(WebClipboard::Buffer());
8760 8760
8761 SkAutoLockPixels autoLock(image.getSkBitmap()); 8761 SkAutoLockPixels autoLock(image.getSkBitmap());
8762 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0) ); 8762 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0) );
8763 }; 8763 };
8764 8764
8765 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) 8765 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom)
8766 { 8766 {
8767 std::string url = m_baseURL + "canvas-copy-image.html"; 8767 std::string url = m_baseURL + "canvas-copy-image.html";
8768 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html") ; 8768 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html") ;
8769 8769
8770 FrameTestHelpers::WebViewHelper helper; 8770 FrameTestHelpers::WebViewHelper helper;
8771 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); 8771 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0);
8772 webView->resize(WebSize(400, 400)); 8772 webView->resize(WebSize(400, 400));
8773 webView->updateAllLifecyclePhases(); 8773 webView->updateAllLifecyclePhases();
8774 webView->setPageScaleFactor(2); 8774 webView->setPageScaleFactor(2);
8775 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); 8775 webView->setVisualViewportOffset(WebFloatPoint(200, 200));
8776 8776
8777 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard); 8777 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard);
8778 8778
8779 WebLocalFrame* localFrame = webView->mainFrame()->toWebLocalFrame(); 8779 WebLocalFrame* localFrame = webView->mainFrameImpl();
8780 localFrame->copyImageAt(WebPoint(0, 0)); 8780 localFrame->copyImageAt(WebPoint(0, 0));
8781 8781
8782 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard)); 8782 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip board::BufferStandard));
8783 8783
8784 WebImage image = static_cast<WebMockClipboard*>(Platform::current()->clipboa rd())->readRawImage(WebClipboard::Buffer()); 8784 WebImage image = static_cast<WebMockClipboard*>(Platform::current()->clipboa rd())->readRawImage(WebClipboard::Buffer());
8785 8785
8786 SkAutoLockPixels autoLock(image.getSkBitmap()); 8786 SkAutoLockPixels autoLock(image.getSkBitmap());
8787 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0) ); 8787 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0) );
8788 }; 8788 };
8789 8789
8790 TEST_F(WebFrameTest, CopyImageWithImageMap) 8790 TEST_F(WebFrameTest, CopyImageWithImageMap)
8791 { 8791 {
8792 SaveImageFromDataURLWebFrameClient client; 8792 SaveImageFromDataURLWebFrameClient client;
8793 8793
8794 std::string url = m_baseURL + "image-map.html"; 8794 std::string url = m_baseURL + "image-map.html";
8795 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); 8795 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html");
8796 8796
8797 FrameTestHelpers::WebViewHelper helper; 8797 FrameTestHelpers::WebViewHelper helper;
8798 WebView* webView = helper.initializeAndLoad(url, true, &client); 8798 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client);
8799 webView->resize(WebSize(400, 400)); 8799 webView->resize(WebSize(400, 400));
8800 8800
8801 client.reset(); 8801 client.reset();
8802 WebLocalFrame* localFrame = webView->mainFrame()->toWebLocalFrame(); 8802 WebLocalFrame* localFrame = webView->mainFrameImpl();
8803 localFrame->saveImageAt(WebPoint(25, 25)); 8803 localFrame->saveImageAt(WebPoint(25, 25));
8804 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" 8804 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64"
8805 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8805 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8806 8806
8807 client.reset(); 8807 client.reset();
8808 localFrame->saveImageAt(WebPoint(75, 25)); 8808 localFrame->saveImageAt(WebPoint(75, 25));
8809 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" 8809 EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64"
8810 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8810 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8811 8811
8812 client.reset(); 8812 client.reset();
8813 localFrame->saveImageAt(WebPoint(125, 25)); 8813 localFrame->saveImageAt(WebPoint(125, 25));
8814 EXPECT_EQ(WebString(), client.result()); 8814 EXPECT_EQ(WebString(), client.result());
8815 8815
8816 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient. 8816 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient.
8817 } 8817 }
8818 8818
8819 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) 8819 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame)
8820 { 8820 {
8821 FrameTestHelpers::WebViewHelper helper; 8821 FrameTestHelpers::WebViewHelper helper;
8822 helper.initialize(true); 8822 helper.initialize(true);
8823 8823
8824 WebURLRequest request; 8824 WebURLRequest request;
8825 std::string redirectURL = m_baseURL + "foo.html"; 8825 std::string redirectURL = m_baseURL + "foo.html";
8826 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), "foo.html"); 8826 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), "foo.html");
8827 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); 8827 request.setURL(toKURL("javascript:location='" + redirectURL + "'"));
8828 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); 8828 request.setRequestorOrigin(WebSecurityOrigin::createUnique());
8829 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); 8829 helper.webView()->mainFrameImpl()->loadRequest(request);
8830 8830
8831 // Normally, the result of the JS url replaces the existing contents on the 8831 // Normally, the result of the JS url replaces the existing contents on the
8832 // Document. However, if the JS triggers a navigation, the contents should 8832 // Document. However, if the JS triggers a navigation, the contents should
8833 // not be replaced. 8833 // not be replaced.
8834 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText()); 8834 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document( )->documentElement()->innerText());
8835 } 8835 }
8836 8836
8837 } // namespace blink 8837 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698