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

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

Issue 5904004: IndexedDB: Update browser tests to test for IDB exception codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 function recordNotFound() 5 function recordNotFound()
6 { 6 {
7 debug('Removed data can no longer be found'); 7 debug('Removed data can no longer be found');
8 8
9 debug('Retrieving an index'); 9 debug('Retrieving an index');
10 shouldBe("objectStore.index('fname_index').name", "'fname_index'"); 10 shouldBe("objectStore.index('fname_index').name", "'fname_index'");
(...skipping 22 matching lines...) Expand all
33 33
34 shouldBe("event.result.fname", "'John'"); 34 shouldBe("event.result.fname", "'John'");
35 shouldBe("event.result.lname", "'Doe'"); 35 shouldBe("event.result.lname", "'Doe'");
36 shouldBe("event.result.id", "1"); 36 shouldBe("event.result.id", "1");
37 37
38 var result = objectStore.delete(1); 38 var result = objectStore.delete(1);
39 result.onsuccess = removeSuccess; 39 result.onsuccess = removeSuccess;
40 result.onerror = unexpectedErrorCallback; 40 result.onerror = unexpectedErrorCallback;
41 } 41 }
42 42
43 function addWithSameKeyFailed()
44 {
45 debug('Adding a record with same key failed');
46 shouldBe("event.code", "webkitIDBDatabaseException.CONSTRAINT_ERR");
47
48 var result = objectStore.get(1);
49 result.onsuccess = getSuccess;
50 result.onerror = unexpectedErrorCallback;
51 }
52
43 function dataAddedSuccess() 53 function dataAddedSuccess()
44 { 54 {
45 debug('Data added'); 55 debug('Data added');
46 56
47 var result = objectStore.get(1); 57 debug('Try to add employee with same id');
48 result.onsuccess = getSuccess; 58 var result = objectStore.add({fname: "Tom", lname: "Jones", id: 1});
49 result.onerror = unexpectedErrorCallback; 59 result.onsuccess = unexpectedSuccessCallback;
60 result.onerror = addWithSameKeyFailed;
50 } 61 }
51 62
52 function populateObjectStore() 63 function populateObjectStore()
53 { 64 {
54 debug('Populating object store'); 65 debug('Populating object store');
55 deleteAllObjectStores(db); 66 deleteAllObjectStores(db);
56 window.objectStore = db.createObjectStore('employees', {keyPath: 'id'}); 67 window.objectStore = db.createObjectStore('employees', {keyPath: 'id'});
57 shouldBe("objectStore.name", "'employees'"); 68 shouldBe("objectStore.name", "'employees'");
58 shouldBe("objectStore.keyPath", "'id'"); 69 shouldBe("objectStore.keyPath", "'id'");
59 70
(...skipping 17 matching lines...) Expand all
77 result.onerror = unexpectedErrorCallback; 88 result.onerror = unexpectedErrorCallback;
78 } 89 }
79 90
80 function test() 91 function test()
81 { 92 {
82 debug('Connecting to indexedDB'); 93 debug('Connecting to indexedDB');
83 var result = webkitIndexedDB.open('name'); 94 var result = webkitIndexedDB.open('name');
84 result.onsuccess = setVersion; 95 result.onsuccess = setVersion;
85 result.onerror = unexpectedErrorCallback; 96 result.onerror = unexpectedErrorCallback;
86 } 97 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698