Add workaround for missing ArrayBuffer.isView in PhantomJS

(closes #7072)
This commit is contained in:
Bryan Housel
2019-11-27 10:53:24 -05:00
parent 8d02a1aad8
commit b9f41bb48c
3 changed files with 10 additions and 2 deletions
+2 -2
View File
@@ -28,9 +28,9 @@
"imagery": "node data/update_imagery",
"lint": "eslint *.js test/spec modules",
"start": "node --max-old-space-size=4096 server.js",
"phantom": "phantomjs --web-security=no node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/phantom.html spec",
"test": "npm-run-all -s lint build test:**",
"test:phantom": "phantomjs --web-security=no node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html spec",
"test:phantom": "phantomjs --web-security=no node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/phantom.html spec",
"test:iD": "phantomjs --web-security=no node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html spec",
"translations": "node data/update_locales"
},
"dependencies": {
+3
View File
@@ -4,4 +4,7 @@ describe('test some capabilities of PhantomJS', function () {
var result = Array.from(s);
expect(result).to.eql([1]);
});
it('has ArrayBuffer.isView', function () {
expect(typeof ArrayBuffer.isView).to.eql('function');
});
});
+5
View File
@@ -52,6 +52,11 @@ Array.from = function(what) {
}
};
// Workaround for `ArrayBuffer.isView` in PhantomJS
// https://github.com/openstreetmap/iD/issues/7072
if (typeof ArrayBuffer.isView === 'undefined') {
ArrayBuffer.isView = function() { return false; };
}
// Add support for sinon-stubbing `fetch` API
// (sinon fakeServer works only on `XMLHttpRequest`)