Fix phantom.js web worker tests that use promises

This commit is contained in:
Tankred Hase 2014-10-01 21:55:50 +02:00
parent d5a0e18d13
commit bdbd7819f4
2 changed files with 33 additions and 0 deletions

View File

@ -118,6 +118,13 @@ module.exports = function(grunt) {
cwd: 'node_modules/',
src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'es6-promise/dist/promise*.js'],
dest: 'test/lib/'
},
polyfill: {
expand: true,
flatten: true,
cwd: 'node_modules/',
src: ['es6-promise/dist/promise*.js'],
dest: 'dist/'
}
},
clean: ['dist/'],

View File

@ -17,6 +17,32 @@
window = {}; // to make UMD bundles work
// Mozilla bind polyfill because phantomjs is stupid
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
FNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
};
FNOP.prototype = this.prototype;
fBound.prototype = new FNOP();
return fBound;
};
}
if (typeof Promise === 'undefined') {
// promises polyfill
importScripts('promise-1.0.0.js');
}
importScripts('openpgp.js');
var MIN_SIZE_RANDOM_BUFFER = 40000;