From 0f648dedf46fc65ecbc85ade633da099283e5f65 Mon Sep 17 00:00:00 2001 From: bartvde Date: Wed, 19 May 2010 12:51:09 +0000 Subject: [PATCH] do not send request if abort has been called, r=elemoine (closes #2065) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10341 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Request.js | 2 ++ tests/Request.html | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/OpenLayers/Request.js b/lib/OpenLayers/Request.js index 35ade9e738..211772437c 100644 --- a/lib/OpenLayers/Request.js +++ b/lib/OpenLayers/Request.js @@ -168,7 +168,9 @@ OpenLayers.Request = { request.send(config.data); } else { window.setTimeout(function(){ + if (request._aborted !== true) { request.send(config.data); + } }, 0); } return request; diff --git a/tests/Request.html b/tests/Request.html index 336e627840..6fac6eff9b 100644 --- a/tests/Request.html +++ b/tests/Request.html @@ -371,6 +371,22 @@ teardown(); } + function test_abort(t) { + t.plan(0); + var fail = false; + OpenLayers.Request.XMLHttpRequest.onsend = function(args) { + fail = true; + } + t.delay_call(0.5, function() { + if (fail === true) { + t.fail("Send should not be called because request is aborted"); + } + OpenLayers.Request.XMLHttpRequest.onsend = null; + }); + var protocol = new OpenLayers.Protocol.HTTP(); + protocol.abort(protocol.read()); + } +