11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<meta charset=utf-8> 31cb0ef41Sopenharmony_ci<script src=/resources/testharness.js></script> 41cb0ef41Sopenharmony_ci<script src=/resources/testharnessreport.js></script> 51cb0ef41Sopenharmony_ci<div id=log></div> 61cb0ef41Sopenharmony_ci<script> 71cb0ef41Sopenharmony_cifunction bURL(url, base) { 81cb0ef41Sopenharmony_ci return new URL(url, base || "about:blank") 91cb0ef41Sopenharmony_ci} 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cifunction runURLTests(urltests) { 121cb0ef41Sopenharmony_ci for(var i = 0, l = urltests.length; i < l; i++) { 131cb0ef41Sopenharmony_ci var expected = urltests[i] 141cb0ef41Sopenharmony_ci if (typeof expected === "string") continue // skip comments 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci test(function() { 171cb0ef41Sopenharmony_ci if (expected.failure) { 181cb0ef41Sopenharmony_ci assert_throws_js(TypeError, function() { 191cb0ef41Sopenharmony_ci bURL(expected.input, expected.base) 201cb0ef41Sopenharmony_ci }) 211cb0ef41Sopenharmony_ci return 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci var url = bURL(expected.input, expected.base) 251cb0ef41Sopenharmony_ci assert_equals(url.href, expected.href, "href") 261cb0ef41Sopenharmony_ci assert_equals(url.protocol, expected.protocol, "protocol") 271cb0ef41Sopenharmony_ci assert_equals(url.username, expected.username, "username") 281cb0ef41Sopenharmony_ci assert_equals(url.password, expected.password, "password") 291cb0ef41Sopenharmony_ci assert_equals(url.host, expected.host, "host") 301cb0ef41Sopenharmony_ci assert_equals(url.hostname, expected.hostname, "hostname") 311cb0ef41Sopenharmony_ci assert_equals(url.port, expected.port, "port") 321cb0ef41Sopenharmony_ci assert_equals(url.pathname, expected.pathname, "pathname") 331cb0ef41Sopenharmony_ci assert_equals(url.search, expected.search, "search") 341cb0ef41Sopenharmony_ci if ("searchParams" in expected) { 351cb0ef41Sopenharmony_ci assert_true("searchParams" in url) 361cb0ef41Sopenharmony_ci assert_equals(url.searchParams.toString(), expected.searchParams, "searchParams") 371cb0ef41Sopenharmony_ci } 381cb0ef41Sopenharmony_ci assert_equals(url.hash, expected.hash, "hash") 391cb0ef41Sopenharmony_ci }, "Parsing: <" + expected.input + "> against <" + expected.base + ">") 401cb0ef41Sopenharmony_ci } 411cb0ef41Sopenharmony_ci} 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_cipromise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…"); 441cb0ef41Sopenharmony_ci</script> 45