summaryrefslogtreecommitdiffstats
path: root/url/url_canon_unittest.cc
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 01:53:52 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 01:53:52 +0000
commit369e84f70d256d188a1866d8cef52edf4468cd9b (patch)
treee7e90408125f4831ce7983fd37414ad763b965b1 /url/url_canon_unittest.cc
parenta7e3691579181327dc65b02d043e7c01d4b06cb9 (diff)
downloadchromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.zip
chromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.tar.gz
chromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.tar.bz2
Support URL fragment resolution against non-hierarchical schemes
Support URL fragment resolution against non-hierarchical schemes As a result, data: about: etc now have 'query' and 'ref' components parsed; as a result a new GURL::GetContent() convenience is added to retrieve the spec with the scheme stripped off. A complication in supporting this is that we now need to allow whitespace to trailing whitespace to be preserved when transferring url_parse::Parsed structs between KURL and GURL. Without this, the URL prior to the #fragment can change (i.e. whitespace stripped) when following an anchor link which breaks the page (causes reload from source). See http://crbug.com/291747 for more details on this. R=brettw@chromium.org TBR=cbentzel@chromium.org BUG=291747 Review URL: https://codereview.chromium.org/23835019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url/url_canon_unittest.cc')
-rw-r--r--url/url_canon_unittest.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/url/url_canon_unittest.cc b/url/url_canon_unittest.cc
index 1b59a00..2275429 100644
--- a/url/url_canon_unittest.cc
+++ b/url/url_canon_unittest.cc
@@ -1609,7 +1609,7 @@ TEST(URLCanonTest, ReplacePathURL) {
const ReplaceCase& cur = replace_cases[i];
int base_len = static_cast<int>(strlen(cur.base));
url_parse::Parsed parsed;
- url_parse::ParsePathURL(cur.base, base_len, &parsed);
+ url_parse::ParsePathURL(cur.base, base_len, false, &parsed);
url_canon::Replacements<char> r;
typedef url_canon::Replacements<char> R; // Clean up syntax.
@@ -1830,7 +1830,7 @@ TEST(URLCanonTest, CanonicalizePathURL) {
for (size_t i = 0; i < ARRAYSIZE(path_cases); i++) {
int url_len = static_cast<int>(strlen(path_cases[i].input));
url_parse::Parsed parsed;
- url_parse::ParsePathURL(path_cases[i].input, url_len, &parsed);
+ url_parse::ParsePathURL(path_cases[i].input, url_len, true, &parsed);
url_parse::Parsed out_parsed;
std::string out_str;
@@ -1848,8 +1848,8 @@ TEST(URLCanonTest, CanonicalizePathURL) {
// When we end with a colon at the end, there should be no path.
if (path_cases[i].input[url_len - 1] == ':') {
- EXPECT_EQ(0, out_parsed.path.begin);
- EXPECT_EQ(-1, out_parsed.path.len);
+ EXPECT_EQ(0, out_parsed.GetContent().begin);
+ EXPECT_EQ(-1, out_parsed.GetContent().len);
}
}
}
@@ -2156,7 +2156,7 @@ TEST(URLCanonTest, ResolveRelativeURL) {
else if (cur_case.is_base_hier)
url_parse::ParseStandardURL(cur_case.base, base_len, &parsed);
else
- url_parse::ParsePathURL(cur_case.base, base_len, &parsed);
+ url_parse::ParsePathURL(cur_case.base, base_len, false, &parsed);
// First see if it is relative.
int test_len = static_cast<int>(strlen(cur_case.test));
@@ -2188,12 +2188,15 @@ TEST(URLCanonTest, ResolveRelativeURL) {
// the URL freshly.
url_parse::Parsed ref_parsed;
int resolved_len = static_cast<int>(resolved.size());
- if (cur_case.is_base_file)
+ if (cur_case.is_base_file) {
url_parse::ParseFileURL(resolved.c_str(), resolved_len, &ref_parsed);
- else if (cur_case.is_base_hier)
- url_parse::ParseStandardURL(resolved.c_str(), resolved_len, &ref_parsed);
- else
- url_parse::ParsePathURL(resolved.c_str(), resolved_len, &ref_parsed);
+ } else if (cur_case.is_base_hier) {
+ url_parse::ParseStandardURL(resolved.c_str(), resolved_len,
+ &ref_parsed);
+ } else {
+ url_parse::ParsePathURL(resolved.c_str(), resolved_len, false,
+ &ref_parsed);
+ }
EXPECT_TRUE(ParsedIsEqual(ref_parsed, resolved_parsed));
}
}