• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Test that `napi_call_function()` returns `napi_cannot_run_js` in experimental
4// mode and `napi_pending_exception` otherwise. This test calls the add-on's
5// `createRef()` method, which creates a strong reference to a JS function. When
6// the process exits, it calls all reference finalizers. The finalizer for the
7// strong reference created herein will attempt to call `napi_get_property()` on
8// a property of the global object and will abort the process if the API doesn't
9// return the correct status.
10
11const { buildType, mustNotCall } = require('../../common');
12const addon_v8 = require(`./build/${buildType}/test_pending_exception`);
13const addon_new = require(`./build/${buildType}/test_cannot_run_js`);
14
15function runTests(addon, isVersion8) {
16  addon.createRef(mustNotCall());
17}
18
19function runAllTests() {
20  runTests(addon_v8, /* isVersion8 */ true);
21  runTests(addon_new, /* isVersion8 */ false);
22}
23
24runAllTests();
25