Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | Cu.import("resource://services-sync/engines/tabs.js"); |
michael@0 | 5 | Cu.import("resource://services-sync/service.js"); |
michael@0 | 6 | Cu.import("resource://services-sync/util.js"); |
michael@0 | 7 | |
michael@0 | 8 | function getMocks() { |
michael@0 | 9 | let engine = new TabEngine(Service); |
michael@0 | 10 | let store = engine._store; |
michael@0 | 11 | store.getTabState = mockGetTabState; |
michael@0 | 12 | store.shouldSkipWindow = mockShouldSkipWindow; |
michael@0 | 13 | return [engine, store]; |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | function run_test() { |
michael@0 | 17 | _("Test getOpenURLs."); |
michael@0 | 18 | let [engine, store] = getMocks(); |
michael@0 | 19 | |
michael@0 | 20 | let urls = ["http://bar.com", "http://foo.com", "http://foobar.com"]; |
michael@0 | 21 | function threeURLs() { |
michael@0 | 22 | return urls.pop(); |
michael@0 | 23 | } |
michael@0 | 24 | store.getWindowEnumerator = mockGetWindowEnumerator.bind(this, threeURLs, 1, 3); |
michael@0 | 25 | |
michael@0 | 26 | let matches; |
michael@0 | 27 | |
michael@0 | 28 | _(" test matching works (true)"); |
michael@0 | 29 | let openurlsset = engine.getOpenURLs(); |
michael@0 | 30 | matches = openurlsset.has("http://foo.com"); |
michael@0 | 31 | do_check_true(matches); |
michael@0 | 32 | |
michael@0 | 33 | _(" test matching works (false)"); |
michael@0 | 34 | matches = openurlsset.has("http://barfoo.com"); |
michael@0 | 35 | do_check_false(matches); |
michael@0 | 36 | } |