1promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…"); 2 3function runURLTests(urlTests) { 4 for (const expected of urlTests) { 5 // Skip comments and tests without "origin" expectation 6 if (typeof expected === "string" || !("origin" in expected)) 7 continue; 8 9 const base = expected.base !== null ? expected.base : undefined; 10 11 test(() => { 12 const url = new URL(expected.input, base); 13 assert_equals(url.origin, expected.origin, "origin"); 14 }, `Origin parsing: <${expected.input}> ${base ? "against <" + base + ">" : "without base"}`); 15 } 16} 17