File tree 4 files changed +34
-5
lines changed
4 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ const {
11
11
ObjectDefineProperty,
12
12
ObjectGetOwnPropertyDescriptor,
13
13
ObjectGetOwnPropertyDescriptors,
14
+ ObjectSetPrototypeOf,
15
+ ObjectValues,
14
16
ReflectApply,
15
17
SafeArrayIterator,
16
18
SafeFinalizationRegistry,
@@ -1067,6 +1069,12 @@ const EventEmitterMixin = (Superclass) => {
1067
1069
}
1068
1070
const protoProps = ObjectGetOwnPropertyDescriptors ( EventEmitter . prototype ) ;
1069
1071
delete protoProps . constructor ;
1072
+ const propertiesValues = ObjectValues ( protoProps ) ;
1073
+ for ( let i = 0 ; i < propertiesValues . length ; i ++ ) {
1074
+ // We want to use null-prototype objects to not rely on globally mutable
1075
+ // %Object.prototype%.
1076
+ ObjectSetPrototypeOf ( propertiesValues [ i ] , null ) ;
1077
+ }
1070
1078
ObjectDefineProperties ( MixedEventEmitter . prototype , protoProps ) ;
1071
1079
return MixedEventEmitter ;
1072
1080
} ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const {
16
16
ObjectFreeze,
17
17
ObjectPrototypeHasOwnProperty,
18
18
ObjectSetPrototypeOf,
19
+ ObjectValues,
19
20
Promise,
20
21
ReflectApply,
21
22
ReflectConstruct,
@@ -369,10 +370,15 @@ function promisify(original) {
369
370
__proto__ : null ,
370
371
value : fn , enumerable : false , writable : false , configurable : true
371
372
} ) ;
372
- return ObjectDefineProperties (
373
- fn ,
374
- ObjectGetOwnPropertyDescriptors ( original )
375
- ) ;
373
+
374
+ const descriptors = ObjectGetOwnPropertyDescriptors ( original ) ;
375
+ const propertiesValues = ObjectValues ( descriptors ) ;
376
+ for ( let i = 0 ; i < propertiesValues . length ; i ++ ) {
377
+ // We want to use null-prototype objects to not rely on globally mutable
378
+ // %Object.prototype%.
379
+ ObjectSetPrototypeOf ( propertiesValues [ i ] , null ) ;
380
+ }
381
+ return ObjectDefineProperties ( fn , descriptors ) ;
376
382
}
377
383
378
384
promisify . custom = kCustomPromisifiedSymbol ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const {
13
13
ObjectGetOwnPropertyDescriptors,
14
14
ObjectGetPrototypeOf,
15
15
ObjectSetPrototypeOf,
16
+ ObjectValues,
16
17
ReflectApply,
17
18
Symbol,
18
19
SymbolFor,
@@ -95,10 +96,17 @@ const messageTypes = {
95
96
// it inherit from NodeEventTarget, even though it is a C++ class, and b) we do
96
97
// not provide methods that are not present in the Browser and not documented
97
98
// on our side (e.g. stopMessagePort).
99
+ const messagePortPrototypePropertyDescriptors = ObjectGetOwnPropertyDescriptors ( MessagePort . prototype ) ;
100
+ const propertiesValues = ObjectValues ( messagePortPrototypePropertyDescriptors ) ;
101
+ for ( let i = 0 ; i < propertiesValues . length ; i ++ ) {
102
+ // We want to use null-prototype objects to not rely on globally mutable
103
+ // %Object.prototype%.
104
+ ObjectSetPrototypeOf ( propertiesValues [ i ] , null ) ;
105
+ }
98
106
// Save a copy of the original set of methods as a shallow clone.
99
107
const MessagePortPrototype = ObjectCreate (
100
108
ObjectGetPrototypeOf ( MessagePort . prototype ) ,
101
- ObjectGetOwnPropertyDescriptors ( MessagePort . prototype ) ) ;
109
+ messagePortPrototypePropertyDescriptors ) ;
102
110
// Set up the new inheritance chain.
103
111
ObjectSetPrototypeOf ( MessagePort , NodeEventTarget ) ;
104
112
ObjectSetPrototypeOf ( MessagePort . prototype , NodeEventTarget . prototype ) ;
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ const {
40
40
ObjectKeys,
41
41
ObjectPrototypeToString,
42
42
ObjectSetPrototypeOf,
43
+ ObjectValues,
43
44
ReflectApply,
44
45
StringPrototypePadStart,
45
46
} = primordials ;
@@ -317,6 +318,12 @@ function callbackify(original) {
317
318
if ( typeof descriptors . name . value === 'string' ) {
318
319
descriptors . name . value += 'Callbackified' ;
319
320
}
321
+ const propertiesValues = ObjectValues ( descriptors ) ;
322
+ for ( let i = 0 ; i < propertiesValues . length ; i ++ ) {
323
+ // We want to use null-prototype objects to not rely on globally mutable
324
+ // %Object.prototype%.
325
+ ObjectSetPrototypeOf ( propertiesValues [ i ] , null ) ;
326
+ }
320
327
ObjectDefineProperties ( callbackified , descriptors ) ;
321
328
return callbackified ;
322
329
}
You can’t perform that action at this time.
0 commit comments