Changeset 626
- Timestamp:
- 01/19/08 14:26:38 (11 months ago)
- Files:
-
- trunk/src/chrome/chromeFiles/content/menucommander.js (modified) (1 diff)
- trunk/src/chrome/chromeFiles/content/utils.js (modified) (1 diff)
- trunk/src/components/greasemonkey.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/chrome/chromeFiles/content/menucommander.js
r605 r626 20 20 GM_MenuCommander.prototype.registerMenuCommand = 21 21 function(commandName, commandFunc, accelKey, accelModifiers, accessKey) { 22 GM_apiLeakCheck();23 24 22 GM_log("> GM_MenuCommander.registerMenuCommand"); 25 23 trunk/src/chrome/chromeFiles/content/utils.js
r611 r626 6 6 var GM_consoleService = Components.classes["@mozilla.org/consoleservice;1"] 7 7 .getService(Components.interfaces.nsIConsoleService); 8 9 function GM_apiLeakCheck() {10 var stack = Components.stack;11 12 do {13 if (2 == stack.language) {14 if ('file' != stack.filename.substr(0, 4) &&15 'chrome' != stack.filename.substr(0, 6)) {16 throw new Error("Greasemonkey access violation");17 }18 }19 20 stack = stack.caller;21 } while (stack);22 };23 8 24 9 function GM_isDef(thing) { trunk/src/components/greasemonkey.js
r624 r626 13 13 .getService(Ci.nsIPromptService) 14 14 .alert(null, "Greasemonkey alert", msg); 15 }; 16 17 // Examines the stack to determine if an API should be callable. 18 // NOTE: This function's mechanism relies on the fact that it is implemented 19 // in this file. 20 function GM_apiLeakCheck() { 21 var stack = Components.stack; 22 var gmSvcFilename = stack.filename; 23 24 do { 25 // Valid stack frames for GM api calls are: native and js when coming from 26 // chrome:// URLs and the greasemonkey.js component's file:// URL. 27 if (2 == stack.language) { 28 if ('chrome' != stack.filename.substr(0, 6) && 29 gmSvcFilename != stack.filename) { 30 throw new Error("Greasemonkey access violation"); 31 } 32 } 33 34 stack = stack.caller; 35 } while (stack); 15 36 }; 16 37 … … 314 335 registerMenuCommand: function(unsafeContentWin, commandName, commandFunc, 315 336 accelKey, accelModifiers, accessKey) { 337 GM_apiLeakCheck(); 338 316 339 var command = {name: commandName, 317 340 accelKey: accelKey,
