| 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 open request's 'success' 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 open request's 'success' event handler."); |
| 7 | 7 |
| 8 function test() | 8 function test() |
| 9 { | 9 { |
| 10 setDBNameFromPath(); | 10 setDBNameFromPath(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 evalAndLog("request2 = indexedDB.deleteDatabase(dbname)"); | 40 evalAndLog("request2 = indexedDB.deleteDatabase(dbname)"); |
| 41 evalAndLog("request2.onsuccess = deleteSuccessCallback"); | 41 evalAndLog("request2.onsuccess = deleteSuccessCallback"); |
| 42 request2.onerror = unexpectedErrorCallback; | 42 request2.onerror = unexpectedErrorCallback; |
| 43 request2.onblocked = deleteBlockedCallback; | 43 request2.onblocked = deleteBlockedCallback; |
| 44 } | 44 } |
| 45 | 45 |
| 46 function openSuccess(evt) | 46 function openSuccess(evt) |
| 47 { | 47 { |
| 48 preamble(evt); | 48 preamble(evt); |
| 49 shouldBeTrue("sawUpgradeNeeded"); | 49 shouldBeTrue("sawUpgradeNeeded"); |
| 50 shouldBeTrue("sawVersionChange"); | 50 shouldBeFalse("sawVersionChange"); |
| 51 evalAndLog("sawOpenSuccess = true"); | 51 evalAndLog("sawOpenSuccess = true"); |
| 52 evalAndLog("db = event.target.result"); | 52 evalAndLog("db = event.target.result"); |
| 53 shouldBe('db.version', '1'); | 53 shouldBe('db.version', '1'); |
| 54 | |
| 55 // Event ordering between 'success' and 'blocked' is not strictly defined | |
| 56 // in the spec. This documents current Chromium behavior to detect | |
| 57 // unexpected changes. | |
| 58 debug("Closing here is too late to prevent the in-flight 'blocked' event, bu
t it does unblock the delete."); | |
| 59 evalAndLog("db.close()"); | |
| 60 } | 54 } |
| 61 | 55 |
| 62 function versionChangeCallback(evt) | 56 function versionChangeCallback(evt) |
| 63 { | 57 { |
| 64 preamble(evt); | 58 preamble(evt); |
| 65 shouldBe("event.oldVersion", "1"); | 59 shouldBe("event.oldVersion", "1"); |
| 66 shouldBeNull("event.newVersion"); | 60 shouldBeNull("event.newVersion"); |
| 67 shouldBeFalse("sawOpenSuccess"); | 61 shouldBeTrue("sawOpenSuccess"); |
| 68 evalAndLog("sawVersionChange = true"); | 62 evalAndLog("sawVersionChange = true"); |
| 69 debug("Connection not closed at the end of 'versionchange', so 'blocked' sho
uld fire"); | 63 debug("Connection not closed at the end of 'versionchange', so 'blocked' sho
uld fire"); |
| 70 } | 64 } |
| 71 | 65 |
| 72 function deleteBlockedCallback(evt) | 66 function deleteBlockedCallback(evt) |
| 73 { | 67 { |
| 74 preamble(evt); | 68 preamble(evt); |
| 75 shouldBeTrue("sawVersionChange"); | 69 shouldBeTrue("sawVersionChange"); |
| 76 shouldBeTrue("sawOpenSuccess"); | 70 shouldBeTrue("sawOpenSuccess"); |
| 77 evalAndLog("sawDeleteBlocked = true"); | 71 evalAndLog("sawDeleteBlocked = true"); |
| 72 evalAndLog("db.close()"); |
| 78 } | 73 } |
| 79 | 74 |
| 80 function deleteSuccessCallback(evt) | 75 function deleteSuccessCallback(evt) |
| 81 { | 76 { |
| 82 preamble(evt); | 77 preamble(evt); |
| 83 shouldBeTrue("sawVersionChange"); | 78 shouldBeTrue("sawVersionChange"); |
| 84 shouldBeTrue("sawDeleteBlocked"); | 79 shouldBeTrue("sawDeleteBlocked"); |
| 85 finishJSTest(); | 80 finishJSTest(); |
| 86 } | 81 } |
| 87 | 82 |
| 88 test(); | 83 test(); |
| OLD | NEW |