forked from mirrors/gecko-dev
This patch gently removes support for __exposedProps__ by changing ExposedPropertiesOnly::check() to always return false, while still failing silently in deny for some kinds of access. The tests that I changed all involve testing the behavior with __exposedProps__. I adjusted them to expect it to fail, or to adjust the error message they get when they fail. That seemed better than deleting them entirely. Note that test_bug1065185.html had a bug, so that it never executed the first case. I fixed that, and then fixed up the test to work when __exposedProps__ is not supported. This also removes various bits of the test framework that use __exposedProps__, but don't actually need to. MozReview-Commit-ID: 8fvkAmITmXY --HG-- extra : rebase_source : ef7e2c55adc12511f17f3865ebb46c343875f0b3
68 lines
2 KiB
JavaScript
68 lines
2 KiB
JavaScript
/* 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 = {
|
|
"stability": "unstable"
|
|
};
|
|
|
|
const { Cc, Ci, Cu, Cr } = require("chrome");
|
|
const self = require("../self");
|
|
const prefs = require("../preferences/service");
|
|
const { merge } = require("../util/object");
|
|
const { ConsoleAPI } = Cu.import("resource://gre/modules/Console.jsm", {});
|
|
|
|
const DEFAULT_LOG_LEVEL = "error";
|
|
const ADDON_LOG_LEVEL_PREF = "extensions." + self.id + ".sdk.console.logLevel";
|
|
const SDK_LOG_LEVEL_PREF = "extensions.sdk.console.logLevel";
|
|
|
|
var logLevel = DEFAULT_LOG_LEVEL;
|
|
function setLogLevel() {
|
|
logLevel = prefs.get(ADDON_LOG_LEVEL_PREF,
|
|
prefs.get(SDK_LOG_LEVEL_PREF,
|
|
DEFAULT_LOG_LEVEL));
|
|
}
|
|
setLogLevel();
|
|
|
|
var logLevelObserver = {
|
|
QueryInterface: function(iid) {
|
|
if (!iid.equals(Ci.nsIObserver) &&
|
|
!iid.equals(Ci.nsISupportsWeakReference) &&
|
|
!iid.equals(Ci.nsISupports))
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
return this;
|
|
},
|
|
observe: function(subject, topic, data) {
|
|
setLogLevel();
|
|
}
|
|
};
|
|
var branch = Cc["@mozilla.org/preferences-service;1"].
|
|
getService(Ci.nsIPrefService).
|
|
getBranch(null);
|
|
branch.addObserver(ADDON_LOG_LEVEL_PREF, logLevelObserver, true);
|
|
branch.addObserver(SDK_LOG_LEVEL_PREF, logLevelObserver, true);
|
|
|
|
function PlainTextConsole(print, innerID) {
|
|
|
|
let consoleOptions = {
|
|
prefix: self.name,
|
|
maxLogLevel: logLevel,
|
|
dump: print,
|
|
innerID: innerID,
|
|
consoleID: "addon/" + self.id
|
|
};
|
|
let console = new ConsoleAPI(consoleOptions);
|
|
|
|
// As we freeze the console object, we can't modify this property afterward
|
|
Object.defineProperty(console, "maxLogLevel", {
|
|
get: function() {
|
|
return logLevel;
|
|
}
|
|
});
|
|
|
|
Object.freeze(console);
|
|
return console;
|
|
};
|
|
exports.PlainTextConsole = PlainTextConsole;
|