Files
node/test/addons-napi/test_handle_scope/test.js
T
Michael Dawson 3e18c49657 n-api: avoid crash in napi_escape_scope()
V8 will crash if escape is called twice on the same
scope.

Add checks to avoid crashing if napi_escape_scope() is
called to try and do this.

Add test that tries to call napi_create_scope() twice.

PR-URL: https://github.com/nodejs/node/pull/13651
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-06-21 16:57:39 -04:00

24 lines
510 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
// testing handle scope api calls
const testHandleScope =
require(`./build/${common.buildType}/test_handle_scope`);
testHandleScope.NewScope();
assert.ok(testHandleScope.NewScopeEscape() instanceof Object);
assert.throws(
() => {
testHandleScope.NewScopeEscapeTwice();
},
Error);
assert.throws(
() => {
testHandleScope.NewScopeWithException(() => { throw new RangeError(); });
},
RangeError);