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.

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

mercurial