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

Side by Side Diff: LayoutTests/http/tests/serviceworker/indexeddb-worker.js

Issue 185643009: Implement ServiceWorker::postMessage() [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Pass raw pointer -> PassOwnPtr Created 6 years, 9 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 var port;
2 self.addEventListener('message', function(e) {
3 var message = e.data;
4 if ('port' in message) {
5 port = message.port;
6 doIndexedDBTest();
7 }
8 });
9 function send(action, text) {
10 if (port) port.postMessage({action: action, text: text});
11 }
12
13 function evalAndLog(s) {
14 send('log', s);
15 try {
16 return eval(s);
17 } catch (ex) {
18 send('fail', 'EXCEPTION: ' + ex);
19 throw ex;
20 }
21 }
22
23 function debug(s) {
24 send('log', s);
25 }
26
27 function doIndexedDBTest() {
28 debug('Preparing the database in the service worker');
29 var request = evalAndLog("indexedDB.deleteDatabase('db')");
30 request.onsuccess = function() {
31 request = evalAndLog("indexedDB.open('db')");
32 request.onupgradeneeded = function() {
33 db = request.result;
34 evalAndLog("db.createObjectStore('store')");
35 };
36 request.onsuccess = function() {
37 db = request.result;
38 evalAndLog("tx = db.transaction('store', 'readwrite')");
39 evalAndLog("store = tx.objectStore('store')");
40 evalAndLog("store.put('value', 'key')");
41 tx.oncomplete = function() {
42 send('quit');
43 };
44 };
45 };
46 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/indexeddb-expected.txt ('k') | LayoutTests/http/tests/serviceworker/postmessage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698