aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/timers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/timers.rs')
-rw-r--r--components/script/timers.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/components/script/timers.rs b/components/script/timers.rs
index 14c4eb89c13..b86bdc17aae 100644
--- a/components/script/timers.rs
+++ b/components/script/timers.rs
@@ -228,18 +228,20 @@ impl OneshotTimers {
}
pub fn suspend(&self) {
- assert!(self.suspended_since.get().is_none());
+ // Suspend is idempotent: do nothing if the timers are already suspended.
+ if self.suspended_since.get().is_some() {
+ return warn!("Suspending an already suspended timer.");
+ }
self.suspended_since.set(Some(precise_time_ms()));
self.invalidate_expected_event_id();
}
pub fn resume(&self) {
- assert!(self.suspended_since.get().is_some());
-
+ // Suspend is idempotent: do nothing if the timers are already suspended.
let additional_offset = match self.suspended_since.get() {
Some(suspended_since) => precise_time_ms() - suspended_since,
- None => panic!("Timers are not suspended.")
+ None => return warn!("Resuming an already resumed timer."),
};
self.suspension_offset.set(self.suspension_offset.get() + additional_offset);