11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst domain = require('domain');
61cb0ef41Sopenharmony_ciconst EventEmitter = require('events');
71cb0ef41Sopenharmony_ciconst isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable);
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst d = new domain.Domain();
101cb0ef41Sopenharmony_ciconst e = new EventEmitter();
111cb0ef41Sopenharmony_ciconst e2 = new EventEmitter();
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cid.add(e);
141cb0ef41Sopenharmony_ciassert.strictEqual(e.domain, d);
151cb0ef41Sopenharmony_ciassert.strictEqual(isEnumerable(e, 'domain'), false);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci// Adding the same event to a domain should not change the member count
181cb0ef41Sopenharmony_cilet previousMemberCount = d.members.length;
191cb0ef41Sopenharmony_cid.add(e);
201cb0ef41Sopenharmony_ciassert.strictEqual(previousMemberCount, d.members.length);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cid.add(e2);
231cb0ef41Sopenharmony_ciassert.strictEqual(e2.domain, d);
241cb0ef41Sopenharmony_ciassert.strictEqual(isEnumerable(e2, 'domain'), false);
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_cipreviousMemberCount = d.members.length;
271cb0ef41Sopenharmony_cid.remove(e2);
281cb0ef41Sopenharmony_ciassert.notStrictEqual(e2.domain, d);
291cb0ef41Sopenharmony_ciassert.strictEqual(isEnumerable(e2, 'domain'), false);
301cb0ef41Sopenharmony_ciassert.strictEqual(previousMemberCount - 1, d.members.length);
31