Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp

Issue 2196983002: Allow doc.written scripts with a matching domain and registry to execute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/network/NetworkUtils.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/network/NetworkUtils.h" 5 #include "platform/network/NetworkUtils.h"
6 6
7 #include "net/base/ip_address.h" 7 #include "net/base/ip_address.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "wtf/text/WTFString.h" 9 #include "wtf/text/WTFString.h"
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 String::fromUTF8(addressString.data(), 54 String::fromUTF8(addressString.data(),
55 addressString.length()))); 55 addressString.length())));
56 } else { 56 } else {
57 EXPECT_FALSE(NetworkUtils::isReservedIPAddress( 57 EXPECT_FALSE(NetworkUtils::isReservedIPAddress(
58 String::fromUTF8(addressString.data(), 58 String::fromUTF8(addressString.data(),
59 addressString.length()))); 59 addressString.length())));
60 } 60 }
61 } 61 }
62 } 62 }
63 63
64 TEST(NetworkUtilsTest, GetDomainAndRegistry)
65 {
66 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("", true));
67 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry(".", true));
68 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("..", true));
69 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("com", true));
70 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry(".com", true));
71 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("www.example.com:8000", tru e));
72
73 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("localhost", true));
74 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("127.0.0.1", true));
75
76 EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry("example.com", t rue));
77 EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry("www.example.com ", true));
78 EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry("multilevel.www. example.com", true));
79 EXPECT_EQ("example.co.uk", NetworkUtils::getDomainAndRegistry("www.example.c o.uk", true));
80
81 // Verify proper handling of 'private registries'.
82 EXPECT_EQ("foo.appspot.com", NetworkUtils::getDomainAndRegistry("www.foo.app spot.com", true));
83 EXPECT_EQ("appspot.com", NetworkUtils::getDomainAndRegistry("www.foo.appspot .com", false));
shivanisha 2016/08/01 16:35:55 Can we also include the example mentioned in the c
Bryan McQuade 2016/08/01 18:43:51 Ah, replied to the overall change rather than the
84
85 // Verify that unknown registries are included.
86 EXPECT_EQ("example.notarealregistry", NetworkUtils::getDomainAndRegistry("ww w.example.notarealregistry", true));
87 }
88
64 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/NetworkUtils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698