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

Unified Diff: url/url_util_unittest.cc

Issue 23468003: Allow fragments to resolve relatively against any scheme (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: really fix Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/url_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_util_unittest.cc
diff --git a/url/url_util_unittest.cc b/url/url_util_unittest.cc
index 8b16d796cf1c027e10386318b5d742aa40fb8a67..378d8f2854e6c916b51a10dde3d5fb560d2974e9 100644
--- a/url/url_util_unittest.cc
+++ b/url/url_util_unittest.cc
@@ -293,3 +293,48 @@ TEST(URLUtilTest, TestResolveRelativeWithNonStandardBase) {
EXPECT_EQ(test_data.out, resolved) << i;
}
}
+
+TEST(URLUtilTest, TestKURLCompatMode) {
+ // Tests the KURL compatibility mode in ResolveRelative
+ struct ResolveRelativeCase {
+ const char* base;
+ const char* rel;
+ const char* out;
+ } kurl_compat_cases[] = {
+ // These were all taken from running tests on KURL in WebKit 534.30.
+ {"about:blank", "#id", "about:blank#id"},
+ {"about:blank#oldfrag", "#id", "about:blank#id"},
+ {"javascript:alert('ab#fg')", "#id", "javascript:alert('ab#id"},
+ {"myscheme:foo?bar#baz?xxx#yyy?zzz", "#id", "myscheme:foo?bar#id"},
+ {"data:foo#bar?xxx#yyy?zzz", "#id", "data:foo#id"},
+ {"mailto:joth@example.com#123", "#id", "mailto:joth@example.com#id"},
+ };
+
+ for (int compat_mode = 0; compat_mode < 2; ++compat_mode) {
+ url_util::SetKURLCompatMode(compat_mode);
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kurl_compat_cases); i++) {
+ const ResolveRelativeCase& test_data = kurl_compat_cases[i];
+ url_parse::Parsed base_parsed;
+ url_parse::ParsePathURL(test_data.base, strlen(test_data.base),
+ &base_parsed);
+
+ std::string resolved;
+ url_canon::StdStringCanonOutput output(&resolved);
+ url_parse::Parsed resolved_parsed;
+ bool valid =
+ url_util::ResolveRelative(test_data.base, strlen(test_data.base),
+ base_parsed,
+ test_data.rel, strlen(test_data.rel),
+ NULL, &output, &resolved_parsed);
+ output.Complete();
+
+ if (!compat_mode) {
+ EXPECT_FALSE(valid);
+ } else {
+ EXPECT_TRUE(valid);
+ EXPECT_EQ(test_data.out, resolved) << i;
+ }
+ }
+ }
+ url_util::SetKURLCompatMode(false);
+}
« no previous file with comments | « url/url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698