From a70e37b142e48a695523d4b032e96c4dc7654b0a Mon Sep 17 00:00:00 2001 From: Ciure Andrei Date: Fri, 13 Sep 2019 12:49:35 +0300 Subject: [PATCH] Backed out 3 changesets (bug 1557083) for causing browser_net_block.js to perma fail CLOSED TREE Backed out changeset 82611a6d116f (bug 1557083) Backed out changeset 576da2d2bf32 (bug 1557083) Backed out changeset 613f24ecf1c3 (bug 1557083) --- .../client/netmonitor/src/actions/requests.js | 16 ++---- devtools/client/netmonitor/src/constants.js | 2 - .../client/netmonitor/src/create-store.js | 7 +-- .../netmonitor/test/browser_net_block.js | 17 +----- devtools/client/netmonitor/test/head.js | 23 +------- .../actors/network-monitor/network-monitor.js | 2 - devtools/server/actors/webconsole.js | 57 +++++-------------- 7 files changed, 22 insertions(+), 102 deletions(-) diff --git a/devtools/client/netmonitor/src/actions/requests.js b/devtools/client/netmonitor/src/actions/requests.js index ef88adea394a..d26f821c6a2d 100644 --- a/devtools/client/netmonitor/src/actions/requests.js +++ b/devtools/client/netmonitor/src/actions/requests.js @@ -6,7 +6,6 @@ const { ADD_REQUEST, - BLOCK_SELECTED_REQUEST_DONE, CLEAR_REQUESTS, CLONE_REQUEST, CLONE_SELECTED_REQUEST, @@ -14,7 +13,6 @@ const { RIGHT_CLICK_REQUEST, SEND_CUSTOM_REQUEST, TOGGLE_RECORDING, - UNBLOCK_SELECTED_REQUEST_DONE, UPDATE_REQUEST, } = require("../constants"); const { getSelectedRequest, getRequestById } = require("../selectors/index"); @@ -111,16 +109,13 @@ function sendCustomRequest(connector, requestId = null) { * Tell the backend to block future requests that match the URL of the selected one. */ function blockSelectedRequestURL(connector, clickedRequest) { - return async dispatch => { + return () => { if (!clickedRequest) { return; } const { url } = clickedRequest; - await connector.blockRequest({ url }); - dispatch({ - type: BLOCK_SELECTED_REQUEST_DONE, - }); + connector.blockRequest({ url }); }; } @@ -128,16 +123,13 @@ function blockSelectedRequestURL(connector, clickedRequest) { * Tell the backend to unblock future requests that match the URL of the selected one. */ function unblockSelectedRequestURL(connector, clickedRequest) { - return async dispatch => { + return () => { if (!clickedRequest) { return; } const { url } = clickedRequest; - await connector.unblockRequest({ url }); - dispatch({ - type: UNBLOCK_SELECTED_REQUEST_DONE, - }); + connector.unblockRequest({ url }); }; } diff --git a/devtools/client/netmonitor/src/constants.js b/devtools/client/netmonitor/src/constants.js index 63a087be5031..da2d760aacde 100644 --- a/devtools/client/netmonitor/src/constants.js +++ b/devtools/client/netmonitor/src/constants.js @@ -10,7 +10,6 @@ const actionTypes = { BATCH_ACTIONS: "BATCH_ACTIONS", BATCH_ENABLE: "BATCH_ENABLE", BATCH_FLUSH: "BATCH_FLUSH", - BLOCK_SELECTED_REQUEST_DONE: "BLOCK_SELECTED_REQUEST_DONE", CLEAR_REQUESTS: "CLEAR_REQUESTS", CLEAR_TIMING_MARKERS: "CLEAR_TIMING_MARKERS", CLONE_REQUEST: "CLONE_REQUEST", @@ -32,7 +31,6 @@ const actionTypes = { TOGGLE_COLUMN: "TOGGLE_COLUMN", TOGGLE_RECORDING: "TOGGLE_RECORDING", TOGGLE_REQUEST_FILTER_TYPE: "TOGGLE_REQUEST_FILTER_TYPE", - UNBLOCK_SELECTED_REQUEST_DONE: "UNBLOCK_SELECTED_REQUEST_DONE", UPDATE_REQUEST: "UPDATE_REQUEST", WATERFALL_RESIZE: "WATERFALL_RESIZE", SET_COLUMNS_WIDTH: "SET_COLUMNS_WIDTH", diff --git a/devtools/client/netmonitor/src/create-store.js b/devtools/client/netmonitor/src/create-store.js index 4a5fae7e112f..abf2f0534d10 100644 --- a/devtools/client/netmonitor/src/create-store.js +++ b/devtools/client/netmonitor/src/create-store.js @@ -10,10 +10,6 @@ const { createStore, } = require("devtools/client/shared/vendor/redux"); -const { - waitUntilService, -} = require("devtools/client/shared/redux/middleware/wait-service.js"); - const { MIN_COLUMN_WIDTH, DEFAULT_COLUMN_WIDTH } = require("./constants"); // Middleware @@ -66,8 +62,7 @@ function configureStore(connector, telemetry) { batching, recording(connector), throttling(connector), - eventTelemetry(connector, telemetry), - waitUntilService + eventTelemetry(connector, telemetry) ); return createStore(rootReducer, initialState, middleware); diff --git a/devtools/client/netmonitor/test/browser_net_block.js b/devtools/client/netmonitor/test/browser_net_block.js index f0cf92eff47e..23fd0a545857 100644 --- a/devtools/client/netmonitor/test/browser_net_block.js +++ b/devtools/client/netmonitor/test/browser_net_block.js @@ -43,14 +43,8 @@ add_task(async function() { monitor, "request-list-context-block-url" ); - const onRequestBlocked = waitForDispatch( - store, - "BLOCK_SELECTED_REQUEST_END" - ); contextBlock.click(); - info("Wait for selected request to be blocked"); - await onRequestBlocked; - info("Selected request is now blocked"); + info("Set request to blocked"); } // Reload to have one request in the list @@ -78,15 +72,8 @@ add_task(async function() { monitor, "request-list-context-unblock-url" ); - const onRequestUnblocked = waitForDispatch( - store, - "UNBLOCK_SELECTED_REQUEST_END" - ); contextUnblock.click(); - - info("Wait for selected request to be unblocked"); - await onRequestUnblocked; - info("Selected request is now unblocked"); + info("Set request to unblocked"); } // Reload to have one request in the list diff --git a/devtools/client/netmonitor/test/head.js b/devtools/client/netmonitor/test/head.js index ac610f7a45b1..4ae082cf084f 100644 --- a/devtools/client/netmonitor/test/head.js +++ b/devtools/client/netmonitor/test/head.js @@ -3,7 +3,7 @@ /* import-globals-from ../../shared/test/shared-head.js */ /* exported Toolbox, restartNetMonitor, teardown, waitForExplicitFinish, - verifyRequestItemTarget, waitFor, waitForDispatch, testFilterButtons, + verifyRequestItemTarget, waitFor, testFilterButtons, performRequestsInContent, waitForNetworkEvents, selectIndexAndWaitForSourceEditor, testColumnsAlignment, hideColumn, showColumn, performRequests, waitForRequestData */ @@ -744,27 +744,6 @@ function waitFor(subject, eventName) { }); } -/** - * Wait for an action of the provided type to be dispatched on the provided - * store. - * - * @param {Object} store - * The redux store (wait-service middleware required). - * @param {String} type - * Type of the action to wait for. - */ -function waitForDispatch(store, type) { - return new Promise(resolve => { - store.dispatch({ - type: "@@service/waitUntil", - predicate: action => action.type === type, - run: (dispatch, getState, action) => { - resolve(action); - }, - }); - }); -} - /** * Tests if a button for a filter of given type is the only one checked. * diff --git a/devtools/server/actors/network-monitor/network-monitor.js b/devtools/server/actors/network-monitor/network-monitor.js index 40accf89d7c7..a7e6331665a5 100644 --- a/devtools/server/actors/network-monitor/network-monitor.js +++ b/devtools/server/actors/network-monitor/network-monitor.js @@ -229,13 +229,11 @@ const NetworkMonitorActor = ActorClassWithSpec(networkMonitorSpec, { onBlockRequest({ data }) { const { filter } = data; this.observer.blockRequest(filter); - this.messageManager.sendAsyncMessage("debug:block-request:response"); }, onUnblockRequest({ data }) { const { filter } = data; this.observer.unblockRequest(filter); - this.messageManager.sendAsyncMessage("debug:unblock-request:response"); }, onGetNetworkEventActor({ data }) { diff --git a/devtools/server/actors/webconsole.js b/devtools/server/actors/webconsole.js index 764b8d3cb731..bec2840ef722 100644 --- a/devtools/server/actors/webconsole.js +++ b/devtools/server/actors/webconsole.js @@ -1911,39 +1911,6 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, { }); }, - /** - * Send a message to all the netmonitor message managers, and resolve when - * all of them replied with the expected responseName message. - * - * @param {String} messageName - * Name of the message to send via the netmonitor message managers. - * @param {String} responseName - * Name of the message that should be received when the message has - * been processed by the netmonitor instance. - * @param {Object} args - * argument object passed with the initial message. - */ - async _sendMessageToNetmonitors(messageName, responseName, args) { - if (!this.netmonitors) { - return; - } - await Promise.all( - this.netmonitors.map(({ messageManager }) => { - const onResponseReceived = new Promise(resolve => { - messageManager.addMessageListener( - responseName, - function onResponse() { - messageManager.removeMessageListener(responseName, onResponse); - resolve(); - } - ); - }); - messageManager.sendAsyncMessage(messageName, args); - return onResponseReceived; - }) - ); - }, - /** * Block a request based on certain filtering options. * @@ -1955,11 +1922,13 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, { * An object containing a `url` key with a URL to block. */ async blockRequest(filter) { - await this._sendMessageToNetmonitors( - "debug:block-request", - "debug:block-request:response", - { filter } - ); + if (this.netmonitors) { + for (const { messageManager } of this.netmonitors) { + messageManager.sendAsyncMessage("debug:block-request", { + filter, + }); + } + } return {}; }, @@ -1975,11 +1944,13 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, { * An object containing a `url` key with a URL to unblock. */ async unblockRequest(filter) { - await this._sendMessageToNetmonitors( - "debug:unblock-request", - "debug:unblock-request:response", - { filter } - ); + if (this.netmonitors) { + for (const { messageManager } of this.netmonitors) { + messageManager.sendAsyncMessage("debug:unblock-request", { + filter, + }); + } + } return {}; },