diff options
author | Pyfisch <pyfisch@gmail.com> | 2018-11-06 13:01:35 +0100 |
---|---|---|
committer | Pyfisch <pyfisch@gmail.com> | 2018-11-06 22:30:31 +0100 |
commit | cb07debcb6f3d3561177ce536c320986720791b7 (patch) | |
tree | ccac4d5a48b3112230f3fc2e873753dd7263e9fb /components/script/script_runtime.rs | |
parent | bf47f90da667e95eaffc8fee36ca8a88e72e276c (diff) | |
download | servo-cb07debcb6f3d3561177ce536c320986720791b7.tar.gz servo-cb07debcb6f3d3561177ce536c320986720791b7.zip |
Format remaining files
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 560e3fe571d..2625bb4d3ce 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -156,40 +156,51 @@ unsafe extern "C" fn promise_rejection_tracker( cx: *mut JSContext, promise: HandleObject, state: PromiseRejectionHandlingState, - _data: *mut c_void + _data: *mut c_void, ) { // TODO: Step 2 - If script's muted errors is true, terminate these steps. // Step 3. let global = GlobalScope::from_context(cx); - wrap_panic(AssertUnwindSafe(|| { - match state { - // Step 4. - PromiseRejectionHandlingState::Unhandled => { - global.add_uncaught_rejection(promise); - }, - // Step 5. - PromiseRejectionHandlingState::Handled => { - // Step 5-1. - if global.get_uncaught_rejections().borrow().contains(&Heap::boxed(promise.get())) { - global.remove_uncaught_rejection(promise); - return; - } - - // Step 5-2. - if !global.get_consumed_rejections().borrow().contains(&Heap::boxed(promise.get())) { - global.add_consumed_rejection(promise); - return; - } - - // Step 5-3. - global.remove_consumed_rejection(promise); - - // TODO: Step 5-4 - Queue a task to fire `rejectionhandled` event - } - }; - }), ()); + wrap_panic( + AssertUnwindSafe(|| { + match state { + // Step 4. + PromiseRejectionHandlingState::Unhandled => { + global.add_uncaught_rejection(promise); + }, + // Step 5. + PromiseRejectionHandlingState::Handled => { + // Step 5-1. + if global + .get_uncaught_rejections() + .borrow() + .contains(&Heap::boxed(promise.get())) + { + global.remove_uncaught_rejection(promise); + return; + } + + // Step 5-2. + if !global + .get_consumed_rejections() + .borrow() + .contains(&Heap::boxed(promise.get())) + { + global.add_consumed_rejection(promise); + return; + } + + // Step 5-3. + global.remove_consumed_rejection(promise); + + // TODO: Step 5-4 - Queue a task to fire `rejectionhandled` event + }, + }; + }), + (), + ); } #[allow(unsafe_code, unrooted_must_root)] @@ -201,11 +212,13 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) { // Step 2. if global.get_uncaught_rejections().borrow().len() > 0 { // Step 1. - let uncaught_rejections: Vec<TrustedPromise> = global.get_uncaught_rejections() + let uncaught_rejections: Vec<TrustedPromise> = global + .get_uncaught_rejections() .borrow() .iter() .map(|promise| { - let promise = Promise::new_with_js_promise(Handle::from_raw(promise.handle()), cx); + let promise = + Promise::new_with_js_promise(Handle::from_raw(promise.handle()), cx); TrustedPromise::new(promise) }) |