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

Commit

Permalink
Merge pull request #605 from erikvold/801152
Browse files Browse the repository at this point in the history
Fix Bug 801152 Deprecate private-browsing activate/deactivate methods r=@Gozala(cherry picked from commit f4224c4)

Conflicts:

	packages/addon-kit/tests/test-private-browsing.js
	packages/api-utils/lib/private-browsing/utils.js
  • Loading branch information
erikvold authored and KWierso committed Oct 22, 2012
1 parent 630924a commit 3eafeed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
24 changes: 21 additions & 3 deletions packages/addon-kit/tests/test-private-browsing.js
Expand Up @@ -3,10 +3,28 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';

let pb = require("private-browsing");
let {Cc,Ci} = require("chrome");
let { Cc,Ci } = require("chrome");
const { Loader } = require('test-harness/loader');
const timer = require("timer");
let pb = LoaderWithHookedConsole().loader.require("private-browsing");

function LoaderWithHookedConsole() {
let errors = [];
let loader = Loader(module, {
console: Object.create(console, {
error: { value: function(e) {
if (!/DEPRECATED:/.test(e)) {
console.error(e);
}
}}
})
});

return {
loader: loader,
errors: errors
}
}

let pbService;
// Currently, only Firefox implements the private browsing service.
Expand Down Expand Up @@ -78,7 +96,7 @@ if (pbService) {
exports.testAutomaticUnload = function(test) {
test.waitUntilDone();
// Create another private browsing instance and unload it
let loader = Loader(module);
let { loader, errors } = LoaderWithHookedConsole();
let pb2 = loader.require("private-browsing");
let called = false;
pb2.on("start", function onStart() {
Expand Down
8 changes: 6 additions & 2 deletions packages/api-utils/lib/private-browsing/utils.js
@@ -1,7 +1,6 @@
/* 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';

module.metadata = {
Expand All @@ -14,6 +13,7 @@ const observers = require('api-utils/observer-service');
const { emit, on, once, off } = require('api-utils/event/core');
const { when: unload } = require('api-utils/unload');
const { getWindowLoadingContext } = require('api-utils/window/utils');
const { deprecateFunction } = require('../deprecate');

let deferredEmit = defer(emit);

Expand Down Expand Up @@ -53,7 +53,11 @@ let setMode = defer(function setMode(value, chromeWin) {
// default
return pbService && (pbService.privateBrowsingEnabled = value);
});
exports.setMode = setMode;
exports.setMode = deprecateFunction(
setMode,
'require("private-browsing").activate and require("private-browsing").deactivate ' +
'is deprecated.'
);

let getMode = function getMode(chromeWin) {
if (isWindowPBEnabled(chromeWin))
Expand Down

0 comments on commit 3eafeed

Please sign in to comment.