Commit 4bfb1418 authored by lukasza's avatar lukasza Committed by Commit bot

Verify other multi-frame concerns in SaveCrossSitePage test.

After the changes the test:

- Continues to test cross-site / multiple-renderer-processes case.

- Starts to verify that frame links got correctly replaced with
  local paths (this uses a separate code path from replacing links
  of other, non-frame savable resources).

- Starts to test that deduplication of savable resources happens across frames
  (deduplication got moved into the browser process in
  https://chromium.googlesource.com/chromium/src/+/6af746b740287560dbc9e85d22738000bc72b521).

BUG=526786

Review URL: https://codereview.chromium.org/1362973003

Cr-Commit-Position: refs/heads/master@{#351133}
parent 9a60f773
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/url_request/url_request_mock_http_job.h" #include "net/test/url_request/url_request_mock_http_job.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::BrowserContext; using content::BrowserContext;
...@@ -55,6 +56,7 @@ using content::DownloadItem; ...@@ -55,6 +56,7 @@ using content::DownloadItem;
using content::DownloadManager; using content::DownloadManager;
using content::WebContents; using content::WebContents;
using net::URLRequestMockHTTPJob; using net::URLRequestMockHTTPJob;
using testing::HasSubstr;
namespace { namespace {
...@@ -809,19 +811,21 @@ IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) { ...@@ -809,19 +811,21 @@ IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) {
return; // Avoid failing on Site Isolation FYI bot. return; // Avoid failing on Site Isolation FYI bot.
} }
GURL url(embedded_test_server()->GetURL( GURL url(embedded_test_server()->GetURL("a.com", "/save_page/iframes.htm"));
"a.com", "/frame_tree/page_with_two_frames_remote_and_local.html"));
ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURL(browser(), url);
base::FilePath full_file_name, dir; base::FilePath full_file_name, dir;
SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "xsite1", 3, SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "iframes", 5,
&dir, &full_file_name); &dir, &full_file_name);
ASSERT_FALSE(HasFailure()); ASSERT_FALSE(HasFailure());
EXPECT_TRUE(base::DirectoryExists(dir)); EXPECT_TRUE(base::DirectoryExists(dir));
base::FilePath expected_files[] = { base::FilePath expected_files[] = {
full_file_name, dir.AppendASCII("title1.html"), full_file_name,
dir.AppendASCII("title1(1).html"), dir.AppendASCII("a.html"), // From iframes.htm
dir.AppendASCII("b.html"), // From iframes.htm
dir.AppendASCII("1.css"), // From b.htm
dir.AppendASCII("1.png"), // Deduplicated from iframes.htm and b.htm.
}; };
for (auto file_path : expected_files) { for (auto file_path : expected_files) {
EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value() EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value()
...@@ -831,6 +835,18 @@ IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) { ...@@ -831,6 +835,18 @@ IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) {
EXPECT_NE(0, actual_file_size) << "Is " << file_path.value() EXPECT_NE(0, actual_file_size) << "Is " << file_path.value()
<< " non-empty?"; << " non-empty?";
} }
// Verify that local links got correctly replaced with local paths
// (most importantly for iframe elements, which are only exercised
// by this particular test).
std::string main_contents;
ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents));
EXPECT_THAT(main_contents,
HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>"));
EXPECT_THAT(main_contents,
HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>"));
EXPECT_THAT(main_contents,
HasSubstr("<img src=\"./iframes_files/1.png\">"));
} }
} // namespace } // namespace
<!doctype html>
<html>
<head></head>
<body>
<h1>Test page features</h1>
This page has two iframes: one is cross-site, the other is same-site.
This helps test save-page when page spans multiple renderer processes.
This page has iframes - this exercises a different link-to-local-path
replacement code than the one used for non-frames / for savable-resources.
This page references /save_page/1.png resource from both
1) the main frame and 2) the /save_page/b.htm same-site subframe
(same-site means that #1 and #2 refer to 1.png via the same url).
This helps test that savable resources are deduplicated across frames.
<h1>Test content</h1>
<iframe src="/cross-site/bar.com/save_page/a.htm"></iframe>
<iframe src="b.htm"></iframe>
<img src="1.png"/>
</body>
</html>
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