1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/password_manager/core/browser/psl_matching_helper.h"
7 #include "base/basictypes.h"
8 #include "components/autofill/core/common/password_form.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace password_manager {
15 TEST(PSLMatchingUtilsTest, IsPublicSuffixDomainMatch) {
23 { "http://facebook.com", "http://m.facebook.com", true },
24 { "http://www.facebook.com", "http://m.facebook.com", true },
25 { "http://www.example.com", "http://wwwexample.com", false },
26 { "http://www.example.com", "https://www.example.com", false },
27 { "http://www.example.com:123", "http://www.example.com", false },
28 { "http://www.example.org", "http://www.example.com", false },
31 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(pairs); ++i) {
32 autofill::PasswordForm form1;
33 form1.signon_realm = pairs[i].url1;
34 autofill::PasswordForm form2;
35 form2.signon_realm = pairs[i].url2;
36 EXPECT_EQ(pairs[i].should_match,
37 PSLMatchingHelper::IsPublicSuffixDomainMatch(form1.signon_realm,
39 << "First URL = " << pairs[i].url1
40 << ", second URL = " << pairs[i].url2;
46 } // namespace password_manager