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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/indexeddb-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/indexeddb-worker.js b/LayoutTests/http/tests/serviceworker/indexeddb-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..5b258be905569c4285980f6028456054a735b9be
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/indexeddb-worker.js
@@ -0,0 +1,46 @@
+var port;
+self.addEventListener('message', function(e) {
+ var message = e.data;
+ if ('port' in message) {
+ port = message.port;
+ doIndexedDBTest();
+ }
+});
+function send(action, text) {
+ if (port) port.postMessage({action: action, text: text});
+}
+
+function evalAndLog(s) {
+ send('log', s);
+ try {
+ return eval(s);
+ } catch (ex) {
+ send('fail', 'EXCEPTION: ' + ex);
+ throw ex;
+ }
+}
+
+function debug(s) {
+ send('log', s);
+}
+
+function doIndexedDBTest() {
+ debug('Preparing the database in the service worker');
+ var request = evalAndLog("indexedDB.deleteDatabase('db')");
+ request.onsuccess = function() {
+ request = evalAndLog("indexedDB.open('db')");
+ request.onupgradeneeded = function() {
+ db = request.result;
+ evalAndLog("db.createObjectStore('store')");
+ };
+ request.onsuccess = function() {
+ db = request.result;
+ evalAndLog("tx = db.transaction('store', 'readwrite')");
+ evalAndLog("store = tx.objectStore('store')");
+ evalAndLog("store.put('value', 'key')");
+ tx.oncomplete = function() {
+ send('quit');
+ };
+ };
+ };
+}
« 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