michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: Cu.import("resource://services-sync/engines/tabs.js"); michael@0: Cu.import("resource://services-sync/service.js"); michael@0: Cu.import("resource://services-sync/util.js"); michael@0: michael@0: function getMocks() { michael@0: let engine = new TabEngine(Service); michael@0: let store = engine._store; michael@0: store.getTabState = mockGetTabState; michael@0: store.shouldSkipWindow = mockShouldSkipWindow; michael@0: return [engine, store]; michael@0: } michael@0: michael@0: function run_test() { michael@0: _("Test getOpenURLs."); michael@0: let [engine, store] = getMocks(); michael@0: michael@0: let urls = ["http://bar.com", "http://foo.com", "http://foobar.com"]; michael@0: function threeURLs() { michael@0: return urls.pop(); michael@0: } michael@0: store.getWindowEnumerator = mockGetWindowEnumerator.bind(this, threeURLs, 1, 3); michael@0: michael@0: let matches; michael@0: michael@0: _(" test matching works (true)"); michael@0: let openurlsset = engine.getOpenURLs(); michael@0: matches = openurlsset.has("http://foo.com"); michael@0: do_check_true(matches); michael@0: michael@0: _(" test matching works (false)"); michael@0: matches = openurlsset.has("http://barfoo.com"); michael@0: do_check_false(matches); michael@0: }