dom/workers/test/test_xhr_system.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial