mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Fix tests and coverage
This commit is contained in:
parent
a372274ee1
commit
ed72ae748f
@ -39,7 +39,7 @@
|
||||
<script src="/src/referencestrip.js"></script>
|
||||
<script src="/src/displayrectangle.js"></script>
|
||||
<script src="/src/spring.js"></script>
|
||||
<script src="/src/imageLoader.js"></script>
|
||||
<script src="/src/imageloader.js"></script>
|
||||
<script src="/src/tile.js"></script>
|
||||
<script src="/src/overlay.js"></script>
|
||||
<script src="/src/drawer.js"></script>
|
||||
|
@ -301,6 +301,24 @@
|
||||
viewer.open('/test/data/testpattern.dzi');
|
||||
});
|
||||
|
||||
|
||||
// The Wikipedia logo has CORS enabled
|
||||
var corsImg = 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png';
|
||||
|
||||
// PhantomJS always taint the canvas, so we only run some tests on browsers
|
||||
// supporting CORS images.
|
||||
function browserSupportsImgCrossOrigin(callback) {
|
||||
var img = new Image();
|
||||
img.crossOrigin = 'anonymous';
|
||||
img.onload = function() {
|
||||
var canvas = document.createElement("canvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(img, 0, 0);
|
||||
callback(!isCanvasTainted(ctx));
|
||||
};
|
||||
img.src = corsImg;
|
||||
}
|
||||
|
||||
function isCanvasTainted(context) {
|
||||
var isTainted = false;
|
||||
try {
|
||||
@ -319,8 +337,7 @@
|
||||
viewer.open( {
|
||||
type: 'legacy-image-pyramid',
|
||||
levels: [ {
|
||||
// The Wikipedia logo has CORS enabled
|
||||
url: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
|
||||
url: corsImg,
|
||||
width: 135,
|
||||
height: 155
|
||||
} ]
|
||||
@ -334,12 +351,16 @@
|
||||
|
||||
asyncTest( 'CrossOriginPolicyAnonymous', function () {
|
||||
|
||||
browserSupportsImgCrossOrigin(function(supported) {
|
||||
if (!supported) {
|
||||
expect(0);
|
||||
start();
|
||||
} else {
|
||||
viewer.crossOriginPolicy = 'Anonymous';
|
||||
viewer.open( {
|
||||
type: 'legacy-image-pyramid',
|
||||
levels: [ {
|
||||
// The Wikipedia logo has CORS enabled
|
||||
url: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
|
||||
url: corsImg,
|
||||
width: 135,
|
||||
height: 155
|
||||
} ]
|
||||
@ -348,6 +369,8 @@
|
||||
ok(!isCanvasTainted(viewer.drawer.context), "Canvas should not be tainted.");
|
||||
start();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user