Bug 1591102 - Let SpecialPowers.pushPermissions wait until the permissions have been applied r=jdm a=pascalc
authorRob Wu <rob@robwu.nl>
Fri, 25 Oct 2019 03:25:39 +0000
changeset 559874 fea34d94ec4fa5e757d114b546010d285375e7a5
parent 559873 42799e05eaeb8fd9f5694e420bc1d0dbd03901f7
child 559875 8902efec39559defebbecf5d422c3d79cc8d003a
push id12250
push userdvarga@mozilla.com
push dateMon, 04 Nov 2019 11:28:25 +0000
treeherdermozilla-beta@5537d9a9bad3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, pascalc
bugs1591102
milestone71.0
Bug 1591102 - Let SpecialPowers.pushPermissions wait until the permissions have been applied r=jdm a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D50486
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