url-setters-a-area.window.js (1535B)
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.any.js. 8 9 promise_test(() => fetch("resources/setters_tests.json").then(res => res.json()).then(runURLSettersTests), "Loading data…"); 10 11 function runURLSettersTests(allTestCases) { 12 for (const [propertyToBeSet, testCases] of Object.entries(allTestCases)) { 13 if (propertyToBeSet === "comment") { 14 continue; 15 } 16 17 for (const testCase of testCases) { 18 const name = `Setting <${testCase.href}>.${propertyToBeSet} = '${testCase.new_value}'${ 19 testCase.comment ? ` ${testCase.comment}` : '' 20 }`; 21 22 const key = testCase.href.split(":")[0]; 23 subsetTestByKey(key, test, () => { 24 const url = document.createElement("a"); 25 url.href = testCase.href; 26 url[propertyToBeSet] = testCase.new_value; 27 28 for (const [property, expectedValue] of Object.entries(testCase.expected)) { 29 assert_equals(url[property], expectedValue); 30 } 31 }, `<a>: ${name}`); 32 33 subsetTestByKey(key, test, () => { 34 const url = document.createElement("area"); 35 url.href = testCase.href; 36 url[propertyToBeSet] = testCase.new_value; 37 38 for (const [property, expectedValue] of Object.entries(testCase.expected)) { 39 assert_equals(url[property], expectedValue); 40 } 41 }, `<area>: ${name}`); 42 } 43 } 44 }