Don't zero-copy transfer buffers in Safari 11.1 and Chrome < 56
See https://bugs.webkit.org/show_bug.cgi?id=184254 and https://bugs.chromium.org/p/chromium/issues/detail?id=334408.
This commit is contained in:
parent
b904aef3a7
commit
77055f6dfe
|
@ -64,7 +64,10 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (util.isUint8Array(obj)) {
|
if (util.isUint8Array(obj)) {
|
||||||
if (zero_copy && collection.indexOf(obj.buffer) === -1) {
|
if (zero_copy && collection.indexOf(obj.buffer) === -1 && !(
|
||||||
|
navigator.userAgent.indexOf('Version/11.1') !== -1 || // Safari 11.1
|
||||||
|
((navigator.userAgent.match(/Chrome\/(\d+)/) || [])[1] < 56 && navigator.userAgent.indexOf('Edge') === -1) // Chrome < 56
|
||||||
|
)) {
|
||||||
collection.push(obj.buffer);
|
collection.push(obj.buffer);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1705,8 +1705,12 @@ describe('[Sauce Labs Group 2] OpenPGP.js public api tests', function() {
|
||||||
return openpgp.decrypt(decOpt);
|
return openpgp.decrypt(decOpt);
|
||||||
}).then(function (decrypted) {
|
}).then(function (decrypted) {
|
||||||
if (openpgp.getWorker()) {
|
if (openpgp.getWorker()) {
|
||||||
|
if (navigator.userAgent.indexOf('Safari') !== -1 && (navigator.userAgent.indexOf('Version/11.1') !== -1 || (navigator.userAgent.match(/Chrome\/(\d+)/) || [])[1] < 56)) {
|
||||||
|
expect(encOpt.message.packets[0].data.byteLength).to.equal(8); // browser doesn't support transfering buffers
|
||||||
|
} else {
|
||||||
expect(encOpt.message.packets[0].data.byteLength).to.equal(0); // transferred buffer should be empty
|
expect(encOpt.message.packets[0].data.byteLength).to.equal(0); // transferred buffer should be empty
|
||||||
}
|
}
|
||||||
|
}
|
||||||
expect(decrypted.data).to.deep.equal(new Uint8Array([0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01]));
|
expect(decrypted.data).to.deep.equal(new Uint8Array([0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01]));
|
||||||
expect(decrypted.signatures.length).to.equal(0);
|
expect(decrypted.signatures.length).to.equal(0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -137,9 +137,15 @@ describe('Util unit tests', function() {
|
||||||
it('should return undefined for an empty oject', function() {
|
it('should return undefined for an empty oject', function() {
|
||||||
expect(openpgp.util.getTransferables({}, true)).to.be.undefined;
|
expect(openpgp.util.getTransferables({}, true)).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
if (typeof navigator !== 'undefined') {
|
||||||
it('should return two buffers', function() {
|
it('should return two buffers', function() {
|
||||||
expect(openpgp.util.getTransferables(obj, true)).to.deep.equal([buf1.buffer, buf2.buffer]);
|
expect(openpgp.util.getTransferables(obj, true)).to.deep.equal(
|
||||||
|
navigator.userAgent.indexOf('Safari') !== -1 && (navigator.userAgent.indexOf('Version/11.1') !== -1 || (navigator.userAgent.match(/Chrome\/(\d+)/) || [])[1] < 56) ?
|
||||||
|
undefined :
|
||||||
|
[buf1.buffer, buf2.buffer]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Misc.", function() {
|
describe("Misc.", function() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user