bug 880741 add indexeddb to frameworker, r=gavin
authorShane Caraveo <scaraveo@mozilla.com>
Fri, 07 Jun 2013 11:25:15 -0700
changeset 146042 7e181e566679c3133b7a7f2b63c7c452579a2633
parent 146041 7c3e3ad77c89fe87f997dff1969d614e8ed00c1e
child 146043 b6652771e70fdd26ef094381aaffb1af1ae3de6f
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs880741
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 880741 add indexeddb to frameworker, r=gavin
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"})
   }
 
 }