tor-browser

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

origin-from-htmlhyperlinkelementutils.window.js (1516B)


      1 // META: title=`Origin.from(HTMLHyperlinkElementUtils)`
      2 // META: script=resources/serializations.js
      3 
      4 test(t => {
      5  const invalid = document.createElement("a");
      6  assert_throws_js(TypeError, _ => Origin.from(invalid));
      7 }, `Origin.from(<a>) throws.`);
      8 
      9 test(t => {
     10  const invalid = document.createElement("area");
     11  assert_throws_js(TypeError, _ => Origin.from(invalid));
     12 }, `Origin.from(<area>) throws.`);
     13 
     14 for (const opaque of urls.opaque) {
     15  // <a>
     16  test(t => {
     17    const a = document.createElement("a");
     18    a.href = opaque;
     19    const origin = Origin.from(a);
     20    assert_true(!!origin);
     21    assert_true(origin.opaque);
     22  }, `Origin.from(<a href="${opaque}">) returns an opaque origin.`);
     23 
     24  // <area>
     25  test(t => {
     26    const area = document.createElement("area");
     27    area.href = opaque;
     28    const origin = Origin.from(area);
     29    assert_true(!!origin);
     30    assert_true(origin.opaque);
     31  }, `Origin.from(<area href="${opaque}">) returns an opaque origin.`);
     32 }
     33 
     34 for (const tuple of urls.tuple) {
     35  // <a>
     36  test(t => {
     37    const a = document.createElement("a");
     38    a.href = tuple;
     39    const origin = Origin.from(a);
     40    assert_true(!!origin);
     41    assert_false(origin.opaque);
     42  }, `Origin.from(<a href="${tuple}">) returns a tuple origin.`);
     43 
     44  // <area>
     45  test(t => {
     46    const area = document.createElement("area");
     47    area.href = tuple;
     48    const origin = Origin.from(area);
     49    assert_true(!!origin);
     50    assert_false(origin.opaque);
     51  }, `Origin.from(<area href="${tuple}">) returns a tuple origin.`);
     52 }