Commit 736fcf50 authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

[MHTML] Test is_mhtml_document() after same-document navigation.

The RenderFrameHostImpl::is_mhtml_document_ attribute is reset after
same-document navigation, which is a bug found in:
https://chromium-review.googlesource.com/c/chromium/src/+/2395777

This adds regression tests. The fix is easy and will come in follow-ups.

Bug: 1126391
Change-Id: Ic5d166da4a73cda7e5fe9a04402cb0a813c9bf49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401019Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805331}
parent 631406ae
......@@ -29,6 +29,7 @@
#include "mojo/public/cpp/system/handle_signals_state.h"
#include "mojo/public/cpp/system/simple_watcher.h"
#include "net/base/filename_util.h"
#include "net/dns/mock_host_resolver.h"
#include "url/gurl.h"
#include "url/url_constants.h"
......@@ -46,6 +47,12 @@ class NavigationMhtmlBrowserTest : public ContentBrowserTest {
RenderFrameHostImpl* main_frame_host() {
return web_contents()->GetFrameTree()->root()->current_frame_host();
}
protected:
void SetUpOnMainThread() final {
ContentBrowserTest::SetUpOnMainThread();
host_resolver()->AddRule("*", "127.0.0.1");
}
};
// Helper class: Build MHTML documents easily in tests.
......@@ -570,4 +577,40 @@ IN_PROC_BROWSER_TEST_F(NavigationMhtmlBrowserTest,
EXPECT_EQ(mhtml_url_with_fragment, main_frame_host()->GetLastCommittedURL());
}
// Check RenderFrameHostImpl::is_mhtml_document() stays true after same-document
// navigation in MHTML document.
// Regression test for https://crbug.com/1126391
IN_PROC_BROWSER_TEST_F(NavigationMhtmlBrowserTest,
SameDocumentNavigationPreservesMhtmlFlag) {
MhtmlArchive mhtml_archive;
mhtml_archive.AddHtmlDocument(GURL("http://a.com/a"), "");
GURL mhtml_url = mhtml_archive.Write("index.mhtml");
EXPECT_TRUE(NavigateToURL(shell(), mhtml_url));
EXPECT_TRUE(main_frame_host()->is_mhtml_document());
EXPECT_TRUE(NavigateToURL(
shell(), GURL(main_frame_host()->GetLastCommittedURL().spec() + "#foo")));
// TODO(https://crbug.com/1126391): This should be true instead.
EXPECT_FALSE(main_frame_host()->is_mhtml_document());
}
// Check RenderFrameHostImpl::is_mhtml_document() is correctly set for history
// navigation to MHTML document. It should continue to work when restored from
// the BackForwardCache.
IN_PROC_BROWSER_TEST_F(NavigationMhtmlBrowserTest,
BackNavigationPreservesMhtmlFlag) {
ASSERT_TRUE(embedded_test_server()->Start());
MhtmlArchive mhtml_archive;
mhtml_archive.AddHtmlDocument(GURL("http://a.com/a"), "");
GURL mhtml_url = mhtml_archive.Write("index.mhtml");
EXPECT_TRUE(NavigateToURL(shell(), mhtml_url));
EXPECT_TRUE(main_frame_host()->is_mhtml_document());
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("b.com", "/title1.html")));
EXPECT_FALSE(main_frame_host()->is_mhtml_document());
web_contents()->GetController().GoBack();
WaitForLoadStop(web_contents());
EXPECT_TRUE(main_frame_host()->is_mhtml_document());
}
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment