11cb0ef41Sopenharmony_ci// Flags: --no-addons
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst bindingPath = require.resolve(`./build/${common.buildType}/binding`);
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst assertError = (error) => {
111cb0ef41Sopenharmony_ci  assert(error instanceof Error);
121cb0ef41Sopenharmony_ci  assert.strictEqual(error.code, 'ERR_DLOPEN_DISABLED');
131cb0ef41Sopenharmony_ci  assert.strictEqual(
141cb0ef41Sopenharmony_ci    error.message,
151cb0ef41Sopenharmony_ci    'Cannot load native addon because loading addons is disabled.',
161cb0ef41Sopenharmony_ci  );
171cb0ef41Sopenharmony_ci};
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci{
201cb0ef41Sopenharmony_ci  let threw = false;
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci  try {
231cb0ef41Sopenharmony_ci    require(bindingPath);
241cb0ef41Sopenharmony_ci  } catch (error) {
251cb0ef41Sopenharmony_ci    assertError(error);
261cb0ef41Sopenharmony_ci    threw = true;
271cb0ef41Sopenharmony_ci  }
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  assert(threw);
301cb0ef41Sopenharmony_ci}
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci{
331cb0ef41Sopenharmony_ci  let threw = false;
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci  try {
361cb0ef41Sopenharmony_ci    process.dlopen({ exports: {} }, bindingPath);
371cb0ef41Sopenharmony_ci  } catch (error) {
381cb0ef41Sopenharmony_ci    assertError(error);
391cb0ef41Sopenharmony_ci    threw = true;
401cb0ef41Sopenharmony_ci  }
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  assert(threw);
431cb0ef41Sopenharmony_ci}
44