mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-03-03 22:23:13 +03:00
Passed options.crossOriginPolicy into getTileSource. Also changed checks on crossOriginPolicy to compare to undefined, and added tests for the addTiledImage crossOriginPolicy api.
This commit is contained in:
parent
1e0ddcedc1
commit
4ccabe78de
@ -1267,7 +1267,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
options.compositeOperation = this.compositeOperation;
|
options.compositeOperation = this.compositeOperation;
|
||||||
}
|
}
|
||||||
if (options.crossOriginPolicy === undefined) {
|
if (options.crossOriginPolicy === undefined) {
|
||||||
options.crossOriginPolicy = options.tileSource.crossOriginPolicy ? options.tileSource.crossOriginPolicy : this.crossOriginPolicy;
|
options.crossOriginPolicy = options.tileSource.crossOriginPolicy !== undefined ? options.tileSource.crossOriginPolicy : this.crossOriginPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
var myQueueItem = {
|
var myQueueItem = {
|
||||||
@ -1331,7 +1331,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
|
|
||||||
this._loadQueue.push(myQueueItem);
|
this._loadQueue.push(myQueueItem);
|
||||||
|
|
||||||
getTileSourceImplementation( this, options.tileSource, function( tileSource ) {
|
getTileSourceImplementation( this, options.tileSource, options, function( tileSource ) {
|
||||||
|
|
||||||
myQueueItem.tileSource = tileSource;
|
myQueueItem.tileSource = tileSource;
|
||||||
|
|
||||||
@ -2115,7 +2115,7 @@ function _getSafeElemSize (oElement) {
|
|||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function getTileSourceImplementation( viewer, tileSource, successCallback,
|
function getTileSourceImplementation( viewer, tileSource, imgOptions, successCallback,
|
||||||
failCallback ) {
|
failCallback ) {
|
||||||
var _this = viewer;
|
var _this = viewer;
|
||||||
|
|
||||||
@ -2149,7 +2149,8 @@ function getTileSourceImplementation( viewer, tileSource, successCallback,
|
|||||||
//If its still a string it means it must be a url at this point
|
//If its still a string it means it must be a url at this point
|
||||||
tileSource = new $.TileSource({
|
tileSource = new $.TileSource({
|
||||||
url: tileSource,
|
url: tileSource,
|
||||||
crossOriginPolicy: viewer.crossOriginPolicy,
|
crossOriginPolicy: imgOptions.crossOriginPolicy !== undefined ?
|
||||||
|
imgOptions.crossOriginPolicy : viewer.crossOriginPolicy,
|
||||||
ajaxWithCredentials: viewer.ajaxWithCredentials,
|
ajaxWithCredentials: viewer.ajaxWithCredentials,
|
||||||
useCanvas: viewer.useCanvas,
|
useCanvas: viewer.useCanvas,
|
||||||
success: function( event ) {
|
success: function( event ) {
|
||||||
@ -2161,8 +2162,10 @@ function getTileSourceImplementation( viewer, tileSource, successCallback,
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
} else if ($.isPlainObject(tileSource) || tileSource.nodeType) {
|
} else if ($.isPlainObject(tileSource) || tileSource.nodeType) {
|
||||||
if (!tileSource.crossOriginPolicy && viewer.crossOriginPolicy) {
|
if (tileSource.crossOriginPolicy === undefined &&
|
||||||
tileSource.crossOriginPolicy = viewer.crossOriginPolicy;
|
(imgOptions.crossOriginPolicy !== undefined || viewer.crossOriginPolicy !== undefined)) {
|
||||||
|
tileSource.crossOriginPolicy = imgOptions.crossOriginPolicy !== undefined ?
|
||||||
|
imgOptions.crossOriginPolicy : viewer.crossOriginPolicy;
|
||||||
}
|
}
|
||||||
if (tileSource.ajaxWithCredentials === undefined) {
|
if (tileSource.ajaxWithCredentials === undefined) {
|
||||||
tileSource.ajaxWithCredentials = viewer.ajaxWithCredentials;
|
tileSource.ajaxWithCredentials = viewer.ajaxWithCredentials;
|
||||||
|
@ -365,4 +365,62 @@
|
|||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
asyncTest( 'CrossOriginPolicyOption', function () {
|
||||||
|
|
||||||
|
browserSupportsImgCrossOrigin(function(supported) {
|
||||||
|
if (!supported) {
|
||||||
|
expect(0);
|
||||||
|
start();
|
||||||
|
} else {
|
||||||
|
viewer.crossOriginPolicy = "Anonymous";
|
||||||
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
|
viewer.addTiledImage( {
|
||||||
|
tileSource: {
|
||||||
|
type: 'legacy-image-pyramid',
|
||||||
|
levels: [ {
|
||||||
|
url: corsImg,
|
||||||
|
width: 135,
|
||||||
|
height: 155
|
||||||
|
} ]
|
||||||
|
},
|
||||||
|
crossOriginPolicy : false
|
||||||
|
} );
|
||||||
|
viewer.addHandler('tile-drawn', function() {
|
||||||
|
ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
|
"Canvas should be tainted.");
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} );
|
||||||
|
asyncTest( 'CrossOriginPolicyTileSource', function () {
|
||||||
|
|
||||||
|
browserSupportsImgCrossOrigin(function(supported) {
|
||||||
|
if (!supported) {
|
||||||
|
expect(0);
|
||||||
|
start();
|
||||||
|
} else {
|
||||||
|
viewer.crossOriginPolicy = false;
|
||||||
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
|
viewer.addTiledImage( {
|
||||||
|
tileSource: {
|
||||||
|
type: 'legacy-image-pyramid',
|
||||||
|
levels: [ {
|
||||||
|
url: corsImg,
|
||||||
|
width: 135,
|
||||||
|
height: 155
|
||||||
|
} ],
|
||||||
|
crossOriginPolicy : "Anonymous"
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
viewer.addHandler('tile-drawn', function() {
|
||||||
|
ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
|
"Canvas should not be tainted.");
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} );
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user