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 422536 2985d2ce41ad650a55e3b4204fe5e483d2e56b1f
parent 422535 07cda954e328926678f3ca362eaa17fec8efe190
child 422537 56381f46d1d93f0f0f72a5dafdefc8e00a23c5bd
push id104286
push userrgurzau@mozilla.com
push dateThu, 14 Jun 2018 15:25:50 +0000
treeherdermozilla-inbound@cf89498e0dec [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);
   }
 };