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 } |
| 2677 |
| 2678 private: |
| 2679 WebFrame* const m_frame; |
| 2680 const WebCore::KURL m_url; |
| 2681 const bool m_ignoreCache; |
| 2682 }; |
| 2683 |
2690 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) | 2684 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) |
2691 { | 2685 { |
2692 const std::string firstURL = "find.html"; | 2686 const std::string firstURL = "find.html"; |
2693 const std::string secondURL = "form.html"; | 2687 const std::string secondURL = "form.html"; |
2694 const std::string thirdURL = "history.html"; | 2688 const std::string thirdURL = "history.html"; |
2695 const float pageScaleFactor = 1.1684f; | 2689 const float pageScaleFactor = 1.1684f; |
2696 const int pageWidth = 640; | 2690 const int pageWidth = 640; |
2697 const int pageHeight = 480; | 2691 const int pageHeight = 480; |
2698 | 2692 |
2699 registerMockedHttpURLLoad(firstURL); | 2693 registerMockedHttpURLLoad(firstURL); |
2700 registerMockedHttpURLLoad(secondURL); | 2694 registerMockedHttpURLLoad(secondURL); |
2701 registerMockedHttpURLLoad(thirdURL); | 2695 registerMockedHttpURLLoad(thirdURL); |
2702 | 2696 |
2703 FrameTestHelpers::WebViewHelper webViewHelper; | 2697 FrameTestHelpers::WebViewHelper webViewHelper; |
2704 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); | 2698 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); |
2705 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); | 2699 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); |
2706 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth
/ 4, pageHeight / 4)); | 2700 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth
/ 4, pageHeight / 4)); |
2707 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); | 2701 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); |
2708 | 2702 |
2709 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff
set(); | 2703 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff
set(); |
2710 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); | 2704 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); |
2711 | 2705 |
2712 // Reload the page using the cache. | 2706 // Reload the page using the cache. |
2713 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas
eURL + secondURL), false); | 2707 Platform::current()->currentThread()->postTask( |
2714 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 2708 new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(),
toKURL(m_baseURL + secondURL), false)); |
| 2709 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); |
2715 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); | 2710 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); |
2716 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); | 2711 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); |
2717 | 2712 |
2718 // Reload the page while ignoring the cache. | 2713 // Reload the page while ignoring the cache. |
2719 webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_bas
eURL + thirdURL), true); | 2714 Platform::current()->currentThread()->postTask( |
2720 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 2715 new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(),
toKURL(m_baseURL + thirdURL), true)); |
| 2716 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); |
2721 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); | 2717 ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOf
fset()); |
2722 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); | 2718 ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); |
2723 } | 2719 } |
2724 | 2720 |
2725 TEST_F(WebFrameTest, ReloadWhileProvisional) | 2721 TEST_F(WebFrameTest, ReloadWhileProvisional) |
2726 { | 2722 { |
2727 // Test that reloading while the previous load is still pending does not cau
se the initial | 2723 // Test that reloading while the previous load is still pending does not cau
se the initial |
2728 // request to get lost. | 2724 // request to get lost. |
2729 registerMockedHttpURLLoad("fixed_layout.html"); | 2725 registerMockedHttpURLLoad("fixed_layout.html"); |
2730 | 2726 |
2731 FrameTestHelpers::WebViewHelper webViewHelper; | 2727 FrameTestHelpers::WebViewHelper webViewHelper; |
2732 webViewHelper.initialize(); | 2728 webViewHelper.initialize(); |
2733 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "fixed_layout.html"); | 2729 WebURLRequest request; |
| 2730 request.initialize(); |
| 2731 request.setURL(toKURL(m_baseURL + "fixed_layout.html")); |
| 2732 webViewHelper.webView()->mainFrame()->loadRequest(request); |
2734 // start reload before first request is delivered. | 2733 // start reload before first request is delivered. |
2735 webViewHelper.webView()->mainFrame()->reload(true); | 2734 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram
e()); |
2736 | |
2737 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
2738 | 2735 |
2739 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); | 2736 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource
(); |
2740 ASSERT_TRUE(dataSource); | 2737 ASSERT_TRUE(dataSource); |
2741 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->reques
t().url().spec())); | 2738 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->reques
t().url().spec())); |
2742 } | 2739 } |
2743 | 2740 |
2744 TEST_F(WebFrameTest, AppendRedirects) | 2741 TEST_F(WebFrameTest, AppendRedirects) |
2745 { | 2742 { |
2746 const std::string firstURL = "about:blank"; | 2743 const std::string firstURL = "about:blank"; |
2747 const std::string secondURL = "http://www.test.com"; | 2744 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())); | 2757 EXPECT_EQ(toKURL(secondURL), toKURL(redirects[1].spec().data())); |
2761 } | 2758 } |
2762 | 2759 |
2763 TEST_F(WebFrameTest, IframeRedirect) | 2760 TEST_F(WebFrameTest, IframeRedirect) |
2764 { | 2761 { |
2765 registerMockedHttpURLLoad("iframe_redirect.html"); | 2762 registerMockedHttpURLLoad("iframe_redirect.html"); |
2766 registerMockedHttpURLLoad("visible_iframe.html"); | 2763 registerMockedHttpURLLoad("visible_iframe.html"); |
2767 | 2764 |
2768 FrameTestHelpers::WebViewHelper webViewHelper; | 2765 FrameTestHelpers::WebViewHelper webViewHelper; |
2769 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); | 2766 webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true); |
2770 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); /
/ Load the iframe. | 2767 // Pump pending requests one more time. The test page loads script that navi
gates. |
| 2768 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
2771 | 2769 |
2772 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU
TF8("ifr")); | 2770 WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromU
TF8("ifr")); |
2773 ASSERT_TRUE(iframe); | 2771 ASSERT_TRUE(iframe); |
2774 WebDataSource* iframeDataSource = iframe->dataSource(); | 2772 WebDataSource* iframeDataSource = iframe->dataSource(); |
2775 ASSERT_TRUE(iframeDataSource); | 2773 ASSERT_TRUE(iframeDataSource); |
2776 WebVector<WebURL> redirects; | 2774 WebVector<WebURL> redirects; |
2777 iframeDataSource->redirectChain(redirects); | 2775 iframeDataSource->redirectChain(redirects); |
2778 ASSERT_EQ(2U, redirects.size()); | 2776 ASSERT_EQ(2U, redirects.size()); |
2779 EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); | 2777 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())); | 2778 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()); | 2899 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
2902 | 2900 |
2903 registerMockedHttpURLLoad("context_notifications_test.html"); | 2901 registerMockedHttpURLLoad("context_notifications_test.html"); |
2904 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 2902 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
2905 | 2903 |
2906 ContextLifetimeTestWebFrameClient webFrameClient; | 2904 ContextLifetimeTestWebFrameClient webFrameClient; |
2907 FrameTestHelpers::WebViewHelper webViewHelper; | 2905 FrameTestHelpers::WebViewHelper webViewHelper; |
2908 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); | 2906 webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html
", true, &webFrameClient); |
2909 | 2907 |
2910 // Refresh, we should get two release notifications and two more create noti
fications. | 2908 // Refresh, we should get two release notifications and two more create noti
fications. |
2911 webViewHelper.webView()->mainFrame()->reload(false); | 2909 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
2912 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
2913 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); | 2910 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); |
2914 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 2911 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
2915 | 2912 |
2916 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. | 2913 // 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) { | 2914 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
2918 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( | 2915 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( |
2919 webFrameClient.createNotifications[webFrameClient.createNotifications.
size() - 3 - i])); | 2916 webFrameClient.createNotifications[webFrameClient.createNotifications.
size() - 3 - i])); |
2920 } | 2917 } |
2921 | 2918 |
2922 // The last two create notifications should be for the current frames and co
ntext. | 2919 // 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; | 3037 FrameTestHelpers::WebViewHelper webViewHelper; |
3041 webViewHelper.initializeAndLoad("about:blank", true); | 3038 webViewHelper.initializeAndLoad("about:blank", true); |
3042 // We set the size because it impacts line wrapping, which changes the | 3039 // We set the size because it impacts line wrapping, which changes the |
3043 // resulting text value. | 3040 // resulting text value. |
3044 webViewHelper.webView()->resize(WebSize(640, 480)); | 3041 webViewHelper.webView()->resize(WebSize(640, 480)); |
3045 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3042 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3046 | 3043 |
3047 // Generate a simple test case. | 3044 // Generate a simple test case. |
3048 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; | 3045 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; |
3049 WebCore::KURL testURL = toKURL("about:blank"); | 3046 WebCore::KURL testURL = toKURL("about:blank"); |
3050 frame->loadHTMLString(simpleSource, testURL); | 3047 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3051 runPendingTasks(); | |
3052 | 3048 |
3053 // Make sure it comes out OK. | 3049 // Make sure it comes out OK. |
3054 const std::string expected("Foo bar\nbaz"); | 3050 const std::string expected("Foo bar\nbaz"); |
3055 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3051 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
3056 EXPECT_EQ(expected, text.utf8()); | 3052 EXPECT_EQ(expected, text.utf8()); |
3057 | 3053 |
3058 // Try reading the same one with clipping of the text. | 3054 // Try reading the same one with clipping of the text. |
3059 const int length = 5; | 3055 const int length = 5; |
3060 text = frame->contentAsText(length); | 3056 text = frame->contentAsText(length); |
3061 EXPECT_EQ(expected.substr(0, length), text.utf8()); | 3057 EXPECT_EQ(expected.substr(0, length), text.utf8()); |
3062 | 3058 |
3063 // Now do a new test with a subframe. | 3059 // Now do a new test with a subframe. |
3064 const char outerFrameSource[] = "Hello<iframe></iframe> world"; | 3060 const char outerFrameSource[] = "Hello<iframe></iframe> world"; |
3065 frame->loadHTMLString(outerFrameSource, testURL); | 3061 FrameTestHelpers::loadHTMLString(frame, outerFrameSource, testURL); |
3066 runPendingTasks(); | |
3067 | 3062 |
3068 // Load something into the subframe. | 3063 // Load something into the subframe. |
3069 WebFrame* subframe = frame->firstChild(); | 3064 WebFrame* subframe = frame->firstChild(); |
3070 ASSERT_TRUE(subframe); | 3065 ASSERT_TRUE(subframe); |
3071 subframe->loadHTMLString("sub<p>text", testURL); | 3066 FrameTestHelpers::loadHTMLString(subframe, "sub<p>text", testURL); |
3072 runPendingTasks(); | |
3073 | 3067 |
3074 text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3068 text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
3075 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); | 3069 EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8()); |
3076 | 3070 |
3077 // Get the frame text where the subframe separator falls on the boundary of | 3071 // 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. | 3072 // what we'll take. There used to be a crash in this case. |
3079 text = frame->contentAsText(12); | 3073 text = frame->contentAsText(12); |
3080 EXPECT_EQ("Hello world", text.utf8()); | 3074 EXPECT_EQ("Hello world", text.utf8()); |
3081 } | 3075 } |
3082 | 3076 |
3083 TEST_F(WebFrameTest, GetFullHtmlOfPage) | 3077 TEST_F(WebFrameTest, GetFullHtmlOfPage) |
3084 { | 3078 { |
3085 FrameTestHelpers::WebViewHelper webViewHelper; | 3079 FrameTestHelpers::WebViewHelper webViewHelper; |
3086 webViewHelper.initializeAndLoad("about:blank", true); | 3080 webViewHelper.initializeAndLoad("about:blank", true); |
3087 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3081 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
3088 | 3082 |
3089 // Generate a simple test case. | 3083 // Generate a simple test case. |
3090 const char simpleSource[] = "<p>Hello</p><p>World</p>"; | 3084 const char simpleSource[] = "<p>Hello</p><p>World</p>"; |
3091 WebCore::KURL testURL = toKURL("about:blank"); | 3085 WebCore::KURL testURL = toKURL("about:blank"); |
3092 frame->loadHTMLString(simpleSource, testURL); | 3086 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); |
3093 runPendingTasks(); | |
3094 | 3087 |
3095 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3088 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
3096 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3089 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
3097 | 3090 |
3098 const std::string html = frame->contentAsMarkup().utf8(); | 3091 const std::string html = frame->contentAsMarkup().utf8(); |
3099 | 3092 |
3100 // Load again with the output html. | 3093 // Load again with the output html. |
3101 frame->loadHTMLString(WebData(html.c_str(), html.length()), testURL); | 3094 FrameTestHelpers::loadHTMLString(frame, html, testURL); |
3102 runPendingTasks(); | |
3103 | 3095 |
3104 EXPECT_EQ(html, frame->contentAsMarkup().utf8()); | 3096 EXPECT_EQ(html, frame->contentAsMarkup().utf8()); |
3105 | 3097 |
3106 text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 3098 text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
3107 EXPECT_EQ("Hello\n\nWorld", text.utf8()); | 3099 EXPECT_EQ("Hello\n\nWorld", text.utf8()); |
3108 | 3100 |
3109 // Test selection check | 3101 // Test selection check |
3110 EXPECT_FALSE(frame->hasSelection()); | 3102 EXPECT_FALSE(frame->hasSelection()); |
3111 frame->executeCommand(WebString::fromUTF8("SelectAll")); | 3103 frame->executeCommand(WebString::fromUTF8("SelectAll")); |
3112 EXPECT_TRUE(frame->hasSelection()); | 3104 EXPECT_TRUE(frame->hasSelection()); |
(...skipping 12 matching lines...) Expand all Loading... |
3125 }; | 3117 }; |
3126 | 3118 |
3127 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) | 3119 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) |
3128 { | 3120 { |
3129 registerMockedHttpURLLoad("hello_world.html"); | 3121 registerMockedHttpURLLoad("hello_world.html"); |
3130 | 3122 |
3131 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; | 3123 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; |
3132 FrameTestHelpers::WebViewHelper webViewHelper; | 3124 FrameTestHelpers::WebViewHelper webViewHelper; |
3133 webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFr
ameClient); | 3125 webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFr
ameClient); |
3134 | 3126 |
3135 webViewHelper.webView()->mainFrame()->reload(); | 3127 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
3136 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
3137 } | 3128 } |
3138 | 3129 |
3139 class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 3130 class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
3140 public: | 3131 public: |
3141 FindUpdateWebFrameClient() | 3132 FindUpdateWebFrameClient() |
3142 : m_findResultsAreReady(false) | 3133 : m_findResultsAreReady(false) |
3143 , m_count(-1) | 3134 , m_count(-1) |
3144 { | 3135 { |
3145 } | 3136 } |
3146 | 3137 |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 class TestSubstituteDataWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 4052 class TestSubstituteDataWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
4062 public: | 4053 public: |
4063 TestSubstituteDataWebFrameClient() | 4054 TestSubstituteDataWebFrameClient() |
4064 : m_commitCalled(false) | 4055 : m_commitCalled(false) |
4065 { | 4056 { |
4066 } | 4057 } |
4067 | 4058 |
4068 virtual void didFailProvisionalLoad(WebLocalFrame* frame, const WebURLError&
error) | 4059 virtual void didFailProvisionalLoad(WebLocalFrame* frame, const WebURLError&
error) |
4069 { | 4060 { |
4070 frame->loadHTMLString("This should appear", toKURL("data:text/html,chrom
ewebdata"), error.unreachableURL, true); | 4061 frame->loadHTMLString("This should appear", toKURL("data:text/html,chrom
ewebdata"), error.unreachableURL, true); |
4071 runPendingTasks(); | |
4072 } | 4062 } |
4073 | 4063 |
4074 virtual void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistory
Item&, WebHistoryCommitType) | 4064 virtual void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistory
Item&, WebHistoryCommitType) |
4075 { | 4065 { |
4076 if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKU
RL("about:blank"))) | 4066 if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKU
RL("about:blank"))) |
4077 m_commitCalled = true; | 4067 m_commitCalled = true; |
4078 } | 4068 } |
4079 | 4069 |
4080 bool commitCalled() const { return m_commitCalled; } | 4070 bool commitCalled() const { return m_commitCalled; } |
4081 | 4071 |
4082 private: | 4072 private: |
4083 bool m_commitCalled; | 4073 bool m_commitCalled; |
4084 }; | 4074 }; |
4085 | 4075 |
4086 TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) | 4076 TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation) |
4087 { | 4077 { |
4088 TestSubstituteDataWebFrameClient webFrameClient; | 4078 TestSubstituteDataWebFrameClient webFrameClient; |
4089 | 4079 |
4090 FrameTestHelpers::WebViewHelper webViewHelper; | 4080 FrameTestHelpers::WebViewHelper webViewHelper; |
4091 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); | 4081 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); |
4092 runPendingTasks(); | |
4093 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4082 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
4094 | 4083 |
4095 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient | 4084 // 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. | 4085 // 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 | 4086 // 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. | 4087 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. |
4099 WebURLError error; | 4088 WebURLError error; |
4100 error.reason = 1337; | 4089 error.reason = 1337; |
4101 error.domain = "WebFrameTest"; | 4090 error.domain = "WebFrameTest"; |
4102 std::string errorURL = "http://0.0.0.0"; | 4091 std::string errorURL = "http://0.0.0.0"; |
4103 WebURLResponse response; | 4092 WebURLResponse response; |
4104 response.initialize(); | 4093 response.initialize(); |
4105 response.setURL(URLTestHelpers::toKURL(errorURL)); | 4094 response.setURL(URLTestHelpers::toKURL(errorURL)); |
4106 response.setMIMEType("text/html"); | 4095 response.setMIMEType("text/html"); |
4107 response.setHTTPStatusCode(500); | 4096 response.setHTTPStatusCode(500); |
4108 WebHistoryItem errorHistoryItem; | 4097 WebHistoryItem errorHistoryItem; |
4109 errorHistoryItem.initialize(); | 4098 errorHistoryItem.initialize(); |
4110 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); | 4099 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); |
4111 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper
s::toKURL(errorURL), response, error); | 4100 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper
s::toKURL(errorURL), response, error); |
4112 frame->loadHistoryItem(errorHistoryItem, WebHistoryDifferentDocumentLoad, We
bURLRequest::UseProtocolCachePolicy); | 4101 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
4113 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4114 | 4102 |
4115 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 4103 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
4116 EXPECT_EQ("This should appear", text.utf8()); | 4104 EXPECT_EQ("This should appear", text.utf8()); |
4117 EXPECT_TRUE(webFrameClient.commitCalled()); | 4105 EXPECT_TRUE(webFrameClient.commitCalled()); |
4118 } | 4106 } |
4119 | 4107 |
4120 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 4108 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
4121 public: | 4109 public: |
4122 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) | 4110 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) |
4123 { | 4111 { |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4529 TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) | 4517 TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) |
4530 { | 4518 { |
4531 TestAccessInitialDocumentWebFrameClient webFrameClient; | 4519 TestAccessInitialDocumentWebFrameClient webFrameClient; |
4532 FrameTestHelpers::WebViewHelper webViewHelper; | 4520 FrameTestHelpers::WebViewHelper webViewHelper; |
4533 webViewHelper.initialize(true, &webFrameClient); | 4521 webViewHelper.initialize(true, &webFrameClient); |
4534 runPendingTasks(); | 4522 runPendingTasks(); |
4535 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 4523 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
4536 | 4524 |
4537 // Access the initial document from a javascript: URL. | 4525 // Access the initial document from a javascript: URL. |
4538 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Modified'))"); | 4526 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.body.appendChild(document.createTextNode('Modified'))"); |
4539 runPendingTasks(); | |
4540 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 4527 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
4541 } | 4528 } |
4542 | 4529 |
4543 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 | 4530 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 |
4544 #if OS(WIN) | 4531 #if OS(WIN) |
4545 TEST_F(WebFrameTest, DISABLED_DidAccessInitialDocumentBodyBeforeModalDialog) | 4532 TEST_F(WebFrameTest, DISABLED_DidAccessInitialDocumentBodyBeforeModalDialog) |
4546 #else | 4533 #else |
4547 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) | 4534 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) |
4548 #endif | 4535 #endif |
4549 { | 4536 { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4822 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 4809 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); |
4823 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); | 4810 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); |
4824 | 4811 |
4825 // ctrl+click event | 4812 // ctrl+click event |
4826 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo
re::EventTypeNames::click, false, false, | 4813 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); | 4814 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)); | 4815 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); |
4829 frameRequest.setTriggeringEvent(event); | 4816 frameRequest.setTriggeringEvent(event); |
4830 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 4817 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); |
4831 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 4818 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); |
| 4819 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
4832 | 4820 |
4833 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 4821 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
4834 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 4822 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
4835 } | 4823 } |
4836 | 4824 |
4837 TEST_F(WebFrameTest, BackToReload) | 4825 TEST_F(WebFrameTest, BackToReload) |
4838 { | 4826 { |
4839 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4827 registerMockedHttpURLLoad("fragment_middle_click.html"); |
4840 FrameTestHelpers::WebViewHelper webViewHelper; | 4828 FrameTestHelpers::WebViewHelper webViewHelper; |
4841 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 4829 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
4842 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4830 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
4843 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4831 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
4844 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 4832 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); |
4845 EXPECT_TRUE(firstItem); | 4833 EXPECT_TRUE(firstItem); |
4846 | 4834 |
4847 registerMockedHttpURLLoad("white-1x1.png"); | 4835 registerMockedHttpURLLoad("white-1x1.png"); |
4848 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 4836 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
4849 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4850 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 4837 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
4851 | 4838 |
4852 frame->loadHistoryItem(WebHistoryItem(firstItem.get()), WebHistoryDifferentD
ocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 4839 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
4853 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4854 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 4840 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
4855 | 4841 |
4856 frame->reload(); | 4842 FrameTestHelpers::reloadFrame(frame); |
4857 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4858 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 4843 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
4859 } | 4844 } |
4860 | 4845 |
4861 TEST_F(WebFrameTest, BackDuringChildFrameReload) | 4846 TEST_F(WebFrameTest, BackDuringChildFrameReload) |
4862 { | 4847 { |
4863 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 4848 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
4864 FrameTestHelpers::WebViewHelper webViewHelper; | 4849 FrameTestHelpers::WebViewHelper webViewHelper; |
4865 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 4850 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
4866 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 4851 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
4867 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4852 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
4868 WebFrame* childFrame = mainFrame->firstChild(); | 4853 WebFrame* childFrame = mainFrame->firstChild(); |
4869 ASSERT_TRUE(childFrame); | 4854 ASSERT_TRUE(childFrame); |
4870 | 4855 |
4871 // Start a history navigation, then have a different frame commit a navigati
on. | 4856 // 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. | 4857 // 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 | 4858 // After the history navigation completes, both the appropriate document url
and |
4874 // the current history item should reflect the history navigation. | 4859 // the current history item should reflect the history navigation. |
4875 registerMockedHttpURLLoad("white-1x1.png"); | 4860 registerMockedHttpURLLoad("white-1x1.png"); |
4876 WebHistoryItem item; | 4861 WebHistoryItem item; |
4877 item.initialize(); | 4862 item.initialize(); |
4878 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 4863 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
4879 item.setURLString(historyURL.string()); | 4864 item.setURLString(historyURL.string()); |
4880 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequ
est::UseProtocolCachePolicy); | 4865 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequ
est::UseProtocolCachePolicy); |
4881 | 4866 |
4882 childFrame->reload(); | 4867 FrameTestHelpers::reloadFrame(childFrame); |
4883 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4884 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); | 4868 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); |
4885 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); | 4869 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); |
4886 } | 4870 } |
4887 | 4871 |
4888 TEST_F(WebFrameTest, ReloadPost) | 4872 TEST_F(WebFrameTest, ReloadPost) |
4889 { | 4873 { |
4890 registerMockedHttpURLLoad("reload_post.html"); | 4874 registerMockedHttpURLLoad("reload_post.html"); |
4891 FrameTestHelpers::WebViewHelper webViewHelper; | 4875 FrameTestHelpers::WebViewHelper webViewHelper; |
4892 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 4876 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
4893 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4877 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
4894 | 4878 |
4895 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); | 4879 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); |
4896 runPendingTasks(); | 4880 // Pump requests one more time after the javascript URL has executed to |
4897 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 4881 // trigger the actual POST load request. |
| 4882 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
4898 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); | 4883 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); |
4899 | 4884 |
4900 frame->reload(); | 4885 FrameTestHelpers::reloadFrame(frame); |
4901 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4902 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 4886 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
4903 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 4887 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
4904 } | 4888 } |
4905 | 4889 |
4906 TEST_F(WebFrameTest, LoadHistoryItemReload) | 4890 TEST_F(WebFrameTest, LoadHistoryItemReload) |
4907 { | 4891 { |
4908 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4892 registerMockedHttpURLLoad("fragment_middle_click.html"); |
4909 FrameTestHelpers::WebViewHelper webViewHelper; | 4893 FrameTestHelpers::WebViewHelper webViewHelper; |
4910 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 4894 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
4911 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4895 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
4912 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 4896 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
4913 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); | 4897 RefPtr<WebCore::HistoryItem> firstItem = mainFrameLoader.currentItem(); |
4914 EXPECT_TRUE(firstItem); | 4898 EXPECT_TRUE(firstItem); |
4915 | 4899 |
4916 registerMockedHttpURLLoad("white-1x1.png"); | 4900 registerMockedHttpURLLoad("white-1x1.png"); |
4917 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 4901 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
4918 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4919 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 4902 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
4920 | 4903 |
4921 // Cache policy overrides should take. | 4904 // Cache policy overrides should take. |
4922 frame->loadHistoryItem(WebHistoryItem(firstItem), WebHistoryDifferentDocumen
tLoad, WebURLRequest::ReloadIgnoringCacheData); | 4905 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); |
4923 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4924 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 4906 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
4925 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 4907 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); |
4926 } | 4908 } |
4927 | 4909 |
4928 | 4910 |
4929 class TestCachePolicyWebFrameClient : public WebFrameClient { | 4911 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien
t { |
4930 public: | 4912 public: |
4931 TestCachePolicyWebFrameClient() | 4913 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent
Client) |
4932 : m_policy(WebURLRequest::UseProtocolCachePolicy) | 4914 : m_parentClient(parentClient) |
4933 , m_client(0) | 4915 , m_policy(WebURLRequest::UseProtocolCachePolicy) |
| 4916 , m_childClient(0) |
4934 , m_willSendRequestCallCount(0) | 4917 , m_willSendRequestCallCount(0) |
4935 , m_childFrameCreationCount(0) | 4918 , m_childFrameCreationCount(0) |
4936 { | 4919 { |
4937 } | 4920 } |
4938 | 4921 |
4939 void setChildWebFrameClient(WebFrameClient* client) { m_client = client; } | 4922 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } |
4940 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 4923 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } |
4941 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 4924 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
4942 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 4925 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
4943 | 4926 |
4944 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString&) | 4927 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString&) |
4945 { | 4928 { |
| 4929 ASSERT(m_childClient); |
4946 m_childFrameCreationCount++; | 4930 m_childFrameCreationCount++; |
4947 WebFrame* frame = WebLocalFrame::create(m_client); | 4931 WebFrame* frame = WebLocalFrame::create(m_childClient); |
4948 parent->appendChild(frame); | 4932 parent->appendChild(frame); |
4949 return frame; | 4933 return frame; |
4950 } | 4934 } |
4951 | 4935 |
4952 virtual void frameDetached(WebFrame* frame) OVERRIDE | 4936 virtual void didStartLoading(bool toDifferentDocument) |
4953 { | 4937 { |
4954 if (frame->parent()) | 4938 if (m_parentClient) { |
4955 frame->parent()->removeChild(frame); | 4939 m_parentClient->didStartLoading(toDifferentDocument); |
4956 frame->close(); | 4940 return; |
| 4941 } |
| 4942 TestWebFrameClient::didStartLoading(toDifferentDocument); |
| 4943 } |
| 4944 |
| 4945 virtual void didStopLoading() |
| 4946 { |
| 4947 if (m_parentClient) { |
| 4948 m_parentClient->didStopLoading(); |
| 4949 return; |
| 4950 } |
| 4951 TestWebFrameClient::didStopLoading(); |
4957 } | 4952 } |
4958 | 4953 |
4959 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) OVERRIDE | 4954 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) OVERRIDE |
4960 { | 4955 { |
4961 m_policy = request.cachePolicy(); | 4956 m_policy = request.cachePolicy(); |
4962 m_willSendRequestCallCount++; | 4957 m_willSendRequestCallCount++; |
4963 } | 4958 } |
4964 | 4959 |
4965 private: | 4960 private: |
| 4961 TestCachePolicyWebFrameClient* m_parentClient; |
| 4962 |
4966 WebURLRequest::CachePolicy m_policy; | 4963 WebURLRequest::CachePolicy m_policy; |
4967 WebFrameClient* m_client; | 4964 TestCachePolicyWebFrameClient* m_childClient; |
4968 int m_willSendRequestCallCount; | 4965 int m_willSendRequestCallCount; |
4969 int m_childFrameCreationCount; | 4966 int m_childFrameCreationCount; |
4970 }; | 4967 }; |
4971 | 4968 |
4972 TEST_F(WebFrameTest, ReloadIframe) | 4969 TEST_F(WebFrameTest, ReloadIframe) |
4973 { | 4970 { |
4974 registerMockedHttpURLLoad("iframe_reload.html"); | 4971 registerMockedHttpURLLoad("iframe_reload.html"); |
4975 registerMockedHttpURLLoad("visible_iframe.html"); | 4972 registerMockedHttpURLLoad("visible_iframe.html"); |
4976 TestCachePolicyWebFrameClient mainClient; | 4973 TestCachePolicyWebFrameClient mainClient(0); |
4977 TestCachePolicyWebFrameClient childClient; | 4974 TestCachePolicyWebFrameClient childClient(&mainClient); |
4978 mainClient.setChildWebFrameClient(&childClient); | 4975 mainClient.setChildWebFrameClient(&childClient); |
4979 | 4976 |
4980 FrameTestHelpers::WebViewHelper webViewHelper; | 4977 FrameTestHelpers::WebViewHelper webViewHelper; |
4981 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 4978 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
4982 | 4979 |
4983 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 4980 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
4984 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); | 4981 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); |
4985 ASSERT_EQ(childFrame->client(), &childClient); | 4982 ASSERT_EQ(childFrame->client(), &childClient); |
4986 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 4983 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
4987 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 4984 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
4988 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); | 4985 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); |
4989 | 4986 |
4990 mainFrame->reload(false); | 4987 FrameTestHelpers::reloadFrame(mainFrame); |
4991 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
4992 | 4988 |
4993 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 4989 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
4994 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 4990 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
4995 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); | 4991 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
4996 | 4992 |
4997 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 4993 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
4998 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 4994 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
4999 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; | 4995 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; |
5000 } | 4996 } |
5001 | 4997 |
(...skipping 19 matching lines...) Expand all Loading... |
5021 TEST_F(WebFrameTest, NavigateToSame) | 5017 TEST_F(WebFrameTest, NavigateToSame) |
5022 { | 5018 { |
5023 registerMockedHttpURLLoad("navigate_to_same.html"); | 5019 registerMockedHttpURLLoad("navigate_to_same.html"); |
5024 TestSameDocumentWebFrameClient client; | 5020 TestSameDocumentWebFrameClient client; |
5025 FrameTestHelpers::WebViewHelper webViewHelper; | 5021 FrameTestHelpers::WebViewHelper webViewHelper; |
5026 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); | 5022 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, &
client); |
5027 EXPECT_FALSE(client.frameLoadTypeSameSeen()); | 5023 EXPECT_FALSE(client.frameLoadTypeSameSeen()); |
5028 | 5024 |
5029 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewHe
lper.webViewImpl()->page()->mainFrame()->document()->url())); | 5025 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewHe
lper.webViewImpl()->page()->mainFrame()->document()->url())); |
5030 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 5026 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); |
5031 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 5027 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
5032 | 5028 |
5033 EXPECT_TRUE(client.frameLoadTypeSameSeen()); | 5029 EXPECT_TRUE(client.frameLoadTypeSameSeen()); |
5034 } | 5030 } |
5035 | 5031 |
5036 TEST_F(WebFrameTest, WebNodeImageContents) | 5032 TEST_F(WebFrameTest, WebNodeImageContents) |
5037 { | 5033 { |
5038 FrameTestHelpers::WebViewHelper webViewHelper; | 5034 FrameTestHelpers::WebViewHelper webViewHelper; |
5039 webViewHelper.initializeAndLoad("about:blank", true); | 5035 webViewHelper.initializeAndLoad("about:blank", true); |
5040 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5036 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5041 | 5037 |
5042 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; | 5038 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
5043 | 5039 |
5044 // Load up the image and test that we can extract the contents. | 5040 // Load up the image and test that we can extract the contents. |
5045 WebCore::KURL testURL = toKURL("about:blank"); | 5041 WebCore::KURL testURL = toKURL("about:blank"); |
5046 frame->loadHTMLString(bluePNG, testURL); | 5042 FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL); |
5047 runPendingTasks(); | |
5048 | 5043 |
5049 WebNode node = frame->document().body().firstChild(); | 5044 WebNode node = frame->document().body().firstChild(); |
5050 EXPECT_TRUE(node.isElementNode()); | 5045 EXPECT_TRUE(node.isElementNode()); |
5051 WebElement element = node.to<WebElement>(); | 5046 WebElement element = node.to<WebElement>(); |
5052 WebImage image = element.imageContents(); | 5047 WebImage image = element.imageContents(); |
5053 ASSERT_FALSE(image.isNull()); | 5048 ASSERT_FALSE(image.isNull()); |
5054 EXPECT_EQ(image.size().width, 10); | 5049 EXPECT_EQ(image.size().width, 10); |
5055 EXPECT_EQ(image.size().height, 10); | 5050 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. | 5051 // FIXME: The rest of this test is disabled since the ImageDecodeCache state
may be inconsistent when this test runs. |
5057 // crbug.com/266088 | 5052 // crbug.com/266088 |
5058 // SkBitmap bitmap = image.getSkBitmap(); | 5053 // SkBitmap bitmap = image.getSkBitmap(); |
5059 // SkAutoLockPixels locker(bitmap); | 5054 // SkAutoLockPixels locker(bitmap); |
5060 // EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); | 5055 // EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); |
5061 } | 5056 } |
5062 | 5057 |
5063 class TestStartStopCallbackWebFrameClient : public WebFrameClient { | 5058 class TestStartStopCallbackWebFrameClient : public FrameTestHelpers::TestWebFram
eClient { |
5064 public: | 5059 public: |
5065 TestStartStopCallbackWebFrameClient() | 5060 TestStartStopCallbackWebFrameClient() |
5066 : m_startLoadingCount(0) | 5061 : m_startLoadingCount(0) |
5067 , m_stopLoadingCount(0) | 5062 , m_stopLoadingCount(0) |
5068 , m_differentDocumentStartCount(0) | 5063 , m_differentDocumentStartCount(0) |
5069 { | 5064 { |
5070 } | 5065 } |
5071 | 5066 |
5072 virtual void didStartLoading(bool toDifferentDocument) OVERRIDE | 5067 virtual void didStartLoading(bool toDifferentDocument) OVERRIDE |
5073 { | 5068 { |
| 5069 TestWebFrameClient::didStartLoading(toDifferentDocument); |
5074 m_startLoadingCount++; | 5070 m_startLoadingCount++; |
5075 if (toDifferentDocument) | 5071 if (toDifferentDocument) |
5076 m_differentDocumentStartCount++; | 5072 m_differentDocumentStartCount++; |
5077 } | 5073 } |
5078 | 5074 |
5079 virtual void didStopLoading() OVERRIDE | 5075 virtual void didStopLoading() OVERRIDE |
5080 { | 5076 { |
| 5077 TestWebFrameClient::didStopLoading(); |
5081 m_stopLoadingCount++; | 5078 m_stopLoadingCount++; |
5082 } | 5079 } |
5083 | 5080 |
5084 int startLoadingCount() const { return m_startLoadingCount; } | 5081 int startLoadingCount() const { return m_startLoadingCount; } |
5085 int stopLoadingCount() const { return m_stopLoadingCount; } | 5082 int stopLoadingCount() const { return m_stopLoadingCount; } |
5086 int differentDocumentStartCount() const { return m_differentDocumentStartCou
nt; } | 5083 int differentDocumentStartCount() const { return m_differentDocumentStartCou
nt; } |
5087 | 5084 |
5088 private: | 5085 private: |
5089 int m_startLoadingCount; | 5086 int m_startLoadingCount; |
5090 int m_stopLoadingCount; | 5087 int m_stopLoadingCount; |
5091 int m_differentDocumentStartCount; | 5088 int m_differentDocumentStartCount; |
5092 }; | 5089 }; |
5093 | 5090 |
5094 TEST_F(WebFrameTest, PushStateStartsAndStops) | 5091 TEST_F(WebFrameTest, PushStateStartsAndStops) |
5095 { | 5092 { |
5096 registerMockedHttpURLLoad("push_state.html"); | 5093 registerMockedHttpURLLoad("push_state.html"); |
5097 TestStartStopCallbackWebFrameClient client; | 5094 TestStartStopCallbackWebFrameClient client; |
5098 FrameTestHelpers::WebViewHelper webViewHelper; | 5095 FrameTestHelpers::WebViewHelper webViewHelper; |
5099 webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client
); | 5096 webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client
); |
5100 runPendingTasks(); | |
5101 | 5097 |
5102 EXPECT_EQ(client.startLoadingCount(), 2); | 5098 EXPECT_EQ(client.startLoadingCount(), 2); |
5103 EXPECT_EQ(client.stopLoadingCount(), 2); | 5099 EXPECT_EQ(client.stopLoadingCount(), 2); |
5104 EXPECT_EQ(client.differentDocumentStartCount(), 1); | 5100 EXPECT_EQ(client.differentDocumentStartCount(), 1); |
5105 } | 5101 } |
5106 | 5102 |
5107 class TestHistoryWebFrameClient : public WebFrameClient { | 5103 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
5108 public: | 5104 public: |
5109 TestHistoryWebFrameClient() | 5105 TestHistoryWebFrameClient() |
5110 { | 5106 { |
5111 m_replacesCurrentHistoryItem = false; | 5107 m_replacesCurrentHistoryItem = false; |
5112 m_frame = 0; | 5108 m_frame = 0; |
5113 } | 5109 } |
5114 void didStartProvisionalLoad(WebLocalFrame* frame) | 5110 void didStartProvisionalLoad(WebLocalFrame* frame) |
5115 { | 5111 { |
5116 WebDataSource* ds = frame->provisionalDataSource(); | 5112 WebDataSource* ds = frame->provisionalDataSource(); |
5117 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | 5113 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); |
(...skipping 11 matching lines...) Expand all Loading... |
5129 // Test which ensures that the first navigation in a subframe will always | 5125 // 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. | 5126 // result in history entry being replaced and not a new one added. |
5131 TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory) | 5127 TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory) |
5132 { | 5128 { |
5133 registerMockedHttpURLLoad("history.html"); | 5129 registerMockedHttpURLLoad("history.html"); |
5134 registerMockedHttpURLLoad("find.html"); | 5130 registerMockedHttpURLLoad("find.html"); |
5135 | 5131 |
5136 FrameTestHelpers::WebViewHelper webViewHelper; | 5132 FrameTestHelpers::WebViewHelper webViewHelper; |
5137 TestHistoryWebFrameClient client; | 5133 TestHistoryWebFrameClient client; |
5138 webViewHelper.initializeAndLoad("about:blank", true, &client); | 5134 webViewHelper.initializeAndLoad("about:blank", true, &client); |
5139 runPendingTasks(); | |
5140 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5135 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
5141 | 5136 |
5142 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5137 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5143 | 5138 |
5144 FrameTestHelpers::loadFrame(frame, | 5139 FrameTestHelpers::loadFrame(frame, |
5145 "javascript:document.body.appendChild(document.createElement('iframe'))"
); | 5140 "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(); | 5141 WebFrame* iframe = frame->firstChild(); |
5150 EXPECT_EQ(client.frame(), iframe); | 5142 EXPECT_EQ(client.frame(), iframe); |
5151 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5143 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
5152 | 5144 |
5153 FrameTestHelpers::loadFrame(frame, | 5145 FrameTestHelpers::loadFrame(frame, |
5154 "javascript:window.frames[0].location.assign('" + m_baseURL + "history.h
tml')"); | 5146 "javascript:window.frames[0].location.assign('" + m_baseURL + "history.h
tml')"); |
5155 runPendingTasks(); | |
5156 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
5157 EXPECT_EQ(client.frame(), iframe); | 5147 EXPECT_EQ(client.frame(), iframe); |
5158 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5148 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
5159 | 5149 |
5160 FrameTestHelpers::loadFrame(frame, | 5150 FrameTestHelpers::loadFrame(frame, |
5161 "javascript:window.frames[0].location.assign('" + m_baseURL + "find.html
')"); | 5151 "javascript:window.frames[0].location.assign('" + m_baseURL + "find.html
')"); |
5162 runPendingTasks(); | |
5163 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
5164 EXPECT_EQ(client.frame(), iframe); | 5152 EXPECT_EQ(client.frame(), iframe); |
5165 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 5153 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
5166 | 5154 |
5167 // Repeat the test, but start out the iframe with initial URL, which is not | 5155 // Repeat the test, but start out the iframe with initial URL, which is not |
5168 // "about:blank". | 5156 // "about:blank". |
5169 FrameTestHelpers::loadFrame(frame, | 5157 FrameTestHelpers::loadFrame(frame, |
5170 "javascript:var f = document.createElement('iframe'); " | 5158 "javascript:var f = document.createElement('iframe'); " |
5171 "f.src = '" + m_baseURL + "history.html';" | 5159 "f.src = '" + m_baseURL + "history.html';" |
5172 "document.body.appendChild(f)"); | 5160 "document.body.appendChild(f)"); |
5173 runPendingTasks(); | |
5174 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
5175 | 5161 |
5176 iframe = frame->firstChild()->nextSibling(); | 5162 iframe = frame->firstChild()->nextSibling(); |
5177 EXPECT_EQ(client.frame(), iframe); | 5163 EXPECT_EQ(client.frame(), iframe); |
5178 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 5164 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
5179 | 5165 |
5180 FrameTestHelpers::loadFrame(frame, | 5166 FrameTestHelpers::loadFrame(frame, |
5181 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html
')"); | 5167 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html
')"); |
5182 runPendingTasks(); | |
5183 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
5184 EXPECT_EQ(client.frame(), iframe); | 5168 EXPECT_EQ(client.frame(), iframe); |
5185 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 5169 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
5186 } | 5170 } |
5187 | 5171 |
5188 // Test verifies that layout will change a layer's scrollable attibutes | 5172 // Test verifies that layout will change a layer's scrollable attibutes |
5189 TEST_F(WebFrameTest, overflowHiddenRewrite) | 5173 TEST_F(WebFrameTest, overflowHiddenRewrite) |
5190 { | 5174 { |
5191 registerMockedHttpURLLoad("non-scrollable.html"); | 5175 registerMockedHttpURLLoad("non-scrollable.html"); |
5192 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 5176 TestMainFrameUserOrProgrammaticScrollFrameClient client; |
5193 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 5177 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
5194 FrameTestHelpers::WebViewHelper webViewHelper; | 5178 FrameTestHelpers::WebViewHelper webViewHelper; |
5195 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 5179 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
5196 | 5180 |
5197 webViewHelper.webView()->resize(WebSize(100, 100)); | 5181 webViewHelper.webView()->resize(WebSize(100, 100)); |
5198 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); | 5182 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); |
5199 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | |
5200 webViewHelper.webView()->layout(); | |
5201 | 5183 |
5202 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); | 5184 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); |
5203 ASSERT_TRUE(compositor->scrollLayer()); | 5185 ASSERT_TRUE(compositor->scrollLayer()); |
5204 | 5186 |
5205 // Verify that the WebLayer is not scrollable initially. | 5187 // Verify that the WebLayer is not scrollable initially. |
5206 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); | 5188 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
5207 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 5189 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
5208 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 5190 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
5209 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | 5191 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); |
5210 | 5192 |
5211 // Call javascript to make the layer scrollable, and verify it. | 5193 // Call javascript to make the layer scrollable, and verify it. |
5212 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); | 5194 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); |
5213 frame->executeScript(WebScriptSource("allowScroll();")); | 5195 frame->executeScript(WebScriptSource("allowScroll();")); |
5214 webViewHelper.webView()->layout(); | 5196 webViewHelper.webView()->layout(); |
5215 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 5197 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
5216 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 5198 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
5217 } | 5199 } |
5218 | 5200 |
5219 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 5201 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. |
5220 TEST_F(WebFrameTest, CurrentHistoryItem) | 5202 TEST_F(WebFrameTest, CurrentHistoryItem) |
5221 { | 5203 { |
5222 registerMockedHttpURLLoad("fixed_layout.html"); | 5204 registerMockedHttpURLLoad("fixed_layout.html"); |
5223 std::string url = m_baseURL + "fixed_layout.html"; | 5205 std::string url = m_baseURL + "fixed_layout.html"; |
5224 | 5206 |
5225 FrameTestHelpers::WebViewHelper webViewHelper; | 5207 FrameTestHelpers::WebViewHelper webViewHelper; |
5226 webViewHelper.initialize(); | 5208 webViewHelper.initialize(); |
5227 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5209 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5228 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); | 5210 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m
ainFrameImpl()->frame()->loader(); |
5229 FrameTestHelpers::loadFrame(frame, url); | 5211 WebURLRequest request; |
| 5212 request.initialize(); |
| 5213 request.setURL(toKURL(url)); |
| 5214 frame->loadRequest(request); |
5230 | 5215 |
5231 // Before commit, there is no history item. | 5216 // Before commit, there is no history item. |
5232 EXPECT_FALSE(mainFrameLoader.currentItem()); | 5217 EXPECT_FALSE(mainFrameLoader.currentItem()); |
5233 | 5218 |
5234 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 5219 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
5235 | 5220 |
5236 // After commit, there is. | 5221 // After commit, there is. |
5237 WebCore::HistoryItem* item = mainFrameLoader.currentItem(); | 5222 WebCore::HistoryItem* item = mainFrameLoader.currentItem(); |
5238 ASSERT_TRUE(item); | 5223 ASSERT_TRUE(item); |
5239 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 5224 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
5240 } | 5225 } |
5241 | 5226 |
5242 class FailCreateChildFrame : public WebFrameClient { | 5227 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
5243 public: | 5228 public: |
5244 FailCreateChildFrame() : m_callCount(0) { } | 5229 FailCreateChildFrame() : m_callCount(0) { } |
5245 | 5230 |
5246 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE | 5231 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE |
5247 { | 5232 { |
5248 ++m_callCount; | 5233 ++m_callCount; |
5249 return 0; | 5234 return 0; |
5250 } | 5235 } |
5251 | 5236 |
5252 virtual void frameDetached(WebFrame* frame) OVERRIDE | |
5253 { | |
5254 frame->close(); | |
5255 } | |
5256 | |
5257 int callCount() const { return m_callCount; } | 5237 int callCount() const { return m_callCount; } |
5258 | 5238 |
5259 private: | 5239 private: |
5260 int m_callCount; | 5240 int m_callCount; |
5261 }; | 5241 }; |
5262 | 5242 |
5263 // Test that we don't crash if WebFrameClient::createChildFrame() fails. | 5243 // Test that we don't crash if WebFrameClient::createChildFrame() fails. |
5264 TEST_F(WebFrameTest, CreateChildFrameFailure) | 5244 TEST_F(WebFrameTest, CreateChildFrameFailure) |
5265 { | 5245 { |
5266 registerMockedHttpURLLoad("create_child_frame_fail.html"); | 5246 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"); | 5402 registerMockedHttpURLLoad("link-manifest-change.html"); |
5423 | 5403 |
5424 ManifestChangeWebFrameClient webFrameClient; | 5404 ManifestChangeWebFrameClient webFrameClient; |
5425 FrameTestHelpers::WebViewHelper webViewHelper; | 5405 FrameTestHelpers::WebViewHelper webViewHelper; |
5426 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); | 5406 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); |
5427 | 5407 |
5428 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); | 5408 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); |
5429 } | 5409 } |
5430 | 5410 |
5431 } // namespace | 5411 } // namespace |
OLD | NEW |