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 #894 from erikvold/839746-4-stabilization
Bug 839746 for stabilization: global private windows are not ignored r=@Gozala
- Loading branch information
Showing
14 changed files
with
656 additions
and
175 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
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
153 changes: 153 additions & 0 deletions
153
test/addons/private-browsing-supported/test-global-private-browsing.js
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,153 @@ | ||
/* 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 windowUtils = require('sdk/deprecated/window-utils'); | ||
const { isWindowPBSupported, isGlobalPBSupported } = require('sdk/private-browsing/utils'); | ||
const { getFrames, getWindowTitle, onFocus, isWindowPrivate, windows, isBrowser } = require('sdk/window/utils'); | ||
const { open, close, focus } = require('sdk/window/helpers'); | ||
const { isPrivate } = require('sdk/private-browsing'); | ||
const { Panel } = require('sdk/panel'); | ||
const { Widget } = require('sdk/widget'); | ||
const { fromIterator: toArray } = require('sdk/util/array'); | ||
|
||
let { LoaderWithHookedConsole } = require('sdk/test/loader'); | ||
let { loader } = LoaderWithHookedConsole(module, function() {}); | ||
const pb = loader.require('sdk/private-browsing'); | ||
|
||
function makeEmptyBrowserWindow(options) { | ||
options = options || {}; | ||
return open('chrome://browser/content/browser.xul', { | ||
features: { | ||
chrome: true, | ||
private: !!options.private, | ||
toolbar: true | ||
} | ||
}); | ||
} | ||
|
||
exports.testShowPanelAndWidgetOnPrivateWindow = function(assert, done) { | ||
var myPrivateWindow; | ||
var finished = false; | ||
var privateWindow; | ||
var privateWindowClosed = false; | ||
|
||
pb.once('start', function() { | ||
assert.pass('private browsing mode started'); | ||
|
||
// make a new private window | ||
makeEmptyBrowserWindow().then(function(window) { | ||
myPrivateWindow = window; | ||
|
||
let wt = windowUtils.WindowTracker({ | ||
onTrack: function(window) { | ||
if (!isBrowser(window) || window !== myPrivateWindow) return; | ||
|
||
assert.ok(isWindowPrivate(window), 'window is private onTrack!'); | ||
let panel = Panel({ | ||
onShow: function() { | ||
assert.ok(this.isShowing, 'the panel is showing on the private window'); | ||
|
||
let count = 0; | ||
let widget = Widget({ | ||
id: "testShowPanelAndWidgetOnPrivateWindow-id", | ||
label: "My Hello Widget", | ||
content: "Hello!", | ||
onAttach: function(mod) { | ||
count++; | ||
if (count == 2) { | ||
panel.destroy(); | ||
widget.destroy(); | ||
close(window); | ||
} | ||
} | ||
}); | ||
} | ||
}).show(window.gBrowser); | ||
}, | ||
onUntrack: function(window) { | ||
if (window === myPrivateWindow) { | ||
wt.unload(); | ||
|
||
pb.once('stop', function() { | ||
assert.pass('private browsing mode end'); | ||
done(); | ||
}); | ||
|
||
pb.deactivate(); | ||
} | ||
} | ||
}); | ||
|
||
assert.equal(isWindowPrivate(window), true, 'the opened window is private'); | ||
assert.equal(isPrivate(window), true, 'the opened window is private'); | ||
assert.ok(getFrames(window).length > 1, 'there are frames for private window'); | ||
assert.equal(getWindowTitle(window), window.document.title, | ||
'getWindowTitle works'); | ||
}); | ||
}); | ||
pb.activate(); | ||
}; | ||
|
||
exports.testWindowTrackerDoesNotIgnorePrivateWindows = function(assert, done) { | ||
var myPrivateWindow; | ||
var count = 0; | ||
|
||
let wt = windowUtils.WindowTracker({ | ||
onTrack: function(window) { | ||
if (!isBrowser(window) || !isWindowPrivate(window)) return; | ||
assert.ok(isWindowPrivate(window), 'window is private onTrack!'); | ||
if (++count == 1) | ||
close(window); | ||
}, | ||
onUntrack: function(window) { | ||
if (count == 1 && isWindowPrivate(window)) { | ||
wt.unload(); | ||
|
||
pb.once('stop', function() { | ||
assert.pass('private browsing mode end'); | ||
done(); | ||
}); | ||
pb.deactivate(); | ||
} | ||
} | ||
}); | ||
|
||
pb.once('start', function() { | ||
assert.pass('private browsing mode started'); | ||
makeEmptyBrowserWindow(); | ||
}); | ||
pb.activate(); | ||
} | ||
|
||
exports.testWindowIteratorDoesNotIgnorePrivateWindows = function(assert, done) { | ||
pb.once('start', function() { | ||
// make a new private window | ||
makeEmptyBrowserWindow().then(function(window) { | ||
assert.ok(isWindowPrivate(window), "window is private"); | ||
assert.equal(isPrivate(window), true, 'the opened window is private'); | ||
assert.ok(toArray(windowUtils.windowIterator()).indexOf(window) > -1, | ||
"window is in windowIterator()"); | ||
assert.ok(windows(null, { includePrivate: true }).indexOf(window) > -1, | ||
"window is in windows()"); | ||
|
||
close(window).then(function() { | ||
pb.once('stop', function() { | ||
done(); | ||
}); | ||
pb.deactivate(); | ||
}); | ||
}); | ||
}); | ||
pb.activate(); | ||
}; | ||
|
||
if (!isGlobalPBSupported) { | ||
module.exports = { | ||
"test Unsupported Test": function UnsupportedTest (assert) { | ||
assert.pass( | ||
"Skipping global private browsing tests"); | ||
} | ||
} | ||
} |
Oops, something went wrong.