Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet type="text/css" href="chrome://global/skin"?> |
michael@0 | 3 | <?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | Any copyright is dedicated to the Public Domain. |
michael@0 | 6 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 7 | --> |
michael@0 | 8 | |
michael@0 | 9 | <window title="Mozilla Bug 945948" |
michael@0 | 10 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 13 | |
michael@0 | 14 | <script type="application/javascript;version=1.7"> |
michael@0 | 15 | <![CDATA[ |
michael@0 | 16 | "use strict"; |
michael@0 | 17 | const { 'utils': Cu } = Components; |
michael@0 | 18 | Cu.import("resource://gre/modules/ContactService.jsm", window); |
michael@0 | 19 | |
michael@0 | 20 | // |
michael@0 | 21 | // Mock message manager |
michael@0 | 22 | // |
michael@0 | 23 | function MockMessageManager() { } |
michael@0 | 24 | MockMessageManager.prototype.assertPermission = function() { return true; }; |
michael@0 | 25 | MockMessageManager.prototype.sendAsyncMessage = function(name, data) { }; |
michael@0 | 26 | |
michael@0 | 27 | // |
michael@0 | 28 | // Mock ContactDB |
michael@0 | 29 | // |
michael@0 | 30 | function MockContactDB() { } |
michael@0 | 31 | MockContactDB.prototype.getAll = function(cb) { |
michael@0 | 32 | cb([]); |
michael@0 | 33 | }; |
michael@0 | 34 | MockContactDB.prototype.clearDispatcher = function() { } |
michael@0 | 35 | MockContactDB.prototype.close = function() { } |
michael@0 | 36 | |
michael@0 | 37 | let realContactDB = ContactService._db; |
michael@0 | 38 | |
michael@0 | 39 | function before() { |
michael@0 | 40 | ok(true, "Install mock ContactDB object"); |
michael@0 | 41 | ContactService._db = new MockContactDB(); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function after() { |
michael@0 | 45 | ok(true, "Restore real ContactDB object"); |
michael@0 | 46 | ContactService._db = realContactDB; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function steps() { |
michael@0 | 50 | let mm1 = new MockMessageManager(); |
michael@0 | 51 | let mm2 = new MockMessageManager(); |
michael@0 | 52 | |
michael@0 | 53 | is(ContactService._cursors.size, 0, "Verify clean contact init"); |
michael@0 | 54 | |
michael@0 | 55 | ContactService.receiveMessage({ |
michael@0 | 56 | target: mm1, |
michael@0 | 57 | name: "Contacts:GetAll", |
michael@0 | 58 | data: { cursorId: 1 }, |
michael@0 | 59 | findOptions: {} |
michael@0 | 60 | }); |
michael@0 | 61 | is(ContactService._cursors.size, 1, "Add contact cursor 1"); |
michael@0 | 62 | |
michael@0 | 63 | ContactService.receiveMessage({ |
michael@0 | 64 | target: mm2, |
michael@0 | 65 | name: "Contacts:GetAll", |
michael@0 | 66 | data: { cursorId: 2 }, |
michael@0 | 67 | findOptions: {} |
michael@0 | 68 | }); |
michael@0 | 69 | is(ContactService._cursors.size, 2, "Add contact cursor 2"); |
michael@0 | 70 | |
michael@0 | 71 | ContactService.receiveMessage({ |
michael@0 | 72 | target: mm1, |
michael@0 | 73 | name: "child-process-shutdown" |
michael@0 | 74 | }); |
michael@0 | 75 | is(ContactService._cursors.size, 1, "Shutdown contact cursor 1"); |
michael@0 | 76 | |
michael@0 | 77 | ContactService.receiveMessage({ |
michael@0 | 78 | target: mm2, |
michael@0 | 79 | name: "child-process-shutdown" |
michael@0 | 80 | }); |
michael@0 | 81 | is(ContactService._cursors.size, 0, "Shutdown contact cursor 2"); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function runTests() { |
michael@0 | 85 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 86 | try { |
michael@0 | 87 | before(); |
michael@0 | 88 | steps(); |
michael@0 | 89 | } finally { |
michael@0 | 90 | after(); |
michael@0 | 91 | SimpleTest.finish(); |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | runTests(); |
michael@0 | 96 | ]]> |
michael@0 | 97 | </script> |
michael@0 | 98 | |
michael@0 | 99 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 100 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=945948" |
michael@0 | 101 | target="_blank">Mozilla Bug 945948</a> |
michael@0 | 102 | </body> |
michael@0 | 103 | </window> |