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