11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// Attempts to test that the source map JS code run on process shutdown
71cb0ef41Sopenharmony_ci// does not call any user-defined JS code.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst { Worker, workerData, parentPort } = require('worker_threads');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciif (!workerData) {
121cb0ef41Sopenharmony_ci  tmpdir.refresh();
131cb0ef41Sopenharmony_ci  process.env.NODE_V8_COVERAGE = tmpdir.path;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  // Count the number of some calls that should not be made.
161cb0ef41Sopenharmony_ci  const callCount = new Int32Array(new SharedArrayBuffer(4));
171cb0ef41Sopenharmony_ci  const w = new Worker(__filename, { workerData: { callCount } });
181cb0ef41Sopenharmony_ci  w.on('message', common.mustCall(() => w.terminate()));
191cb0ef41Sopenharmony_ci  w.on('exit', common.mustCall(() => {
201cb0ef41Sopenharmony_ci    assert.strictEqual(callCount[0], 0);
211cb0ef41Sopenharmony_ci  }));
221cb0ef41Sopenharmony_ci  return;
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconst { callCount } = workerData;
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cifunction increaseCallCount() { callCount[0]++; }
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci// Increase the call count when a forbidden method is called.
301cb0ef41Sopenharmony_cifor (const property of ['_cache', 'lineLengths', 'url']) {
311cb0ef41Sopenharmony_ci  Object.defineProperty(Object.prototype, property, {
321cb0ef41Sopenharmony_ci    get: increaseCallCount,
331cb0ef41Sopenharmony_ci    set: increaseCallCount
341cb0ef41Sopenharmony_ci  });
351cb0ef41Sopenharmony_ci}
361cb0ef41Sopenharmony_ciObject.getPrototypeOf([][Symbol.iterator]()).next = increaseCallCount;
371cb0ef41Sopenharmony_ciObject.getPrototypeOf((new Map()).entries()).next = increaseCallCount;
381cb0ef41Sopenharmony_ciArray.prototype[Symbol.iterator] = increaseCallCount;
391cb0ef41Sopenharmony_ciMap.prototype[Symbol.iterator] = increaseCallCount;
401cb0ef41Sopenharmony_ciMap.prototype.entries = increaseCallCount;
411cb0ef41Sopenharmony_ciObject.keys = increaseCallCount;
421cb0ef41Sopenharmony_ciObject.create = increaseCallCount;
431cb0ef41Sopenharmony_ciObject.hasOwnProperty = increaseCallCount;
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ciparentPort.postMessage('done');
46