summaryrefslogtreecommitdiff
path: root/test/parallel/test-whatwg-url-origin.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2017-02-02 14:13:16 +0800
committerJames M Snell <jasnell@gmail.com>2017-02-02 11:46:52 -0800
commit10b687b58b02fa7c55e06b6bd8fc5bc8ef2e1a7f (patch)
treefc8b0501a8822578c467aaf2e08e5ded84244313 /test/parallel/test-whatwg-url-origin.js
parent2a887385ba3ef54f6baf70644c9cb6babef669a3 (diff)
downloadandroid-node-v8-10b687b58b02fa7c55e06b6bd8fc5bc8ef2e1a7f.tar.gz
android-node-v8-10b687b58b02fa7c55e06b6bd8fc5bc8ef2e1a7f.tar.bz2
android-node-v8-10b687b58b02fa7c55e06b6bd8fc5bc8ef2e1a7f.zip
test, url: synchronize WPT url tests
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: https://github.com/w3c/web-platform-tests/pull/4413 Refs: https://github.com/whatwg/url/issues/104 PR-URL: https://github.com/nodejs/node/pull/11079 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'test/parallel/test-whatwg-url-origin.js')
-rw-r--r--test/parallel/test-whatwg-url-origin.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/parallel/test-whatwg-url-origin.js b/test/parallel/test-whatwg-url-origin.js
new file mode 100644
index 0000000000..1186a1d184
--- /dev/null
+++ b/test/parallel/test-whatwg-url-origin.js
@@ -0,0 +1,52 @@
+'use strict';
+const common = require('../common');
+const path = require('path');
+const URL = require('url').URL;
+const { test, assert_equals } = common.WPT;
+
+if (!common.hasIntl) {
+ // A handful of the tests fail when ICU is not included.
+ common.skip('missing Intl');
+ return;
+}
+
+const request = {
+ response: require(path.join(common.fixturesDir, 'url-tests.json'))
+};
+
+/* eslint-disable */
+/* WPT Refs:
+ https://github.com/w3c/web-platform-tests/blob/8791bed/url/url-origin.html
+ License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
+*/
+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()
+ // })
+ // })
+}
+
+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()
+/* eslint-enable */