1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
require "./test_helper.js"
extend global, require "./test_chrome_stubs.js"
# FIXME:
# Would like to do:
# extend(global, require "../../background_scripts/marks.js")
# But it looks like marks.coffee has never been included in a test before!
# Temporary fix...
root.Marks =
create: () -> true
goto:
bind: () -> true
extend(global, require "../../lib/utils.js")
Utils.getCurrentVersion = -> '1.44'
extend(global,require "../../background_scripts/settings.js")
Sync.init()
extend(global, require "../../background_scripts/exclusions.js")
extend(global, require "../../background_scripts/commands.js")
extend(global, require "../../background_scripts/main.js")
# These tests cover only the most basic aspects of excluded URLs and passKeys.
#
context "Excluded URLs and pass keys",
setup ->
Exclusions.postUpdateHook(
[
{ pattern: "http*://mail.google.com/*", passKeys: "" }
{ pattern: "http*://www.facebook.com/*", passKeys: "abab" }
{ pattern: "http*://www.facebook.com/*", passKeys: "cdcd" }
{ pattern: "http*://www.bbc.com/*", passKeys: "" }
{ pattern: "http*://www.bbc.com/*", passKeys: "ab" }
])
should "be disabled for excluded sites", ->
rule = isEnabledForUrl({ url: 'http://mail.google.com/calendar/page' })
assert.isFalse rule.isEnabledForUrl
assert.isFalse rule.passKeys
should "be disabled for excluded sites, one exclusion", ->
rule = isEnabledForUrl({ url: 'http://www.bbc.com/calendar/page' })
assert.isFalse rule.isEnabledForUrl
assert.isFalse rule.passKeys
should "be enabled, but with pass keys", ->
rule = isEnabledForUrl({ url: 'https://www.facebook.com/something' })
assert.isTrue rule.isEnabledForUrl
assert.equal rule.passKeys, 'abcd'
should "be enabled", ->
rule = isEnabledForUrl({ url: 'http://www.twitter.com/pages' })
assert.isTrue rule.isEnabledForUrl
assert.isFalse rule.passKeys
|