tor-browser

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

browser_http_index_format.js (1513B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const FILE_URI = Services.appinfo.OS == "WINNT" ? "file://C:/" : "file:///";
      7 
      8 const RESOURCE_URI = "resource:///";
      9 
     10 const ZIP_FILE = "res_empty.zip";
     11 const ZIP_DIR = getChromeDir(getResolvedURI(gTestPath));
     12 ZIP_DIR.append(ZIP_FILE);
     13 ZIP_DIR.normalize();
     14 const ZIP_URI = Services.io.newFileURI(ZIP_DIR).spec;
     15 const JAR_URI = "jar:" + ZIP_URI + "!/";
     16 
     17 const BASE_URI = "http://mochi.test:8888/browser/netwerk/test/browser/";
     18 const INDEX_URI = BASE_URI + "res_http_index_format";
     19 
     20 async function expectIndexToDisplay(aUrl, aExpectToDisplay) {
     21  info(`Opening ${aUrl} to check if index will be displayed`);
     22  const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, aUrl, true);
     23  await SpecialPowers.spawn(
     24    tab.linkedBrowser,
     25    [aExpectToDisplay],
     26    aExpectToDisplay => {
     27      is(
     28        !!content.document.getElementsByTagName("table").length,
     29        aExpectToDisplay,
     30        "The index should be displayed"
     31      );
     32    }
     33  );
     34  await BrowserTestUtils.removeTab(tab);
     35 }
     36 
     37 add_task(async function test_http_index_format() {
     38  await expectIndexToDisplay(FILE_URI, true);
     39  await expectIndexToDisplay(RESOURCE_URI, true);
     40  await expectIndexToDisplay(JAR_URI, true);
     41  await expectIndexToDisplay(INDEX_URI, false);
     42 
     43  await SpecialPowers.pushPrefEnv({
     44    set: [["network.http_index_format.allowed_schemes", "*"]],
     45  });
     46 
     47  await expectIndexToDisplay(INDEX_URI, true);
     48 });