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

Side by Side Diff: url/gurl_unittest.cc

Issue 23835019: Support URL fragment resolution againt non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: brettw2 Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « url/gurl.cc ('k') | url/third_party/mozilla/url_parse.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "url/gurl.h" 6 #include "url/gurl.h"
7 #include "url/url_canon.h" 7 #include "url/url_canon.h"
8 #include "url/url_test_utils.h" 8 #include "url/url_test_utils.h"
9 9
10 // Some implementations of base/basictypes.h may define ARRAYSIZE. 10 // Some implementations of base/basictypes.h may define ARRAYSIZE.
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 SetupReplacement(&GURL::Replacements::SetPath, &repl, cur.path); 343 SetupReplacement(&GURL::Replacements::SetPath, &repl, cur.path);
344 SetupReplacement(&GURL::Replacements::SetQuery, &repl, cur.query); 344 SetupReplacement(&GURL::Replacements::SetQuery, &repl, cur.query);
345 SetupReplacement(&GURL::Replacements::SetRef, &repl, cur.ref); 345 SetupReplacement(&GURL::Replacements::SetRef, &repl, cur.ref);
346 GURL output = url.ReplaceComponents(repl); 346 GURL output = url.ReplaceComponents(repl);
347 347
348 EXPECT_EQ(replace_cases[i].expected, output.spec()); 348 EXPECT_EQ(replace_cases[i].expected, output.spec());
349 EXPECT_EQ(output.SchemeIsFileSystem(), output.inner_url() != NULL); 349 EXPECT_EQ(output.SchemeIsFileSystem(), output.inner_url() != NULL);
350 } 350 }
351 } 351 }
352 352
353 TEST(GURLTest, ClearFragmentOnDataUrl) {
354 // http://crbug.com/291747 - a data URL may legitimately have trailing
355 // whitespace in the spec after the ref is cleared. Test this does not trigger
356 // the url_parse::Parsed importing validation DCHECK in GURL.
357 GURL url(" data: one ? two # three ");
358
359 // By default the trailing whitespace will have been stripped.
360 EXPECT_EQ("data: one ? two # three", url.spec());
361 GURL::Replacements repl;
362 repl.ClearRef();
363 GURL url_no_ref = url.ReplaceComponents(repl);
364
365 EXPECT_EQ("data: one ? two ", url_no_ref.spec());
366
367 // Importing a parsed url via this constructor overload will retain trailing
368 // whitespace.
369 GURL import_url(url_no_ref.spec(),
370 url_no_ref.parsed_for_possibly_invalid_spec(),
371 url_no_ref.is_valid());
372 EXPECT_EQ(url_no_ref, import_url);
373 EXPECT_EQ(import_url.query(), " two ");
374 }
375
353 TEST(GURLTest, PathForRequest) { 376 TEST(GURLTest, PathForRequest) {
354 struct TestCase { 377 struct TestCase {
355 const char* input; 378 const char* input;
356 const char* expected; 379 const char* expected;
357 const char* inner_expected; 380 const char* inner_expected;
358 } cases[] = { 381 } cases[] = {
359 {"http://www.google.com", "/", NULL}, 382 {"http://www.google.com", "/", NULL},
360 {"http://www.google.com/", "/", NULL}, 383 {"http://www.google.com/", "/", NULL},
361 {"http://www.google.com/foo/bar.html?baz=22", "/foo/bar.html?baz=22", NULL}, 384 {"http://www.google.com/foo/bar.html?baz=22", "/foo/bar.html?baz=22", NULL},
362 {"http://www.google.com/foo/bar.html#ref", "/foo/bar.html", NULL}, 385 {"http://www.google.com/foo/bar.html#ref", "/foo/bar.html", NULL},
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 TEST(GURLTest, IsStandard) { 545 TEST(GURLTest, IsStandard) {
523 GURL a("http:foo/bar"); 546 GURL a("http:foo/bar");
524 EXPECT_TRUE(a.IsStandard()); 547 EXPECT_TRUE(a.IsStandard());
525 548
526 GURL b("foo:bar/baz"); 549 GURL b("foo:bar/baz");
527 EXPECT_FALSE(b.IsStandard()); 550 EXPECT_FALSE(b.IsStandard());
528 551
529 GURL c("foo://bar/baz"); 552 GURL c("foo://bar/baz");
530 EXPECT_FALSE(c.IsStandard()); 553 EXPECT_FALSE(c.IsStandard());
531 } 554 }
OLDNEW
« no previous file with comments | « url/gurl.cc ('k') | url/third_party/mozilla/url_parse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698