| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com:0/" + file
Name), WebString::fromUTF8(fileName)); | 287 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com:0/" + file
Name), WebString::fromUTF8(fileName)); |
| 288 | 288 |
| 289 FrameTestHelpers::WebViewHelper webViewHelper; | 289 FrameTestHelpers::WebViewHelper webViewHelper; |
| 290 | 290 |
| 291 /// Pass true to enable JavaScript. | 291 /// Pass true to enable JavaScript. |
| 292 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 292 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
| 293 | 293 |
| 294 // Setting host to "hostname:" should be treated as "hostname:0". | 294 // Setting host to "hostname:" should be treated as "hostname:0". |
| 295 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.host = 'www.test.com:'; void 0;"); | 295 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.host = 'www.test.com:'; void 0;"); |
| 296 | 296 |
| 297 runPendingTasks(); | |
| 298 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 299 | |
| 300 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); | 297 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); |
| 301 // Required to see any updates in contentAsText. | |
| 302 runPendingTasks(); | |
| 303 webViewHelper.webView()->layout(); | |
| 304 | 298 |
| 305 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 299 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
| 306 EXPECT_EQ("http://www.test.com:0/" + fileName, content); | 300 EXPECT_EQ("http://www.test.com:0/" + fileName, content); |
| 307 } | 301 } |
| 308 | 302 |
| 309 TEST_F(WebFrameTest, LocationSetEmptyPort) | 303 TEST_F(WebFrameTest, LocationSetEmptyPort) |
| 310 { | 304 { |
| 311 std::string fileName = "print-location-href.html"; | 305 std::string fileName = "print-location-href.html"; |
| 312 registerMockedHttpURLLoad(fileName); | 306 registerMockedHttpURLLoad(fileName); |
| 313 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com:0/" + file
Name), WebString::fromUTF8(fileName)); | 307 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com:0/" + file
Name), WebString::fromUTF8(fileName)); |
| 314 | 308 |
| 315 FrameTestHelpers::WebViewHelper webViewHelper; | 309 FrameTestHelpers::WebViewHelper webViewHelper; |
| 316 | 310 |
| 317 /// Pass true to enable JavaScript. | 311 /// Pass true to enable JavaScript. |
| 318 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 312 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
| 319 | 313 |
| 320 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.port = ''; void 0;"); | 314 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:location.port = ''; void 0;"); |
| 321 | 315 |
| 322 runPendingTasks(); | |
| 323 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 324 | |
| 325 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); | 316 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.textContent = location.href; void 0;"); |
| 326 // Required to see any updates in contentAsText. | |
| 327 runPendingTasks(); | |
| 328 webViewHelper.webView()->layout(); | |
| 329 | 317 |
| 330 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 318 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
| 331 EXPECT_EQ("http://www.test.com:0/" + fileName, content); | 319 EXPECT_EQ("http://www.test.com:0/" + fileName, content); |
| 332 } | 320 } |
| 333 | 321 |
| 334 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 322 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 335 public: | 323 public: |
| 336 CSSCallbackWebFrameClient() : m_updateCount(0) { } | 324 CSSCallbackWebFrameClient() : m_updateCount(0) { } |
| 337 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa
tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) OVERRIDE; | 325 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa
tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) OVERRIDE; |
| 338 | 326 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 int updateCount() const | 365 int updateCount() const |
| 378 { | 366 { |
| 379 return m_client.m_updateCount; | 367 return m_client.m_updateCount; |
| 380 } | 368 } |
| 381 | 369 |
| 382 const std::set<std::string>& matchedSelectors() | 370 const std::set<std::string>& matchedSelectors() |
| 383 { | 371 { |
| 384 return m_client.m_matchedSelectors[m_frame]; | 372 return m_client.m_matchedSelectors[m_frame]; |
| 385 } | 373 } |
| 386 | 374 |
| 387 void loadHTML(const WebData& html) | 375 void loadHTML(const std::string& html) |
| 388 { | 376 { |
| 389 m_frame->loadHTMLString(html, toKURL("about:blank")); | 377 FrameTestHelpers::loadHTMLString(m_frame, html, toKURL("about:blank")); |
| 390 runPendingTasks(); | |
| 391 } | 378 } |
| 392 | 379 |
| 393 void executeScript(const WebString& code) | 380 void executeScript(const WebString& code) |
| 394 { | 381 { |
| 395 m_frame->executeScript(WebScriptSource(code)); | 382 m_frame->executeScript(WebScriptSource(code)); |
| 396 m_frame->view()->layout(); | 383 m_frame->view()->layout(); |
| 397 runPendingTasks(); | 384 runPendingTasks(); |
| 398 } | 385 } |
| 399 | 386 |
| 400 CSSCallbackWebFrameClient m_client; | 387 CSSCallbackWebFrameClient m_client; |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 int viewportHeight = 800; | 1364 int viewportHeight = 800; |
| 1378 | 1365 |
| 1379 FrameTestHelpers::WebViewHelper webViewHelper; | 1366 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1380 webViewHelper.initializeAndLoad("about:blank", true, 0, &client, enableViewp
ortSettings); | 1367 webViewHelper.initializeAndLoad("about:blank", true, 0, &client, enableViewp
ortSettings); |
| 1381 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1368 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
| 1382 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1369 webViewHelper.webView()->settings()->setUseWideViewport(true); |
| 1383 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1370 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
| 1384 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1371 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1385 | 1372 |
| 1386 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "wide_document_width_viewport.html"); | 1373 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "wide_document_width_viewport.html"); |
| 1387 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1388 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1374 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1389 | 1375 |
| 1390 int wideDocumentWidth = 800; | 1376 int wideDocumentWidth = 800; |
| 1391 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; | 1377 float minimumPageScaleFactor = viewportWidth / (float) wideDocumentWidth; |
| 1392 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); | 1378 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->pageScaleFactor()
); |
| 1393 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); | 1379 EXPECT_EQ(minimumPageScaleFactor, webViewHelper.webView()->minimumPageScaleF
actor()); |
| 1394 } | 1380 } |
| 1395 | 1381 |
| 1396 TEST_F(WebFrameTest, WideViewportQuirkClobbersHeight) | 1382 TEST_F(WebFrameTest, WideViewportQuirkClobbersHeight) |
| 1397 { | 1383 { |
| 1398 UseMockScrollbarSettings mockScrollbarSettings; | 1384 UseMockScrollbarSettings mockScrollbarSettings; |
| 1399 registerMockedHttpURLLoad("viewport-height-1000.html"); | 1385 registerMockedHttpURLLoad("viewport-height-1000.html"); |
| 1400 | 1386 |
| 1401 FixedLayoutTestWebViewClient client; | 1387 FixedLayoutTestWebViewClient client; |
| 1402 client.m_screenInfo.deviceScaleFactor = 1; | 1388 client.m_screenInfo.deviceScaleFactor = 1; |
| 1403 int viewportWidth = 600; | 1389 int viewportWidth = 600; |
| 1404 int viewportHeight = 800; | 1390 int viewportHeight = 800; |
| 1405 | 1391 |
| 1406 FrameTestHelpers::WebViewHelper webViewHelper; | 1392 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1407 webViewHelper.initializeAndLoad("about:blank", true, 0, &client, enableViewp
ortSettings); | 1393 webViewHelper.initializeAndLoad("about:blank", true, 0, &client, enableViewp
ortSettings); |
| 1408 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1394 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
| 1409 webViewHelper.webView()->settings()->setUseWideViewport(false); | 1395 webViewHelper.webView()->settings()->setUseWideViewport(false); |
| 1410 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1396 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
| 1411 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1397 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1412 | 1398 |
| 1413 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-height-1000.html"); | 1399 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-height-1000.html"); |
| 1414 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1415 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1400 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1416 | 1401 |
| 1417 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1402 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
| 1418 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1403 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
| 1419 } | 1404 } |
| 1420 | 1405 |
| 1421 TEST_F(WebFrameTest, LayoutSize320Quirk) | 1406 TEST_F(WebFrameTest, LayoutSize320Quirk) |
| 1422 { | 1407 { |
| 1423 UseMockScrollbarSettings mockScrollbarSettings; | 1408 UseMockScrollbarSettings mockScrollbarSettings; |
| 1424 registerMockedHttpURLLoad("viewport/viewport-30.html"); | 1409 registerMockedHttpURLLoad("viewport/viewport-30.html"); |
| 1425 | 1410 |
| 1426 FixedLayoutTestWebViewClient client; | 1411 FixedLayoutTestWebViewClient client; |
| 1427 client.m_screenInfo.deviceScaleFactor = 1; | 1412 client.m_screenInfo.deviceScaleFactor = 1; |
| 1428 int viewportWidth = 600; | 1413 int viewportWidth = 600; |
| 1429 int viewportHeight = 800; | 1414 int viewportHeight = 800; |
| 1430 | 1415 |
| 1431 FrameTestHelpers::WebViewHelper webViewHelper; | 1416 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1432 webViewHelper.initializeAndLoad("about:blank", true, 0, &client, enableViewp
ortSettings); | 1417 webViewHelper.initializeAndLoad("about:blank", true, 0, &client, enableViewp
ortSettings); |
| 1433 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1418 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
| 1434 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1419 webViewHelper.webView()->settings()->setUseWideViewport(true); |
| 1435 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1420 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
| 1436 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1421 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1437 | 1422 |
| 1438 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); | 1423 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport/viewport-30.html"); |
| 1439 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1440 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1424 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1441 | 1425 |
| 1442 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); | 1426 EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().width()); |
| 1443 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); | 1427 EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->la
youtSize().height()); |
| 1444 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); | 1428 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); |
| 1445 | 1429 |
| 1446 // The magic number to snap to device-width is 320, so test that 321 is | 1430 // The magic number to snap to device-width is 320, so test that 321 is |
| 1447 // respected. | 1431 // respected. |
| 1448 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 1432 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); |
| 1449 WebCore::ViewportDescription description = document->viewportDescription(); | 1433 WebCore::ViewportDescription description = document->viewportDescription(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1480 client.m_screenInfo.deviceScaleFactor = 1; | 1464 client.m_screenInfo.deviceScaleFactor = 1; |
| 1481 int viewportWidth = 640; | 1465 int viewportWidth = 640; |
| 1482 int viewportHeight = 480; | 1466 int viewportHeight = 480; |
| 1483 | 1467 |
| 1484 FrameTestHelpers::WebViewHelper webViewHelper; | 1468 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1485 webViewHelper.initialize(true, 0, &client, enableViewportSettings); | 1469 webViewHelper.initialize(true, 0, &client, enableViewportSettings); |
| 1486 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); | 1470 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); |
| 1487 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1471 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
| 1488 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); | 1472 webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true); |
| 1489 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-zero-values.html"); | 1473 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-zero-values.html"); |
| 1490 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1491 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1474 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1492 | 1475 |
| 1493 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); | 1476 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); |
| 1494 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1477 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
| 1495 | 1478 |
| 1496 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1479 webViewHelper.webView()->settings()->setUseWideViewport(true); |
| 1497 webViewHelper.webView()->layout(); | 1480 webViewHelper.webView()->layout(); |
| 1498 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); | 1481 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); |
| 1499 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 1482 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
| 1500 } | 1483 } |
| 1501 | 1484 |
| 1502 TEST_F(WebFrameTest, OverflowHiddenDisablesScrolling) | 1485 TEST_F(WebFrameTest, OverflowHiddenDisablesScrolling) |
| 1503 { | 1486 { |
| 1504 registerMockedHttpURLLoad("body-overflow-hidden.html"); | 1487 registerMockedHttpURLLoad("body-overflow-hidden.html"); |
| 1505 | 1488 |
| 1506 FixedLayoutTestWebViewClient client; | 1489 FixedLayoutTestWebViewClient client; |
| 1507 client.m_screenInfo.deviceScaleFactor = 1; | 1490 client.m_screenInfo.deviceScaleFactor = 1; |
| 1508 int viewportWidth = 640; | 1491 int viewportWidth = 640; |
| 1509 int viewportHeight = 480; | 1492 int viewportHeight = 480; |
| 1510 | 1493 |
| 1511 FrameTestHelpers::WebViewHelper webViewHelper; | 1494 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1512 webViewHelper.initialize(true, 0, &client); | 1495 webViewHelper.initialize(true, 0, &client); |
| 1513 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1496 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
| 1514 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1515 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1497 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1516 | 1498 |
| 1517 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 1499 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); |
| 1518 EXPECT_FALSE(view->userInputScrollable(WebCore::VerticalScrollbar)); | 1500 EXPECT_FALSE(view->userInputScrollable(WebCore::VerticalScrollbar)); |
| 1519 } | 1501 } |
| 1520 | 1502 |
| 1521 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) | 1503 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) |
| 1522 { | 1504 { |
| 1523 registerMockedHttpURLLoad("body-overflow-hidden.html"); | 1505 registerMockedHttpURLLoad("body-overflow-hidden.html"); |
| 1524 | 1506 |
| 1525 FixedLayoutTestWebViewClient client; | 1507 FixedLayoutTestWebViewClient client; |
| 1526 client.m_screenInfo.deviceScaleFactor = 1; | 1508 client.m_screenInfo.deviceScaleFactor = 1; |
| 1527 int viewportWidth = 640; | 1509 int viewportWidth = 640; |
| 1528 int viewportHeight = 480; | 1510 int viewportHeight = 480; |
| 1529 | 1511 |
| 1530 FrameTestHelpers::WebViewHelper webViewHelper; | 1512 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1531 webViewHelper.initialize(true, 0, &client); | 1513 webViewHelper.initialize(true, 0, &client); |
| 1532 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t
rue); | 1514 webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(t
rue); |
| 1533 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); | 1515 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "body-overflow-hidden.html"); |
| 1534 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1535 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1516 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1536 | 1517 |
| 1537 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 1518 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); |
| 1538 EXPECT_TRUE(view->userInputScrollable(WebCore::VerticalScrollbar)); | 1519 EXPECT_TRUE(view->userInputScrollable(WebCore::VerticalScrollbar)); |
| 1539 } | 1520 } |
| 1540 | 1521 |
| 1541 TEST_F(WebFrameTest, NonZeroValuesNoQuirk) | 1522 TEST_F(WebFrameTest, NonZeroValuesNoQuirk) |
| 1542 { | 1523 { |
| 1543 UseMockScrollbarSettings mockScrollbarSettings; | 1524 UseMockScrollbarSettings mockScrollbarSettings; |
| 1544 registerMockedHttpURLLoad("viewport-nonzero-values.html"); | 1525 registerMockedHttpURLLoad("viewport-nonzero-values.html"); |
| 1545 | 1526 |
| 1546 FixedLayoutTestWebViewClient client; | 1527 FixedLayoutTestWebViewClient client; |
| 1547 client.m_screenInfo.deviceScaleFactor = 1; | 1528 client.m_screenInfo.deviceScaleFactor = 1; |
| 1548 int viewportWidth = 640; | 1529 int viewportWidth = 640; |
| 1549 int viewportHeight = 480; | 1530 int viewportHeight = 480; |
| 1550 float expectedPageScaleFactor = 0.5f; | 1531 float expectedPageScaleFactor = 0.5f; |
| 1551 | 1532 |
| 1552 FrameTestHelpers::WebViewHelper webViewHelper; | 1533 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1553 webViewHelper.initialize(true, 0, &client, enableViewportSettings); | 1534 webViewHelper.initialize(true, 0, &client, enableViewportSettings); |
| 1554 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); | 1535 webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true); |
| 1555 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1536 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
| 1556 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-nonzero-values.html"); | 1537 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "viewport-nonzero-values.html"); |
| 1557 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1558 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1538 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1559 | 1539 |
| 1560 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl
()->mainFrameImpl()->frameView()->layoutSize().width()); | 1540 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl
()->mainFrameImpl()->frameView()->layoutSize().width()); |
| 1561 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1541 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
| 1562 | 1542 |
| 1563 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1543 webViewHelper.webView()->settings()->setUseWideViewport(true); |
| 1564 webViewHelper.webView()->layout(); | 1544 webViewHelper.webView()->layout(); |
| 1565 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl
()->mainFrameImpl()->frameView()->layoutSize().width()); | 1545 EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl
()->mainFrameImpl()->frameView()->layoutSize().width()); |
| 1566 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1546 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
| 1567 } | 1547 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) | 1594 TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) |
| 1615 { | 1595 { |
| 1616 registerMockedHttpURLLoad("fixed_layout.html"); | 1596 registerMockedHttpURLLoad("fixed_layout.html"); |
| 1617 | 1597 |
| 1618 float pageScaleFactor = 3; | 1598 float pageScaleFactor = 3; |
| 1619 FrameTestHelpers::WebViewHelper webViewHelper; | 1599 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1620 webViewHelper.initializeAndLoad("about:html", true, 0, 0); | 1600 webViewHelper.initializeAndLoad("about:html", true, 0, 0); |
| 1621 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); | 1601 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); |
| 1622 | 1602 |
| 1623 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); | 1603 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); |
| 1624 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 1625 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 1604 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); |
| 1626 EXPECT_EQ(pageScaleFactor, view->visibleContentScaleFactor()); | 1605 EXPECT_EQ(pageScaleFactor, view->visibleContentScaleFactor()); |
| 1627 } | 1606 } |
| 1628 | 1607 |
| 1629 TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem) | 1608 TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem) |
| 1630 { | 1609 { |
| 1631 UseMockScrollbarSettings mockScrollbarSettings; | 1610 UseMockScrollbarSettings mockScrollbarSettings; |
| 1632 registerMockedHttpURLLoad("fixed_layout.html"); | 1611 registerMockedHttpURLLoad("fixed_layout.html"); |
| 1633 | 1612 |
| 1634 FixedLayoutTestWebViewClient client; | 1613 FixedLayoutTestWebViewClient client; |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 | 2171 |
| 2193 int viewWidth = 500; | 2172 int viewWidth = 500; |
| 2194 int viewHeight = 500; | 2173 int viewHeight = 500; |
| 2195 | 2174 |
| 2196 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 2175 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
| 2197 FrameTestHelpers::WebViewHelper webViewHelper; | 2176 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2198 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 2177 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
| 2199 | 2178 |
| 2200 webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); | 2179 webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight)); |
| 2201 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); | 2180 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "large-div.html"); |
| 2202 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 2203 webViewHelper.webView()->layout(); | |
| 2204 | 2181 |
| 2205 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); | 2182 WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); |
| 2206 EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar())
; | 2183 EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar())
; |
| 2207 EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2184 EXPECT_TRUE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
| 2208 | 2185 |
| 2209 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); | 2186 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); |
| 2210 webViewHelper.webView()->layout(); | 2187 webViewHelper.webView()->layout(); |
| 2211 EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()
); | 2188 EXPECT_FALSE(view->renderView()->compositor()->layerForHorizontalScrollbar()
); |
| 2212 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2189 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
| 2213 } | 2190 } |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2675 { | 2652 { |
| 2676 // Test for case in http://crbug.com/73104. Reloading a frame very quickly | 2653 // Test for case in http://crbug.com/73104. Reloading a frame very quickly |
| 2677 // would sometimes call decidePolicyForNavigation with isRedirect=true | 2654 // would sometimes call decidePolicyForNavigation with isRedirect=true |
| 2678 registerMockedHttpURLLoad("form.html"); | 2655 registerMockedHttpURLLoad("form.html"); |
| 2679 | 2656 |
| 2680 TestReloadDoesntRedirectWebFrameClient webFrameClient; | 2657 TestReloadDoesntRedirectWebFrameClient webFrameClient; |
| 2681 FrameTestHelpers::WebViewHelper webViewHelper; | 2658 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2682 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); | 2659 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameCli
ent); |
| 2683 | 2660 |
| 2684 webViewHelper.webView()->mainFrame()->reload(true); | 2661 webViewHelper.webView()->mainFrame()->reload(true); |
| 2685 // start reload before request is delivered. | 2662 // start another reload before request is delivered. |
| 2686 webViewHelper.webView()->mainFrame()->reload(true); | 2663 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
| 2687 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 2688 } | 2664 } |
| 2689 | 2665 |
| 2666 class ReloadWithOverrideURLTask : public WebThread::Task { |
| 2667 public: |
| 2668 ReloadWithOverrideURLTask(WebFrame* frame, const WebCore::KURL& url, bool ig
noreCache) |
| 2669 : m_frame(frame), m_url(url), m_ignoreCache(ignoreCache) |
| 2670 { |
| 2671 } |
| 2672 |
| 2673 virtual void run() OVERRIDE |
| 2674 { |
| 2675 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); |
| 2676 FrameTestHelpers::pumpPendingRequestsDoNotUse(m_frame); |
| 2677 } |
| 2678 |
| 2679 private: |
| 2680 WebFrame* const m_frame; |
| 2681 const WebCore::KURL m_url; |
| 2682 const bool m_ignoreCache; |
| 2683 }; |
| 2684 |
| 2690 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) | 2685 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) |
| 2691 { | 2686 { |
| 2692 const std::string firstURL = "find.html"; | 2687 const std::string firstURL = "find.html"; |
| 2693 const std::string secondURL = "form.html"; | 2688 const std::string secondURL = "form.html"; |
| 2694 const std::string thirdURL = "history.html"; | 2689 const std::string thirdURL = "history.html"; |
| 2695 const float pageScaleFactor = 1.1684f; | 2690 const float pageScaleFactor = 1.1684f; |
| 2696 const int pageWidth = 640; | 2691 const int pageWidth = 640; |
| 2697 const int pageHeight = 480; | 2692 const int pageHeight = 480; |
| 2698 | 2693 |
| 2699 registerMockedHttpURLLoad(firstURL); | 2694 registerMockedHttpURLLoad(firstURL); |
| 2700 registerMockedHttpURLLoad(secondURL); | 2695 registerMockedHttpURLLoad(secondURL); |
| 2701 registerMockedHttpURLLoad(thirdURL); | 2696 registerMockedHttpURLLoad(thirdURL); |
| 2702 | 2697 |
| 2703 FrameTestHelpers::WebViewHelper webViewHelper; | 2698 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2704 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); | 2699 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); |
| 2705 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); | 2700 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); |
| 2706 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth
/ 4, pageHeight / 4)); | 2701 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth
/ 4, pageHeight / 4)); |
| 2707 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); | 2702 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); |
| 2708 | 2703 |
| 2709 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff
set(); | 2704 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff
set(); |
| 2710 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); | 2705 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); |
| 2711 | 2706 |
| 2712 // Reload the page using the cache. | 2707 // Reload the page using the cache. |
| 2713 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas
eURL + secondURL), false); | 2708 Platform::current()->currentThread()->postTask( |
| 2714 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 2709 new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(),
toKURL(m_baseURL + secondURL), false)); |
| 2710 Platform::current()->currentThread()->enterRunLoop(); |
| 2715 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); | 2711 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); |
| 2716 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); | 2712 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); |
| 2717 | 2713 |
| 2718 // Reload the page while ignoring the cache. | 2714 // Reload the page while ignoring the cache. |
| 2719 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas
eURL + thirdURL), true); | 2715 Platform::current()->currentThread()->postTask( |
| 2720 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 2716 new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(),
toKURL(m_baseURL + thirdURL), true)); |
| 2717 Platform::current()->currentThread()->enterRunLoop(); |
| 2721 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); | 2718 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); |
| 2722 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); | 2719 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); |
| 2723 } | 2720 } |
| 2724 | 2721 |
| 2725 TEST_F(WebFrameTest, ReloadWhileProvisional) | 2722 TEST_F(WebFrameTest, ReloadWhileProvisional) |
| 2726 { | 2723 { |
| 2727 // Test that reloading while the previous load is still pending does not cau
se the initial | 2724 // Test that reloading while the previous load is still pending does not cau
se the initial |
| 2728 // request to get lost. | 2725 // request to get lost. |
| 2729 registerMockedHttpURLLoad("fixed_layout.html"); | 2726 registerMockedHttpURLLoad("fixed_layout.html"); |
| 2730 | 2727 |
| 2731 FrameTestHelpers::WebViewHelper webViewHelper; | 2728 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2732 webViewHelper.initialize(); | 2729 webViewHelper.initialize(); |
| 2733 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); | 2730 WebURLRequest request; |
| 2731 request.initialize(); |
| 2732 request.setURL(toKURL(m_baseURL + "fixed_layout.html")); |
| 2733 webViewHelper.webView()->mainFrame()->loadRequest(request); |
| 2734 // start reload before first request is delivered. | 2734 // start reload before first request is delivered. |
| 2735 webViewHelper.webView()->mainFrame()->reload(true); | 2735 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
| 2736 | |
| 2737 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 2738 | 2736 |
| 2739 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); | 2737 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); |
| 2740 ASSERT_TRUE(dataSource); | 2738 ASSERT_TRUE(dataSource); |
| 2741 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->reques
t().url().spec())); | 2739 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->reques
t().url().spec())); |
| 2742 } | 2740 } |
| 2743 | 2741 |
| 2744 TEST_F(WebFrameTest, AppendRedirects) | 2742 TEST_F(WebFrameTest, AppendRedirects) |
| 2745 { | 2743 { |
| 2746 const std::string firstURL = "about:blank"; | 2744 const std::string firstURL = "about:blank"; |
| 2747 const std::string secondURL = "http://www.test.com"; | 2745 const std::string secondURL = "http://www.test.com"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2760 EXPECT_EQ(toKURL(secondURL), toKURL(redirects[1].spec().data())); | 2758 EXPECT_EQ(toKURL(secondURL), toKURL(redirects[1].spec().data())); |
| 2761 } | 2759 } |
| 2762 | 2760 |
| 2763 TEST_F(WebFrameTest, IframeRedirect) | 2761 TEST_F(WebFrameTest, IframeRedirect) |
| 2764 { | 2762 { |
| 2765 registerMockedHttpURLLoad("iframe_redirect.html"); | 2763 registerMockedHttpURLLoad("iframe_redirect.html"); |
| 2766 registerMockedHttpURLLoad("visible_iframe.html"); | 2764 registerMockedHttpURLLoad("visible_iframe.html"); |
| 2767 | 2765 |
| 2768 FrameTestHelpers::WebViewHelper webViewHelper; | 2766 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2769 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); | 2767 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); |
| 2770 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); /
/ Load the iframe. | 2768 // Pump pending requests one more time. The test page loads script that navi
gates. |
| 2769 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
| 2770 Platform::current()->currentThread()->enterRunLoop(); |
| 2771 | 2771 |
| 2772 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU
TF8("ifr")); | 2772 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU
TF8("ifr")); |
| 2773 ASSERT_TRUE(iframe); | 2773 ASSERT_TRUE(iframe); |
| 2774 WebDataSource* iframeDataSource = iframe->dataSource(); | 2774 WebDataSource* iframeDataSource = iframe->dataSource(); |
| 2775 ASSERT_TRUE(iframeDataSource); | 2775 ASSERT_TRUE(iframeDataSource); |
| 2776 WebVector<WebURL> redirects; | 2776 WebVector<WebURL> redirects; |
| 2777 iframeDataSource->redirectChain(redirects); | 2777 iframeDataSource->redirectChain(redirects); |
| 2778 ASSERT_EQ(2U, redirects.size()); | 2778 ASSERT_EQ(2U, redirects.size()); |
| 2779 EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); | 2779 EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); |
| 2780 EXPECT_EQ(toKURL("http://www.test.com/visible_iframe.html"), toKURL(redirect
s[1].spec().data())); | 2780 EXPECT_EQ(toKURL("http://www.test.com/visible_iframe.html"), toKURL(redirect
s[1].spec().data())); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2901 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 2901 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 2902 | 2902 |
| 2903 registerMockedHttpURLLoad("context_notifications_test.html"); | 2903 registerMockedHttpURLLoad("context_notifications_test.html"); |
| 2904 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 2904 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
| 2905 | 2905 |
| 2906 ContextLifetimeTestWebFrameClient webFrameClient; | 2906 ContextLifetimeTestWebFrameClient webFrameClient; |
| 2907 FrameTestHelpers::WebViewHelper webViewHelper; | 2907 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2908 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); | 2908 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); |
| 2909 | 2909 |
| 2910 // Refresh, we should get two release notifications and two more create noti
fications. | 2910 // Refresh, we should get two release notifications and two more create noti
fications. |
| 2911 webViewHelper.webView()->mainFrame()->reload(false); | 2911 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
| 2912 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 2913 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); | 2912 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); |
| 2914 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 2913 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
| 2915 | 2914 |
| 2916 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. | 2915 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. |
| 2917 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 2916 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
| 2918 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( | 2917 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( |
| 2919 webFrameClient.createNotifications[webFrameClient.createNotifications.
size() - 3 - i])); | 2918 webFrameClient.createNotifications[webFrameClient.createNotifications.
size() - 3 - i])); |
| 2920 } | 2919 } |
| 2921 | 2920 |
| 2922 // The last two create notifications should be for the current frames and co
ntext. | 2921 // The last two create notifications should be for the current frames and co
ntext. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3040 FrameTestHelpers::WebViewHelper webViewHelper; | 3039 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3041 webViewHelper.initializeAndLoad("about:blank", true); | 3040 webViewHelper.initializeAndLoad("about:blank", true); |
| 3042 // We set the size because it impacts line wrapping, which changes the | 3041 // We set the size because it impacts line wrapping, which changes the |
| 3043 // resulting text value. | 3042 // resulting text value. |
| 3044 webViewHelper.webView()->resize(WebSize(640, 480)); | 3043 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3045 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3044 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 3046 | 3045 |
| 3047 // Generate a simple test case. | 3046 // Generate a simple test case. |
| 3048 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 3047 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
| 3049 WebCore::KURL testURL = toKURL("about:blank"); | 3048 WebCore::KURL testURL = toKURL("about:blank"); |
| 3050 frame->loadHTMLString(simpleSource, testURL); | 3049 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
| 3051 runPendingTasks(); | |
| 3052 | 3050 |
| 3053 // Make sure it comes out OK. | 3051 // Make sure it comes out OK. |
| 3054 const std::string expected("Foo bar\nbaz"); | 3052 const std::string expected("Foo bar\nbaz"); |
| 3055 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3053 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 3056 EXPECT_EQ(expected, text.utf8()); | 3054 EXPECT_EQ(expected, text.utf8()); |
| 3057 | 3055 |
| 3058 // Try reading the same one with clipping of the text. | 3056 // Try reading the same one with clipping of the text. |
| 3059 const int length = 5; | 3057 const int length = 5; |
| 3060 text = frame->contentAsText(length); | 3058 text = frame->contentAsText(length); |
| 3061 EXPECT_EQ(expected.substr(0, length), text.utf8()); | 3059 EXPECT_EQ(expected.substr(0, length), text.utf8()); |
| 3062 | 3060 |
| 3063 // Now do a new test with a subframe. | 3061 // Now do a new test with a subframe. |
| 3064 const char outerFrameSource[] = "Hello<iframe></iframe> world"; | 3062 const char outerFrameSource[] = "Hello<iframe></iframe> world"; |
| 3065 frame->loadHTMLString(outerFrameSource, testURL); | 3063 FrameTestHelpers::loadHTMLString(frame, outerFrameSource, testURL); |
| 3066 runPendingTasks(); | |
| 3067 | 3064 |
| 3068 // Load something into the subframe. | 3065 // Load something into the subframe. |
| 3069 WebFrame* subframe = frame->firstChild(); | 3066 WebFrame* subframe = frame->firstChild(); |
| 3070 ASSERT_TRUE(subframe); | 3067 ASSERT_TRUE(subframe); |
| 3071 subframe->loadHTMLString("sub<p>text", testURL); | 3068 FrameTestHelpers::loadHTMLString(subframe, "sub<p>text", testURL); |
| 3072 runPendingTasks(); | |
| 3073 | 3069 |
| 3074 text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3070 text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 3075 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); | 3071 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); |
| 3076 | 3072 |
| 3077 // Get the frame text where the subframe separator falls on the boundary of | 3073 // Get the frame text where the subframe separator falls on the boundary of |
| 3078 // what we'll take. There used to be a crash in this case. | 3074 // what we'll take. There used to be a crash in this case. |
| 3079 text = frame->contentAsText(12); | 3075 text = frame->contentAsText(12); |
| 3080 EXPECT_EQ("Hello world", text.utf8()); | 3076 EXPECT_EQ("Hello world", text.utf8()); |
| 3081 } | 3077 } |
| 3082 | 3078 |
| 3083 TEST_F(WebFrameTest, GetFullHtmlOfPage) | 3079 TEST_F(WebFrameTest, GetFullHtmlOfPage) |
| 3084 { | 3080 { |
| 3085 FrameTestHelpers::WebViewHelper webViewHelper; | 3081 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3086 webViewHelper.initializeAndLoad("about:blank", true); | 3082 webViewHelper.initializeAndLoad("about:blank", true); |
| 3087 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3083 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 3088 | 3084 |
| 3089 // Generate a simple test case. | 3085 // Generate a simple test case. |
| 3090 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 3086 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
| 3091 WebCore::KURL testURL = toKURL("about:blank"); | 3087 WebCore::KURL testURL = toKURL("about:blank"); |
| 3092 frame->loadHTMLString(simpleSource, testURL); | 3088 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
| 3093 runPendingTasks(); | |
| 3094 | 3089 |
| 3095 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3090 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 3096 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3091 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
| 3097 | 3092 |
| 3098 const std::string html = frame->contentAsMarkup().utf8(); | 3093 const std::string html = frame->contentAsMarkup().utf8(); |
| 3099 | 3094 |
| 3100 // Load again with the output html. | 3095 // Load again with the output html. |
| 3101 frame->loadHTMLString(WebData(html.c_str(), html.length()), testURL); | 3096 FrameTestHelpers::loadHTMLString(frame, html, testURL); |
| 3102 runPendingTasks(); | |
| 3103 | 3097 |
| 3104 EXPECT_EQ(html, frame->contentAsMarkup().utf8()); | 3098 EXPECT_EQ(html, frame->contentAsMarkup().utf8()); |
| 3105 | 3099 |
| 3106 text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3100 text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 3107 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3101 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
| 3108 | 3102 |
| 3109 // Test selection check | 3103 // Test selection check |
| 3110 EXPECT_FALSE(frame->hasSelection()); | 3104 EXPECT_FALSE(frame->hasSelection()); |
| 3111 frame->executeCommand(WebString::fromUTF8("SelectAll")); | 3105 frame->executeCommand(WebString::fromUTF8("SelectAll")); |
| 3112 EXPECT_TRUE(frame->hasSelection()); | 3106 EXPECT_TRUE(frame->hasSelection()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3125 }; | 3119 }; |
| 3126 | 3120 |
| 3127 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) | 3121 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) |
| 3128 { | 3122 { |
| 3129 registerMockedHttpURLLoad("hello_world.html"); | 3123 registerMockedHttpURLLoad("hello_world.html"); |
| 3130 | 3124 |
| 3131 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; | 3125 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; |
| 3132 FrameTestHelpers::WebViewHelper webViewHelper; | 3126 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3133 webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFr
ameClient); | 3127 webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFr
ameClient); |
| 3134 | 3128 |
| 3135 webViewHelper.webView()->mainFrame()->reload(); | 3129 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
| 3136 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 3137 } | 3130 } |
| 3138 | 3131 |
| 3139 class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 3132 class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 3140 public: | 3133 public: |
| 3141 FindUpdateWebFrameClient() | 3134 FindUpdateWebFrameClient() |
| 3142 : m_findResultsAreReady(false) | 3135 : m_findResultsAreReady(false) |
| 3143 , m_count(-1) | 3136 , m_count(-1) |
| 3144 { | 3137 { |
| 3145 } | 3138 } |
| 3146 | 3139 |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4082 private: | 4075 private: |
| 4083 bool m_commitCalled; | 4076 bool m_commitCalled; |
| 4084 }; | 4077 }; |
| 4085 | 4078 |
| 4086 TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) | 4079 TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) |
| 4087 { | 4080 { |
| 4088 TestSubstituteDataWebFrameClient webFrameClient; | 4081 TestSubstituteDataWebFrameClient webFrameClient; |
| 4089 | 4082 |
| 4090 FrameTestHelpers::WebViewHelper webViewHelper; | 4083 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4091 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); | 4084 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); |
| 4092 runPendingTasks(); | |
| 4093 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4085 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 4094 | 4086 |
| 4095 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient | 4087 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient |
| 4096 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. | 4088 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. |
| 4097 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting | 4089 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting |
| 4098 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. | 4090 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. |
| 4099 WebURLError error; | 4091 WebURLError error; |
| 4100 error.reason = 1337; | 4092 error.reason = 1337; |
| 4101 error.domain = "WebFrameTest"; | 4093 error.domain = "WebFrameTest"; |
| 4102 std::string errorURL = "http://0.0.0.0"; | 4094 std::string errorURL = "http://0.0.0.0"; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4529 TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) | 4521 TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) |
| 4530 { | 4522 { |
| 4531 TestAccessInitialDocumentWebFrameClient webFrameClient; | 4523 TestAccessInitialDocumentWebFrameClient webFrameClient; |
| 4532 FrameTestHelpers::WebViewHelper webViewHelper; | 4524 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4533 webViewHelper.initialize(true, &webFrameClient); | 4525 webViewHelper.initialize(true, &webFrameClient); |
| 4534 runPendingTasks(); | 4526 runPendingTasks(); |
| 4535 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 4527 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 4536 | 4528 |
| 4537 // Access the initial document from a javascript: URL. | 4529 // Access the initial document from a javascript: URL. |
| 4538 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Modified'))"); | 4530 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Modified'))"); |
| 4539 runPendingTasks(); | |
| 4540 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 4531 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
| 4541 } | 4532 } |
| 4542 | 4533 |
| 4543 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 | 4534 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 |
| 4544 #if OS(WIN) | 4535 #if OS(WIN) |
| 4545 TEST_F(WebFrameTest, DISABLED_DidAccessInitialDocumentBodyBeforeModalDialog) | 4536 TEST_F(WebFrameTest, DISABLED_DidAccessInitialDocumentBodyBeforeModalDialog) |
| 4546 #else | 4537 #else |
| 4547 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) | 4538 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) |
| 4548 #endif | 4539 #endif |
| 4549 { | 4540 { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4822 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 4813 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); |
| 4823 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); | 4814 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); |
| 4824 | 4815 |
| 4825 // ctrl+click event | 4816 // ctrl+click event |
| 4826 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, | 4817 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, |
| 4827 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); | 4818 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0
, nullptr, nullptr); |
| 4828 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); | 4819 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); |
| 4829 frameRequest.setTriggeringEvent(event); | 4820 frameRequest.setTriggeringEvent(event); |
| 4830 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 4821 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); |
| 4831 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 4822 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); |
| 4823 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
| 4832 | 4824 |
| 4833 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 4825 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
| 4834 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 4826 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
| 4835 } | 4827 } |
| 4836 | 4828 |
| 4837 TEST_F(WebFrameTest, BackToReload) | 4829 TEST_F(WebFrameTest, BackToReload) |
| 4838 { | 4830 { |
| 4839 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4831 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 4840 FrameTestHelpers::WebViewHelper webViewHelper; | 4832 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4841 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 4833 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
| 4842 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4834 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 4843 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4835 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
| 4844 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 4836 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); |
| 4845 EXPECT_TRUE(firstItem); | 4837 EXPECT_TRUE(firstItem); |
| 4846 | 4838 |
| 4847 registerMockedHttpURLLoad("white-1x1.png"); | 4839 registerMockedHttpURLLoad("white-1x1.png"); |
| 4848 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 4840 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
| 4849 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4850 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 4841 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
| 4851 | 4842 |
| 4852 frame->loadHistoryItem(WebHistoryItem(firstItem.get()), WebHistoryDifferentD
ocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 4843 frame->loadHistoryItem(WebHistoryItem(firstItem.get()), WebHistoryDifferentD
ocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
| 4853 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 4844 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
| 4854 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 4845 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
| 4855 | 4846 |
| 4856 frame->reload(); | 4847 FrameTestHelpers::reloadFrame(frame); |
| 4857 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4858 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 4848 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
| 4859 } | 4849 } |
| 4860 | 4850 |
| 4861 TEST_F(WebFrameTest, BackDuringChildFrameReload) | 4851 TEST_F(WebFrameTest, BackDuringChildFrameReload) |
| 4862 { | 4852 { |
| 4863 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 4853 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
| 4864 FrameTestHelpers::WebViewHelper webViewHelper; | 4854 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4865 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 4855 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
| 4866 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 4856 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
| 4867 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4857 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
| 4868 WebFrame* childFrame = mainFrame->firstChild(); | 4858 WebFrame* childFrame = mainFrame->firstChild(); |
| 4869 ASSERT_TRUE(childFrame); | 4859 ASSERT_TRUE(childFrame); |
| 4870 | 4860 |
| 4871 // Start a history navigation, then have a different frame commit a navigati
on. | 4861 // Start a history navigation, then have a different frame commit a navigati
on. |
| 4872 // In this case, reload an about:blank frame, which will commit synchronousl
y. | 4862 // In this case, reload an about:blank frame, which will commit synchronousl
y. |
| 4873 // After the history navigation completes, both the appropriate document url
and | 4863 // After the history navigation completes, both the appropriate document url
and |
| 4874 // the current history item should reflect the history navigation. | 4864 // the current history item should reflect the history navigation. |
| 4875 registerMockedHttpURLLoad("white-1x1.png"); | 4865 registerMockedHttpURLLoad("white-1x1.png"); |
| 4876 WebHistoryItem item; | 4866 WebHistoryItem item; |
| 4877 item.initialize(); | 4867 item.initialize(); |
| 4878 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 4868 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
| 4879 item.setURLString(historyURL.string()); | 4869 item.setURLString(historyURL.string()); |
| 4880 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequ
est::UseProtocolCachePolicy); | 4870 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequ
est::UseProtocolCachePolicy); |
| 4881 | 4871 |
| 4882 childFrame->reload(); | 4872 FrameTestHelpers::reloadFrame(childFrame); |
| 4883 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4884 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); | 4873 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); |
| 4885 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); | 4874 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); |
| 4886 } | 4875 } |
| 4887 | 4876 |
| 4888 TEST_F(WebFrameTest, ReloadPost) | 4877 TEST_F(WebFrameTest, ReloadPost) |
| 4889 { | 4878 { |
| 4890 registerMockedHttpURLLoad("reload_post.html"); | 4879 registerMockedHttpURLLoad("reload_post.html"); |
| 4891 FrameTestHelpers::WebViewHelper webViewHelper; | 4880 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4892 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 4881 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
| 4893 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4882 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 4894 | 4883 |
| 4895 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); | 4884 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); |
| 4896 runPendingTasks(); | |
| 4897 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4898 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); | 4885 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); |
| 4899 | 4886 |
| 4900 frame->reload(); | 4887 FrameTestHelpers::reloadFrame(frame); |
| 4901 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4902 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 4888 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
| 4903 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 4889 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
| 4904 } | 4890 } |
| 4905 | 4891 |
| 4906 TEST_F(WebFrameTest, LoadHistoryItemReload) | 4892 TEST_F(WebFrameTest, LoadHistoryItemReload) |
| 4907 { | 4893 { |
| 4908 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4894 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 4909 FrameTestHelpers::WebViewHelper webViewHelper; | 4895 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4910 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 4896 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
| 4911 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4897 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 4912 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4898 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
| 4913 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 4899 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); |
| 4914 EXPECT_TRUE(firstItem); | 4900 EXPECT_TRUE(firstItem); |
| 4915 | 4901 |
| 4916 registerMockedHttpURLLoad("white-1x1.png"); | 4902 registerMockedHttpURLLoad("white-1x1.png"); |
| 4917 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 4903 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
| 4918 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4919 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 4904 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
| 4920 | 4905 |
| 4921 // Cache policy overrides should take. | 4906 // Cache policy overrides should take. |
| 4922 frame->loadHistoryItem(WebHistoryItem(firstItem), WebHistoryDifferentDocumen
tLoad, WebURLRequest::ReloadIgnoringCacheData); | 4907 frame->loadHistoryItem(WebHistoryItem(firstItem), WebHistoryDifferentDocumen
tLoad, WebURLRequest::ReloadIgnoringCacheData); |
| 4923 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 4908 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
| 4924 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 4909 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
| 4925 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 4910 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
| 4926 } | 4911 } |
| 4927 | 4912 |
| 4928 | 4913 |
| 4929 class TestCachePolicyWebFrameClient : public WebFrameClient { | 4914 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien
t { |
| 4930 public: | 4915 public: |
| 4931 TestCachePolicyWebFrameClient() | 4916 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent
Client) |
| 4932 : m_policy(WebURLRequest::UseProtocolCachePolicy) | 4917 : m_parentClient(parentClient) |
| 4933 , m_client(0) | 4918 , m_policy(WebURLRequest::UseProtocolCachePolicy) |
| 4919 , m_childClient(0) |
| 4934 , m_willSendRequestCallCount(0) | 4920 , m_willSendRequestCallCount(0) |
| 4935 , m_childFrameCreationCount(0) | 4921 , m_childFrameCreationCount(0) |
| 4936 { | 4922 { |
| 4937 } | 4923 } |
| 4938 | 4924 |
| 4939 void setChildWebFrameClient(WebFrameClient* client) { m_client = client; } | 4925 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } |
| 4940 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 4926 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } |
| 4941 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 4927 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
| 4942 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 4928 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
| 4943 | 4929 |
| 4944 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString&) | 4930 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString&) |
| 4945 { | 4931 { |
| 4932 ASSERT(m_childClient); |
| 4946 m_childFrameCreationCount++; | 4933 m_childFrameCreationCount++; |
| 4947 WebFrame* frame = WebLocalFrame::create(m_client); | 4934 WebFrame* frame = WebLocalFrame::create(m_childClient); |
| 4948 parent->appendChild(frame); | 4935 parent->appendChild(frame); |
| 4949 return frame; | 4936 return frame; |
| 4950 } | 4937 } |
| 4951 | 4938 |
| 4952 virtual void frameDetached(WebFrame* frame) OVERRIDE | 4939 virtual void didStartLoading(bool toDifferentDocument) |
| 4953 { | 4940 { |
| 4954 if (frame->parent()) | 4941 if (m_parentClient) { |
| 4955 frame->parent()->removeChild(frame); | 4942 m_parentClient->didStartLoading(toDifferentDocument); |
| 4956 frame->close(); | 4943 return; |
| 4944 } |
| 4945 TestWebFrameClient::didStartLoading(toDifferentDocument); |
| 4946 } |
| 4947 |
| 4948 virtual void didStopLoading() |
| 4949 { |
| 4950 if (m_parentClient) { |
| 4951 m_parentClient->didStopLoading(); |
| 4952 return; |
| 4953 } |
| 4954 TestWebFrameClient::didStopLoading(); |
| 4957 } | 4955 } |
| 4958 | 4956 |
| 4959 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) OVERRIDE | 4957 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) OVERRIDE |
| 4960 { | 4958 { |
| 4961 m_policy = request.cachePolicy(); | 4959 m_policy = request.cachePolicy(); |
| 4962 m_willSendRequestCallCount++; | 4960 m_willSendRequestCallCount++; |
| 4963 } | 4961 } |
| 4964 | 4962 |
| 4965 private: | 4963 private: |
| 4964 TestCachePolicyWebFrameClient* m_parentClient; |
| 4965 |
| 4966 WebURLRequest::CachePolicy m_policy; | 4966 WebURLRequest::CachePolicy m_policy; |
| 4967 WebFrameClient* m_client; | 4967 TestCachePolicyWebFrameClient* m_childClient; |
| 4968 int m_willSendRequestCallCount; | 4968 int m_willSendRequestCallCount; |
| 4969 int m_childFrameCreationCount; | 4969 int m_childFrameCreationCount; |
| 4970 }; | 4970 }; |
| 4971 | 4971 |
| 4972 TEST_F(WebFrameTest, ReloadIframe) | 4972 TEST_F(WebFrameTest, ReloadIframe) |
| 4973 { | 4973 { |
| 4974 registerMockedHttpURLLoad("iframe_reload.html"); | 4974 registerMockedHttpURLLoad("iframe_reload.html"); |
| 4975 registerMockedHttpURLLoad("visible_iframe.html"); | 4975 registerMockedHttpURLLoad("visible_iframe.html"); |
| 4976 TestCachePolicyWebFrameClient mainClient; | 4976 TestCachePolicyWebFrameClient mainClient(0); |
| 4977 TestCachePolicyWebFrameClient childClient; | 4977 TestCachePolicyWebFrameClient childClient(&mainClient); |
| 4978 mainClient.setChildWebFrameClient(&childClient); | 4978 mainClient.setChildWebFrameClient(&childClient); |
| 4979 | 4979 |
| 4980 FrameTestHelpers::WebViewHelper webViewHelper; | 4980 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4981 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 4981 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
| 4982 | 4982 |
| 4983 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 4983 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
| 4984 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); | 4984 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); |
| 4985 ASSERT_EQ(childFrame->client(), &childClient); | 4985 ASSERT_EQ(childFrame->client(), &childClient); |
| 4986 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 4986 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
| 4987 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 4987 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
| 4988 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); | 4988 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); |
| 4989 | 4989 |
| 4990 mainFrame->reload(false); | 4990 FrameTestHelpers::reloadFrame(mainFrame); |
| 4991 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 4992 | 4991 |
| 4993 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 4992 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
| 4994 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 4993 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
| 4995 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); | 4994 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
| 4996 | 4995 |
| 4997 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 4996 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
| 4998 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 4997 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
| 4999 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; | 4998 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; |
| 5000 } | 4999 } |
| 5001 | 5000 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5036 TEST_F(WebFrameTest, WebNodeImageContents) | 5035 TEST_F(WebFrameTest, WebNodeImageContents) |
| 5037 { | 5036 { |
| 5038 FrameTestHelpers::WebViewHelper webViewHelper; | 5037 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5039 webViewHelper.initializeAndLoad("about:blank", true); | 5038 webViewHelper.initializeAndLoad("about:blank", true); |
| 5040 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5039 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5041 | 5040 |
| 5042 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; | 5041 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
| 5043 | 5042 |
| 5044 // Load up the image and test that we can extract the contents. | 5043 // Load up the image and test that we can extract the contents. |
| 5045 WebCore::KURL testURL = toKURL("about:blank"); | 5044 WebCore::KURL testURL = toKURL("about:blank"); |
| 5046 frame->loadHTMLString(bluePNG, testURL); | 5045 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); |
| 5047 runPendingTasks(); | |
| 5048 | 5046 |
| 5049 WebNode node = frame->document().body().firstChild(); | 5047 WebNode node = frame->document().body().firstChild(); |
| 5050 EXPECT_TRUE(node.isElementNode()); | 5048 EXPECT_TRUE(node.isElementNode()); |
| 5051 WebElement element = node.to<WebElement>(); | 5049 WebElement element = node.to<WebElement>(); |
| 5052 WebImage image = element.imageContents(); | 5050 WebImage image = element.imageContents(); |
| 5053 ASSERT_FALSE(image.isNull()); | 5051 ASSERT_FALSE(image.isNull()); |
| 5054 EXPECT_EQ(image.size().width, 10); | 5052 EXPECT_EQ(image.size().width, 10); |
| 5055 EXPECT_EQ(image.size().height, 10); | 5053 EXPECT_EQ(image.size().height, 10); |
| 5056 // FIXME: The rest of this test is disabled since the ImageDecodeCache state
may be inconsistent when this test runs. | 5054 // FIXME: The rest of this test is disabled since the ImageDecodeCache state
may be inconsistent when this test runs. |
| 5057 // crbug.com/266088 | 5055 // crbug.com/266088 |
| 5058 // SkBitmap bitmap = image.getSkBitmap(); | 5056 // SkBitmap bitmap = image.getSkBitmap(); |
| 5059 // SkAutoLockPixels locker(bitmap); | 5057 // SkAutoLockPixels locker(bitmap); |
| 5060 // EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); | 5058 // EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); |
| 5061 } | 5059 } |
| 5062 | 5060 |
| 5063 class TestStartStopCallbackWebFrameClient : public WebFrameClient { | 5061 class TestStartStopCallbackWebFrameClient : public FrameTestHelpers::TestWebFram
eClient { |
| 5064 public: | 5062 public: |
| 5065 TestStartStopCallbackWebFrameClient() | 5063 TestStartStopCallbackWebFrameClient() |
| 5066 : m_startLoadingCount(0) | 5064 : m_startLoadingCount(0) |
| 5067 , m_stopLoadingCount(0) | 5065 , m_stopLoadingCount(0) |
| 5068 , m_differentDocumentStartCount(0) | 5066 , m_differentDocumentStartCount(0) |
| 5069 { | 5067 { |
| 5070 } | 5068 } |
| 5071 | 5069 |
| 5072 virtual void didStartLoading(bool toDifferentDocument) OVERRIDE | 5070 virtual void didStartLoading(bool toDifferentDocument) OVERRIDE |
| 5073 { | 5071 { |
| 5072 TestWebFrameClient::didStartLoading(toDifferentDocument); |
| 5074 m_startLoadingCount++; | 5073 m_startLoadingCount++; |
| 5075 if (toDifferentDocument) | 5074 if (toDifferentDocument) |
| 5076 m_differentDocumentStartCount++; | 5075 m_differentDocumentStartCount++; |
| 5077 } | 5076 } |
| 5078 | 5077 |
| 5079 virtual void didStopLoading() OVERRIDE | 5078 virtual void didStopLoading() OVERRIDE |
| 5080 { | 5079 { |
| 5080 TestWebFrameClient::didStopLoading(); |
| 5081 m_stopLoadingCount++; | 5081 m_stopLoadingCount++; |
| 5082 } | 5082 } |
| 5083 | 5083 |
| 5084 int startLoadingCount() const { return m_startLoadingCount; } | 5084 int startLoadingCount() const { return m_startLoadingCount; } |
| 5085 int stopLoadingCount() const { return m_stopLoadingCount; } | 5085 int stopLoadingCount() const { return m_stopLoadingCount; } |
| 5086 int differentDocumentStartCount() const { return m_differentDocumentStartCou
nt; } | 5086 int differentDocumentStartCount() const { return m_differentDocumentStartCou
nt; } |
| 5087 | 5087 |
| 5088 private: | 5088 private: |
| 5089 int m_startLoadingCount; | 5089 int m_startLoadingCount; |
| 5090 int m_stopLoadingCount; | 5090 int m_stopLoadingCount; |
| 5091 int m_differentDocumentStartCount; | 5091 int m_differentDocumentStartCount; |
| 5092 }; | 5092 }; |
| 5093 | 5093 |
| 5094 TEST_F(WebFrameTest, PushStateStartsAndStops) | 5094 TEST_F(WebFrameTest, PushStateStartsAndStops) |
| 5095 { | 5095 { |
| 5096 registerMockedHttpURLLoad("push_state.html"); | 5096 registerMockedHttpURLLoad("push_state.html"); |
| 5097 TestStartStopCallbackWebFrameClient client; | 5097 TestStartStopCallbackWebFrameClient client; |
| 5098 FrameTestHelpers::WebViewHelper webViewHelper; | 5098 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5099 webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client
); | 5099 webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client
); |
| 5100 runPendingTasks(); | |
| 5101 | 5100 |
| 5102 EXPECT_EQ(client.startLoadingCount(), 2); | 5101 EXPECT_EQ(client.startLoadingCount(), 2); |
| 5103 EXPECT_EQ(client.stopLoadingCount(), 2); | 5102 EXPECT_EQ(client.stopLoadingCount(), 2); |
| 5104 EXPECT_EQ(client.differentDocumentStartCount(), 1); | 5103 EXPECT_EQ(client.differentDocumentStartCount(), 1); |
| 5105 } | 5104 } |
| 5106 | 5105 |
| 5107 class TestHistoryWebFrameClient : public WebFrameClient { | 5106 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 5108 public: | 5107 public: |
| 5109 TestHistoryWebFrameClient() | 5108 TestHistoryWebFrameClient() |
| 5110 { | 5109 { |
| 5111 m_replacesCurrentHistoryItem = false; | 5110 m_replacesCurrentHistoryItem = false; |
| 5112 m_frame = 0; | 5111 m_frame = 0; |
| 5113 } | 5112 } |
| 5114 void didStartProvisionalLoad(WebLocalFrame* frame) | 5113 void didStartProvisionalLoad(WebLocalFrame* frame) |
| 5115 { | 5114 { |
| 5116 WebDataSource* ds = frame->provisionalDataSource(); | 5115 WebDataSource* ds = frame->provisionalDataSource(); |
| 5117 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | 5116 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5129 // Test which ensures that the first navigation in a subframe will always | 5128 // Test which ensures that the first navigation in a subframe will always |
| 5130 // result in history entry being replaced and not a new one added. | 5129 // result in history entry being replaced and not a new one added. |
| 5131 TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory) | 5130 TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory) |
| 5132 { | 5131 { |
| 5133 registerMockedHttpURLLoad("history.html"); | 5132 registerMockedHttpURLLoad("history.html"); |
| 5134 registerMockedHttpURLLoad("find.html"); | 5133 registerMockedHttpURLLoad("find.html"); |
| 5135 | 5134 |
| 5136 FrameTestHelpers::WebViewHelper webViewHelper; | 5135 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5137 TestHistoryWebFrameClient client; | 5136 TestHistoryWebFrameClient client; |
| 5138 webViewHelper.initializeAndLoad("about:blank", true, &client); | 5137 webViewHelper.initializeAndLoad("about:blank", true, &client); |
| 5139 runPendingTasks(); | |
| 5140 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5138 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| 5141 | 5139 |
| 5142 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5140 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5143 | 5141 |
| 5144 FrameTestHelpers::loadFrame(frame, | 5142 FrameTestHelpers::loadFrame(frame, |
| 5145 "javascript:document.body.appendChild(document.createElement('iframe'))"
); | 5143 "javascript:document.body.appendChild(document.createElement('iframe'))"
); |
| 5146 // Need to call runPendingTasks in order for the JavaScript above to be | |
| 5147 // evaluated and executed. | |
| 5148 runPendingTasks(); | |
| 5149 WebFrame* iframe = frame->firstChild(); | 5144 WebFrame* iframe = frame->firstChild(); |
| 5150 EXPECT_EQ(client.frame(), iframe); | 5145 EXPECT_EQ(client.frame(), iframe); |
| 5151 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5146 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| 5152 | 5147 |
| 5153 FrameTestHelpers::loadFrame(frame, | 5148 FrameTestHelpers::loadFrame(frame, |
| 5154 "javascript:window.frames[0].location.assign('" + m_baseURL + "history.h
tml')"); | 5149 "javascript:window.frames[0].location.assign('" + m_baseURL + "history.h
tml')"); |
| 5155 runPendingTasks(); | |
| 5156 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 5157 EXPECT_EQ(client.frame(), iframe); | 5150 EXPECT_EQ(client.frame(), iframe); |
| 5158 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5151 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| 5159 | 5152 |
| 5160 FrameTestHelpers::loadFrame(frame, | 5153 FrameTestHelpers::loadFrame(frame, |
| 5161 "javascript:window.frames[0].location.assign('" + m_baseURL + "find.html
')"); | 5154 "javascript:window.frames[0].location.assign('" + m_baseURL + "find.html
')"); |
| 5162 runPendingTasks(); | |
| 5163 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 5164 EXPECT_EQ(client.frame(), iframe); | 5155 EXPECT_EQ(client.frame(), iframe); |
| 5165 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 5156 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 5166 | 5157 |
| 5167 // Repeat the test, but start out the iframe with initial URL, which is not | 5158 // Repeat the test, but start out the iframe with initial URL, which is not |
| 5168 // "about:blank". | 5159 // "about:blank". |
| 5169 FrameTestHelpers::loadFrame(frame, | 5160 FrameTestHelpers::loadFrame(frame, |
| 5170 "javascript:var f = document.createElement('iframe'); " | 5161 "javascript:var f = document.createElement('iframe'); " |
| 5171 "f.src = '" + m_baseURL + "history.html';" | 5162 "f.src = '" + m_baseURL + "history.html';" |
| 5172 "document.body.appendChild(f)"); | 5163 "document.body.appendChild(f)"); |
| 5173 runPendingTasks(); | |
| 5174 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 5175 | 5164 |
| 5176 iframe = frame->firstChild()->nextSibling(); | 5165 iframe = frame->firstChild()->nextSibling(); |
| 5177 EXPECT_EQ(client.frame(), iframe); | 5166 EXPECT_EQ(client.frame(), iframe); |
| 5178 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5167 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| 5179 | 5168 |
| 5180 FrameTestHelpers::loadFrame(frame, | 5169 FrameTestHelpers::loadFrame(frame, |
| 5181 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html
')"); | 5170 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html
')"); |
| 5182 runPendingTasks(); | |
| 5183 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 5184 EXPECT_EQ(client.frame(), iframe); | 5171 EXPECT_EQ(client.frame(), iframe); |
| 5185 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 5172 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 5186 } | 5173 } |
| 5187 | 5174 |
| 5188 // Test verifies that layout will change a layer's scrollable attibutes | 5175 // Test verifies that layout will change a layer's scrollable attibutes |
| 5189 TEST_F(WebFrameTest, overflowHiddenRewrite) | 5176 TEST_F(WebFrameTest, overflowHiddenRewrite) |
| 5190 { | 5177 { |
| 5191 registerMockedHttpURLLoad("non-scrollable.html"); | 5178 registerMockedHttpURLLoad("non-scrollable.html"); |
| 5192 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 5179 TestMainFrameUserOrProgrammaticScrollFrameClient client; |
| 5193 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 5180 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
| 5194 FrameTestHelpers::WebViewHelper webViewHelper; | 5181 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5195 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 5182 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
| 5196 | 5183 |
| 5197 webViewHelper.webView()->resize(WebSize(100, 100)); | 5184 webViewHelper.webView()->resize(WebSize(100, 100)); |
| 5198 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); | 5185 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); |
| 5199 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
| 5200 webViewHelper.webView()->layout(); | |
| 5201 | 5186 |
| 5202 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); | 5187 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); |
| 5203 ASSERT_TRUE(compositor->scrollLayer()); | 5188 ASSERT_TRUE(compositor->scrollLayer()); |
| 5204 | 5189 |
| 5205 // Verify that the WebLayer is not scrollable initially. | 5190 // Verify that the WebLayer is not scrollable initially. |
| 5206 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); | 5191 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
| 5207 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 5192 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| 5208 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 5193 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
| 5209 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | 5194 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); |
| 5210 | 5195 |
| 5211 // Call javascript to make the layer scrollable, and verify it. | 5196 // Call javascript to make the layer scrollable, and verify it. |
| 5212 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); | 5197 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); |
| 5213 frame->executeScript(WebScriptSource("allowScroll();")); | 5198 frame->executeScript(WebScriptSource("allowScroll();")); |
| 5214 webViewHelper.webView()->layout(); | 5199 webViewHelper.webView()->layout(); |
| 5215 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 5200 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
| 5216 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 5201 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| 5217 } | 5202 } |
| 5218 | 5203 |
| 5219 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 5204 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. |
| 5220 TEST_F(WebFrameTest, CurrentHistoryItem) | 5205 TEST_F(WebFrameTest, CurrentHistoryItem) |
| 5221 { | 5206 { |
| 5222 registerMockedHttpURLLoad("fixed_layout.html"); | 5207 registerMockedHttpURLLoad("fixed_layout.html"); |
| 5223 std::string url = m_baseURL + "fixed_layout.html"; | 5208 std::string url = m_baseURL + "fixed_layout.html"; |
| 5224 | 5209 |
| 5225 FrameTestHelpers::WebViewHelper webViewHelper; | 5210 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5226 webViewHelper.initialize(); | 5211 webViewHelper.initialize(); |
| 5227 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5212 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5228 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 5213 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
| 5229 FrameTestHelpers::loadFrame(frame, url); | 5214 WebURLRequest request; |
| 5215 request.initialize(); |
| 5216 request.setURL(toKURL(url)); |
| 5217 frame->loadRequest(request); |
| 5230 | 5218 |
| 5231 // Before commit, there is no history item. | 5219 // Before commit, there is no history item. |
| 5232 EXPECT_FALSE(mainFrameLoader.currentItem()); | 5220 EXPECT_FALSE(mainFrameLoader.currentItem()); |
| 5233 | 5221 |
| 5234 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 5222 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
| 5223 Platform::current()->currentThread()->enterRunLoop(); |
| 5235 | 5224 |
| 5236 // After commit, there is. | 5225 // After commit, there is. |
| 5237 WebCore::HistoryItem* item = mainFrameLoader.currentItem(); | 5226 WebCore::HistoryItem* item = mainFrameLoader.currentItem(); |
| 5238 ASSERT_TRUE(item); | 5227 ASSERT_TRUE(item); |
| 5239 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 5228 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
| 5240 } | 5229 } |
| 5241 | 5230 |
| 5242 class FailCreateChildFrame : public WebFrameClient { | 5231 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
| 5243 public: | 5232 public: |
| 5244 FailCreateChildFrame() : m_callCount(0) { } | 5233 FailCreateChildFrame() : m_callCount(0) { } |
| 5245 | 5234 |
| 5246 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE | 5235 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE |
| 5247 { | 5236 { |
| 5248 ++m_callCount; | 5237 ++m_callCount; |
| 5249 return 0; | 5238 return 0; |
| 5250 } | 5239 } |
| 5251 | 5240 |
| 5252 virtual void frameDetached(WebFrame* frame) OVERRIDE | |
| 5253 { | |
| 5254 frame->close(); | |
| 5255 } | |
| 5256 | |
| 5257 int callCount() const { return m_callCount; } | 5241 int callCount() const { return m_callCount; } |
| 5258 | 5242 |
| 5259 private: | 5243 private: |
| 5260 int m_callCount; | 5244 int m_callCount; |
| 5261 }; | 5245 }; |
| 5262 | 5246 |
| 5263 // Test that we don't crash if WebFrameClient::createChildFrame() fails. | 5247 // Test that we don't crash if WebFrameClient::createChildFrame() fails. |
| 5264 TEST_F(WebFrameTest, CreateChildFrameFailure) | 5248 TEST_F(WebFrameTest, CreateChildFrameFailure) |
| 5265 { | 5249 { |
| 5266 registerMockedHttpURLLoad("create_child_frame_fail.html"); | 5250 registerMockedHttpURLLoad("create_child_frame_fail.html"); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5422 registerMockedHttpURLLoad("link-manifest-change.html"); | 5406 registerMockedHttpURLLoad("link-manifest-change.html"); |
| 5423 | 5407 |
| 5424 ManifestChangeWebFrameClient webFrameClient; | 5408 ManifestChangeWebFrameClient webFrameClient; |
| 5425 FrameTestHelpers::WebViewHelper webViewHelper; | 5409 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5426 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); | 5410 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); |
| 5427 | 5411 |
| 5428 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); | 5412 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); |
| 5429 } | 5413 } |
| 5430 | 5414 |
| 5431 } // namespace | 5415 } // namespace |
| OLD | NEW |