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

Unified Diff: LayoutTests/http/tests/serviceworker/indexeddb.html

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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/http/tests/serviceworker/indexeddb-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/indexeddb.html
diff --git a/LayoutTests/http/tests/serviceworker/indexeddb.html b/LayoutTests/http/tests/serviceworker/indexeddb.html
new file mode 100644
index 0000000000000000000000000000000000000000..3766f376b11e49f23401cb7e069d48c658911a49
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/indexeddb.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+
+description("Verify that IndexedDB is functional in a ServiceWorker");
+var jsTestIsAsync = true;
+
+evalAndLog("messageChannel = new MessageChannel()");
+evalAndLog("messageChannel.port1.onmessage = onMessageHandler");
+
+debug("");
+evalAndLog("navigator.serviceWorker.register('indexeddb-worker.js')").then(
+ function(result) {
+ serviceWorker = result;
+ evalAndLog("serviceWorker.postMessage({port: messageChannel.port2}, [messageChannel.port2])");
+ },
+ function(reason) {
+ testFailed(reason.name);
+ finishJSTest();
+ });
+
+function onMessageHandler(e) {
+ var prefix = "[ServiceWorker] ";
+ message = e.data;
+ switch (message.action) {
+ case 'log':
+ debug(prefix + message.text);
+ break;
+ case 'pass':
+ testPassed(prefix + message.text);
+ break;
+ case 'fail':
+ testFailed(prefix + message.text);
+ break;
+ case 'quit':
+ verifyDatabase();
+ break;
+ }
+}
+
+function verifyDatabase() {
+ debug("");
+ debug("Verifying the database from the page");
+ debug("");
+ evalAndLog("request = indexedDB.open('db')");
+ request.onsuccess = function() {
+ evalAndLog("db = request.result");
+ evalAndLog("tx = db.transaction('store')");
+ evalAndLog("store = tx.objectStore('store')");
+ evalAndLog("request = store.get('key')");
+ request.onsuccess = function() {
+ shouldBe("request.result", "'value'");
+ finishJSTest();
+ };
+ };
+}
+</script>
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/http/tests/serviceworker/indexeddb-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698