Skip to content

Commit

Permalink
Merge branch 'ticket1026' of git@github.com:arantius/greasemonkey
Browse files Browse the repository at this point in the history
  • Loading branch information
arantius committed Sep 16, 2009
2 parents 7904dbb + 99eb79a commit 37ff12a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/greasemonkey.js
Expand Up @@ -10,6 +10,21 @@ const appSvc = Cc["@mozilla.org/appshell/appShellService;1"]

const gmSvcFilename = Components.stack.filename;

const maxJSVersion = (function getMaxJSVersion() {
// Default to version 1.6, which FF1.5 and later support.
var jsVersion = 160;

var jsds = Cc["@mozilla.org/js/jsd/debugger-service;1"].getService()
.QueryInterface(Ci.jsdIDebuggerService);
jsds.on();
jsds.enumerateContexts({ enumerateContext: function(context) {
if (context.version > jsVersion) jsVersion = context.version;
}});
jsds.off();

return (jsVersion / 100).toString();
})();

function alert(msg) {
Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService)
Expand Down Expand Up @@ -327,7 +342,7 @@ var greasemonkeyService = {
try {
// workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=307984
var lineFinder = new Error();
Components.utils.evalInSandbox(code, sandbox);
Components.utils.evalInSandbox(code, sandbox, maxJSVersion);
} catch (e) { // catches errors while running the script code
try {
if (e && "return not in function" == e.message)
Expand Down

0 comments on commit 37ff12a

Please sign in to comment.