Move test VM crypto definition (#1584)
This commit is contained in:
parent
8179846e38
commit
28fa3fa795
@ -150,6 +150,13 @@ class VM {
|
|||||||
constructor(context={}) {
|
constructor(context={}) {
|
||||||
this._urlMap = new Map();
|
this._urlMap = new Map();
|
||||||
context.URL = createURLClass(this._urlMap);
|
context.URL = createURLClass(this._urlMap);
|
||||||
|
context.crypto = {
|
||||||
|
getRandomValues: (array) => {
|
||||||
|
const buffer = crypto.randomBytes(array.byteLength);
|
||||||
|
buffer.copy(array);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
};
|
||||||
this._context = vm.createContext(context);
|
this._context = vm.createContext(context);
|
||||||
this._assert = {
|
this._assert = {
|
||||||
deepStrictEqual
|
deepStrictEqual
|
||||||
|
@ -16,19 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const crypto = require('crypto');
|
|
||||||
const {testMain} = require('../dev/util');
|
const {testMain} = require('../dev/util');
|
||||||
const {VM} = require('../dev/vm');
|
const {VM} = require('../dev/vm');
|
||||||
|
|
||||||
const vm = new VM({
|
const vm = new VM();
|
||||||
crypto: {
|
|
||||||
getRandomValues: (array) => {
|
|
||||||
const buffer = crypto.randomBytes(array.byteLength);
|
|
||||||
buffer.copy(array);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
vm.execute([
|
vm.execute([
|
||||||
'js/core.js'
|
'js/core.js'
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user