Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
Co-Authored-By: Liam Murphy <43807659+Liamolucko@users.noreply.github.com>
  • Loading branch information
daxpedda and Liamolucko committed Jan 23, 2024
1 parent 056a72d commit be94f88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
22 changes: 7 additions & 15 deletions crates/cli/src/bin/wasm-bindgen-test-runner/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub(crate) fn spawn(
document.getElementById('output').textContent = "Loading wasm module...";
{}
port_receive.addEventListener("message", function(e) {{
port.addEventListener("message", function(e) {{
// Checking the whether the message is from wasm_bindgen_test
if(
e.data &&
Expand All @@ -173,7 +173,7 @@ pub(crate) fn spawn(
}});
async function main(test) {{
port_send.postMessage(test)
port.postMessage(test)
}}
const tests = [];
Expand All @@ -187,21 +187,14 @@ pub(crate) fn spawn(

match test_mode {
TestMode::DedicatedWorker { .. } => {
format!(
r#"
const worker = new Worker("worker.js", {{type: "{module}"}});
const port_send = worker;
const port_receive = worker;
"#
)
format!("const port = new Worker('worker.js', {{type: '{module}'}});\n")
}
TestMode::SharedWorker { .. } => {
format!(
r#"
const worker = new SharedWorker("worker.js?random=" + crypto.randomUUID(), {{type: "{module}"}});
const port_send = worker.port;
const port_receive = worker.port;
worker.port.start();
const port = worker.port;
port.start();
"#
)
}
Expand All @@ -220,9 +213,8 @@ pub(crate) fn spawn(
}});
const channel = new MessageChannel();
navigator.serviceWorker.controller.postMessage(undefined, [channel.port2]);
const port_send = channel.port1;
const port_receive = channel.port1;
channel.port1.start();
const port = channel.port1;
port.start();
"#
)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ macro_rules! console_log {
///
/// * `run_in_browser` - requires that this test is run in a browser rather than
/// node.js, which is the default for executing tests.
/// * `run_in_worker` - requires that this test is run in a web worker rather than
/// * `run_in_dedicated_worker` - requires that this test is run in a web worker rather than
/// node.js, which is the default for executing tests.
/// * `run_in_shared_worker` - requires that this test is run in a shared worker rather than
/// node.js, which is the default for executing tests.
Expand Down

0 comments on commit be94f88

Please sign in to comment.