tor-browser

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

test_worker_xhr_system.js (931B)


      1 /* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */
      2 
      3 function ok(what, msg) {
      4  postMessage({ event: msg, test: "ok", a: what });
      5 }
      6 
      7 function is(a, b, msg) {
      8  postMessage({ event: msg, test: "is", a, b });
      9 }
     10 
     11 self.onmessage = function onmessage() {
     12  // An XHR with system privileges will be able to do cross-site calls.
     13 
     14  const TEST_URL =
     15    "http://example.com/tests/dom/xhr/tests/test_XHR_system.html";
     16  is(location.hostname, "mochi.test", "hostname should be mochi.test");
     17 
     18  var xhr = new XMLHttpRequest({ mozSystem: true });
     19  is(xhr.mozSystem, true, ".mozSystem == true");
     20  xhr.open("GET", TEST_URL);
     21  xhr.onload = function onload() {
     22    is(xhr.status, 200);
     23    ok(xhr.responseText != null);
     24    ok(xhr.responseText.length);
     25    postMessage({ test: "finish" });
     26  };
     27  xhr.onerror = function onerror() {
     28    ok(false, "Got an error event!");
     29    postMessage({ test: "finish" });
     30  };
     31  xhr.send();
     32 };