Implementation:SeleniumHQ Selenium Closure Testing MockClock
| Knowledge Sources | |
|---|---|
| Domains | JavaScript_Atoms, Vendored_Library |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Vendored Google Closure Library module providing a mock clock for controlling setTimeout/setInterval in tests, used by Selenium JavaScript atoms.
Description
goog.testing.MockClock is a vendored copy of the Google Closure Library module. It provides a mock implementation of setTimeout, setInterval, clearTimeout, and clearInterval for unit testing time-dependent code. It manages a reverse-order priority queue of pending timers and allows test code to advance time programmatically via tick(). It extends goog.Disposable and integrates with goog.async.run and goog.Promise. Selenium uses this as part of its JavaScript atom infrastructure.
Usage
This module is consumed internally by Selenium's JavaScript atoms build system. Not imported directly by end users.
Code Reference
Source Location
- Repository: SeleniumHQ_Selenium
- File: third_party/closure/goog/testing/mockclock.js
- Lines: 1-973
Key Exports
goog.provide('goog.testing.MockClock');
// MockClock - controls time in tests
goog.testing.MockClock = function(opt_autoInstall) { ... };
// Extends goog.Disposable
// Internal queue of pending timers
// this.queue_ = [];
// this.deletedKeys_ = {};
// Key methods: install(), uninstall(), tick(millis), reset()