[qooxdoo-commit] SF.net SVN: qooxdoo:[28562] trunk/qooxdoo/framework/source/class/qx
Brought to you by:
ecker,
martinwittemann
From: <tri...@us...> - 2011-08-30 08:32:06
|
Revision: 28562 http://qooxdoo.svn.sourceforge.net/qooxdoo/?rev=28562&view=rev Author: tristankoch Date: 2011-08-30 08:31:59 +0000 (Tue, 30 Aug 2011) Log Message: ----------- [BUG #5485] When aborting, update phase to "abort" before user handler are invoked Modified Paths: -------------- trunk/qooxdoo/framework/source/class/qx/io/request/AbstractRequest.js trunk/qooxdoo/framework/source/class/qx/test/io/request/MRequest.js trunk/qooxdoo/framework/source/class/qx/test/io/request/XhrWithRemote.js Modified: trunk/qooxdoo/framework/source/class/qx/io/request/AbstractRequest.js =================================================================== --- trunk/qooxdoo/framework/source/class/qx/io/request/AbstractRequest.js 2011-08-30 08:16:22 UTC (rev 28561) +++ trunk/qooxdoo/framework/source/class/qx/io/request/AbstractRequest.js 2011-08-30 08:31:59 UTC (rev 28562) @@ -374,6 +374,10 @@ this.debug("Abort request"); } this.__abort = true; + + // Update phase to "abort" before user handler are invoked [BUG #5485] + this.__phase = "abort"; + this._transport.abort(); }, @@ -564,7 +568,7 @@ // Transport switches to readyState DONE on abort and may already // have successful HTTP status when response is served from cache. // - // Not fire "loading" (and "success" when cached). + // Not fire custom event "loading" (or "success", when cached). if (this.__abort) { return; } Modified: trunk/qooxdoo/framework/source/class/qx/test/io/request/MRequest.js =================================================================== --- trunk/qooxdoo/framework/source/class/qx/test/io/request/MRequest.js 2011-08-30 08:16:22 UTC (rev 28561) +++ trunk/qooxdoo/framework/source/class/qx/test/io/request/MRequest.js 2011-08-30 08:31:59 UTC (rev 28562) @@ -425,6 +425,72 @@ this.assertEquals("abort", req.getPhase()); }, + "test: phase is abort on readyState DONE when aborted before": function() { + this.setUpFakeTransport(); + var req = this.req, + transport = this.transport; + + req.addListener("readyStateChange", function() { + if (req.getReadyState() == 4) { + this.assertEquals("abort", req.getPhase()); + } + }, this); + + req.send(); + req.abort(); + + // Transport switches to readyState DONE on abort + transport.readyState = 4; + transport.onreadystatechange(); + + transport.onabort(); + }, + + "test: phase is abort on readyState DONE when aborting loading": function() { + this.setUpFakeTransport(); + var req = this.req, + transport = this.transport; + + req.addListener("readyStateChange", function() { + if (req.getReadyState() == 4) { + this.assertEquals("abort", req.getPhase()); + } + }, this); + + req.send(); + + // Loading + transport.readyState = 3; + transport.onreadystatechange(); + + // Abort loading + req.abort(); + + // Transport switches to readyState DONE on abort + transport.readyState = 4; + transport.onreadystatechange(); + transport.onabort(); + }, + + "test: phase is abort on loadEnd when aborted before": function() { + this.setUpFakeTransport(); + var req = this.req, + transport = this.transport; + + req.addListener("loadEnd", function() { + this.assertEquals("abort", req.getPhase()); + }, this); + + req.send(); + req.abort(); + + // Transport fires "onloadend" on abort + transport.readyState = 4; + transport.onloadend(); + + transport.onabort(); + }, + "test: phase is timeout": function() { this.setUpFakeTransport(); var req = this.req, Modified: trunk/qooxdoo/framework/source/class/qx/test/io/request/XhrWithRemote.js =================================================================== --- trunk/qooxdoo/framework/source/class/qx/test/io/request/XhrWithRemote.js 2011-08-30 08:16:22 UTC (rev 28561) +++ trunk/qooxdoo/framework/source/class/qx/test/io/request/XhrWithRemote.js 2011-08-30 08:31:59 UTC (rev 28562) @@ -118,6 +118,34 @@ req.abort(); }, + "test: progress phases when abort after loading": function() { + var req = this.req, + phases = [], + expectedPhases = ["opened", "sent", "loading", "abort"], + url = this.noCache(this.getUrl("qx/test/xmlhttp/loading.php")) + "&duration=100"; + + req.addListener("changePhase", function() { + phases.push(req.getPhase()); + + if (req.getPhase() === "abort") { + this.resume(function() { + this.assertArrayEquals(expectedPhases, phases); + }); + } + + }, this); + + req.setUrl(url); + req.send(); + + // Abort loading. Give remote some time to respond. + qx.event.Timer.once(function() { + req.abort(); + }, this, 500); + + this.wait(); + }, + // "test: fetch resources simultaneously": function() { // this.require(["php"]); // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |