@@ -4,12 +4,11 @@ import {
44 Agent ,
55 ManagedRealm ,
66 createTest262Intrinsics ,
7- evalQ ,
7+ X ,
88 boostTest262Harness ,
99 Get ,
1010 Set ,
1111 Value ,
12- Realm ,
1312 Throw ,
1413 CreateBuiltinFunction ,
1514 JSStringValue ,
@@ -76,34 +75,32 @@ function recreateAgent(features, signal) {
7675 } ) ;
7776 agent . hostDefinedOptions . hostHooks ??= { } ;
7877 agent . hostDefinedOptions . hostHooks . HostLoadImportedModule = composeModuleLoaders ( [ builtinLoader ] )
79- realm . scope ( ( ) => {
80- const defineModule = CreateBuiltinFunction ( function * defineModule ( [ specifier , source ] ) {
81- if ( ! ( specifier instanceof JSStringValue ) ) {
82- return Throw . TypeError ( 'specifier is not a string' ) ;
83- }
84- if ( ! ( source instanceof JSStringValue ) ) {
85- return Throw . TypeError ( 'source is not a string' ) ;
86- }
87- if ( surroundingAgent . debugger_cannotPreview ) {
88- return surroundingAgent . debugger_cannotPreview ;
89- }
90- virtualModuleSourceCache . set ( specifier . stringValue ( ) , source . stringValue ( ) ) ;
91- return Value . undefined ;
92- } , 2 , 'defineModule' , [ 'SourceText' ] ) ;
93- /** @type {import('../../lib/engine262.mjs').ECMAScriptFunctionObject } */ ( /** @type {any } */ ( defineModule ) ) . SourceText = 'function defineModule(specifier, source) { [native code] }' ;
94- CreateNonEnumerableDataPropertyOrThrow ( realm . GlobalObject , Value ( 'defineModule' ) , defineModule ) ;
95- } ) ;
78+ const pop = realm . pushTopContext ( ) ;
79+ const defineModule = CreateBuiltinFunction ( function * defineModule ( [ specifier , source ] ) {
80+ if ( ! ( specifier instanceof JSStringValue ) ) {
81+ return Throw . TypeError ( 'specifier is not a string' ) ;
82+ }
83+ if ( ! ( source instanceof JSStringValue ) ) {
84+ return Throw . TypeError ( 'source is not a string' ) ;
85+ }
86+ if ( surroundingAgent . debugger_cannotPreview ) {
87+ return surroundingAgent . debugger_cannotPreview ;
88+ }
89+ virtualModuleSourceCache . set ( specifier . stringValue ( ) , source . stringValue ( ) ) ;
90+ return Value . undefined ;
91+ } , 2 , 'defineModule' , [ 'SourceText' ] ) ;
92+ /** @type {import('../../lib/engine262.mjs').ECMAScriptFunctionObject } */ ( /** @type {any } */ ( defineModule ) ) . SourceText = 'function defineModule(specifier, source) { [native code] }' ;
93+ CreateNonEnumerableDataPropertyOrThrow ( realm . GlobalObject , Value ( 'defineModule' ) , defineModule ) ;
94+ pop ?. ( ) ;
9695 }
9796
9897 if ( features . includes ( 'test262-harness' ) ) {
9998 createTest262Intrinsics ( realm , false , console . log ) ;
10099 importBundledTest262Harness ( realm ) ;
101- evalQ ( ( _Q , X ) => {
102- realm . scope ( ( ) => {
103- const consoleTrace = X ( Get ( X ( Get ( realm . GlobalObject , Value ( 'console' ) ) ) , Value ( 'trace' ) ) ) ;
104- X ( Set ( realm . GlobalObject , Value ( '__consolePrintHandle__' ) , consoleTrace , Value . true ) ) ;
105- } ) ;
106- } ) ;
100+ const pop = realm . pushTopContext ( ) ;
101+ const consoleTrace = X ( Get ( X ( Get ( realm . GlobalObject , Value ( 'console' ) ) ) , Value ( 'trace' ) ) ) ;
102+ X ( Set ( realm . GlobalObject , Value ( '__consolePrintHandle__' ) , consoleTrace , Value . true ) ) ;
103+ pop ?. ( ) ;
107104 boostTest262Harness ( realm ) ;
108105 }
109106}
0 commit comments