From 8a659af44a8205f39e4c0e04146978447ca3f38e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Apr 2015 12:02:09 +0100 Subject: Get incognto state directly from chrome.extensions.inIncognitoContext --- tests/unit_tests/exclusion_test.coffee | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/unit_tests/exclusion_test.coffee b/tests/unit_tests/exclusion_test.coffee index 287d699d..b3ed7194 100644 --- a/tests/unit_tests/exclusion_test.coffee +++ b/tests/unit_tests/exclusion_test.coffee @@ -21,10 +21,6 @@ extend(global, require "../../background_scripts/exclusions.js") extend(global, require "../../background_scripts/commands.js") extend(global, require "../../background_scripts/main.js") -dummyTab = - tab: - incognito: false - # These tests cover only the most basic aspects of excluded URLs and passKeys. # context "Excluded URLs and pass keys", @@ -40,22 +36,22 @@ context "Excluded URLs and pass keys", ]) should "be disabled for excluded sites", -> - rule = isEnabledForUrl({ url: 'http://mail.google.com/calendar/page' }, dummyTab) + 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' }, dummyTab) + 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' }, dummyTab) + 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' }, dummyTab) + rule = isEnabledForUrl({ url: 'http://www.twitter.com/pages' }) assert.isTrue rule.isEnabledForUrl assert.isFalse rule.passKeys -- cgit v1.2.3 From 16df2200b491e2463b784b4979ba5e9528604b64 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Apr 2015 12:53:17 +0100 Subject: Add chrome.webNavigation stubs to fix tests --- tests/dom_tests/chrome.coffee | 2 ++ tests/unit_tests/test_chrome_stubs.coffee | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/dom_tests/chrome.coffee b/tests/dom_tests/chrome.coffee index 5f276649..4c9bfa52 100644 --- a/tests/dom_tests/chrome.coffee +++ b/tests/dom_tests/chrome.coffee @@ -29,3 +29,5 @@ root.chrome = set: -> onChanged: addListener: -> + extension: + inIncognitoContext: false diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee index bc50521a..60f3a890 100644 --- a/tests/unit_tests/test_chrome_stubs.coffee +++ b/tests/unit_tests/test_chrome_stubs.coffee @@ -38,6 +38,12 @@ exports.chrome = addListener: () -> true query: () -> true + webNavigation: + onHistoryStateUpdated: + addListener: () -> + onReferenceFragmentUpdated: + addListener: () -> + windows: onRemoved: addListener: () -> true -- cgit v1.2.3 From 6446cf04c7b44c3d419dc450a73b60bcaf5cdf02 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Apr 2015 13:53:54 +0100 Subject: Always initialise event listeners early The event listeners were registered late, potentially allowing the page to get priority over us for key events, etc., when: * the original URL was disabled by an exclusion rule * the URL was changed - without a page load (by history.pushState or modifying location.hash), and - the new URL isn't (completely) disabled by any exclusion rules. This forces the event listeners to be registered even when the current URL is disabled, to avoid this problem. --- tests/dom_tests/dom_tests.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index f81982ac..59970d7c 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -1,6 +1,6 @@ # Install frontend event handlers. -initializeWhenEnabled() +initializeWithState() installListener = (element, event, callback) -> element.addEventListener event, (-> callback.apply(this, arguments)), true -- cgit v1.2.3