summaryrefslogtreecommitdiff
path: root/test_napi/init_test.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-26 06:40:17 +0200
committerGitHub <noreply@github.com>2023-05-26 10:10:17 +0530
commit512d5337c480a2a2704881d3fe1c40b6e0445cf0 (patch)
tree99b03358883223a69f48b2d0e5b9387f3abae517 /test_napi/init_test.js
parent7ae55e75d812edc93251357465f8d49fc2fb5d26 (diff)
fix(napi): clear currently registering module slot (#19249)
This commit fixes problem with loading N-API modules that use the "old" way of registration (using "napi_module_register" API). The slot was not cleared after loading modules, causing subsequent calls that use the new way of registration (using "napi_register_module_v1" API) to try and load the previous module. Ref https://github.com/denoland/deno/issues/16460 --------- Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'test_napi/init_test.js')
-rw-r--r--test_napi/init_test.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test_napi/init_test.js b/test_napi/init_test.js
new file mode 100644
index 000000000..633fdbb61
--- /dev/null
+++ b/test_napi/init_test.js
@@ -0,0 +1,14 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+import { assert, libSuffix } from "./common.js";
+
+const ops = Deno[Deno.internal].core.ops;
+
+Deno.test("ctr initialization (napi_module_register)", {
+ ignore: Deno.build.os == "windows",
+}, function () {
+ const path = new URL(`./module.${libSuffix}`, import.meta.url).pathname;
+ const obj = ops.op_napi_open(path, {});
+ assert(obj != null);
+ assert(typeof obj === "object");
+});