зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1572442 - Refactor how we create Console's network data provider. r=Honza.
The DataProvider is what allows us to use the Netmonitor components. The way it was created before was non optimal, as it were inside an enhancer, and was then attached to a proxy. As we may now have multiple proxies, this could cause some issue. So we take this as an opportunity to create the DataProvider in the WebConsoleWrapper (where live the actions we need for the provider), and remove the now unused function on the WebConsoleConnectionProxy. Differential Revision: https://phabricator.services.mozilla.com/D41354 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f07d2560ed
Коммит
91cb50a784
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const DataProvider = require("devtools/client/netmonitor/src/connector/firefox-data-provider");
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getAllNetworkMessagesUpdateById,
|
getAllNetworkMessagesUpdateById,
|
||||||
} = require("devtools/client/webconsole/selectors/messages");
|
} = require("devtools/client/webconsole/selectors/messages");
|
||||||
|
@ -29,37 +27,17 @@ const {
|
||||||
* unnecessary data over RDP.
|
* unnecessary data over RDP.
|
||||||
*/
|
*/
|
||||||
function enableNetProvider(webConsoleUI) {
|
function enableNetProvider(webConsoleUI) {
|
||||||
let dataProvider;
|
|
||||||
return next => (reducer, initialState, enhancer) => {
|
return next => (reducer, initialState, enhancer) => {
|
||||||
function netProviderEnhancer(state, action) {
|
function netProviderEnhancer(state, action) {
|
||||||
const proxy = webConsoleUI ? webConsoleUI.getProxy() : null;
|
const dataProvider =
|
||||||
if (!proxy) {
|
webConsoleUI &&
|
||||||
|
webConsoleUI.wrapper &&
|
||||||
|
webConsoleUI.wrapper.networkDataProvider;
|
||||||
|
|
||||||
|
if (!dataProvider) {
|
||||||
return reducer(state, action);
|
return reducer(state, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
const actions = {
|
|
||||||
updateRequest: (id, data, batch) => {
|
|
||||||
return proxy.dispatchRequestUpdate(id, data);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Data provider implements async logic for fetching
|
|
||||||
// data from the backend. It's created the first
|
|
||||||
// time it's needed.
|
|
||||||
if (!dataProvider && proxy.webConsoleClient) {
|
|
||||||
dataProvider = new DataProvider({
|
|
||||||
actions,
|
|
||||||
webConsoleClient: proxy.webConsoleClient,
|
|
||||||
});
|
|
||||||
|
|
||||||
// /!\ This is terrible, but it allows ResponsePanel to be able to call
|
|
||||||
// `dataProvider.requestData` to fetch response content lazily.
|
|
||||||
// `proxy.networkDataProvider` is put by WebConsoleOutputWrapper on
|
|
||||||
// `serviceContainer` which allow NetworkEventMessage to expose requestData on
|
|
||||||
// the fake `connector` object it hands over to ResponsePanel.
|
|
||||||
proxy.networkDataProvider = dataProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
const type = action.type;
|
const type = action.type;
|
||||||
const newState = reducer(state, action);
|
const newState = reducer(state, action);
|
||||||
|
|
||||||
|
|
|
@ -60,15 +60,3 @@ async function testNetworkMessage(messageNode) {
|
||||||
messageNode.querySelector("#headers-panel .headers-overview")
|
messageNode.querySelector("#headers-panel .headers-overview")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wait until all lazily fetch requests in netmonitor get finished.
|
|
||||||
* Otherwise test will be shutdown too early and cause failure.
|
|
||||||
*/
|
|
||||||
async function waitForLazyRequests(toolbox) {
|
|
||||||
const { ui } = toolbox.getCurrentPanel().hud;
|
|
||||||
const proxy = ui.proxy;
|
|
||||||
return waitUntil(() => {
|
|
||||||
return !proxy.networkDataProvider.lazyRequestData.size;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -346,15 +346,3 @@ function expandXhrMessage(node) {
|
||||||
node.querySelector(".url").click();
|
node.querySelector(".url").click();
|
||||||
return waitFor(() => node.querySelector(".network-info"));
|
return waitFor(() => node.querySelector(".network-info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wait until all lazily fetch requests in netmonitor get finished.
|
|
||||||
* Otherwise test will be shutdown too early and cause failure.
|
|
||||||
*/
|
|
||||||
async function waitForLazyRequests(toolbox) {
|
|
||||||
const { ui } = toolbox.getCurrentPanel().hud;
|
|
||||||
const proxy = ui.proxy;
|
|
||||||
return waitUntil(() => {
|
|
||||||
return !proxy.networkDataProvider.lazyRequestData.size;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -1520,3 +1520,14 @@ function toggleLayout(hud) {
|
||||||
});
|
});
|
||||||
return waitFor(() => isEditorModeEnabled(hud) === !enabled);
|
return waitFor(() => isEditorModeEnabled(hud) === !enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait until all lazily fetch requests in netmonitor get finished.
|
||||||
|
* Otherwise test will be shutdown too early and cause failure.
|
||||||
|
*/
|
||||||
|
async function waitForLazyRequests(toolbox) {
|
||||||
|
const { wrapper } = toolbox.getCurrentPanel().hud.ui;
|
||||||
|
return waitUntil(() => {
|
||||||
|
return !wrapper.networkDataProvider.lazyRequestData.size;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,10 @@ const WebConsoleWrapper = require("devtools/client/webconsole/webconsole-wrapper
|
||||||
const { messagesAdd } = require("devtools/client/webconsole/actions/messages");
|
const { messagesAdd } = require("devtools/client/webconsole/actions/messages");
|
||||||
|
|
||||||
async function getWebConsoleWrapper() {
|
async function getWebConsoleWrapper() {
|
||||||
const hud = { target: { client: {} }, getMappedExpression: () => {} };
|
const hud = {
|
||||||
|
target: { client: {}, getFront: () => {} },
|
||||||
|
getMappedExpression: () => {},
|
||||||
|
};
|
||||||
const webConsoleUi = getWebConsoleUiMock(hud);
|
const webConsoleUi = getWebConsoleUiMock(hud);
|
||||||
|
|
||||||
const wcow = new WebConsoleWrapper(null, webConsoleUi, null, null);
|
const wcow = new WebConsoleWrapper(null, webConsoleUi, null, null);
|
||||||
|
|
|
@ -355,15 +355,6 @@ class WebConsoleConnectionProxy {
|
||||||
this.webConsoleUI.wrapper.dispatchMessageUpdate(networkInfo, response);
|
this.webConsoleUI.wrapper.dispatchMessageUpdate(networkInfo, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchRequestUpdate(id, data) {
|
|
||||||
// Some request might try to update while we are closing the toolbox.
|
|
||||||
if (!this.webConsoleUI) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.webConsoleUI.wrapper.dispatchRequestUpdate(id, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release an object actor.
|
* Release an object actor.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,6 +34,8 @@ const EventEmitter = require("devtools/shared/event-emitter");
|
||||||
const App = createFactory(require("devtools/client/webconsole/components/App"));
|
const App = createFactory(require("devtools/client/webconsole/components/App"));
|
||||||
const ObjectClient = require("devtools/shared/client/object-client");
|
const ObjectClient = require("devtools/shared/client/object-client");
|
||||||
const LongStringClient = require("devtools/shared/client/long-string-client");
|
const LongStringClient = require("devtools/shared/client/long-string-client");
|
||||||
|
const DataProvider = require("devtools/client/netmonitor/src/connector/firefox-data-provider");
|
||||||
|
|
||||||
loader.lazyRequireGetter(
|
loader.lazyRequireGetter(
|
||||||
this,
|
this,
|
||||||
"Constants",
|
"Constants",
|
||||||
|
@ -73,18 +75,27 @@ class WebConsoleWrapper {
|
||||||
this.queuedMessageUpdates = [];
|
this.queuedMessageUpdates = [];
|
||||||
this.queuedRequestUpdates = [];
|
this.queuedRequestUpdates = [];
|
||||||
this.throttledDispatchPromise = null;
|
this.throttledDispatchPromise = null;
|
||||||
|
|
||||||
this.telemetry = new Telemetry();
|
this.telemetry = new Telemetry();
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(async resolve => {
|
||||||
const attachRefToWebConsoleUI = (id, node) => {
|
const attachRefToWebConsoleUI = (id, node) => {
|
||||||
this.webConsoleUI[id] = node;
|
this.webConsoleUI[id] = node;
|
||||||
};
|
};
|
||||||
const { webConsoleUI } = this;
|
const { webConsoleUI } = this;
|
||||||
const debuggerClient = this.hud.target.client;
|
const debuggerClient = this.hud.target.client;
|
||||||
|
|
||||||
|
const webConsoleClient = await this.hud.target.getFront("console");
|
||||||
|
this.networkDataProvider = new DataProvider({
|
||||||
|
actions: {
|
||||||
|
updateRequest: (id, data) => {
|
||||||
|
return this.batchedRequestUpdates({ id, data });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
webConsoleClient,
|
||||||
|
});
|
||||||
|
|
||||||
const serviceContainer = {
|
const serviceContainer = {
|
||||||
attachRefToWebConsoleUI,
|
attachRefToWebConsoleUI,
|
||||||
emitNewMessage: (node, messageId, timeStamp) => {
|
emitNewMessage: (node, messageId, timeStamp) => {
|
||||||
|
@ -136,9 +147,8 @@ class WebConsoleWrapper {
|
||||||
const proxy = webConsoleUI.getProxy();
|
const proxy = webConsoleUI.getProxy();
|
||||||
return proxy.webConsoleClient.getString(grip);
|
return proxy.webConsoleClient.getString(grip);
|
||||||
},
|
},
|
||||||
requestData(id, type) {
|
requestData: (id, type) => {
|
||||||
const proxy = webConsoleUI.getProxy();
|
return this.networkDataProvider.requestData(id, type);
|
||||||
return proxy.networkDataProvider.requestData(id, type);
|
|
||||||
},
|
},
|
||||||
onViewSource(frame) {
|
onViewSource(frame) {
|
||||||
if (webConsoleUI && webConsoleUI.hud && webConsoleUI.hud.viewSource) {
|
if (webConsoleUI && webConsoleUI.hud && webConsoleUI.hud.viewSource) {
|
||||||
|
@ -584,10 +594,6 @@ class WebConsoleWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchRequestUpdate(id, data) {
|
|
||||||
return this.batchedRequestUpdates({ id, data });
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatchSidebarClose() {
|
dispatchSidebarClose() {
|
||||||
store.dispatch(actions.sidebarClose());
|
store.dispatch(actions.sidebarClose());
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче