Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions web/client/components/map/openlayers/__tests__/Layer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,40 @@ describe('Openlayers layer', () => {
}, 200);
});
});
it('render wms singleTile layer with error does not request a spurious "null" url', (done) => {
mockAxios.onGet().reply(r => {
expect(r.url.indexOf('SAMPLE_URL') >= 0 ).toBeTruthy();
return [200, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<ows:ExceptionReport xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
" <ows:Exception exceptionCode=\"InvalidParameterValue\" locator=\"srsname\">\n" +
" <ows:ExceptionText>msWFSGetFeature(): WFS server error. Invalid GetFeature Request</ows:ExceptionText>\n" +
" </ows:Exception>\n" +
"</ows:ExceptionReport>"];
});
const options = {
type: 'wms',
visibility: true,
singleTile: true,
url: 'SAMPLE_URL',
name: 'osm:vector_tile'
};
const layer = ReactDOM.render(<OpenlayersLayer
type="wms"
options={{
...options
}}
map={map} />, document.getElementById("container"));
expect(layer.layer.getSource()).toBeTruthy();
layer.layer.getSource().on('imageloaderror', (e) => {
setTimeout(() => {
// the error handler must not set img.src = null, which the DOM coerces
// to the literal string "null" and resolves into a spurious request
const img = e.image.getImage();
expect(img.getAttribute('src') === 'null' || (img.src || '').endsWith('/null')).toBe(false);
done();
}, 200);
});
});
it('creates a tiled wms layer for openlayers map with long url', (done) => {
let options = {
"type": "wms",
Expand Down
3 changes: 1 addition & 2 deletions web/client/components/map/openlayers/plugins/WMSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ const loadFunction = (options, headers) => function(image, src) {
throw new Error(response.dataText);
}
}).catch(errorMessage => {
image.getImage().src = null; // needed to trigger the MS imageloaderror event in Map.onLayerError
image.setState(3); // set error state for tile and removed from the queue to prevent reloading loops
image.setState(3); // set error state for tile; this alone fires the source's tileloaderror/imageloaderror (state-based, no DOM event needed) and removes it from the queue to prevent reloading loops
failTiles.add(src); // indexing fail url tile to prevent reloading loops
console.error(errorMessage); // show ogc exception in console for debugging
});
Expand Down
Loading