tor-browser

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

test_fetch-chrome.js (954B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Tests for DevToolsUtils.fetch on chrome:// URI's.
      6 
      7 const URL_FOUND = "chrome://devtools-shared/locale/debugger.properties";
      8 const URL_NOT_FOUND = "chrome://this/is/not/here.js";
      9 
     10 /**
     11 * Test that non-existent files are handled correctly.
     12 */
     13 add_task(async function test_missing() {
     14  await DevToolsUtils.fetch(URL_NOT_FOUND).then(
     15    result => {
     16      info(result);
     17      ok(false, "fetch resolved unexpectedly for non-existent chrome:// URI");
     18    },
     19    () => {
     20      ok(true, "fetch rejected as the chrome:// URI was non-existent.");
     21    }
     22  );
     23 });
     24 
     25 /**
     26 * Tests that existing files are handled correctly.
     27 */
     28 add_task(async function test_normal() {
     29  await DevToolsUtils.fetch(URL_FOUND).then(result => {
     30    notDeepEqual(
     31      result.content,
     32      "",
     33      "chrome:// URI seems to be read correctly."
     34    );
     35  });
     36 });