mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 20:42:49 +00:00
Bug 1686440 - [devtools] Fix webconsole network events and stacktrace tests r=ochameau,nchevobbe
Fixes browser_webconsole_stubs_network_event.js Fixes browser_webconsole_network_messages_stacktrace_console_initiated_request.js Differential Revision: https://phabricator.services.mozilla.com/D99623
This commit is contained in:
parent
e8f4f16d7b
commit
c0cca06a13
@ -8,5 +8,4 @@ DevToolsModules(
|
||||
"batching.js",
|
||||
"css-error-reporting.js",
|
||||
"message-cache-clearing.js",
|
||||
"net-provider.js",
|
||||
)
|
||||
|
@ -1,82 +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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
getAllNetworkMessagesUpdateById,
|
||||
} = require("devtools/client/webconsole/selectors/messages");
|
||||
|
||||
const {
|
||||
getMessage,
|
||||
getAllMessagesUiById,
|
||||
} = require("devtools/client/webconsole/selectors/messages");
|
||||
|
||||
const {
|
||||
MESSAGE_OPEN,
|
||||
NETWORK_MESSAGES_UPDATE,
|
||||
} = require("devtools/client/webconsole/constants");
|
||||
|
||||
/**
|
||||
* This enhancer is responsible for fetching HTTP details data
|
||||
* collected by the backend. The fetch happens on-demand
|
||||
* when the user expands network log in order to inspect it.
|
||||
*
|
||||
* This way we don't slow down the Console logging by fetching.
|
||||
* unnecessary data over RDP.
|
||||
*/
|
||||
function enableNetProvider(webConsoleUI) {
|
||||
return next => (reducer, initialState, enhancer) => {
|
||||
function netProviderEnhancer(state, action) {
|
||||
const dataProvider =
|
||||
webConsoleUI &&
|
||||
webConsoleUI.wrapper &&
|
||||
webConsoleUI.wrapper.networkDataProvider;
|
||||
|
||||
if (!dataProvider) {
|
||||
return reducer(state, action);
|
||||
}
|
||||
|
||||
const { type } = action;
|
||||
const newState = reducer(state, action);
|
||||
|
||||
// If network message has been opened, fetch all HTTP details
|
||||
// from the backend. It can happen (especially in test) that
|
||||
// the message is opened before all network event updates are
|
||||
// received. The rest of updates will be handled below, see:
|
||||
// NETWORK_MESSAGES_UPDATE action handler.
|
||||
if (type == MESSAGE_OPEN) {
|
||||
const updates = getAllNetworkMessagesUpdateById(newState);
|
||||
const message = updates[action.id];
|
||||
if (message && !message.openedOnce && message.source == "network") {
|
||||
dataProvider.onNetworkResourceAvailable(message);
|
||||
dataProvider.onNetworkResourceUpdated(message);
|
||||
}
|
||||
}
|
||||
|
||||
// Process all incoming HTTP details packets. Note that
|
||||
// Network event update packets are sent in batches from:
|
||||
// `WebConsoleOutputWrapper.dispatchMessagesUpdate` using
|
||||
// NETWORK_MESSAGES_UPDATE action.
|
||||
// Make sure to call `dataProvider.onNetworkResourceUpdated`
|
||||
// to fetch data from the backend.
|
||||
if (type == NETWORK_MESSAGES_UPDATE) {
|
||||
const allMessages = getAllMessagesUiById(newState);
|
||||
for (const { actor } of action.messages) {
|
||||
const open = allMessages.includes(actor);
|
||||
if (open) {
|
||||
const message = getMessage(newState, actor);
|
||||
dataProvider.onNetworkResourceUpdated(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newState;
|
||||
}
|
||||
|
||||
return next(netProviderEnhancer, initialState, enhancer);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = enableNetProvider;
|
@ -488,7 +488,6 @@ function messages(
|
||||
if (currMessage.source == "network") {
|
||||
openState.messagesById = new Map(messagesById).set(action.id, {
|
||||
...currMessage,
|
||||
openedOnce: true,
|
||||
});
|
||||
}
|
||||
return openState;
|
||||
|
@ -33,7 +33,6 @@ const { thunk } = require("devtools/client/shared/redux/middleware/thunk");
|
||||
const enableBatching = require("devtools/client/webconsole/enhancers/batching");
|
||||
const enableActorReleaser = require("devtools/client/webconsole/enhancers/actor-releaser");
|
||||
const ensureCSSErrorReportingEnabled = require("devtools/client/webconsole/enhancers/css-error-reporting");
|
||||
const enableNetProvider = require("devtools/client/webconsole/enhancers/net-provider");
|
||||
const enableMessagesCacheClearing = require("devtools/client/webconsole/enhancers/message-cache-clearing");
|
||||
|
||||
/**
|
||||
@ -110,7 +109,6 @@ function configureStore(webConsoleUI, options = {}) {
|
||||
middleware,
|
||||
enableActorReleaser(webConsoleUI),
|
||||
enableBatching(),
|
||||
enableNetProvider(webConsoleUI),
|
||||
enableMessagesCacheClearing(webConsoleUI),
|
||||
ensureCSSErrorReportingEnabled(webConsoleUI)
|
||||
)
|
||||
|
@ -28,6 +28,7 @@ rawPackets.set(`GET request`, {
|
||||
"isXHR": false,
|
||||
"cause": {
|
||||
"type": "img",
|
||||
"loadingDocumentUri": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
"stacktraceAvailable": true,
|
||||
"lastFrame": {
|
||||
"filename": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
@ -66,6 +67,7 @@ rawPackets.set(`GET request update`, {
|
||||
"isXHR": false,
|
||||
"cause": {
|
||||
"type": "img",
|
||||
"loadingDocumentUri": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
"stacktraceAvailable": true,
|
||||
"lastFrame": {
|
||||
"filename": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
@ -104,6 +106,7 @@ rawPackets.set(`XHR GET request`, {
|
||||
"isXHR": true,
|
||||
"cause": {
|
||||
"type": "xhr",
|
||||
"loadingDocumentUri": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
"stacktraceAvailable": true,
|
||||
"lastFrame": {
|
||||
"filename": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
@ -141,6 +144,7 @@ rawPackets.set(`XHR GET request update`, {
|
||||
"isXHR": true,
|
||||
"cause": {
|
||||
"type": "xhr",
|
||||
"loadingDocumentUri": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
"stacktraceAvailable": true,
|
||||
"lastFrame": {
|
||||
"filename": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
@ -179,6 +183,7 @@ rawPackets.set(`XHR POST request`, {
|
||||
"isXHR": true,
|
||||
"cause": {
|
||||
"type": "xhr",
|
||||
"loadingDocumentUri": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
"stacktraceAvailable": true,
|
||||
"lastFrame": {
|
||||
"filename": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
@ -216,6 +221,7 @@ rawPackets.set(`XHR POST request update`, {
|
||||
"isXHR": true,
|
||||
"cause": {
|
||||
"type": "xhr",
|
||||
"loadingDocumentUri": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
"stacktraceAvailable": true,
|
||||
"lastFrame": {
|
||||
"filename": "http://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-network-event.html",
|
||||
|
@ -80,7 +80,6 @@ exports.NetworkEventMessage = function(props) {
|
||||
totalTime: null,
|
||||
indent: 0,
|
||||
updates: null,
|
||||
openedOnce: false,
|
||||
securityState: null,
|
||||
securityInfo: null,
|
||||
requestHeadersFromUploadStream: null,
|
||||
|
@ -60,8 +60,6 @@ class WebConsoleUI {
|
||||
this.hud = hud;
|
||||
this.hudId = this.hud.hudId;
|
||||
this.isBrowserConsole = this.hud.isBrowserConsole;
|
||||
// Map of all stacktrace resources keyed by network event's channelId
|
||||
this.netEventStackTraces = new Map();
|
||||
|
||||
this.isBrowserToolboxConsole =
|
||||
this.hud.currentTarget &&
|
||||
@ -386,37 +384,13 @@ class WebConsoleUI {
|
||||
}
|
||||
|
||||
if (resource.resourceType === TYPES.NETWORK_EVENT_STACKTRACE) {
|
||||
this.netEventStackTraces.set(resource.resourceId, resource);
|
||||
this.wrapper.networkDataProvider?.onStackTraceAvailable(resource);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resource.resourceType === TYPES.NETWORK_EVENT) {
|
||||
// Add the stacktrace
|
||||
if (this.netEventStackTraces.has(resource.resourceId)) {
|
||||
const {
|
||||
stacktraceAvailable,
|
||||
lastFrame,
|
||||
targetFront,
|
||||
} = this.netEventStackTraces.get(resource.resourceId);
|
||||
|
||||
resource.cause.stacktraceAvailable = stacktraceAvailable;
|
||||
resource.cause.lastFrame = lastFrame;
|
||||
this.netEventStackTraces.delete(resource.resourceId);
|
||||
|
||||
if (
|
||||
this.wrapper?.networkDataProvider?.stackTraceRequestInfoByActorID
|
||||
) {
|
||||
this.wrapper.networkDataProvider.stackTraceRequestInfoByActorID.set(
|
||||
resource.actor,
|
||||
{
|
||||
targetFront,
|
||||
resourceId: resource.resourceId,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
this.wrapper.networkDataProvider?.onNetworkResourceAvailable(resource);
|
||||
}
|
||||
|
||||
messages.push(resource);
|
||||
}
|
||||
this.wrapper.dispatchMessagesAdd(messages);
|
||||
@ -428,7 +402,10 @@ class WebConsoleUI {
|
||||
({ resource }) =>
|
||||
resource.resourceType == this.hud.resourceWatcher.TYPES.NETWORK_EVENT
|
||||
)
|
||||
.map(({ resource }) => resource);
|
||||
.map(({ resource }) => {
|
||||
this.wrapper.networkDataProvider?.onNetworkResourceUpdated(resource);
|
||||
return resource;
|
||||
});
|
||||
this.wrapper.dispatchMessagesUpdate(messageUpdates);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,10 @@ module.exports = async function({
|
||||
url: actor.url,
|
||||
method: actor.method,
|
||||
isXHR: actor.isXHR,
|
||||
cause: { type: actor.cause.type },
|
||||
cause: {
|
||||
type: actor.cause.type,
|
||||
loadingDocumentUri: actor.cause.loadingDocumentUri,
|
||||
},
|
||||
timings: {},
|
||||
private: actor.private,
|
||||
fromCache: actor.fromCache,
|
||||
|
Loading…
x
Reference in New Issue
Block a user