dom/workers/test/test_bug883784.jsm

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 this.EXPORTED_SYMBOLS = ["Test"];
michael@0 2
michael@0 3 this.Test = {
michael@0 4 start: function(ok, is, finish) {
michael@0 5 let worker = new ChromeWorker("jsm_url_worker.js");
michael@0 6 worker.onmessage = function(event) {
michael@0 7
michael@0 8 if (event.data.type == 'finish') {
michael@0 9 finish();
michael@0 10 } else if (event.data.type == 'status') {
michael@0 11 ok(event.data.status, event.data.msg);
michael@0 12 } else if (event.data.type == 'url') {
michael@0 13 var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
michael@0 14 .createInstance(Components.interfaces.nsIXMLHttpRequest);
michael@0 15 xhr.open('GET', event.data.url, false);
michael@0 16 xhr.onreadystatechange = function() {
michael@0 17 if (xhr.readyState == 4) {
michael@0 18 ok(true, "Blob readable!");
michael@0 19 }
michael@0 20 }
michael@0 21 xhr.send();
michael@0 22 }
michael@0 23 };
michael@0 24
michael@0 25 var self = this;
michael@0 26 worker.onerror = function(event) {
michael@0 27 is(event.target, worker);
michael@0 28 ok(false, "Worker had an error: " + event.data);
michael@0 29 self.worker.terminate();
michael@0 30 finish();
michael@0 31 };
michael@0 32
michael@0 33 worker.postMessage(0);
michael@0 34 }
michael@0 35 };

mercurial