Bug 1466071: Part 1: Prevent orderedWindows from changing while iterating. r=mikedeboer
authorAdam Gashlin <agashlin@mozilla.com>
Tue, 05 Jun 2018 13:47:58 -0700
changeset 422546 2985d2ce41ad
parent 422545 07cda954e328
child 422547 56381f46d1d9
push id34138
push userdluca@mozilla.com
push date2018-06-15 02:39 +0000
treeherdermozilla-central@e51f8dbf0397 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1466071
milestone62.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
Bug 1466071: Part 1: Prevent orderedWindows from changing while iterating. r=mikedeboer
browser/modules/BrowserWindowTracker.jsm
--- a/browser/modules/BrowserWindowTracker.jsm
+++ b/browser/modules/BrowserWindowTracker.jsm
@@ -206,17 +206,19 @@ this.BrowserWindowTracker = {
   /**
    * Iterator property that yields window objects by z-index, in reverse order.
    * This means that the lastly focused window will the first item that is yielded.
    * Note: we only know the order of windows we're actively tracking, which
    * basically means _only_ browser windows.
    */
   orderedWindows: {
     * [Symbol.iterator]() {
-      for (let window of _trackedWindows)
+      // Clone the windows array immediately as it may change during iteration,
+      // we'd rather have an outdated order than skip/revisit windows.
+      for (let window of [..._trackedWindows])
         yield window;
     }
   },
 
   track(window) {
     return WindowHelper.addWindow(window);
   }
 };