test_metadata2Restore.js (10151B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 /* exported testGenerator */ 7 var testGenerator = testSteps(); 8 9 function* testSteps() { 10 const openParams = [ 11 // This one lives in storage/default/http+++localhost+81^userContextId=1 12 // The .metadata-v2 file was intentionally removed for this origin directory 13 // to test restoring. 14 { 15 attrs: { userContextId: 1 }, 16 url: "http://localhost:81", 17 dbName: "dbC", 18 dbVersion: 1, 19 }, 20 21 // This one lives in storage/default/http+++localhost+82^userContextId=1 22 // The .metadata-v2 file was intentionally truncated for this origin directory 23 // to test restoring. 24 { 25 attrs: { userContextId: 1 }, 26 url: "http://localhost:82", 27 dbName: "dbD", 28 dbVersion: 1, 29 }, 30 31 // This one lives in storage/default/http+++localhost+83^userContextId=1 32 // The .metadata-v2 file was intentionally modified to contain only 33 // 4 bytes of the 64 bit timestamp 34 // for this origin directory to test restoring. 35 { 36 attrs: { userContextId: 1 }, 37 url: "http://localhost:83", 38 dbName: "dbE", 39 dbVersion: 1, 40 }, 41 42 // This one lives in storage/default/http+++localhost+84^userContextId=1 43 // The .metadata-v2 file was intentionally modified to contain only 44 // the 64 bit timestamp 45 // for this origin directory to test restoring. 46 { 47 attrs: { userContextId: 1 }, 48 url: "http://localhost:84", 49 dbName: "dbF", 50 dbVersion: 1, 51 }, 52 53 // This one lives in storage/default/http+++localhost+85^userContextId=1 54 // The .metadata-v2 file was intentionally modified to contain only 55 // the 64 bit timestamp and 56 // the 8 bit persisted flag 57 // for this origin directory to test restoring. 58 { 59 attrs: { userContextId: 1 }, 60 url: "http://localhost:85", 61 dbName: "dbG", 62 dbVersion: 1, 63 }, 64 65 // This one lives in storage/default/http+++localhost+86^userContextId=1 66 // The .metadata-v2 file was intentionally modified to contain only 67 // the 64 bit timestamp, 68 // the 8 bit persisted flag and 69 // 2 bytes of the 32 bit reserved data 1 70 // for this origin directory to test restoring. 71 { 72 attrs: { userContextId: 1 }, 73 url: "http://localhost:86", 74 dbName: "dbH", 75 dbVersion: 1, 76 }, 77 78 // This one lives in storage/default/http+++localhost+87^userContextId=1 79 // The .metadata-v2 file was intentionally modified to contain only 80 // the 64 bit timestamp, 81 // the 8 bit persisted flag and 82 // the 32 bit reserved data 1 83 // for this origin directory to test restoring. 84 { 85 attrs: { userContextId: 1 }, 86 url: "http://localhost:87", 87 dbName: "dbI", 88 dbVersion: 1, 89 }, 90 91 // This one lives in storage/default/http+++localhost+88^userContextId=1 92 // The .metadata-v2 file was intentionally modified to contain only 93 // the 64 bit timestamp, 94 // the 8 bit persisted flag, 95 // the 32 bit reserved data 1 and 96 // 2 bytes of the 32 bit reserved data 2 97 // for this origin directory to test restoring. 98 { 99 attrs: { userContextId: 1 }, 100 url: "http://localhost:88", 101 dbName: "dbJ", 102 dbVersion: 1, 103 }, 104 105 // This one lives in storage/default/http+++localhost+89^userContextId=1 106 // The .metadata-v2 file was intentionally modified to contain only 107 // the 64 bit timestamp, 108 // the 8 bit persisted flag, 109 // the 32 bit reserved data 1 and 110 // the 32 bit reserved data 2 111 // for this origin directory to test restoring. 112 { 113 attrs: { userContextId: 1 }, 114 url: "http://localhost:89", 115 dbName: "dbK", 116 dbVersion: 1, 117 }, 118 119 // This one lives in storage/default/http+++localhost+90^userContextId=1 120 // The .metadata-v2 file was intentionally modified to contain only 121 // the 64 bit timestamp, 122 // the 8 bit persisted flag, 123 // the 32 bit reserved data 1, 124 // the 32 bit reserved data 2 and 125 // 2 bytes of the 32 bit suffix length 126 // for this origin directory to test restoring. 127 { 128 attrs: { userContextId: 1 }, 129 url: "http://localhost:90", 130 dbName: "dbL", 131 dbVersion: 1, 132 }, 133 134 // This one lives in storage/default/http+++localhost+91^userContextId=1 135 // The .metadata-v2 file was intentionally modified to contain only 136 // the 64 bit timestamp, 137 // the 8 bit persisted flag, 138 // the 32 bit reserved data 1, 139 // the 32 bit reserved data 2, 140 // the 32 bit suffix length and 141 // first 5 chars of the suffix 142 // for this origin directory to test restoring. 143 { 144 attrs: { userContextId: 1 }, 145 url: "http://localhost:91", 146 dbName: "dbM", 147 dbVersion: 1, 148 }, 149 150 // This one lives in storage/default/http+++localhost+92^userContextId=1 151 // The .metadata-v2 file was intentionally modified to contain only 152 // the 64 bit timestamp, 153 // the 8 bit persisted flag, 154 // the 32 bit reserved data 1, 155 // the 32 bit reserved data 2, 156 // the 32 bit suffix length and 157 // the suffix 158 // for this origin directory to test restoring. 159 { 160 attrs: { userContextId: 1 }, 161 url: "http://localhost:92", 162 dbName: "dbN", 163 dbVersion: 1, 164 }, 165 166 // This one lives in storage/default/http+++localhost+93^userContextId=1 167 // The .metadata-v2 file was intentionally modified to contain only 168 // the 64 bit timestamp, 169 // the 8 bit persisted flag, 170 // the 32 bit reserved data 1, 171 // the 32 bit reserved data 2, 172 // the 32 bit suffix length, 173 // the suffix and 174 // 2 bytes of the 32 bit group length 175 // for this origin directory to test restoring. 176 { 177 attrs: { userContextId: 1 }, 178 url: "http://localhost:93", 179 dbName: "dbO", 180 dbVersion: 1, 181 }, 182 183 // This one lives in storage/default/http+++localhost+94^userContextId=1 184 // The .metadata-v2 file was intentionally modified to contain only 185 // the 64 bit timestamp, 186 // the 8 bit persisted flag, 187 // the 32 bit reserved data 1, 188 // the 32 bit reserved data 2, 189 // the 32 bit suffix length, 190 // the suffix, 191 // the 32 bit group length and 192 // first 5 chars of the group 193 // for this origin directory to test restoring. 194 { 195 attrs: { userContextId: 1 }, 196 url: "http://localhost:94", 197 dbName: "dbP", 198 dbVersion: 1, 199 }, 200 201 // This one lives in storage/default/http+++localhost+95^userContextId=1 202 // The .metadata-v2 file was intentionally modified to contain only 203 // the 64 bit timestamp, 204 // the 8 bit persisted flag, 205 // the 32 bit reserved data 1, 206 // the 32 bit reserved data 2, 207 // the 32 bit suffix length, 208 // the suffix, 209 // the 32 bit group length and 210 // the group 211 // for this origin directory to test restoring. 212 { 213 attrs: { userContextId: 1 }, 214 url: "http://localhost:95", 215 dbName: "dbQ", 216 dbVersion: 1, 217 }, 218 219 // This one lives in storage/default/http+++localhost+96^userContextId=1 220 // The .metadata-v2 file was intentionally modified to contain only 221 // the 64 bit timestamp, 222 // the 8 bit persisted flag, 223 // the 32 bit reserved data 1, 224 // the 32 bit reserved data 2, 225 // the 32 bit suffix length, 226 // the suffix, 227 // the 32 bit group length, 228 // the group and 229 // 2 bytes of the 32 bit origin length 230 // for this origin directory to test restoring. 231 { 232 attrs: { userContextId: 1 }, 233 url: "http://localhost:96", 234 dbName: "dbR", 235 dbVersion: 1, 236 }, 237 238 // This one lives in storage/default/http+++localhost+97^userContextId=1 239 // The .metadata-v2 file was intentionally modified to contain only 240 // the 64 bit timestamp, 241 // the 8 bit persisted flag, 242 // the 32 bit reserved data 1, 243 // the 32 bit reserved data 2, 244 // the 32 bit suffix length, 245 // the suffix, 246 // the 32 bit group length, 247 // the group, 248 // the 32 bit origin length and 249 // first 12 char of the origin 250 // for this origin directory to test restoring. 251 { 252 attrs: { userContextId: 1 }, 253 url: "http://localhost:97", 254 dbName: "dbS", 255 dbVersion: 1, 256 }, 257 258 // This one lives in storage/default/http+++localhost+98^userContextId=1 259 // The .metadata-v2 file was intentionally modified to contain only 260 // the 64 bit timestamp, 261 // the 8 bit persisted flag, 262 // the 32 bit reserved data 1, 263 // the 32 bit reserved data 2, 264 // the 32 bit suffix length, 265 // the suffix, 266 // the 32 bit group length, 267 // the group, 268 // the 32 bit origin length and 269 // the origin 270 // for this origin directory to test restoring. 271 { 272 attrs: { userContextId: 1 }, 273 url: "http://localhost:98", 274 dbName: "dbT", 275 dbVersion: 1, 276 }, 277 ]; 278 279 function openDatabase(params) { 280 let request; 281 if ("url" in params) { 282 let uri = Services.io.newURI(params.url); 283 let principal = Services.scriptSecurityManager.createContentPrincipal( 284 uri, 285 params.attrs || {} 286 ); 287 request = indexedDB.openForPrincipal( 288 principal, 289 params.dbName, 290 params.dbVersion 291 ); 292 } else { 293 request = indexedDB.open(params.dbName, params.dbVersion); 294 } 295 return request; 296 } 297 298 clearAllDatabases(continueToNextStepSync); 299 yield undefined; 300 301 installPackagedProfile("metadata2Restore_profile"); 302 303 for (let params of openParams) { 304 let request = openDatabase(params); 305 request.onerror = errorHandler; 306 request.onupgradeneeded = unexpectedSuccessHandler; 307 request.onsuccess = grabEventAndContinueHandler; 308 let event = yield undefined; 309 310 is(event.type, "success", "Correct event type"); 311 } 312 313 resetAllDatabases(continueToNextStepSync); 314 yield undefined; 315 316 for (let params of openParams) { 317 let request = openDatabase(params); 318 request.onerror = errorHandler; 319 request.onupgradeneeded = unexpectedSuccessHandler; 320 request.onsuccess = grabEventAndContinueHandler; 321 let event = yield undefined; 322 323 is(event.type, "success", "Correct event type"); 324 } 325 326 finishTest(); 327 yield undefined; 328 }