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 | let req; |
michael@0 | 24 | |
michael@0 | 25 | let steps = [ |
michael@0 | 26 | clearDatabase, |
michael@0 | 27 | function() { |
michael@0 | 28 | // add a contact |
michael@0 | 29 | createResult1 = new mozContact({}); |
michael@0 | 30 | req = navigator.mozContacts.save(createResult1); |
michael@0 | 31 | req.onsuccess = function() { |
michael@0 | 32 | next(); |
michael@0 | 33 | }; |
michael@0 | 34 | req.onerror = onFailure; |
michael@0 | 35 | }, |
michael@0 | 36 | |
michael@0 | 37 | getOne(), |
michael@0 | 38 | getOne("Retrieving one contact with getAll - cached"), |
michael@0 | 39 | |
michael@0 | 40 | clearDatabase, |
michael@0 | 41 | addContacts, |
michael@0 | 42 | |
michael@0 | 43 | getAll(), |
michael@0 | 44 | getAll("Retrieving 40 contacts with getAll - cached"), |
michael@0 | 45 | |
michael@0 | 46 | function() { |
michael@0 | 47 | ok(true, "Deleting one contact"); |
michael@0 | 48 | req = mozContacts.remove(createResult1); |
michael@0 | 49 | req.onsuccess = function() { |
michael@0 | 50 | next(); |
michael@0 | 51 | }; |
michael@0 | 52 | req.onerror = onFailure; |
michael@0 | 53 | }, |
michael@0 | 54 | function() { |
michael@0 | 55 | ok(true, "Test cache invalidation"); |
michael@0 | 56 | req = mozContacts.getAll({}); |
michael@0 | 57 | let count = 0; |
michael@0 | 58 | req.onsuccess = function(event) { |
michael@0 | 59 | ok(true, "on success"); |
michael@0 | 60 | if (req.result) { |
michael@0 | 61 | ok(true, "result is valid"); |
michael@0 | 62 | count++; |
michael@0 | 63 | req.continue(); |
michael@0 | 64 | } else { |
michael@0 | 65 | is(count, 39, "last contact - 39 contacts returned"); |
michael@0 | 66 | next(); |
michael@0 | 67 | } |
michael@0 | 68 | }; |
michael@0 | 69 | req.onerror = onFailure; |
michael@0 | 70 | }, |
michael@0 | 71 | |
michael@0 | 72 | clearDatabase, |
michael@0 | 73 | addContacts, |
michael@0 | 74 | |
michael@0 | 75 | function() { |
michael@0 | 76 | ok(true, "Test cache consistency when deleting contact during getAll"); |
michael@0 | 77 | req = mozContacts.find({}); |
michael@0 | 78 | req.onsuccess = function(e) { |
michael@0 | 79 | let lastContact = e.target.result[e.target.result.length-1]; |
michael@0 | 80 | req = mozContacts.getAll({}); |
michael@0 | 81 | let count = 0; |
michael@0 | 82 | let firstResult = true; |
michael@0 | 83 | req.onsuccess = function(event) { |
michael@0 | 84 | ok(true, "on success"); |
michael@0 | 85 | if (firstResult) { |
michael@0 | 86 | if (req.result) { |
michael@0 | 87 | count++; |
michael@0 | 88 | } |
michael@0 | 89 | let delReq = mozContacts.remove(lastContact); |
michael@0 | 90 | delReq.onsuccess = function() { |
michael@0 | 91 | firstResult = false; |
michael@0 | 92 | req.continue(); |
michael@0 | 93 | }; |
michael@0 | 94 | } else { |
michael@0 | 95 | if (req.result) { |
michael@0 | 96 | ok(true, "result is valid"); |
michael@0 | 97 | count++; |
michael@0 | 98 | req.continue(); |
michael@0 | 99 | } else { |
michael@0 | 100 | is(count, 40, "last contact - 40 contacts returned"); |
michael@0 | 101 | next(); |
michael@0 | 102 | } |
michael@0 | 103 | } |
michael@0 | 104 | }; |
michael@0 | 105 | }; |
michael@0 | 106 | }, |
michael@0 | 107 | |
michael@0 | 108 | clearDatabase, |
michael@0 | 109 | |
michael@0 | 110 | function() { |
michael@0 | 111 | ok(true, "all done!\n"); |
michael@0 | 112 | SimpleTest.finish(); |
michael@0 | 113 | } |
michael@0 | 114 | ]; |
michael@0 | 115 | |
michael@0 | 116 | start_tests(); |
michael@0 | 117 | </script> |
michael@0 | 118 | </pre> |
michael@0 | 119 | </body> |
michael@0 | 120 | </html> |