Bug 880741 - Add indexeddb to frameworker. r=gavin, a=akeybl
authorShane Caraveo <scaraveo@mozilla.com>
Fri, 07 Jun 2013 11:25:15 -0700
changeset 142939 8bba8f847b9f12c3d5685cf8e34c6d9f22730147
parent 142938 fe30bac80d31f29fb0f93e2d717406e44a27fd33
child 142940 38342c15a73b2d306943bd6219e9a0c4dc4ab22d
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, akeybl
bugs880741
milestone23.0a2
Bug 880741 - Add indexeddb to frameworker. r=gavin, a=akeybl
toolkit/components/social/FrameWorker.jsm
toolkit/components/social/test/browser/browser_frameworker.js
toolkit/components/social/test/browser/worker_social.js
--- a/toolkit/components/social/FrameWorker.jsm
+++ b/toolkit/components/social/FrameWorker.jsm
@@ -131,17 +131,17 @@ FrameWorker.prototype = {
     let sandbox = new Cu.Sandbox(workerWindow);
 
     // copy the window apis onto the sandbox namespace only functions or
     // objects that are naturally a part of an iframe, I'm assuming they are
     // safe to import this way
     let workerAPI = ['WebSocket', 'localStorage', 'atob', 'btoa',
                      'clearInterval', 'clearTimeout', 'dump',
                      'setInterval', 'setTimeout', 'XMLHttpRequest',
-                     'FileReader', 'Blob', 'EventSource',
+                     'FileReader', 'Blob', 'EventSource', 'indexedDB',
                      'location'];
     // Bug 798660 - XHR and WebSocket have issues in a sandbox and need
     // to be unwrapped to work
     let needsWaive = ['XMLHttpRequest', 'WebSocket'];
     // Methods need to be bound with the proper |this|.
     let needsBind = ['atob', 'btoa', 'dump', 'setInterval', 'clearInterval',
                      'setTimeout', 'clearTimeout'];
     workerAPI.forEach(function(fn) {
--- a/toolkit/components/social/test/browser/browser_frameworker.js
+++ b/toolkit/components/social/test/browser/browser_frameworker.js
@@ -647,9 +647,22 @@ let tests = {
       } else if (e.data.topic == "pong") {
         worker.terminate();
         cbnext();
       }
     }
     worker.port.postMessage({topic: "ping"})
   },
 
+
+  testIndexedDB: function(cbnext) {
+    let worker = getFrameWorkerHandle("https://example.com/browser/toolkit/components/social/test/browser/worker_social.js", undefined, "testIndexedDB");
+    worker.port.onmessage = function(e) {
+      let m = e.data;
+      if (m.topic == "social.indexeddb-result") {
+        is(m.data.result, "ok", "created indexeddb");
+        worker.terminate();
+        cbnext();
+      }
+    }
+    worker.port.postMessage({topic: "test-indexeddb-create"})
+  },
 }
--- a/toolkit/components/social/test/browser/worker_social.js
+++ b/toolkit/components/social/test/browser/worker_social.js
@@ -42,16 +42,28 @@ onconnect = function(e) {
         // start
         apiPort.postMessage({topic: 'social.reload-worker'});
         break;
       case "test-notification-create":
         apiPort.postMessage({topic: 'social.notification-create',
                              data: data});
         testerPort.postMessage({topic: 'did-notification-create'});
         break;
+      case "test-indexeddb-create":
+        var request = indexedDB.open("workerdb", 1);
+        request.onerror = function(event) {
+          port.postMessage({topic: 'social.indexeddb-result', data: { result: "error" }});
+        };
+        request.onsuccess = function(event) {
+          // Do something with request.result!
+          var db = request.result;
+          db.close();
+          port.postMessage({topic: 'social.indexeddb-result', data: { result: "ok" }});
+        };
+        break;
     }
   }
   // used for "test-reload-worker"
   if (apiPort && apiPort != port) {
     port.postMessage({topic: "worker.connected"})
   }
 
 }