Skip to content

Commit 5aa985b

Browse files
hoxyqfacebook-github-bot
authored andcommitted
@react-native/js-polyfills: polyfill console.timeStamp
Summary: # Changelog: [Internal] The main reason for the stub is to make sure this method is always installed. The actual implementation will be part of the `jsinspector-modern` stack, which is fully initialized in production builds. Once there is a gurantee that RuntimeTarget globals are always installed in any environments, we can remove polyfills altogether. Reviewed By: GijsWeterings Differential Revision: D76987507
1 parent 18f4db4 commit 5aa985b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
* @fantom_mode *
10+
* @fantom_flags fuseboxEnabledRelease:*
11+
*/
12+
13+
describe('console.timeStamp()', () => {
14+
it('installed', () => {
15+
expect(typeof console.timeStamp).toBe('function');
16+
});
17+
});

packages/polyfills/console.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ function consoleAssertPolyfill(expression, label) {
569569
}
570570
}
571571

572+
// https://developer.mozilla.org/en-US/docs/Web/API/console/timeStamp_static.
573+
// Non-standard API for recording markers on a timeline of the Performance instrumentation.
574+
// The actual logging is not provided by definition.
575+
function consoleTimeStampStub() {}
576+
572577
if (global.nativeLoggingHook) {
573578
const originalConsole = global.console;
574579
// Preserve the original `console` as `originalConsole`
@@ -592,6 +597,7 @@ if (global.nativeLoggingHook) {
592597
groupEnd: consoleGroupEndPolyfill,
593598
groupCollapsed: consoleGroupCollapsedPolyfill,
594599
assert: consoleAssertPolyfill,
600+
timeStamp: consoleTimeStampStub,
595601
};
596602

597603
// TODO(T206796580): This was copy-pasted from ExceptionsManager.js
@@ -694,6 +700,7 @@ if (global.nativeLoggingHook) {
694700
profile: stub,
695701
profileEnd: stub,
696702
table: stub,
703+
timeStamp: consoleTimeStampStub,
697704
};
698705

699706
Object.defineProperty(console, '_isPolyfilled', {

0 commit comments

Comments
 (0)