@@ -23,7 +23,6 @@ if (typeof require === "function" && typeof module === "object") {
23
23
24
24
/**
25
25
* Queues a function to be called during a browser's idle periods
26
- *
27
26
* @callback RequestIdleCallback
28
27
* @param {function(IdleDeadline) } callback
29
28
* @param {{timeout: number} } options - an options object
@@ -106,7 +105,6 @@ if (typeof require === "function" && typeof module === "object") {
106
105
107
106
/**
108
107
* Configuration object for the `install` method.
109
- *
110
108
* @typedef {object } Config
111
109
* @property {number|Date } [now] a number (in milliseconds) or a Date object (default epoch)
112
110
* @property {string[] } [toFake] names of the methods that should be faked.
@@ -120,7 +118,6 @@ if (typeof require === "function" && typeof module === "object") {
120
118
/* eslint-disable jsdoc/require-property-description */
121
119
/**
122
120
* The internal structure to describe a scheduled fake timer
123
- *
124
121
* @typedef {object } Timer
125
122
* @property {Function } func
126
123
* @property {*[] } args
@@ -134,7 +131,6 @@ if (typeof require === "function" && typeof module === "object") {
134
131
135
132
/**
136
133
* A Node timer
137
- *
138
134
* @typedef {object } NodeImmediate
139
135
* @property {function(): boolean } hasRef
140
136
* @property {function(): NodeImmediate } ref
@@ -146,7 +142,6 @@ if (typeof require === "function" && typeof module === "object") {
146
142
147
143
/**
148
144
* Mocks available features in the specified global namespace.
149
- *
150
145
* @param {* } _global Namespace to mock (e.g. `window`)
151
146
* @returns {FakeTimers }
152
147
*/
@@ -276,7 +271,6 @@ function withGlobal(_global) {
276
271
* Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into
277
272
* number of milliseconds. This is used to support human-readable strings passed
278
273
* to clock.tick()
279
- *
280
274
* @param {string } str
281
275
* @returns {number }
282
276
*/
@@ -312,7 +306,6 @@ function withGlobal(_global) {
312
306
313
307
/**
314
308
* Get the decimal part of the millisecond value as nanoseconds
315
- *
316
309
* @param {number } msFloat the number of milliseconds
317
310
* @returns {number } an integer number of nanoseconds in the range [0,1e6)
318
311
*
@@ -329,7 +322,6 @@ function withGlobal(_global) {
329
322
330
323
/**
331
324
* Used to grok the `now` parameter to createClock.
332
- *
333
325
* @param {Date|number } epoch the system time
334
326
* @returns {number }
335
327
*/
@@ -483,7 +475,6 @@ function withGlobal(_global) {
483
475
/**
484
476
* A normal Class constructor cannot be called without `new`, but Date can, so we need
485
477
* to wrap it in a Proxy in order to ensure this functionality of Date is kept intact
486
- *
487
478
* @type {ClockDate }
488
479
*/
489
480
const ClockDateProxy = new Proxy ( ClockDate , {
@@ -510,7 +501,6 @@ function withGlobal(_global) {
510
501
* Most of the properties are the original native ones,
511
502
* but we need to take control of those that have a
512
503
* dependency on the current clock.
513
- *
514
504
* @returns {object } the partly fake Intl implementation
515
505
*/
516
506
function createIntl ( ) {
@@ -683,7 +673,6 @@ function withGlobal(_global) {
683
673
/* eslint consistent-return: "off" */
684
674
/**
685
675
* Timer comparitor
686
- *
687
676
* @param {Timer } a
688
677
* @param {Timer } b
689
678
* @returns {number }
@@ -815,7 +804,6 @@ function withGlobal(_global) {
815
804
816
805
/**
817
806
* Gets clear handler name for a given timer type
818
- *
819
807
* @param {string } ttype
820
808
*/
821
809
function getClearHandler ( ttype ) {
@@ -827,7 +815,6 @@ function withGlobal(_global) {
827
815
828
816
/**
829
817
* Gets schedule handler name for a given timer type
830
- *
831
818
* @param {string } ttype
832
819
*/
833
820
function getScheduleHandler ( ttype ) {
@@ -1183,13 +1170,11 @@ function withGlobal(_global) {
1183
1170
1184
1171
/**
1185
1172
* A high resolution timestamp in milliseconds.
1186
- *
1187
1173
* @typedef {number } DOMHighResTimeStamp
1188
1174
*/
1189
1175
1190
1176
/**
1191
1177
* performance.now()
1192
- *
1193
1178
* @returns {DOMHighResTimeStamp }
1194
1179
*/
1195
1180
function fakePerformanceNow ( ) {
@@ -1848,6 +1833,9 @@ function withGlobal(_global) {
1848
1833
new FakePerformanceEntry ( name , "mark" , 0 , 0 ) ;
1849
1834
clock . performance . measure = ( name ) =>
1850
1835
new FakePerformanceEntry ( name , "measure" , 0 , 100 ) ;
1836
+ // `timeOrigin` should return the time of when the Window session started
1837
+ // (or the Worker was installed)
1838
+ clock . performance . timeOrigin = getEpoch ( config . now ) ;
1851
1839
} else if ( ( config . toFake || [ ] ) . includes ( "performance" ) ) {
1852
1840
return handleMissingTimer ( "performance" ) ;
1853
1841
}
0 commit comments