diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 9e20b09ef20..b3bd5b1c396 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -809,11 +809,13 @@ impl ScriptThread { pub fn mark_document_with_no_blocked_loads(doc: &Document) { SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = unsafe { &*root.get().unwrap() }; - script_thread - .docs_with_no_blocking_loads - .borrow_mut() - .insert(Dom::from_ref(doc)); + unsafe { + if let Some(script_thread) = root.get() { + (*script_thread) + .docs_with_no_blocking_loads + .borrow_mut() + .insert(Dom::from_ref(doc)); + }} }) }