1// META: script=/common/subset-tests-by-key.js 2// META: variant=?include=file 3// META: variant=?include=javascript 4// META: variant=?include=mailto 5// META: variant=?exclude=(file|javascript|mailto) 6 7// Keep this file in sync with url-setters-a-area.window.js. 8 9promise_test(() => fetch("resources/setters_tests.json").then(res => res.json()).then(runURLSettersTests), "Loading data…"); 10 11function runURLSettersTests(all_test_cases) { 12 for (var attribute_to_be_set in all_test_cases) { 13 if (attribute_to_be_set == "comment") { 14 continue; 15 } 16 var test_cases = all_test_cases[attribute_to_be_set]; 17 for(var i = 0, l = test_cases.length; i < l; i++) { 18 var test_case = test_cases[i]; 19 var name = "Setting <" + test_case.href + ">." + attribute_to_be_set + 20 " = '" + test_case.new_value + "'"; 21 if ("comment" in test_case) { 22 name += " " + test_case.comment; 23 } 24 const key = test_case.href.split(":")[0]; 25 subsetTestByKey(key, test, function() { 26 var url = new URL(test_case.href); 27 url[attribute_to_be_set] = test_case.new_value; 28 for (var attribute in test_case.expected) { 29 assert_equals(url[attribute], test_case.expected[attribute]) 30 } 31 }, "URL: " + name) 32 } 33 } 34} 35