OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 window.indexedDB = window.indexedDB || window.webkitIndexedDB || | |
6 window.mozIndexedDB || window.msIndexedDB; | |
7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange; | |
8 | |
9 var automation = { | 5 var automation = { |
10 results: {} | 6 results: {} |
11 }; | 7 }; |
12 | 8 |
13 automation.setDone = function() { | 9 automation.setDone = function() { |
14 this.setStatus("Test complete."); | 10 this.setStatus("Test complete."); |
15 document.cookie = '__done=1; path=/'; | 11 document.cookie = '__done=1; path=/'; |
16 }; | 12 }; |
17 | 13 |
18 automation.addResult = function(name, result) { | 14 automation.addResult = function(name, result) { |
(...skipping 16 matching lines...) Expand all Loading... |
35 function assert(t) { | 31 function assert(t) { |
36 if (!t) { | 32 if (!t) { |
37 var e = new Error("Assertion failed!"); | 33 var e = new Error("Assertion failed!"); |
38 console.log(e.stack); | 34 console.log(e.stack); |
39 throw e; | 35 throw e; |
40 } | 36 } |
41 } | 37 } |
42 | 38 |
43 function onError(e) { | 39 function onError(e) { |
44 var s = "Caught error."; | 40 var s = "Caught error."; |
45 if (e.target && e.target.webkitErrorMessage) | 41 if (e.target && e.target.error) |
46 s += "\n" + e.target.webkitErrorMessage; | 42 s += "\n" + e.target.error.name + "\n" + e.target.error.message; |
47 else if (e.target && e.target.error) | |
48 s += "\n" + e.target.error.name; | |
49 console.log(s); | 43 console.log(s); |
50 automation.setStatus(s); | 44 automation.setStatus(s); |
51 e.stopPropagation(); | 45 e.stopPropagation(); |
52 throw new Error(e); | 46 throw new Error(e); |
53 } | 47 } |
54 | 48 |
55 var baseVersion = 2; // The version with our object stores. | 49 var baseVersion = 2; // The version with our object stores. |
56 var curVersion; | 50 var curVersion; |
57 | 51 |
58 // Valid options fields: | 52 // Valid options fields: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 var db = openRequest.result; | 84 var db = openRequest.result; |
91 db.onerror = errorHandler; | 85 db.onerror = errorHandler; |
92 createObjectStores(db); | 86 createObjectStores(db); |
93 // onsuccess will get called after this exits. | 87 // onsuccess will get called after this exits. |
94 }; | 88 }; |
95 openRequest.onsuccess = function(ev) { | 89 openRequest.onsuccess = function(ev) { |
96 assert(openRequest == ev.target); | 90 assert(openRequest == ev.target); |
97 var db = openRequest.result; | 91 var db = openRequest.result; |
98 curVersion = db.version; | 92 curVersion = db.version; |
99 db.onerror = function(ev) { | 93 db.onerror = function(ev) { |
100 console.log("db error", arguments, openRequest.webkitErrorMessage); | 94 console.log("db error", arguments, openRequest.error.message); |
101 errorHandler(ev); | 95 errorHandler(ev); |
102 }; | 96 }; |
103 if (curVersion != baseVersion) { | 97 if (curVersion != baseVersion) { |
104 // This is the legacy path, which runs only in Chrome. | 98 // This is the legacy path, which runs only in Chrome. |
105 var setVersionRequest = db.setVersion(baseVersion); | 99 var setVersionRequest = db.setVersion(baseVersion); |
106 setVersionRequest.onerror = errorHandler; | 100 setVersionRequest.onerror = errorHandler; |
107 setVersionRequest.onsuccess = function(e) { | 101 setVersionRequest.onsuccess = function(e) { |
108 assert(setVersionRequest == e.target); | 102 assert(setVersionRequest == e.target); |
109 createObjectStores(db); | 103 createObjectStores(db); |
110 var versionTransaction = setVersionRequest.result; | 104 var versionTransaction = setVersionRequest.result; |
(...skipping 14 matching lines...) Expand all Loading... |
125 openRequest.onblocked = errorHandler; | 119 openRequest.onblocked = errorHandler; |
126 openRequest.onupgradeneeded = function(ev) { | 120 openRequest.onupgradeneeded = function(ev) { |
127 doAlteration(ev.target.transaction); | 121 doAlteration(ev.target.transaction); |
128 // onsuccess will get called after this exits. | 122 // onsuccess will get called after this exits. |
129 }; | 123 }; |
130 openRequest.onsuccess = function(ev) { | 124 openRequest.onsuccess = function(ev) { |
131 assert(openRequest == ev.target); | 125 assert(openRequest == ev.target); |
132 var db = openRequest.result; | 126 var db = openRequest.result; |
133 db.onerror = function(ev) { | 127 db.onerror = function(ev) { |
134 console.log("error altering db", arguments, | 128 console.log("error altering db", arguments, |
135 openRequest.webkitErrorMessage); | 129 openRequest.error.message); |
136 errorHandler(); | 130 errorHandler(); |
137 }; | 131 }; |
138 if (db.version != version) { | 132 if (db.version != version) { |
139 // This is the legacy path, which runs only in Chrome before M23. | 133 // This is the legacy path, which runs only in Chrome before M23. |
140 var setVersionRequest = db.setVersion(version); | 134 var setVersionRequest = db.setVersion(version); |
141 setVersionRequest.onerror = errorHandler; | 135 setVersionRequest.onerror = errorHandler; |
142 setVersionRequest.onsuccess = | 136 setVersionRequest.onsuccess = |
143 function(e) { | 137 function(e) { |
144 curVersion = db.version; | 138 curVersion = db.version; |
145 assert(setVersionRequest == e.target); | 139 assert(setVersionRequest == e.target); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 this.a = this.b ^ rot(this.c, 17); | 426 this.a = this.b ^ rot(this.c, 17); |
433 this.b = uint32(this.c + this.d); | 427 this.b = uint32(this.c + this.d); |
434 this.c = uint32(this.d + e); | 428 this.c = uint32(this.d + e); |
435 this.d = uint32(e + this.a); | 429 this.d = uint32(e + this.a); |
436 return this.d; | 430 return this.d; |
437 }; | 431 }; |
438 | 432 |
439 var prng = new SmallPRNG(seed); | 433 var prng = new SmallPRNG(seed); |
440 return function() { return prng.ranval() / 0x100000000; }; | 434 return function() { return prng.ranval() / 0x100000000; }; |
441 }(0)); | 435 }(0)); |
OLD | NEW |