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 2395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 | 2406 |
2407 FrameTestHelpers::WebViewHelper webViewHelper; | 2407 FrameTestHelpers::WebViewHelper webViewHelper; |
2408 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, | 2408 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, |
2409 nullptr, &client, nullptr, | 2409 nullptr, &client, nullptr, |
2410 enableViewportSettings); | 2410 enableViewportSettings); |
2411 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2411 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2412 | 2412 |
2413 webViewHelper.webView()->setPageScaleFactor(3); | 2413 webViewHelper.webView()->setPageScaleFactor(3); |
2414 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 2414 EXPECT_EQ(3, toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
2415 ->loader() | 2415 ->loader() |
2416 .currentItem() | 2416 .documentLoader() |
| 2417 ->historyItem() |
2417 ->pageScaleFactor()); | 2418 ->pageScaleFactor()); |
2418 } | 2419 } |
2419 | 2420 |
2420 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) { | 2421 TEST_P(ParameterizedWebFrameTest, initialScaleWrittenToHistoryItem) { |
2421 registerMockedHttpURLLoad("fixed_layout.html"); | 2422 registerMockedHttpURLLoad("fixed_layout.html"); |
2422 | 2423 |
2423 FixedLayoutTestWebViewClient client; | 2424 FixedLayoutTestWebViewClient client; |
2424 client.m_screenInfo.deviceScaleFactor = 1; | 2425 client.m_screenInfo.deviceScaleFactor = 1; |
2425 int viewportWidth = 640; | 2426 int viewportWidth = 640; |
2426 int viewportHeight = 480; | 2427 int viewportHeight = 480; |
2427 | 2428 |
2428 FrameTestHelpers::WebViewHelper webViewHelper; | 2429 FrameTestHelpers::WebViewHelper webViewHelper; |
2429 webViewHelper.initialize(true, nullptr, &client, nullptr, | 2430 webViewHelper.initialize(true, nullptr, &client, nullptr, |
2430 enableViewportSettings); | 2431 enableViewportSettings); |
2431 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); | 2432 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); |
2432 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 2433 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
2433 m_baseURL + "fixed_layout.html"); | 2434 m_baseURL + "fixed_layout.html"); |
2434 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 2435 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
2435 | 2436 |
2436 int defaultFixedLayoutWidth = 980; | 2437 int defaultFixedLayoutWidth = 980; |
2437 float minimumPageScaleFactor = viewportWidth / (float)defaultFixedLayoutWidth; | 2438 float minimumPageScaleFactor = viewportWidth / (float)defaultFixedLayoutWidth; |
2438 EXPECT_EQ(minimumPageScaleFactor, | 2439 EXPECT_EQ(minimumPageScaleFactor, |
2439 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 2440 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
2440 ->loader() | 2441 ->loader() |
2441 .currentItem() | 2442 .documentLoader() |
| 2443 ->historyItem() |
2442 ->pageScaleFactor()); | 2444 ->pageScaleFactor()); |
2443 } | 2445 } |
2444 | 2446 |
2445 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) { | 2447 TEST_P(ParameterizedWebFrameTest, pageScaleFactorDoesntShrinkFrameView) { |
2446 registerMockedHttpURLLoad("large-div.html"); | 2448 registerMockedHttpURLLoad("large-div.html"); |
2447 | 2449 |
2448 FixedLayoutTestWebViewClient client; | 2450 FixedLayoutTestWebViewClient client; |
2449 client.m_screenInfo.deviceScaleFactor = 1; | 2451 client.m_screenInfo.deviceScaleFactor = 1; |
2450 // Small viewport to ensure there are always scrollbars. | 2452 // Small viewport to ensure there are always scrollbars. |
2451 int viewportWidth = 64; | 2453 int viewportWidth = 64; |
(...skipping 4576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7028 } | 7030 } |
7029 | 7031 |
7030 TEST_P(ParameterizedWebFrameTest, BackToReload) { | 7032 TEST_P(ParameterizedWebFrameTest, BackToReload) { |
7031 registerMockedHttpURLLoad("fragment_middle_click.html"); | 7033 registerMockedHttpURLLoad("fragment_middle_click.html"); |
7032 FrameTestHelpers::WebViewHelper webViewHelper; | 7034 FrameTestHelpers::WebViewHelper webViewHelper; |
7033 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", | 7035 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", |
7034 true); | 7036 true); |
7035 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7037 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7036 const FrameLoader& mainFrameLoader = | 7038 const FrameLoader& mainFrameLoader = |
7037 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7039 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
7038 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 7040 Persistent<HistoryItem> firstItem = |
| 7041 mainFrameLoader.documentLoader()->historyItem(); |
7039 EXPECT_TRUE(firstItem); | 7042 EXPECT_TRUE(firstItem); |
7040 | 7043 |
7041 registerMockedHttpURLLoad("white-1x1.png"); | 7044 registerMockedHttpURLLoad("white-1x1.png"); |
7042 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 7045 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
7043 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 7046 EXPECT_NE(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
7044 | 7047 |
7045 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), | 7048 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), |
7046 WebHistoryDifferentDocumentLoad, | 7049 WebHistoryDifferentDocumentLoad, |
7047 WebCachePolicy::UseProtocolCachePolicy); | 7050 WebCachePolicy::UseProtocolCachePolicy); |
7048 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 7051 EXPECT_EQ(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
7049 | 7052 |
7050 FrameTestHelpers::reloadFrame(frame); | 7053 FrameTestHelpers::reloadFrame(frame); |
7051 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 7054 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
7052 frame->dataSource()->getRequest().getCachePolicy()); | 7055 frame->dataSource()->getRequest().getCachePolicy()); |
7053 } | 7056 } |
7054 | 7057 |
7055 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) { | 7058 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) { |
7056 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 7059 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
7057 FrameTestHelpers::WebViewHelper webViewHelper; | 7060 FrameTestHelpers::WebViewHelper webViewHelper; |
7058 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", | 7061 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", |
(...skipping 13 matching lines...) Expand all Loading... |
7072 WebHistoryItem item; | 7075 WebHistoryItem item; |
7073 item.initialize(); | 7076 item.initialize(); |
7074 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 7077 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
7075 item.setURLString(historyURL.string()); | 7078 item.setURLString(historyURL.string()); |
7076 WebURLRequest request = mainFrame->requestFromHistoryItem( | 7079 WebURLRequest request = mainFrame->requestFromHistoryItem( |
7077 item, WebCachePolicy::UseProtocolCachePolicy); | 7080 item, WebCachePolicy::UseProtocolCachePolicy); |
7078 mainFrame->load(request, WebFrameLoadType::BackForward, item); | 7081 mainFrame->load(request, WebFrameLoadType::BackForward, item); |
7079 | 7082 |
7080 FrameTestHelpers::reloadFrame(childFrame); | 7083 FrameTestHelpers::reloadFrame(childFrame); |
7081 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); | 7084 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); |
7082 EXPECT_EQ(item.urlString(), | 7085 EXPECT_EQ( |
7083 WebString(mainFrameLoader.currentItem()->urlString())); | 7086 item.urlString(), |
| 7087 WebString(mainFrameLoader.documentLoader()->historyItem()->urlString())); |
7084 } | 7088 } |
7085 | 7089 |
7086 TEST_P(ParameterizedWebFrameTest, ReloadPost) { | 7090 TEST_P(ParameterizedWebFrameTest, ReloadPost) { |
7087 registerMockedHttpURLLoad("reload_post.html"); | 7091 registerMockedHttpURLLoad("reload_post.html"); |
7088 FrameTestHelpers::WebViewHelper webViewHelper; | 7092 FrameTestHelpers::WebViewHelper webViewHelper; |
7089 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 7093 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
7090 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7094 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7091 | 7095 |
7092 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 7096 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
7093 "javascript:document.forms[0].submit()"); | 7097 "javascript:document.forms[0].submit()"); |
(...skipping 12 matching lines...) Expand all Loading... |
7106 } | 7110 } |
7107 | 7111 |
7108 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { | 7112 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { |
7109 registerMockedHttpURLLoad("fragment_middle_click.html"); | 7113 registerMockedHttpURLLoad("fragment_middle_click.html"); |
7110 FrameTestHelpers::WebViewHelper webViewHelper; | 7114 FrameTestHelpers::WebViewHelper webViewHelper; |
7111 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", | 7115 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", |
7112 true); | 7116 true); |
7113 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7117 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7114 const FrameLoader& mainFrameLoader = | 7118 const FrameLoader& mainFrameLoader = |
7115 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7119 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
7116 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 7120 Persistent<HistoryItem> firstItem = |
| 7121 mainFrameLoader.documentLoader()->historyItem(); |
7117 EXPECT_TRUE(firstItem); | 7122 EXPECT_TRUE(firstItem); |
7118 | 7123 |
7119 registerMockedHttpURLLoad("white-1x1.png"); | 7124 registerMockedHttpURLLoad("white-1x1.png"); |
7120 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 7125 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
7121 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 7126 EXPECT_NE(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
7122 | 7127 |
7123 // Cache policy overrides should take. | 7128 // Cache policy overrides should take. |
7124 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), | 7129 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), |
7125 WebHistoryDifferentDocumentLoad, | 7130 WebHistoryDifferentDocumentLoad, |
7126 WebCachePolicy::ValidatingCacheData); | 7131 WebCachePolicy::ValidatingCacheData); |
7127 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 7132 EXPECT_EQ(firstItem.get(), mainFrameLoader.documentLoader()->historyItem()); |
7128 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 7133 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
7129 frame->dataSource()->getRequest().getCachePolicy()); | 7134 frame->dataSource()->getRequest().getCachePolicy()); |
7130 } | 7135 } |
7131 | 7136 |
7132 class TestCachePolicyWebFrameClient | 7137 class TestCachePolicyWebFrameClient |
7133 : public FrameTestHelpers::TestWebFrameClient { | 7138 : public FrameTestHelpers::TestWebFrameClient { |
7134 public: | 7139 public: |
7135 explicit TestCachePolicyWebFrameClient( | 7140 explicit TestCachePolicyWebFrameClient( |
7136 TestCachePolicyWebFrameClient* parentClient) | 7141 TestCachePolicyWebFrameClient* parentClient) |
7137 : m_parentClient(parentClient), | 7142 : m_parentClient(parentClient), |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7395 private: | 7400 private: |
7396 WebHistoryCommitType m_lastCommitType; | 7401 WebHistoryCommitType m_lastCommitType; |
7397 }; | 7402 }; |
7398 | 7403 |
7399 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) { | 7404 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) { |
7400 registerMockedHttpURLLoad("push_state.html"); | 7405 registerMockedHttpURLLoad("push_state.html"); |
7401 TestDidNavigateCommitTypeWebFrameClient client; | 7406 TestDidNavigateCommitTypeWebFrameClient client; |
7402 FrameTestHelpers::WebViewHelper webViewHelper; | 7407 FrameTestHelpers::WebViewHelper webViewHelper; |
7403 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( | 7408 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( |
7404 m_baseURL + "push_state.html", true, &client); | 7409 m_baseURL + "push_state.html", true, &client); |
7405 Persistent<HistoryItem> item = | 7410 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame()) |
7406 toLocalFrame(webViewImpl->page()->mainFrame())->loader().currentItem(); | 7411 ->loader() |
| 7412 .documentLoader() |
| 7413 ->historyItem(); |
7407 runPendingTasks(); | 7414 runPendingTasks(); |
7408 | 7415 |
7409 toLocalFrame(webViewImpl->page()->mainFrame()) | 7416 toLocalFrame(webViewImpl->page()->mainFrame()) |
7410 ->loader() | 7417 ->loader() |
7411 .load( | 7418 .load(FrameLoadRequest(nullptr, |
7412 FrameLoadRequest( | 7419 item->generateResourceRequest( |
7413 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 7420 WebCachePolicy::UseProtocolCachePolicy)), |
7414 item.get(), WebCachePolicy::UseProtocolCachePolicy)), | 7421 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); |
7415 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); | |
7416 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 7422 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
7417 } | 7423 } |
7418 | 7424 |
7419 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7425 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
7420 public: | 7426 public: |
7421 TestHistoryWebFrameClient() { | 7427 TestHistoryWebFrameClient() { |
7422 m_replacesCurrentHistoryItem = false; | 7428 m_replacesCurrentHistoryItem = false; |
7423 } | 7429 } |
7424 | 7430 |
7425 void didStartProvisionalLoad(WebDataSource* dataSource, | 7431 void didStartProvisionalLoad(WebDataSource* dataSource, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7531 | 7537 |
7532 FrameTestHelpers::WebViewHelper webViewHelper; | 7538 FrameTestHelpers::WebViewHelper webViewHelper; |
7533 webViewHelper.initialize(); | 7539 webViewHelper.initialize(); |
7534 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7540 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
7535 const FrameLoader& mainFrameLoader = | 7541 const FrameLoader& mainFrameLoader = |
7536 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7542 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
7537 WebURLRequest request(toKURL(url)); | 7543 WebURLRequest request(toKURL(url)); |
7538 frame->loadRequest(request); | 7544 frame->loadRequest(request); |
7539 | 7545 |
7540 // Before commit, there is no history item. | 7546 // Before commit, there is no history item. |
7541 EXPECT_FALSE(mainFrameLoader.currentItem()); | 7547 EXPECT_FALSE(mainFrameLoader.documentLoader()->historyItem()); |
7542 | 7548 |
7543 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(frame); | 7549 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(frame); |
7544 | 7550 |
7545 // After commit, there is. | 7551 // After commit, there is. |
7546 HistoryItem* item = mainFrameLoader.currentItem(); | 7552 HistoryItem* item = mainFrameLoader.documentLoader()->historyItem(); |
7547 ASSERT_TRUE(item); | 7553 ASSERT_TRUE(item); |
7548 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 7554 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
7549 } | 7555 } |
7550 | 7556 |
7551 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 7557 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
7552 public: | 7558 public: |
7553 FailCreateChildFrame() : m_callCount(0) {} | 7559 FailCreateChildFrame() : m_callCount(0) {} |
7554 | 7560 |
7555 WebLocalFrame* createChildFrame( | 7561 WebLocalFrame* createChildFrame( |
7556 WebLocalFrame* parent, | 7562 WebLocalFrame* parent, |
(...skipping 4002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11559 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); | 11565 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
11560 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); | 11566 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
11561 EXPECT_FALSE(testSelectAll("<input>")); | 11567 EXPECT_FALSE(testSelectAll("<input>")); |
11562 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); | 11568 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
11563 // TODO(amaralp): Empty contenteditable should not have select all enabled. | 11569 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
11564 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); | 11570 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
11565 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); | 11571 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
11566 } | 11572 } |
11567 | 11573 |
11568 } // namespace blink | 11574 } // namespace blink |
OLD | NEW |