diff --git a/lib/OpenLayers/Strategy/BBOX.js b/lib/OpenLayers/Strategy/BBOX.js index b6307876fb..6d59e4c2ab 100644 --- a/lib/OpenLayers/Strategy/BBOX.js +++ b/lib/OpenLayers/Strategy/BBOX.js @@ -124,9 +124,12 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { * Callback function called on "moveend" or "refresh" layer events. * * Parameters: - * options - {Object} An object with a property named "force", this - * property references a boolean value indicating if new data - * must be incondtionally read. + * options - {Object} Optional object whose properties will determine + * the behaviour of this Strategy + * + * Valid options include: + * force - {Boolean} if true, new data must be unconditionally read. + * noAbort - {Boolean} if true, do not abort previous requests. */ update: function(options) { var mapBounds = this.getMapBounds(); @@ -218,7 +221,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { * returned by the layer protocol. */ triggerRead: function(options) { - if (this.response) { + if (this.response && !(options && options.noAbort === true)) { this.layer.protocol.abort(this.response); this.layer.events.triggerEvent("loadend"); } diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index c0ff4ff401..aa66c65321 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -33,7 +33,7 @@ } function test_update(t) { - t.plan(5); + t.plan(7); // Create a dummy layer that can act as the map base layer. // This will be unnecessary if #1921 is addressed (allowing @@ -43,9 +43,10 @@ var strategy = new OpenLayers.Strategy.BBOX({ ratio: 1 // makes for easier comparison to map bounds }); + var log = []; var layer = new OpenLayers.Layer.Vector(null, { isBaseLayer: true, - protocol: new OpenLayers.Protocol(), + protocol: new OpenLayers.Protocol({abort: function(response) { log.push(response); }}), strategies: [strategy] }); @@ -61,7 +62,14 @@ * should be removed when the issue(s) described in #1835 are addressed. */ strategy.update({force: true}); - + strategy.response = {}; + strategy.update({force: true}); + t.eq(log.length, 1, "Response aborted"); + log = []; + strategy.update({force: true}); + strategy.update({force: true, noAbort: true}); + t.eq(log.length, 0, "Response not aborted when noAbort is true"); + // test that the strategy bounds were set t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");