mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-27 23:56:09 +03:00
Upgraded grunt-contrib-qunit to ^3.1.0 which utilizes pupetter instead of phantomjs
This commit is contained in:
parent
c7aa6eda84
commit
998439f29c
@ -57,7 +57,7 @@ You can also publish the built version to the site-build repository. This assume
|
|||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
Our tests are based on [QUnit](http://qunitjs.com/) and [PhantomJS](http://phantomjs.org/); they're both installed when you run `npm install`. To run on the command line:
|
Our tests are based on [QUnit](http://qunitjs.com/) and [Puppeteer](https://github.com/GoogleChrome/puppeteer); they're both installed when you run `npm install`. To run on the command line:
|
||||||
|
|
||||||
grunt test
|
grunt test
|
||||||
|
|
||||||
|
@ -171,7 +171,6 @@ module.exports = function(grunt) {
|
|||||||
baseUrl: '.',
|
baseUrl: '.',
|
||||||
disposeCollector: true
|
disposeCollector: true
|
||||||
},
|
},
|
||||||
inject: 'test/helpers/phantom-bridge.js',
|
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
4138
package-lock.json
generated
4138
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,7 @@
|
|||||||
"grunt-contrib-compress": "^1.4.3",
|
"grunt-contrib-compress": "^1.4.3",
|
||||||
"grunt-contrib-concat": "^1.0.1",
|
"grunt-contrib-concat": "^1.0.1",
|
||||||
"grunt-contrib-connect": "^1.0.2",
|
"grunt-contrib-connect": "^1.0.2",
|
||||||
"grunt-contrib-qunit": "^2.0.0",
|
"grunt-contrib-qunit": "^3.1.0",
|
||||||
"grunt-contrib-uglify": "^3.4.0",
|
"grunt-contrib-uglify": "^3.4.0",
|
||||||
"grunt-contrib-watch": "^1.1.0",
|
"grunt-contrib-watch": "^1.1.0",
|
||||||
"grunt-eslint": "^20.2.0",
|
"grunt-eslint": "^20.2.0",
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* grunt-contrib-qunit
|
|
||||||
* http://gruntjs.com/
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 "Cowboy" Ben Alman, contributors
|
|
||||||
* Licensed under the MIT license.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*global QUnit:true, alert:true*/
|
|
||||||
(function (factory) {
|
|
||||||
if (typeof define === 'function' && define.amd) {
|
|
||||||
require(['qunit'], factory);
|
|
||||||
} else {
|
|
||||||
factory(QUnit);
|
|
||||||
}
|
|
||||||
}(function(QUnit) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Don't re-order tests.
|
|
||||||
QUnit.config.reorder = false;
|
|
||||||
|
|
||||||
// Send messages to the parent PhantomJS process via alert! Good times!!
|
|
||||||
function sendMessage() {
|
|
||||||
var args = [].slice.call(arguments);
|
|
||||||
alert(JSON.stringify(args));
|
|
||||||
}
|
|
||||||
|
|
||||||
// These methods connect QUnit to PhantomJS.
|
|
||||||
QUnit.log(function(obj) {
|
|
||||||
// What is this I don’t even
|
|
||||||
if (obj.message === '[object Object], undefined:undefined') { return; }
|
|
||||||
|
|
||||||
// Parse some stuff before sending it.
|
|
||||||
var actual, expected;
|
|
||||||
if (!obj.result) {
|
|
||||||
// Dumping large objects can be very slow, and the dump isn't used for
|
|
||||||
// passing tests, so only dump if the test failed.
|
|
||||||
actual = QUnit.dump.parse(obj.actual);
|
|
||||||
expected = QUnit.dump.parse(obj.expected);
|
|
||||||
}
|
|
||||||
// Send it.
|
|
||||||
sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source, obj.todo);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.testStart(function(obj) {
|
|
||||||
sendMessage('qunit.testStart', obj.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.testDone(function(obj) {
|
|
||||||
sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total, obj.runtime, obj.skipped, obj.todo);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.moduleStart(function(obj) {
|
|
||||||
sendMessage('qunit.moduleStart', obj.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.moduleDone(function(obj) {
|
|
||||||
sendMessage('qunit.moduleDone', obj.name, obj.failed, obj.passed, obj.total);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.begin(function() {
|
|
||||||
sendMessage('qunit.begin');
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.done(function(obj) {
|
|
||||||
// send coverage data if available
|
|
||||||
if ( window.__coverage__ ) {
|
|
||||||
sendMessage( "qunit.coverage", window.__coverage__ );
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage('qunit.done', obj.failed, obj.passed, obj.total, obj.runtime);
|
|
||||||
});
|
|
||||||
}));
|
|
@ -307,20 +307,6 @@
|
|||||||
// The Wikipedia logo has CORS enabled
|
// The Wikipedia logo has CORS enabled
|
||||||
var corsImg = 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png';
|
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(!OpenSeadragon.isCanvasTainted(canvas));
|
|
||||||
};
|
|
||||||
img.src = corsImg;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUnit.test( 'CrossOriginPolicyMissing', function (assert) {
|
QUnit.test( 'CrossOriginPolicyMissing', function (assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
viewer.crossOriginPolicy = false;
|
viewer.crossOriginPolicy = false;
|
||||||
@ -343,86 +329,68 @@
|
|||||||
|
|
||||||
QUnit.test( 'CrossOriginPolicyAnonymous', function (assert) {
|
QUnit.test( 'CrossOriginPolicyAnonymous', function (assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
browserSupportsImgCrossOrigin(function(supported) {
|
|
||||||
if (!supported) {
|
viewer.crossOriginPolicy = 'Anonymous';
|
||||||
assert.expect(0);
|
viewer.open( {
|
||||||
done();
|
type: 'legacy-image-pyramid',
|
||||||
} else {
|
levels: [ {
|
||||||
viewer.crossOriginPolicy = 'Anonymous';
|
url: corsImg,
|
||||||
viewer.open( {
|
width: 135,
|
||||||
type: 'legacy-image-pyramid',
|
height: 155
|
||||||
levels: [ {
|
} ]
|
||||||
url: corsImg,
|
} );
|
||||||
width: 135,
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
height: 155
|
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
} ]
|
"Canvas should not be tainted.");
|
||||||
} );
|
done();
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
|
||||||
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
|
||||||
"Canvas should not be tainted.");
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'CrossOriginPolicyOption', function (assert) {
|
QUnit.test( 'CrossOriginPolicyOption', function (assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
browserSupportsImgCrossOrigin(function(supported) {
|
|
||||||
if (!supported) {
|
viewer.crossOriginPolicy = "Anonymous";
|
||||||
assert.expect(0);
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
done();
|
viewer.addTiledImage( {
|
||||||
} else {
|
tileSource: {
|
||||||
viewer.crossOriginPolicy = "Anonymous";
|
type: 'legacy-image-pyramid',
|
||||||
viewer.smoothTileEdgesMinZoom = Infinity;
|
levels: [ {
|
||||||
viewer.addTiledImage( {
|
url: corsImg,
|
||||||
tileSource: {
|
width: 135,
|
||||||
type: 'legacy-image-pyramid',
|
height: 155
|
||||||
levels: [ {
|
} ]
|
||||||
url: corsImg,
|
},
|
||||||
width: 135,
|
crossOriginPolicy : false
|
||||||
height: 155
|
} );
|
||||||
} ]
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
},
|
assert.ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
crossOriginPolicy : false
|
"Canvas should be tainted.");
|
||||||
} );
|
done();
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
|
||||||
assert.ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
|
||||||
"Canvas should be tainted.");
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'CrossOriginPolicyTileSource', function (assert) {
|
QUnit.test( 'CrossOriginPolicyTileSource', function (assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
browserSupportsImgCrossOrigin(function(supported) {
|
|
||||||
if (!supported) {
|
viewer.crossOriginPolicy = false;
|
||||||
assert.expect(0);
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
done();
|
viewer.addTiledImage( {
|
||||||
} else {
|
tileSource: {
|
||||||
viewer.crossOriginPolicy = false;
|
type: 'legacy-image-pyramid',
|
||||||
viewer.smoothTileEdgesMinZoom = Infinity;
|
levels: [ {
|
||||||
viewer.addTiledImage( {
|
url: corsImg,
|
||||||
tileSource: {
|
width: 135,
|
||||||
type: 'legacy-image-pyramid',
|
height: 155
|
||||||
levels: [ {
|
} ],
|
||||||
url: corsImg,
|
crossOriginPolicy : "Anonymous"
|
||||||
width: 135,
|
|
||||||
height: 155
|
|
||||||
} ],
|
|
||||||
crossOriginPolicy : "Anonymous"
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
|
||||||
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
|
||||||
"Canvas should not be tainted.");
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
} );
|
||||||
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
|
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
|
"Canvas should not be tainted.");
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
@ -530,13 +530,6 @@
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// PhantomJS is missing Function.prototype.bind
|
|
||||||
function bind(func, _this) {
|
|
||||||
return function() {
|
|
||||||
return func.apply(_this, arguments);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
QUnit.test('_getCornerTiles without wrapping', function(assert) {
|
QUnit.test('_getCornerTiles without wrapping', function(assert) {
|
||||||
var tiledImageMock = {
|
var tiledImageMock = {
|
||||||
wrapHorizontal: false,
|
wrapHorizontal: false,
|
||||||
@ -549,9 +542,7 @@
|
|||||||
tileOverlap: 1,
|
tileOverlap: 1,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
var _getCornerTiles = bind(
|
var _getCornerTiles = OpenSeadragon.TiledImage.prototype._getCornerTiles.bind(tiledImageMock);
|
||||||
OpenSeadragon.TiledImage.prototype._getCornerTiles,
|
|
||||||
tiledImageMock);
|
|
||||||
|
|
||||||
function assertCornerTiles(topLeftBound, bottomRightBound,
|
function assertCornerTiles(topLeftBound, bottomRightBound,
|
||||||
expectedTopLeft, expectedBottomRight) {
|
expectedTopLeft, expectedBottomRight) {
|
||||||
@ -599,9 +590,7 @@
|
|||||||
tileOverlap: 1,
|
tileOverlap: 1,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
var _getCornerTiles = bind(
|
var _getCornerTiles = OpenSeadragon.TiledImage.prototype._getCornerTiles.bind(tiledImageMock);
|
||||||
OpenSeadragon.TiledImage.prototype._getCornerTiles,
|
|
||||||
tiledImageMock);
|
|
||||||
|
|
||||||
function assertCornerTiles(topLeftBound, bottomRightBound,
|
function assertCornerTiles(topLeftBound, bottomRightBound,
|
||||||
expectedTopLeft, expectedBottomRight) {
|
expectedTopLeft, expectedBottomRight) {
|
||||||
@ -648,9 +637,7 @@
|
|||||||
tileOverlap: 1,
|
tileOverlap: 1,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
var _getCornerTiles = bind(
|
var _getCornerTiles = OpenSeadragon.TiledImage.prototype._getCornerTiles.bind(tiledImageMock);
|
||||||
OpenSeadragon.TiledImage.prototype._getCornerTiles,
|
|
||||||
tiledImageMock);
|
|
||||||
|
|
||||||
function assertCornerTiles(topLeftBound, bottomRightBound,
|
function assertCornerTiles(topLeftBound, bottomRightBound,
|
||||||
expectedTopLeft, expectedBottomRight) {
|
expectedTopLeft, expectedBottomRight) {
|
||||||
|
Loading…
Reference in New Issue
Block a user