From 3e9253a5cbb7fb93e211a6ca6ce91d862b6de926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 18 Nov 2010 13:39:08 +0000 Subject: [PATCH] make Request.html pass again, it passes in Chrome7, IE7 and FF3, no functional change git-svn-id: http://svn.openlayers.org/trunk/openlayers@10904 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- tests/Request.html | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tests/Request.html b/tests/Request.html index 6fac6eff9b..acdd8951d8 100644 --- a/tests/Request.html +++ b/tests/Request.html @@ -372,19 +372,41 @@ } function test_abort(t) { + t.plan(0); - var fail = false; - OpenLayers.Request.XMLHttpRequest.onsend = function(args) { - fail = true; - } + + var sendCalled; + + // set up + + var _open = OpenLayers.Request.XMLHttpRequest.prototype.open; + OpenLayers.Request.XMLHttpRequest.prototype.open = function() { + this.readyState = OpenLayers.Request.XMLHttpRequest.OPENED; + }; + + var _setRequestHeader = OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader; + OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader = function() {}; + + var _send = OpenLayers.Request.XMLHttpRequest.prototype.send; + OpenLayers.Request.XMLHttpRequest.prototype.send = function() { + sendCalled = true; + }; + + // test + + sendCalled = false; + OpenLayers.Request.issue().abort(); + t.delay_call(0.5, function() { - if (fail === true) { + if (sendCalled) { t.fail("Send should not be called because request is aborted"); } - OpenLayers.Request.XMLHttpRequest.onsend = null; + + // tear down + OpenLayers.Request.XMLHttpRequest.prototype.open = _open; + OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader = _setRequestHeader; + OpenLayers.Request.XMLHttpRequest.prototype.send = _send; }); - var protocol = new OpenLayers.Protocol.HTTP(); - protocol.abort(protocol.read()); }