aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.coffee
diff options
context:
space:
mode:
authormrmr19932016-02-11 04:49:13 +0000
committermrmr19932016-02-11 04:49:13 +0000
commit2f73ad6c7357c9a7105e99a929991df735efc96e (patch)
tree2fe2124a6a394b051d305d17b087f341f8b77f5e /lib/utils.coffee
parentffafb533a3715546a5d2d2e8b960323b1f3fc03a (diff)
downloadvimium-2f73ad6c7357c9a7105e99a929991df735efc96e.tar.bz2
Tidy up detection for the current page and context belonging to us
Diffstat (limited to 'lib/utils.coffee')
-rw-r--r--lib/utils.coffee8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 4726739b..50d8c7dd 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -2,12 +2,12 @@ Utils =
getCurrentVersion: ->
chrome.runtime.getManifest().version
- # Returns true whenever the current page is from the extension's origin (and thus can access the
- # extension's localStorage).
- isExtensionPage: -> document.location?.origin + "/" == chrome.extension.getURL ""
+ # Returns true whenever the current page (or the page supplied as an argument) is from the extension's
+ # origin (and thus can access the extension's localStorage).
+ isExtensionPage: (win = window) -> try win.document.location?.origin + "/" == chrome.extension.getURL ""
# Returns true whenever the current page is the extension's background page.
- isBackgroundPage: -> @isExtensionPage() and try chrome.extension.getBackgroundPage() == window
+ isBackgroundPage: -> @isExtensionPage() and chrome.extension.getBackgroundPage?() == window
# Takes a dot-notation object string and call the function
# that it points to with the correct value for 'this'.