Bug 1591102 - Let SpecialPowers.pushPermissions wait until the permissions have been applied r=jdm draft
authorRob Wu <rob@robwu.nl>
Thu, 24 Oct 2019 15:56:38 +0000
changeset 2396009 a78cf4c3bbf2c7814b17ce1013583ca3a55eec30
parent 2395845 724c75f9d98fa441703a4e36f294672859e138d7
child 2396010 629f8b61efa4b737a0e6949ce76f096e2abf0dca
push id439671
push userreviewbot
push dateThu, 24 Oct 2019 15:57:04 +0000
treeherdertry@b7974acd8b8b [default view] [failures only]
reviewersjdm
bugs1591102
milestone72.0a1
Bug 1591102 - Let SpecialPowers.pushPermissions wait until the permissions have been applied r=jdm Differential Diff: PHID-DIFF-4q2yrvdnc4mbeirf3z64
testing/specialpowers/content/SpecialPowersChild.jsm
--- a/testing/specialpowers/content/SpecialPowersChild.jsm
+++ b/testing/specialpowers/content/SpecialPowersChild.jsm
@@ -909,23 +909,28 @@ class SpecialPowersChild extends JSWindo
           // bind() is used to set 'this' to SpecialPowersAPI itself.
           this._addMessageListener(
             "specialpowers-perm-changed",
             this.permChangedProxy.bind(this)
           );
         }
       }
       this._permissionsUndoStack.push(cleanupPermissions);
-      this._pendingPermissions.push([
-        pendingPermissions,
-        this._delayCallbackTwice(callback),
-      ]);
-      this._applyPermissions();
+      await new Promise(resolve => {
+        this._pendingPermissions.push([
+          pendingPermissions,
+          this._delayCallbackTwice(resolve),
+        ]);
+        this._applyPermissions();
+      });
     } else {
-      this._setTimeout(callback);
+      await this.promiseTimeout();
+    }
+    if (callback) {
+      callback();
     }
   }
 
   /*
    * This function should be used when specialpowers is in content process but
    * it want to get the notification from chrome space.
    *
    * This function will call Services.obs.addObserver in SpecialPowersObserver