summaryrefslogtreecommitdiff
path: root/test/parallel/test-v8-startup-snapshot-api.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-v8-startup-snapshot-api.js')
-rw-r--r--test/parallel/test-v8-startup-snapshot-api.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/parallel/test-v8-startup-snapshot-api.js b/test/parallel/test-v8-startup-snapshot-api.js
new file mode 100644
index 0000000000..c373891154
--- /dev/null
+++ b/test/parallel/test-v8-startup-snapshot-api.js
@@ -0,0 +1,26 @@
+'use strict';
+
+require('../common');
+const assert = require('assert');
+
+const {
+ isBuildingSnapshot,
+ addSerializeCallback,
+ addDeserializeCallback,
+ setDeserializeMainFunction
+} = require('v8').startupSnapshot;
+
+// This test verifies that the v8.startupSnapshot APIs are not available when
+// it is not building snapshot.
+
+assert(!isBuildingSnapshot());
+
+assert.throws(() => addSerializeCallback(() => {}), {
+ code: 'ERR_NOT_BUILDING_SNAPSHOT',
+});
+assert.throws(() => addDeserializeCallback(() => {}), {
+ code: 'ERR_NOT_BUILDING_SNAPSHOT',
+});
+assert.throws(() => setDeserializeMainFunction(() => {}), {
+ code: 'ERR_NOT_BUILDING_SNAPSHOT',
+});