Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/test/data/indexeddb/version_change_crash.js

Issue 8341092: Verify that VERSION_CHANGE transactions are rolled back after crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: incorporating feedback Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 window.indexedDB = window.indexedDB || window.webkitIndexedDB;
6 window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
7
8 window.testResult = '';
9
10 var INDUCE_BROWSER_CRASH_URL = 'about:inducebrowsercrashforrealz';
11 function crashBrowser() {
12 chrome.tabs.create({url: INDUCE_BROWSER_CRASH_URL}, callbackFail(ERROR));
13 }
14
15
16 function test() {
17
18 var openreq = window.indexedDB.open('test-db');
19 openreq.onsuccess = function(e) {
20 var db = openreq.result;
21
22 if (document.location.hash === '#part1') {
23 testPart1(db);
24 } else if (document.location.hash === '#part2') {
25 testPart2(db);
26 } else if (document.location.hash === '#part3') {
27 testPart3(db);
28 } else {
29 window.testResult = 'fail';
30 }
31 };
32 }
33
34 function testPart1(db) {
35 // Prepare the database, then exit normally
36
37 // Set version 1, create store1
38 var setverreq = db.setVersion('1.0');
39 setverreq.onsuccess = function(e) {
40 db.createObjectStore('store1');
41 setverreq.result.oncomplete = function (e) {
42 window.testResult = 'part1 - complete';
43 };
44 };
45 }
46
47 function testPart2(db) {
48 // Start a VERSION_CHANGE then crash
49
50 // Set version 2, twiddle stores and crash
51 var setverreq = db.setVersion('2.0');
52 setverreq.onsuccess = function(e) {
53 var store = db.createObjectStore('store2');
54 window.testResult = 'part2 - crash me';
55
56 // Keep adding to the transaction so it can't commit
57 (function loop() { store.put(0, 0).onsuccess = loop; }());
58 };
59 }
60
61 function testPart3(db) {
62 // Validate that Part 2 never committed
63
64 // Check version
65 if (db.version !== '1.0') {
66 window.testResult = 'fail, version incorrect';
67 return;
68 }
69
70 if (!db.objectStoreNames.contains('store1')) {
71 window.testResult = 'fail, store1 does not exist';
72 return;
73 }
74
75 if (db.objectStoreNames.contains('store2')) {
76 window.testResult = 'fail, store2 exists';
77 return;
78 }
79
80 window.testResult = 'part3 - pass';
81 }
OLDNEW
« no previous file with comments | « chrome/test/data/indexeddb/version_change_crash.html ('k') | chrome/test/functional/indexeddb.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698