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

Side by Side Diff: third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer-helpers.js

Issue 2449563002: [IndexedDB] Add Observer Tests (Closed)
Patch Set: Fixed errors in other tests, and marked observer tests as long Created 4 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
OLDNEW
(Empty)
1 if (this.importScripts) {
2 importScripts('testharness-helpers.js');
3 importScripts('observer-actions.js');
4 }
5
6 window=this;
7 var isWorker = window.document === undefined;
8
9 // This runs two tests with the given body function, one where the database
10 // changes happen in the same frame, and another where the changes happen in
11 // a separate worker.
12 function indexeddb_observers_test(body_func, description) {
13 var db1_prefix = 'db' + self.location.pathname + '-' + description + '1';
14 var db2_prefix = 'db' + self.location.pathname + '-' + description + '2';
15
16 var createDatabases = function(t, db1_name, db2_name, done_callback) {
17 var done_barrier = create_barrier(done_callback);
18 delete_then_open(t, db1_name, function(t, db) {
19 var os1 = db.createObjectStore('store1');
20 var os2 = db.createObjectStore('store2');
21 os1.put('b', 'a');
22 os2.put('y', 'x');
23 }, done_barrier(t));
24
25 delete_then_open(t, db2_name, function(t, db) {
26 var os1 = db.createObjectStore('store3');
27 var os2 = db.createObjectStore('store4');
28 os1.put('c', 'c');
29 os2.put('w', 'w');
30 }, done_barrier(t));
31 }
32
33 async_test(function(t) {
34 var db1_name = db1_prefix + "-frame";
35 var db2_name = db2_prefix + "-frame";
36
37 var observers_added_callback = t.step_func(function() {
38 indexeddb_observers_actions(
39 db1_name, db2_name,
40 t.unreached_func('Error performing observer actions in frame'));
41 });
42 var start_tests = t.step_func(function() {
43 body_func(t, db1_name, db2_name, observers_added_callback);
44 });
45 createDatabases(t, db1_name, db2_name, start_tests);
46 }, description + " (changes in frame).", { timeout: 20000 });
47
48 async_test(function(t) {
49 var db1_name = db1_prefix + "-worker";
50 var db2_name = db2_prefix + "-worker";
51
52 var observers_added_callback = t.step_func(function() {
53 var name_dict = {
54 db1_name: db1_name,
55 db2_name: db2_name
56 };
57 var hash_string = encodeURIComponent(JSON.stringify(name_dict));
58 var url = 'resources/observer-actions.js#' + hash_string;
59
60 // Since Chrome doesn't support starting workers in workers, we have to
61 // implement this postMessage protocol to ask our host frame to start the
62 // given worker.
63 if (isWorker) {
64 postMessage({'start_worker_url': url});
65 } else {
66 new Worker(url);
67 }
68 });
69
70 var start_tests = t.step_func(function() {
71 body_func(t, db1_name, db2_name, observers_added_callback);
72 });
73 createDatabases(t, db1_name, db2_name, start_tests);
74 }, description + ' (changes in worker).', { timeout: 20000 });
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698