mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
The changes can be seen here between 8.0.1 and 8.2.1: https://github.com/mochajs/mocha/releases There are no breaking changes. The upgrade will give us the ability to use global fixtures which may speed up parallel mode. I'm also hoping this fixes a bug with describe.skip() not working properly for parallel mode. DISABLE_THIRD_PARTY_CHECK=Update Mocha Bug: chromium:1101784 Change-Id: Ia052a80c0f6dcefb1a2f21444cdfd3789a3203f8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2529149 Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
'use strict'
|
|
|
|
// limit of Crypto.getRandomValues()
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
var MAX_BYTES = 65536
|
|
|
|
// Node supports requesting up to this number of bytes
|
|
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
|
|
var MAX_UINT32 = 4294967295
|
|
|
|
function oldBrowser () {
|
|
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
|
|
}
|
|
|
|
var Buffer = require('safe-buffer').Buffer
|
|
var crypto = global.crypto || global.msCrypto
|
|
|
|
if (crypto && crypto.getRandomValues) {
|
|
module.exports = randomBytes
|
|
} else {
|
|
module.exports = oldBrowser
|
|
}
|
|
|
|
function randomBytes (size, cb) {
|
|
// phantomjs needs to throw
|
|
if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
|
|
|
|
var bytes = Buffer.allocUnsafe(size)
|
|
|
|
if (size > 0) { // getRandomValues fails on IE if size == 0
|
|
if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
|
|
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
|
for (var generated = 0; generated < size; generated += MAX_BYTES) {
|
|
// buffer.slice automatically checks if the end is past the end of
|
|
// the buffer so we don't have to here
|
|
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
|
|
}
|
|
} else {
|
|
crypto.getRandomValues(bytes)
|
|
}
|
|
}
|
|
|
|
if (typeof cb === 'function') {
|
|
return process.nextTick(function () {
|
|
cb(null, bytes)
|
|
})
|
|
}
|
|
|
|
return bytes
|
|
}
|