tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

url-setters.any.js (1156B)


      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 
      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 test_case of testCases) {
     18      const name = `Setting <${test_case.href}>.${propertyToBeSet} = '${test_case.new_value}'${
     19        test_case.comment ? ` ${test_case.comment}` : ''
     20      }`;
     21 
     22      const key = test_case.href.split(":")[0];
     23      subsetTestByKey(key, test, () => {
     24        const url = new URL(test_case.href);
     25        url[propertyToBeSet] = test_case.new_value;
     26 
     27        for (const [property, expectedValue] of Object.entries(test_case.expected)) {
     28          assert_equals(url[property], expectedValue);
     29        }
     30      }, `URL: ${name}`);
     31    }
     32  }
     33 }