[qooxdoo-commit] SF.net SVN: qooxdoo:[27480] trunk/qooxdoo/framework/source/class/qx
Brought to you by:
ecker,
martinwittemann
From: <adr...@us...> - 2011-05-31 15:36:12
|
Revision: 27480 http://qooxdoo.svn.sourceforge.net/qooxdoo/?rev=27480&view=rev Author: adrianolaru Date: 2011-05-31 15:36:06 +0000 (Tue, 31 May 2011) Log Message: ----------- [BUG #4721] Making the test run Modified Paths: -------------- trunk/qooxdoo/framework/source/class/qx/bom/WebWorker.js trunk/qooxdoo/framework/source/class/qx/test/bom/WebWorker.js Modified: trunk/qooxdoo/framework/source/class/qx/bom/WebWorker.js =================================================================== --- trunk/qooxdoo/framework/source/class/qx/bom/WebWorker.js 2011-05-31 14:11:22 UTC (rev 27479) +++ trunk/qooxdoo/framework/source/class/qx/bom/WebWorker.js 2011-05-31 15:36:06 UTC (rev 27480) @@ -73,21 +73,7 @@ __fake : null, - /** - * The fake worker context - * @param worker {qx.bom.WebWorker} current worker - * @param code {String} The code to be evaluated - */ - __FakeWorker: function(worker, code) { - var postMessage = this.postMessage = function (e) { - worker.fireDataEvent("message", e); - }; - var onmessage; - eval(code); - this.onmessage = onmessage; - }, - /** * Initialize the native worker * @param src {String} The path to worker as an URL @@ -101,7 +87,6 @@ qx.bom.Event.addNativeListener(this._worker, "error", this._handleErrorBound); }, - /** * Initialize the fake worker * @param src {String} The path to worker as an URL @@ -110,8 +95,16 @@ var that = this; var req = new qx.bom.request.Xhr(); req.onload = function() { - that.__fake = new that.__FakeWorker(that, req.responseText); + that.__fake = (function(w) { + eval("var onmessage = null; var postMessage = function (e) "+ + "{ w.fireDataEvent('message', e); };" + req.responseText); + return { + onmessage: onmessage, + postMessage: postMessage + } + })(that); }; + req.open("GET", src, false); req.send(); }, @@ -127,13 +120,12 @@ if (this.__isNative) { this._worker.postMessage(msg); } else { - window.setTimeout(function() { try { - that.__fake.onmessage.call(that.__fake, {data: msg}); + that.__fake.onmessage && that.__fake.onmessage({data: msg}); } catch (ex) { + console.log(ex); that.fireDataEvent("error", ex); } - }, 0); } }, Modified: trunk/qooxdoo/framework/source/class/qx/test/bom/WebWorker.js =================================================================== --- trunk/qooxdoo/framework/source/class/qx/test/bom/WebWorker.js 2011-05-31 14:11:22 UTC (rev 27479) +++ trunk/qooxdoo/framework/source/class/qx/test/bom/WebWorker.js 2011-05-31 15:36:06 UTC (rev 27480) @@ -41,15 +41,10 @@ this._send = function(message, fn) { this._worker.addListener("message", function(e) { - this.resume(function() { - //check the type, it should be the same - this.assertType(e.getData(), typeof message); - //make other checks - fn.call(this, message, e); - }, this); + this.assertType(e.getData(), typeof message); + fn.call(this, message, e); }, this); this._worker.postMessage(message); - this.wait(); }; }, @@ -65,6 +60,7 @@ testMessageEvent: function() { this._send("message", function(mess, e) { + console.log(e.getData()); this.assertIdentical(mess, e.getData()); }); }, @@ -73,29 +69,29 @@ var message = "error"; this._worker.addListener("error", function(e) { - this.resume(function() { - this.assertTrue(/error/.test(e.getData())); - }, this); + console.log(e.getData()); + this.assertTrue(/error/.test(e.getData())); }, this); - this._worker.postMessage(message); - this.wait(); }, testPostMessageWithNumber: function() { this._send(1, function(mess, e) { + console.log(e.getData()); this.assertIdentical(mess, e.getData()); }); }, testPostMessageWithBoolean: function() { this._send(true, function(mess, e) { + console.log(e.getData()); this.assertIdentical(mess, e.getData()); }); }, testPostMessageWithNull: function() { this._send(null, function(mess, e) { + console.log(e.getData()); this.assertIdentical(mess, e.getData()); }); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |