Bug 1082450 - Fix quitter extension. r=gabor

This commit is contained in:
Bobby Holley 2014-10-15 15:05:08 +02:00
parent a0a87ae128
commit d8c553d744

View File

@ -4,19 +4,14 @@
var Ci = Components.interfaces; var Ci = Components.interfaces;
var Cc = Components.classes; var Cc = Components.classes;
var Cu = Components.utils;
function Quitter() { function Quitter() {
} }
Quitter.prototype = { Quitter.prototype = {
toString: function() { return "[Quitter]"; }, toString: function() { return "[Quitter]"; },
quit: function() { quit: function() { sendSyncMessage('Quitter.Quit', {}); }
sendSyncMessage('Quitter.Quit', {});
},
__exposedProps__: {
'toString': 'r',
'quit': 'r'
}
}; };
// This is a frame script, so it may be running in a content process. // This is a frame script, so it may be running in a content process.
@ -30,8 +25,12 @@ function QuitterManager() {
QuitterManager.prototype = { QuitterManager.prototype = {
handleEvent: function handleEvent(aEvent) { handleEvent: function handleEvent(aEvent) {
var quitter = new Quitter(window);
var window = aEvent.target.defaultView; var window = aEvent.target.defaultView;
window.wrappedJSObject.Quitter = new Quitter(window); window.wrappedJSObject.Quitter = Cu.cloneInto({
toString: quitter.toString.bind(quitter),
quit: quitter.quit.bind(quitter)
}, window, {cloneFunctions: true});
} }
}; };