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

Unified Diff: tests/corelib/uri_test.dart

Issue 2134153002: Roll Webkit DEPS to fix layout test status (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Also revert 323ca7e410765f98a88d078c8c8c388fd972eba9 Created 4 years, 5 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 | « tests/corelib/data_uri_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_test.dart
diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart
index 3d24e2daa9bea2b13edaf0f5a1804216a5b67247..ef7a9a35cb0865842c667578df1fd973080c5e94 100644
--- a/tests/corelib/uri_test.dart
+++ b/tests/corelib/uri_test.dart
@@ -10,12 +10,6 @@ import 'dart:convert';
testUri(String uriText, bool isAbsolute) {
var uri = Uri.parse(uriText);
- // Test that parsing a substring works the same as parsing the string.
- String wrapper = "://@[]:/%?#";
- var embeddedUri = Uri.parse(
- "$wrapper$uri$wrapper", wrapper.length, uriText.length + wrapper.length);
-
- Expect.equals(uri, embeddedUri);
Expect.equals(isAbsolute, uri.isAbsolute);
Expect.stringEquals(uriText, uri.toString());
@@ -88,8 +82,7 @@ testUriPerRFCs() {
final urisSample = "http://a/b/c/d;p?q";
Uri base = Uri.parse(urisSample);
testResolve(expect, relative) {
- String name = "$base << $relative";
- Expect.stringEquals(expect, base.resolve(relative).toString(), name);
+ Expect.stringEquals(expect, base.resolve(relative).toString());
}
// From RFC 3986.
@@ -139,232 +132,19 @@ testUriPerRFCs() {
// Additional tests (not from RFC 3986).
testResolve("http://a/b/g;p/h;s", "../g;p/h;s");
- base = Uri.parse("s:a/b");
- testResolve("s:a/c", "c");
- testResolve("s:/c", "../c");
-
- base = Uri.parse("S:a/b");
- testResolve("s:a/c", "c");
- testResolve("s:/c", "../c");
-
- base = Uri.parse("s:foo");
- testResolve("s:bar", "bar");
- testResolve("s:bar", "../bar");
-
- base = Uri.parse("S:foo");
- testResolve("s:bar", "bar");
- testResolve("s:bar", "../bar");
-
- // Special-case (deliberate non-RFC behavior).
- base = Uri.parse("foo/bar");
- testResolve("foo/baz", "baz");
- testResolve("baz", "../baz");
-
- base = Uri.parse("s:/foo");
- testResolve("s:/bar", "bar");
- testResolve("s:/bar", "../bar");
-
- base = Uri.parse("S:/foo");
- testResolve("s:/bar", "bar");
- testResolve("s:/bar", "../bar");
-
// Test non-URI base (no scheme, no authority, relative path).
base = Uri.parse("a/b/c?_#_");
testResolve("a/b/g?q#f", "g?q#f");
testResolve("./", "../..");
testResolve("../", "../../..");
testResolve("a/b/", ".");
- testResolve("c", "../../c"); // Deliberate non-RFC behavior.
+ testResolve("c", "../../c");
base = Uri.parse("../../a/b/c?_#_"); // Initial ".." in base url.
testResolve("../../a/d", "../d");
testResolve("../../../d", "../../../d");
- base = Uri.parse("s://h/p?q#f"); // A simple base.
- // Simple references:
- testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F");
- testResolve("s://h2/P?Q#F", "//h2/P?Q#F");
- testResolve("s://h/P?Q#F", "/P?Q#F");
- testResolve("s://h/p?Q#F", "?Q#F");
- testResolve("s://h/p?q#F", "#F");
- testResolve("s://h/p?q", "");
- // Non-simple references:
- testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20");
- testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20");
- testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20");
- testResolve("s://h/P?Q#F%20", "/P?Q#F%20");
- testResolve("s://h/p?Q#F%20", "?Q#F%20");
- testResolve("s://h/p?q#F%20", "#F%20");
-
- base = Uri.parse("s://h/p1/p2/p3"); // A simple base with a path.
- testResolve("s://h/p1/p2/", ".");
- testResolve("s://h/p1/p2/", "./");
- testResolve("s://h/p1/", "..");
- testResolve("s://h/p1/", "../");
- testResolve("s://h/", "../..");
- testResolve("s://h/", "../../");
- testResolve("s://h/p1/%20", "../%20");
- testResolve("s://h/", "../../../..");
- testResolve("s://h/", "../../../../");
-
- base = Uri.parse("s://h/p?q#f%20"); // A non-simpe base.
- // Simple references:
- testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F");
- testResolve("s://h2/P?Q#F", "//h2/P?Q#F");
- testResolve("s://h/P?Q#F", "/P?Q#F");
- testResolve("s://h/p?Q#F", "?Q#F");
- testResolve("s://h/p?q#F", "#F");
- testResolve("s://h/p?q", "");
- // Non-simple references:
- testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20");
- testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20");
- testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20");
- testResolve("s://h/P?Q#F%20", "/P?Q#F%20");
- testResolve("s://h/p?Q#F%20", "?Q#F%20");
- testResolve("s://h/p?q#F%20", "#F%20");
-
- base = Uri.parse("S://h/p1/p2/p3"); // A non-simple base with a path.
- testResolve("s://h/p1/p2/", ".");
- testResolve("s://h/p1/p2/", "./");
- testResolve("s://h/p1/", "..");
- testResolve("s://h/p1/", "../");
- testResolve("s://h/", "../..");
- testResolve("s://h/", "../../");
- testResolve("s://h/p1/%20", "../%20");
- testResolve("s://h/", "../../../..");
- testResolve("s://h/", "../../../../");
-
- base = Uri.parse("../../../"); // A simple relative path.
- testResolve("../../../a", "a");
- testResolve("../../../../a", "../a");
- testResolve("../../../a%20", "a%20");
- testResolve("../../../../a%20", "../a%20");
-
- // Tests covering the branches of the merge algorithm in RFC 3986
- // with both simple and complex base URIs.
- for (var b in ["s://a/pa/pb?q#f", "s://a/pa/pb?q#f%20"]) {
- var origBase = Uri.parse(b);
- base = origBase;
-
- // if defined(R.scheme) then ...
- testResolve("s2://a2/p2?q2#f2", "s2://a2/p2?q2#f2");
- // else, if defined(R.authority) then ...
- testResolve("s://a2/p2?q2#f2", "//a2/p2?q2#f2");
- testResolve("s://a2/?q2#f2", "//a2/../?q2#f2");
- testResolve("s://a2?q2#f2", "//a2?q2#f2");
- testResolve("s://a2#f2", "//a2#f2");
- testResolve("s://a2", "//a2");
- // else, if (R.path == "") then ...
- // if defined(R.query) then
- testResolve("s://a/pa/pb?q2#f2", "?q2#f2");
- testResolve("s://a/pa/pb?q2", "?q2");
- // else
- testResolve("s://a/pa/pb?q#f2", "#f2");
- testResolve("s://a/pa/pb?q", "");
- // else, if (R.path starts-with "/") then ...
- testResolve("s://a/p2?q2#f2", "/p2?q2#f2");
- testResolve("s://a/?q2#f2", "/?q2#f2");
- testResolve("s://a/#f2", "/#f2");
- testResolve("s://a/", "/");
- testResolve("s://a/", "/../");
- // else ... T.path = merge(Base.path, R.path)
- // ... remove-dot-fragments(T.path) ...
- // (Cover the merge function and the remove-dot-fragments functions too).
-
- // If base has authority and empty path ...
- var emptyPathBase = Uri.parse(b.replaceFirst("/pa/pb", ""));
- base = emptyPathBase;
- testResolve("s://a/p2?q2#f2", "p2?q2#f2");
- testResolve("s://a/p2#f2", "p2#f2");
- testResolve("s://a/p2", "p2");
-
- base = origBase;
- // otherwise
- // (Cover both no authority and non-empty path and both).
- var noAuthEmptyPathBase = Uri.parse(b.replaceFirst("//a/pa/pb", ""));
- var noAuthAbsPathBase = Uri.parse(b.replaceFirst("//a", ""));
- var noAuthRelPathBase = Uri.parse(b.replaceFirst("//a/", ""));
- var noAuthRelSinglePathBase = Uri.parse(b.replaceFirst("//a/pa/", ""));
-
- testResolve("s://a/pa/p2?q2#f2", "p2?q2#f2");
- testResolve("s://a/pa/p2#f2", "p2#f2");
- testResolve("s://a/pa/p2", "p2");
-
- base = noAuthEmptyPathBase;
- testResolve("s:p2?q2#f2", "p2?q2#f2");
- testResolve("s:p2#f2", "p2#f2");
- testResolve("s:p2", "p2");
-
- base = noAuthAbsPathBase;
- testResolve("s:/pa/p2?q2#f2", "p2?q2#f2");
- testResolve("s:/pa/p2#f2", "p2#f2");
- testResolve("s:/pa/p2", "p2");
-
- base = noAuthRelPathBase;
- testResolve("s:pa/p2?q2#f2", "p2?q2#f2");
- testResolve("s:pa/p2#f2", "p2#f2");
- testResolve("s:pa/p2", "p2");
-
- base = noAuthRelSinglePathBase;
- testResolve("s:p2?q2#f2", "p2?q2#f2");
- testResolve("s:p2#f2", "p2#f2");
- testResolve("s:p2", "p2");
-
- // Then remove dot segments.
-
- // A. if input buffer starts with "../" or "./".
- // This only happens if base has only a single (may be empty) segment and
- // no slash.
- base = emptyPathBase;
- testResolve("s://a/p2", "../p2");
- testResolve("s://a/", "../");
- testResolve("s://a/", "..");
- testResolve("s://a/p2", "./p2");
- testResolve("s://a/", "./");
- testResolve("s://a/", ".");
- testResolve("s://a/p2", "../../p2");
- testResolve("s://a/p2", "../../././p2");
-
- base = noAuthRelSinglePathBase;
- testResolve("s:p2", "../p2");
- testResolve("s:", "../");
- testResolve("s:", "..");
- testResolve("s:p2", "./p2");
- testResolve("s:", "./");
- testResolve("s:", ".");
- testResolve("s:p2", "../../p2");
- testResolve("s:p2", "../../././p2");
-
- // B. if input buffer starts with "/./" or is "/.". replace with "/".
- // (The URI implementation removes the "." path segments when parsing,
- // so this case isn't handled by merge).
- base = origBase;
- testResolve("s://a/pa/p2", "./p2");
-
- // C. if input buffer starts with "/../" or is "/..", replace with "/"
- // and remove preceeding segment.
- testResolve("s://a/p2", "../p2");
- var longPathBase = Uri.parse(b.replaceFirst("/pb", "/pb/pc/pd"));
- base = longPathBase;
- testResolve("s://a/pa/pb/p2", "../p2");
- testResolve("s://a/pa/p2", "../../p2");
- testResolve("s://a/p2", "../../../p2");
- testResolve("s://a/p2", "../../../../p2");
- var noAuthRelLongPathBase =
- Uri.parse(b.replaceFirst("//a/pa/pb", "pa/pb/pc/pd"));
- base = noAuthRelLongPathBase;
- testResolve("s:pa/pb/p2", "../p2");
- testResolve("s:pa/p2", "../../p2");
- testResolve("s:/p2", "../../../p2");
- testResolve("s:/p2", "../../../../p2");
-
- // D. if the input buffer contains only ".." or ".", remove it.
- base = noAuthEmptyPathBase;
- testResolve("s:", "..");
- testResolve("s:", ".");
- base = noAuthRelSinglePathBase;
- testResolve("s:", "..");
- testResolve("s:", ".");
- }
+ base = Uri.parse("s:a/b");
+ testResolve("s:/c", "../c");
}
void testResolvePath(String expected, String path) {
@@ -718,11 +498,6 @@ main() {
query: null,
fragment: null).toString());
Expect.stringEquals("file:///", Uri.parse("file:").toString());
- Expect.stringEquals("file:///", Uri.parse("file:/").toString());
- Expect.stringEquals("file:///", Uri.parse("file:").toString());
- Expect.stringEquals("file:///foo", Uri.parse("file:foo").toString());
- Expect.stringEquals("file:///foo", Uri.parse("file:/foo").toString());
- Expect.stringEquals("file://foo/", Uri.parse("file://foo").toString());
testResolvePath("/a/g", "/a/b/c/./../../g");
testResolvePath("/a/g", "/a/b/c/./../../g");
« no previous file with comments | « tests/corelib/data_uri_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698