This repository has been archived by the owner on Feb 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #858 from erikvold/851161
Fix Bug 851161 preventing panels from being used with per-window private browsing r=@Gozala(cherry picked from commit 707eca7)
- Loading branch information
Showing
8 changed files
with
253 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* 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'; | ||
|
||
const { getMostRecentBrowserWindow, windows: getWindows } = require('../window/utils'); | ||
const { ignoreWindow } = require('../private-browsing/utils'); | ||
const { isPrivateBrowsingSupported } = require('../self'); | ||
|
||
function getWindow(anchor) { | ||
let window; | ||
let windows = getWindows("navigator:browser", { | ||
includePrivate: isPrivateBrowsingSupported | ||
}); | ||
|
||
if (anchor) { | ||
let anchorWindow = anchor.ownerDocument.defaultView.top; | ||
let anchorDocument = anchorWindow.document; | ||
|
||
// loop thru supported windows | ||
for each(let enumWindow in windows) { | ||
// Check if the anchor is in this browser window. | ||
if (enumWindow == anchorWindow) { | ||
window = anchorWindow; | ||
break; | ||
} | ||
|
||
// Check if the anchor is in a browser tab in this browser window. | ||
let browser = enumWindow.gBrowser.getBrowserForDocument(anchorDocument); | ||
if (browser) { | ||
window = enumWindow; | ||
break; | ||
} | ||
|
||
// Look in other subdocuments (sidebar, etc.)? | ||
} | ||
} | ||
|
||
// If we didn't find the anchor's window (or we have no anchor), | ||
// return the most recent browser window. | ||
if (!window) | ||
window = getMostRecentBrowserWindow(); | ||
|
||
// if the window is not supported, then it should be ignored | ||
if (ignoreWindow(window)) { | ||
return null; | ||
} | ||
|
||
return window; | ||
} | ||
exports.getWindow = getWindow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const { isWindowPBSupported } = require('sdk/private-browsing/utils'); | ||
|
||
if (isWindowPBSupported) { | ||
exports.testRequirePanel = function (assert) { | ||
try { | ||
require('panel'); | ||
} | ||
catch(e) { | ||
assert.ok(e.message.match(/Bug 816257/), 'Bug 816257 is mentioned'); | ||
return; | ||
} | ||
assert.fail('the panel module should throw an error'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.