mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Merge pull request #2142 from Aiosa/master
Delegate error printing to the ajax caller.
This commit is contained in:
commit
334e8fbc67
@ -122,6 +122,18 @@ $.EventSource.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of handlers registered for a given event.
|
||||||
|
* @param {String} eventName - Name of event to inspect.
|
||||||
|
* @return {number} amount of events
|
||||||
|
*/
|
||||||
|
numberOfHandlers: function (eventName) {
|
||||||
|
var events = this.events[ eventName ];
|
||||||
|
if ( !events ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return events.length;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all event handlers for a given event type. If no type is given all
|
* Remove all event handlers for a given event type. If no type is given all
|
||||||
|
@ -130,7 +130,7 @@ ImageJob.prototype = {
|
|||||||
self.image.src = url;
|
self.image.src = url;
|
||||||
},
|
},
|
||||||
error: function(request) {
|
error: function(request) {
|
||||||
self.errorMsg = "Image load aborted - XHR error";
|
self.errorMsg = "Image load aborted - XHR error: Ajax returned " + request.status;
|
||||||
self.finish(false);
|
self.finish(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2364,10 +2364,10 @@ function OpenSeadragon( options ){
|
|||||||
protocol !== "https:" )) {
|
protocol !== "https:" )) {
|
||||||
onSuccess( request );
|
onSuccess( request );
|
||||||
} else {
|
} else {
|
||||||
$.console.error( "AJAX request returned %d: %s", request.status, url );
|
|
||||||
|
|
||||||
if ( $.isFunction( onError ) ) {
|
if ( $.isFunction( onError ) ) {
|
||||||
onError( request );
|
onError( request );
|
||||||
|
} else {
|
||||||
|
$.console.error( "AJAX request returned %d: %s", request.status, url );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ $.TileSource.prototype = {
|
|||||||
exception rather than the second one raised when we try to access xhr.status
|
exception rather than the second one raised when we try to access xhr.status
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
msg = "HTTP " + xhr.status + " attempting to load TileSource";
|
msg = "HTTP " + xhr.status + " attempting to load TileSource: " + url;
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
var formattedExc;
|
var formattedExc;
|
||||||
if ( typeof ( exc ) === "undefined" || !exc.toString ) {
|
if ( typeof ( exc ) === "undefined" || !exc.toString ) {
|
||||||
@ -538,9 +538,11 @@ $.TileSource.prototype = {
|
|||||||
formattedExc = exc.toString();
|
formattedExc = exc.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = formattedExc + " attempting to load TileSource";
|
msg = formattedExc + " attempting to load TileSource: " + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.console.error(msg);
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Raised when an error occurs loading a TileSource.
|
* Raised when an error occurs loading a TileSource.
|
||||||
*
|
*
|
||||||
|
@ -58,8 +58,8 @@
|
|||||||
|
|
||||||
assert.equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
assert.equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
||||||
|
|
||||||
assert.ok(testLog.error.contains('["AJAX request returned %d: %s",404,"/test/data/not-a-real-file"]'),
|
assert.ok(testLog.error.contains('["HTTP 404 attempting to load TileSource: /test/data/not-a-real-file"]'),
|
||||||
"AJAX failures should be logged to the console");
|
"'open-failed' fired after AJAX error handler prints error to the console.'");
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -1152,6 +1152,36 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
QUnit.test( 'Viewer: event count test with \'tile-drawing\'', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
|
assert.ok(viewer.numberOfHandlers('tile-drawing') === 0,
|
||||||
|
"'tile-drawing' event is empty by default.");
|
||||||
|
|
||||||
|
var tileDrawing = function ( event ) {
|
||||||
|
viewer.removeHandler( 'tile-drawing', tileDrawing );
|
||||||
|
assert.ok(viewer.numberOfHandlers('tile-drawing') === 0,
|
||||||
|
"'tile-drawing' deleted: count is 0.");
|
||||||
|
viewer.close();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
var tileDrawingDummy = function ( event ) {};
|
||||||
|
|
||||||
|
viewer.addHandler( 'tile-drawing', tileDrawing );
|
||||||
|
assert.ok(viewer.numberOfHandlers('tile-drawing') === 1,
|
||||||
|
"'tile-drawing' event set to 1.");
|
||||||
|
|
||||||
|
viewer.addHandler( 'tile-drawing', tileDrawingDummy );
|
||||||
|
assert.ok(viewer.numberOfHandlers('tile-drawing') === 2,
|
||||||
|
"'tile-drawing' event set to 2.");
|
||||||
|
|
||||||
|
viewer.removeHandler( 'tile-drawing', tileDrawingDummy );
|
||||||
|
assert.ok(viewer.numberOfHandlers('tile-drawing') === 1,
|
||||||
|
"'tile-drawing' deleted once: count is 1.");
|
||||||
|
|
||||||
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
|
} );
|
||||||
|
|
||||||
QUnit.test( 'Viewer: tile-drawing event', function (assert) {
|
QUnit.test( 'Viewer: tile-drawing event', function (assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var tileDrawing = function ( event ) {
|
var tileDrawing = function ( event ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user