OLD | NEW |
1 if (this.importScripts) { | 1 if (this.importScripts) { |
2 importScripts('../../../resources/js-test.js'); | 2 importScripts('../../../resources/js-test.js'); |
3 importScripts('shared.js'); | 3 importScripts('shared.js'); |
4 } | 4 } |
5 | 5 |
6 description("Test that a deleteDatabase called while handling an upgradeneeded e
vent is queued and fires its events at the right time. The close() call to unblo
ck the delete occurs in the connection's 'versionchange' event handler."); | 6 description("Test that a deleteDatabase called while handling an upgradeneeded e
vent is queued and fires its events at the right time. The close() call to unblo
ck the delete occurs in the connection's 'versionchange' event handler."); |
7 | 7 |
8 function test() | 8 function test() |
9 { | 9 { |
10 removeVendorPrefixes(); | 10 removeVendorPrefixes(); |
11 setDBNameFromPath(); | 11 setDBNameFromPath(); |
12 | 12 |
13 request = evalAndLog("indexedDB.deleteDatabase(dbname)"); | 13 request = evalAndLog("indexedDB.deleteDatabase(dbname)"); |
14 request.onsuccess = initiallyDeleted; | 14 request.onsuccess = initiallyDeleted; |
15 request.onerror = unexpectedErrorCallback; | 15 request.onerror = unexpectedErrorCallback; |
16 } | 16 } |
17 | 17 |
18 var sawUpgradeNeeded = false; | 18 var sawUpgradeNeeded = false; |
19 var sawVersionChange = false; | 19 var sawVersionChange = false; |
| 20 var sawOpenError = false; |
20 | 21 |
21 function initiallyDeleted(evt) { | 22 function initiallyDeleted(evt) { |
22 preamble(evt); | 23 preamble(evt); |
23 evalAndLog("request = indexedDB.open(dbname, 1)"); | 24 evalAndLog("request = indexedDB.open(dbname, 1)"); |
24 request.onupgradeneeded = upgradeNeededCallback; | 25 request.onupgradeneeded = upgradeNeededCallback; |
25 request.onsuccess = unexpectedSuccessCallback; | 26 request.onsuccess = unexpectedSuccessCallback; |
| 27 request.onerror = openError; |
| 28 } |
| 29 |
| 30 function openError(evt) { |
| 31 preamble(evt); |
| 32 shouldBeTrue("sawVersionChange"); |
| 33 evalAndLog("sawOpenError = true"); |
| 34 evt.preventDefault(); |
26 } | 35 } |
27 | 36 |
28 function upgradeNeededCallback(evt) | 37 function upgradeNeededCallback(evt) |
29 { | 38 { |
30 preamble(evt); | 39 preamble(evt); |
31 shouldBeFalse("sawUpgradeNeeded"); | 40 shouldBeFalse("sawUpgradeNeeded"); |
32 evalAndLog("sawUpgradeNeeded = true"); | 41 evalAndLog("sawUpgradeNeeded = true"); |
33 shouldBe("event.oldVersion", "0"); | 42 shouldBe("event.oldVersion", "0"); |
34 shouldBe("event.newVersion", "1"); | 43 shouldBe("event.newVersion", "1"); |
35 | 44 |
(...skipping 12 matching lines...) Expand all Loading... |
48 evalAndLog("sawVersionChange = true"); | 57 evalAndLog("sawVersionChange = true"); |
49 | 58 |
50 debug("Closing the connection before the IDBOpenDBRequest's success fires wi
ll cause the open to fail."); | 59 debug("Closing the connection before the IDBOpenDBRequest's success fires wi
ll cause the open to fail."); |
51 evalAndLog("db.close()"); | 60 evalAndLog("db.close()"); |
52 } | 61 } |
53 | 62 |
54 function deleteSuccessCallback(evt) | 63 function deleteSuccessCallback(evt) |
55 { | 64 { |
56 preamble(evt); | 65 preamble(evt); |
57 shouldBeTrue("sawVersionChange"); | 66 shouldBeTrue("sawVersionChange"); |
| 67 shouldBeTrue("sawOpenError"); |
58 shouldBeTrue("sawUpgradeNeeded"); | 68 shouldBeTrue("sawUpgradeNeeded"); |
59 finishJSTest(); | 69 finishJSTest(); |
60 } | 70 } |
61 | 71 |
62 test(); | 72 test(); |
OLD | NEW |