blob: 274de420bebbf3ba7180653922d7c0c303fc2679 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
'use strict';
const common = require('../common');
if (!common.hasIntl) {
// A handful of the tests fail when ICU is not included.
common.skip('missing Intl');
}
const path = require('path');
const URL = require('url').URL;
const { test, assert_equals } = require('../common/wpt');
const request = {
response: require(path.join(common.fixturesDir, 'url-tests'))
};
/* The following tests are copied from WPT. Modifications to them should be
upstreamed first. 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
*/
/* eslint-disable */
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 */
|