nodejs/test/parallel/test-timers-api-refs.js
Kyle Simpson 9fa25c8ca0 timers: fixing API refs to use safe internal refs
Added safe internal references for 'clearTimeout(..)', 'active(..)', and
'unenroll(..)'. Changed various API refs from 'export.*' to use these
safe internal references.

Now, overwriting the global API identifiers does not create potential
breakage and/or race conditions. See Issue #2493.

PR-URL: https://github.com/nodejs/node/pull/5882
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Fixes: https://github.com/nodejs/node/issues/2493
2016-03-28 16:18:14 -07:00

21 lines
452 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
// don't verify the globals for this test
common.globalCheck = false;
// try overriding global APIs to make sure
// they're not relied on by the timers
global.clearTimeout = assert.fail;
// run timeouts/intervals through the paces
const intv = setInterval(function() {}, 1);
setTimeout(function() {
clearInterval(intv);
}, 100);
setTimeout(function() {}, 2);