summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp129
1 files changed, 88 insertions, 41 deletions
diff --git a/chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp b/chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp
index b489b167e9e..662045bb985 100644
--- a/chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp
+++ b/chromium/third_party/WebKit/Source/platform/weborigin/KURLTest.cpp
@@ -48,7 +48,6 @@ struct ComponentCase {
const int port;
const char* user;
const char* pass;
- const char* path;
const char* lastPath;
const char* query;
const char* ref;
@@ -111,21 +110,21 @@ TEST(KURLTest, SameGetters)
TEST(KURLTest, DISABLED_DifferentGetters)
{
ComponentCase cases[] = {
- // url protocol host port user pass path lastPath query ref
+ // url protocol host port user pass lastPath query ref
// Old WebKit allows references and queries in what we call "path" URLs
// like javascript, so the path here will only consist of "hello!".
- {"javascript:hello!?#/\\world", "javascript", "", 0, "", 0, "hello!?#/\\world", "world", 0, 0},
+ {"javascript:hello!?#/\\world", "javascript", "", 0, "", 0, "world", 0, 0},
// Old WebKit doesn't handle "parameters" in paths, so will
// disagree with us about where the path is for this URL.
- {"http://a.com/hello;world", "http", "a.com", 0, "", 0, "/hello;world", "hello", 0, 0},
+ {"http://a.com/hello;world", "http", "a.com", 0, "", 0, "hello", 0, 0},
// WebKit doesn't like UTF-8 or UTF-16 input.
- {"http://\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd/", "http", "xn--6qqa088eba", 0, "", 0, "/", 0, 0, 0},
+ {"http://\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd/", "http", "xn--6qqa088eba", 0, "", 0, 0, 0, 0},
// WebKit %-escapes non-ASCII characters in reference, but we don't.
- {"http://www.google.com/foo/blah?bar=baz#\xce\xb1\xce\xb2", "http", "www.google.com", 0, "", 0, "/foo/blah/", "blah", "bar=baz", "\xce\xb1\xce\xb2"},
+ {"http://www.google.com/foo/blah?bar=baz#\xce\xb1\xce\xb2", "http", "www.google.com", 0, "", 0, "blah", "bar=baz", "\xce\xb1\xce\xb2"},
};
for (size_t i = 0; i < arraysize(cases); i++) {
@@ -180,50 +179,63 @@ TEST(KURLTest, Setters)
// can't set setting the http port to "80" (or even "0").
//
// We also can't test clearing the query.
- //
- // The format is every other row is a test, and the row that follows it is the
- // expected result.
struct ExpectedComponentCase {
const char* url;
- const char* protocol;
- const char* host;
- const int port;
- const char* user;
- const char* pass;
- const char* path;
- const char* query;
- const char* ref;
- // The full expected URL with the given "set" applied.
+ const char* protocol;
const char* expectedProtocol;
+
+ const char* host;
const char* expectedHost;
+
+ const int port;
const char* expectedPort;
+
+ const char* user;
const char* expectedUser;
+
+ const char* pass;
const char* expectedPass;
+
+ const char* path;
const char* expectedPath;
+
+ const char* query;
const char* expectedQuery;
- const char* expectedRef;
} cases[] = {
- // url protocol host port user pass path query ref
- {"http://www.google.com/", "https", "news.google.com", 8888, "me", "pass", "/foo", "?q=asdf", "heehee",
- "https://www.google.com/",
- "https://news.google.com/",
- "https://news.google.com:8888/",
- "https://me@news.google.com:8888/",
- "https://me:pass@news.google.com:8888/",
- "https://me:pass@news.google.com:8888/foo",
- "https://me:pass@news.google.com:8888/foo?q=asdf",
- "https://me:pass@news.google.com:8888/foo?q=asdf#heehee"},
-
- {"https://me:pass@google.com:88/a?f#b", "http", "goo.com", 92, "", "", "/", 0, "",
- "http://me:pass@google.com:88/a?f#b",
- "http://me:pass@goo.com:88/a?f#b",
- "http://me:pass@goo.com:92/a?f#b",
- "http://:pass@goo.com:92/a?f#b",
- "http://goo.com:92/a?f#b",
- "http://goo.com:92/?f#b",
- "http://goo.com:92/#b",
- "https://goo.com:92/"},
+ {
+ "http://www.google.com/",
+ // protocol
+ "https", "https://www.google.com/",
+ // host
+ "news.google.com", "https://news.google.com/",
+ // port
+ 8888, "https://news.google.com:8888/",
+ // user
+ "me", "https://me@news.google.com:8888/",
+ // pass
+ "pass", "https://me:pass@news.google.com:8888/",
+ // path
+ "/foo", "https://me:pass@news.google.com:8888/foo",
+ // query
+ "?q=asdf", "https://me:pass@news.google.com:8888/foo?q=asdf"
+ }, {
+ "https://me:pass@google.com:88/a?f#b",
+ // protocol
+ "http", "http://me:pass@google.com:88/a?f#b",
+ // host
+ "goo.com", "http://me:pass@goo.com:88/a?f#b",
+ // port
+ 92, "http://me:pass@goo.com:92/a?f#b",
+ // user
+ "", "http://:pass@goo.com:92/a?f#b",
+ // pass
+ "", "http://goo.com:92/a?f#b",
+ // path
+ "/", "http://goo.com:92/?f#b",
+ // query
+ 0, "http://goo.com:92/#b"
+ },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
@@ -288,7 +300,7 @@ TEST(KURLTest, Decode)
// Test the error behavior for invalid UTF-8 (we differ from WebKit here).
WTF::String invalid = WebCore::decodeURLEscapeSequences(
"%e4%a0%e5%a5%bd");
- char16 invalidExpectedHelper[4] = { 0x00e4, 0x00a0, 0x597d, 0 };
+ UChar invalidExpectedHelper[4] = { 0x00e4, 0x00a0, 0x597d, 0 };
WTF::String invalidExpected(
reinterpret_cast<const ::UChar*>(invalidExpectedHelper),
3);
@@ -334,7 +346,7 @@ TEST(KURLTest, Encode)
EXPECT_EQ(reference, output);
// Also test that it gets converted to UTF-8 properly.
- char16 wideInputHelper[3] = { 0x4f60, 0x597d, 0 };
+ UChar wideInputHelper[3] = { 0x4f60, 0x597d, 0 };
WTF::String wideInput(
reinterpret_cast<const ::UChar*>(wideInputHelper), 2);
WTF::String wideReference("%E4%BD%A0%E5%A5%BD");
@@ -606,6 +618,18 @@ TEST(KURLTest, DeepCopy)
EXPECT_NE(dest.string().impl(), src.string().impl());
}
+TEST(KURLTest, DeepCopyInnerURL)
+{
+ const char url[] = "filesystem:http://www.google.com/temporary/test.txt";
+ const char innerURL[] = "http://www.google.com/temporary";
+ WebCore::KURL src(WebCore::ParsedURLString, url);
+ EXPECT_TRUE(src.string() == url);
+ EXPECT_TRUE(src.innerURL()->string() == innerURL);
+ WebCore::KURL dest = src.copy();
+ EXPECT_TRUE(dest.string() == url);
+ EXPECT_TRUE(dest.innerURL()->string() == innerURL);
+}
+
TEST(KURLTest, LastPathComponent)
{
WebCore::KURL url1(WebCore::ParsedURLString, "http://host/path/to/file.txt");
@@ -657,4 +681,27 @@ TEST(KURLTest, ProtocolIs)
EXPECT_TRUE(invalidUTF8.protocolIs(""));
}
+TEST(KURLTest, strippedForUseAsReferrer)
+{
+ struct ReferrerCase {
+ const char* input;
+ const char* output;
+ } referrerCases[] = {
+ {"data:text/html;charset=utf-8,<html></html>", ""},
+ {"javascript:void(0);", ""},
+ {"about:config", ""},
+ {"https://www.google.com/", "https://www.google.com/"},
+ {"http://me@news.google.com:8888/", "http://news.google.com:8888/"},
+ {"http://:pass@news.google.com:8888/foo", "http://news.google.com:8888/foo"},
+ {"http://me:pass@news.google.com:8888/", "http://news.google.com:8888/"},
+ {"https://www.google.com/a?f#b", "https://www.google.com/a?f"},
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(referrerCases); i++) {
+ WebCore::KURL kurl(WebCore::ParsedURLString, referrerCases[i].input);
+ WTF::String referrer = kurl.strippedForUseAsReferrer();
+ EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
+ }
+}
+
} // namespace