diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 9923109087..4db5ff8440 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -7,6 +7,7 @@ /** * @requires OpenLayers/Tile.js * @requires OpenLayers/Animation.js + * @requires OpenLayers/Util.js */ /** @@ -317,7 +318,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { this.layer.div.appendChild(this.getTile()); this.events.triggerEvent(this._loadEvent); var img = this.getImage(); - if (this.url && img.getAttribute("src") == this.url) { + if (this.url && OpenLayers.Util.isEquivalentUrl(img.src, this.url)) { this._loadTimeout = window.setTimeout( OpenLayers.Function.bind(this.onImageLoad, this), 0 ); diff --git a/tests/TileManager.html b/tests/TileManager.html index 72a58b4922..1468c5b46b 100644 --- a/tests/TileManager.html +++ b/tests/TileManager.html @@ -64,17 +64,28 @@ gridSize = layer.div.childNodes.length; map.setCenter([17, 47]); }); + + function inCache(img) { + var search = img.src.split('?')[1]; + for (var s in tileManager.tileCache) { + if (s.split('?')[1] == search) { + return true; + } + } + return false; + } + t.delay_call(4, function() { t.eq(tileManager.tileCacheIndex.length, 12, "tiles cached"); t.ok(tileManager.tileCache[layer.grid[1][2].url] === layer.grid[1][2].imgDiv, "correct object cached"); - t.ok(!(firstInCache.getAttribute("src") in tileManager.tileCache), "old tile discarded"); - t.ok(sharedTile.getAttribute("src") in tileManager.tileCache, "shared tile still in cache"); + t.ok(!inCache(firstInCache), "old tile discarded"); + t.ok(inCache(sharedTile), "shared tile still in cache"); firstInCache = tileManager.tileCache[tileManager.tileCacheIndex[0]]; map.setCenter([16, 48]); }); t.delay_call(6, function() { - t.ok(!(firstInCache.getAttribute("src") in tileManager.tileCache), "old tile discarded"); - t.ok(sharedTile.getAttribute("src") in tileManager.tileCache, "shared tile still in cache"); + t.ok(!inCache(firstInCache), "old tile discarded"); + t.ok(inCache(sharedTile), "shared tile still in cache"); t.eq(layer.div.childNodes.length, gridSize, 'no unused images left in dom'); map.destroy(); });