NEW: foojsapi
authorNikhil Marathe <nsm.nikhil@gmail.com>
Tue, 08 Jul 2014 16:32:42 -0700
changeset 1093 6e9d171e5618840ffeb0d86b7ed5a930cbccacad
parent 1092 9ce0c5217c44e07ec3d07da93c923cc6c77fe771
child 1094 54b8d342043d93fe28205882228a632d2cb79f38
push id32
push usernsm.nikhil@gmail.com
push dateThu, 24 Jul 2014 00:32:46 +0000
NEW: foojsapi qparent: 8bfe3372f848 qtip: e4767a9b7861 top: foojsapi
foojsapi
series
new file mode 100644
--- /dev/null
+++ b/foojsapi
@@ -0,0 +1,102 @@
+# HG changeset patch
+# Parent 8bfe3372f8484b77581d32c526db2ca91d79420f
+# User Nikhil Marathe <nsm.nikhil@gmail.com>
+diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
+--- a/dom/workers/ServiceWorkerManager.cpp
++++ b/dom/workers/ServiceWorkerManager.cpp
+@@ -65,23 +65,24 @@ UpdatePromise::ResolveAllPromises(const 
+   RuntimeService* rs = RuntimeService::GetOrCreateService();
+   MOZ_ASSERT(rs);
+ 
+   nsTArray<nsTWeakRef<Promise>> array;
+   array.SwapElements(mPromises);
+   for (uint32_t i = 0; i < array.Length(); ++i) {
+     nsTWeakRef<Promise>& pendingPromise = array.ElementAt(i);
+     if (pendingPromise) {
+-      nsCOMPtr<nsIGlobalObject> go =
+-        do_QueryInterface(pendingPromise->GetParentObject());
++      nsCOMPtr<nsIGlobalObject> go = pendingPromise->GetParentObject();
+       MOZ_ASSERT(go);
+ 
+-      AutoSafeJSContext cx;
++      AutoJSAPI jsapi;
++      jsapi.Init(go);
++      JSContext* cx = jsapi.cx();
++
+       JS::Rooted<JSObject*> global(cx, go->GetGlobalJSObject());
+-      JSAutoCompartment ac(cx, global);
+ 
+       GlobalObject domGlobal(cx, global);
+ 
+       nsRefPtr<ServiceWorker> serviceWorker;
+       nsresult rv = rs->CreateServiceWorker(domGlobal,
+                                             NS_ConvertUTF8toUTF16(aScriptSpec),
+                                             aScope,
+                                             getter_AddRefs(serviceWorker));
+@@ -962,22 +963,22 @@ ServiceWorkerManager::CreateServiceWorke
+                                                    ServiceWorker** aServiceWorker)
+ {
+   AssertIsOnMainThread();
+   MOZ_ASSERT(aWindow);
+ 
+   RuntimeService* rs = RuntimeService::GetOrCreateService();
+   nsRefPtr<ServiceWorker> serviceWorker;
+ 
++  AutoJSAPI jsapi;
++  jsapi.Init(aWindow);
++  JSContext* cx = jsapi.cx();
++
+   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(aWindow);
+-
+-  AutoSafeJSContext cx;
+   JS::Rooted<JSObject*> jsGlobal(cx, sgo->GetGlobalJSObject());
+-  JSAutoCompartment ac(cx, jsGlobal);
+-
+   GlobalObject global(cx, jsGlobal);
+   nsresult rv = rs->CreateServiceWorker(global,
+                                         NS_ConvertUTF8toUTF16(aScriptSpec),
+                                         aScope,
+                                         getter_AddRefs(serviceWorker));
+ 
+   if (NS_WARN_IF(NS_FAILED(rv))) {
+     return rv;
+diff --git a/dom/workers/test/serviceworkers/test_installation_simple.html b/dom/workers/test/serviceworkers/test_installation_simple.html
+--- a/dom/workers/test/serviceworkers/test_installation_simple.html
++++ b/dom/workers/test/serviceworkers/test_installation_simple.html
+@@ -67,29 +67,35 @@
+       ok(false, "realWorker Registration should have succeeded!");
+     });
+   }
+ 
+   function abortPrevious() {
+     var p = navigator.serviceWorker.register("worker2.js", { scope: "foo/*" });
+     var q = navigator.serviceWorker.register("worker3.js", { scope: "foo/*" });
+ 
+-    return Promise.all([
++    var r = Promise.all([
+       p.then(function(w) {
+         ok(false, "First registration should fail with AbortError");
+       }, function(e) {
+         ok(e.name === "AbortError", "First registration should fail with AbortError");
+       }),
+ 
+       q.then(function(w) {
+         ok(w instanceof ServiceWorker, "Second registration should succeed");
+       }, function(e) {
+         ok(false, "Second registration should succeed");
+       })
+     ]);
++    setTimeout(function() {
++    SpecialPowers.gc();
++    SpecialPowers.gc();
++    SpecialPowers.gc();
++    }, 500);
++    return r;
+   }
+ 
+   function networkError404() {
+     return navigator.serviceWorker.register("404.js").then(function(w) {
+         todo(false, "Should fail with NetworkError");
+       }, function(e) {
+         todo(e.name === "NetworkError", "Should fail with NetworkError");
+       });
--- a/series
+++ b/series
@@ -1,8 +1,9 @@
+foojsapi
 984048-swm-scopes+
 984048-sw-docload
 984048-swm-activate+
 983497-swc-events-infra+
 983497-swc-events+
 1002570-swc-props
 1011268-swm-unregister
 sw-instance-events-and-state-2