Procházet zdrojové kódy

Update WPT data and expectations (#859)

Luca Casonato před 3 roky
rodič
revize
115837002b
3 změnil soubory, kde provedl 629 přidání a 162 odebrání
  1. 33 17
      url/tests/expected_failures.txt
  2. 471 20
      url/tests/setters_tests.json
  3. 125 125
      url/tests/urltestdata.json

+ 33 - 17
url/tests/expected_failures.txt

@@ -1,12 +1,12 @@
 </> against <file://h/C:/a/b>
-<file:\\\\//> against <about:blank>
-<file:\\\\\\\\> against <about:blank>
-<file:\\\\\\\\?fox> against <about:blank>
-<file:\\\\\\\\#guppy> against <about:blank>
-<file://spider///> against <about:blank>
-<file:\\\\localhost//> against <about:blank>
-<file://\\/localhost//cat> against <about:blank>
-<file://localhost//a//../..//> against <about:blank>
+<file:\\\\//>
+<file:\\\\\\\\>
+<file:\\\\\\\\?fox>
+<file:\\\\\\\\#guppy>
+<file://spider///>
+<file:\\\\localhost//>
+<file://\\/localhost//cat>
+<file://localhost//a//../..//>
 </////mouse> against <file:///elephant>
 <\\/localhost//pig> against <file://lion/>
 <//localhost//pig> against <file://lion/>
@@ -19,19 +19,35 @@
 <C|\n/> against <file://host/dir/file>
 <C|\\> against <file://host/dir/file>
 </c:/foo/bar> against <file://host/path>
-<file://example.net/C:/> against <about:blank>
-<file://1.2.3.4/C:/> against <about:blank>
-<file://[1::8]/C:/> against <about:blank>
+<file://example.net/C:/>
+<file://1.2.3.4/C:/>
+<file://[1::8]/C:/>
 <C|/> against <file://host/>
 </C:/> against <file://host/>
 <file:C:/> against <file://host/>
 <file:/C:/> against <file://host/>
-<file://localhost//a//../..//foo> against <about:blank>
-<file://localhost////foo> against <about:blank>
-<file:////foo> against <about:blank>
+<file://localhost//a//../..//foo>
+<file://localhost////foo>
+<file:////foo>
 <file:////one/two> against <file:///>
 <////one/two> against <file:///>
 <file:///.//> against <file:////>
-<file:.//p> against <about:blank>
-<file:/.//p> against <about:blank>
-<https://x/?#\u{0}y> against <about:blank>
+<file:.//p>
+<file:/.//p>
+<http://example.net/path> set hostname to <example.com:8080>
+<http://example.net:8080/path> set hostname to <example.com:>
+<non-spec:/.//p> set hostname to <h>
+<non-spec:/.//p> set hostname to <>
+<foo://somehost/some/path> set pathname to <>
+<foo:///some/path> set pathname to <>
+<http://example.net:8080/path> set port to <randomstring>
+<file:///var/log/system.log> set href to <http://0300.168.0xF0>
+<data:space  ?query#fragment> set search to <>
+<sc:space  ?query#fragment> set search to <>
+<file://monkey/> set pathname to <\\\\>
+<file:///unicorn> set pathname to <//\\/>
+<file:///unicorn> set pathname to <//monkey/..//>
+<non-spec:/> set pathname to </.//p>
+<non-spec:/> set pathname to </..//p>
+<non-spec:/> set pathname to <//p>
+<non-spec:/.//> set pathname to <p>

+ 471 - 20
url/tests/setters_tests.json

@@ -1,6 +1,6 @@
 {
     "comment": [
-        "AS OF https://github.com/web-platform-tests/wpt/blob/09b34ae130cd946e111cd427d6bcf2d6f257aed8/url/resources/setters_tests.json, but only passing tests",
+        "# Pulled from https://github.com/web-platform-tests/wpt/blob/befe66343e5f21dc464c8c772c6d20695936714f/url/resources/setters_tests.json",
         "## Tests for setters of https://url.spec.whatwg.org/#urlutils-members",
         "",
         "This file contains a JSON object.",
@@ -120,11 +120,11 @@
             }
         },
         {
-            "href": "gopher://example.net:1234",
+            "href": "https://example.net:1234",
             "new_value": "file",
             "expected": {
-                "href": "gopher://example.net:1234",
-                "protocol": "gopher:"
+                "href": "https://example.net:1234/",
+                "protocol": "https:"
             }
         },
         {
@@ -146,7 +146,7 @@
         },
         {
             "href": "file:///test",
-            "new_value": "gopher",
+            "new_value": "https",
             "expected": {
                 "href": "file:///test",
                 "protocol": "file:"
@@ -270,6 +270,57 @@
                 "protocol": "https:",
                 "port": ""
             }
+        },
+        {
+            "comment": "Tab and newline are stripped",
+            "href": "http://test/",
+            "new_value": "h\u000D\u000Att\u0009ps",
+            "expected": {
+              "href": "https://test/",
+              "protocol": "https:",
+              "port": ""
+            }
+        },
+        {
+            "href": "http://test/",
+            "new_value": "https\u000D",
+            "expected": {
+              "href": "https://test/",
+              "protocol": "https:"
+            }
+        },
+        {
+            "comment": "Non-tab/newline C0 controls result in no-op",
+            "href": "http://test/",
+            "new_value": "https\u0000",
+            "expected": {
+              "href": "http://test/",
+              "protocol": "http:"
+            }
+        },
+        {
+            "href": "http://test/",
+            "new_value": "https\u000C",
+            "expected": {
+              "href": "http://test/",
+              "protocol": "http:"
+            }
+        },
+        {
+            "href": "http://test/",
+            "new_value": "https\u000E",
+            "expected": {
+              "href": "http://test/",
+              "protocol": "http:"
+            }
+        },
+        {
+            "href": "http://test/",
+            "new_value": "https\u0020",
+            "expected": {
+              "href": "http://test/",
+              "protocol": "http:"
+            }
         }
     ],
     "username": [
@@ -962,6 +1013,16 @@
                 "port": ""
             }
         },
+        {
+            "href": "file://hi/x",
+            "new_value": "",
+            "expected": {
+                "href": "file:///x",
+                "host": "",
+                "hostname": "",
+                "port": ""
+            }
+        },
         {
             "href": "sc://test@test/",
             "new_value": "",
@@ -981,6 +1042,62 @@
                 "hostname": "test",
                 "port": "12"
             }
+        },
+        {
+            "comment": "Leading / is not stripped",
+            "href": "http://example.com/",
+            "new_value": "///bad.com",
+            "expected": {
+                "href": "http://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
+        },
+        {
+            "comment": "Leading / is not stripped",
+            "href": "sc://example.com/",
+            "new_value": "///bad.com",
+            "expected": {
+                "href": "sc:///",
+                "host": "",
+                "hostname": ""
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "a%C2%ADb",
+            "expected": {
+                "href": "https://ab/",
+                "host": "ab",
+                "hostname": "ab"
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "\u00AD",
+            "expected": {
+                "href": "https://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "%C2%AD",
+            "expected": {
+                "href": "https://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "xn--",
+            "expected": {
+                "href": "https://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
         }
     ],
     "hostname": [
@@ -1144,24 +1261,24 @@
             }
         },
         {
-            "comment": "Stuff after a : delimiter is ignored",
+            "comment": ": delimiter invalidates entire value",
             "href": "http://example.net/path",
             "new_value": "example.com:8080",
             "expected": {
-                "href": "http://example.com/path",
-                "host": "example.com",
-                "hostname": "example.com",
+                "href": "http://example.net/path",
+                "host": "example.net",
+                "hostname": "example.net",
                 "port": ""
             }
         },
         {
-            "comment": "Stuff after a : delimiter is ignored",
+            "comment": ": delimiter invalidates entire value",
             "href": "http://example.net:8080/path",
             "new_value": "example.com:",
             "expected": {
-                "href": "http://example.com:8080/path",
-                "host": "example.com:8080",
-                "hostname": "example.com",
+                "href": "http://example.net:8080/path",
+                "host": "example.net:8080",
+                "hostname": "example.net",
                 "port": "8080"
             }
         },
@@ -1286,6 +1403,16 @@
                 "port": ""
             }
         },
+        {
+            "href": "file://hi/x",
+            "new_value": "",
+            "expected": {
+                "href": "file:///x",
+                "host": "",
+                "hostname": "",
+                "port": ""
+            }
+        },
         {
             "href": "sc://test@test/",
             "new_value": "",
@@ -1305,6 +1432,83 @@
                 "hostname": "test",
                 "port": "12"
             }
+        },
+        {
+            "comment": "Drop /. from path",
+            "href": "non-spec:/.//p",
+            "new_value": "h",
+            "expected": {
+                "href": "non-spec://h//p",
+                "host": "h",
+                "hostname": "h",
+                "pathname": "//p"
+            }
+        },
+        {
+            "href": "non-spec:/.//p",
+            "new_value": "",
+            "expected": {
+                "href": "non-spec:////p",
+                "host": "",
+                "hostname": "",
+                "pathname": "//p"
+            }
+        },
+        {
+            "comment": "Leading / is not stripped",
+            "href": "http://example.com/",
+            "new_value": "///bad.com",
+            "expected": {
+                "href": "http://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
+        },
+        {
+            "comment": "Leading / is not stripped",
+            "href": "sc://example.com/",
+            "new_value": "///bad.com",
+            "expected": {
+                "href": "sc:///",
+                "host": "",
+                "hostname": ""
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "a%C2%ADb",
+            "expected": {
+                "href": "https://ab/",
+                "host": "ab",
+                "hostname": "ab"
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "\u00AD",
+            "expected": {
+                "href": "https://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "%C2%AD",
+            "expected": {
+                "href": "https://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
+        },
+        {
+            "href": "https://example.com/",
+            "new_value": "xn--",
+            "expected": {
+                "href": "https://example.com/",
+                "host": "example.com",
+                "hostname": "example.com"
+            }
         }
     ],
     "port": [
@@ -1461,6 +1665,17 @@
                 "port": "8080"
             }
         },
+        {
+            "comment": "Setting port to a string that doesn't parse as a number",
+            "href": "http://example.net:8080/path",
+            "new_value": "randomstring",
+            "expected": {
+                "href": "http://example.net:8080/path",
+                "host": "example.net:8080",
+                "hostname": "example.net",
+                "port": "8080"
+            }
+        },
         {
             "comment": "Port numbers are 16 bit integers, overflowing is an error",
             "href": "non-special://example.net:8080/path",
@@ -1519,11 +1734,35 @@
                 "href": "javascript://x:12/",
                 "port": "12"
             }
+        },
+        {
+            "comment": "Leading u0009 on special scheme",
+            "href": "https://domain.com:443",
+            "new_value": "\u00098080",
+            "expected": {
+                "port": "8080"
+            }
+        },
+        {
+            "comment": "Leading u0009 on non-special scheme",
+            "href": "wpt++://domain.com:443",
+            "new_value": "\u00098080",
+            "expected": {
+                "port": "8080"
+            }
+        },
+        {
+            "comment": "Should use all ascii prefixed characters as port",
+            "href": "https://www.google.com:4343",
+            "new_value": "4wpt",
+            "expected": {
+                "port": "4"
+            }
         }
     ],
     "pathname": [
         {
-            "comment": "Cannot-be-a-base don’t have a path",
+            "comment": "Opaque paths cannot be set",
             "href": "mailto:me@example.net",
             "new_value": "/foo",
             "expected": {
@@ -1531,6 +1770,67 @@
                 "pathname": "me@example.net"
             }
         },
+        {
+            "href": "data:original",
+            "new_value": "new value",
+            "expected": {
+                "href": "data:original",
+                "pathname": "original"
+            }
+        },
+        {
+            "href": "sc:original",
+            "new_value": "new value",
+            "expected": {
+                "href": "sc:original",
+                "pathname": "original"
+            }
+        },
+        {
+            "comment": "Special URLs cannot have their paths erased",
+            "href": "file:///some/path",
+            "new_value": "",
+            "expected": {
+                "href": "file:///",
+                "pathname": "/"
+            }
+        },
+        {
+            "comment": "Non-special URLs can have their paths erased",
+            "href": "foo://somehost/some/path",
+            "new_value": "",
+            "expected": {
+                "href": "foo://somehost",
+                "pathname": ""
+            }
+        },
+        {
+            "comment": "Non-special URLs with an empty host can have their paths erased",
+            "href": "foo:///some/path",
+            "new_value": "",
+            "expected": {
+                "href": "foo://",
+                "pathname": ""
+            }
+        },
+        {
+            "comment": "Path-only URLs cannot have their paths erased",
+            "href": "foo:/some/path",
+            "new_value": "",
+            "expected": {
+                "href": "foo:/",
+                "pathname": "/"
+            }
+        },
+        {
+            "comment": "Path-only URLs always have an initial slash",
+            "href": "foo:/some/path",
+            "new_value": "test",
+            "expected": {
+                "href": "foo:/test",
+                "pathname": "/test"
+            }
+        },
         {
             "href": "unix:/run/foo.socket?timeout=10",
             "new_value": "/var/log/../run/bar.socket",
@@ -1627,13 +1927,31 @@
                 "pathname": "/%23"
             }
         },
+        {
+            "comment": "? doesn't mess up encoding",
+            "href": "http://example.net",
+            "new_value": "/?é",
+            "expected": {
+                "href": "http://example.net/%3F%C3%A9",
+                "pathname": "/%3F%C3%A9"
+            }
+        },
+        {
+            "comment": "# doesn't mess up encoding",
+            "href": "http://example.net",
+            "new_value": "/#é",
+            "expected": {
+                "href": "http://example.net/%23%C3%A9",
+                "pathname": "/%23%C3%A9"
+            }
+        },
         {
             "comment": "File URLs and (back)slashes",
             "href": "file://monkey/",
             "new_value": "\\\\",
             "expected": {
-                "href": "file://monkey/",
-                "pathname": "/"
+                "href": "file://monkey//",
+                "pathname": "//"
             }
         },
         {
@@ -1641,8 +1959,8 @@
             "href": "file:///unicorn",
             "new_value": "//\\/",
             "expected": {
-                "href": "file:///",
-                "pathname": "/"
+                "href": "file://////",
+                "pathname": "////"
             }
         },
         {
@@ -1650,8 +1968,59 @@
             "href": "file:///unicorn",
             "new_value": "//monkey/..//",
             "expected": {
-                "href": "file:///",
-                "pathname": "/"
+                "href": "file://///",
+                "pathname": "///"
+            }
+        },
+        {
+            "comment": "Serialize /. in path",
+            "href": "non-spec:/",
+            "new_value": "/.//p",
+            "expected": {
+                "href": "non-spec:/.//p",
+                "pathname": "//p"
+            }
+        },
+        {
+            "href": "non-spec:/",
+            "new_value": "/..//p",
+            "expected": {
+                "href": "non-spec:/.//p",
+                "pathname": "//p"
+            }
+        },
+        {
+            "href": "non-spec:/",
+            "new_value": "//p",
+            "expected": {
+                "href": "non-spec:/.//p",
+                "pathname": "//p"
+            }
+        },
+        {
+            "comment": "Drop /. from path",
+            "href": "non-spec:/.//",
+            "new_value": "p",
+            "expected": {
+                "href": "non-spec:/p",
+                "pathname": "/p"
+            }
+        },
+        {
+            "comment": "Non-special URLs with non-opaque paths percent-encode U+0020",
+            "href": "data:/nospace",
+            "new_value": "space ",
+            "expected": {
+                "href": "data:/space%20",
+                "pathname": "/space%20"
+            }
+        },
+        {
+            "href": "sc:/nospace",
+            "new_value": "space ",
+            "expected": {
+                "href": "sc:/space%20",
+                "pathname": "/space%20"
             }
         },
         {
@@ -1756,6 +2125,42 @@
                 "search": "?%c3%89t%C3%A9"
             }
         },
+        {
+            "comment": "Drop trailing spaces from trailing opaque paths",
+            "href": "data:space ?query",
+            "new_value": "",
+            "expected": {
+                "href": "data:space",
+                "pathname": "space",
+                "search": ""
+            }
+        },
+        {
+            "href": "sc:space ?query",
+            "new_value": "",
+            "expected": {
+                "href": "sc:space",
+                "pathname": "space",
+                "search": ""
+            }
+        },
+        {
+            "comment": "Do not drop trailing spaces from non-trailing opaque paths",
+            "href": "data:space  ?query#fragment",
+            "new_value": "",
+            "expected": {
+                "href": "data:space  #fragment",
+                "search": ""
+            }
+        },
+        {
+            "href": "sc:space  ?query#fragment",
+            "new_value": "",
+            "expected": {
+                "href": "sc:space  #fragment",
+                "search": ""
+            }
+        },
         {
             "comment": "Trailing space should be encoded",
             "href": "http://example.net",
@@ -1908,6 +2313,42 @@
                 "hash": "#castle"
             }
         },
+        {
+            "comment": "Drop trailing spaces from trailing opaque paths",
+            "href": "data:space                                                                                                                                  #fragment",
+            "new_value": "",
+            "expected": {
+                "href": "data:space",
+                "pathname": "space",
+                "hash": ""
+            }
+        },
+        {
+            "href": "sc:space    #fragment",
+            "new_value": "",
+            "expected": {
+                "href": "sc:space",
+                "pathname": "space",
+                "hash": ""
+            }
+        },
+        {
+            "comment": "Do not drop trailing spaces from non-trailing opaque paths",
+            "href": "data:space  ?query#fragment",
+            "new_value": "",
+            "expected": {
+                "href": "data:space  ?query",
+                "hash": ""
+            }
+        },
+        {
+            "href": "sc:space  ?query#fragment",
+            "new_value": "",
+            "expected": {
+                "href": "sc:space  ?query",
+                "hash": ""
+            }
+        },
         {
             "comment": "Trailing space should be encoded",
             "href": "http://example.net",
@@ -1926,5 +2367,15 @@
                 "hash": "#%00"
             }
         }
+    ],
+    "href": [
+        {
+            "href": "file:///var/log/system.log",
+            "new_value": "http://0300.168.0xF0",
+            "expected": {
+                "href": "http://192.168.0.240/",
+                "protocol": "http:"
+            }
+        }
     ]
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 125 - 125
url/tests/urltestdata.json


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů