1<!doctype html> 2<meta charset=utf-8> 3<script src=/resources/testharness.js></script> 4<script src=/resources/testharnessreport.js></script> 5<div id=log></div> 6<script> 7promise_test(() => fetch("resources/setters_tests.json").then(res => res.json()).then(runURLSettersTests), "Loading data…"); 8 9function runURLSettersTests(all_test_cases) { 10 for (var attribute_to_be_set in all_test_cases) { 11 if (attribute_to_be_set == "comment") { 12 continue; 13 } 14 var test_cases = all_test_cases[attribute_to_be_set]; 15 for(var i = 0, l = test_cases.length; i < l; i++) { 16 var test_case = test_cases[i]; 17 var name = "Setting <" + test_case.href + ">." + attribute_to_be_set + 18 " = '" + test_case.new_value + "'"; 19 if ("comment" in test_case) { 20 name += " " + test_case.comment; 21 } 22 test(function() { 23 var url = new URL(test_case.href); 24 url[attribute_to_be_set] = test_case.new_value; 25 for (var attribute in test_case.expected) { 26 assert_equals(url[attribute], test_case.expected[attribute]) 27 } 28 }, "URL: " + name) 29 test(function() { 30 var url = document.createElement("a"); 31 url.href = test_case.href; 32 url[attribute_to_be_set] = test_case.new_value; 33 for (var attribute in test_case.expected) { 34 assert_equals(url[attribute], test_case.expected[attribute]) 35 } 36 }, "<a>: " + name) 37 test(function() { 38 var url = document.createElement("area"); 39 url.href = test_case.href; 40 url[attribute_to_be_set] = test_case.new_value; 41 for (var attribute in test_case.expected) { 42 assert_equals(url[attribute], test_case.expected[attribute]) 43 } 44 }, "<area>: " + name) 45 } 46 } 47} 48</script> 49