michael@0: // Used to test XHR in the worker. michael@0: onconnect = function(e) { michael@0: let port = e.ports[0]; michael@0: let req; michael@0: try { michael@0: req = new XMLHttpRequest(); michael@0: } catch(e) { michael@0: port.postMessage({topic: "done", result: "FAILED to create XHR object, " + e.toString() }); michael@0: } michael@0: if (req === undefined) { // until bug 756173 is fixed... michael@0: port.postMessage({topic: "done", result: "FAILED to create XHR object"}); michael@0: return; michael@0: } michael@0: // The test that uses this worker MUST use the same origin to load the worker. michael@0: // We fetch the test app manifest so we can check the data is what we expect. michael@0: let url = "https://example.com/browser/toolkit/components/social/test/browser/data.json"; michael@0: req.open("GET", url, true); michael@0: req.onreadystatechange = function() { michael@0: if (req.readyState === 4) { michael@0: let ok = req.status == 200 && req.responseText.length > 0; michael@0: if (ok) { michael@0: // check we actually got something sane... michael@0: try { michael@0: let data = JSON.parse(req.responseText); michael@0: ok = "response" in data; michael@0: } catch(e) { michael@0: ok = e.toString(); michael@0: } michael@0: } michael@0: port.postMessage({topic: "done", result: ok ? "ok" : "bad response"}); michael@0: } michael@0: } michael@0: req.send(null); michael@0: }