Skip to content

Commit 91217b2

Browse files
committed
fix: some tests were failing
1 parent 083260d commit 91217b2

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

emulate-browsers/base/test/plugins-Chrome.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
},
6161
"_$function": "function MimeType() { [native code] }",
6262
"_$type": "function",
63+
"_$invocation": "TypeError: Illegal constructor",
64+
"_$value": "function MimeType() { [native code] }",
6365
"_$flags": "cw"
6466
},
6567
"MimeTypeArray": {
@@ -140,6 +142,8 @@
140142
},
141143
"_$function": "function MimeTypeArray() { [native code] }",
142144
"_$type": "function",
145+
"_$invocation": "TypeError: Illegal constructor",
146+
"_$value": "function MimeTypeArray() { [native code] }",
143147
"_$flags": "cw"
144148
},
145149
"Plugin": {
@@ -202,6 +206,7 @@
202206
},
203207
"_$function": "function item() { [native code] }",
204208
"_$invocation": "TypeError: Illegal invocation",
209+
"_$value": "function item() { [native code] }",
205210
"_$type": "function",
206211
"_$flags": "cew"
207212
},
@@ -218,6 +223,7 @@
218223
},
219224
"_$function": "function namedItem() { [native code] }",
220225
"_$invocation": "TypeError: Illegal invocation",
226+
"_$value": "function namedItem() { [native code] }",
221227
"_$type": "function",
222228
"_$flags": "cew"
223229
},
@@ -235,7 +241,9 @@
235241
"_$type": "constructor"
236242
},
237243
"_$function": "function Plugin() { [native code] }",
244+
"_$invocation": "TypeError: Illegal constructor",
238245
"_$type": "function",
246+
"_$value": "function Plugin() { [native code] }",
239247
"_$flags": "cw"
240248
},
241249
"PluginArray": {
@@ -280,6 +288,7 @@
280288
},
281289
"_$function": "function item() { [native code] }",
282290
"_$invocation": "TypeError: Illegal invocation",
291+
"_$value": "function item() { [native code] }",
283292
"_$type": "function",
284293
"_$flags": "cew"
285294
},
@@ -296,6 +305,7 @@
296305
},
297306
"_$function": "function namedItem() { [native code] }",
298307
"_$invocation": "TypeError: Illegal invocation",
308+
"_$value": "function namedItem() { [native code] }",
299309
"_$type": "function",
300310
"_$flags": "cew"
301311
},
@@ -312,6 +322,7 @@
312322
},
313323
"_$function": "function refresh() { [native code] }",
314324
"_$invocation": "TypeError: Illegal invocation",
325+
"_$value": "function refresh() { [native code] }",
315326
"_$type": "function",
316327
"_$flags": "cew"
317328
},
@@ -330,7 +341,7 @@
330341
},
331342
"_$function": "function PluginArray() { [native code] }",
332343
"_$invocation": "TypeError: Illegal constructor",
333-
"_$value": "function Plugin() { [native code] }",
344+
"_$value": "function PluginArray() { [native code] }",
334345
"_$type": "function",
335346
"_$flags": "cw"
336347
}

emulate-browsers/base/test/plugins.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ test('it should override plugins in a browser window', async () => {
136136
false,
137137
)) as any,
138138
).window;
139+
139140
for (const proto of ['Plugin', 'PluginArray', 'MimeType', 'MimeTypeArray']) {
140141
if (debug) console.log(proto, inspect(structure[proto], false, null, true));
141142
expect(structure[proto]).toStrictEqual(pluginsChrome[proto]);

replay/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
isBinaryInstalled,
1010
isLocalBuildPresent,
1111
} from './install/Utils';
12-
import getResolvable from '~shared/utils/promise';
1312

1413
const replayDir = getInstallDirectory();
1514
const registrationApiFilepath = `${replayDir}/api.txt`;
@@ -125,22 +124,26 @@ export async function openReplayApp(...extraArgs: string[]) {
125124
child = await launchReplay(getBinaryPath(), ['--binary-launch', ...extraArgs]);
126125
}
127126

128-
const registrationComplete = getResolvable<void>();
127+
let registrationResolve: () => any;
128+
let registrationReject: (reason?: any) => any;
129+
const registrationComplete = new Promise<void>((resolve, reject) => {
130+
registrationResolve = resolve;
131+
registrationReject = reject;
132+
});
129133
const onPrematureExit = (code, signal) =>
130-
registrationComplete.reject(new Error(`Replay shutdown with exit code ${code}: ${signal}`));
134+
registrationReject(new Error(`Replay shutdown with exit code ${code}: ${signal}`));
131135
child.once('exit', onPrematureExit);
132-
child.once('error', registrationComplete.reject);
133-
136+
child.once('error', registrationReject);
134137
// wait for change
135138
const watcher = Fs.watch(registrationApiFilepath, { persistent: false, recursive: false }, () => {
136139
if (resolveHost()) {
137-
registrationComplete.resolve();
140+
registrationResolve();
138141
}
139142
});
140-
return registrationComplete.promise.finally(() => {
143+
return registrationComplete.finally(() => {
141144
watcher.close();
142145
child.off('exit', onPrematureExit);
143-
child.off('error', registrationComplete.reject);
146+
child.off('error', registrationReject);
144147
});
145148
}
146149

0 commit comments

Comments
 (0)