()
| 1123 | process.nextTick(() => super.close()); |
| 1124 | } |
| 1125 | createContext() { |
| 1126 | let context; |
| 1127 | if (this.useGlobal) { |
| 1128 | context = globalThis; |
| 1129 | } else { |
| 1130 | sendInspectorCommand((session) => { |
| 1131 | session.post('Runtime.enable'); |
| 1132 | session.once('Runtime.executionContextCreated', ({ params }) => { |
| 1133 | this[kContextId] = params.context.id; |
| 1134 | }); |
| 1135 | context = vm.createContext(vm.constants.DONT_CONTEXTIFY); |
| 1136 | session.post('Runtime.disable'); |
| 1137 | }, () => { |
| 1138 | context = vm.createContext(vm.constants.DONT_CONTEXTIFY); |
| 1139 | }); |
| 1140 | ArrayPrototypeForEach(ObjectGetOwnPropertyNames(globalThis), (name) => { |
| 1141 | // Only set properties that do not already exist as a global builtin. |
| 1142 | if (!globalBuiltins.has(name)) { |
| 1143 | ObjectDefineProperty(context, name, |
| 1144 | { |
| 1145 | __proto__: null, |
| 1146 | ...ObjectGetOwnPropertyDescriptor(globalThis, name), |
| 1147 | }); |
| 1148 | } |
| 1149 | }); |
| 1150 | context.global = context; |
| 1151 | const _console = new Console(this.output); |
| 1152 | ObjectDefineProperty(context, 'console', { |
| 1153 | __proto__: null, |
| 1154 | configurable: true, |
| 1155 | writable: true, |
| 1156 | value: _console, |
| 1157 | }); |
| 1158 | } |
| 1159 | |
| 1160 | const replModule = new CJSModule('<repl>'); |
| 1161 | replModule.paths = CJSModule._resolveLookupPaths('<repl>', parentModule); |
| 1162 | |
| 1163 | ObjectDefineProperty(context, 'module', { |
| 1164 | __proto__: null, |
| 1165 | configurable: true, |
| 1166 | writable: true, |
| 1167 | value: replModule, |
| 1168 | }); |
| 1169 | ObjectDefineProperty(context, 'require', { |
| 1170 | __proto__: null, |
| 1171 | configurable: true, |
| 1172 | writable: true, |
| 1173 | value: makeRequireFunction(replModule), |
| 1174 | }); |
| 1175 | |
| 1176 | addBuiltinLibsToObject(context, '<REPL>'); |
| 1177 | |
| 1178 | return context; |
| 1179 | } |
| 1180 | resetContext() { |
| 1181 | this.context = this.createContext(); |
| 1182 | this.underscoreAssigned = false; |
no test coverage detected