1'use strict'; 2 3const common = require('../../common'); 4const assert = require('assert'); 5const { 6 makeBufferInNewContext, 7} = require(`./build/${common.buildType}/binding`); 8 9// Because the `Buffer` function and its protoype property only (currently) 10// exist in a Node.js instance’s main context, trying to create buffers from 11// another context throws an exception. 12assert.throws( 13 () => makeBufferInNewContext(), 14 (exception) => { 15 assert.strictEqual(exception.constructor.name, 'Error'); 16 assert(!(exception.constructor instanceof Error)); 17 18 assert.strictEqual(exception.code, 'ERR_BUFFER_CONTEXT_NOT_AVAILABLE'); 19 assert.strictEqual(exception.message, 20 'Buffer is not available for the current Context'); 21 return true; 22 }, 23); 24