Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import invariant from 'invariant';
type TaskCanceller = () => void;
type TaskCancelProvider = () => TaskCanceller;

const runnables: Runnables = {};
const sections: Runnables = {};
const runnables = Object.create(null) as any as Runnables;
const sections = Object.create(null) as any as Runnables;
const taskProviders: Map<string, TaskProvider> = new Map();
const taskCancelProviders: Map<string, TaskCancelProvider> = new Map();
let componentProviderInstrumentationHook: ComponentProviderInstrumentationHook =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

'use strict';

const AppRegistry = require('../AppRegistryImpl');

describe('AppRegistry', () => {
it('does not return inherited Object properties as registered apps', () => {
expect(AppRegistry.getRunnable('constructor')).toBeUndefined();
});

it('registers app and section keys named __proto__', () => {
const app = jest.fn();
const section = () =>
function Section() {
return null;
};

AppRegistry.registerRunnable('__proto__', app);
AppRegistry.registerSection('__proto__', section);

expect(AppRegistry.getRunnable('__proto__')).toBeInstanceOf(Function);
expect(AppRegistry.getAppKeys()).toContain('__proto__');
expect(AppRegistry.getSectionKeys()).toContain('__proto__');
expect(Object.keys(AppRegistry.getSections())).toContain('__proto__');
});
});
Loading