Bug 1898763: An attempt to fix intermittent failing test, test_caches_delete_cleanup_after_shutdown.py.r=dom-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D229992
This commit is contained in:
Harveer Singh
2024-11-29 17:38:48 +00:00
parent b4945dff62
commit c242346ebd

View File

@@ -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,),