OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 webViewHelper.webView() | 398 webViewHelper.webView() |
399 ->mainFrameImpl() | 399 ->mainFrameImpl() |
400 ->frame() | 400 ->frame() |
401 ->document() | 401 ->document() |
402 ->suspendScheduledTasks(); | 402 ->suspendScheduledTasks(); |
403 webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndReturnValue( | 403 webViewHelper.webView()->mainFrameImpl()->requestExecuteScriptAndReturnValue( |
404 WebScriptSource(WebString("'hello';")), false, &callbackHelper); | 404 WebScriptSource(WebString("'hello';")), false, &callbackHelper); |
405 runPendingTasks(); | 405 runPendingTasks(); |
406 EXPECT_FALSE(callbackHelper.didComplete()); | 406 EXPECT_FALSE(callbackHelper.didComplete()); |
407 | 407 |
408 // If the frame navigates, pending scripts should be removed, but the callback
should always be ran. | 408 // If the frame navigates, pending scripts should be removed, but the callback |
| 409 // should always be ran. |
409 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 410 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
410 m_baseURL + "bar.html"); | 411 m_baseURL + "bar.html"); |
411 EXPECT_TRUE(callbackHelper.didComplete()); | 412 EXPECT_TRUE(callbackHelper.didComplete()); |
412 EXPECT_EQ(String(), callbackHelper.stringValue()); | 413 EXPECT_EQ(String(), callbackHelper.stringValue()); |
413 } | 414 } |
414 | 415 |
415 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) { | 416 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) { |
416 registerMockedHttpURLLoad("single_iframe.html"); | 417 registerMockedHttpURLLoad("single_iframe.html"); |
417 registerMockedHttpURLLoad("visible_iframe.html"); | 418 registerMockedHttpURLLoad("visible_iframe.html"); |
418 | 419 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 459 |
459 // Pass true to enable JavaScript. | 460 // Pass true to enable JavaScript. |
460 FrameTestHelpers::WebViewHelper webViewHelper; | 461 FrameTestHelpers::WebViewHelper webViewHelper; |
461 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); | 462 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); |
462 | 463 |
463 // Try to run JS against the chrome-style URL. | 464 // Try to run JS against the chrome-style URL. |
464 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 465 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
465 "javascript:document.body.appendChild(document." | 466 "javascript:document.body.appendChild(document." |
466 "createTextNode('Clobbered'))"); | 467 "createTextNode('Clobbered'))"); |
467 | 468 |
468 // Now retrieve the frame's text and ensure it was modified by running javascr
ipt. | 469 // Now retrieve the frame's text and ensure it was modified by running |
| 470 // javascript. |
469 std::string content = | 471 std::string content = |
470 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 472 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
471 .utf8(); | 473 .utf8(); |
472 EXPECT_NE(std::string::npos, content.find("Clobbered")); | 474 EXPECT_NE(std::string::npos, content.find("Clobbered")); |
473 } | 475 } |
474 | 476 |
475 TEST_P(ParameterizedWebFrameTest, ChromePageNoJavascript) { | 477 TEST_P(ParameterizedWebFrameTest, ChromePageNoJavascript) { |
476 registerMockedChromeURLLoad("history.html"); | 478 registerMockedChromeURLLoad("history.html"); |
477 | 479 |
478 /// Pass true to enable JavaScript. | 480 /// Pass true to enable JavaScript. |
479 FrameTestHelpers::WebViewHelper webViewHelper; | 481 FrameTestHelpers::WebViewHelper webViewHelper; |
480 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); | 482 webViewHelper.initializeAndLoad(m_chromeURL + "history.html", true); |
481 | 483 |
482 // Try to run JS against the chrome-style URL after prohibiting it. | 484 // Try to run JS against the chrome-style URL after prohibiting it. |
483 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); | 485 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); |
484 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 486 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
485 "javascript:document.body.appendChild(document." | 487 "javascript:document.body.appendChild(document." |
486 "createTextNode('Clobbered'))"); | 488 "createTextNode('Clobbered'))"); |
487 | 489 |
488 // Now retrieve the frame's text and ensure it wasn't modified by running java
script. | 490 // Now retrieve the frame's text and ensure it wasn't modified by running |
| 491 // javascript. |
489 std::string content = | 492 std::string content = |
490 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 493 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
491 .utf8(); | 494 .utf8(); |
492 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 495 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
493 } | 496 } |
494 | 497 |
495 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) { | 498 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) { |
496 std::string fileName = "print-location-href.html"; | 499 std::string fileName = "print-location-href.html"; |
497 registerMockedHttpURLLoad(fileName); | 500 registerMockedHttpURLLoad(fileName); |
498 URLTestHelpers::registerMockedURLLoad( | 501 URLTestHelpers::registerMockedURLLoad( |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 948 |
946 Document* document = | 949 Document* document = |
947 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->document(); | 950 toLocalFrame(webViewHelper.webView()->page()->mainFrame())->document(); |
948 document->settings()->setTextAutosizingEnabled(true); | 951 document->settings()->setTextAutosizingEnabled(true); |
949 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 952 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
950 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 953 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
951 | 954 |
952 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); | 955 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); |
953 | 956 |
954 ViewportDescription description = document->viewportDescription(); | 957 ViewportDescription description = document->viewportDescription(); |
955 // Choose a width that's not going match the viewport width of the loaded docu
ment. | 958 // Choose a width that's not going match the viewport width of the loaded |
| 959 // document. |
956 description.minWidth = Length(100, blink::Fixed); | 960 description.minWidth = Length(100, blink::Fixed); |
957 description.maxWidth = Length(100, blink::Fixed); | 961 description.maxWidth = Length(100, blink::Fixed); |
958 webViewHelper.webView()->updatePageDefinedViewportConstraints(description); | 962 webViewHelper.webView()->updatePageDefinedViewportConstraints(description); |
959 | 963 |
960 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); | 964 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); |
961 } | 965 } |
962 | 966 |
963 TEST_P(ParameterizedWebFrameTest, | 967 TEST_P(ParameterizedWebFrameTest, |
964 WorkingTextAutosizingMultipliers_VirtualViewport) { | 968 WorkingTextAutosizingMultipliers_VirtualViewport) { |
965 const std::string htmlFile = "fixed_layout.html"; | 969 const std::string htmlFile = "fixed_layout.html"; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 int viewportHeight = 480; | 1224 int viewportHeight = 480; |
1221 | 1225 |
1222 FrameTestHelpers::WebViewHelper webViewHelper; | 1226 FrameTestHelpers::WebViewHelper webViewHelper; |
1223 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr, | 1227 webViewHelper.initializeAndLoad(m_baseURL + "large-div.html", true, nullptr, |
1224 &client, nullptr, enableViewportSettings); | 1228 &client, nullptr, enableViewportSettings); |
1225 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1229 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1226 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1230 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1227 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1231 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1228 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1232 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1229 | 1233 |
1230 // The page must be displayed at 100% zoom, despite that it hosts a wide div e
lement. | 1234 // The page must be displayed at 100% zoom, despite that it hosts a wide div |
| 1235 // element. |
1231 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1236 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
1232 } | 1237 } |
1233 | 1238 |
1234 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidth) { | 1239 TEST_P(ParameterizedWebFrameTest, NoWideViewportIgnoresPageViewportWidth) { |
1235 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); | 1240 registerMockedHttpURLLoad("viewport-auto-initial-scale.html"); |
1236 | 1241 |
1237 FixedLayoutTestWebViewClient client; | 1242 FixedLayoutTestWebViewClient client; |
1238 client.m_screenInfo.deviceScaleFactor = 1; | 1243 client.m_screenInfo.deviceScaleFactor = 1; |
1239 int viewportWidth = 640; | 1244 int viewportWidth = 640; |
1240 int viewportHeight = 480; | 1245 int viewportHeight = 480; |
1241 | 1246 |
1242 FrameTestHelpers::WebViewHelper webViewHelper; | 1247 FrameTestHelpers::WebViewHelper webViewHelper; |
1243 webViewHelper.initializeAndLoad( | 1248 webViewHelper.initializeAndLoad( |
1244 m_baseURL + "viewport-auto-initial-scale.html", true, nullptr, &client, | 1249 m_baseURL + "viewport-auto-initial-scale.html", true, nullptr, &client, |
1245 nullptr, enableViewportSettings); | 1250 nullptr, enableViewportSettings); |
1246 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1251 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1247 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1252 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1248 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1253 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1249 | 1254 |
1250 // The page sets viewport width to 3000, but with UseWideViewport == false is
must be ignored. | 1255 // The page sets viewport width to 3000, but with UseWideViewport == false is |
| 1256 // must be ignored. |
1251 EXPECT_EQ(viewportWidth, webViewHelper.webView() | 1257 EXPECT_EQ(viewportWidth, webViewHelper.webView() |
1252 ->mainFrameImpl() | 1258 ->mainFrameImpl() |
1253 ->frameView() | 1259 ->frameView() |
1254 ->contentsSize() | 1260 ->contentsSize() |
1255 .width()); | 1261 .width()); |
1256 EXPECT_EQ(viewportHeight, webViewHelper.webView() | 1262 EXPECT_EQ(viewportHeight, webViewHelper.webView() |
1257 ->mainFrameImpl() | 1263 ->mainFrameImpl() |
1258 ->frameView() | 1264 ->frameView() |
1259 ->contentsSize() | 1265 ->contentsSize() |
1260 .height()); | 1266 .height()); |
1261 } | 1267 } |
1262 | 1268 |
1263 TEST_P(ParameterizedWebFrameTest, | 1269 TEST_P(ParameterizedWebFrameTest, |
1264 NoWideViewportIgnoresPageViewportWidthButAccountsScale) { | 1270 NoWideViewportIgnoresPageViewportWidthButAccountsScale) { |
1265 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); | 1271 registerMockedHttpURLLoad("viewport-wide-2x-initial-scale.html"); |
1266 | 1272 |
1267 FixedLayoutTestWebViewClient client; | 1273 FixedLayoutTestWebViewClient client; |
1268 client.m_screenInfo.deviceScaleFactor = 1; | 1274 client.m_screenInfo.deviceScaleFactor = 1; |
1269 int viewportWidth = 640; | 1275 int viewportWidth = 640; |
1270 int viewportHeight = 480; | 1276 int viewportHeight = 480; |
1271 | 1277 |
1272 FrameTestHelpers::WebViewHelper webViewHelper; | 1278 FrameTestHelpers::WebViewHelper webViewHelper; |
1273 webViewHelper.initializeAndLoad( | 1279 webViewHelper.initializeAndLoad( |
1274 m_baseURL + "viewport-wide-2x-initial-scale.html", true, nullptr, &client, | 1280 m_baseURL + "viewport-wide-2x-initial-scale.html", true, nullptr, &client, |
1275 nullptr, enableViewportSettings); | 1281 nullptr, enableViewportSettings); |
1276 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1282 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1277 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1283 webViewHelper.webView()->settings()->setUseWideViewport(false); |
1278 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1284 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1279 | 1285 |
1280 // The page sets viewport width to 3000, but with UseWideViewport == false it
must be ignored. | 1286 // The page sets viewport width to 3000, but with UseWideViewport == false it |
1281 // While the initial scale specified by the page must be accounted. | 1287 // must be ignored while the initial scale specified by the page must be |
| 1288 // accounted. |
1282 EXPECT_EQ(viewportWidth / 2, webViewHelper.webView() | 1289 EXPECT_EQ(viewportWidth / 2, webViewHelper.webView() |
1283 ->mainFrameImpl() | 1290 ->mainFrameImpl() |
1284 ->frameView() | 1291 ->frameView() |
1285 ->contentsSize() | 1292 ->contentsSize() |
1286 .width()); | 1293 .width()); |
1287 EXPECT_EQ(viewportHeight / 2, webViewHelper.webView() | 1294 EXPECT_EQ(viewportHeight / 2, webViewHelper.webView() |
1288 ->mainFrameImpl() | 1295 ->mainFrameImpl() |
1289 ->frameView() | 1296 ->frameView() |
1290 ->contentsSize() | 1297 ->contentsSize() |
1291 .height()); | 1298 .height()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 int viewportWidth = 640; | 1419 int viewportWidth = 640; |
1413 int viewportHeight = 480; | 1420 int viewportHeight = 480; |
1414 | 1421 |
1415 FrameTestHelpers::WebViewHelper webViewHelper; | 1422 FrameTestHelpers::WebViewHelper webViewHelper; |
1416 webViewHelper.initializeAndLoad( | 1423 webViewHelper.initializeAndLoad( |
1417 m_baseURL + "viewport-wide-2x-initial-scale.html", true, nullptr, &client, | 1424 m_baseURL + "viewport-wide-2x-initial-scale.html", true, nullptr, &client, |
1418 nullptr, enableViewportSettings); | 1425 nullptr, enableViewportSettings); |
1419 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1426 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1420 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1427 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1421 | 1428 |
1422 // The page must be displayed at 200% zoom, as specified in its viewport meta
tag. | 1429 // The page must be displayed at 200% zoom, as specified in its viewport meta |
| 1430 // tag. |
1423 EXPECT_EQ(2.0f, webViewHelper.webView()->pageScaleFactor()); | 1431 EXPECT_EQ(2.0f, webViewHelper.webView()->pageScaleFactor()); |
1424 } | 1432 } |
1425 | 1433 |
1426 TEST_P(ParameterizedWebFrameTest, setInitialPageScaleFactorPermanently) { | 1434 TEST_P(ParameterizedWebFrameTest, setInitialPageScaleFactorPermanently) { |
1427 registerMockedHttpURLLoad("fixed_layout.html"); | 1435 registerMockedHttpURLLoad("fixed_layout.html"); |
1428 | 1436 |
1429 FixedLayoutTestWebViewClient client; | 1437 FixedLayoutTestWebViewClient client; |
1430 client.m_screenInfo.deviceScaleFactor = 1; | 1438 client.m_screenInfo.deviceScaleFactor = 1; |
1431 float enforcedPageScaleFactor = 2.0f; | 1439 float enforcedPageScaleFactor = 2.0f; |
1432 | 1440 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor); | 1502 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor); |
1495 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1503 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1496 | 1504 |
1497 EXPECT_EQ(enforcedPageScaleFactor, | 1505 EXPECT_EQ(enforcedPageScaleFactor, |
1498 webViewHelper.webView()->pageScaleFactor()); | 1506 webViewHelper.webView()->pageScaleFactor()); |
1499 } | 1507 } |
1500 | 1508 |
1501 TEST_P(ParameterizedWebFrameTest, | 1509 TEST_P(ParameterizedWebFrameTest, |
1502 SmallPermanentInitialPageScaleFactorIsClobbered) { | 1510 SmallPermanentInitialPageScaleFactorIsClobbered) { |
1503 const char* pages[] = { | 1511 const char* pages[] = { |
1504 // These pages trigger the clobbering condition. There must be a matching
item in "pageScaleFactors" array. | 1512 // These pages trigger the clobbering condition. There must be a matching |
| 1513 // item in "pageScaleFactors" array. |
1505 "viewport-device-0.5x-initial-scale.html", | 1514 "viewport-device-0.5x-initial-scale.html", |
1506 "viewport-initial-scale-1.html", | 1515 "viewport-initial-scale-1.html", |
1507 // These ones do not. | 1516 // These ones do not. |
1508 "viewport-auto-initial-scale.html", | 1517 "viewport-auto-initial-scale.html", |
1509 "viewport-target-densitydpi-device-and-fixed-width.html"}; | 1518 "viewport-target-densitydpi-device-and-fixed-width.html"}; |
1510 float pageScaleFactors[] = {0.5f, 1.0f}; | 1519 float pageScaleFactors[] = {0.5f, 1.0f}; |
1511 for (size_t i = 0; i < WTF_ARRAY_LENGTH(pages); ++i) | 1520 for (size_t i = 0; i < WTF_ARRAY_LENGTH(pages); ++i) |
1512 registerMockedHttpURLLoad(pages[i]); | 1521 registerMockedHttpURLLoad(pages[i]); |
1513 | 1522 |
1514 FixedLayoutTestWebViewClient client; | 1523 FixedLayoutTestWebViewClient client; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 EXPECT_EQ(0, webViewHelper.webView() | 1633 EXPECT_EQ(0, webViewHelper.webView() |
1625 ->mainFrameImpl() | 1634 ->mainFrameImpl() |
1626 ->frameView() | 1635 ->frameView() |
1627 ->layoutSize() | 1636 ->layoutSize() |
1628 .height()); | 1637 .height()); |
1629 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); | 1638 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); |
1630 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); | 1639 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); |
1631 | 1640 |
1632 // The flag ForceZeroLayoutHeight will cause the following resize of viewport | 1641 // The flag ForceZeroLayoutHeight will cause the following resize of viewport |
1633 // height to be ignored by the outer viewport (the container layer of | 1642 // height to be ignored by the outer viewport (the container layer of |
1634 // LayerCompositor). The height of the visualViewport, however, is not affecte
d. | 1643 // LayerCompositor). The height of the visualViewport, however, is not |
| 1644 // affected. |
1635 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 1645 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
1636 EXPECT_FALSE( | 1646 EXPECT_FALSE( |
1637 webViewHelper.webView()->mainFrameImpl()->frameView()->needsLayout()); | 1647 webViewHelper.webView()->mainFrameImpl()->frameView()->needsLayout()); |
1638 EXPECT_EQ(viewportWidth, webViewHelper.webView() | 1648 EXPECT_EQ(viewportWidth, webViewHelper.webView() |
1639 ->mainFrameImpl() | 1649 ->mainFrameImpl() |
1640 ->frameView() | 1650 ->frameView() |
1641 ->layoutSize() | 1651 ->layoutSize() |
1642 .width()); | 1652 .width()); |
1643 EXPECT_EQ(0, webViewHelper.webView() | 1653 EXPECT_EQ(0, webViewHelper.webView() |
1644 ->mainFrameImpl() | 1654 ->mainFrameImpl() |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 | 2367 |
2358 FrameTestHelpers::WebViewHelper webViewHelper; | 2368 FrameTestHelpers::WebViewHelper webViewHelper; |
2359 webViewHelper.initializeAndLoad( | 2369 webViewHelper.initializeAndLoad( |
2360 m_baseURL + "viewport-target-densitydpi-high.html", true, nullptr, | 2370 m_baseURL + "viewport-target-densitydpi-high.html", true, nullptr, |
2361 &client, nullptr, enableViewportSettings); | 2371 &client, nullptr, enableViewportSettings); |
2362 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 2372 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
2363 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI( | 2373 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI( |
2364 true); | 2374 true); |
2365 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2375 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2366 | 2376 |
2367 // We need to account for the fact that logical pixels are unconditionally m
ultiplied by deviceScaleFactor to produce | 2377 // We need to account for the fact that logical pixels are unconditionally |
2368 // physical pixels. | 2378 // multiplied by deviceScaleFactor to produce physical pixels. |
2369 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; | 2379 float densityDpiScaleRatio = deviceScaleFactor * targetDpi / deviceDpi; |
2370 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webView() | 2380 EXPECT_NEAR(viewportWidth * densityDpiScaleRatio, webViewHelper.webView() |
2371 ->mainFrameImpl() | 2381 ->mainFrameImpl() |
2372 ->frameView() | 2382 ->frameView() |
2373 ->layoutSize() | 2383 ->layoutSize() |
2374 .width(), | 2384 .width(), |
2375 1.0f); | 2385 1.0f); |
2376 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView() | 2386 EXPECT_NEAR(viewportHeight * densityDpiScaleRatio, webViewHelper.webView() |
2377 ->mainFrameImpl() | 2387 ->mainFrameImpl() |
2378 ->frameView() | 2388 ->frameView() |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 webViewHelper.resize(WebSize(viewportSize.height, viewportSize.width)); | 2742 webViewHelper.resize(WebSize(viewportSize.height, viewportSize.width)); |
2733 float expectedPageScaleFactor = | 2743 float expectedPageScaleFactor = |
2734 initialPageScaleFactor * | 2744 initialPageScaleFactor * |
2735 (shouldScaleRelativeToViewportWidth ? 1 / aspectRatio : 1); | 2745 (shouldScaleRelativeToViewportWidth ? 1 / aspectRatio : 1); |
2736 EXPECT_NEAR(expectedPageScaleFactor, | 2746 EXPECT_NEAR(expectedPageScaleFactor, |
2737 webViewHelper.webView()->pageScaleFactor(), 0.05f); | 2747 webViewHelper.webView()->pageScaleFactor(), 0.05f); |
2738 EXPECT_EQ(WebSize(), | 2748 EXPECT_EQ(WebSize(), |
2739 webViewHelper.webView()->mainFrame()->scrollOffset()); | 2749 webViewHelper.webView()->mainFrame()->scrollOffset()); |
2740 } | 2750 } |
2741 | 2751 |
2742 // Resizing just the height should not affect pageScaleFactor or scrollOffse
t. | 2752 // Resizing just the height should not affect pageScaleFactor or |
| 2753 // scrollOffset. |
2743 { | 2754 { |
2744 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height)); | 2755 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height)); |
2745 webViewHelper.webView()->setPageScaleFactor(initialPageScaleFactor); | 2756 webViewHelper.webView()->setPageScaleFactor(initialPageScaleFactor); |
2746 webViewHelper.webView()->mainFrame()->setScrollOffset(scrollOffset); | 2757 webViewHelper.webView()->mainFrame()->setScrollOffset(scrollOffset); |
2747 webViewHelper.webView()->updateAllLifecyclePhases(); | 2758 webViewHelper.webView()->updateAllLifecyclePhases(); |
2748 const WebSize expectedScrollOffset = | 2759 const WebSize expectedScrollOffset = |
2749 webViewHelper.webView()->mainFrame()->scrollOffset(); | 2760 webViewHelper.webView()->mainFrame()->scrollOffset(); |
2750 webViewHelper.resize( | 2761 webViewHelper.resize( |
2751 WebSize(viewportSize.width, viewportSize.height * 0.8f)); | 2762 WebSize(viewportSize.width, viewportSize.height * 0.8f)); |
2752 EXPECT_EQ(initialPageScaleFactor, | 2763 EXPECT_EQ(initialPageScaleFactor, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 const WebSize scrollOffset(0, 0); | 2801 const WebSize scrollOffset(0, 0); |
2791 const WebSize viewportSize(240, 320); | 2802 const WebSize viewportSize(240, 320); |
2792 const bool shouldScaleRelativeToViewportWidth = false; | 2803 const bool shouldScaleRelativeToViewportWidth = false; |
2793 | 2804 |
2794 testResizeYieldsCorrectScrollAndScale(url, initialPageScaleFactor, | 2805 testResizeYieldsCorrectScrollAndScale(url, initialPageScaleFactor, |
2795 scrollOffset, viewportSize, | 2806 scrollOffset, viewportSize, |
2796 shouldScaleRelativeToViewportWidth); | 2807 shouldScaleRelativeToViewportWidth); |
2797 } | 2808 } |
2798 | 2809 |
2799 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedWidth) { | 2810 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedWidth) { |
2800 // With a fixed width, pageScaleFactor scales by the relative change in viewpo
rt width. | 2811 // With a fixed width, pageScaleFactor scales by the relative change in |
| 2812 // viewport width. |
2801 const char* url = "resize_scroll_fixed_width.html"; | 2813 const char* url = "resize_scroll_fixed_width.html"; |
2802 const float initialPageScaleFactor = 2; | 2814 const float initialPageScaleFactor = 2; |
2803 const WebSize scrollOffset(0, 200); | 2815 const WebSize scrollOffset(0, 200); |
2804 const WebSize viewportSize(240, 320); | 2816 const WebSize viewportSize(240, 320); |
2805 const bool shouldScaleRelativeToViewportWidth = true; | 2817 const bool shouldScaleRelativeToViewportWidth = true; |
2806 | 2818 |
2807 testResizeYieldsCorrectScrollAndScale(url, initialPageScaleFactor, | 2819 testResizeYieldsCorrectScrollAndScale(url, initialPageScaleFactor, |
2808 scrollOffset, viewportSize, | 2820 scrollOffset, viewportSize, |
2809 shouldScaleRelativeToViewportWidth); | 2821 shouldScaleRelativeToViewportWidth); |
2810 } | 2822 } |
2811 | 2823 |
2812 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedLayout) { | 2824 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedLayout) { |
2813 // With a fixed layout, pageScaleFactor scales by the relative change in viewp
ort width. | 2825 // With a fixed layout, pageScaleFactor scales by the relative change in |
| 2826 // viewport width. |
2814 const char* url = "resize_scroll_fixed_layout.html"; | 2827 const char* url = "resize_scroll_fixed_layout.html"; |
2815 const float initialPageScaleFactor = 2; | 2828 const float initialPageScaleFactor = 2; |
2816 const WebSize scrollOffset(200, 400); | 2829 const WebSize scrollOffset(200, 400); |
2817 const WebSize viewportSize(320, 240); | 2830 const WebSize viewportSize(320, 240); |
2818 const bool shouldScaleRelativeToViewportWidth = true; | 2831 const bool shouldScaleRelativeToViewportWidth = true; |
2819 | 2832 |
2820 testResizeYieldsCorrectScrollAndScale(url, initialPageScaleFactor, | 2833 testResizeYieldsCorrectScrollAndScale(url, initialPageScaleFactor, |
2821 scrollOffset, viewportSize, | 2834 scrollOffset, viewportSize, |
2822 shouldScaleRelativeToViewportWidth); | 2835 shouldScaleRelativeToViewportWidth); |
2823 } | 2836 } |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3103 WebRect topDiv(200, 100, 200, 150); | 3116 WebRect topDiv(200, 100, 200, 150); |
3104 WebRect bottomDiv(200, 300, 200, 150); | 3117 WebRect bottomDiv(200, 300, 200, 150); |
3105 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); | 3118 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); |
3106 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); | 3119 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); |
3107 float scale; | 3120 float scale; |
3108 setScaleAndScrollAndLayout( | 3121 setScaleAndScrollAndLayout( |
3109 webViewHelper.webView(), WebPoint(0, 0), | 3122 webViewHelper.webView(), WebPoint(0, 0), |
3110 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3123 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3111 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3124 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3112 | 3125 |
3113 // Test double tap on two different divs | 3126 // Test double tap on two different divs. After first zoom, we should go back |
3114 // After first zoom, we should go back to minimum page scale with a second dou
ble tap. | 3127 // to minimum page scale with a second double tap. |
3115 simulateDoubleTap(webViewHelper.webView(), topPoint, scale); | 3128 simulateDoubleTap(webViewHelper.webView(), topPoint, scale); |
3116 EXPECT_FLOAT_EQ(1, scale); | 3129 EXPECT_FLOAT_EQ(1, scale); |
3117 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); | 3130 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); |
3118 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3131 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3119 | 3132 |
3120 // If the user pinch zooms after double tap, a second double tap should zoom b
ack to the div. | 3133 // If the user pinch zooms after double tap, a second double tap should zoom |
| 3134 // back to the div. |
3121 simulateDoubleTap(webViewHelper.webView(), topPoint, scale); | 3135 simulateDoubleTap(webViewHelper.webView(), topPoint, scale); |
3122 EXPECT_FLOAT_EQ(1, scale); | 3136 EXPECT_FLOAT_EQ(1, scale); |
3123 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3137 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3124 WebFloatSize(), 0.6f, 0); | 3138 WebFloatSize(), 0.6f, 0); |
3125 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); | 3139 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); |
3126 EXPECT_FLOAT_EQ(1, scale); | 3140 EXPECT_FLOAT_EQ(1, scale); |
3127 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); | 3141 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); |
3128 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3142 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3129 | 3143 |
3130 // If we didn't yet get an auto-zoom update and a second double-tap arrives, s
hould go back to minimum scale. | 3144 // If we didn't yet get an auto-zoom update and a second double-tap arrives, |
| 3145 // should go back to minimum scale. |
3131 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3146 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3132 WebFloatSize(), 1.1f, 0); | 3147 WebFloatSize(), 1.1f, 0); |
3133 webViewHelper.webView()->animateDoubleTapZoom(topPoint); | 3148 webViewHelper.webView()->animateDoubleTapZoom(topPoint); |
3134 EXPECT_TRUE( | 3149 EXPECT_TRUE( |
3135 webViewHelper.webView()->fakeDoubleTapAnimationPendingForTesting()); | 3150 webViewHelper.webView()->fakeDoubleTapAnimationPendingForTesting()); |
3136 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); | 3151 simulateDoubleTap(webViewHelper.webView(), bottomPoint, scale); |
3137 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3152 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3138 } | 3153 } |
3139 | 3154 |
3140 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) { | 3155 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3233 webViewHelper.webView()->updateAllLifecyclePhases(); | 3248 webViewHelper.webView()->updateAllLifecyclePhases(); |
3234 | 3249 |
3235 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); | 3250 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); |
3236 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(true); | 3251 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(true); |
3237 | 3252 |
3238 WebRect div(200, 100, 200, 150); | 3253 WebRect div(200, 100, 200, 150); |
3239 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 3254 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
3240 float scale; | 3255 float scale; |
3241 | 3256 |
3242 // Test double tap scale bounds. | 3257 // Test double tap scale bounds. |
3243 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < maximumLegibleSca
leFactor | 3258 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < |
| 3259 // maximumLegibleScaleFactor |
3244 float legibleScale = maximumLegibleScaleFactor; | 3260 float legibleScale = maximumLegibleScaleFactor; |
3245 setScaleAndScrollAndLayout( | 3261 setScaleAndScrollAndLayout( |
3246 webViewHelper.webView(), WebPoint(0, 0), | 3262 webViewHelper.webView(), WebPoint(0, 0), |
3247 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3263 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3248 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3264 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3249 float doubleTapZoomAlreadyLegibleScale = | 3265 float doubleTapZoomAlreadyLegibleScale = |
3250 webViewHelper.webView()->minimumPageScaleFactor() * | 3266 webViewHelper.webView()->minimumPageScaleFactor() * |
3251 doubleTapZoomAlreadyLegibleRatio; | 3267 doubleTapZoomAlreadyLegibleRatio; |
3252 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); | 3268 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); |
3253 webViewHelper.webView()->updateAllLifecyclePhases(); | 3269 webViewHelper.webView()->updateAllLifecyclePhases(); |
3254 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3270 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3255 EXPECT_FLOAT_EQ(legibleScale, scale); | 3271 EXPECT_FLOAT_EQ(legibleScale, scale); |
3256 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3272 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3257 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3273 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3258 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3274 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3259 EXPECT_FLOAT_EQ(legibleScale, scale); | 3275 EXPECT_FLOAT_EQ(legibleScale, scale); |
3260 | 3276 |
3261 // Zoom in to reset double_tap_zoom_in_effect flag. | 3277 // Zoom in to reset double_tap_zoom_in_effect flag. |
3262 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3278 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3263 WebFloatSize(), 1.1f, 0); | 3279 WebFloatSize(), 1.1f, 0); |
3264 // 1 < maximumLegibleScaleFactor < minimumPageScale < doubleTapZoomAlreadyLegi
bleScale | 3280 // 1 < maximumLegibleScaleFactor < minimumPageScale < |
| 3281 // doubleTapZoomAlreadyLegibleScale |
3265 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4); | 3282 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4); |
3266 webViewHelper.webView()->updateAllLifecyclePhases(); | 3283 webViewHelper.webView()->updateAllLifecyclePhases(); |
3267 doubleTapZoomAlreadyLegibleScale = | 3284 doubleTapZoomAlreadyLegibleScale = |
3268 webViewHelper.webView()->minimumPageScaleFactor() * | 3285 webViewHelper.webView()->minimumPageScaleFactor() * |
3269 doubleTapZoomAlreadyLegibleRatio; | 3286 doubleTapZoomAlreadyLegibleRatio; |
3270 setScaleAndScrollAndLayout( | 3287 setScaleAndScrollAndLayout( |
3271 webViewHelper.webView(), WebPoint(0, 0), | 3288 webViewHelper.webView(), WebPoint(0, 0), |
3272 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3289 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3273 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3290 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3274 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3291 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3275 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3292 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3276 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3293 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3277 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3294 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3278 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3295 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3279 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3296 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3280 | 3297 |
3281 // Zoom in to reset double_tap_zoom_in_effect flag. | 3298 // Zoom in to reset double_tap_zoom_in_effect flag. |
3282 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3299 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3283 WebFloatSize(), 1.1f, 0); | 3300 WebFloatSize(), 1.1f, 0); |
3284 // minimumPageScale < 1 < maximumLegibleScaleFactor < doubleTapZoomAlreadyLegi
bleScale | 3301 // minimumPageScale < 1 < maximumLegibleScaleFactor < |
| 3302 // doubleTapZoomAlreadyLegibleScale |
3285 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); | 3303 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); |
3286 webViewHelper.webView()->updateAllLifecyclePhases(); | 3304 webViewHelper.webView()->updateAllLifecyclePhases(); |
3287 doubleTapZoomAlreadyLegibleScale = | 3305 doubleTapZoomAlreadyLegibleScale = |
3288 webViewHelper.webView()->minimumPageScaleFactor() * | 3306 webViewHelper.webView()->minimumPageScaleFactor() * |
3289 doubleTapZoomAlreadyLegibleRatio; | 3307 doubleTapZoomAlreadyLegibleRatio; |
3290 setScaleAndScrollAndLayout( | 3308 setScaleAndScrollAndLayout( |
3291 webViewHelper.webView(), WebPoint(0, 0), | 3309 webViewHelper.webView(), WebPoint(0, 0), |
3292 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3310 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3293 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3311 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3294 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3312 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3295 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3313 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3296 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3314 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3297 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3315 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3298 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3316 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3299 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3317 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3300 | 3318 |
3301 // Zoom in to reset double_tap_zoom_in_effect flag. | 3319 // Zoom in to reset double_tap_zoom_in_effect flag. |
3302 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3320 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3303 WebFloatSize(), 1.1f, 0); | 3321 WebFloatSize(), 1.1f, 0); |
3304 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < maximumLegibleSca
leFactor | 3322 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < |
| 3323 // maximumLegibleScaleFactor |
3305 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4); | 3324 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4); |
3306 webViewHelper.webView()->updateAllLifecyclePhases(); | 3325 webViewHelper.webView()->updateAllLifecyclePhases(); |
3307 doubleTapZoomAlreadyLegibleScale = | 3326 doubleTapZoomAlreadyLegibleScale = |
3308 webViewHelper.webView()->minimumPageScaleFactor() * | 3327 webViewHelper.webView()->minimumPageScaleFactor() * |
3309 doubleTapZoomAlreadyLegibleRatio; | 3328 doubleTapZoomAlreadyLegibleRatio; |
3310 setScaleAndScrollAndLayout( | 3329 setScaleAndScrollAndLayout( |
3311 webViewHelper.webView(), WebPoint(0, 0), | 3330 webViewHelper.webView(), WebPoint(0, 0), |
3312 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3331 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3313 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3332 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3314 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3333 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
(...skipping 22 matching lines...) Expand all Loading... |
3337 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); | 3356 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); |
3338 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(true); | 3357 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(true); |
3339 webViewHelper.webView()->page()->settings().setAccessibilityFontScaleFactor( | 3358 webViewHelper.webView()->page()->settings().setAccessibilityFontScaleFactor( |
3340 accessibilityFontScaleFactor); | 3359 accessibilityFontScaleFactor); |
3341 | 3360 |
3342 WebRect div(200, 100, 200, 150); | 3361 WebRect div(200, 100, 200, 150); |
3343 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 3362 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
3344 float scale; | 3363 float scale; |
3345 | 3364 |
3346 // Test double tap scale bounds. | 3365 // Test double tap scale bounds. |
3347 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < accessibilityFont
ScaleFactor | 3366 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < |
| 3367 // accessibilityFontScaleFactor |
3348 float legibleScale = accessibilityFontScaleFactor; | 3368 float legibleScale = accessibilityFontScaleFactor; |
3349 setScaleAndScrollAndLayout( | 3369 setScaleAndScrollAndLayout( |
3350 webViewHelper.webView(), WebPoint(0, 0), | 3370 webViewHelper.webView(), WebPoint(0, 0), |
3351 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3371 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3352 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3372 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3353 float doubleTapZoomAlreadyLegibleScale = | 3373 float doubleTapZoomAlreadyLegibleScale = |
3354 webViewHelper.webView()->minimumPageScaleFactor() * | 3374 webViewHelper.webView()->minimumPageScaleFactor() * |
3355 doubleTapZoomAlreadyLegibleRatio; | 3375 doubleTapZoomAlreadyLegibleRatio; |
3356 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); | 3376 webViewHelper.webView()->setDefaultPageScaleLimits(0.5f, 4); |
3357 webViewHelper.webView()->updateAllLifecyclePhases(); | 3377 webViewHelper.webView()->updateAllLifecyclePhases(); |
3358 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3378 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3359 EXPECT_FLOAT_EQ(legibleScale, scale); | 3379 EXPECT_FLOAT_EQ(legibleScale, scale); |
3360 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3380 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3361 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3381 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3362 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3382 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3363 EXPECT_FLOAT_EQ(legibleScale, scale); | 3383 EXPECT_FLOAT_EQ(legibleScale, scale); |
3364 | 3384 |
3365 // Zoom in to reset double_tap_zoom_in_effect flag. | 3385 // Zoom in to reset double_tap_zoom_in_effect flag. |
3366 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3386 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3367 WebFloatSize(), 1.1f, 0); | 3387 WebFloatSize(), 1.1f, 0); |
3368 // 1 < accessibilityFontScaleFactor < minimumPageScale < doubleTapZoomAlreadyL
egibleScale | 3388 // 1 < accessibilityFontScaleFactor < minimumPageScale < |
| 3389 // doubleTapZoomAlreadyLegibleScale |
3369 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4); | 3390 webViewHelper.webView()->setDefaultPageScaleLimits(1.0f, 4); |
3370 webViewHelper.webView()->updateAllLifecyclePhases(); | 3391 webViewHelper.webView()->updateAllLifecyclePhases(); |
3371 doubleTapZoomAlreadyLegibleScale = | 3392 doubleTapZoomAlreadyLegibleScale = |
3372 webViewHelper.webView()->minimumPageScaleFactor() * | 3393 webViewHelper.webView()->minimumPageScaleFactor() * |
3373 doubleTapZoomAlreadyLegibleRatio; | 3394 doubleTapZoomAlreadyLegibleRatio; |
3374 setScaleAndScrollAndLayout( | 3395 setScaleAndScrollAndLayout( |
3375 webViewHelper.webView(), WebPoint(0, 0), | 3396 webViewHelper.webView(), WebPoint(0, 0), |
3376 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3397 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3377 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3398 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3378 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3399 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3379 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3400 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3380 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3401 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3381 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3402 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3382 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3403 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3383 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3404 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3384 | 3405 |
3385 // Zoom in to reset double_tap_zoom_in_effect flag. | 3406 // Zoom in to reset double_tap_zoom_in_effect flag. |
3386 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3407 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3387 WebFloatSize(), 1.1f, 0); | 3408 WebFloatSize(), 1.1f, 0); |
3388 // minimumPageScale < 1 < accessibilityFontScaleFactor < doubleTapZoomAlreadyL
egibleScale | 3409 // minimumPageScale < 1 < accessibilityFontScaleFactor < |
| 3410 // doubleTapZoomAlreadyLegibleScale |
3389 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); | 3411 webViewHelper.webView()->setDefaultPageScaleLimits(0.95f, 4); |
3390 webViewHelper.webView()->updateAllLifecyclePhases(); | 3412 webViewHelper.webView()->updateAllLifecyclePhases(); |
3391 doubleTapZoomAlreadyLegibleScale = | 3413 doubleTapZoomAlreadyLegibleScale = |
3392 webViewHelper.webView()->minimumPageScaleFactor() * | 3414 webViewHelper.webView()->minimumPageScaleFactor() * |
3393 doubleTapZoomAlreadyLegibleRatio; | 3415 doubleTapZoomAlreadyLegibleRatio; |
3394 setScaleAndScrollAndLayout( | 3416 setScaleAndScrollAndLayout( |
3395 webViewHelper.webView(), WebPoint(0, 0), | 3417 webViewHelper.webView(), WebPoint(0, 0), |
3396 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3418 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3397 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3419 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3398 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3420 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3399 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3421 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3400 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3422 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3401 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); | 3423 EXPECT_FLOAT_EQ(webViewHelper.webView()->minimumPageScaleFactor(), scale); |
3402 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3424 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
3403 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 3425 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
3404 | 3426 |
3405 // Zoom in to reset double_tap_zoom_in_effect flag. | 3427 // Zoom in to reset double_tap_zoom_in_effect flag. |
3406 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 3428 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
3407 WebFloatSize(), 1.1f, 0); | 3429 WebFloatSize(), 1.1f, 0); |
3408 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < accessibilityFont
ScaleFactor | 3430 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < |
| 3431 // accessibilityFontScaleFactor |
3409 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4); | 3432 webViewHelper.webView()->setDefaultPageScaleLimits(0.9f, 4); |
3410 webViewHelper.webView()->updateAllLifecyclePhases(); | 3433 webViewHelper.webView()->updateAllLifecyclePhases(); |
3411 doubleTapZoomAlreadyLegibleScale = | 3434 doubleTapZoomAlreadyLegibleScale = |
3412 webViewHelper.webView()->minimumPageScaleFactor() * | 3435 webViewHelper.webView()->minimumPageScaleFactor() * |
3413 doubleTapZoomAlreadyLegibleRatio; | 3436 doubleTapZoomAlreadyLegibleRatio; |
3414 setScaleAndScrollAndLayout( | 3437 setScaleAndScrollAndLayout( |
3415 webViewHelper.webView(), WebPoint(0, 0), | 3438 webViewHelper.webView(), WebPoint(0, 0), |
3416 (webViewHelper.webView()->minimumPageScaleFactor()) * | 3439 (webViewHelper.webView()->minimumPageScaleFactor()) * |
3417 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 3440 (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
3418 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); | 3441 simulateDoubleTap(webViewHelper.webView(), doubleTapPoint, scale); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3612 // The edit box is wider than the viewport when legible. | 3635 // The edit box is wider than the viewport when legible. |
3613 viewportWidth = 200; | 3636 viewportWidth = 200; |
3614 viewportHeight = 150; | 3637 viewportHeight = 150; |
3615 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 3638 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
3616 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), | 3639 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), |
3617 initialScale); | 3640 initialScale); |
3618 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( | 3641 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( |
3619 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, | 3642 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, |
3620 scroll, needAnimation); | 3643 scroll, needAnimation); |
3621 EXPECT_TRUE(needAnimation); | 3644 EXPECT_TRUE(needAnimation); |
3622 // The caret should be right aligned since the caret would be offscreen when t
he edit box is left aligned. | 3645 // The caret should be right aligned since the caret would be offscreen when |
| 3646 // the edit box is left aligned. |
3623 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; | 3647 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; |
3624 EXPECT_NEAR(hScroll, scroll.x(), 2); | 3648 EXPECT_NEAR(hScroll, scroll.x(), 2); |
3625 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 3649 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
3626 | 3650 |
3627 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), | 3651 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), |
3628 initialScale); | 3652 initialScale); |
3629 // Move focus to edit box with text. | 3653 // Move focus to edit box with text. |
3630 webViewHelper.webView()->advanceFocus(false); | 3654 webViewHelper.webView()->advanceFocus(false); |
3631 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( | 3655 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( |
3632 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, | 3656 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, |
(...skipping 11 matching lines...) Expand all Loading... |
3644 webViewHelper.webView()->advanceFocus(true); | 3668 webViewHelper.webView()->advanceFocus(true); |
3645 // Zoom out slightly. | 3669 // Zoom out slightly. |
3646 const float withinToleranceScale = scale * 0.9f; | 3670 const float withinToleranceScale = scale * 0.9f; |
3647 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, | 3671 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, |
3648 withinToleranceScale); | 3672 withinToleranceScale); |
3649 // Move focus back to the second edit box. | 3673 // Move focus back to the second edit box. |
3650 webViewHelper.webView()->advanceFocus(false); | 3674 webViewHelper.webView()->advanceFocus(false); |
3651 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( | 3675 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( |
3652 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, | 3676 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, |
3653 scroll, needAnimation); | 3677 scroll, needAnimation); |
3654 // The scale should not be adjusted as the zoomed out scale was sufficiently c
lose to the previously focused scale. | 3678 // The scale should not be adjusted as the zoomed out scale was sufficiently |
| 3679 // close to the previously focused scale. |
3655 EXPECT_FALSE(needAnimation); | 3680 EXPECT_FALSE(needAnimation); |
3656 } | 3681 } |
3657 | 3682 |
3658 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) { | 3683 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) { |
3659 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 3684 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
3660 | 3685 |
3661 const bool autoZoomToLegibleScale = true; | 3686 const bool autoZoomToLegibleScale = true; |
3662 const int viewportWidth = 450; | 3687 const int viewportWidth = 450; |
3663 const int viewportHeight = 300; | 3688 const int viewportHeight = 300; |
3664 const float minReadableCaretHeight = 16.0f; | 3689 const float minReadableCaretHeight = 16.0f; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3714 EXPECT_TRUE(needAnimation); | 3739 EXPECT_TRUE(needAnimation); |
3715 // Horizontal scroll have to be the same | 3740 // Horizontal scroll have to be the same |
3716 EXPECT_NEAR(hScroll, scroll.x(), 1); | 3741 EXPECT_NEAR(hScroll, scroll.x(), 1); |
3717 vScroll = | 3742 vScroll = |
3718 editBoxWithText.y - (viewportHeight / scale - editBoxWithText.height) / 2; | 3743 editBoxWithText.y - (viewportHeight / scale - editBoxWithText.height) / 2; |
3719 EXPECT_NEAR(vScroll, scroll.y(), 1); | 3744 EXPECT_NEAR(vScroll, scroll.y(), 1); |
3720 // Page scale have to be unchanged | 3745 // Page scale have to be unchanged |
3721 EXPECT_EQ(newScale, scale); | 3746 EXPECT_EQ(newScale, scale); |
3722 } | 3747 } |
3723 | 3748 |
3724 // Tests the scroll into view functionality when autoZoomeFocusedNodeToLegibleSc
ale set | 3749 // Tests the scroll into view functionality when |
3725 // to false. i.e. The path non-Android platforms take. | 3750 // autoZoomeFocusedNodeToLegibleScale set to false. i.e. The path non-Android |
| 3751 // platforms take. |
3726 TEST_F(WebFrameTest, DivScrollIntoEditableTestZoomToLegibleScaleDisabled) { | 3752 TEST_F(WebFrameTest, DivScrollIntoEditableTestZoomToLegibleScaleDisabled) { |
3727 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 3753 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
3728 | 3754 |
3729 const bool autoZoomToLegibleScale = false; | 3755 const bool autoZoomToLegibleScale = false; |
3730 int viewportWidth = 100; | 3756 int viewportWidth = 100; |
3731 int viewportHeight = 100; | 3757 int viewportHeight = 100; |
3732 float leftBoxRatio = 0.3f; | 3758 float leftBoxRatio = 0.3f; |
3733 FrameTestHelpers::WebViewHelper webViewHelper; | 3759 FrameTestHelpers::WebViewHelper webViewHelper; |
3734 webViewHelper.initializeAndLoad(m_baseURL + | 3760 webViewHelper.initializeAndLoad(m_baseURL + |
3735 "get_scale_for_zoom_into_editable_test.html"); | 3761 "get_scale_for_zoom_into_editable_test.html"); |
3736 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(false); | 3762 webViewHelper.webView()->page()->settings().setTextAutosizingEnabled(false); |
3737 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 3763 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
3738 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); | 3764 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); |
3739 | 3765 |
3740 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); | 3766 webViewHelper.webView()->enableFakePageScaleAnimationForTesting(true); |
3741 | 3767 |
3742 WebRect editBoxWithText(200, 200, 250, 20); | 3768 WebRect editBoxWithText(200, 200, 250, 20); |
3743 WebRect editBoxWithNoText(200, 250, 250, 20); | 3769 WebRect editBoxWithNoText(200, 250, 250, 20); |
3744 | 3770 |
3745 // Test scrolling the focused node | 3771 // Test scrolling the focused node |
3746 // Since we're zoomed out, the caret is considered too small to be legible and
so we'd | 3772 // Since we're zoomed out, the caret is considered too small to be legible and |
3747 // normally zoom in. Make sure we don't change scale since the auto-zoom setti
ng is off. | 3773 // so we'd normally zoom in. Make sure we don't change scale since the |
| 3774 // auto-zoom setting is off. |
3748 | 3775 |
3749 // Focus the second empty textbox. | 3776 // Focus the second empty textbox. |
3750 webViewHelper.webView()->advanceFocus(false); | 3777 webViewHelper.webView()->advanceFocus(false); |
3751 webViewHelper.webView()->advanceFocus(false); | 3778 webViewHelper.webView()->advanceFocus(false); |
3752 | 3779 |
3753 // Set the page scale to be smaller than the minimal readable scale. | 3780 // Set the page scale to be smaller than the minimal readable scale. |
3754 float initialScale = 0.25f; | 3781 float initialScale = 0.25f; |
3755 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), | 3782 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), |
3756 initialScale); | 3783 initialScale); |
3757 | 3784 |
(...skipping 17 matching lines...) Expand all Loading... |
3775 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, scale); | 3802 setScaleAndScrollAndLayout(webViewHelper.webView(), scroll, scale); |
3776 | 3803 |
3777 // Select the first textbox. | 3804 // Select the first textbox. |
3778 webViewHelper.webView()->advanceFocus(true); | 3805 webViewHelper.webView()->advanceFocus(true); |
3779 WebRect rect, caret; | 3806 WebRect rect, caret; |
3780 webViewHelper.webView()->selectionBounds(caret, rect); | 3807 webViewHelper.webView()->selectionBounds(caret, rect); |
3781 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( | 3808 webViewHelper.webView()->computeScaleAndScrollForFocusedNode( |
3782 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, | 3809 webViewHelper.webView()->focusedElement(), autoZoomToLegibleScale, scale, |
3783 scroll, needAnimation); | 3810 scroll, needAnimation); |
3784 | 3811 |
3785 // There should be no change at all since the textbox is fully visible already
. | 3812 // There should be no change at all since the textbox is fully visible |
| 3813 // already. |
3786 EXPECT_EQ(initialScale, scale); | 3814 EXPECT_EQ(initialScale, scale); |
3787 EXPECT_FALSE(needAnimation); | 3815 EXPECT_FALSE(needAnimation); |
3788 } | 3816 } |
3789 | 3817 |
3790 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) { | 3818 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) { |
3791 registerMockedHttpURLLoad("sometext.html"); | 3819 registerMockedHttpURLLoad("sometext.html"); |
3792 | 3820 |
3793 FrameTestHelpers::WebViewHelper webViewHelper; | 3821 FrameTestHelpers::WebViewHelper webViewHelper; |
3794 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); | 3822 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); |
3795 webViewHelper.resize(WebSize(640, 480)); | 3823 webViewHelper.resize(WebSize(640, 480)); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3921 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 3949 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
3922 toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); | 3950 toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); |
3923 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 3951 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
3924 webViewHelper.webView()->mainFrame()); | 3952 webViewHelper.webView()->mainFrame()); |
3925 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().width); | 3953 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().width); |
3926 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().height); | 3954 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->scrollOffset().height); |
3927 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 3955 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
3928 } | 3956 } |
3929 | 3957 |
3930 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) { | 3958 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) { |
3931 // Test that reloading while the previous load is still pending does not cause
the initial | 3959 // Test that reloading while the previous load is still pending does not cause |
3932 // request to get lost. | 3960 // the initial request to get lost. |
3933 registerMockedHttpURLLoad("fixed_layout.html"); | 3961 registerMockedHttpURLLoad("fixed_layout.html"); |
3934 | 3962 |
3935 FrameTestHelpers::WebViewHelper webViewHelper; | 3963 FrameTestHelpers::WebViewHelper webViewHelper; |
3936 webViewHelper.initialize(); | 3964 webViewHelper.initialize(); |
3937 WebURLRequest request; | 3965 WebURLRequest request; |
3938 request.setURL(toKURL(m_baseURL + "fixed_layout.html")); | 3966 request.setURL(toKURL(m_baseURL + "fixed_layout.html")); |
3939 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 3967 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
3940 webViewHelper.webView()->mainFrame()->loadRequest(request); | 3968 webViewHelper.webView()->mainFrame()->loadRequest(request); |
3941 // start reload before first request is delivered. | 3969 // start reload before first request is delivered. |
3942 FrameTestHelpers::reloadFrameIgnoringCache( | 3970 FrameTestHelpers::reloadFrameIgnoringCache( |
(...skipping 24 matching lines...) Expand all Loading... |
3967 EXPECT_EQ(toKURL(firstURL), KURL(redirects[0])); | 3995 EXPECT_EQ(toKURL(firstURL), KURL(redirects[0])); |
3968 EXPECT_EQ(toKURL(secondURL), KURL(redirects[1])); | 3996 EXPECT_EQ(toKURL(secondURL), KURL(redirects[1])); |
3969 } | 3997 } |
3970 | 3998 |
3971 TEST_P(ParameterizedWebFrameTest, IframeRedirect) { | 3999 TEST_P(ParameterizedWebFrameTest, IframeRedirect) { |
3972 registerMockedHttpURLLoad("iframe_redirect.html"); | 4000 registerMockedHttpURLLoad("iframe_redirect.html"); |
3973 registerMockedHttpURLLoad("visible_iframe.html"); | 4001 registerMockedHttpURLLoad("visible_iframe.html"); |
3974 | 4002 |
3975 FrameTestHelpers::WebViewHelper webViewHelper; | 4003 FrameTestHelpers::WebViewHelper webViewHelper; |
3976 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); | 4004 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); |
3977 // Pump pending requests one more time. The test page loads script that naviga
tes. | 4005 // Pump pending requests one more time. The test page loads script that |
| 4006 // navigates. |
3978 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4007 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
3979 webViewHelper.webView()->mainFrame()); | 4008 webViewHelper.webView()->mainFrame()); |
3980 | 4009 |
3981 WebFrame* iframe = webViewHelper.webView()->findFrameByName( | 4010 WebFrame* iframe = webViewHelper.webView()->findFrameByName( |
3982 WebString::fromUTF8("ifr"), nullptr); | 4011 WebString::fromUTF8("ifr"), nullptr); |
3983 ASSERT_TRUE(iframe); | 4012 ASSERT_TRUE(iframe); |
3984 WebDataSource* iframeDataSource = iframe->dataSource(); | 4013 WebDataSource* iframeDataSource = iframe->dataSource(); |
3985 ASSERT_TRUE(iframeDataSource); | 4014 ASSERT_TRUE(iframeDataSource); |
3986 WebVector<WebURL> redirects; | 4015 WebVector<WebURL> redirects; |
3987 iframeDataSource->redirectChain(redirects); | 4016 iframeDataSource->redirectChain(redirects); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4058 wrapUnique(new Notification(frame, context, worldId))); | 4087 wrapUnique(new Notification(frame, context, worldId))); |
4059 } | 4088 } |
4060 }; | 4089 }; |
4061 | 4090 |
4062 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload) { | 4091 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload) { |
4063 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 4092 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
4064 | 4093 |
4065 registerMockedHttpURLLoad("context_notifications_test.html"); | 4094 registerMockedHttpURLLoad("context_notifications_test.html"); |
4066 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 4095 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
4067 | 4096 |
4068 // Load a frame with an iframe, make sure we get the right create notification
s. | 4097 // Load a frame with an iframe, make sure we get the right create |
| 4098 // notifications. |
4069 ContextLifetimeTestWebFrameClient webFrameClient; | 4099 ContextLifetimeTestWebFrameClient webFrameClient; |
4070 FrameTestHelpers::WebViewHelper webViewHelper; | 4100 FrameTestHelpers::WebViewHelper webViewHelper; |
4071 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", | 4101 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", |
4072 true, &webFrameClient); | 4102 true, &webFrameClient); |
4073 | 4103 |
4074 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 4104 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
4075 WebFrame* childFrame = mainFrame->firstChild(); | 4105 WebFrame* childFrame = mainFrame->firstChild(); |
4076 | 4106 |
4077 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); | 4107 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); |
4078 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); | 4108 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); |
4079 | 4109 |
4080 auto& firstCreateNotification = webFrameClient.createNotifications[0]; | 4110 auto& firstCreateNotification = webFrameClient.createNotifications[0]; |
4081 auto& secondCreateNotification = webFrameClient.createNotifications[1]; | 4111 auto& secondCreateNotification = webFrameClient.createNotifications[1]; |
4082 | 4112 |
4083 EXPECT_EQ(mainFrame, firstCreateNotification->frame); | 4113 EXPECT_EQ(mainFrame, firstCreateNotification->frame); |
4084 EXPECT_EQ(mainFrame->mainWorldScriptContext(), | 4114 EXPECT_EQ(mainFrame->mainWorldScriptContext(), |
4085 firstCreateNotification->context); | 4115 firstCreateNotification->context); |
4086 EXPECT_EQ(0, firstCreateNotification->worldId); | 4116 EXPECT_EQ(0, firstCreateNotification->worldId); |
4087 | 4117 |
4088 EXPECT_EQ(childFrame, secondCreateNotification->frame); | 4118 EXPECT_EQ(childFrame, secondCreateNotification->frame); |
4089 EXPECT_EQ(childFrame->mainWorldScriptContext(), | 4119 EXPECT_EQ(childFrame->mainWorldScriptContext(), |
4090 secondCreateNotification->context); | 4120 secondCreateNotification->context); |
4091 EXPECT_EQ(0, secondCreateNotification->worldId); | 4121 EXPECT_EQ(0, secondCreateNotification->worldId); |
4092 | 4122 |
4093 // Close the view. We should get two release notifications that are exactly th
e same as the create ones, in reverse order. | 4123 // Close the view. We should get two release notifications that are exactly |
| 4124 // the same as the create ones, in reverse order. |
4094 webViewHelper.reset(); | 4125 webViewHelper.reset(); |
4095 | 4126 |
4096 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 4127 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
4097 auto& firstReleaseNotification = webFrameClient.releaseNotifications[0]; | 4128 auto& firstReleaseNotification = webFrameClient.releaseNotifications[0]; |
4098 auto& secondReleaseNotification = webFrameClient.releaseNotifications[1]; | 4129 auto& secondReleaseNotification = webFrameClient.releaseNotifications[1]; |
4099 | 4130 |
4100 ASSERT_TRUE(firstCreateNotification->Equals(secondReleaseNotification.get())); | 4131 ASSERT_TRUE(firstCreateNotification->Equals(secondReleaseNotification.get())); |
4101 ASSERT_TRUE(secondCreateNotification->Equals(firstReleaseNotification.get())); | 4132 ASSERT_TRUE(secondCreateNotification->Equals(firstReleaseNotification.get())); |
4102 } | 4133 } |
4103 | 4134 |
4104 TEST_P(ParameterizedWebFrameTest, ContextNotificationsReload) { | 4135 TEST_P(ParameterizedWebFrameTest, ContextNotificationsReload) { |
4105 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 4136 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
4106 | 4137 |
4107 registerMockedHttpURLLoad("context_notifications_test.html"); | 4138 registerMockedHttpURLLoad("context_notifications_test.html"); |
4108 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 4139 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
4109 | 4140 |
4110 ContextLifetimeTestWebFrameClient webFrameClient; | 4141 ContextLifetimeTestWebFrameClient webFrameClient; |
4111 FrameTestHelpers::WebViewHelper webViewHelper; | 4142 FrameTestHelpers::WebViewHelper webViewHelper; |
4112 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", | 4143 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", |
4113 true, &webFrameClient); | 4144 true, &webFrameClient); |
4114 | 4145 |
4115 // Refresh, we should get two release notifications and two more create notifi
cations. | 4146 // Refresh, we should get two release notifications and two more create |
| 4147 // notifications. |
4116 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); | 4148 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
4117 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); | 4149 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); |
4118 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 4150 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
4119 | 4151 |
4120 // The two release notifications we got should be exactly the same as the firs
t two create notifications. | 4152 // The two release notifications we got should be exactly the same as the |
| 4153 // first two create notifications. |
4121 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 4154 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
4122 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( | 4155 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( |
4123 webFrameClient | 4156 webFrameClient |
4124 .createNotifications[webFrameClient.createNotifications.size() - 3 - | 4157 .createNotifications[webFrameClient.createNotifications.size() - 3 - |
4125 i] | 4158 i] |
4126 .get())); | 4159 .get())); |
4127 } | 4160 } |
4128 | 4161 |
4129 // The last two create notifications should be for the current frames and cont
ext. | 4162 // The last two create notifications should be for the current frames and |
| 4163 // context. |
4130 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 4164 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
4131 WebFrame* childFrame = mainFrame->firstChild(); | 4165 WebFrame* childFrame = mainFrame->firstChild(); |
4132 auto& firstRefreshNotification = webFrameClient.createNotifications[2]; | 4166 auto& firstRefreshNotification = webFrameClient.createNotifications[2]; |
4133 auto& secondRefreshNotification = webFrameClient.createNotifications[3]; | 4167 auto& secondRefreshNotification = webFrameClient.createNotifications[3]; |
4134 | 4168 |
4135 EXPECT_EQ(mainFrame, firstRefreshNotification->frame); | 4169 EXPECT_EQ(mainFrame, firstRefreshNotification->frame); |
4136 EXPECT_EQ(mainFrame->mainWorldScriptContext(), | 4170 EXPECT_EQ(mainFrame->mainWorldScriptContext(), |
4137 firstRefreshNotification->context); | 4171 firstRefreshNotification->context); |
4138 EXPECT_EQ(0, firstRefreshNotification->worldId); | 4172 EXPECT_EQ(0, firstRefreshNotification->worldId); |
4139 | 4173 |
(...skipping 24 matching lines...) Expand all Loading... |
4164 int extensionGroup = 0; | 4198 int extensionGroup = 0; |
4165 webViewHelper.webView()->mainFrame()->executeScriptInIsolatedWorld( | 4199 webViewHelper.webView()->mainFrame()->executeScriptInIsolatedWorld( |
4166 isolatedWorldId, &scriptSource, numSources, extensionGroup); | 4200 isolatedWorldId, &scriptSource, numSources, extensionGroup); |
4167 | 4201 |
4168 // We should now have a new create notification. | 4202 // We should now have a new create notification. |
4169 ASSERT_EQ(1u, webFrameClient.createNotifications.size()); | 4203 ASSERT_EQ(1u, webFrameClient.createNotifications.size()); |
4170 auto& notification = webFrameClient.createNotifications[0]; | 4204 auto& notification = webFrameClient.createNotifications[0]; |
4171 ASSERT_EQ(isolatedWorldId, notification->worldId); | 4205 ASSERT_EQ(isolatedWorldId, notification->worldId); |
4172 ASSERT_EQ(webViewHelper.webView()->mainFrame(), notification->frame); | 4206 ASSERT_EQ(webViewHelper.webView()->mainFrame(), notification->frame); |
4173 | 4207 |
4174 // We don't have an API to enumarate isolated worlds for a frame, but we can a
t least assert that the context we got is *not* the main world's context. | 4208 // We don't have an API to enumarate isolated worlds for a frame, but we can |
| 4209 // at least assert that the context we got is *not* the main world's context. |
4175 ASSERT_NE(webViewHelper.webView()->mainFrame()->mainWorldScriptContext(), | 4210 ASSERT_NE(webViewHelper.webView()->mainFrame()->mainWorldScriptContext(), |
4176 v8::Local<v8::Context>::New(isolate, notification->context)); | 4211 v8::Local<v8::Context>::New(isolate, notification->context)); |
4177 | 4212 |
4178 webViewHelper.reset(); | 4213 webViewHelper.reset(); |
4179 | 4214 |
4180 // We should have gotten three release notifications (one for each of the fram
es, plus one for the isolated context). | 4215 // We should have gotten three release notifications (one for each of the |
| 4216 // frames, plus one for the isolated context). |
4181 ASSERT_EQ(3u, webFrameClient.releaseNotifications.size()); | 4217 ASSERT_EQ(3u, webFrameClient.releaseNotifications.size()); |
4182 | 4218 |
4183 // And one of them should be exactly the same as the create notification for t
he isolated context. | 4219 // And one of them should be exactly the same as the create notification for |
| 4220 // the isolated context. |
4184 int matchCount = 0; | 4221 int matchCount = 0; |
4185 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 4222 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
4186 if (webFrameClient.releaseNotifications[i]->Equals( | 4223 if (webFrameClient.releaseNotifications[i]->Equals( |
4187 webFrameClient.createNotifications[0].get())) | 4224 webFrameClient.createNotifications[0].get())) |
4188 ++matchCount; | 4225 ++matchCount; |
4189 } | 4226 } |
4190 EXPECT_EQ(1, matchCount); | 4227 EXPECT_EQ(1, matchCount); |
4191 } | 4228 } |
4192 | 4229 |
4193 TEST_P(ParameterizedWebFrameTest, FindInPage) { | 4230 TEST_P(ParameterizedWebFrameTest, FindInPage) { |
(...skipping 10 matching lines...) Expand all Loading... |
4204 frame->find(findIdentifier, WebString::fromUTF8("bar1"), options, false)); | 4241 frame->find(findIdentifier, WebString::fromUTF8("bar1"), options, false)); |
4205 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 4242 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
4206 WebRange range = frame->selectionRange(); | 4243 WebRange range = frame->selectionRange(); |
4207 EXPECT_EQ(5, range.startOffset()); | 4244 EXPECT_EQ(5, range.startOffset()); |
4208 EXPECT_EQ(9, range.endOffset()); | 4245 EXPECT_EQ(9, range.endOffset()); |
4209 EXPECT_TRUE(frame->document().focusedElement().isNull()); | 4246 EXPECT_TRUE(frame->document().focusedElement().isNull()); |
4210 | 4247 |
4211 // Find in an <input> value. | 4248 // Find in an <input> value. |
4212 EXPECT_TRUE( | 4249 EXPECT_TRUE( |
4213 frame->find(findIdentifier, WebString::fromUTF8("bar2"), options, false)); | 4250 frame->find(findIdentifier, WebString::fromUTF8("bar2"), options, false)); |
4214 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the se
lection on the found text. | 4251 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the |
| 4252 // selection on the found text. |
4215 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 4253 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
4216 range = frame->selectionRange(); | 4254 range = frame->selectionRange(); |
4217 ASSERT_FALSE(range.isNull()); | 4255 ASSERT_FALSE(range.isNull()); |
4218 EXPECT_EQ(5, range.startOffset()); | 4256 EXPECT_EQ(5, range.startOffset()); |
4219 EXPECT_EQ(9, range.endOffset()); | 4257 EXPECT_EQ(9, range.endOffset()); |
4220 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("input")); | 4258 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("input")); |
4221 | 4259 |
4222 // Find in a <textarea> content. | 4260 // Find in a <textarea> content. |
4223 EXPECT_TRUE( | 4261 EXPECT_TRUE( |
4224 frame->find(findIdentifier, WebString::fromUTF8("bar3"), options, false)); | 4262 frame->find(findIdentifier, WebString::fromUTF8("bar3"), options, false)); |
4225 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the se
lection on the found text. | 4263 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the |
| 4264 // selection on the found text. |
4226 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 4265 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
4227 range = frame->selectionRange(); | 4266 range = frame->selectionRange(); |
4228 ASSERT_FALSE(range.isNull()); | 4267 ASSERT_FALSE(range.isNull()); |
4229 EXPECT_EQ(5, range.startOffset()); | 4268 EXPECT_EQ(5, range.startOffset()); |
4230 EXPECT_EQ(9, range.endOffset()); | 4269 EXPECT_EQ(9, range.endOffset()); |
4231 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("textarea")); | 4270 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("textarea")); |
4232 | 4271 |
4233 // Find in a contentEditable element. | 4272 // Find in a contentEditable element. |
4234 EXPECT_TRUE( | 4273 EXPECT_TRUE( |
4235 frame->find(findIdentifier, WebString::fromUTF8("bar4"), options, false)); | 4274 frame->find(findIdentifier, WebString::fromUTF8("bar4"), options, false)); |
4236 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the se
lection on the found text. | 4275 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the |
| 4276 // selection on the found text. |
4237 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 4277 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
4238 range = frame->selectionRange(); | 4278 range = frame->selectionRange(); |
4239 ASSERT_FALSE(range.isNull()); | 4279 ASSERT_FALSE(range.isNull()); |
4240 EXPECT_EQ(0, range.startOffset()); | 4280 EXPECT_EQ(0, range.startOffset()); |
4241 EXPECT_EQ(4, range.endOffset()); | 4281 EXPECT_EQ(4, range.endOffset()); |
4242 // "bar4" is surrounded by <span>, but the focusable node should be the parent
<div>. | 4282 // "bar4" is surrounded by <span>, but the focusable node should be the parent |
| 4283 // <div>. |
4243 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("div")); | 4284 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("div")); |
4244 | 4285 |
4245 // Find in <select> content. | 4286 // Find in <select> content. |
4246 EXPECT_FALSE( | 4287 EXPECT_FALSE( |
4247 frame->find(findIdentifier, WebString::fromUTF8("bar5"), options, false)); | 4288 frame->find(findIdentifier, WebString::fromUTF8("bar5"), options, false)); |
4248 // If there are any matches, stopFinding will set the selection on the found t
ext. | 4289 // If there are any matches, stopFinding will set the selection on the found |
4249 // However, we do not expect any matches, so check that the selection is null. | 4290 // text. However, we do not expect any matches, so check that the selection |
| 4291 // is null. |
4250 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); | 4292 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
4251 range = frame->selectionRange(); | 4293 range = frame->selectionRange(); |
4252 ASSERT_TRUE(range.isNull()); | 4294 ASSERT_TRUE(range.isNull()); |
4253 } | 4295 } |
4254 | 4296 |
4255 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) { | 4297 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) { |
4256 FrameTestHelpers::WebViewHelper webViewHelper; | 4298 FrameTestHelpers::WebViewHelper webViewHelper; |
4257 webViewHelper.initializeAndLoad("about:blank", true); | 4299 webViewHelper.initializeAndLoad("about:blank", true); |
4258 // We set the size because it impacts line wrapping, which changes the | 4300 // We set the size because it impacts line wrapping, which changes the |
4259 // resulting text value. | 4301 // resulting text value. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4426 EXPECT_EQ(mainFrame->selectNearestFindMatch(resultRect.center(), 0), | 4468 EXPECT_EQ(mainFrame->selectNearestFindMatch(resultRect.center(), 0), |
4427 resultIndex + 1); | 4469 resultIndex + 1); |
4428 | 4470 |
4429 // Check that the find result ordering matches with our expectations. | 4471 // Check that the find result ordering matches with our expectations. |
4430 Range* result = mainFrame->textFinder()->activeMatch(); | 4472 Range* result = mainFrame->textFinder()->activeMatch(); |
4431 ASSERT_TRUE(result); | 4473 ASSERT_TRUE(result); |
4432 result->setEnd(result->endContainer(), result->endOffset() + 3); | 4474 result->setEnd(result->endContainer(), result->endOffset() + 3); |
4433 EXPECT_EQ(result->text(), | 4475 EXPECT_EQ(result->text(), |
4434 String::format("%s %02d", kFindString, resultIndex + 2)); | 4476 String::format("%s %02d", kFindString, resultIndex + 2)); |
4435 | 4477 |
4436 // Verify that the expected match rect also matches the currently active mat
ch. | 4478 // Verify that the expected match rect also matches the currently active |
4437 // Compare the enclosing rects to prevent precision issues caused by CSS tra
nsforms. | 4479 // match. Compare the enclosing rects to prevent precision issues caused by |
| 4480 // CSS transforms. |
4438 FloatRect activeMatch = mainFrame->activeFindMatchRect(); | 4481 FloatRect activeMatch = mainFrame->activeFindMatchRect(); |
4439 EXPECT_EQ(enclosingIntRect(activeMatch), enclosingIntRect(resultRect)); | 4482 EXPECT_EQ(enclosingIntRect(activeMatch), enclosingIntRect(resultRect)); |
4440 | 4483 |
4441 // The rects version should not have changed. | 4484 // The rects version should not have changed. |
4442 EXPECT_EQ(mainFrame->findMatchMarkersVersion(), rectsVersion); | 4485 EXPECT_EQ(mainFrame->findMatchMarkersVersion(), rectsVersion); |
4443 } | 4486 } |
4444 | 4487 |
4445 // Resizing should update the rects version. | 4488 // Resizing should update the rects version. |
4446 webViewHelper.resize(WebSize(800, 600)); | 4489 webViewHelper.resize(WebSize(800, 600)); |
4447 runPendingTasks(); | 4490 runPendingTasks(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4606 runPendingTasks(); | 4649 runPendingTasks(); |
4607 EXPECT_FALSE(client.findResultsAreReady()); | 4650 EXPECT_FALSE(client.findResultsAreReady()); |
4608 | 4651 |
4609 mainFrame->ensureTextFinder().resetMatchCount(); | 4652 mainFrame->ensureTextFinder().resetMatchCount(); |
4610 | 4653 |
4611 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4654 for (WebLocalFrameImpl* frame = mainFrame; frame; |
4612 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext(false))) | 4655 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext(false))) |
4613 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4656 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, |
4614 options, true); | 4657 options, true); |
4615 | 4658 |
4616 // The first scopeStringMatches will have reset the state. Detach before it ac
tually scopes. | 4659 // The first scopeStringMatches will have reset the state. Detach before it |
| 4660 // actually scopes. |
4617 removeElementById(mainFrame, "frame"); | 4661 removeElementById(mainFrame, "frame"); |
4618 | 4662 |
4619 runPendingTasks(); | 4663 runPendingTasks(); |
4620 EXPECT_TRUE(client.findResultsAreReady()); | 4664 EXPECT_TRUE(client.findResultsAreReady()); |
4621 } | 4665 } |
4622 | 4666 |
4623 TEST_P(ParameterizedWebFrameTest, ResetMatchCount) { | 4667 TEST_P(ParameterizedWebFrameTest, ResetMatchCount) { |
4624 registerMockedHttpURLLoad("find_in_generated_frame.html"); | 4668 registerMockedHttpURLLoad("find_in_generated_frame.html"); |
4625 | 4669 |
4626 FindUpdateWebFrameClient client; | 4670 FindUpdateWebFrameClient client; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4783 | 4827 |
4784 FrameTestHelpers::WebViewHelper webViewHelper; | 4828 FrameTestHelpers::WebViewHelper webViewHelper; |
4785 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", | 4829 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", |
4786 &webViewHelper); | 4830 &webViewHelper); |
4787 frame = webViewHelper.webView()->mainFrameImpl(); | 4831 frame = webViewHelper.webView()->mainFrameImpl(); |
4788 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); | 4832 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); |
4789 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4833 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4790 frame->executeCommand(WebString::fromUTF8("Unselect")); | 4834 frame->executeCommand(WebString::fromUTF8("Unselect")); |
4791 EXPECT_EQ("", selectionAsString(frame)); | 4835 EXPECT_EQ("", selectionAsString(frame)); |
4792 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 4836 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
4793 // On some devices, the above bottomRightMinusOne() causes the ending '.' not
selected. | 4837 // On some devices, the above bottomRightMinusOne() causes the ending '.' not |
| 4838 // selected. |
4794 std::string selectionString = selectionAsString(frame); | 4839 std::string selectionString = selectionAsString(frame); |
4795 EXPECT_TRUE(selectionString == "Some test text for testing." || | 4840 EXPECT_TRUE(selectionString == "Some test text for testing." || |
4796 selectionString == "Some test text for testing"); | 4841 selectionString == "Some test text for testing"); |
4797 | 4842 |
4798 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", | 4843 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", |
4799 &webViewHelper); | 4844 &webViewHelper); |
4800 frame = webViewHelper.webView()->mainFrameImpl(); | 4845 frame = webViewHelper.webView()->mainFrameImpl(); |
4801 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)); | 4846 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)); |
4802 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4847 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4803 frame->executeCommand(WebString::fromUTF8("Unselect")); | 4848 frame->executeCommand(WebString::fromUTF8("Unselect")); |
4804 EXPECT_EQ("", selectionAsString(frame)); | 4849 EXPECT_EQ("", selectionAsString(frame)); |
4805 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 4850 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
4806 // On some devices, the above bottomRightMinusOne() causes the ending '.' not
selected. | 4851 // On some devices, the above bottomRightMinusOne() causes the ending '.' not |
| 4852 // selected. |
4807 selectionString = selectionAsString(frame); | 4853 selectionString = selectionAsString(frame); |
4808 EXPECT_TRUE(selectionString == "Some offscreen test text for testing." || | 4854 EXPECT_TRUE(selectionString == "Some offscreen test text for testing." || |
4809 selectionString == "Some offscreen test text for testing"); | 4855 selectionString == "Some offscreen test text for testing"); |
4810 } | 4856 } |
4811 | 4857 |
4812 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) { | 4858 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) { |
4813 WebFrame* frame; | 4859 WebFrame* frame; |
4814 WebRect startWebRect; | 4860 WebRect startWebRect; |
4815 WebRect endWebRect; | 4861 WebRect endWebRect; |
4816 | 4862 |
4817 registerMockedHttpURLLoad("select_range_iframe.html"); | 4863 registerMockedHttpURLLoad("select_range_iframe.html"); |
4818 registerMockedHttpURLLoad("select_range_basic.html"); | 4864 registerMockedHttpURLLoad("select_range_basic.html"); |
4819 | 4865 |
4820 FrameTestHelpers::WebViewHelper webViewHelper; | 4866 FrameTestHelpers::WebViewHelper webViewHelper; |
4821 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", | 4867 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", |
4822 &webViewHelper); | 4868 &webViewHelper); |
4823 frame = webViewHelper.webView()->mainFrame(); | 4869 frame = webViewHelper.webView()->mainFrame(); |
4824 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame(); | 4870 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame(); |
4825 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); | 4871 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); |
4826 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4872 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4827 subframe->executeCommand(WebString::fromUTF8("Unselect")); | 4873 subframe->executeCommand(WebString::fromUTF8("Unselect")); |
4828 EXPECT_EQ("", selectionAsString(subframe)); | 4874 EXPECT_EQ("", selectionAsString(subframe)); |
4829 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); | 4875 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
4830 // On some devices, the above bottomRightMinusOne() causes the ending '.' not
selected. | 4876 // On some devices, the above bottomRightMinusOne() causes the ending '.' not |
| 4877 // selected. |
4831 std::string selectionString = selectionAsString(subframe); | 4878 std::string selectionString = selectionAsString(subframe); |
4832 EXPECT_TRUE(selectionString == "Some test text for testing." || | 4879 EXPECT_TRUE(selectionString == "Some test text for testing." || |
4833 selectionString == "Some test text for testing"); | 4880 selectionString == "Some test text for testing"); |
4834 } | 4881 } |
4835 | 4882 |
4836 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) { | 4883 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) { |
4837 WebLocalFrame* frame; | 4884 WebLocalFrame* frame; |
4838 WebRect startWebRect; | 4885 WebRect startWebRect; |
4839 WebRect endWebRect; | 4886 WebRect endWebRect; |
4840 | 4887 |
4841 registerMockedHttpURLLoad("select_range_div_editable.html"); | 4888 registerMockedHttpURLLoad("select_range_div_editable.html"); |
4842 | 4889 |
4843 // Select the middle of an editable element, then try to extend the selection
to the top of the document. | 4890 // Select the middle of an editable element, then try to extend the selection |
4844 // The selection range should be clipped to the bounds of the editable element
. | 4891 // to the top of the document. The selection range should be clipped to the |
| 4892 // bounds of the editable element. |
4845 FrameTestHelpers::WebViewHelper webViewHelper; | 4893 FrameTestHelpers::WebViewHelper webViewHelper; |
4846 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", | 4894 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", |
4847 &webViewHelper); | 4895 &webViewHelper); |
4848 frame = webViewHelper.webView()->mainFrameImpl(); | 4896 frame = webViewHelper.webView()->mainFrameImpl(); |
4849 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4897 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4850 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4898 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4851 | 4899 |
4852 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); | 4900 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
4853 EXPECT_EQ("16-char header. This text is initially selected.", | 4901 EXPECT_EQ("16-char header. This text is initially selected.", |
4854 selectionAsString(frame)); | 4902 selectionAsString(frame)); |
(...skipping 16 matching lines...) Expand all Loading... |
4871 | 4919 |
4872 // positionForPoint returns the wrong values for contenteditable spans. See | 4920 // positionForPoint returns the wrong values for contenteditable spans. See |
4873 // http://crbug.com/238334. | 4921 // http://crbug.com/238334. |
4874 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) { | 4922 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) { |
4875 WebLocalFrame* frame; | 4923 WebLocalFrame* frame; |
4876 WebRect startWebRect; | 4924 WebRect startWebRect; |
4877 WebRect endWebRect; | 4925 WebRect endWebRect; |
4878 | 4926 |
4879 registerMockedHttpURLLoad("select_range_span_editable.html"); | 4927 registerMockedHttpURLLoad("select_range_span_editable.html"); |
4880 | 4928 |
4881 // Select the middle of an editable element, then try to extend the selection
to the top of the document. | 4929 // Select the middle of an editable element, then try to extend the selection |
4882 // The selection range should be clipped to the bounds of the editable element
. | 4930 // to the top of the document. |
| 4931 // The selection range should be clipped to the bounds of the editable |
| 4932 // element. |
4883 FrameTestHelpers::WebViewHelper webViewHelper; | 4933 FrameTestHelpers::WebViewHelper webViewHelper; |
4884 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html", | 4934 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html", |
4885 &webViewHelper); | 4935 &webViewHelper); |
4886 frame = webViewHelper.webView()->mainFrameImpl(); | 4936 frame = webViewHelper.webView()->mainFrameImpl(); |
4887 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); | 4937 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
4888 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | 4938 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
4889 | 4939 |
4890 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); | 4940 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
4891 EXPECT_EQ("16-char header. This text is initially selected.", | 4941 EXPECT_EQ("16-char header. This text is initially selected.", |
4892 selectionAsString(frame)); | 4942 selectionAsString(frame)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4946 EXPECT_EQ(" [ Footer 1. Footer 2.", selectionAsString(frame)); | 4996 EXPECT_EQ(" [ Footer 1. Footer 2.", selectionAsString(frame)); |
4947 | 4997 |
4948 // Can extend the selection completely across editable elements. | 4998 // Can extend the selection completely across editable elements. |
4949 frame->executeScript(WebScriptSource("selectElement('footer_2');")); | 4999 frame->executeScript(WebScriptSource("selectElement('footer_2');")); |
4950 EXPECT_EQ("Footer 2.", selectionAsString(frame)); | 5000 EXPECT_EQ("Footer 2.", selectionAsString(frame)); |
4951 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "footer_2")), | 5001 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "footer_2")), |
4952 topLeft(elementBounds(frame, "header_2"))); | 5002 topLeft(elementBounds(frame, "header_2"))); |
4953 EXPECT_EQ("Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1. Footer 2.", | 5003 EXPECT_EQ("Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1. Footer 2.", |
4954 selectionAsString(frame)); | 5004 selectionAsString(frame)); |
4955 | 5005 |
4956 // If the selection is editable text, we can't extend it into non-editable tex
t. | 5006 // If the selection is editable text, we can't extend it into non-editable |
| 5007 // text. |
4957 frame->executeScript(WebScriptSource("selectElement('editable_2');")); | 5008 frame->executeScript(WebScriptSource("selectElement('editable_2');")); |
4958 EXPECT_EQ("Editable 2.", selectionAsString(frame)); | 5009 EXPECT_EQ("Editable 2.", selectionAsString(frame)); |
4959 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")), | 5010 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")), |
4960 topLeft(elementBounds(frame, "header_2"))); | 5011 topLeft(elementBounds(frame, "header_2"))); |
4961 // positionForPoint returns the wrong values for contenteditable spans. See | 5012 // positionForPoint returns the wrong values for contenteditable spans. See |
4962 // http://crbug.com/238334. | 5013 // http://crbug.com/238334. |
4963 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); | 5014 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); |
4964 } | 5015 } |
4965 | 5016 |
4966 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) { | 5017 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5001 EXPECT_EQ("Header 1. Header 2. ] ", selectionAsString(frame)); | 5052 EXPECT_EQ("Header 1. Header 2. ] ", selectionAsString(frame)); |
5002 | 5053 |
5003 // Can extend the selection completely across editable elements. | 5054 // Can extend the selection completely across editable elements. |
5004 frame->executeScript(WebScriptSource("selectElement('header_1');")); | 5055 frame->executeScript(WebScriptSource("selectElement('header_1');")); |
5005 EXPECT_EQ("Header 1.", selectionAsString(frame)); | 5056 EXPECT_EQ("Header 1.", selectionAsString(frame)); |
5006 frame->selectRange(topLeft(elementBounds(frame, "header_1")), | 5057 frame->selectRange(topLeft(elementBounds(frame, "header_1")), |
5007 bottomRightMinusOne(elementBounds(frame, "footer_1"))); | 5058 bottomRightMinusOne(elementBounds(frame, "footer_1"))); |
5008 EXPECT_EQ("Header 1. Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1.", | 5059 EXPECT_EQ("Header 1. Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1.", |
5009 selectionAsString(frame)); | 5060 selectionAsString(frame)); |
5010 | 5061 |
5011 // If the selection is editable text, we can't extend it into non-editable tex
t. | 5062 // If the selection is editable text, we can't extend it into non-editable |
| 5063 // text. |
5012 frame->executeScript(WebScriptSource("selectElement('editable_1');")); | 5064 frame->executeScript(WebScriptSource("selectElement('editable_1');")); |
5013 EXPECT_EQ("Editable 1.", selectionAsString(frame)); | 5065 EXPECT_EQ("Editable 1.", selectionAsString(frame)); |
5014 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), | 5066 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), |
5015 bottomRightMinusOne(elementBounds(frame, "footer_1"))); | 5067 bottomRightMinusOne(elementBounds(frame, "footer_1"))); |
5016 // positionForPoint returns the wrong values for contenteditable spans. See | 5068 // positionForPoint returns the wrong values for contenteditable spans. See |
5017 // http://crbug.com/238334. | 5069 // http://crbug.com/238334. |
5018 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); | 5070 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); |
5019 } | 5071 } |
5020 | 5072 |
5021 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) { | 5073 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) { |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5582 client.resetTriggered(); | 5634 client.resetTriggered(); |
5583 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); | 5635 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); |
5584 | 5636 |
5585 int j = i % 10; | 5637 int j = i % 10; |
5586 if (j >= 7 && j <= 9) | 5638 if (j >= 7 && j <= 9) |
5587 EXPECT_TRUE(client.triggered()); | 5639 EXPECT_TRUE(client.triggered()); |
5588 else | 5640 else |
5589 EXPECT_FALSE(client.triggered()); | 5641 EXPECT_FALSE(client.triggered()); |
5590 } | 5642 } |
5591 | 5643 |
5592 // The same taps shouldn't trigger didTapMultipleTargets() after disabling the
notification for | 5644 // The same taps shouldn't trigger didTapMultipleTargets() after disabling the |
5593 // multi-target-tap. | 5645 // notification for multi-target-tap. |
5594 webViewHelper.webView()->settings()->setMultiTargetTapNotificationEnabled( | 5646 webViewHelper.webView()->settings()->setMultiTargetTapNotificationEnabled( |
5595 false); | 5647 false); |
5596 | 5648 |
5597 for (int i = 0; i <= 46; i++) { | 5649 for (int i = 0; i <= 46; i++) { |
5598 client.resetTriggered(); | 5650 client.resetTriggered(); |
5599 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); | 5651 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); |
5600 EXPECT_FALSE(client.triggered()); | 5652 EXPECT_FALSE(client.triggered()); |
5601 } | 5653 } |
5602 } | 5654 } |
5603 | 5655 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5721 | 5773 |
5722 // Scroll visual viewport to the bottom of the main frame. | 5774 // Scroll visual viewport to the bottom of the main frame. |
5723 visualViewport.setLocation(FloatPoint(0, 200)); | 5775 visualViewport.setLocation(FloatPoint(0, 200)); |
5724 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 200), visualViewport.location()); | 5776 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 200), visualViewport.location()); |
5725 | 5777 |
5726 // Now the tap with the same coordinates should hit two elements. | 5778 // Now the tap with the same coordinates should hit two elements. |
5727 client.resetTriggered(); | 5779 client.resetTriggered(); |
5728 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); | 5780 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); |
5729 EXPECT_TRUE(client.triggered()); | 5781 EXPECT_TRUE(client.triggered()); |
5730 | 5782 |
5731 // The same tap shouldn't trigger didTapMultipleTargets() after disabling the
notification for | 5783 // The same tap shouldn't trigger didTapMultipleTargets() after disabling the |
5732 // multi-target-tap. | 5784 // notification for multi-target-tap. |
5733 webViewHelper.webView()->settings()->setMultiTargetTapNotificationEnabled( | 5785 webViewHelper.webView()->settings()->setMultiTargetTapNotificationEnabled( |
5734 false); | 5786 false); |
5735 client.resetTriggered(); | 5787 client.resetTriggered(); |
5736 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); | 5788 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); |
5737 EXPECT_FALSE(client.triggered()); | 5789 EXPECT_FALSE(client.triggered()); |
5738 } | 5790 } |
5739 | 5791 |
5740 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupBlacklist) { | 5792 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupBlacklist) { |
5741 const unsigned viewportWidth = 500; | 5793 const unsigned viewportWidth = 500; |
5742 const unsigned viewportHeight = 1000; | 5794 const unsigned viewportHeight = 1000; |
5743 const unsigned divHeight = 100; | 5795 const unsigned divHeight = 100; |
5744 const std::string htmlFile = "disambiguation_popup_blacklist.html"; | 5796 const std::string htmlFile = "disambiguation_popup_blacklist.html"; |
5745 registerMockedHttpURLLoad(htmlFile); | 5797 registerMockedHttpURLLoad(htmlFile); |
5746 | 5798 |
5747 DisambiguationPopupTestWebViewClient client; | 5799 DisambiguationPopupTestWebViewClient client; |
5748 | 5800 |
5749 // Make sure we initialize to minimum scale, even if the window size | 5801 // Make sure we initialize to minimum scale, even if the window size |
5750 // only becomes available after the load begins. | 5802 // only becomes available after the load begins. |
5751 FrameTestHelpers::WebViewHelper webViewHelper; | 5803 FrameTestHelpers::WebViewHelper webViewHelper; |
5752 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); | 5804 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client); |
5753 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 5805 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
5754 | 5806 |
5755 // Click somewhere where the popup shouldn't appear. | 5807 // Click somewhere where the popup shouldn't appear. |
5756 client.resetTriggered(); | 5808 client.resetTriggered(); |
5757 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, 0)); | 5809 webViewHelper.webView()->handleInputEvent(fatTap(viewportWidth / 2, 0)); |
5758 EXPECT_FALSE(client.triggered()); | 5810 EXPECT_FALSE(client.triggered()); |
5759 | 5811 |
5760 // Click directly in between two container divs with click handlers, with chil
dren that don't handle clicks. | 5812 // Click directly in between two container divs with click handlers, with |
| 5813 // children that don't handle clicks. |
5761 client.resetTriggered(); | 5814 client.resetTriggered(); |
5762 webViewHelper.webView()->handleInputEvent( | 5815 webViewHelper.webView()->handleInputEvent( |
5763 fatTap(viewportWidth / 2, divHeight)); | 5816 fatTap(viewportWidth / 2, divHeight)); |
5764 EXPECT_TRUE(client.triggered()); | 5817 EXPECT_TRUE(client.triggered()); |
5765 | 5818 |
5766 // The third div container should be blacklisted if you click on the link it c
ontains. | 5819 // The third div container should be blacklisted if you click on the link it |
| 5820 // contains. |
5767 client.resetTriggered(); | 5821 client.resetTriggered(); |
5768 webViewHelper.webView()->handleInputEvent( | 5822 webViewHelper.webView()->handleInputEvent( |
5769 fatTap(viewportWidth / 2, divHeight * 3.25)); | 5823 fatTap(viewportWidth / 2, divHeight * 3.25)); |
5770 EXPECT_FALSE(client.triggered()); | 5824 EXPECT_FALSE(client.triggered()); |
5771 } | 5825 } |
5772 | 5826 |
5773 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupPageScale) { | 5827 TEST_P(ParameterizedWebFrameTest, DisambiguationPopupPageScale) { |
5774 registerMockedHttpURLLoad("disambiguation_popup_page_scale.html"); | 5828 registerMockedHttpURLLoad("disambiguation_popup_page_scale.html"); |
5775 | 5829 |
5776 DisambiguationPopupTestWebViewClient client; | 5830 DisambiguationPopupTestWebViewClient client; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5829 bool m_commitCalled; | 5883 bool m_commitCalled; |
5830 }; | 5884 }; |
5831 | 5885 |
5832 TEST_P(ParameterizedWebFrameTest, ReplaceNavigationAfterHistoryNavigation) { | 5886 TEST_P(ParameterizedWebFrameTest, ReplaceNavigationAfterHistoryNavigation) { |
5833 TestSubstituteDataWebFrameClient webFrameClient; | 5887 TestSubstituteDataWebFrameClient webFrameClient; |
5834 | 5888 |
5835 FrameTestHelpers::WebViewHelper webViewHelper; | 5889 FrameTestHelpers::WebViewHelper webViewHelper; |
5836 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); | 5890 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); |
5837 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5891 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5838 | 5892 |
5839 // Load a url as a history navigation that will return an error. TestSubstitut
eDataWebFrameClient | 5893 // Load a url as a history navigation that will return an error. |
5840 // will start a SubstituteData load in response to the load failure, which sho
uld get fully committed. | 5894 // TestSubstituteDataWebFrameClient will start a SubstituteData load in |
5841 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRecei
veData() wasn't getting | 5895 // response to the load failure, which should get fully committed. Due to |
5842 // called in this case, which resulted in the SubstituteData document not gett
ing displayed. | 5896 // https://bugs.webkit.org/show_bug.cgi?id=91685, |
| 5897 // FrameLoader::didReceiveData() wasn't getting called in this case, which |
| 5898 // resulted in the SubstituteData document not getting displayed. |
5843 WebURLError error; | 5899 WebURLError error; |
5844 error.reason = 1337; | 5900 error.reason = 1337; |
5845 error.domain = "WebFrameTest"; | 5901 error.domain = "WebFrameTest"; |
5846 std::string errorURL = "http://0.0.0.0"; | 5902 std::string errorURL = "http://0.0.0.0"; |
5847 WebURLResponse response; | 5903 WebURLResponse response; |
5848 response.setURL(URLTestHelpers::toKURL(errorURL)); | 5904 response.setURL(URLTestHelpers::toKURL(errorURL)); |
5849 response.setMIMEType("text/html"); | 5905 response.setMIMEType("text/html"); |
5850 response.setHTTPStatusCode(500); | 5906 response.setHTTPStatusCode(500); |
5851 WebHistoryItem errorHistoryItem; | 5907 WebHistoryItem errorHistoryItem; |
5852 errorHistoryItem.initialize(); | 5908 errorHistoryItem.initialize(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5898 } | 5954 } |
5899 | 5955 |
5900 TEST_P(ParameterizedWebFrameTest, EmptyDocument) { | 5956 TEST_P(ParameterizedWebFrameTest, EmptyDocument) { |
5901 registerMockedHttpURLLoad("frameserializer/svg/green_rectangle.svg"); | 5957 registerMockedHttpURLLoad("frameserializer/svg/green_rectangle.svg"); |
5902 | 5958 |
5903 TestWillInsertBodyWebFrameClient webFrameClient; | 5959 TestWillInsertBodyWebFrameClient webFrameClient; |
5904 FrameTestHelpers::WebViewHelper webViewHelper; | 5960 FrameTestHelpers::WebViewHelper webViewHelper; |
5905 webViewHelper.initialize(false, &webFrameClient); | 5961 webViewHelper.initialize(false, &webFrameClient); |
5906 | 5962 |
5907 EXPECT_FALSE(webFrameClient.m_didLoad); | 5963 EXPECT_FALSE(webFrameClient.m_didLoad); |
5908 EXPECT_EQ( | 5964 // The empty document that a new frame starts with triggers this. |
5909 1, | 5965 EXPECT_EQ(1, webFrameClient.m_numBodies); |
5910 webFrameClient | |
5911 .m_numBodies); // The empty document that a new frame starts with tri
ggers this. | |
5912 } | 5966 } |
5913 | 5967 |
5914 TEST_P(ParameterizedWebFrameTest, | 5968 TEST_P(ParameterizedWebFrameTest, |
5915 MoveCaretSelectionTowardsWindowPointWithNoSelection) { | 5969 MoveCaretSelectionTowardsWindowPointWithNoSelection) { |
5916 FrameTestHelpers::WebViewHelper webViewHelper; | 5970 FrameTestHelpers::WebViewHelper webViewHelper; |
5917 webViewHelper.initializeAndLoad("about:blank", true); | 5971 webViewHelper.initializeAndLoad("about:blank", true); |
5918 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5972 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5919 | 5973 |
5920 // This test passes if this doesn't crash. | 5974 // This test passes if this doesn't crash. |
5921 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0)); | 5975 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0)); |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6418 TestScrolledFrameClient() { reset(); } | 6472 TestScrolledFrameClient() { reset(); } |
6419 void reset() { m_didScrollFrame = false; } | 6473 void reset() { m_didScrollFrame = false; } |
6420 bool wasFrameScrolled() const { return m_didScrollFrame; } | 6474 bool wasFrameScrolled() const { return m_didScrollFrame; } |
6421 | 6475 |
6422 // WebFrameClient: | 6476 // WebFrameClient: |
6423 void didChangeScrollOffset(WebLocalFrame* frame) override { | 6477 void didChangeScrollOffset(WebLocalFrame* frame) override { |
6424 if (frame->parent()) | 6478 if (frame->parent()) |
6425 return; | 6479 return; |
6426 EXPECT_FALSE(m_didScrollFrame); | 6480 EXPECT_FALSE(m_didScrollFrame); |
6427 FrameView* view = toWebLocalFrameImpl(frame)->frameView(); | 6481 FrameView* view = toWebLocalFrameImpl(frame)->frameView(); |
6428 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 6482 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect which |
6429 // which is called from LocalFrame::createView (before the frame is associat
ed | 6483 // is called from LocalFrame::createView (before the frame is associated |
6430 // with the the view). | 6484 // with the the view). |
6431 if (view) | 6485 if (view) |
6432 m_didScrollFrame = true; | 6486 m_didScrollFrame = true; |
6433 } | 6487 } |
6434 | 6488 |
6435 private: | 6489 private: |
6436 bool m_didScrollFrame; | 6490 bool m_didScrollFrame; |
6437 }; | 6491 }; |
6438 | 6492 |
6439 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) { | 6493 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6621 PlatformMouseEvent::RealOrIndistinguishable, String(), nullptr); | 6675 PlatformMouseEvent::RealOrIndistinguishable, String(), nullptr); |
6622 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); | 6676 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
6623 frameRequest.setTriggeringEvent(event); | 6677 frameRequest.setTriggeringEvent(event); |
6624 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6678 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
6625 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 6679 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
6626 ->loader() | 6680 ->loader() |
6627 .load(frameRequest); | 6681 .load(frameRequest); |
6628 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 6682 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
6629 webViewHelper.webView()->mainFrame()); | 6683 webViewHelper.webView()->mainFrame()); |
6630 | 6684 |
6631 // decidePolicyForNavigation should be called both for the original request an
d the ctrl+click. | 6685 // decidePolicyForNavigation should be called both for the original request |
| 6686 // and the ctrl+click. |
6632 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 6687 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
6633 } | 6688 } |
6634 | 6689 |
6635 TEST_P(ParameterizedWebFrameTest, BackToReload) { | 6690 TEST_P(ParameterizedWebFrameTest, BackToReload) { |
6636 registerMockedHttpURLLoad("fragment_middle_click.html"); | 6691 registerMockedHttpURLLoad("fragment_middle_click.html"); |
6637 FrameTestHelpers::WebViewHelper webViewHelper; | 6692 FrameTestHelpers::WebViewHelper webViewHelper; |
6638 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", | 6693 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", |
6639 true); | 6694 true); |
6640 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6695 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6641 const FrameLoader& mainFrameLoader = | 6696 const FrameLoader& mainFrameLoader = |
(...skipping 19 matching lines...) Expand all Loading... |
6661 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 6716 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
6662 FrameTestHelpers::WebViewHelper webViewHelper; | 6717 FrameTestHelpers::WebViewHelper webViewHelper; |
6663 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", | 6718 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", |
6664 true); | 6719 true); |
6665 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 6720 WebLocalFrame* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
6666 const FrameLoader& mainFrameLoader = | 6721 const FrameLoader& mainFrameLoader = |
6667 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 6722 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
6668 WebFrame* childFrame = mainFrame->firstChild(); | 6723 WebFrame* childFrame = mainFrame->firstChild(); |
6669 ASSERT_TRUE(childFrame); | 6724 ASSERT_TRUE(childFrame); |
6670 | 6725 |
6671 // Start a history navigation, then have a different frame commit a navigation
. | 6726 // Start a history navigation, then have a different frame commit a |
6672 // In this case, reload an about:blank frame, which will commit synchronously. | 6727 // navigation. In this case, reload an about:blank frame, which will commit |
6673 // After the history navigation completes, both the appropriate document url a
nd | 6728 // synchronously. After the history navigation completes, both the |
6674 // the current history item should reflect the history navigation. | 6729 // appropriate document url and the current history item should reflect the |
| 6730 // history navigation. |
6675 registerMockedHttpURLLoad("white-1x1.png"); | 6731 registerMockedHttpURLLoad("white-1x1.png"); |
6676 WebHistoryItem item; | 6732 WebHistoryItem item; |
6677 item.initialize(); | 6733 item.initialize(); |
6678 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 6734 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
6679 item.setURLString(historyURL.string()); | 6735 item.setURLString(historyURL.string()); |
6680 WebURLRequest request = mainFrame->requestFromHistoryItem( | 6736 WebURLRequest request = mainFrame->requestFromHistoryItem( |
6681 item, WebCachePolicy::UseProtocolCachePolicy); | 6737 item, WebCachePolicy::UseProtocolCachePolicy); |
6682 mainFrame->load(request, WebFrameLoadType::BackForward, item); | 6738 mainFrame->load(request, WebFrameLoadType::BackForward, item); |
6683 | 6739 |
6684 FrameTestHelpers::reloadFrame(childFrame); | 6740 FrameTestHelpers::reloadFrame(childFrame); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6809 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 6865 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
6810 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild()); | 6866 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild()); |
6811 ASSERT_EQ(childFrame->client(), &childClient); | 6867 ASSERT_EQ(childFrame->client(), &childClient); |
6812 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 6868 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
6813 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 6869 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
6814 EXPECT_EQ(childClient.getCachePolicy(), | 6870 EXPECT_EQ(childClient.getCachePolicy(), |
6815 WebCachePolicy::UseProtocolCachePolicy); | 6871 WebCachePolicy::UseProtocolCachePolicy); |
6816 | 6872 |
6817 FrameTestHelpers::reloadFrame(mainFrame); | 6873 FrameTestHelpers::reloadFrame(mainFrame); |
6818 | 6874 |
6819 // A new WebFrame should have been created, but the child WebFrameClient shoul
d be reused. | 6875 // A new WebFrame should have been created, but the child WebFrameClient |
| 6876 // should be reused. |
6820 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 6877 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
6821 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), | 6878 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), |
6822 &childClient); | 6879 &childClient); |
6823 | 6880 |
6824 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 6881 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
6825 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 6882 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
6826 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::ValidatingCacheData); | 6883 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::ValidatingCacheData); |
6827 } | 6884 } |
6828 | 6885 |
6829 class TestSameDocumentWebFrameClient | 6886 class TestSameDocumentWebFrameClient |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6921 KURL testURL = toKURL("about:blank"); | 6978 KURL testURL = toKURL("about:blank"); |
6922 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); | 6979 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); |
6923 | 6980 |
6924 WebNode node = frame->document().body().firstChild(); | 6981 WebNode node = frame->document().body().firstChild(); |
6925 EXPECT_TRUE(node.isElementNode()); | 6982 EXPECT_TRUE(node.isElementNode()); |
6926 WebElement element = node.to<WebElement>(); | 6983 WebElement element = node.to<WebElement>(); |
6927 WebImage image = element.imageContents(); | 6984 WebImage image = element.imageContents(); |
6928 ASSERT_FALSE(image.isNull()); | 6985 ASSERT_FALSE(image.isNull()); |
6929 EXPECT_EQ(image.size().width, 10); | 6986 EXPECT_EQ(image.size().width, 10); |
6930 EXPECT_EQ(image.size().height, 10); | 6987 EXPECT_EQ(image.size().height, 10); |
6931 // FIXME: The rest of this test is disabled since the ImageDecodeCache stat
e may be inconsistent when this test runs. | 6988 // FIXME: The rest of this test is disabled since the ImageDecodeCache state |
6932 // crbug.com/266088 | 6989 // may be inconsistent when this test runs, crbug.com/266088 |
6933 // SkBitmap bitmap = image.getSkBitmap(); | 6990 //SkBitmap bitmap = image.getSkBitmap(); |
6934 // SkAutoLockPixels locker(bitmap); | 6991 //SkAutoLockPixels locker(bitmap); |
6935 // EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); | 6992 //EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); |
6936 } | 6993 } |
6937 | 6994 |
6938 class TestStartStopCallbackWebFrameClient | 6995 class TestStartStopCallbackWebFrameClient |
6939 : public FrameTestHelpers::TestWebFrameClient { | 6996 : public FrameTestHelpers::TestWebFrameClient { |
6940 public: | 6997 public: |
6941 TestStartStopCallbackWebFrameClient() | 6998 TestStartStopCallbackWebFrameClient() |
6942 : m_startLoadingCount(0), | 6999 : m_startLoadingCount(0), |
6943 m_stopLoadingCount(0), | 7000 m_stopLoadingCount(0), |
6944 m_differentDocumentStartCount(0) {} | 7001 m_differentDocumentStartCount(0) {} |
6945 | 7002 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7126 | 7183 |
7127 // Call javascript to make the layer scrollable, and verify it. | 7184 // Call javascript to make the layer scrollable, and verify it. |
7128 WebLocalFrameImpl* frame = | 7185 WebLocalFrameImpl* frame = |
7129 (WebLocalFrameImpl*)webViewHelper.webView()->mainFrame(); | 7186 (WebLocalFrameImpl*)webViewHelper.webView()->mainFrame(); |
7130 frame->executeScript(WebScriptSource("allowScroll();")); | 7187 frame->executeScript(WebScriptSource("allowScroll();")); |
7131 webViewHelper.webView()->updateAllLifecyclePhases(); | 7188 webViewHelper.webView()->updateAllLifecyclePhases(); |
7132 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 7189 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
7133 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 7190 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
7134 } | 7191 } |
7135 | 7192 |
7136 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 7193 // Test that currentHistoryItem reflects the current page, not the provisional |
| 7194 // load. |
7137 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) { | 7195 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) { |
7138 registerMockedHttpURLLoad("fixed_layout.html"); | 7196 registerMockedHttpURLLoad("fixed_layout.html"); |
7139 std::string url = m_baseURL + "fixed_layout.html"; | 7197 std::string url = m_baseURL + "fixed_layout.html"; |
7140 | 7198 |
7141 FrameTestHelpers::WebViewHelper webViewHelper; | 7199 FrameTestHelpers::WebViewHelper webViewHelper; |
7142 webViewHelper.initialize(); | 7200 webViewHelper.initialize(); |
7143 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7201 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7144 const FrameLoader& mainFrameLoader = | 7202 const FrameLoader& mainFrameLoader = |
7145 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7203 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
7146 WebURLRequest request; | 7204 WebURLRequest request; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7200 | 7258 |
7201 WebViewImpl* webView = webViewHelper.webView(); | 7259 WebViewImpl* webView = webViewHelper.webView(); |
7202 webViewHelper.resize(WebSize(100, 100)); | 7260 webViewHelper.resize(WebSize(100, 100)); |
7203 | 7261 |
7204 Document* document = webView->mainFrameImpl()->frame()->document(); | 7262 Document* document = webView->mainFrameImpl()->frame()->document(); |
7205 Element* bottomFixed = document->getElementById("bottom-fixed"); | 7263 Element* bottomFixed = document->getElementById("bottom-fixed"); |
7206 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); | 7264 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); |
7207 Element* rightFixed = document->getElementById("right-fixed"); | 7265 Element* rightFixed = document->getElementById("right-fixed"); |
7208 Element* leftRightFixed = document->getElementById("left-right-fixed"); | 7266 Element* leftRightFixed = document->getElementById("left-right-fixed"); |
7209 | 7267 |
7210 // The layout viewport will hit the min-scale limit of 0.25, so it'll be 400x8
00. | 7268 // The layout viewport will hit the min-scale limit of 0.25, so it'll be |
| 7269 // 400x800. |
7211 webViewHelper.resize(WebSize(100, 200)); | 7270 webViewHelper.resize(WebSize(100, 200)); |
7212 EXPECT_EQ(800, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); | 7271 EXPECT_EQ(800, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); |
7213 EXPECT_EQ(800, topBottomFixed->offsetHeight()); | 7272 EXPECT_EQ(800, topBottomFixed->offsetHeight()); |
7214 | 7273 |
7215 // Now the layout viewport hits the content width limit of 500px so it'll be 5
00x500. | 7274 // Now the layout viewport hits the content width limit of 500px so it'll be |
| 7275 // 500x500. |
7216 webViewHelper.resize(WebSize(200, 200)); | 7276 webViewHelper.resize(WebSize(200, 200)); |
7217 EXPECT_EQ(500, rightFixed->offsetLeft() + rightFixed->offsetWidth()); | 7277 EXPECT_EQ(500, rightFixed->offsetLeft() + rightFixed->offsetWidth()); |
7218 EXPECT_EQ(500, leftRightFixed->offsetWidth()); | 7278 EXPECT_EQ(500, leftRightFixed->offsetWidth()); |
7219 } | 7279 } |
7220 | 7280 |
7221 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) { | 7281 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) { |
7222 FrameTestHelpers::WebViewHelper webViewHelper; | 7282 FrameTestHelpers::WebViewHelper webViewHelper; |
7223 webViewHelper.initializeAndLoad("about:blank"); | 7283 webViewHelper.initializeAndLoad("about:blank"); |
7224 webViewHelper.resize(WebSize(200, 200)); | 7284 webViewHelper.resize(WebSize(200, 200)); |
7225 webViewHelper.webView()->updateAllLifecyclePhases(); | 7285 webViewHelper.webView()->updateAllLifecyclePhases(); |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8309 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8369 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
8310 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue( | 8370 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue( |
8311 WebScriptSource("document.querySelector('#frame2').contentWindow;")); | 8371 WebScriptSource("document.querySelector('#frame2').contentWindow;")); |
8312 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); | 8372 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); |
8313 // Check that its view is consistent with the world. | 8373 // Check that its view is consistent with the world. |
8314 v8::Local<v8::Value> remoteWindowTop = | 8374 v8::Local<v8::Value> remoteWindowTop = |
8315 mainFrame()->executeScriptAndReturnValue(WebScriptSource( | 8375 mainFrame()->executeScriptAndReturnValue(WebScriptSource( |
8316 "document.querySelector('#frame2').contentWindow.top;")); | 8376 "document.querySelector('#frame2').contentWindow.top;")); |
8317 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 8377 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
8318 | 8378 |
8319 // Now check that remote -> local works too, since it goes through a different
code path. | 8379 // Now check that remote -> local works too, since it goes through a different |
| 8380 // code path. |
8320 FrameTestHelpers::TestWebFrameClient client; | 8381 FrameTestHelpers::TestWebFrameClient client; |
8321 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( | 8382 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( |
8322 &client, remoteFrame, WebSandboxFlags::None); | 8383 &client, remoteFrame, WebSandboxFlags::None); |
8323 remoteFrame->swap(localFrame); | 8384 remoteFrame->swap(localFrame); |
8324 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( | 8385 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( |
8325 WebScriptSource("document.querySelector('#frame2').contentWindow;")); | 8386 WebScriptSource("document.querySelector('#frame2').contentWindow;")); |
8326 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); | 8387 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); |
8327 v8::Local<v8::Value> localWindowTop = | 8388 v8::Local<v8::Value> localWindowTop = |
8328 mainFrame()->executeScriptAndReturnValue(WebScriptSource( | 8389 mainFrame()->executeScriptAndReturnValue(WebScriptSource( |
8329 "document.querySelector('#frame2').contentWindow.top;")); | 8390 "document.querySelector('#frame2').contentWindow.top;")); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8439 childFrame->executeScriptAndReturnValue( | 8500 childFrame->executeScriptAndReturnValue( |
8440 WebScriptSource("parent.frames[0]")); | 8501 WebScriptSource("parent.frames[0]")); |
8441 EXPECT_TRUE(childOfRemoteParent->IsObject()); | 8502 EXPECT_TRUE(childOfRemoteParent->IsObject()); |
8442 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); | 8503 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); |
8443 | 8504 |
8444 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( | 8505 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( |
8445 WebScriptSource("parent.frames.length")); | 8506 WebScriptSource("parent.frames.length")); |
8446 ASSERT_TRUE(windowLength->IsInt32()); | 8507 ASSERT_TRUE(windowLength->IsInt32()); |
8447 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); | 8508 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); |
8448 | 8509 |
8449 // Manually reset to break WebViewHelper's dependency on the stack allocated c
lients. | 8510 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 8511 // clients. |
8450 reset(); | 8512 reset(); |
8451 } | 8513 } |
8452 | 8514 |
8453 // Check that frames with a remote parent don't crash while accessing window.fra
meElement. | 8515 // Check that frames with a remote parent don't crash while accessing |
| 8516 // window.frameElement. |
8454 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) { | 8517 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) { |
8455 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8518 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
8456 | 8519 |
8457 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8520 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
8458 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 8521 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
8459 mainFrame()->swap(remoteParentFrame); | 8522 mainFrame()->swap(remoteParentFrame); |
8460 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8523 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
8461 | 8524 |
8462 WebLocalFrame* childFrame = | 8525 WebLocalFrame* childFrame = |
8463 FrameTestHelpers::createLocalChild(remoteParentFrame); | 8526 FrameTestHelpers::createLocalChild(remoteParentFrame); |
8464 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 8527 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
8465 | 8528 |
8466 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( | 8529 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( |
8467 WebScriptSource("window.frameElement")); | 8530 WebScriptSource("window.frameElement")); |
8468 // frameElement should be null if cross-origin. | 8531 // frameElement should be null if cross-origin. |
8469 ASSERT_FALSE(frameElement.IsEmpty()); | 8532 ASSERT_FALSE(frameElement.IsEmpty()); |
8470 EXPECT_TRUE(frameElement->IsNull()); | 8533 EXPECT_TRUE(frameElement->IsNull()); |
8471 | 8534 |
8472 // Manually reset to break WebViewHelper's dependency on the stack allocated c
lients. | 8535 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 8536 // clients. |
8473 reset(); | 8537 reset(); |
8474 } | 8538 } |
8475 | 8539 |
8476 class RemoteToLocalSwapWebFrameClient | 8540 class RemoteToLocalSwapWebFrameClient |
8477 : public FrameTestHelpers::TestWebFrameClient { | 8541 : public FrameTestHelpers::TestWebFrameClient { |
8478 public: | 8542 public: |
8479 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) | 8543 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) |
8480 : m_historyCommitType(WebHistoryInertCommit), | 8544 : m_historyCommitType(WebHistoryInertCommit), |
8481 m_remoteFrame(remoteFrame) {} | 8545 m_remoteFrame(remoteFrame) {} |
8482 | 8546 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8792 }; | 8856 }; |
8793 | 8857 |
8794 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) { | 8858 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) { |
8795 FrameTestHelpers::TestWebViewClient viewClient; | 8859 FrameTestHelpers::TestWebViewClient viewClient; |
8796 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8860 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
8797 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); | 8861 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); |
8798 view->setMainFrame(remoteClient.frame()); | 8862 view->setMainFrame(remoteClient.frame()); |
8799 remoteClient.frame()->setReplicatedOrigin( | 8863 remoteClient.frame()->setReplicatedOrigin( |
8800 WebSecurityOrigin::createFromString(WebString::fromUTF8(m_baseURL))); | 8864 WebSecurityOrigin::createFromString(WebString::fromUTF8(m_baseURL))); |
8801 | 8865 |
8802 // If an iframe has a remote main frame, ensure the inital commit is correctly
identified as WebInitialCommitInChildFrame. | 8866 // If an iframe has a remote main frame, ensure the inital commit is correctly |
| 8867 // identified as WebInitialCommitInChildFrame. |
8803 CommitTypeWebFrameClient childFrameClient; | 8868 CommitTypeWebFrameClient childFrameClient; |
8804 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild( | 8869 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild( |
8805 view->mainFrame()->toWebRemoteFrame(), "frameName", &childFrameClient); | 8870 view->mainFrame()->toWebRemoteFrame(), "frameName", &childFrameClient); |
8806 registerMockedHttpURLLoad("foo.html"); | 8871 registerMockedHttpURLLoad("foo.html"); |
8807 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); | 8872 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); |
8808 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()); | 8873 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()); |
8809 view->close(); | 8874 view->close(); |
8810 } | 8875 } |
8811 | 8876 |
8812 class GestureEventTestWebWidgetClient | 8877 class GestureEventTestWebWidgetClient |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9278 TEST_P(WebFrameOverscrollTest, | 9343 TEST_P(WebFrameOverscrollTest, |
9279 AccumulatedRootOverscrollAndUnsedDeltaValuesOnOverscroll) { | 9344 AccumulatedRootOverscrollAndUnsedDeltaValuesOnOverscroll) { |
9280 OverscrollWebViewClient client; | 9345 OverscrollWebViewClient client; |
9281 registerMockedHttpURLLoad("overscroll/overscroll.html"); | 9346 registerMockedHttpURLLoad("overscroll/overscroll.html"); |
9282 FrameTestHelpers::WebViewHelper webViewHelper; | 9347 FrameTestHelpers::WebViewHelper webViewHelper; |
9283 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", | 9348 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", |
9284 true, nullptr, &client, nullptr, | 9349 true, nullptr, &client, nullptr, |
9285 configureAndroid); | 9350 configureAndroid); |
9286 webViewHelper.resize(WebSize(200, 200)); | 9351 webViewHelper.resize(WebSize(200, 200)); |
9287 | 9352 |
9288 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple scroll
Update. | 9353 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple |
| 9354 // scrollUpdate. |
9289 ScrollBegin(&webViewHelper); | 9355 ScrollBegin(&webViewHelper); |
9290 EXPECT_CALL(client, didOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), | 9356 EXPECT_CALL(client, didOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), |
9291 WebFloatPoint(100, 100), WebFloatSize())); | 9357 WebFloatPoint(100, 100), WebFloatSize())); |
9292 ScrollUpdate(&webViewHelper, -308, -316); | 9358 ScrollUpdate(&webViewHelper, -308, -316); |
9293 Mock::VerifyAndClearExpectations(&client); | 9359 Mock::VerifyAndClearExpectations(&client); |
9294 | 9360 |
9295 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), | 9361 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), |
9296 WebFloatPoint(100, 100), WebFloatSize())); | 9362 WebFloatPoint(100, 100), WebFloatSize())); |
9297 ScrollUpdate(&webViewHelper, 0, -13); | 9363 ScrollUpdate(&webViewHelper, 0, -13); |
9298 Mock::VerifyAndClearExpectations(&client); | 9364 Mock::VerifyAndClearExpectations(&client); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9344 ScrollEnd(&webViewHelper); | 9410 ScrollEnd(&webViewHelper); |
9345 ScrollBegin(&webViewHelper); | 9411 ScrollBegin(&webViewHelper); |
9346 | 9412 |
9347 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 9413 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
9348 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), | 9414 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), |
9349 WebFloatPoint(100, 100), WebFloatSize())); | 9415 WebFloatPoint(100, 100), WebFloatSize())); |
9350 ScrollUpdate(&webViewHelper, 0, -100); | 9416 ScrollUpdate(&webViewHelper, 0, -100); |
9351 ScrollUpdate(&webViewHelper, 0, -100); | 9417 ScrollUpdate(&webViewHelper, 0, -100); |
9352 Mock::VerifyAndClearExpectations(&client); | 9418 Mock::VerifyAndClearExpectations(&client); |
9353 | 9419 |
9354 // TODO(bokan): This has never worked but by the accident that this test was b
eing | 9420 // TODO(bokan): This has never worked but by the accident that this test was |
9355 // run in a WebView without a size. This test should be fixed along with the b
ug. | 9421 // being run in a WebView without a size. This test should be fixed along with |
9356 // crbug.com/589320. | 9422 // the bug, crbug.com/589320. |
9357 // Page scrolls vertically, but over-scrolls horizontally. | 9423 // Page scrolls vertically, but over-scrolls horizontally. |
9358 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100,
0), WebFloatPoint(100, 100), WebFloatSize())); | 9424 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, |
| 9425 // 0), WebFloatPoint(100, 100), WebFloatSize())); |
9359 // ScrollUpdate(&webViewHelper, 100, 50); | 9426 // ScrollUpdate(&webViewHelper, 100, 50); |
9360 // Mock::VerifyAndClearExpectations(&client); | 9427 // Mock::VerifyAndClearExpectations(&client); |
9361 | 9428 |
9362 // Scrolling up, Overscroll is not reported. | 9429 // Scrolling up, Overscroll is not reported. |
9363 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 9430 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); |
9364 // ScrollUpdate(&webViewHelper, 0, -50); | 9431 // ScrollUpdate(&webViewHelper, 0, -50); |
9365 // Mock::VerifyAndClearExpectations(&client); | 9432 // Mock::VerifyAndClearExpectations(&client); |
9366 | 9433 |
9367 // Page scrolls horizontally, but over-scrolls vertically. | 9434 // Page scrolls horizontally, but over-scrolls vertically. |
9368 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100
), WebFloatPoint(100, 100), WebFloatSize())); | 9435 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, |
| 9436 // 100), WebFloatPoint(100, 100), WebFloatSize())); |
9369 // ScrollUpdate(&webViewHelper, -100, -100); | 9437 // ScrollUpdate(&webViewHelper, -100, -100); |
9370 // Mock::VerifyAndClearExpectations(&client); | 9438 // Mock::VerifyAndClearExpectations(&client); |
9371 } | 9439 } |
9372 | 9440 |
9373 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { | 9441 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
9374 OverscrollWebViewClient client; | 9442 OverscrollWebViewClient client; |
9375 registerMockedHttpURLLoad("overscroll/div-overscroll.html"); | 9443 registerMockedHttpURLLoad("overscroll/div-overscroll.html"); |
9376 FrameTestHelpers::WebViewHelper webViewHelper; | 9444 FrameTestHelpers::WebViewHelper webViewHelper; |
9377 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/div-overscroll.html", | 9445 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/div-overscroll.html", |
9378 true, nullptr, &client, nullptr, | 9446 true, nullptr, &client, nullptr, |
(...skipping 28 matching lines...) Expand all Loading... |
9407 webViewHelper.resize(WebSize(200, 200)); | 9475 webViewHelper.resize(WebSize(200, 200)); |
9408 | 9476 |
9409 ScrollBegin(&webViewHelper); | 9477 ScrollBegin(&webViewHelper); |
9410 // Scroll the IFrame to the end. | 9478 // Scroll the IFrame to the end. |
9411 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 9479 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); |
9412 | 9480 |
9413 // This scroll will fully scroll the iframe but will be consumed before being | 9481 // This scroll will fully scroll the iframe but will be consumed before being |
9414 // counted as overscroll. | 9482 // counted as overscroll. |
9415 ScrollUpdate(&webViewHelper, 0, -320); | 9483 ScrollUpdate(&webViewHelper, 0, -320); |
9416 | 9484 |
9417 // This scroll will again target the iframe but wont bubble further up. Make s
ure | 9485 // This scroll will again target the iframe but wont bubble further up. Make |
9418 // that the unused scroll isn't handled as overscroll. | 9486 // sure that the unused scroll isn't handled as overscroll. |
9419 ScrollUpdate(&webViewHelper, 0, -50); | 9487 ScrollUpdate(&webViewHelper, 0, -50); |
9420 Mock::VerifyAndClearExpectations(&client); | 9488 Mock::VerifyAndClearExpectations(&client); |
9421 | 9489 |
9422 ScrollEnd(&webViewHelper); | 9490 ScrollEnd(&webViewHelper); |
9423 ScrollBegin(&webViewHelper); | 9491 ScrollBegin(&webViewHelper); |
9424 | 9492 |
9425 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. | 9493 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. |
9426 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 9494 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
9427 WebFloatPoint(100, 100), WebFloatSize())); | 9495 WebFloatPoint(100, 100), WebFloatSize())); |
9428 ScrollUpdate(&webViewHelper, 0, -150); | 9496 ScrollUpdate(&webViewHelper, 0, -150); |
9429 Mock::VerifyAndClearExpectations(&client); | 9497 Mock::VerifyAndClearExpectations(&client); |
9430 | 9498 |
9431 ScrollEnd(&webViewHelper); | 9499 ScrollEnd(&webViewHelper); |
9432 } | 9500 } |
9433 | 9501 |
9434 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { | 9502 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { |
9435 OverscrollWebViewClient client; | 9503 OverscrollWebViewClient client; |
9436 registerMockedHttpURLLoad("overscroll/overscroll.html"); | 9504 registerMockedHttpURLLoad("overscroll/overscroll.html"); |
9437 FrameTestHelpers::WebViewHelper webViewHelper; | 9505 FrameTestHelpers::WebViewHelper webViewHelper; |
9438 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( | 9506 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( |
9439 m_baseURL + "overscroll/overscroll.html", true, nullptr, &client, nullptr, | 9507 m_baseURL + "overscroll/overscroll.html", true, nullptr, &client, nullptr, |
9440 configureAndroid); | 9508 configureAndroid); |
9441 webViewHelper.resize(WebSize(200, 200)); | 9509 webViewHelper.resize(WebSize(200, 200)); |
9442 webViewImpl->setPageScaleFactor(3.0); | 9510 webViewImpl->setPageScaleFactor(3.0); |
9443 | 9511 |
9444 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. Th
e point is (99, 99) because we clamp | 9512 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. |
9445 // in the division by 3 to 33 so when we go back to viewport coordinates it be
comes (99, 99). | 9513 // The point is (99, 99) because we clamp in the division by 3 to 33 so when |
| 9514 // we go back to viewport coordinates it becomes (99, 99). |
9446 ScrollBegin(&webViewHelper); | 9515 ScrollBegin(&webViewHelper); |
9447 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), | 9516 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), |
9448 WebFloatPoint(99, 99), WebFloatSize())); | 9517 WebFloatPoint(99, 99), WebFloatSize())); |
9449 ScrollUpdate(&webViewHelper, 0, 30); | 9518 ScrollUpdate(&webViewHelper, 0, 30); |
9450 Mock::VerifyAndClearExpectations(&client); | 9519 Mock::VerifyAndClearExpectations(&client); |
9451 | 9520 |
9452 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), | 9521 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), |
9453 WebFloatPoint(99, 99), WebFloatSize())); | 9522 WebFloatPoint(99, 99), WebFloatSize())); |
9454 ScrollUpdate(&webViewHelper, 0, 30); | 9523 ScrollUpdate(&webViewHelper, 0, 30); |
9455 Mock::VerifyAndClearExpectations(&client); | 9524 Mock::VerifyAndClearExpectations(&client); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9493 WebFloatPoint(100, 100), WebFloatSize())); | 9562 WebFloatPoint(100, 100), WebFloatSize())); |
9494 ScrollUpdate(&webViewHelper, 0, 0.10); | 9563 ScrollUpdate(&webViewHelper, 0, 0.10); |
9495 Mock::VerifyAndClearExpectations(&client); | 9564 Mock::VerifyAndClearExpectations(&client); |
9496 | 9565 |
9497 EXPECT_CALL(client, didOverscroll(WebFloatSize(-0.10, 0), | 9566 EXPECT_CALL(client, didOverscroll(WebFloatSize(-0.10, 0), |
9498 WebFloatSize(-10.10, -10.10), | 9567 WebFloatSize(-10.10, -10.10), |
9499 WebFloatPoint(100, 100), WebFloatSize())); | 9568 WebFloatPoint(100, 100), WebFloatSize())); |
9500 ScrollUpdate(&webViewHelper, 0.10, 0); | 9569 ScrollUpdate(&webViewHelper, 0.10, 0); |
9501 Mock::VerifyAndClearExpectations(&client); | 9570 Mock::VerifyAndClearExpectations(&client); |
9502 | 9571 |
9503 // For residual values overscrollDelta should be reset and didOverscroll shoul
dn't be called. | 9572 // For residual values overscrollDelta should be reset and didOverscroll |
| 9573 // shouldn't be called. |
9504 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 9574 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); |
9505 ScrollUpdate(&webViewHelper, 0, 0.09); | 9575 ScrollUpdate(&webViewHelper, 0, 0.09); |
9506 Mock::VerifyAndClearExpectations(&client); | 9576 Mock::VerifyAndClearExpectations(&client); |
9507 | 9577 |
9508 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 9578 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); |
9509 ScrollUpdate(&webViewHelper, 0.09, 0.09); | 9579 ScrollUpdate(&webViewHelper, 0.09, 0.09); |
9510 Mock::VerifyAndClearExpectations(&client); | 9580 Mock::VerifyAndClearExpectations(&client); |
9511 | 9581 |
9512 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 9582 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); |
9513 ScrollUpdate(&webViewHelper, 0.09, 0); | 9583 ScrollUpdate(&webViewHelper, 0.09, 0); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9810 webView->setPageScaleFactor(4); | 9880 webView->setPageScaleFactor(4); |
9811 webView->setVisualViewportOffset(WebFloatPoint(1, 1)); | 9881 webView->setVisualViewportOffset(WebFloatPoint(1, 1)); |
9812 | 9882 |
9813 client.reset(); | 9883 client.reset(); |
9814 localFrame->saveImageAt(WebPoint(3, 3)); | 9884 localFrame->saveImageAt(WebPoint(3, 3)); |
9815 EXPECT_EQ( | 9885 EXPECT_EQ( |
9816 WebString::fromUTF8("data:image/gif;base64" | 9886 WebString::fromUTF8("data:image/gif;base64" |
9817 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), | 9887 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), |
9818 client.result()); | 9888 client.result()); |
9819 | 9889 |
9820 helper | 9890 // Explicitly reset to break dependency on locally scoped client. |
9821 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | 9891 helper.reset(); |
9822 } | 9892 } |
9823 | 9893 |
9824 TEST_F(WebFrameTest, SaveImageWithImageMap) { | 9894 TEST_F(WebFrameTest, SaveImageWithImageMap) { |
9825 std::string url = m_baseURL + "image-map.html"; | 9895 std::string url = m_baseURL + "image-map.html"; |
9826 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); | 9896 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); |
9827 | 9897 |
9828 FrameTestHelpers::WebViewHelper helper; | 9898 FrameTestHelpers::WebViewHelper helper; |
9829 SaveImageFromDataURLWebFrameClient client; | 9899 SaveImageFromDataURLWebFrameClient client; |
9830 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 9900 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
9831 webView->resize(WebSize(400, 400)); | 9901 webView->resize(WebSize(400, 400)); |
(...skipping 11 matching lines...) Expand all Loading... |
9843 localFrame->saveImageAt(WebPoint(75, 25)); | 9913 localFrame->saveImageAt(WebPoint(75, 25)); |
9844 EXPECT_EQ( | 9914 EXPECT_EQ( |
9845 WebString::fromUTF8("data:image/gif;base64" | 9915 WebString::fromUTF8("data:image/gif;base64" |
9846 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), | 9916 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), |
9847 client.result()); | 9917 client.result()); |
9848 | 9918 |
9849 client.reset(); | 9919 client.reset(); |
9850 localFrame->saveImageAt(WebPoint(125, 25)); | 9920 localFrame->saveImageAt(WebPoint(125, 25)); |
9851 EXPECT_EQ(WebString(), client.result()); | 9921 EXPECT_EQ(WebString(), client.result()); |
9852 | 9922 |
9853 helper | 9923 // Explicitly reset to break dependency on locally scoped client. |
9854 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | 9924 helper.reset(); |
9855 } | 9925 } |
9856 | 9926 |
9857 TEST_F(WebFrameTest, CopyImageAt) { | 9927 TEST_F(WebFrameTest, CopyImageAt) { |
9858 std::string url = m_baseURL + "canvas-copy-image.html"; | 9928 std::string url = m_baseURL + "canvas-copy-image.html"; |
9859 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html"); | 9929 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html"); |
9860 | 9930 |
9861 FrameTestHelpers::WebViewHelper helper; | 9931 FrameTestHelpers::WebViewHelper helper; |
9862 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); | 9932 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); |
9863 webView->resize(WebSize(400, 400)); | 9933 webView->resize(WebSize(400, 400)); |
9864 | 9934 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9928 client.reset(); | 9998 client.reset(); |
9929 localFrame->saveImageAt(WebPoint(75, 25)); | 9999 localFrame->saveImageAt(WebPoint(75, 25)); |
9930 EXPECT_EQ( | 10000 EXPECT_EQ( |
9931 WebString::fromUTF8("data:image/gif;base64" | 10001 WebString::fromUTF8("data:image/gif;base64" |
9932 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), | 10002 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), |
9933 client.result()); | 10003 client.result()); |
9934 | 10004 |
9935 client.reset(); | 10005 client.reset(); |
9936 localFrame->saveImageAt(WebPoint(125, 25)); | 10006 localFrame->saveImageAt(WebPoint(125, 25)); |
9937 EXPECT_EQ(WebString(), client.result()); | 10007 EXPECT_EQ(WebString(), client.result()); |
9938 | 10008 // Explicitly reset to break dependency on locally scoped client. |
9939 helper | 10009 helper.reset(); |
9940 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | |
9941 } | 10010 } |
9942 | 10011 |
9943 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { | 10012 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { |
9944 FrameTestHelpers::WebViewHelper helper; | 10013 FrameTestHelpers::WebViewHelper helper; |
9945 helper.initialize(true); | 10014 helper.initialize(true); |
9946 | 10015 |
9947 WebURLRequest request; | 10016 WebURLRequest request; |
9948 std::string redirectURL = m_baseURL + "foo.html"; | 10017 std::string redirectURL = m_baseURL + "foo.html"; |
9949 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), "foo.html"); | 10018 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), "foo.html"); |
9950 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); | 10019 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10090 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); | 10159 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); |
10091 | 10160 |
10092 Document* document = | 10161 Document* document = |
10093 toLocalFrame(helper.webView()->page()->mainFrame())->document(); | 10162 toLocalFrame(helper.webView()->page()->mainFrame())->document(); |
10094 EXPECT_TRUE(document->isImageDocument()); | 10163 EXPECT_TRUE(document->isImageDocument()); |
10095 EXPECT_EQ(Resource::DecodeError, | 10164 EXPECT_EQ(Resource::DecodeError, |
10096 toImageDocument(document)->cachedImage()->getStatus()); | 10165 toImageDocument(document)->cachedImage()->getStatus()); |
10097 } | 10166 } |
10098 | 10167 |
10099 } // namespace blink | 10168 } // namespace blink |
OLD | NEW |