forked from denoland/deno
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide option to delete Deno namespace in worker (denoland#2717)
- Loading branch information
1 parent
aaa7a3e
commit ddee2df
Showing
18 changed files
with
128 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. | ||
import { window } from "./window"; | ||
|
||
// This allows us to access core in API even if we | ||
// dispose window.Deno | ||
export const core = window.Deno.core as DenoCore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
args: run --reload tests/039_worker_deno_ns.ts | ||
output: tests/039_worker_deno_ns.ts.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const w1 = new Worker("./tests/039_worker_deno_ns/has_ns.ts"); | ||
const w2 = new Worker("./tests/039_worker_deno_ns/no_ns.ts", { | ||
noDenoNamespace: true | ||
}); | ||
let w1MsgCount = 0; | ||
let w2MsgCount = 0; | ||
w1.onmessage = (msg): void => { | ||
console.log(msg.data); | ||
w1MsgCount++; | ||
if (w1MsgCount === 1) { | ||
w1.postMessage("CONTINUE"); | ||
} else { | ||
w2.postMessage("START"); | ||
} | ||
}; | ||
w2.onmessage = (msg): void => { | ||
console.log(msg.data); | ||
w2MsgCount++; | ||
if (w2MsgCount === 1) { | ||
w2.postMessage("CONTINUE"); | ||
} else { | ||
Deno.exit(0); | ||
} | ||
}; | ||
w1.postMessage("START"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
has_ns.ts: is window.Deno available: true | ||
[SPAWNED BY has_ns.ts] maybe_ns.ts: is window.Deno available: true | ||
no_ns.ts: is window.Deno available: false | ||
[SPAWNED BY no_ns.ts] maybe_ns.ts: is window.Deno available: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
onmessage = (msg): void => { | ||
if (msg.data === "START") { | ||
postMessage("has_ns.ts: is window.Deno available: " + !!window.Deno); | ||
} else { | ||
const worker = new Worker("./tests/039_worker_deno_ns/maybe_ns.ts"); | ||
worker.onmessage = (msg): void => { | ||
postMessage("[SPAWNED BY has_ns.ts] " + msg.data); | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
postMessage("maybe_ns.ts: is window.Deno available: " + !!window.Deno); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
onmessage = (msg): void => { | ||
if (msg.data === "START") { | ||
postMessage("no_ns.ts: is window.Deno available: " + !!window.Deno); | ||
} else { | ||
const worker = new Worker("./tests/039_worker_deno_ns/maybe_ns.ts"); | ||
worker.onmessage = (msg): void => { | ||
postMessage("[SPAWNED BY no_ns.ts] " + msg.data); | ||
}; | ||
} | ||
}; |