Skip to content
Closed
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 @@ -57,7 +57,8 @@ class MessageQueue {
__spy: ?(data: SpyData) => void;

constructor() {
this._lazyCallableModules = {};
// $FlowFixMe[incompatible-type] Object.create(null) is used as a string-keyed map.
this._lazyCallableModules = Object.create(null);
this._queue = [[], [], [], 0];
this._successCallbacks = new Map();
this._failureCallbacks = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ describe('MessageQueue', () => {
expect(queue.getCallableModule(name)).toEqual(dummyModule);
});

it('should not return inherited Object properties as callable modules', () => {
expect(queue.getCallableModule('constructor')).toBeNull();
expect(queue.getCallableModule('__proto__')).toBeNull();
});

it('should register callable modules named __proto__', () => {
const dummyModule = {};
queue.registerCallableModule('__proto__', dummyModule);

expect(queue.getCallableModule('__proto__')).toBe(dummyModule);
});

it('should not initialize lazily registered module before it was used for the first time', () => {
const dummyModule = {},
name = 'modulesName';
Expand Down
Loading