Fixing Intermittent failure in pages with timers

Fixes #4923
This commit is contained in:
Prabhjyot Singh Sodhi 2015-02-18 17:17:16 +05:30
parent b589735b47
commit cc48797999
8 changed files with 24 additions and 21 deletions

View file

@ -114,7 +114,7 @@ impl<T: Reflectable> Drop for Trusted<T> {
*refcount -= 1;
if *refcount == 0 {
self.script_chan.send(
ScriptMsg::RefcountCleanup(TrustedReference(self.ptr)));
ScriptMsg::RefcountCleanup(TrustedReference(self.ptr))).unwrap();
}
}
}

View file

@ -49,8 +49,8 @@ pub struct SendableWorkerScriptChan {
}
impl ScriptChan for SendableWorkerScriptChan {
fn send(&self, msg: ScriptMsg) {
self.sender.send((self.worker.clone(), msg)).unwrap();
fn send(&self, msg: ScriptMsg) -> Result<(), ()> {
return self.sender.send((self.worker.clone(), msg)).map_err(|_| ());
}
fn clone(&self) -> Box<ScriptChan + Send> {
@ -147,7 +147,7 @@ impl DedicatedWorkerGlobalScope {
Err(_) => {
println!("error loading script {}", worker_url.serialize());
parent_sender.send(ScriptMsg::RunnableMsg(
box WorkerEventHandler::new(worker)));
box WorkerEventHandler::new(worker))).unwrap();
return;
}
Ok((metadata, bytes)) => {
@ -235,7 +235,7 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerG
let col_num = errorevent.Colno();
let worker = self.worker.borrow().as_ref().unwrap().clone();
self.parent_sender.send(ScriptMsg::WorkerDispatchErrorEvent(worker, msg, file_name,
line_num, col_num));
line_num, col_num)).unwrap();
}
}
@ -244,7 +244,7 @@ impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalSc
let data = try!(StructuredCloneData::write(cx, message));
let worker = self.worker.borrow().as_ref().unwrap().clone();
self.parent_sender.send(ScriptMsg::RunnableMsg(
box WorkerMessageHandler::new(worker, data)));
box WorkerMessageHandler::new(worker, data))).unwrap();
Ok(())
}

View file

@ -215,7 +215,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
}
// This is wrong. https://html.spec.whatwg.org/multipage/forms.html#planned-navigation
win.r().script_chan().send(ScriptMsg::TriggerLoad(win.r().page().id, load_data));
win.r().script_chan().send(ScriptMsg::TriggerLoad(win.r().page().id, load_data)).unwrap();
}
fn get_form_dataset<'b>(self, submitter: Option<FormSubmitter<'b>>) -> Vec<FormDatum> {

View file

@ -257,7 +257,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
ScriptOrigin::Internal => {
let chan = window.script_chan();
let handler = Trusted::new(window.get_cx(), self, chan.clone());
chan.send(ScriptMsg::RunnableMsg(box handler));
chan.send(ScriptMsg::RunnableMsg(box handler)).unwrap();
}
}
}
@ -268,7 +268,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
let window = window.r();
let chan = window.script_chan();
let handler = Trusted::new(window.get_cx(), self, chan.clone());
chan.send(ScriptMsg::RunnableMsg(box handler));
chan.send(ScriptMsg::RunnableMsg(box handler)).unwrap();
}
fn dispatch_load_event(self) {

View file

@ -197,7 +197,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
}
fn Close(self) {
self.script_chan.send(ScriptMsg::ExitWindow(self.page.id.clone()));
self.script_chan.send(ScriptMsg::ExitWindow(self.page.id.clone())).unwrap();
}
fn Document(self) -> Temporary<Document> {
@ -387,10 +387,10 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
let url = url.unwrap();
match url.fragment {
Some(fragment) => {
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment));
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment)).unwrap();
},
None => {
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url))).unwrap();
}
}
}

View file

@ -220,7 +220,7 @@ impl XMLHttpRequest {
xhr.process_partial_response(msg);
},
SyncOrAsync::Async(ref addr, ref script_chan) => {
script_chan.send(ScriptMsg::RunnableMsg(box XHRProgressHandler::new(addr.clone(), msg)));
script_chan.send(ScriptMsg::RunnableMsg(box XHRProgressHandler::new(addr.clone(), msg))).unwrap();
}
}
}