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

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/writer-starvation.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>Writer starvation</title>
4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
5 <meta name=timeout content=long>
6 <script src=../../../resources/testharness.js></script>
7 <script src=../../../resources/testharnessreport.js></script>
8 <script src=support.js></script>
9
10 <script>
11 var db, read_request_count = 0, read_success_count = 0;
12 var write_request_count = 0, write_success_count = 0;
13 var RQ_COUNT = 25;
14
15 var open_rq = createdb(async_test(undefined, {timeout: 20000}));
16 open_rq.onupgradeneeded = function(e) {
17 db = e.target.result;
18 db.createObjectStore("s")
19 .add("1", 1);
20 }
21
22 open_rq.onsuccess = function(e) {
23 var i = 0, continue_reading = true;
24
25 /* Pre-fill some read requests */
26 for (i = 0; i < RQ_COUNT; i++)
27 {
28 read_request_count++;
29
30 db.transaction("s")
31 .objectStore("s")
32 .get(1)
33 .onsuccess = this.step_func(function(e) {
34 read_success_count++;
35 assert_equals(e.target.transaction.mode, "readonly");
36 });
37 }
38
39 this.step(loop);
40
41 function loop() {
42 read_request_count++;
43
44 db.transaction("s")
45 .objectStore("s")
46 .get(1)
47 .onsuccess = this.step_func(function(e)
48 {
49 read_success_count++;
50 assert_equals(e.target.transaction.mode, "readonly");
51
52 if (read_success_count >= RQ_COUNT && write_request_count == 0)
53 {
54 write_request_count++;
55
56 db.transaction("s", "readwrite")
57 .objectStore("s")
58 .add("written", read_request_count)
59 .onsuccess = this.step_func(function(e)
60 {
61 write_success_count++;
62 assert_equals(e.target.transaction.mode, "readwrite");
63 assert_equals(e.target.result, read_success_count,
64 "write cb came before later read cb's")
65 });
66
67 /* Reads done after the write */
68 for (i = 0; i < 5; i++)
69 {
70 read_request_count++;
71
72 db.transaction("s")
73 .objectStore("s")
74 .get(1)
75 .onsuccess = this.step_func(function(e)
76 {
77 read_success_count++;
78 });
79 }
80 }
81 });
82
83 if (read_success_count < RQ_COUNT + 5)
84 setTimeout(this.step_func(loop), write_request_count ? 1000 : 10 0);
85 else
86 // This is merely a "nice" hack to run finish after the last req uest is done
87 db.transaction("s")
88 .objectStore("s")
89 .count()
90 .onsuccess = this.step_func(function()
91 {
92 setTimeout(this.step_func(finish), 100);
93 });
94 }
95 }
96
97
98 function finish() {
99 assert_equals(read_request_count, read_success_count, "read counts");
100 assert_equals(write_request_count, write_success_count, "write counts");
101 this.done();
102 }
103 </script>
104
105 <div id=log></div>
OLDNEW
« no previous file with comments | « LayoutTests/imported/web-platform-tests/IndexedDB/value_recursive.htm ('k') | LayoutTests/imported/web-platform-tests/LICENSE » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698