1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/test_xhr_system.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +function ok(what, msg) { 1.5 + postMessage({ event: msg, test: 'ok', a: what }); 1.6 +} 1.7 + 1.8 +function is(a, b, msg) { 1.9 + postMessage({ event: msg, test: 'is', a: a, b: b }); 1.10 +} 1.11 + 1.12 +self.onmessage = function onmessage(event) { 1.13 + 1.14 + // An XHR with system privileges will be able to do cross-site calls. 1.15 + 1.16 + const TEST_URL = "http://example.com/tests/content/base/test/test_XHR_system.html"; 1.17 + is(location.hostname, "mochi.test", "hostname should be mochi.test"); 1.18 + 1.19 + var xhr = new XMLHttpRequest({mozSystem: true}); 1.20 + is(xhr.mozSystem, true, ".mozSystem == true"); 1.21 + xhr.open("GET", TEST_URL); 1.22 + xhr.onload = function onload() { 1.23 + is(xhr.status, 200); 1.24 + ok(xhr.responseText != null); 1.25 + ok(xhr.responseText.length); 1.26 + postMessage({test: "finish"}); 1.27 + }; 1.28 + xhr.onerror = function onerror() { 1.29 + ok(false, "Got an error event!"); 1.30 + postMessage({test: "finish"}); 1.31 + } 1.32 + xhr.send(); 1.33 +};