| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| index f07cc25b0229d67e22a0ba089313c8e906aee166..4f8620580eb622a3ffd06718aeea5344c22d45aa 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| @@ -4100,11 +4100,18 @@ TEST_P(ParameterizedWebFrameTest, ReloadDoesntSetRedirect) {
|
| class ClearScrollStateOnCommitWebFrameClient
|
| : public FrameTestHelpers::TestWebFrameClient {
|
| public:
|
| - void didCommitProvisionalLoad(WebLocalFrame* frame,
|
| + void didCommitProvisionalLoad(WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType) override {
|
| - frame->view()->resetScrollAndScaleState();
|
| + if (m_webView)
|
| + m_webView->resetScrollAndScaleState();
|
| }
|
| +
|
| + void setWebView(WebView* webView) { m_webView = webView; }
|
| +
|
| + private:
|
| + WebView* m_webView = nullptr;
|
| };
|
|
|
| TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) {
|
| @@ -4126,6 +4133,7 @@ TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) {
|
| webViewHelper.webView()->mainFrame()->setScrollOffset(
|
| WebSize(pageWidth / 4, pageHeight / 4));
|
| webViewHelper.webView()->setPageScaleFactor(pageScaleFactor);
|
| + client.setWebView(webViewHelper.webView());
|
|
|
| WebSize previousOffset =
|
| webViewHelper.webView()->mainFrame()->getScrollOffset();
|
| @@ -6127,10 +6135,11 @@ class TestSubstituteDataWebFrameClient
|
| error.unreachableURL, true);
|
| }
|
|
|
| - virtual void didCommitProvisionalLoad(WebLocalFrame* frame,
|
| + virtual void didCommitProvisionalLoad(WebDataSource* dataSource,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType) {
|
| - if (frame->dataSource()->response().url() !=
|
| + if (dataSource->response().url() !=
|
| WebURL(URLTestHelpers::toKURL("about:blank")))
|
| m_commitCalled = true;
|
| }
|
| @@ -6182,7 +6191,8 @@ class TestWillInsertBodyWebFrameClient
|
| public:
|
| TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) {}
|
|
|
| - void didCommitProvisionalLoad(WebLocalFrame*,
|
| + void didCommitProvisionalLoad(WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType) override {
|
| m_numBodies = 0;
|
| @@ -6853,7 +6863,8 @@ TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) {
|
| class TestNavigationPolicyWebFrameClient
|
| : public FrameTestHelpers::TestWebFrameClient {
|
| public:
|
| - void didNavigateWithinPage(WebLocalFrame*,
|
| + void didNavigateWithinPage(WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType,
|
| bool) override {
|
| @@ -7020,8 +7031,6 @@ TEST_P(ParameterizedWebFrameTest, ReloadPost) {
|
| FrameTestHelpers::reloadFrame(frame);
|
| EXPECT_EQ(WebCachePolicy::ValidatingCacheData,
|
| frame->dataSource()->getRequest().getCachePolicy());
|
| - EXPECT_EQ(WebNavigationTypeFormResubmitted,
|
| - frame->dataSource()->navigationType());
|
| }
|
|
|
| TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) {
|
| @@ -7097,7 +7106,9 @@ class TestCachePolicyWebFrameClient
|
| TestWebFrameClient::didStopLoading();
|
| }
|
|
|
| - void willSendRequest(WebLocalFrame*, WebURLRequest& request) override {
|
| + void willSendRequest(WebLocalFrame*,
|
| + WebURLRequest& request,
|
| + WebFrameLoadType) override {
|
| m_policy = request.getCachePolicy();
|
| m_willSendRequestCallCount++;
|
| }
|
| @@ -7154,7 +7165,9 @@ class TestSameDocumentWebFrameClient
|
| TestSameDocumentWebFrameClient()
|
| : m_frameLoadTypeReloadMainResourceSeen(false) {}
|
|
|
| - virtual void willSendRequest(WebLocalFrame* frame, WebURLRequest&) {
|
| + virtual void willSendRequest(WebLocalFrame* frame,
|
| + WebURLRequest&,
|
| + WebFrameLoadType) {
|
| FrameLoader& frameLoader = toWebLocalFrameImpl(frame)->frame()->loader();
|
| if (frameLoader.provisionalDocumentLoader()->loadType() ==
|
| FrameLoadTypeReloadMainResource)
|
| @@ -7196,7 +7209,9 @@ class TestSameDocumentWithImageWebFrameClient
|
| public:
|
| TestSameDocumentWithImageWebFrameClient() : m_numOfImageRequests(0) {}
|
|
|
| - virtual void willSendRequest(WebLocalFrame*, WebURLRequest& request) {
|
| + virtual void willSendRequest(WebLocalFrame*,
|
| + WebURLRequest& request,
|
| + WebFrameLoadType) {
|
| if (request.getRequestContext() == WebURLRequest::RequestContextImage) {
|
| m_numOfImageRequests++;
|
| EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy,
|
| @@ -7307,7 +7322,8 @@ class TestDidNavigateCommitTypeWebFrameClient
|
| TestDidNavigateCommitTypeWebFrameClient()
|
| : m_lastCommitType(WebHistoryInertCommit) {}
|
|
|
| - void didNavigateWithinPage(WebLocalFrame*,
|
| + void didNavigateWithinPage(WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType type,
|
| bool) override {
|
| @@ -7344,21 +7360,17 @@ class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
|
| public:
|
| TestHistoryWebFrameClient() {
|
| m_replacesCurrentHistoryItem = false;
|
| - m_frame = nullptr;
|
| }
|
|
|
| - void didStartProvisionalLoad(WebLocalFrame* frame) {
|
| - WebDataSource* ds = frame->provisionalDataSource();
|
| - m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem();
|
| - m_frame = frame;
|
| + void didStartProvisionalLoad(WebDataSource*, WebFrameLoadType loadType) {
|
| + m_replacesCurrentHistoryItem =
|
| + loadType == WebFrameLoadType::ReplaceCurrentItem;
|
| }
|
|
|
| bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; }
|
| - WebFrame* frame() { return m_frame; }
|
|
|
| private:
|
| bool m_replacesCurrentHistoryItem;
|
| - WebFrame* m_frame;
|
| };
|
|
|
| // Tests that the first navigation in an initially blank subframe will result in
|
| @@ -7378,17 +7390,14 @@ TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) {
|
|
|
| WebFrame* iframe = frame->firstChild();
|
| ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client());
|
| - EXPECT_EQ(iframe, client.frame());
|
|
|
| std::string url1 = m_baseURL + "history.html";
|
| FrameTestHelpers::loadFrame(iframe, url1);
|
| - EXPECT_EQ(iframe, client.frame());
|
| EXPECT_EQ(url1, iframe->document().url().string().utf8());
|
| EXPECT_TRUE(client.replacesCurrentHistoryItem());
|
|
|
| std::string url2 = m_baseURL + "find.html";
|
| FrameTestHelpers::loadFrame(iframe, url2);
|
| - EXPECT_EQ(iframe, client.frame());
|
| EXPECT_EQ(url2, iframe->document().url().string().utf8());
|
| EXPECT_FALSE(client.replacesCurrentHistoryItem());
|
| }
|
| @@ -7415,12 +7424,10 @@ TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) {
|
| "document.body.appendChild(f)");
|
|
|
| WebFrame* iframe = frame->firstChild();
|
| - EXPECT_EQ(iframe, client.frame());
|
| EXPECT_EQ(url1, iframe->document().url().string().utf8());
|
|
|
| std::string url2 = m_baseURL + "find.html";
|
| FrameTestHelpers::loadFrame(iframe, url2);
|
| - EXPECT_EQ(iframe, client.frame());
|
| EXPECT_EQ(url2, iframe->document().url().string().utf8());
|
| EXPECT_FALSE(client.replacesCurrentHistoryItem());
|
| }
|
| @@ -8967,20 +8974,25 @@ class RemoteToLocalSwapWebFrameClient
|
| public:
|
| explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame)
|
| : m_historyCommitType(WebHistoryInertCommit),
|
| - m_remoteFrame(remoteFrame) {}
|
| + m_remoteFrame(remoteFrame),
|
| + m_localFrame(nullptr) {}
|
|
|
| void didCommitProvisionalLoad(
|
| - WebLocalFrame* frame,
|
| + WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType historyCommitType) override {
|
| m_historyCommitType = historyCommitType;
|
| - m_remoteFrame->swap(frame);
|
| + if (m_localFrame)
|
| + m_remoteFrame->swap(m_localFrame);
|
| }
|
|
|
| WebHistoryCommitType historyCommitType() const { return m_historyCommitType; }
|
| + void setLocalFrame(WebLocalFrame* localFrame) { m_localFrame = localFrame; }
|
|
|
| WebHistoryCommitType m_historyCommitType;
|
| WebRemoteFrame* m_remoteFrame;
|
| + WebLocalFrame* m_localFrame;
|
| };
|
|
|
| // The commit type should be Initial if we are swapping a RemoteFrame to a
|
| @@ -9000,6 +9012,7 @@ TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterNewRemoteToLocalSwap) {
|
| RemoteToLocalSwapWebFrameClient client(remoteFrame);
|
| WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
|
| &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
|
| + client.setLocalFrame(localFrame);
|
| FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
|
| EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
|
|
|
| @@ -9025,6 +9038,7 @@ TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) {
|
| RemoteToLocalSwapWebFrameClient client(remoteFrame);
|
| WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
|
| &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
|
| + client.setLocalFrame(localFrame);
|
| localFrame->setCommittedFirstRealLoad();
|
| FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
|
| EXPECT_EQ(WebStandardCommit, client.historyCommitType());
|
| @@ -9058,6 +9072,7 @@ TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap) {
|
| RemoteToLocalSwapWebFrameClient client(remoteFrame);
|
| WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
|
| &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
|
| + client.setLocalFrame(localFrame);
|
| FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
|
| EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8());
|
| EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)
|
| @@ -9085,6 +9100,7 @@ TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap) {
|
| RemoteToLocalSwapWebFrameClient client2(remoteFrame2);
|
| WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(
|
| &client2, nullptr, nullptr, remoteFrame2, WebSandboxFlags::None);
|
| + client.setLocalFrame(localFrame);
|
| FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html");
|
| EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8());
|
| EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)
|
| @@ -9269,7 +9285,8 @@ class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
|
| : m_historyCommitType(WebHistoryInertCommit) {}
|
|
|
| void didCommitProvisionalLoad(
|
| - WebLocalFrame*,
|
| + WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType historyCommitType) override {
|
| m_historyCommitType = historyCommitType;
|
| @@ -10079,10 +10096,11 @@ class CallbackOrderingWebFrameClient
|
| EXPECT_EQ(0, m_callbackCount++);
|
| FrameTestHelpers::TestWebFrameClient::didStartLoading(toDifferentDocument);
|
| }
|
| - void didStartProvisionalLoad(WebLocalFrame*) override {
|
| + void didStartProvisionalLoad(WebDataSource*, WebFrameLoadType) override {
|
| EXPECT_EQ(1, m_callbackCount++);
|
| }
|
| - void didCommitProvisionalLoad(WebLocalFrame*,
|
| + void didCommitProvisionalLoad(WebDataSource*,
|
| + WebFrameLoadType,
|
| const WebHistoryItem&,
|
| WebHistoryCommitType) override {
|
| EXPECT_EQ(2, m_callbackCount++);
|
| @@ -10468,7 +10486,9 @@ class TestResourcePriorityWebFrameClient
|
|
|
| TestResourcePriorityWebFrameClient() {}
|
|
|
| - void willSendRequest(WebLocalFrame*, WebURLRequest& request) override {
|
| + void willSendRequest(WebLocalFrame*,
|
| + WebURLRequest& request,
|
| + WebFrameLoadType) override {
|
| ExpectedRequest* expectedRequest = m_expectedRequests.get(request.url());
|
| DCHECK(expectedRequest);
|
| EXPECT_EQ(expectedRequest->priority, request.getPriority());
|
|
|