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 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=836519 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Mozilla Bug 836519</title> |
michael@0 | 8 | <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=836519">Mozilla Bug 836519</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script type="text/javascript;version=1.8" src="http://mochi.test:8888/tests/dom/contacts/tests/shared.js"></script> |
michael@0 | 21 | <script class="testbody" type="text/javascript;version=1.8"> |
michael@0 | 22 | "use strict"; |
michael@0 | 23 | |
michael@0 | 24 | let req; |
michael@0 | 25 | |
michael@0 | 26 | let steps = [ |
michael@0 | 27 | function start() { |
michael@0 | 28 | SpecialPowers.Cc["@mozilla.org/tools/profiler;1"].getService(SpecialPowers.Ci.nsIProfiler).AddMarker("GETALL_START"); |
michael@0 | 29 | next(); |
michael@0 | 30 | }, |
michael@0 | 31 | clearDatabase, |
michael@0 | 32 | addContacts, |
michael@0 | 33 | |
michael@0 | 34 | function() { |
michael@0 | 35 | ok(true, "Delete the current contact while iterating"); |
michael@0 | 36 | req = mozContacts.getAll({}); |
michael@0 | 37 | let count = 0; |
michael@0 | 38 | let previousId = null; |
michael@0 | 39 | req.onsuccess = function() { |
michael@0 | 40 | if (req.result) { |
michael@0 | 41 | ok(true, "on success"); |
michael@0 | 42 | if (previousId) { |
michael@0 | 43 | isnot(previousId, req.result.id, "different contacts returned"); |
michael@0 | 44 | } |
michael@0 | 45 | previousId = req.result.id; |
michael@0 | 46 | count++; |
michael@0 | 47 | let delReq = mozContacts.remove(req.result); |
michael@0 | 48 | delReq.onsuccess = function() { |
michael@0 | 49 | ok(true, "deleted current contact"); |
michael@0 | 50 | req.continue(); |
michael@0 | 51 | }; |
michael@0 | 52 | } else { |
michael@0 | 53 | is(count, 40, "returned 40 contacts"); |
michael@0 | 54 | next(); |
michael@0 | 55 | } |
michael@0 | 56 | }; |
michael@0 | 57 | }, |
michael@0 | 58 | |
michael@0 | 59 | clearDatabase, |
michael@0 | 60 | addContacts, |
michael@0 | 61 | |
michael@0 | 62 | function() { |
michael@0 | 63 | ok(true, "Iterating through the contact list inside a cursor callback"); |
michael@0 | 64 | let count1 = 0, count2 = 0; |
michael@0 | 65 | let req1 = mozContacts.getAll({}); |
michael@0 | 66 | let req2; |
michael@0 | 67 | req1.onsuccess = function() { |
michael@0 | 68 | if (count1 == 0) { |
michael@0 | 69 | count1++; |
michael@0 | 70 | req2 = mozContacts.getAll({}); |
michael@0 | 71 | req2.onsuccess = function() { |
michael@0 | 72 | if (req2.result) { |
michael@0 | 73 | count2++; |
michael@0 | 74 | req2.continue(); |
michael@0 | 75 | } else { |
michael@0 | 76 | is(count2, 40, "inner cursor returned 40 contacts"); |
michael@0 | 77 | req1.continue(); |
michael@0 | 78 | } |
michael@0 | 79 | }; |
michael@0 | 80 | } else { |
michael@0 | 81 | if (req1.result) { |
michael@0 | 82 | count1++; |
michael@0 | 83 | req1.continue(); |
michael@0 | 84 | } else { |
michael@0 | 85 | is(count1, 40, "outer cursor returned 40 contacts"); |
michael@0 | 86 | next(); |
michael@0 | 87 | } |
michael@0 | 88 | } |
michael@0 | 89 | }; |
michael@0 | 90 | }, |
michael@0 | 91 | |
michael@0 | 92 | clearDatabase, |
michael@0 | 93 | addContacts, |
michael@0 | 94 | |
michael@0 | 95 | function() { |
michael@0 | 96 | ok(true, "20 concurrent cursors"); |
michael@0 | 97 | const NUM_CURSORS = 20; |
michael@0 | 98 | let completed = 0; |
michael@0 | 99 | for (let i = 0; i < NUM_CURSORS; ++i) { |
michael@0 | 100 | mozContacts.getAll({}).onsuccess = (function(i) { |
michael@0 | 101 | let count = 0; |
michael@0 | 102 | return function(event) { |
michael@0 | 103 | let req = event.target; |
michael@0 | 104 | if (req.result) { |
michael@0 | 105 | count++; |
michael@0 | 106 | req.continue(); |
michael@0 | 107 | } else { |
michael@0 | 108 | is(count, 40, "cursor " + i + " returned 40 contacts"); |
michael@0 | 109 | if (++completed == NUM_CURSORS) { |
michael@0 | 110 | next(); |
michael@0 | 111 | } |
michael@0 | 112 | } |
michael@0 | 113 | }; |
michael@0 | 114 | })(i); |
michael@0 | 115 | } |
michael@0 | 116 | }, |
michael@0 | 117 | |
michael@0 | 118 | clearDatabase, |
michael@0 | 119 | addContacts, |
michael@0 | 120 | |
michael@0 | 121 | function() { |
michael@0 | 122 | if (!SpecialPowers.isMainProcess()) { |
michael@0 | 123 | // We stop calling continue() intentionally here to see if the cursor gets |
michael@0 | 124 | // cleaned up properly in the parent. |
michael@0 | 125 | ok(true, "Leaking a cursor"); |
michael@0 | 126 | req = mozContacts.getAll({ |
michael@0 | 127 | sortBy: "familyName", |
michael@0 | 128 | sortOrder: "ascending" |
michael@0 | 129 | }); |
michael@0 | 130 | req.onsuccess = function(event) { |
michael@0 | 131 | next(); |
michael@0 | 132 | }; |
michael@0 | 133 | req.onerror = onFailure; |
michael@0 | 134 | } else { |
michael@0 | 135 | next(); |
michael@0 | 136 | } |
michael@0 | 137 | }, |
michael@0 | 138 | |
michael@0 | 139 | clearDatabase, |
michael@0 | 140 | |
michael@0 | 141 | function() { |
michael@0 | 142 | ok(true, "all done!\n"); |
michael@0 | 143 | SpecialPowers.Cc["@mozilla.org/tools/profiler;1"].getService(SpecialPowers.Ci.nsIProfiler).AddMarker("GETALL_END"); |
michael@0 | 144 | SimpleTest.finish(); |
michael@0 | 145 | } |
michael@0 | 146 | ]; |
michael@0 | 147 | |
michael@0 | 148 | start_tests(); |
michael@0 | 149 | </script> |
michael@0 | 150 | </pre> |
michael@0 | 151 | </body> |
michael@0 | 152 | </html> |