Skip to content

Commit

Permalink
better handling of content script errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmayer committed Nov 23, 2012
1 parent 0a68e16 commit bdbe0be
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
65 changes: 50 additions & 15 deletions extension/data/content.js
Expand Up @@ -235,7 +235,12 @@ function makeObjectProxy(objectName, object) {
},

delete: function(name) {
return delete object[name];
try {
return delete object[name];
}
catch(error) {
return null;
}
},

fix: function() {
Expand All @@ -251,18 +256,28 @@ function makeObjectProxy(objectName, object) {
},

get: function(receiver, name) {
if(typeof object[name] == "function")
return makeFunctionProxy(object, objectName + "." + name, object[name]);
else {
logValue(objectName + "." + name, object[name], "get");
return object[name];
try {
if(typeof object[name] == "function")
return makeFunctionProxy(object, objectName + "." + name, object[name]);
else {
logValue(objectName + "." + name, object[name], "get");
return object[name];
}
}
catch(error) {
return null;
}
},

set: function(receiver, name, val) {
logValue(objectName + "." + name, val, "set");
object[name] = val;
return true;
try {
logValue(objectName + "." + name, val, "set");
object[name] = val;
return true;
}
catch(error) {
return false;
}
},

enumerate: function() {
Expand Down Expand Up @@ -312,7 +327,12 @@ function makeFunctionProxy(object, functionName, func) {
},

delete: function(name) {
return delete func[name];
try {
return delete func[name];
}
catch(error) {
return null;
}
},

fix: function() {
Expand All @@ -328,12 +348,22 @@ function makeFunctionProxy(object, functionName, func) {
},

get: function(receiver, name) {
return func[name];
try {
return func[name];
}
catch(error) {
return null;
}
},

set: function(receiver, name, val) {
func[name] = val;
return true;
try {
func[name] = val;
return true;
}
catch(error) {
return false;
}
},

enumerate: function() {
Expand All @@ -347,8 +377,13 @@ function makeFunctionProxy(object, functionName, func) {
}
},
function() {
logCall(functionName, arguments);
return func.apply(object, arguments);
try {
logCall(functionName, arguments);
return func.apply(object, arguments);
}
catch(error) {
return null;
}
},
function() {
return null;
Expand Down
Binary file modified extension/fourthparty.xpi
Binary file not shown.

0 comments on commit bdbe0be

Please sign in to comment.