summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2021-05-22 18:08:24 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2021-05-23 15:16:42 +0200
commitaf1546391c4a561eb26ccf9cd244b05aed9b5bfc (patch)
tree6c3a07150dd2dc4a3ea712c21c74585e6bca0bab /runtime
parent8cf7f966f24d0fb996b41d92b04ad9647337a8f6 (diff)
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.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/build.rs5
-rw-r--r--runtime/examples/hello_runtime.rs2
-rw-r--r--runtime/web_worker.rs8
-rw-r--r--runtime/worker.rs8
4 files changed, 20 insertions, 3 deletions
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<PathBuf>) {
deno_crypto::init(None),
deno_webgpu::init(false),
deno_timers::init::<deno_timers::NoTimersPermission>(),
- 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<GetErrorClassFn>,
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::<Permissions>(),
@@ -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<Url>,
pub location_data_dir: Option<std::path::PathBuf>,
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::<Permissions>(),
// 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)