11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst domain = require('domain');
61cb0ef41Sopenharmony_ciconst fs = require('fs');
71cb0ef41Sopenharmony_ciconst isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable);
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciprocess.on('warning', common.mustNotCall());
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci{
121cb0ef41Sopenharmony_ci  const d = new domain.Domain();
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  d.on('error', common.mustCall((err) => {
151cb0ef41Sopenharmony_ci    assert.strictEqual(err.message, 'foobar');
161cb0ef41Sopenharmony_ci    assert.strictEqual(err.domain, d);
171cb0ef41Sopenharmony_ci    assert.strictEqual(isEnumerable(err, 'domain'), false);
181cb0ef41Sopenharmony_ci    assert.strictEqual(err.domainEmitter, undefined);
191cb0ef41Sopenharmony_ci    assert.strictEqual(err.domainBound, undefined);
201cb0ef41Sopenharmony_ci    assert.strictEqual(err.domainThrown, true);
211cb0ef41Sopenharmony_ci  }));
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci  d.run(common.mustCall(() => {
241cb0ef41Sopenharmony_ci    process.nextTick(common.mustCall(() => {
251cb0ef41Sopenharmony_ci      const i = setInterval(common.mustCall(() => {
261cb0ef41Sopenharmony_ci        clearInterval(i);
271cb0ef41Sopenharmony_ci        setTimeout(common.mustCall(() => {
281cb0ef41Sopenharmony_ci          fs.stat('this file does not exist', common.mustCall((er, stat) => {
291cb0ef41Sopenharmony_ci            throw new Error('foobar');
301cb0ef41Sopenharmony_ci          }));
311cb0ef41Sopenharmony_ci        }), 1);
321cb0ef41Sopenharmony_ci      }), 1);
331cb0ef41Sopenharmony_ci    }));
341cb0ef41Sopenharmony_ci  }));
351cb0ef41Sopenharmony_ci}
36