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

Side by Side Diff: LayoutTests/http/tests/serviceworker/indexeddb.html

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: rebase Created 6 years, 4 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.js"></script>
6 <script> 6 <script>
7 var test = async_test('Verify Indexed DB operation in a Service Worker'); 7 async_test(function(t) {
8 test.step(function() {
9 var scope = 'resources/blank.html'; 8 var scope = 'resources/blank.html';
10 service_worker_unregister_and_register( 9 service_worker_unregister_and_register(
11 test, 'resources/indexeddb-worker.js', scope).then(test.step_func(onRegi ster)); 10 t, 'resources/indexeddb-worker.js', scope)
12 11 .then(function(registration) {
13 function onRegister(worker) { 12 return wait_for_update(t, registration);
13 })
14 .then(function(sw) {
14 var messageChannel = new MessageChannel(); 15 var messageChannel = new MessageChannel();
15 messageChannel.port1.onmessage = test.step_func(onMessage); 16 messageChannel.port1.onmessage = t.step_func(onMessage);
16 17 sw.postMessage({port: messageChannel.port2}, [messageChannel.port2]);
17 worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]) ; 18 })
18 } 19 .catch(unreached_rejection(t));
19 20
20 function onMessage() { 21 function onMessage() {
21 var openRequest = indexedDB.open('db'); 22 var openRequest = indexedDB.open('db');
22 openRequest.onsuccess = test.step_func(function() { 23 openRequest.onsuccess = t.step_func(function() {
23 var db = openRequest.result; 24 var db = openRequest.result;
24 var tx = db.transaction('store'); 25 var tx = db.transaction('store');
25 var store = tx.objectStore('store'); 26 var store = tx.objectStore('store');
26 var getRequest = store.get('key'); 27 var getRequest = store.get('key');
27 getRequest.onsuccess = test.step_func(function() { 28 getRequest.onsuccess = t.step_func(function() {
28 assert_equals(getRequest.result, 'value', 29 assert_equals(
29 'The get() result should match what the worker put ().'); 30 getRequest.result, 'value',
30 service_worker_unregister_and_done(test, scope); 31 'The get() result should match what the worker put().');
32 service_worker_unregister_and_done(t, scope);
31 }); 33 });
32 }); 34 });
33 } 35 }
34 }); 36 }, 'Verify Indexed DB operation in a Service Worker');
35 </script> 37 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698