@@ -7,10 +7,14 @@ const {
77 FunctionPrototypeBind,
88 FunctionPrototypeCall,
99 ObjectAssign,
10+ ObjectDefineProperties,
1011 ObjectDefineProperty,
1112 ObjectGetOwnPropertyDescriptor,
13+ ObjectGetOwnPropertyDescriptors,
1214 ObjectGetPrototypeOf,
1315 ObjectKeys,
16+ ObjectSetPrototypeOf,
17+ ObjectValues,
1418 Proxy,
1519 ReflectApply,
1620 ReflectConstruct,
@@ -146,7 +150,7 @@ class MockFunctionContext {
146150
147151 if ( typeof methodName === 'string' ) {
148152 // This is an object method spy.
149- ObjectDefineProperty ( object , methodName , descriptor ) ;
153+ ObjectDefineProperty ( object , methodName , { __proto__ : null , ... descriptor } ) ;
150154 } else {
151155 // This is a bare function spy. There isn't much to do here but make
152156 // the mock call the original function.
@@ -880,13 +884,14 @@ function normalizeModuleMockOptions(options) {
880884
881885
882886function copyOwnProperties ( from , to ) {
883- const keys = ObjectKeys ( from ) ;
887+ const descriptors = ObjectGetOwnPropertyDescriptors ( from ) ;
884888
885- for ( let i = 0 ; i < keys . length ; ++ i ) {
886- const key = keys [ i ] ;
887- const descriptor = ObjectGetOwnPropertyDescriptor ( from , key ) ;
888- ObjectDefineProperty ( to , key , descriptor ) ;
889+ const descValues = ObjectValues ( descriptors ) ;
890+ for ( let i = 0 ; i < descValues . length ; ++ i ) {
891+ ObjectSetPrototypeOf ( descValues [ i ] , null ) ;
889892 }
893+
894+ ObjectDefineProperties ( to , descriptors ) ;
890895}
891896
892897function setupSharedModuleState ( ) {
0 commit comments