Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 'use strict';
6 // The panel module currently supports only Firefox.
7 // See: https://bugzilla.mozilla.org/show_bug.cgi?id=jetpack-panel-apps
8 module.metadata = {
9 'stability': 'unstable',
10 'engines': {
11 'Firefox': '*'
12 }
13 };
15 const { getMostRecentBrowserWindow, windows: getWindows } = require('../window/utils');
16 const { ignoreWindow } = require('../private-browsing/utils');
17 const { isPrivateBrowsingSupported } = require('../self');
18 const { isGlobalPBSupported } = require('../private-browsing/utils');
20 function getWindow(anchor) {
21 let window;
22 let windows = getWindows("navigator:browser", {
23 includePrivate: isPrivateBrowsingSupported || isGlobalPBSupported
24 });
26 if (anchor) {
27 let anchorWindow = anchor.ownerDocument.defaultView.top;
28 let anchorDocument = anchorWindow.document;
30 // loop thru supported windows
31 for each(let enumWindow in windows) {
32 // Check if the anchor is in this browser window.
33 if (enumWindow == anchorWindow) {
34 window = anchorWindow;
35 break;
36 }
38 // Check if the anchor is in a browser tab in this browser window.
39 let browser = enumWindow.gBrowser.getBrowserForDocument(anchorDocument);
40 if (browser) {
41 window = enumWindow;
42 break;
43 }
45 // Look in other subdocuments (sidebar, etc.)?
46 }
47 }
49 // If we didn't find the anchor's window (or we have no anchor),
50 // return the most recent browser window.
51 if (!window)
52 window = getMostRecentBrowserWindow();
54 // if the window is not supported, then it should be ignored
55 if (ignoreWindow(window)) {
56 return null;
57 }
59 return window;
60 }
61 exports.getWindow = getWindow;