tor-browser

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

embed-allowed-schemas.sub.window.js (1257B)


      1 async function test_uri(t, uri, pred) {
      2    const embed = document.createElement("embed");
      3    const promise = new Promise((resolve, reject) => {
      4        embed.onload = e => resolve(e.type);
      5        embed.src = uri;
      6        document.body.append(embed);
      7    });
      8    assert_equals(await promise, "load")
      9    assert_true(pred(embed));
     10 
     11    embed.remove();
     12 }
     13 
     14 // It's difficult detecting failure for <embed>, but the element
     15 // having an offsetWidth of '0' is often enough.
     16 function has_width(embed) {
     17    return embed.offsetWidth > 0;
     18 }
     19 
     20 promise_test(async t => {
     21    await test_uri(t, "about:blank", has_width);
     22 }, "about: allowed in embed");
     23 
     24 promise_test(async t => {
     25    const blobParts = ['Hello, world!'];
     26    const blob = new Blob(blobParts, { type: "text/html" })
     27    await test_uri(t, URL.createObjectURL(blob), has_width);
     28 }, "blob: allowed in embed");
     29 
     30 promise_test(async t => {
     31    await test_uri(t, "data:,Hello%2C%20World%21", has_width);
     32 }, "data: allowed in embed");
     33 
     34 promise_test(async t => {
     35    await test_uri(t, "https://{{domains[www]}}:{{ports[https][0]}}", has_width);
     36 }, "https: allowed in embed");
     37 
     38 promise_test(async t => {
     39    await test_uri(t, "http://{{domains[www]}}:{{ports[http][0]}}", has_width);
     40 }, "http: allowed in embed");