Reintroduce parent runtimes for worker threads.

This commit is contained in:
Josh Matthews 2018-12-02 14:58:15 -05:00
parent 644101e1e4
commit 367014a4ea
7 changed files with 49 additions and 14 deletions

View file

@ -47,7 +47,7 @@ use js::jsapi::{HandleObject, Heap};
use js::jsapi::{JSAutoCompartment, JSContext};
use js::panic::maybe_resume_unwind;
use js::rust::wrappers::Evaluate2;
use js::rust::{get_object_class, CompileOptionsWrapper, Runtime};
use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime};
use js::rust::{HandleValue, MutableHandleValue};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use msg::constellation_msg::PipelineId;
@ -711,6 +711,16 @@ impl GlobalScope {
unreachable!();
}
pub fn runtime_handle(&self) -> ParentRuntime {
if self.is::<Window>() {
ScriptThread::runtime_handle()
} else if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
worker.runtime_handle()
} else {
unreachable!()
}
}
/// Returns the ["current"] global object.
///
/// ["current"]: https://html.spec.whatwg.org/multipage/#current