Backed out changeset f0112085d836 (bug 817337) for mochitest-5 orange

This commit is contained in:
Ehsan Akhgari 2012-12-06 10:33:36 -05:00
Родитель 1d4952b9bf
Коммит 8256529bce
3 изменённых файлов: 33 добавлений и 72 удалений

Просмотреть файл

@ -53,9 +53,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
XPCOMUtils.defineLazyModuleGetter(this, "KeywordURLResetPrompter",
"resource:///modules/KeywordURLResetPrompter.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
"resource:///modules/RecentWindow.jsm");
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
@ -1587,9 +1584,41 @@ BrowserGlue.prototype = {
}
},
#ifndef XP_WIN
#define BROKEN_WM_Z_ORDER
#endif
// this returns the most recent non-popup browser window
getMostRecentBrowserWindow: function BG_getMostRecentBrowserWindow() {
return RecentWindow.getMostRecentBrowserWindow();
function isFullBrowserWindow(win) {
return !win.closed &&
win.toolbar.visible;
}
#ifdef BROKEN_WM_Z_ORDER
var win = Services.wm.getMostRecentWindow("navigator:browser");
// if we're lucky, this isn't a popup, and we can just return this
if (win && !isFullBrowserWindow(win)) {
win = null;
let windowList = Services.wm.getEnumerator("navigator:browser");
// this is oldest to newest, so this gets a bit ugly
while (windowList.hasMoreElements()) {
let nextWin = windowList.getNext();
if (isFullBrowserWindow(nextWin))
win = nextWin;
}
}
return win;
#else
var windowList = Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
while (windowList.hasMoreElements()) {
let win = windowList.getNext();
if (isFullBrowserWindow(win))
return win;
}
return null;
#endif
},
#ifdef MOZ_SERVICES_SYNC

Просмотреть файл

@ -28,8 +28,6 @@ EXTRA_JS_MODULES = \
KeywordURLResetPrompter.jsm \
$(NULL)
EXTRA_PP_JS_MODULES = RecentWindow.jsm
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
EXTRA_JS_MODULES += \
WindowsPreviewPerTab.jsm \

Просмотреть файл

@ -1,66 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = ["RecentWindow"];
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
#ifndef XP_WIN
#define BROKEN_WM_Z_ORDER
#endif
this.RecentWindow = {
/*
* Get the most recent browser window.
*
* @param aOptions an object accepting the arguments for the search.
* Set the private property to true in order to restrict the
* search to private windows only, or to false in order to
* restrict the search to non-private windows only. To search
* in both groups, don't specify the private property.
*/
getMostRecentBrowserWindow: function RW_getMostRecentBrowserWindow(aOptions) {
let checkPrivacy = typeof aOptions == "object" &&
"private" in aOptions;
let wantPrivate = checkPrivacy && aOptions.private;
function isSuitableBrowserWindow(win) {
return (!win.closed &&
win.toolbar.visible &&
(!checkPrivacy ||
PrivateBrowsingUtils.isWindowPrivate(win) == wantPrivate));
}
#ifdef BROKEN_WM_Z_ORDER
let win = Services.wm.getMostRecentWindow("navigator:browser");
// if we're lucky, this isn't a popup, and we can just return this
if (win && !isSuitableBrowserWindow(win)) {
win = null;
let windowList = Services.wm.getEnumerator("navigator:browser");
// this is oldest to newest, so this gets a bit ugly
while (windowList.hasMoreElements()) {
let nextWin = windowList.getNext();
if (isSuitableBrowserWindow(nextWin))
win = nextWin;
}
}
return win;
#else
let windowList = Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
while (windowList.hasMoreElements()) {
let win = windowList.getNext();
if (isSuitableBrowserWindow(win))
return win;
}
return null;
#endif
}
};