aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/bindings/global.rs10
-rw-r--r--components/script/dom/dedicatedworkerglobalscope.rs11
-rw-r--r--components/script/dom/window.rs13
-rw-r--r--components/script/dom/worker.rs1
-rw-r--r--components/script/dom/workerglobalscope.rs11
-rw-r--r--components/script/script_thread.rs6
-rw-r--r--tests/wpt/metadata/workers/semantics/encodings/004.worker.js.ini2
7 files changed, 42 insertions, 12 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs
index 7dea10fd0a0..304976e22a6 100644
--- a/components/script/dom/bindings/global.rs
+++ b/components/script/dom/bindings/global.rs
@@ -18,7 +18,7 @@ use ipc_channel::ipc::IpcSender;
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
-use msg::constellation_msg::{ConstellationChan, PipelineId};
+use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId};
use net_traits::ResourceThread;
use profile_traits::mem;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
@@ -263,6 +263,14 @@ impl<'a> GlobalRef<'a> {
GlobalRef::Worker(ref worker) => worker.reflector(),
}
}
+
+ /// Returns an `IpcSender` to report panics on.
+ pub fn panic_chan(&self) -> &IpcSender<PanicMsg> {
+ match *self {
+ GlobalRef::Window(ref window) => window.panic_chan(),
+ GlobalRef::Worker(ref worker) => worker.panic_chan(),
+ }
+ }
}
impl GlobalRoot {
diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs
index dbd127e79ee..42b2dad043a 100644
--- a/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/components/script/dom/dedicatedworkerglobalscope.rs
@@ -36,8 +36,7 @@ use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::sync::{Arc, Mutex};
use url::Url;
use util::str::DOMString;
-use util::thread::spawn_named;
-use util::thread_state;
+use util::thread::spawn_named_with_send_on_panic;
use util::thread_state::{IN_WORKER, SCRIPT};
/// Messages used to control the worker event loops
@@ -218,9 +217,9 @@ impl DedicatedWorkerGlobalScope {
own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>,
receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>) {
let serialized_worker_url = worker_url.to_string();
- spawn_named(format!("WebWorker for {}", serialized_worker_url), move || {
- thread_state::initialize(SCRIPT | IN_WORKER);
-
+ let name = format!("WebWorker for {}", serialized_worker_url);
+ let panic_chan = init.panic_chan.clone();
+ spawn_named_with_send_on_panic(name, SCRIPT | IN_WORKER, move || {
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
@@ -284,7 +283,7 @@ impl DedicatedWorkerGlobalScope {
global.handle_event(event);
}
}, reporter_name, parent_sender, CommonScriptMsg::CollectReports);
- });
+ }, Some(id.clone()), panic_chan);
}
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 46e07794dfd..679bdec49cf 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -42,7 +42,7 @@ use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
use libc;
-use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId};
+use msg::constellation_msg::{ConstellationChan, LoadData, PanicMsg, PipelineId, SubpageId};
use msg::constellation_msg::{WindowSizeData, WindowSizeType};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use net_traits::ResourceThread;
@@ -253,6 +253,9 @@ pub struct Window {
ignore_further_async_events: Arc<AtomicBool>,
error_reporter: CSSErrorReporter,
+
+ #[ignore_heap_size_of = "Defined in ipc-channel"]
+ panic_chan: IpcSender<PanicMsg>,
}
impl Window {
@@ -1275,6 +1278,10 @@ impl Window {
&self.scheduler_chan
}
+ pub fn panic_chan(&self) -> &IpcSender<PanicMsg> {
+ &self.panic_chan
+ }
+
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
self.timers.schedule_callback(callback,
duration,
@@ -1428,6 +1435,7 @@ impl Window {
constellation_chan: ConstellationChan<ConstellationMsg>,
control_chan: IpcSender<ConstellationControlMsg>,
scheduler_chan: IpcSender<TimerEventRequest>,
+ panic_chan: IpcSender<PanicMsg>,
timer_event_chan: IpcSender<TimerEvent>,
layout_chan: LayoutChan,
id: PipelineId,
@@ -1496,7 +1504,8 @@ impl Window {
devtools_wants_updates: Cell::new(false),
webdriver_script_chan: DOMRefCell::new(None),
ignore_further_async_events: Arc::new(AtomicBool::new(false)),
- error_reporter: error_reporter
+ error_reporter: error_reporter,
+ panic_chan: panic_chan,
};
WindowBinding::Wrap(runtime.cx(), win)
diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs
index 1c7fc6def0d..3750744a531 100644
--- a/components/script/dom/worker.rs
+++ b/components/script/dom/worker.rs
@@ -106,6 +106,7 @@ impl Worker {
from_devtools_sender: optional_sender,
constellation_chan: constellation_chan,
scheduler_chan: scheduler_chan,
+ panic_chan: global.panic_chan().clone(),
worker_id: worker_id,
closing: closing,
};
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index f518c22890e..adaf27abb18 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -21,7 +21,7 @@ use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, JSContext, JSRuntime, RootedValue};
use js::jsval::UndefinedValue;
use js::rust::Runtime;
-use msg::constellation_msg::{ConstellationChan, PipelineId};
+use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId};
use net_traits::{LoadContext, ResourceThread, load_whole_resource};
use profile_traits::mem;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
@@ -49,6 +49,7 @@ pub struct WorkerGlobalScopeInit {
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub scheduler_chan: IpcSender<TimerEventRequest>,
+ pub panic_chan: IpcSender<PanicMsg>,
pub worker_id: WorkerId,
pub closing: Arc<AtomicBool>,
}
@@ -94,6 +95,9 @@ pub struct WorkerGlobalScope {
#[ignore_heap_size_of = "Defined in std"]
scheduler_chan: IpcSender<TimerEventRequest>,
+
+ #[ignore_heap_size_of = "Defined in ipc-channel"]
+ panic_chan: IpcSender<PanicMsg>,
}
impl WorkerGlobalScope {
@@ -124,6 +128,7 @@ impl WorkerGlobalScope {
devtools_wants_updates: Cell::new(false),
constellation_chan: init.constellation_chan,
scheduler_chan: init.scheduler_chan,
+ panic_chan: init.panic_chan,
}
}
@@ -191,6 +196,10 @@ impl WorkerGlobalScope {
self.next_worker_id.set(WorkerId(id_num + 1));
worker_id
}
+
+ pub fn panic_chan(&self) -> &IpcSender<PanicMsg> {
+ &self.panic_chan
+ }
}
impl WorkerGlobalScopeMethods for WorkerGlobalScope {
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 73350bed207..228b2c6def4 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -59,7 +59,7 @@ use js::rust::Runtime;
use layout_interface::{ReflowQueryType};
use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan};
use mem::heap_size_of_self_and_children;
-use msg::constellation_msg::{ConstellationChan, LoadData};
+use msg::constellation_msg::{ConstellationChan, LoadData, PanicMsg};
use msg::constellation_msg::{PipelineId, PipelineNamespace};
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
use msg::webdriver_msg::WebDriverScriptCommand;
@@ -383,6 +383,8 @@ pub struct ScriptThread {
timer_event_port: Receiver<TimerEvent>,
content_process_shutdown_chan: IpcSender<()>,
+
+ panic_chan: IpcSender<PanicMsg>,
}
/// In the event of thread panic, all data on the stack runs its destructor. However, there
@@ -575,6 +577,7 @@ impl ScriptThread {
compositor: DOMRefCell::new(state.compositor),
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
+ panic_chan: state.panic_chan.0,
devtools_chan: state.devtools_chan,
devtools_port: devtools_port,
@@ -1450,6 +1453,7 @@ impl ScriptThread {
self.constellation_chan.clone(),
self.control_chan.clone(),
self.scheduler_chan.clone(),
+ self.panic_chan.clone(),
ipc_timer_event_chan,
incomplete.layout_chan,
incomplete.pipeline_id,
diff --git a/tests/wpt/metadata/workers/semantics/encodings/004.worker.js.ini b/tests/wpt/metadata/workers/semantics/encodings/004.worker.js.ini
index 6bc9d82e172..e4a34597ae2 100644
--- a/tests/wpt/metadata/workers/semantics/encodings/004.worker.js.ini
+++ b/tests/wpt/metadata/workers/semantics/encodings/004.worker.js.ini
@@ -1,3 +1,3 @@
[004.worker]
type: testharness
- expected: TIMEOUT
+ expected: CRASH