timeout.sys.mjs (693B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs"; 6 import { setTimeout } from "resource://gre/modules/Timer.sys.mjs"; 7 8 class TimeoutModule extends Module { 9 destroy() {} 10 11 blockProcess(params) { 12 const start = Date.now(); 13 while (Date.now() - start < params.delay) { 14 // Do nothing 15 } 16 } 17 18 async waitFor(params) { 19 await new Promise(r => setTimeout(r, params.delay)); 20 return true; 21 } 22 } 23 24 export const timeout = TimeoutModule;