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

Side by Side Diff: url/scheme_host_port_unittest.cc

Issue 2560923002: [url] Remove comparisons for blob/filesystem schemes in scheme_host_port (Closed)
Patch Set: Remove DCHECK, add comment to unit test (trybots prev) Created 4 years 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 | « url/scheme_host_port.cc ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 TEST(SchemeHostPortTest, Invalid) { 37 TEST(SchemeHostPortTest, Invalid) {
38 url::SchemeHostPort invalid; 38 url::SchemeHostPort invalid;
39 EXPECT_EQ("", invalid.scheme()); 39 EXPECT_EQ("", invalid.scheme());
40 EXPECT_EQ("", invalid.host()); 40 EXPECT_EQ("", invalid.host());
41 EXPECT_EQ(0, invalid.port()); 41 EXPECT_EQ(0, invalid.port());
42 EXPECT_TRUE(invalid.IsInvalid()); 42 EXPECT_TRUE(invalid.IsInvalid());
43 EXPECT_TRUE(invalid.Equals(invalid)); 43 EXPECT_TRUE(invalid.Equals(invalid));
44 44
45 const char* urls[] = {"data:text/html,Hello!", 45 const char* urls[] = {
46 "javascript:alert(1)", 46 "data:text/html,Hello!", "javascript:alert(1)",
47 "file://example.com:443/etc/passwd", 47 "file://example.com:443/etc/passwd",
48 "blob:https://example.com/uuid-goes-here", 48
49 "filesystem:https://example.com/temporary/yay.png"}; 49 // These schemes do not follow the generic URL syntax, so make sure we
50 // treat them as invalid (scheme, host, port) tuples (even though such
51 // URLs' _Origin_ might have a (scheme, host, port) tuple, they themselves
52 // do not). This is only *implicitly* checked in the code, by means of
53 // blob schemes not being standard, and filesystem schemes having type
54 // SCHEME_WITHOUT_AUTHORITY. If conditions change such that the implicit
55 // checks no longer hold, this policy should be made explicit.
56 "blob:https://example.com/uuid-goes-here",
57 "filesystem:https://example.com/temporary/yay.png"};
50 58
51 for (auto* test : urls) { 59 for (auto* test : urls) {
52 SCOPED_TRACE(test); 60 SCOPED_TRACE(test);
53 GURL url(test); 61 GURL url(test);
54 url::SchemeHostPort tuple(url); 62 url::SchemeHostPort tuple(url);
55 EXPECT_EQ("", tuple.scheme()); 63 EXPECT_EQ("", tuple.scheme());
56 EXPECT_EQ("", tuple.host()); 64 EXPECT_EQ("", tuple.host());
57 EXPECT_EQ(0, tuple.port()); 65 EXPECT_EQ(0, tuple.port());
58 EXPECT_TRUE(tuple.IsInvalid()); 66 EXPECT_TRUE(tuple.IsInvalid());
59 EXPECT_TRUE(tuple.Equals(tuple)); 67 EXPECT_TRUE(tuple.Equals(tuple));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 for (size_t j = i; j < arraysize(tuples); j++) { 246 for (size_t j = i; j < arraysize(tuples); j++) {
239 url::SchemeHostPort to_compare(tuples[j].scheme, tuples[j].host, 247 url::SchemeHostPort to_compare(tuples[j].scheme, tuples[j].host,
240 tuples[j].port); 248 tuples[j].port);
241 EXPECT_EQ(i < j, current < to_compare) << i << " < " << j; 249 EXPECT_EQ(i < j, current < to_compare) << i << " < " << j;
242 EXPECT_EQ(j < i, to_compare < current) << j << " < " << i; 250 EXPECT_EQ(j < i, to_compare < current) << j << " < " << i;
243 } 251 }
244 } 252 }
245 } 253 }
246 254
247 } // namespace url 255 } // namespace url
OLDNEW
« no previous file with comments | « url/scheme_host_port.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698