tor-browser

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

browser_viewsource.js (793B)


      1 "use strict";
      2 
      3 add_task(async function () {
      4  const PAGE_URL = getRootDirectory(gTestPath) + "file_viewsource.html";
      5  let viewSourceTab = await BrowserTestUtils.openNewForegroundTab(
      6    gBrowser,
      7    "view-source:" + PAGE_URL
      8  );
      9 
     10  let xhrPromise = new Promise(resolve => {
     11    let xhr = new XMLHttpRequest();
     12    xhr.open("GET", PAGE_URL, true);
     13    xhr.onload = event => resolve(event.target.responseText);
     14    xhr.send();
     15  });
     16 
     17  let viewSourceContentPromise = SpecialPowers.spawn(
     18    viewSourceTab.linkedBrowser,
     19    [],
     20    async function () {
     21      return content.document.body.textContent;
     22    }
     23  );
     24 
     25  let results = await Promise.all([viewSourceContentPromise, xhrPromise]);
     26  is(results[0], results[1], "Sources should match");
     27  BrowserTestUtils.removeTab(viewSourceTab);
     28 });