fix(worker): make worker name spec compliant (#4746)

This commit is contained in:
Bartek Iwańczuk 2020-04-14 17:41:06 +02:00 committed by GitHub
parent cb5dd69dda
commit e08ece2d2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 16 deletions

View file

@ -107,7 +107,10 @@ export const workerRuntimeGlobalProperties = {
workerMessageRecvCallback: nonEnumerable(workerMessageRecvCallback),
};
export function bootstrapWorkerRuntime(name: string): void {
export function bootstrapWorkerRuntime(
name: string,
internalName?: string
): void {
if (hasBootstrapped) {
throw new Error("Worker runtime already bootstrapped");
}
@ -119,7 +122,7 @@ export function bootstrapWorkerRuntime(name: string): void {
Object.defineProperties(globalThis, eventTargetProperties);
Object.defineProperties(globalThis, { name: readOnly(name) });
setEventTargetData(globalThis);
const s = runtime.start(name);
const s = runtime.start(internalName ?? name);
const location = new LocationImpl(s.location);
immutableDefine(globalThis, "location", location);