Bug 1463796 [wpt PR 11125] - Organize url/, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Wed, 06 Jun 2018 16:29:04 +0000
changeset 806614 bb6143626fa6668573e70eef9f8fe984bdf8600b
parent 806613 2328200e4c9b7af3ee940d34b091125ebf1fa043
child 806615 b246a87add182779a8d2611020b2cb6b33e1a79d
push id112908
push userbmo:gl@mozilla.com
push dateMon, 11 Jun 2018 02:53:29 +0000
reviewerstestonly
bugs1463796, 11125, 10918
milestone62.0a1
Bug 1463796 [wpt PR 11125] - Organize url/, a=testonly Automatic update from web-platform-testsOrganize url/ Move secondary resources into a resources/ directory and document the other two JSON resources. Fixes #10918. -- wpt-commits: 56a5265d0b143e2323696139b579428adb224f1d wpt-pr: 11125
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/url/README.md
testing/web-platform/tests/url/a-element-origin-xhtml.xhtml
testing/web-platform/tests/url/a-element-origin.html
testing/web-platform/tests/url/a-element-origin.js
testing/web-platform/tests/url/a-element-xhtml.xhtml
testing/web-platform/tests/url/a-element.html
testing/web-platform/tests/url/a-element.js
testing/web-platform/tests/url/failure.html
testing/web-platform/tests/url/resources/a-element-origin.js
testing/web-platform/tests/url/resources/a-element.js
testing/web-platform/tests/url/resources/setters_tests.json
testing/web-platform/tests/url/resources/toascii.json
testing/web-platform/tests/url/resources/urltestdata.json
testing/web-platform/tests/url/setters_tests.json
testing/web-platform/tests/url/toascii.json
testing/web-platform/tests/url/toascii.window.js
testing/web-platform/tests/url/url-constructor.html
testing/web-platform/tests/url/url-origin.html
testing/web-platform/tests/url/url-setters.html
testing/web-platform/tests/url/urltestdata.json
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -296526,37 +296526,37 @@
      {}
     ]
    ],
    "url/README.md": [
     [
      {}
     ]
    ],
-   "url/a-element-origin.js": [
-    [
-     {}
-    ]
-   ],
-   "url/a-element.js": [
-    [
-     {}
-    ]
-   ],
-   "url/setters_tests.json": [
-    [
-     {}
-    ]
-   ],
-   "url/toascii.json": [
-    [
-     {}
-    ]
-   ],
-   "url/urltestdata.json": [
+   "url/resources/a-element-origin.js": [
+    [
+     {}
+    ]
+   ],
+   "url/resources/a-element.js": [
+    [
+     {}
+    ]
+   ],
+   "url/resources/setters_tests.json": [
+    [
+     {}
+    ]
+   ],
+   "url/resources/toascii.json": [
+    [
+     {}
+    ]
+   ],
+   "url/resources/urltestdata.json": [
     [
      {}
     ]
    ],
    "user-timing/OWNERS": [
     [
      {}
     ]
@@ -609207,81 +609207,85 @@
    "4e49ff6d795fff54bc14069ab4f6f5fb5270f1c8",
    "testharness"
   ],
   "url/OWNERS": [
    "2b34648545644bc6ce8f70d0a7d0b26428498cea",
    "support"
   ],
   "url/README.md": [
-   "c617345fc667ed52a8e97027d121001d7a9edae0",
+   "17ffb158bda35ef8b55f8f7f5f084df2e0651bfc",
    "support"
   ],
   "url/a-element-origin-xhtml.xhtml": [
-   "56019fd2d3870324ba412e3e0c602bad3b90ef49",
+   "e46971a9bd9bbd1da7b8373fd4db4a1f7655b6e0",
    "testharness"
   ],
   "url/a-element-origin.html": [
-   "9e93740286ed4f6964b13861eedaf94705572d60",
-   "testharness"
-  ],
-  "url/a-element-origin.js": [
-   "db3ac8253d1d877c49e365f89eea0ed1a5bad32e",
-   "support"
+   "dca3c2a98527eaa828d98f28e1f619e0389a62bb",
+   "testharness"
   ],
   "url/a-element-xhtml.xhtml": [
-   "3c85e56094317c6babc96bdc187ee66ee4f040cd",
+   "d538bb2755a6f0cf461d40c9ed5ca4ea3254d1d4",
    "testharness"
   ],
   "url/a-element.html": [
-   "f1e6c1192c181236eb9bd32ead4f42338d020577",
-   "testharness"
-  ],
-  "url/a-element.js": [
-   "cf3fd382286fe89570e68e0d90131db35e03e6ef",
-   "support"
+   "17f7748607bd43c276d3b9013b5de42516aacc47",
+   "testharness"
   ],
   "url/data-uri-fragment.html": [
    "2db7660e8dab868a2dc771a3a702832b8978a980",
    "testharness"
   ],
   "url/failure.html": [
-   "82c87b01a847f2821d1d71ea5e1c2ce8528f4deb",
+   "be435247e1df422dfd051e35aea241d8e6b35207",
    "testharness"
   ],
   "url/historical.any.js": [
    "89dd0f84e69896c802c7a2062c9f4846cdca98c6",
    "testharness"
   ],
   "url/interfaces.any.js": [
    "a83c44354ce5f1e558d5f09fa0e5589582149f0c",
    "testharness"
   ],
-  "url/setters_tests.json": [
+  "url/resources/a-element-origin.js": [
+   "831d8c67d797a206df6d46b0ef427fbde9c1e847",
+   "support"
+  ],
+  "url/resources/a-element.js": [
+   "add0f2682d43e98f57cdae10f4c1c3a2e7bb8ae0",
+   "support"
+  ],
+  "url/resources/setters_tests.json": [
    "7c9707c02714de9a17989ecc71775978e994ae8a",
    "support"
   ],
-  "url/toascii.json": [
+  "url/resources/toascii.json": [
    "e8f5d819b9b4608d730a0a601e16ac2dd6c2d134",
    "support"
   ],
+  "url/resources/urltestdata.json": [
+   "442c5f9d5faeb6752c8b33a04c73f3f3ba82ccb7",
+   "support"
+  ],
   "url/toascii.window.js": [
-   "7166d07215b578c5d11d7ac831ddb47d0821155a",
+   "0b9d59d1900f3440a5e631a9488207c2947ebf69",
    "testharness"
   ],
   "url/url-constructor.html": [
-   "478523551e13b4066293fc2244972dd82b9bd87f",
+   "e1cc6dfc07040b019201dd7695b5171572f2fb8f",
    "testharness"
   ],
   "url/url-origin.html": [
-   "84a487b251a9f6dd320bf793050d1e43ae933ed9",
+   "c68cfe55de2330dce6b9c4fa40c0983a14e5c871",
    "testharness"
   ],
   "url/url-setters.html": [
-   "f9746a232f2047deb0bf0b5a73376a69b0ec14e2",
+   "46668877b10431168404c83af3e7c58c48940cfc",
    "testharness"
   ],
   "url/url-tojson.html": [
    "d961e88b6976933599ec06b1a2b6da6f200c150b",
    "testharness"
   ],
   "url/urlencoded-parser.html": [
    "4eb385fec2e8cbd3e65dbf36edb47a6f2beb0de8",
@@ -609322,20 +609326,16 @@
   "url/urlsearchparams-sort.html": [
    "dfc8f32339d084299318e9eb94fc47171247f2e1",
    "testharness"
   ],
   "url/urlsearchparams-stringifier.html": [
    "479e3fb9fc9eee208c492428c7032a96c70a5ae8",
    "testharness"
   ],
-  "url/urltestdata.json": [
-   "442c5f9d5faeb6752c8b33a04c73f3f3ba82ccb7",
-   "support"
-  ],
   "user-timing/OWNERS": [
    "b82f9756b15ef3ea45fb250e304031d9ceaee9c7",
    "support"
   ],
   "user-timing/clearMarks.html": [
    "2d63d9e6d85171289c7e3feab7d5db1083d2d461",
    "testharness"
   ],
--- a/testing/web-platform/tests/url/README.md
+++ b/testing/web-platform/tests/url/README.md
@@ -1,13 +1,13 @@
 ## urltestdata.json
 
 These tests are for browsers, but the data for
 `a-element.html`, `url-constructor.html`, `a-element-xhtml.xhtml`, and `failure.html`
-is in `urltestdata.json` and can be re-used by non-browser implementations.
+is in `resources/urltestdata.json` and can be re-used by non-browser implementations.
 This file contains a JSON array of comments as strings and test cases as objects.
 The keys for each test case are:
 
 * `base`: an absolute URL as a string whose [parsing] without a base of its own must succeed.
   This key is always present,
   and may have a value like `"about:blank"` when `input` is an absolute URL.
 * `input`: an URL as a string to be [parsed][parsing] with `base` as its base URL.
 * Either:
@@ -22,15 +22,27 @@ The keys for each test case are:
     In that case, the API’s `origin` attribute is not tested.
 
 In addition to testing that parsing `input` against `base` gives the result, a test harness for the
 `URL` constructor (or similar APIs) should additionally test the following pattern: if `failure` is
 true, parsing `about:blank` against `base` must give failure. This tests that the logic for
 converting base URLs into strings properly fails the whole parsing algorithm if the base URL cannot
 be parsed.
 
+## setters_tests.json
+
+`resources/setters_tests.json` is self-documented.
+
+## toascii.json
+
+`resources/toascii.json` is a JSON resource containing an array where each item is an object
+consisting of an optional `comment` field and mandatory `input` and `output` fields. `input` is the
+domain to be parsed according to the rules of UTS #46 (as stipulated by the URL Standard). `output`
+gives the expected output of the parser after serialization. An `output` of `null` means parsing is
+expected to fail.
+
 ## URL parser's encoding argument
 
 Tests in `/encoding` and `/html/infrastructure/urls/resolving-urls/query-encoding/` cover the
 encoding argument to the URL parser.
 
 [parsing]: https://url.spec.whatwg.org/#concept-basic-url-parser
 [API]: https://url.spec.whatwg.org/#api
--- a/testing/web-platform/tests/url/a-element-origin-xhtml.xhtml
+++ b/testing/web-platform/tests/url/a-element-origin-xhtml.xhtml
@@ -4,12 +4,12 @@
   <head>
     <title>URL Test</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <base id="base"/>
   </head>
   <body>
     <div id="log"></div>
-    <script src="a-element-origin.js"></script>
+    <script src="resources/a-element-origin.js"></script>
   </body>
 </html>
-<!-- Other dependencies: urltestdata.json -->
+<!-- Other dependencies: resources/urltestdata.json -->
--- a/testing/web-platform/tests/url/a-element-origin.html
+++ b/testing/web-platform/tests/url/a-element-origin.html
@@ -1,8 +1,8 @@
 <!doctype html>
 <meta charset=utf-8>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <base id=base>
 <div id=log></div>
-<script src=a-element-origin.js></script>
-<!-- Other dependencies: urltestdata.json -->
+<script src=resources/a-element-origin.js></script>
+<!-- Other dependencies: resources/urltestdata.json -->
deleted file mode 100644
--- a/testing/web-platform/tests/url/a-element-origin.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var setup = async_test("Loading data…")
-setup.step(function() {
-  var request = new XMLHttpRequest()
-  request.open("GET", "urltestdata.json")
-  request.send()
-  request.responseType = "json"
-  request.onload = setup.step_func(function() {
-    runURLTests(request.response)
-    setup.done()
-  })
-})
-
-function setBase(base) {
-  document.getElementById("base").href = base
-}
-
-function bURL(url, base) {
-  base = base || "about:blank"
-  setBase(base)
-  var a = document.createElement("a")
-  a.setAttribute("href", url)
-  return a
-}
-
-function runURLTests(urltests) {
-  for(var i = 0, l = urltests.length; i < l; i++) {
-    var expected = urltests[i]
-    if (typeof expected === "string" || !("origin" in expected)) continue
-
-    test(function() {
-      var url = bURL(expected.input, expected.base)
-      assert_equals(url.origin, expected.origin, "origin")
-    }, "Parsing origin: <" + expected.input + "> against <" + expected.base + ">")
-  }
-}
--- a/testing/web-platform/tests/url/a-element-xhtml.xhtml
+++ b/testing/web-platform/tests/url/a-element-xhtml.xhtml
@@ -4,12 +4,12 @@
   <head>
     <title>URL Test</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <base id="base"/>
   </head>
   <body>
     <div id="log"></div>
-    <script src="a-element.js"></script>
+    <script src="resources/a-element.js"></script>
   </body>
 </html>
-<!-- Other dependencies: urltestdata.json -->
+<!-- Other dependencies: resources/urltestdata.json -->
--- a/testing/web-platform/tests/url/a-element.html
+++ b/testing/web-platform/tests/url/a-element.html
@@ -1,8 +1,8 @@
 <!doctype html>
 <meta charset=utf-8>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <base id=base>
 <div id=log></div>
-<script src=a-element.js></script>
-<!-- Other dependencies: urltestdata.json -->
+<script src=resources/a-element.js></script>
+<!-- Other dependencies: resources/urltestdata.json -->
deleted file mode 100644
--- a/testing/web-platform/tests/url/a-element.js
+++ /dev/null
@@ -1,52 +0,0 @@
-var setup = async_test("Loading data…")
-setup.step(function() {
-  var request = new XMLHttpRequest()
-  request.open("GET", "urltestdata.json")
-  request.send()
-  request.responseType = "json"
-  request.onload = setup.step_func(function() {
-    runURLTests(request.response)
-    setup.done()
-  })
-})
-
-function setBase(base) {
-  document.getElementById("base").href = base
-}
-
-function bURL(url, base) {
-  base = base || "about:blank"
-  setBase(base)
-  var a = document.createElement("a")
-  a.setAttribute("href", url)
-  return a
-}
-
-function runURLTests(urltests) {
-  for(var i = 0, l = urltests.length; i < l; i++) {
-    var expected = urltests[i]
-    if (typeof expected === "string") continue // skip comments
-
-    test(function() {
-      var url = bURL(expected.input, expected.base)
-      if(expected.failure) {
-        if(url.protocol !== ':') {
-          assert_unreached("Expected URL to fail parsing")
-        }
-        assert_equals(url.href, expected.input, "failure should set href to input")
-        return
-      }
-
-      assert_equals(url.href, expected.href, "href")
-      assert_equals(url.protocol, expected.protocol, "protocol")
-      assert_equals(url.username, expected.username, "username")
-      assert_equals(url.password, expected.password, "password")
-      assert_equals(url.host, expected.host, "host")
-      assert_equals(url.hostname, expected.hostname, "hostname")
-      assert_equals(url.port, expected.port, "port")
-      assert_equals(url.pathname, expected.pathname, "pathname")
-      assert_equals(url.search, expected.search, "search")
-      assert_equals(url.hash, expected.hash, "hash")
-    }, "Parsing: <" + expected.input + "> against <" + expected.base + ">")
-  }
-}
--- a/testing/web-platform/tests/url/failure.html
+++ b/testing/web-platform/tests/url/failure.html
@@ -1,17 +1,17 @@
 <!doctype html>
 <meta charset=utf-8>
 <title>Test URL parser failure consistency</title>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <div id=log></div>
 <iframe></iframe>
 <script>
-promise_test(() => fetch("urltestdata.json").then(res => res.json()).then(runTests), "Loading data…")
+promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runTests), "Loading data…")
 
 function runTests(testData) {
   for(const test of testData) {
     if (typeof test === "string" || !test.failure || test.base !== "about:blank") {
       continue
     }
 
     const name = test.input + " should throw"
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/url/resources/a-element-origin.js
@@ -0,0 +1,25 @@
+promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
+
+function setBase(base) {
+  document.getElementById("base").href = base
+}
+
+function bURL(url, base) {
+  base = base || "about:blank"
+  setBase(base)
+  var a = document.createElement("a")
+  a.setAttribute("href", url)
+  return a
+}
+
+function runURLTests(urltests) {
+  for(var i = 0, l = urltests.length; i < l; i++) {
+    var expected = urltests[i]
+    if (typeof expected === "string" || !("origin" in expected)) continue
+
+    test(function() {
+      var url = bURL(expected.input, expected.base)
+      assert_equals(url.origin, expected.origin, "origin")
+    }, "Parsing origin: <" + expected.input + "> against <" + expected.base + ">")
+  }
+}
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/url/resources/a-element.js
@@ -0,0 +1,42 @@
+promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
+
+function setBase(base) {
+  document.getElementById("base").href = base
+}
+
+function bURL(url, base) {
+  base = base || "about:blank"
+  setBase(base)
+  var a = document.createElement("a")
+  a.setAttribute("href", url)
+  return a
+}
+
+function runURLTests(urltests) {
+  for(var i = 0, l = urltests.length; i < l; i++) {
+    var expected = urltests[i]
+    if (typeof expected === "string") continue // skip comments
+
+    test(function() {
+      var url = bURL(expected.input, expected.base)
+      if(expected.failure) {
+        if(url.protocol !== ':') {
+          assert_unreached("Expected URL to fail parsing")
+        }
+        assert_equals(url.href, expected.input, "failure should set href to input")
+        return
+      }
+
+      assert_equals(url.href, expected.href, "href")
+      assert_equals(url.protocol, expected.protocol, "protocol")
+      assert_equals(url.username, expected.username, "username")
+      assert_equals(url.password, expected.password, "password")
+      assert_equals(url.host, expected.host, "host")
+      assert_equals(url.hostname, expected.hostname, "hostname")
+      assert_equals(url.port, expected.port, "port")
+      assert_equals(url.pathname, expected.pathname, "pathname")
+      assert_equals(url.search, expected.search, "search")
+      assert_equals(url.hash, expected.hash, "hash")
+    }, "Parsing: <" + expected.input + "> against <" + expected.base + ">")
+  }
+}
rename from testing/web-platform/tests/url/setters_tests.json
rename to testing/web-platform/tests/url/resources/setters_tests.json
rename from testing/web-platform/tests/url/toascii.json
rename to testing/web-platform/tests/url/resources/toascii.json
rename from testing/web-platform/tests/url/urltestdata.json
rename to testing/web-platform/tests/url/resources/urltestdata.json
--- a/testing/web-platform/tests/url/toascii.window.js
+++ b/testing/web-platform/tests/url/toascii.window.js
@@ -1,17 +1,9 @@
-async_test(t => {
-  const request = new XMLHttpRequest()
-  request.open("GET", "toascii.json")
-  request.send()
-  request.responseType = "json"
-  request.onload = t.step_func_done(() => {
-    runTests(request.response)
-  })
-}, "Loading data…")
+promise_test(() => fetch("resources/toascii.json").then(res => res.json()).then(runTests), "Loading data…");
 
 function makeURL(type, input) {
   input = "https://" + input + "/x"
   if(type === "url") {
     return new URL(input)
   } else {
     const url = document.createElement(type)
     url.href = input
--- a/testing/web-platform/tests/url/url-constructor.html
+++ b/testing/web-platform/tests/url/url-constructor.html
@@ -1,28 +1,14 @@
 <!doctype html>
 <meta charset=utf-8>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <div id=log></div>
 <script>
-function runURLConstructorTests() {
-  var setup = async_test("Loading data…")
-  setup.step(function() {
-    var request = new XMLHttpRequest()
-    request.open("GET", "urltestdata.json")
-    request.send()
-    request.responseType = "json"
-    request.onload = setup.step_func(function() {
-      runURLTests(request.response)
-      setup.done()
-    })
-  })
-}
-
 function bURL(url, base) {
   return new URL(url, base || "about:blank")
 }
 
 function runURLTests(urltests) {
   for(var i = 0, l = urltests.length; i < l; i++) {
     var expected = urltests[i]
     if (typeof expected === "string") continue // skip comments
@@ -117,10 +103,10 @@ function runURLSearchParamTests() {
     assert_equals(url2.searchParams.toString(), '%3Fa=b&c=d')
 
     url2.href = 'http://example.org/file??a=b'
     assert_equals(url2.search, '??a=b')
     assert_equals(url2.searchParams.toString(), '%3Fa=b')
   }, 'URL.searchParams and URL.search setters, update propagation')
 }
 runURLSearchParamTests()
-runURLConstructorTests()
+promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
 </script>
--- a/testing/web-platform/tests/url/url-origin.html
+++ b/testing/web-platform/tests/url/url-origin.html
@@ -1,37 +1,24 @@
 <!doctype html>
 <meta charset=utf-8>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <div id=log></div>
 <script>
-function runURLOriginTests() {
-  var setup = async_test("Loading data…")
-  setup.step(function() {
-    var request = new XMLHttpRequest()
-    request.open("GET", "urltestdata.json")
-    request.send()
-    request.responseType = "json"
-    request.onload = setup.step_func(function() {
-      runURLTests(request.response)
-      setup.done()
-    })
-  })
-}
+promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
 
 function bURL(url, base) {
   return new URL(url, base || "about:blank")
 }
 
 function runURLTests(urltests) {
   for(var i = 0, l = urltests.length; i < l; i++) {
     var expected = urltests[i]
     if (typeof expected === "string" || !("origin" in expected)) continue
 
     test(function() {
       var url = bURL(expected.input, expected.base)
       assert_equals(url.origin, expected.origin, "origin")
     }, "Origin parsing: <" + expected.input + "> against <" + expected.base + ">")
   }
 }
-runURLOriginTests()
 </script>
--- a/testing/web-platform/tests/url/url-setters.html
+++ b/testing/web-platform/tests/url/url-setters.html
@@ -1,27 +1,15 @@
 <!doctype html>
 <meta charset=utf-8>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <div id=log></div>
 <script>
-function startURLSettersTests() {
-  var setup = async_test("Loading data…")
-  setup.step(function() {
-    var request = new XMLHttpRequest()
-    request.open("GET", "setters_tests.json")
-    request.send()
-    request.responseType = "json"
-    request.onload = setup.step_func(function() {
-      runURLSettersTests(request.response)
-      setup.done()
-    })
-  })
-}
+promise_test(() => fetch("resources/setters_tests.json").then(res => res.json()).then(runURLSettersTests), "Loading data…");
 
 function runURLSettersTests(all_test_cases) {
   for (var attribute_to_be_set in all_test_cases) {
     if (attribute_to_be_set == "comment") {
       continue;
     }
     var test_cases = all_test_cases[attribute_to_be_set];
     for(var i = 0, l = test_cases.length; i < l; i++) {
@@ -52,11 +40,9 @@ function runURLSettersTests(all_test_cas
         url[attribute_to_be_set] = test_case.new_value;
         for (var attribute in test_case.expected) {
           assert_equals(url[attribute], test_case.expected[attribute])
         }
       }, "<area>: " + name)
     }
   }
 }
-
-startURLSettersTests()
 </script>