From af1546391c4a561eb26ccf9cd244b05aed9b5bfc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 22 May 2021 18:08:24 +0200 Subject: feat(extensions): BroadcastChannel WPT conformance Replaces the file-backed provider by an in-memory one because proper file locking is a hard problem that detracts from the proof of concept. Teach the WPT runner how to extract tests from .html files because all the relevant tests in test_util/wpt/webmessaging/broadcastchannel are inside basics.html and interface.html. --- runtime/build.rs | 5 ++++- runtime/examples/hello_runtime.rs | 2 ++ runtime/web_worker.rs | 8 +++++++- runtime/worker.rs | 8 +++++++- 4 files changed, 20 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/build.rs b/runtime/build.rs index 4fe89af3e..d228fffd6 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -52,7 +52,10 @@ fn create_runtime_snapshot(snapshot_path: &Path, files: Vec) { deno_crypto::init(None), deno_webgpu::init(false), deno_timers::init::(), - deno_broadcast_channel::init(), + deno_broadcast_channel::init( + deno_broadcast_channel::InMemoryBroadcastChannel::default(), + false, // No --unstable. + ), ]; let js_runtime = JsRuntime::new(RuntimeOptions { diff --git a/runtime/examples/hello_runtime.rs b/runtime/examples/hello_runtime.rs index 80a258c17..e8abaffb8 100644 --- a/runtime/examples/hello_runtime.rs +++ b/runtime/examples/hello_runtime.rs @@ -2,6 +2,7 @@ use deno_core::error::AnyError; use deno_core::FsModuleLoader; +use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel; use deno_runtime::deno_file::BlobUrlStore; use deno_runtime::permissions::Permissions; use deno_runtime::worker::MainWorker; @@ -42,6 +43,7 @@ async fn main() -> Result<(), AnyError> { location: None, location_data_dir: None, blob_url_store: BlobUrlStore::default(), + broadcast_channel: InMemoryBroadcastChannel::default(), }; let js_path = diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 172d24dea..c2356651e 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -7,6 +7,7 @@ use crate::metrics; use crate::ops; use crate::permissions::Permissions; use crate::tokio_util::create_basic_runtime; +use deno_broadcast_channel::InMemoryBroadcastChannel; use deno_core::error::AnyError; use deno_core::error::Context as ErrorContext; use deno_core::futures::channel::mpsc; @@ -230,6 +231,7 @@ pub struct WebWorkerOptions { pub no_color: bool, pub get_error_class_fn: Option, pub blob_url_store: BlobUrlStore, + pub broadcast_channel: InMemoryBroadcastChannel, } impl WebWorker { @@ -268,7 +270,10 @@ impl WebWorker { options.user_agent.clone(), options.ca_data.clone(), ), - deno_broadcast_channel::init(), + deno_broadcast_channel::init( + options.broadcast_channel.clone(), + options.unstable, + ), deno_crypto::init(options.seed), deno_webgpu::init(options.unstable), deno_timers::init::(), @@ -567,6 +572,7 @@ mod tests { no_color: true, get_error_class_fn: None, blob_url_store: BlobUrlStore::default(), + broadcast_channel: InMemoryBroadcastChannel::default(), }; let mut worker = WebWorker::from_options( diff --git a/runtime/worker.rs b/runtime/worker.rs index b41f0291c..9ffd0b5ab 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -7,6 +7,7 @@ use crate::js; use crate::metrics; use crate::ops; use crate::permissions::Permissions; +use deno_broadcast_channel::InMemoryBroadcastChannel; use deno_core::error::AnyError; use deno_core::error::Context as ErrorContext; use deno_core::futures::future::poll_fn; @@ -71,6 +72,7 @@ pub struct WorkerOptions { pub location: Option, pub location_data_dir: Option, pub blob_url_store: BlobUrlStore, + pub broadcast_channel: InMemoryBroadcastChannel, } impl MainWorker { @@ -107,7 +109,10 @@ impl MainWorker { ), deno_webstorage::init(options.location_data_dir.clone()), deno_crypto::init(options.seed), - deno_broadcast_channel::init(), + deno_broadcast_channel::init( + options.broadcast_channel.clone(), + options.unstable, + ), deno_webgpu::init(options.unstable), deno_timers::init::(), // Metrics @@ -296,6 +301,7 @@ mod tests { location: None, location_data_dir: None, blob_url_store: BlobUrlStore::default(), + broadcast_channel: InMemoryBroadcastChannel::default(), }; MainWorker::from_options(main_module, permissions, &options) -- cgit v1.2.3