Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
bug 834961: no longer prevent opening of private windows in window/ut…
Browse files Browse the repository at this point in the history
…ils, it is prevented in high level windows module still however. Also fixing issues using the loader in test/private-browsing/helper
  • Loading branch information
erikvold committed Feb 21, 2013
1 parent 9d5669a commit 4a3bdea
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
4 changes: 0 additions & 4 deletions lib/sdk/window/utils.js
Expand Up @@ -151,8 +151,6 @@ function open(uri, options) {
serializeFeatures(options.features || {}),
options.args || null);

if (ignoreWindow(newWindow))
return undefined;
return newWindow;
}
exports.open = open;
Expand Down Expand Up @@ -234,8 +232,6 @@ function openDialog(options) {
])
);

if (ignoreWindow(newWindow))
return undefined;
return newWindow;
}
exports.openDialog = openDialog;
Expand Down
19 changes: 17 additions & 2 deletions test/private-browsing/helper.js
Expand Up @@ -26,8 +26,16 @@ require('sdk/private-browsing/window/utils');

function PBLoader(options) {
options = options || {};
let packaging = JSON.parse(JSON.stringify(require("@loader/options")));
packaging.metadata = merge(packaging.metadata, options.metadata);
let jpOptions = require("@loader/options");
let packaging = {
metadata: {}
};

shallowClone(jpOptions, packaging);
shallowClone(options, packaging);

shallowClone(jpOptions.metadata || {}, packaging.metadata);
shallowClone(options.metadata || {}, packaging.metadata);

let globals = {};
let errors = [];
Expand All @@ -53,6 +61,13 @@ function PBLoader(options) {
}
}

function shallowClone(source, target) {
for (let prop in source) {
if (!(prop in target))
target[prop] = source[prop];
}
}

function deactivate(callback) {
if (pbUtils.isGlobalPBSupported) {
if (callback)
Expand Down
35 changes: 33 additions & 2 deletions test/private-browsing/windows.js
Expand Up @@ -4,12 +4,14 @@
'use strict';

const { loader, pb, pbUtils } = require('./helper');
const { openDialog } = loader.require('window/utils');
const { openDialog, open } = loader.require('window/utils');

const { isPrivate } = require('sdk/private-browsing');
const { browserWindows: windows } = require('sdk/windows');


// test openDialog() from window/utils with private option
// test isActive state in pwpb case
// test isPrivate on ChromeWindow
exports.testPerWindowPrivateBrowsingGetter = function(assert, done) {
let win = openDialog({
private: true
Expand All @@ -20,6 +22,35 @@ exports.testPerWindowPrivateBrowsingGetter = function(assert, done) {

assert.equal(pbUtils.getMode(win),
true, 'Newly opened window is in PB mode');
assert.ok(isPrivate(win), 'isPrivate(window) is true');
assert.equal(pb.isActive, false, 'PB mode is not active');

win.addEventListener("unload", function onunload() {
win.removeEventListener('unload', onload, false);
assert.equal(pb.isActive, false, 'PB mode is not active');
done();
}, false);

win.close();
}, false);
}

// test open() from window/utils with private feature
// test isActive state in pwpb case
// test isPrivate on ChromeWindow
exports.testPerWindowPrivateBrowsingGetter = function(assert, done) {
let win = open('chrome://browser/content/browser.xul', {
features: {
private: true
}
});

win.addEventListener('DOMContentLoaded', function onload() {
win.removeEventListener('DOMContentLoaded', onload, false);

assert.equal(pbUtils.getMode(win),
true, 'Newly opened window is in PB mode');
assert.ok(isPrivate(win), 'isPrivate(window) is true');
assert.equal(pb.isActive, false, 'PB mode is not active');

win.addEventListener("unload", function onunload() {
Expand Down

0 comments on commit 4a3bdea

Please sign in to comment.