Commit f3e85f5d authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

Add additional checks to SavePage tests for MHTML

Ensure that all frames in the page loaded from mhtml
have unique origins and content-id urls (except for
the main frame which has a file url).

Bug: none
Change-Id: I0c1d40b82404de2e95e6a7e10dd354826a799d84
Reviewed-on: https://chromium-review.googlesource.com/c/1279188
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarŁukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599708}
parent 8052d0e1
......@@ -1072,6 +1072,15 @@ class SavePageOriginalVsSavedComparisonTest
expected_number_of_frames_in_original_page;
AssertExpectationsAboutCurrentTab(expected_number_of_frames_in_saved_page,
expected_substrings);
if (GetParam() == content::SAVE_PAGE_TYPE_AS_MHTML) {
std::set<url::Origin> origins;
GetCurrentTab(browser())->ForEachFrame(
base::BindRepeating(&CheckFrameForMHTML, base::Unretained(&origins)));
int unique_origins = origins.size();
EXPECT_EQ(expected_number_of_frames_in_saved_page, unique_origins)
<< "All origins should be unique";
}
}
// Helper method to deduplicate some code across 2 tests.
......@@ -1148,6 +1157,18 @@ class SavePageOriginalVsSavedComparisonTest
static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) {
(*i)++;
}
static void CheckFrameForMHTML(std::set<url::Origin>* origins,
content::RenderFrameHost* host) {
// See RFC n°2557, section-8.3: "Use of the Content-ID header and CID URLs".
const char kContentIdScheme[] = "cid";
origins->insert(host->GetLastCommittedOrigin());
EXPECT_TRUE(host->GetLastCommittedOrigin().opaque());
if (!host->GetParent())
EXPECT_TRUE(host->GetLastCommittedURL().SchemeIsFile());
else
EXPECT_TRUE(host->GetLastCommittedURL().SchemeIs(kContentIdScheme));
}
};
// Test coverage for:
......
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