From 55d0ff9ce72c6d1845bfbc87f2a6daa1153a64c3 Mon Sep 17 00:00:00 2001 From: Infocatcher Date: Wed, 6 Jul 2016 10:58:17 +0300 Subject: [PATCH] Clarify logic: don't create global variables at all --- protocol-process.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/protocol-process.js b/protocol-process.js index ab82791..16f4142 100644 --- a/protocol-process.js +++ b/protocol-process.js @@ -1,13 +1,12 @@ -Components.utils.import("resource://gre/modules/Services.jsm"); -if(Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) { - Components.utils.import("chrome://privatetab/content/protocol.jsm"); +(function() { + var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {}); + if(Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_CONTENT) + return; + var {privateProtocol} = Components.utils.import("chrome://privatetab/content/protocol.jsm", {}); privateProtocol.init(function() {}); - let global = this; addMessageListener("PrivateTab:ProtocolDestroy", function destroy(msg) { removeMessageListener("PrivateTab:ProtocolDestroy", destroy); privateProtocol.destroy(); - delete global.Services; - delete global.privateProtocol; Components.utils.unload("chrome://privatetab/content/protocol.jsm"); }); -} \ No newline at end of file +})(); \ No newline at end of file