Bug 985652 - Only register pref actor on b2g if certified is allowed. r=ochameau

This commit is contained in:
"J. Ryan Stinnett" 2014-03-26 10:43:44 -07:00
parent 1474af8de3
commit 997536266b
4 changed files with 2 additions and 43 deletions

View File

@ -1154,7 +1154,6 @@ let RemoteDebugger = {
globalActorFactories: restrictPrivileges ? {
webappsActor: DebuggerServer.globalActorFactories.webappsActor,
deviceActor: DebuggerServer.globalActorFactories.deviceActor,
preferenceActor: DebuggerServer.globalActorFactories.preferenceActor,
} : DebuggerServer.globalActorFactories
};
let root = new DebuggerServer.RootActor(connection, parameters);

View File

@ -20,23 +20,7 @@ exports.unregister = function(handle) {
let PreferenceActor = protocol.ActorClass({
typeName: "preference",
_arePrefsAccessible: function() {
// We are using the authorization to debug certified apps as a proxy for the
// authorization to read and write preferences. We also perform this check
// inside every operation.
return !Services.prefs.getBoolPref("devtools.debugger.forbid-certified-apps");
},
arePrefsAccessible: method(function() {
return this._arePrefsAccessible();
}, {
request: {},
response: { value: RetVal("boolean") },
}),
getBoolPref: method(function(name) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
return Services.prefs.getBoolPref(name);
}, {
request: { value: Arg(0) },
@ -44,9 +28,6 @@ let PreferenceActor = protocol.ActorClass({
}),
getCharPref: method(function(name) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
return Services.prefs.getCharPref(name);
}, {
request: { value: Arg(0) },
@ -54,9 +35,6 @@ let PreferenceActor = protocol.ActorClass({
}),
getIntPref: method(function(name) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
return Services.prefs.getIntPref(name);
}, {
request: { value: Arg(0) },
@ -64,9 +42,6 @@ let PreferenceActor = protocol.ActorClass({
}),
getAllPrefs: method(function() {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
let prefs = {};
Services.prefs.getChildList("").forEach(function(name, index) {
// append all key/value pairs into a huge json object.
@ -99,9 +74,6 @@ let PreferenceActor = protocol.ActorClass({
}),
setBoolPref: method(function(name, value) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
Services.prefs.setBoolPref(name, value);
Services.prefs.savePrefFile(null);
}, {
@ -110,9 +82,6 @@ let PreferenceActor = protocol.ActorClass({
}),
setCharPref: method(function(name, value) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
Services.prefs.setCharPref(name, value);
Services.prefs.savePrefFile(null);
}, {
@ -121,9 +90,6 @@ let PreferenceActor = protocol.ActorClass({
}),
setIntPref: method(function(name, value) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
Services.prefs.setIntPref(name, value);
Services.prefs.savePrefFile(null);
}, {
@ -132,9 +98,6 @@ let PreferenceActor = protocol.ActorClass({
}),
clearUserPref: method(function(name) {
if (!this._arePrefsAccessible()) {
throw new Error("Operation not permitted");
}
Services.prefs.clearUserPref(name);
Services.prefs.savePrefFile(null);
}, {

View File

@ -357,11 +357,11 @@ var DebuggerServer = {
if (!restrictPrivileges) {
this.addTabActors();
this.addGlobalActor(this.ChromeDebuggerActor, "chromeDebugger");
this.registerModule("devtools/server/actors/preference");
}
this.addActors("resource://gre/modules/devtools/server/actors/webapps.js");
this.registerModule("devtools/server/actors/device");
this.registerModule("devtools/server/actors/preference");
},
/**

View File

@ -38,7 +38,6 @@ function runTests() {
var prefs = {};
var localPref = {
accessible: true,
boolPref: true,
intPref: 0x1234,
charPref: "Hello World",
@ -46,7 +45,6 @@ function runTests() {
function checkValues() {
is(prefs.accessible, localPref.accessible, "preference is accessible");
is(prefs.boolPref, localPref.boolPref, "read/write bool pref");
is(prefs.intPref, localPref.intPref, "read/write int pref");
is(prefs.charPref, localPref.charPref, "read/write string pref");
@ -83,8 +81,7 @@ function runTests() {
}
p.arePrefsAccessible().then((value) => prefs["accessible"] = value)
.then(() => p.getAllPrefs()).then((json) => prefs["allPrefs"] = json)
p.getAllPrefs().then((json) => prefs["allPrefs"] = json)
.then(() => p.setBoolPref("test.bool", localPref.boolPref))
.then(() => p.setIntPref("test.int", localPref.intPref))
.then(() => p.setCharPref("test.string", localPref.charPref))