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