1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/sync/tests/unit/test_tab_engine.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +Cu.import("resource://services-sync/engines/tabs.js"); 1.8 +Cu.import("resource://services-sync/service.js"); 1.9 +Cu.import("resource://services-sync/util.js"); 1.10 + 1.11 +function getMocks() { 1.12 + let engine = new TabEngine(Service); 1.13 + let store = engine._store; 1.14 + store.getTabState = mockGetTabState; 1.15 + store.shouldSkipWindow = mockShouldSkipWindow; 1.16 + return [engine, store]; 1.17 +} 1.18 + 1.19 +function run_test() { 1.20 + _("Test getOpenURLs."); 1.21 + let [engine, store] = getMocks(); 1.22 + 1.23 + let urls = ["http://bar.com", "http://foo.com", "http://foobar.com"]; 1.24 + function threeURLs() { 1.25 + return urls.pop(); 1.26 + } 1.27 + store.getWindowEnumerator = mockGetWindowEnumerator.bind(this, threeURLs, 1, 3); 1.28 + 1.29 + let matches; 1.30 + 1.31 + _(" test matching works (true)"); 1.32 + let openurlsset = engine.getOpenURLs(); 1.33 + matches = openurlsset.has("http://foo.com"); 1.34 + do_check_true(matches); 1.35 + 1.36 + _(" test matching works (false)"); 1.37 + matches = openurlsset.has("http://barfoo.com"); 1.38 + do_check_false(matches); 1.39 +}