Bug 1428529 - ensure window.opener.Preferences is defined; r=jaws
authorMyk Melez <myk@mykzilla.org>
Mon, 08 Jan 2018 20:33:40 -0800
changeset 450101 453a923a261c9ef664778e7c548cffd18b3abcf1
parent 450100 722f664d592a2a9a6439260362e951dc76ceb950
child 450102 688c7cfe35d2807f17592f00aac43accaf7da69b
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1428529
milestone59.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 1428529 - ensure window.opener.Preferences is defined; r=jaws MozReview-Commit-ID: DNvpuQplNgb
browser/base/content/test/general/browser_sanitizeDialog.js
toolkit/content/preferencesBindings.js
--- a/browser/base/content/test/general/browser_sanitizeDialog.js
+++ b/browser/base/content/test/general/browser_sanitizeDialog.js
@@ -814,17 +814,26 @@ WindowHelper.prototype = {
             await wh.onunload();
           }
           await PlacesTestUtils.promiseAsyncUpdates();
           wh._resolveClosed();
         })();
       });
     }
     Services.ww.registerNotification(windowObserver);
-    Services.ww.openWindow(null,
+
+    let browserWin = null;
+    if (Services.appinfo.OS !== "Darwin") {
+      // Retrieve the browser window so we can specify it as the parent
+      // of the dialog to simulate the way the user opens the dialog
+      // on Windows and Linux.
+      browserWin = Services.wm.getMostRecentWindow("navigator:browser");
+    }
+
+    Services.ww.openWindow(browserWin,
                            "chrome://browser/content/sanitize.xul",
                            "SanitizeDialog",
                            "chrome,titlebar,dialog,centerscreen,modal",
                            null);
   },
 
   /**
    * Selects a duration in the duration dropdown.
--- a/toolkit/content/preferencesBindings.js
+++ b/toolkit/content/preferencesBindings.js
@@ -297,16 +297,17 @@ const Preferences = window.Preferences =
         throw new Error(`preference with id '${id}' doesn't have name`);
       }
 
       // In non-instant apply mode, we must try and use the last saved state
       // from any previous opens of a child dialog instead of the value from
       // preferences, to pick up any edits a user may have made.
 
       if (Preferences.type == "child" && window.opener &&
+          window.opener.Preferences &&
           Services.scriptSecurityManager.isSystemPrincipal(window.opener.document.nodePrincipal)) {
         // Try to find the preference in the parent window.
         const preference = window.opener.Preferences.get(this.name);
 
         // Don't use the value setter here, we don't want updateElements to be
         // prematurely fired.
         this._value = preference ? preference.value : this.valueFromPreferences;
       } else