servo: Merge #18370 - An observer disconnected after a mark must receive the mark (from pylbrecht:observer); r=ferjm
authorP. Albrecht <palbrecht@mailbox.org>
Fri, 08 Sep 2017 13:04:26 -0500
changeset 429303 b0d2e384b6e0842e523b1922659c3a8f0c2d8ee4
parent 429302 5ec55a721cf1330726e89f588696692d064d5c0e
child 429304 d923714255be7364e9c60487942c5c918c88d3e9
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersferjm
bugs18370, 18283, 18284
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18370 - An observer disconnected after a mark must receive the mark (from pylbrecht:observer); r=ferjm <!-- Please describe your changes on the following line: --> I worked on top of #18283 as suggested [here](https://github.com/servo/servo/issues/18284#issuecomment-326043873). r? @ferjm <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #18284 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 867d542261336d918177f8780ef915b7ec84e3ba
servo/components/script/dom/performance.rs
--- a/servo/components/script/dom/performance.rs
+++ b/servo/components/script/dom/performance.rs
@@ -177,16 +177,25 @@ impl Performance {
 
     /// Remove a PerformanceObserver from the list of observers.
     pub fn remove_observer(&self, observer: &DOMPerformanceObserver) {
         let mut observers = self.observers.borrow_mut();
         let index = match observers.iter().position(|o| &(*o.observer) == observer) {
             Some(p) => p,
             None => return,
         };
+
+        if self.pending_notification_observers_task.get() {
+            if let Some(o) = observers.iter().nth(index) {
+                DOMPerformanceObserver::new(&self.global(),
+                                            o.observer.callback(),
+                                            o.observer.entries()).notify();
+            }
+        }
+
         observers.remove(index);
     }
 
     /// Queue a notification for each performance observer interested in
     /// this type of performance entry and queue a low priority task to
     /// notify the observers if no other notification task is already queued.
     ///
     /// Algorithm spec: