tor-browser

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

fetch.js (955B)


      1 "use strict";
      2 
      3 const { AddonTestUtils } = ChromeUtils.importESModule(
      4  "resource://testing-common/AddonTestUtils.sys.mjs"
      5 );
      6 
      7 AddonTestUtils.init(this);
      8 AddonTestUtils.createAppInfo(
      9  "xpcshell@tests.mozilla.org",
     10  "XPCShell",
     11  "42",
     12  "42"
     13 );
     14 
     15 add_task(async function helper() {
     16  do_get_profile();
     17 
     18  // The SearchService is also needed in order to construct the initial state,
     19  // which means that the AddonManager needs to be available.
     20  await AddonTestUtils.promiseStartupManager();
     21 
     22  // The example.com domain will be used to host the dynamic layout JSON and
     23  // the top stories JSON.
     24  let server = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
     25  server.registerDirectory("/", do_get_cwd());
     26 
     27  Assert.equal(true, fetch instanceof Function);
     28  var k = await fetch("http://example.com/");
     29  console.log(k);
     30  console.log(k.body);
     31  var r = k.body.getReader();
     32  console.log(r);
     33  var v = await r.read();
     34  console.log(v);
     35 });