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 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 | 2402 |
2403 FrameTestHelpers::WebViewHelper webViewHelper; | 2403 FrameTestHelpers::WebViewHelper webViewHelper; |
2404 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, | 2404 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, |
2405 nullptr, &client, nullptr, | 2405 nullptr, &client, nullptr, |
2406 enableViewportSettings); | 2406 enableViewportSettings); |
2407 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2407 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2408 | 2408 |
2409 webViewHelper.webView()->setPageScaleFactor(3); | 2409 webViewHelper.webView()->setPageScaleFactor(3); |
2410 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 2410 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
2411 ->loader() | 2411 ->loader() |
2412 .currentItem() | 2412 .documentLoader() |
| 2413 ->historyItem() |
2413 ->pageScaleFactor()); | 2414 ->pageScaleFactor()); |
2414 } | 2415 } |
2415 | 2416 |
2416 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) { | 2417 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) { |
2417 registerMockedHttpURLLoad("fixed_layout.html"); | 2418 registerMockedHttpURLLoad("fixed_layout.html"); |
2418 | 2419 |
2419 FixedLayoutTestWebViewClient client; | 2420 FixedLayoutTestWebViewClient client; |
2420 client.m_screenInfo.deviceScaleFactor = 1; | 2421 client.m_screenInfo.deviceScaleFactor = 1; |
2421 int viewportWidth = 640; | 2422 int viewportWidth = 640; |
2422 int viewportHeight = 480; | 2423 int viewportHeight = 480; |
2423 | 2424 |
2424 FrameTestHelpers::WebViewHelper webViewHelper; | 2425 FrameTestHelpers::WebViewHelper webViewHelper; |
2425 webViewHelper.initialize(true, nullptr, &client, nullptr, | 2426 webViewHelper.initialize(true, nullptr, &client, nullptr, |
2426 enableViewportSettings); | 2427 enableViewportSettings); |
2427 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 2428 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
2428 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 2429 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
2429 m_baseURL + "fixed_layout.html"); | 2430 m_baseURL + "fixed_layout.html"); |
2430 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2431 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2431 | 2432 |
2432 int defaultFixedLayoutWidth = 980; | 2433 int defaultFixedLayoutWidth = 980; |
2433 float minimumPageScaleFactor = viewportWidth / (float)defaultFixedLayoutWidth; | 2434 float minimumPageScaleFactor = viewportWidth / (float)defaultFixedLayoutWidth; |
2434 EXPECT_EQ(minimumPageScaleFactor, | 2435 EXPECT_EQ(minimumPageScaleFactor, |
2435 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 2436 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
2436 ->loader() | 2437 ->loader() |
2437 .currentItem() | 2438 .documentLoader() |
| 2439 ->historyItem() |
2438 ->pageScaleFactor()); | 2440 ->pageScaleFactor()); |
2439 } | 2441 } |
2440 | 2442 |
2441 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) { | 2443 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) { |
2442 registerMockedHttpURLLoad("large-div.html"); | 2444 registerMockedHttpURLLoad("large-div.html"); |
2443 | 2445 |
2444 FixedLayoutTestWebViewClient client; | 2446 FixedLayoutTestWebViewClient client; |
2445 client.m_screenInfo.deviceScaleFactor = 1; | 2447 client.m_screenInfo.deviceScaleFactor = 1; |
2446 // Small viewport to ensure there are always scrollbars. | 2448 // Small viewport to ensure there are always scrollbars. |
2447 int viewportWidth = 64; | 2449 int viewportWidth = 64; |
(...skipping 4520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6968 } | 6970 } |
6969 | 6971 |
6970 TEST_P(ParameterizedWebFrameTest, BackToReload) { | 6972 TEST_P(ParameterizedWebFrameTest, BackToReload) { |
6971 registerMockedHttpURLLoad("fragment_middle_click.html"); | 6973 registerMockedHttpURLLoad("fragment_middle_click.html"); |
6972 FrameTestHelpers::WebViewHelper webViewHelper; | 6974 FrameTestHelpers::WebViewHelper webViewHelper; |
6973 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", | 6975 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", |
6974 true); | 6976 true); |
6975 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6977 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6976 const FrameLoader& mainFrameLoader = | 6978 const FrameLoader& mainFrameLoader = |
6977 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 6979 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
6978 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 6980 Persistent<HistoryItem> firstItem = |
| 6981 mainFrameLoader.documentLoader()->historyItem(); |
6979 EXPECT_TRUE(firstItem); | 6982 EXPECT_TRUE(firstItem); |
6980 | 6983 |
6981 registerMockedHttpURLLoad("white-1x1.png"); | 6984 registerMockedHttpURLLoad("white-1x1.png"); |
6982 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 6985 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
6983 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 6986 EXPECT_NE(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
6984 | 6987 |
6985 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), | 6988 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), |
6986 WebHistoryDifferentDocumentLoad, | 6989 WebHistoryDifferentDocumentLoad, |
6987 WebCachePolicy::UseProtocolCachePolicy); | 6990 WebCachePolicy::UseProtocolCachePolicy); |
6988 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 6991 EXPECT_EQ(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
6989 | 6992 |
6990 FrameTestHelpers::reloadFrame(frame); | 6993 FrameTestHelpers::reloadFrame(frame); |
6991 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 6994 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
6992 frame->dataSource()->getRequest().getCachePolicy()); | 6995 frame->dataSource()->getRequest().getCachePolicy()); |
6993 } | 6996 } |
6994 | 6997 |
6995 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) { | 6998 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) { |
6996 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 6999 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
6997 FrameTestHelpers::WebViewHelper webViewHelper; | 7000 FrameTestHelpers::WebViewHelper webViewHelper; |
6998 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", | 7001 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", |
(...skipping 13 matching lines...) Expand all Loading... |
7012 WebHistoryItem item; | 7015 WebHistoryItem item; |
7013 item.initialize(); | 7016 item.initialize(); |
7014 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 7017 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
7015 item.setURLString(historyURL.string()); | 7018 item.setURLString(historyURL.string()); |
7016 WebURLRequest request = mainFrame->requestFromHistoryItem( | 7019 WebURLRequest request = mainFrame->requestFromHistoryItem( |
7017 item, WebCachePolicy::UseProtocolCachePolicy); | 7020 item, WebCachePolicy::UseProtocolCachePolicy); |
7018 mainFrame->load(request, WebFrameLoadType::BackForward, item); | 7021 mainFrame->load(request, WebFrameLoadType::BackForward, item); |
7019 | 7022 |
7020 FrameTestHelpers::reloadFrame(childFrame); | 7023 FrameTestHelpers::reloadFrame(childFrame); |
7021 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); | 7024 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); |
7022 EXPECT_EQ(item.urlString(), | 7025 EXPECT_EQ( |
7023 WebString(mainFrameLoader.currentItem()->urlString())); | 7026 item.urlString(), |
| 7027 WebString(mainFrameLoader.documentLoader()->historyItem()->urlString())); |
7024 } | 7028 } |
7025 | 7029 |
7026 TEST_P(ParameterizedWebFrameTest, ReloadPost) { | 7030 TEST_P(ParameterizedWebFrameTest, ReloadPost) { |
7027 registerMockedHttpURLLoad("reload_post.html"); | 7031 registerMockedHttpURLLoad("reload_post.html"); |
7028 FrameTestHelpers::WebViewHelper webViewHelper; | 7032 FrameTestHelpers::WebViewHelper webViewHelper; |
7029 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 7033 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
7030 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7034 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7031 | 7035 |
7032 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 7036 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
7033 "javascript:document.forms[0].submit()"); | 7037 "javascript:document.forms[0].submit()"); |
(...skipping 12 matching lines...) Expand all Loading... |
7046 } | 7050 } |
7047 | 7051 |
7048 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { | 7052 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { |
7049 registerMockedHttpURLLoad("fragment_middle_click.html"); | 7053 registerMockedHttpURLLoad("fragment_middle_click.html"); |
7050 FrameTestHelpers::WebViewHelper webViewHelper; | 7054 FrameTestHelpers::WebViewHelper webViewHelper; |
7051 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", | 7055 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", |
7052 true); | 7056 true); |
7053 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7057 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7054 const FrameLoader& mainFrameLoader = | 7058 const FrameLoader& mainFrameLoader = |
7055 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7059 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
7056 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 7060 Persistent<HistoryItem> firstItem = |
| 7061 mainFrameLoader.documentLoader()->historyItem(); |
7057 EXPECT_TRUE(firstItem); | 7062 EXPECT_TRUE(firstItem); |
7058 | 7063 |
7059 registerMockedHttpURLLoad("white-1x1.png"); | 7064 registerMockedHttpURLLoad("white-1x1.png"); |
7060 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 7065 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
7061 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 7066 EXPECT_NE(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
7062 | 7067 |
7063 // Cache policy overrides should take. | 7068 // Cache policy overrides should take. |
7064 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), | 7069 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), |
7065 WebHistoryDifferentDocumentLoad, | 7070 WebHistoryDifferentDocumentLoad, |
7066 WebCachePolicy::ValidatingCacheData); | 7071 WebCachePolicy::ValidatingCacheData); |
7067 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 7072 EXPECT_EQ(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
7068 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 7073 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
7069 frame->dataSource()->getRequest().getCachePolicy()); | 7074 frame->dataSource()->getRequest().getCachePolicy()); |
7070 } | 7075 } |
7071 | 7076 |
7072 class TestCachePolicyWebFrameClient | 7077 class TestCachePolicyWebFrameClient |
7073 : public FrameTestHelpers::TestWebFrameClient { | 7078 : public FrameTestHelpers::TestWebFrameClient { |
7074 public: | 7079 public: |
7075 explicit TestCachePolicyWebFrameClient( | 7080 explicit TestCachePolicyWebFrameClient( |
7076 TestCachePolicyWebFrameClient* parentClient) | 7081 TestCachePolicyWebFrameClient* parentClient) |
7077 : m_parentClient(parentClient), | 7082 : m_parentClient(parentClient), |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7338 private: | 7343 private: |
7339 WebHistoryCommitType m_lastCommitType; | 7344 WebHistoryCommitType m_lastCommitType; |
7340 }; | 7345 }; |
7341 | 7346 |
7342 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) { | 7347 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) { |
7343 registerMockedHttpURLLoad("push_state.html"); | 7348 registerMockedHttpURLLoad("push_state.html"); |
7344 TestDidNavigateCommitTypeWebFrameClient client; | 7349 TestDidNavigateCommitTypeWebFrameClient client; |
7345 FrameTestHelpers::WebViewHelper webViewHelper; | 7350 FrameTestHelpers::WebViewHelper webViewHelper; |
7346 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( | 7351 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( |
7347 m_baseURL + "push_state.html", true, &client); | 7352 m_baseURL + "push_state.html", true, &client); |
7348 Persistent<HistoryItem> item = | 7353 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame()) |
7349 toLocalFrame(webViewImpl->page()->mainFrame())->loader().currentItem(); | 7354 ->loader() |
| 7355 .documentLoader() |
| 7356 ->historyItem(); |
7350 runPendingTasks(); | 7357 runPendingTasks(); |
7351 | 7358 |
7352 toLocalFrame(webViewImpl->page()->mainFrame()) | 7359 toLocalFrame(webViewImpl->page()->mainFrame()) |
7353 ->loader() | 7360 ->loader() |
7354 .load( | 7361 .load(FrameLoadRequest(nullptr, |
7355 FrameLoadRequest( | 7362 item->generateResourceRequest( |
7356 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 7363 WebCachePolicy::UseProtocolCachePolicy)), |
7357 item.get(), WebCachePolicy::UseProtocolCachePolicy)), | 7364 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); |
7358 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); | |
7359 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 7365 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
7360 } | 7366 } |
7361 | 7367 |
7362 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7368 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
7363 public: | 7369 public: |
7364 TestHistoryWebFrameClient() { | 7370 TestHistoryWebFrameClient() { |
7365 m_replacesCurrentHistoryItem = false; | 7371 m_replacesCurrentHistoryItem = false; |
7366 } | 7372 } |
7367 | 7373 |
7368 void didStartProvisionalLoad(WebDataSource* dataSource, | 7374 void didStartProvisionalLoad(WebDataSource* dataSource, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7474 | 7480 |
7475 FrameTestHelpers::WebViewHelper webViewHelper; | 7481 FrameTestHelpers::WebViewHelper webViewHelper; |
7476 webViewHelper.initialize(); | 7482 webViewHelper.initialize(); |
7477 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7483 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7478 const FrameLoader& mainFrameLoader = | 7484 const FrameLoader& mainFrameLoader = |
7479 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7485 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
7480 WebURLRequest request(toKURL(url)); | 7486 WebURLRequest request(toKURL(url)); |
7481 frame->loadRequest(request); | 7487 frame->loadRequest(request); |
7482 | 7488 |
7483 // Before commit, there is no history item. | 7489 // Before commit, there is no history item. |
7484 EXPECT_FALSE(mainFrameLoader.currentItem()); | 7490 EXPECT_FALSE(mainFrameLoader.documentLoader()->historyItem()); |
7485 | 7491 |
7486 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(frame); | 7492 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(frame); |
7487 | 7493 |
7488 // After commit, there is. | 7494 // After commit, there is. |
7489 HistoryItem* item = mainFrameLoader.currentItem(); | 7495 HistoryItem* item = mainFrameLoader.documentLoader()->historyItem(); |
7490 ASSERT_TRUE(item); | 7496 ASSERT_TRUE(item); |
7491 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 7497 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
7492 } | 7498 } |
7493 | 7499 |
7494 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 7500 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
7495 public: | 7501 public: |
7496 FailCreateChildFrame() : m_callCount(0) {} | 7502 FailCreateChildFrame() : m_callCount(0) {} |
7497 | 7503 |
7498 WebLocalFrame* createChildFrame( | 7504 WebLocalFrame* createChildFrame( |
7499 WebLocalFrame* parent, | 7505 WebLocalFrame* parent, |
(...skipping 3929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11429 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); | 11435 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
11430 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); | 11436 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
11431 EXPECT_FALSE(testSelectAll("<input>")); | 11437 EXPECT_FALSE(testSelectAll("<input>")); |
11432 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); | 11438 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
11433 // TODO(amaralp): Empty contenteditable should not have select all enabled. | 11439 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
11434 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); | 11440 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
11435 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); | 11441 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
11436 } | 11442 } |
11437 | 11443 |
11438 } // namespace blink | 11444 } // namespace blink |
OLD | NEW |