From c34adb197a74043ae3a62275cef56c60ea2d7690 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 13 Mar 2016 11:37:41 +0100 Subject: [PATCH] Don't modify the global, shared scope in frame scripts --- extension/bootstrap.coffee | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/extension/bootstrap.coffee b/extension/bootstrap.coffee index 0993adc..f744e22 100644 --- a/extension/bootstrap.coffee +++ b/extension/bootstrap.coffee @@ -82,7 +82,7 @@ do (global = this) -> require.scopes = {} - global.startup = (args...) -> + startup = (args...) -> # `require` cannot be used outside of `startup` (except for in frame # scripts), so wait setting `require.data` until here. require.data = require('./require-data') @@ -90,7 +90,7 @@ do (global = this) -> main = if IS_FRAME_SCRIPT then './lib/main-frame' else './lib/main' require(main)(args...) - global.shutdown = -> + shutdown = -> for shutdownHandler in shutdownHandlers try shutdownHandler() @@ -105,10 +105,6 @@ do (global = this) -> scope[name] = null require.scopes = {} - global.install = -> - - global.uninstall = -> - if IS_FRAME_SCRIPT messageManager = require('./lib/message-manager') @@ -119,7 +115,12 @@ do (global = this) -> # been set to `null` by Firefox when this runs. If so, simply return. return unless ok and content? - global.startup() + startup() - messageManager.listenOnce('shutdown', global.shutdown) + messageManager.listenOnce('shutdown', shutdown) ) + else + global.startup = startup + global.shutdown = shutdown + global.install = -> + global.uninstall = -> -- 2.39.3