Upgraded grunt-contrib-qunit to ^3.1.0 which utilizes pupetter instead of phantomjs

This commit is contained in:
David McAlpine 2019-07-17 20:02:40 -04:00
parent c7aa6eda84
commit 998439f29c
7 changed files with 2588 additions and 1777 deletions

View File

@ -57,7 +57,7 @@ You can also publish the built version to the site-build repository. This assume
### 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

View File

@ -171,7 +171,6 @@ module.exports = function(grunt) {
baseUrl: '.',
disposeCollector: true
},
inject: 'test/helpers/phantom-bridge.js',
timeout: 10000
}
},

4116
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@
"grunt-contrib-compress": "^1.4.3",
"grunt-contrib-concat": "^1.0.1",
"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-watch": "^1.1.0",
"grunt-eslint": "^20.2.0",

View File

@ -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 dont 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);
});
}));

View File

@ -307,20 +307,6 @@
// 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(!OpenSeadragon.isCanvasTainted(canvas));
};
img.src = corsImg;
}
QUnit.test( 'CrossOriginPolicyMissing', function (assert) {
var done = assert.async();
viewer.crossOriginPolicy = false;
@ -343,11 +329,7 @@
QUnit.test( 'CrossOriginPolicyAnonymous', function (assert) {
var done = assert.async();
browserSupportsImgCrossOrigin(function(supported) {
if (!supported) {
assert.expect(0);
done();
} else {
viewer.crossOriginPolicy = 'Anonymous';
viewer.open( {
type: 'legacy-image-pyramid',
@ -362,18 +344,12 @@
"Canvas should not be tainted.");
done();
});
}
});
} );
QUnit.test( 'CrossOriginPolicyOption', function (assert) {
var done = assert.async();
browserSupportsImgCrossOrigin(function(supported) {
if (!supported) {
assert.expect(0);
done();
} else {
viewer.crossOriginPolicy = "Anonymous";
viewer.smoothTileEdgesMinZoom = Infinity;
viewer.addTiledImage( {
@ -392,18 +368,12 @@
"Canvas should be tainted.");
done();
});
}
});
} );
QUnit.test( 'CrossOriginPolicyTileSource', function (assert) {
var done = assert.async();
browserSupportsImgCrossOrigin(function(supported) {
if (!supported) {
assert.expect(0);
done();
} else {
viewer.crossOriginPolicy = false;
viewer.smoothTileEdgesMinZoom = Infinity;
viewer.addTiledImage( {
@ -422,8 +392,6 @@
"Canvas should not be tainted.");
done();
});
}
});
} );

View File

@ -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) {
var tiledImageMock = {
wrapHorizontal: false,
@ -549,9 +542,7 @@
tileOverlap: 1,
}),
};
var _getCornerTiles = bind(
OpenSeadragon.TiledImage.prototype._getCornerTiles,
tiledImageMock);
var _getCornerTiles = OpenSeadragon.TiledImage.prototype._getCornerTiles.bind(tiledImageMock);
function assertCornerTiles(topLeftBound, bottomRightBound,
expectedTopLeft, expectedBottomRight) {
@ -599,9 +590,7 @@
tileOverlap: 1,
}),
};
var _getCornerTiles = bind(
OpenSeadragon.TiledImage.prototype._getCornerTiles,
tiledImageMock);
var _getCornerTiles = OpenSeadragon.TiledImage.prototype._getCornerTiles.bind(tiledImageMock);
function assertCornerTiles(topLeftBound, bottomRightBound,
expectedTopLeft, expectedBottomRight) {
@ -648,9 +637,7 @@
tileOverlap: 1,
}),
};
var _getCornerTiles = bind(
OpenSeadragon.TiledImage.prototype._getCornerTiles,
tiledImageMock);
var _getCornerTiles = OpenSeadragon.TiledImage.prototype._getCornerTiles.bind(tiledImageMock);
function assertCornerTiles(topLeftBound, bottomRightBound,
expectedTopLeft, expectedBottomRight) {