diff --git a/dom/cache/test/marionette/test_caches_delete_cleanup_after_shutdown.py b/dom/cache/test/marionette/test_caches_delete_cleanup_after_shutdown.py index 93d63bb80480..d5cf0e2ce99b 100644 --- a/dom/cache/test/marionette/test_caches_delete_cleanup_after_shutdown.py +++ b/dom/cache/test/marionette/test_caches_delete_cleanup_after_shutdown.py @@ -43,21 +43,30 @@ class CachesDeleteCleanupAtShutdownTestCase(MarionetteTestCase): self.marionette.set_pref(QM_TESTING_PREF, False) def getUsage(self): - return self.marionette.execute_script( + usage = self.marionette.execute_async_script( """ - return window.wrappedJSObject.getStorageEstimate(); + const [resolve] = arguments; + window.wrappedJSObject.getStorageEstimate() + .then(resolve) + .catch(()=>resolve(-1)); """, new_sandbox=False, ) + assert ( + usage != -1 + ) # usage should not be an invalid number which gets sets in catch handler above. + return usage def doCacheWork(self, n): # max timeout for this script to execute is 5 minutes maxTimeout = 5 * 60 * 1000 - return self.marionette.execute_script( + assert self.marionette.execute_async_script( """ - const [cacheId, n] = arguments; - return window.wrappedJSObject.doCacheWork(cacheId, n); + const [cacheId, n, resolve] = arguments; + window.wrappedJSObject.doCacheWork(cacheId, n) + .then(()=>resolve(true)) + .catch(()=>resolve(false)); """, script_args=( CACHE_ID, @@ -68,10 +77,12 @@ class CachesDeleteCleanupAtShutdownTestCase(MarionetteTestCase): ) def openCache(self): - return self.marionette.execute_async_script( + assert self.marionette.execute_async_script( """ const [cacheId, resolve] = arguments; - window.wrappedJSObject.openCache(cacheId).then(resolve("success")); + window.wrappedJSObject.openCache(cacheId) + .then(()=>resolve(true)) + .catch(()=>resolve(false)); """, new_sandbox=False, script_args=(CACHE_ID,),