Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | }; |