aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-26 13:39:27 +0000
committerStephen Blott2016-03-26 13:39:27 +0000
commite2ea471eff20504b53da36a791769d246fff9593 (patch)
tree0fa9b664f24b1706659bf7c2e6cf4e2c177bc2e7
parenta1103158551ace4232b613d290f5d193a7c5185f (diff)
downloadvimium-e2ea471eff20504b53da36a791769d246fff9593.tar.bz2
Add test for badly-formed exclusion regexp.
-rw-r--r--background_scripts/exclusions.coffee1
-rw-r--r--tests/unit_tests/exclusion_test.coffee5
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee1
3 files changed, 7 insertions, 0 deletions
diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee
index 10450670..42d3b872 100644
--- a/background_scripts/exclusions.coffee
+++ b/background_scripts/exclusions.coffee
@@ -10,6 +10,7 @@ RegexpCache =
try
new RegExp("^" + pattern.replace(/\*/g, ".*") + "$")
catch
+ BgUtils.log "bad regexp in exclusion rule: #{pattern}"
/^$/ # Match the empty string.
# The Exclusions class manages the exclusion rule setting. An exclusion is an object with two attributes:
diff --git a/tests/unit_tests/exclusion_test.coffee b/tests/unit_tests/exclusion_test.coffee
index 54cb4ed3..f53d23f6 100644
--- a/tests/unit_tests/exclusion_test.coffee
+++ b/tests/unit_tests/exclusion_test.coffee
@@ -16,6 +16,7 @@ extend(global, require "../../lib/utils.js")
Utils.getCurrentVersion = -> '1.44'
extend(global,require "../../lib/settings.js")
extend(global,require "../../lib/clipboard.js")
+extend(global, require "../../background_scripts/bg_utils.js")
extend(global, require "../../background_scripts/exclusions.js")
extend(global, require "../../background_scripts/commands.js")
extend(global, require "../../background_scripts/main.js")
@@ -70,3 +71,7 @@ context "Excluded URLs and pass keys",
assert.isTrue rule.isEnabledForUrl
assert.equal "abcdef", rule.passKeys
+ should "be enabled for malformed regular expressions", ->
+ Exclusions.postUpdateHook [ { pattern: "http*://www.bad-regexp.com/*[a-", passKeys: "" } ]
+ rule = isEnabledForUrl({ url: 'http://www.bad-regexp.com/pages' })
+ assert.isTrue rule.isEnabledForUrl
diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee
index bbcd01e7..b0b527c5 100644
--- a/tests/unit_tests/test_chrome_stubs.coffee
+++ b/tests/unit_tests/test_chrome_stubs.coffee
@@ -30,6 +30,7 @@ exports.chrome =
extension:
getURL: (path) -> path
getBackgroundPage: -> {}
+ getViews: -> []
tabs:
onSelectionChanged: