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

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/keygenerator-constrainterror.htm

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 months 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 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>Keygenerator ConstraintError when using same id as already generated</tit le>
4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
5 <script src="../../../resources/testharness.js"></script>
6 <script src="../../../resources/testharnessreport.js"></script>
7 <script src="support.js"></script>
8
9 <script>
10
11 var db,
12 t = async_test(document.title, {timeout: 10000}),
13 objects = [1, null, {id: 2}, null, 2.00001, 5, null, {id: 6} ],
14 expected = [1, 2, 2.00001, 3, 5, 6],
15 errors = 0;
16
17 var open_rq = createdb(t);
18 open_rq.onupgradeneeded = function(e) {
19 db = e.target.result;
20 var objStore = db.createObjectStore("store", { keyPath: "id", autoIncrem ent: true });
21
22 for (var i = 0; i < objects.length; i++)
23 {
24 if (objects[i] === null)
25 {
26 objStore.add({});
27 }
28 else if (typeof objects[i] === "object")
29 {
30 var rq = objStore.add(objects[i])
31 rq.yeh = objects[i];
32 rq.onerror = t.step_func(function(e) {
33 errors++;
34
35 assert_equals(e.target.error.name, "ConstraintError");
36 assert_equals(e.type, "error");
37
38 e.stopPropagation();
39 e.preventDefault();
40 });
41 rq.onsuccess = t.step_func(function(e) {
42 assert_unreached("Got rq.success when adding duplicate id " + objects[i]);
43 });
44 }
45 else
46 objStore.add({ id: objects[i] });
47 }
48 };
49
50 open_rq.onsuccess = function(e) {
51 var actual_keys = [],
52 rq = db.transaction("store")
53 .objectStore("store")
54 .openCursor();
55
56 rq.onsuccess = t.step_func(function(e) {
57 var cursor = e.target.result;
58
59 if (cursor) {
60 actual_keys.push(cursor.key.valueOf());
61 cursor.continue();
62 }
63 else {
64 assert_equals(errors, 2, "expected ConstraintError's");
65
66 assert_equals(actual_keys.length, expected.length, "array length ");
67 assert_object_equals(actual_keys, expected, "keygenerator array" );
68
69 t.done();
70 }
71 });
72 };
73
74 </script>
75
76 <div id="log"></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698