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

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

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

Powered by Google App Engine
This is Rietveld 408576698