Properly setting the hoverRequest so it can be aborted. r=ahocevar (closes #2797)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10649 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2010-08-20 19:30:00 +00:00
parent 050eda6670
commit 5750b5f6e0
2 changed files with 38 additions and 2 deletions

View File

@@ -433,10 +433,10 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
if(this.drillDown === false) {
var wmsOptions = this.buildWMSOptions(this.url, layers,
clickPosition, layers[0].params.FORMAT);
var response = OpenLayers.Request.GET(wmsOptions);
var request = OpenLayers.Request.GET(wmsOptions);
if (options.hover === true) {
this.hoverRequest = response.priv;
this.hoverRequest = request;
}
} else {
this._requestCount = 0;

View File

@@ -350,6 +350,42 @@
map.destroy();
}
function test_hover(t) {
t.plan(2);
var map = new OpenLayers.Map({
div: "map",
layers: [
new OpenLayers.Layer.WMS(null, "/dummywms", {layers: "one"})
],
center: new OpenLayers.LonLat(0, 0),
zoom: 1
});
var control = new OpenLayers.Control.WMSGetFeatureInfo({
hover: true
});
map.addControl(control);
control.activate();
// mock up a mousemove
control.getInfoForHover({xy: new OpenLayers.Pixel(10, 10)});
t.ok(!!control.hoverRequest, "hoverRequest set");
// confirm that request is canceled on next move
var called = 0;
control.hoverRequest.abort = function() {
++called;
};
control.handler.px = null;
control.handler.mousemove({xy: new OpenLayers.Pixel(20, 20)});
t.eq(called, 1, "hover request aborted");
map.destroy();
}
function test_drillDown(t) {
t.plan(4);