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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/indexeddb.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Indexed DB</title> 2 <title>Service Worker: Indexed DB</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="/resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="/resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.sub.js"></script>
6 <script> 6 <script>
7 async_test(function(t) { 7 async_test(function(t) {
8 var scope = 'resources/blank.html'; 8 var scope = 'resources/blank.html';
9 service_worker_unregister_and_register( 9 service_worker_unregister_and_register(
10 t, 'resources/indexeddb-worker.js', scope) 10 t, 'resources/indexeddb-worker.js', scope)
11 .then(function(registration) { 11 .then(function(registration) {
12 var sw = registration.installing; 12 var sw = registration.installing;
13 var messageChannel = new MessageChannel(); 13 var messageChannel = new MessageChannel();
14 messageChannel.port1.onmessage = t.step_func(onMessage); 14 messageChannel.port1.onmessage = t.step_func(onMessage);
15 sw.postMessage({port: messageChannel.port2}, [messageChannel.port2]); 15 sw.postMessage({port: messageChannel.port2}, [messageChannel.port2]);
16 }) 16 })
17 .catch(unreached_rejection(t)); 17 .catch(unreached_rejection(t));
18 18
19 function onMessage() { 19 function onMessage() {
20 var openRequest = indexedDB.open('db'); 20 var openRequest = indexedDB.open('db');
21 openRequest.onsuccess = t.step_func(function() { 21 openRequest.onsuccess = t.step_func(function() {
22 var db = openRequest.result; 22 var db = openRequest.result;
23 var tx = db.transaction('store'); 23 var tx = db.transaction('store');
24 var store = tx.objectStore('store'); 24 var store = tx.objectStore('store');
25 var getRequest = store.get('key'); 25 var getRequest = store.get('key');
26 getRequest.onsuccess = t.step_func(function() { 26 getRequest.onsuccess = t.step_func(function() {
27 assert_equals( 27 assert_equals(
28 getRequest.result, 'value', 28 getRequest.result, 'value',
29 'The get() result should match what the worker put().'); 29 'The get() result should match what the worker put().');
30 service_worker_unregister_and_done(t, scope); 30 service_worker_unregister_and_done(t, scope);
31 }); 31 });
32 }); 32 });
33 } 33 }
34 }, 'Verify Indexed DB operation in a Service Worker'); 34 }, 'Verify Indexed DB operation in a Service Worker');
35 </script> 35 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698