aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vimium_frontend.coffee
diff options
context:
space:
mode:
authormrmr19932017-10-25 16:45:45 +0100
committermrmr19932017-10-25 16:51:46 +0100
commitaca953e06a7cf5aa6906df677a8fb6ed3e688a03 (patch)
treef207a026e1e8e97b718aaec98f3e8f7b530af9cf /content_scripts/vimium_frontend.coffee
parent03569d64b445780576f960d0553dc763c807de95 (diff)
downloadvimium-aca953e06a7cf5aa6906df677a8fb6ed3e688a03.tar.bz2
FF: Share |root| global proxy, re-add the globals to window on DOMLoad
This is a workaround for Firefox bug 1408996.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
-rw-r--r--content_scripts/vimium_frontend.coffee22
1 files changed, 14 insertions, 8 deletions
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?