tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit def4c11111e9435585c383cc53c7262c683f5277
parent 9cf0006acdaa348439344ac68724701240ebda4e
Author: Alexandre Poirot <poirot.alex@gmail.com>
Date:   Tue,  7 Oct 2025 22:22:10 +0000

Bug 1991698 - [devtools] Use the shared wait-service middleware in the debugger. r=devtools-reviewers,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D267186

Diffstat:
Mdevtools/client/debugger/src/actions/utils/create-store.js | 4+++-
Mdevtools/client/debugger/src/actions/utils/middleware/moz.build | 1-
Ddevtools/client/debugger/src/actions/utils/middleware/wait-service.js | 62--------------------------------------------------------------
Mdevtools/client/framework/test/metrics/browser_metrics_debugger.js | 1+
4 files changed, 4 insertions(+), 64 deletions(-)

diff --git a/devtools/client/debugger/src/actions/utils/create-store.js b/devtools/client/debugger/src/actions/utils/create-store.js @@ -12,7 +12,6 @@ import { createStore, applyMiddleware, } from "devtools/client/shared/vendor/redux"; -import { waitUntilService } from "./middleware/wait-service"; import { log } from "./middleware/log"; import { promise } from "./middleware/promise"; import { timing } from "./middleware/timing"; @@ -24,6 +23,9 @@ const { const { thunk, } = require("resource://devtools/client/shared/redux/middleware/thunk.js"); +const { + waitUntilService, +} = require("resource://devtools/client/shared/redux/middleware/wait-service.js"); /** * This creates a dispatcher with all the standard middleware in place diff --git a/devtools/client/debugger/src/actions/utils/middleware/moz.build b/devtools/client/debugger/src/actions/utils/middleware/moz.build @@ -10,5 +10,4 @@ CompiledModules( "log.js", "promise.js", "timing.js", - "wait-service.js", ) diff --git a/devtools/client/debugger/src/actions/utils/middleware/wait-service.js b/devtools/client/debugger/src/actions/utils/middleware/wait-service.js @@ -1,62 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ - -/** - * A middleware which acts like a service, because it is stateful - * and "long-running" in the background. It provides the ability - * for actions to install a function to be run once when a specific - * condition is met by an action coming through the system. Think of - * it as a thunk that blocks until the condition is met. Example: - * - * ```js - * const services = { WAIT_UNTIL: require('wait-service').NAME }; - * - * { type: services.WAIT_UNTIL, - * predicate: action => action.type === "ADD_ITEM", - * run: (dispatch, getState, action) => { - * // Do anything here. You only need to accept the arguments - * // if you need them. `action` is the action that satisfied - * // the predicate. - * } - * } - * ``` - */ -export const NAME = "@@service/waitUntil"; - -export function waitUntilService({ dispatch, getState }) { - let pending = []; - - function checkPending(action) { - const readyRequests = []; - const stillPending = []; - - // Find the pending requests whose predicates are satisfied with - // this action. Wait to run the requests until after we update the - // pending queue because the request handler may synchronously - // dispatch again and run this service (that use case is - // completely valid). - for (const request of pending) { - if (request.predicate(action)) { - readyRequests.push(request); - } else { - stillPending.push(request); - } - } - - pending = stillPending; - for (const request of readyRequests) { - request.run(dispatch, getState, action); - } - } - - return next => action => { - if (action.type === NAME) { - pending.push(action); - return null; - } - const result = next(action); - checkPending(action); - return result; - }; -} diff --git a/devtools/client/framework/test/metrics/browser_metrics_debugger.js b/devtools/client/framework/test/metrics/browser_metrics_debugger.js @@ -37,6 +37,7 @@ add_task(async function () { "resource://devtools/client/shared/vendor/redux.js", "resource://devtools/client/shared/redux/subscriber.js", "resource://devtools/client/shared/redux/middleware/thunk.js", + "resource://devtools/client/shared/redux/middleware/wait-service.js", // React components loaded from Toolbox and Panel BrowserLoaders "resource://devtools/client/shared/components/menu/MenuButton.js",