aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/hud.coffee3
-rw-r--r--content_scripts/link_hints.coffee3
-rw-r--r--content_scripts/marks.coffee3
-rw-r--r--content_scripts/mode.coffee3
-rw-r--r--content_scripts/mode_find.coffee3
-rw-r--r--content_scripts/mode_insert.coffee3
-rw-r--r--content_scripts/mode_key_handler.coffee3
-rw-r--r--content_scripts/mode_visual.coffee3
-rw-r--r--content_scripts/scroller.coffee3
-rw-r--r--content_scripts/ui_component.coffee3
-rw-r--r--content_scripts/vimium_frontend.coffee22
-rw-r--r--content_scripts/vomnibar.coffee3
-rw-r--r--lib/clipboard.coffee3
-rw-r--r--lib/dom_utils.coffee3
-rw-r--r--lib/find_mode_history.coffee3
-rw-r--r--lib/handler_stack.coffee3
-rw-r--r--lib/keyboard_utils.coffee3
-rw-r--r--lib/rect.coffee3
-rw-r--r--lib/settings.coffee3
-rw-r--r--lib/utils.coffee5
20 files changed, 54 insertions, 27 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee
index c2170914..6185d786 100644
--- a/content_scripts/hud.coffee
+++ b/content_scripts/hud.coffee
@@ -127,5 +127,6 @@ class Tween
}
"""
-root = exports ? window
+root = exports ? (window.root ?= {})
root.HUD = HUD
+extend window, root unless exports?
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index f3e0ac84..8b5bb8d9 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -897,8 +897,9 @@ class WaitForEnter extends Mode
@exit()
callback false # false -> isSuccess.
-root = exports ? window
+root = exports ? (window.root ?= {})
root.LinkHints = LinkHints
root.HintCoordinator = HintCoordinator
# For tests:
extend root, {LinkHintsMode, LocalHints, AlphabetHints, WaitForEnter}
+extend window, root unless exports?
diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee
index 6eab3be6..55f3137c 100644
--- a/content_scripts/marks.coffee
+++ b/content_scripts/marks.coffee
@@ -84,5 +84,6 @@ Marks =
@showMessage "Local mark not set", keyChar
DomUtils.consumeKeyup event
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Marks = Marks
+extend window, root unless exports?
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 9de423ff..2057d093 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -209,5 +209,6 @@ class SuppressAllKeyboardEvents extends Mode
suppressAllKeyboardEvents: true
super extend defaults, options
-root = exports ? window
+root = exports ? (window.root ?= {})
extend root, {Mode, SuppressAllKeyboardEvents}
+extend window, root unless exports?
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee
index 5a2da741..5238ab34 100644
--- a/content_scripts/mode_find.coffee
+++ b/content_scripts/mode_find.coffee
@@ -215,6 +215,7 @@ getCurrentRange = ->
selection.collapseToStart() if selection.type == "Range"
selection.getRangeAt 0
-root = exports ? window
+root = exports ? (window.root ?= {})
root.PostFindMode = PostFindMode
root.FindMode = FindMode
+extend window, root unless exports?
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee
index 1dc66d52..a43a129f 100644
--- a/content_scripts/mode_insert.coffee
+++ b/content_scripts/mode_insert.coffee
@@ -129,6 +129,7 @@ class PassNextKeyMode extends Mode
@exit()
@passEventToPage
-root = exports ? window
+root = exports ? (window.root ?= {})
root.InsertMode = InsertMode
root.PassNextKeyMode = PassNextKeyMode
+extend window, root unless exports?
diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee
index 1b3b21e7..0e84b9fb 100644
--- a/content_scripts/mode_key_handler.coffee
+++ b/content_scripts/mode_key_handler.coffee
@@ -93,5 +93,6 @@ class KeyHandlerMode extends Mode
@exit() if @options.count? and --@options.count <= 0
@suppressEvent
-root = exports ? window
+root = exports ? (window.root ?= {})
root.KeyHandlerMode = KeyHandlerMode
+extend window, root unless exports?
diff --git a/content_scripts/mode_visual.coffee b/content_scripts/mode_visual.coffee
index 28097005..f99e42f9 100644
--- a/content_scripts/mode_visual.coffee
+++ b/content_scripts/mode_visual.coffee
@@ -380,6 +380,7 @@ class CaretMode extends VisualMode
return true
false
-root = exports ? window
+root = exports ? (window.root ?= {})
root.VisualMode = VisualMode
root.VisualLineMode = VisualLineMode
+extend window, root unless exports?
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee
index 56862d49..4a6c7edf 100644
--- a/content_scripts/scroller.coffee
+++ b/content_scripts/scroller.coffee
@@ -301,5 +301,6 @@ Scroller =
element = findScrollableElement element, "x", amount, 1
CoreScroller.scroll element, "x", amount, false
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Scroller = Scroller
+extend window, root unless exports?
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee
index 203f0c8c..c71bfb35 100644
--- a/content_scripts/ui_component.coffee
+++ b/content_scripts/ui_component.coffee
@@ -96,5 +96,6 @@ class UIComponent
@options = null
@postMessage "hidden" # Inform the UI component that it is hidden.
-root = exports ? window
+root = exports ? (window.root ?= {})
root.UIComponent = UIComponent
+extend window, root unless exports?
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 96ce81a3..0beb2110 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -2,6 +2,12 @@
# This content script must be run prior to domReady so that we perform some operations very early.
#
+root = exports ? (window.root ?= {})
+# On Firefox, sometimes the variables assigned to window are lost (bug 1408996), so we reinstall them.
+# NOTE(mrmr1993): This bug leads to catastrophic failure (ie. nothing works and errors abound).
+DomUtils.documentReady ->
+ (extend ? root.extend) window, root
+
isEnabledForUrl = true
isIncognitoMode = chrome.extension.inIncognitoContext
normalMode = null
@@ -245,7 +251,7 @@ Frame =
postMessage: (handler, request = {}) -> @port.postMessage extend request, {handler}
linkHintsMessage: (request) -> HintCoordinator[request.messageType] request
registerFrameId: ({chromeFrameId}) ->
- frameId = window.frameId = chromeFrameId
+ frameId = root.frameId = window.frameId = chromeFrameId
# We register a frame immediately only if it is focused or its window isn't tiny. We register tiny
# frames later, when necessary. This affects focusFrame() and link hints.
if windowIsFocused() or not DomUtils.windowIsTooSmall()
@@ -327,7 +333,7 @@ focusThisFrame = (request) ->
document.activeElement.blur() if document.activeElement.tagName.toLowerCase() == "iframe"
flashFrame() if request.highlight
-extend window,
+extend root,
scrollToBottom: ->
Marks.setPreviousPosition()
Scroller.scrollTo "y", "max"
@@ -345,7 +351,7 @@ extend window,
scrollLeft: (count) -> Scroller.scrollBy "x", -1 * Settings.get("scrollStepSize") * count
scrollRight: (count) -> Scroller.scrollBy "x", Settings.get("scrollStepSize") * count
-extend window,
+extend root,
reload: (count, options) ->
hard = options?.hard
window.location.reload(hard)
@@ -654,12 +660,12 @@ findAndFollowRel = (value) ->
followLink(element)
return true
-window.goPrevious = ->
+root.goPrevious = ->
previousPatterns = Settings.get("previousPatterns") || ""
previousStrings = previousPatterns.split(",").filter( (s) -> s.trim().length )
findAndFollowRel("prev") || findAndFollowLink(previousStrings)
-window.goNext = ->
+root.goNext = ->
nextPatterns = Settings.get("nextPatterns") || ""
nextStrings = nextPatterns.split(",").filter( (s) -> s.trim().length )
findAndFollowRel("next") || findAndFollowLink(nextStrings)
@@ -669,11 +675,11 @@ enterFindMode = ->
Marks.setPreviousPosition()
new FindMode()
-window.showHelp = (sourceFrameId) ->
+root.showHelp = (sourceFrameId) ->
HelpDialog.toggle {sourceFrameId, showAllCommandDetails: false}
# If we are in the help dialog iframe, then HelpDialog is already defined with the necessary functions.
-window.HelpDialog ?=
+root.HelpDialog ?=
helpUI: null
isShowing: -> @helpUI?.showing
abort: -> @helpUI.hide false if @isShowing()
@@ -690,7 +696,6 @@ window.HelpDialog ?=
initializePreDomReady()
DomUtils.documentReady initializeOnDomReady
-root = exports ? window
root.handlerStack = handlerStack
root.frameId = frameId
root.Frame = Frame
@@ -701,3 +706,4 @@ extend root, {handleEscapeForFindMode, handleEnterForFindMode, performFind, perf
enterFindMode, focusThisFrame}
# These are exported only for the tests.
extend root, {installModes}
+extend window, root unless exports?
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee
index 14d72e87..ad98aa48 100644
--- a/content_scripts/vomnibar.coffee
+++ b/content_scripts/vomnibar.coffee
@@ -58,5 +58,6 @@ Vomnibar =
HelpDialog.abort()
@vomnibarUI.activate extend options, { name: "activate", sourceFrameId, focus: true }
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Vomnibar = Vomnibar
+extend window, root unless exports?
diff --git a/lib/clipboard.coffee b/lib/clipboard.coffee
index af143dd9..1d378e76 100644
--- a/lib/clipboard.coffee
+++ b/lib/clipboard.coffee
@@ -25,5 +25,6 @@ Clipboard =
value
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Clipboard = Clipboard
+extend window, root unless exports?
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index ff5991dc..e771d436 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -416,5 +416,6 @@ DomUtils =
style.textContent = Settings.get "userDefinedLinkHintCss"
document.head.appendChild style
-root = exports ? window
+root = exports ? (window.root ?= {})
root.DomUtils = DomUtils
+extend window, root unless exports?
diff --git a/lib/find_mode_history.coffee b/lib/find_mode_history.coffee
index ff660bd2..93698266 100644
--- a/lib/find_mode_history.coffee
+++ b/lib/find_mode_history.coffee
@@ -46,5 +46,6 @@ FindModeHistory =
refreshRawQueryList: (query, rawQueryList) ->
([ query ].concat rawQueryList.filter (q) => q != query)[0..@max]
-root = exports ? window
+root = exports ? (window.root ?= {})
root.FindModeHistory = FindModeHistory
+extend window, root unless exports?
diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee
index 806b707f..2439f55c 100644
--- a/lib/handler_stack.coffee
+++ b/lib/handler_stack.coffee
@@ -1,4 +1,4 @@
-root = exports ? window
+root = exports ? (window.root ?= {})
class HandlerStack
constructor: ->
@@ -120,3 +120,4 @@ class HandlerStack
root.HandlerStack = HandlerStack
root.handlerStack = new HandlerStack()
+extend window, root unless exports?
diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee
index 1a1ea797..681ee139 100644
--- a/lib/keyboard_utils.coffee
+++ b/lib/keyboard_utils.coffee
@@ -101,5 +101,6 @@ KeyboardUtils =
KeyboardUtils.init()
-root = exports ? window
+root = exports ? (window.root ?= {})
root.KeyboardUtils = KeyboardUtils
+extend window, root unless exports?
diff --git a/lib/rect.coffee b/lib/rect.coffee
index d4807cc2..59764d18 100644
--- a/lib/rect.coffee
+++ b/lib/rect.coffee
@@ -91,5 +91,6 @@ Rect =
(rect1, rect2) ->
halfOverlapChecker(rect1, rect2) or halfOverlapChecker rect2, rect1
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Rect = Rect
+extend window, root unless exports?
diff --git a/lib/settings.coffee b/lib/settings.coffee
index 38718990..11cf7557 100644
--- a/lib/settings.coffee
+++ b/lib/settings.coffee
@@ -218,5 +218,6 @@ if Utils.isBackgroundPage()
# be removed after 1.58 has been out for sufficiently long.
Settings.nuke "copyNonDefaultsToChromeStorage-20150717"
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Settings = Settings
+extend window, root unless exports?
diff --git a/lib/utils.coffee b/lib/utils.coffee
index d0a82cf7..b5b96844 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -335,8 +335,11 @@ class JobRunner
onReady: (callback) ->
@fetcher.use callback
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Utils = Utils
root.SimpleCache = SimpleCache
root.AsyncDataFetcher = AsyncDataFetcher
root.JobRunner = JobRunner
+unless exports?
+ root.extend = extend
+ extend window, root