Bug 1536596 - Added unit tests for AnonymizedOriginString. r=dom-workers-and-storage-reviewers,janv

Depends on D88288

Differential Revision: https://phabricator.services.mozilla.com/D88289
This commit is contained in:
Simon Giesecke 2020-08-26 13:54:53 +00:00
Родитель 0cb09645d3
Коммит 3dd521872b
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -380,6 +380,24 @@ TEST(QuotaCommon_ErrToOkOrErr, NsresultToNsCOMPtr_nullptr_Err)
EXPECT_EQ(res.unwrapErr(), NS_ERROR_UNEXPECTED);
}
class StringPairParameterized
: public ::testing::TestWithParam<std::pair<const char*, const char*>> {};
TEST_P(StringPairParameterized, AnonymizedOriginString) {
const auto [in, expectedAnonymized] = GetParam();
const auto anonymized = AnonymizedOriginString(nsDependentCString(in));
EXPECT_STREQ(anonymized.get(), expectedAnonymized);
}
INSTANTIATE_TEST_CASE_P(
QuotaCommon, StringPairParameterized,
::testing::Values(
// XXX Do we really want to anonymize about: origins?
std::pair("about:home", "about:aaaa"),
std::pair("https://foo.bar.com", "https://aaa.aaa.aaa"),
std::pair("https://foo.bar.com:8000", "https://aaa.aaa.aaa:DDDD"),
std::pair("file://UNIVERSAL_FILE_ORIGIN",
"file://aaaaaaaaa_aaaa_aaaaaa")));
TEST(QuotaCommon_ToResultGet, Lambda_NoInput)
{
auto task = [](nsresult* aRv) -> int32_t {