Skip to content

Commit

Permalink
Bug 1580155: Rename event constants used only for tests r=Honza.
Browse files Browse the repository at this point in the history
  • Loading branch information
kritisingh1 committed Mar 9, 2020
1 parent f4a3c61 commit d7e1f2b
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 77 deletions.
15 changes: 9 additions & 6 deletions devtools/client/netmonitor/src/connector/chrome/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";
const { EVENTS } = require("devtools/client/netmonitor/src/constants");
const {
EVENTS,
TEST_EVENTS,
} = require("devtools/client/netmonitor/src/constants");
const {
Payloads,
} = require("devtools/client/netmonitor/src/connector/chrome/utils");
Expand Down Expand Up @@ -119,7 +122,7 @@ class CDPConnector {
this.update(requestId, {
requestHeaders: header,
}).then(() => {
window.emit(EVENTS.RECEIVED_REQUEST_HEADERS, header);
window.emit(TEST_EVENTS.RECEIVED_REQUEST_HEADERS, header);
});
}

Expand All @@ -136,7 +139,7 @@ class CDPConnector {

updateResponseState(requestId, state) {
this.update(requestId, state).then(() => {
window.emit(EVENTS.STARTED_RECEIVING_RESPONSE, requestId);
window.emit(TEST_EVENTS.STARTED_RECEIVING_RESPONSE, requestId);
});
}

Expand All @@ -147,7 +150,7 @@ class CDPConnector {
this.update(requestId, {
responseHeaders: header,
}).then(() => {
window.emit(EVENTS.RECEIVED_RESPONSE_HEADERS, header);
window.emit(TEST_EVENTS.RECEIVED_RESPONSE_HEADERS, header);
});
}

Expand Down Expand Up @@ -188,7 +191,7 @@ class CDPConnector {
return;
}
this.actions.updateRequest(requestId, payload, true).then(() => {
window.emit(EVENTS.RECEIVED_RESPONSE_CONTENT, requestId);
window.emit(TEST_EVENTS.RECEIVED_RESPONSE_CONTENT, requestId);
});
}

Expand All @@ -199,7 +202,7 @@ class CDPConnector {
this.update(requestId, {
requestPostData: postData,
}).then(() => {
window.emit(EVENTS.RECEIVED_REQUEST_POST_DATA, requestId);
window.emit(TEST_EVENTS.RECEIVED_REQUEST_POST_DATA, requestId);
});
}

Expand Down
5 changes: 3 additions & 2 deletions devtools/client/netmonitor/src/connector/firefox-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Services = require("Services");
const {
ACTIVITY_TYPE,
EVENTS,
TEST_EVENTS,
} = require("devtools/client/netmonitor/src/constants");
const FirefoxDataProvider = require("devtools/client/netmonitor/src/connector/firefox-data-provider");
const {
Expand Down Expand Up @@ -304,7 +305,7 @@ class FirefoxConnector {
this.actions.addTimingMarker(event);
}

this.emitForTests(EVENTS.TIMELINE_EVENT, event);
this.emitForTests(TEST_EVENTS.TIMELINE_EVENT, event);
}

/**
Expand Down Expand Up @@ -499,7 +500,7 @@ class FirefoxConnector {
});
}

this.emitForTests(EVENTS.THROTTLING_CHANGED, { profile });
this.emitForTests(TEST_EVENTS.THROTTLING_CHANGED, { profile });
}

/**
Expand Down
31 changes: 17 additions & 14 deletions devtools/client/netmonitor/src/connector/firefox-data-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

"use strict";

const { EVENTS } = require("devtools/client/netmonitor/src/constants");
const {
EVENTS,
TEST_EVENTS,
} = require("devtools/client/netmonitor/src/constants");
const { CurlUtils } = require("devtools/client/shared/curl");
const {
fetchHeaders,
Expand Down Expand Up @@ -344,7 +347,7 @@ class FirefoxDataProvider {
*/
getLongString(stringGrip) {
return this.webConsoleFront.getString(stringGrip).then(payload => {
this.emitForTests(EVENTS.LONGSTRING_RESOLVED, { payload });
this.emitForTests(TEST_EVENTS.LONGSTRING_RESOLVED, { payload });
return payload;
});
}
Expand Down Expand Up @@ -383,7 +386,7 @@ class FirefoxDataProvider {
channelId,
});

this.emitForTests(EVENTS.NETWORK_EVENT, actor);
this.emitForTests(TEST_EVENTS.NETWORK_EVENT, actor);
}

/**
Expand Down Expand Up @@ -413,7 +416,7 @@ class FirefoxDataProvider {
statusText: networkInfo.response.statusText,
headersSize: networkInfo.response.headersSize,
});
this.emitForTests(EVENTS.STARTED_RECEIVING_RESPONSE, actor);
this.emitForTests(TEST_EVENTS.STARTED_RECEIVING_RESPONSE, actor);
break;
case "responseContent":
this.pushRequestToQueue(actor, {
Expand All @@ -439,7 +442,7 @@ class FirefoxDataProvider {

this.onPayloadDataReceived(actor);

this.emitForTests(EVENTS.NETWORK_EVENT_UPDATED, actor);
this.emitForTests(TEST_EVENTS.NETWORK_EVENT_UPDATED, actor);
}

/**
Expand Down Expand Up @@ -658,7 +661,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
requestHeaders: response,
});
this.emitForTests(EVENTS.RECEIVED_REQUEST_HEADERS, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_REQUEST_HEADERS, response.from);
return payload.requestHeaders;
}

Expand All @@ -671,7 +674,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
responseHeaders: response,
});
this.emitForTests(EVENTS.RECEIVED_RESPONSE_HEADERS, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_RESPONSE_HEADERS, response.from);
return payload.responseHeaders;
}

Expand All @@ -684,7 +687,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
requestCookies: response,
});
this.emitForTests(EVENTS.RECEIVED_REQUEST_COOKIES, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_REQUEST_COOKIES, response.from);
return payload.requestCookies;
}

Expand All @@ -697,7 +700,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
requestPostData: response,
});
this.emitForTests(EVENTS.RECEIVED_REQUEST_POST_DATA, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_REQUEST_POST_DATA, response.from);
return payload.requestPostData;
}

Expand All @@ -710,7 +713,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
securityInfo: response.securityInfo,
});
this.emitForTests(EVENTS.RECEIVED_SECURITY_INFO, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_SECURITY_INFO, response.from);
return payload.securityInfo;
}

Expand All @@ -723,7 +726,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
responseCookies: response,
});
this.emitForTests(EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
return payload.responseCookies;
}

Expand All @@ -735,7 +738,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
responseCache: response,
});
this.emitForTests(EVENTS.RECEIVED_RESPONSE_CACHE, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_RESPONSE_CACHE, response.from);
return payload.responseCache;
}

Expand All @@ -752,7 +755,7 @@ class FirefoxDataProvider {
mimeType: response.content.mimeType,
responseContent: response,
});
this.emitForTests(EVENTS.RECEIVED_RESPONSE_CONTENT, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_RESPONSE_CONTENT, response.from);
return payload.responseContent;
}

Expand Down Expand Up @@ -783,7 +786,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
stacktrace: response.stacktrace,
});
this.emitForTests(EVENTS.RECEIVED_EVENT_STACKTRACE, response.from);
this.emitForTests(TEST_EVENTS.RECEIVED_EVENT_STACKTRACE, response.from);
return payload.stacktrace;
}

Expand Down
72 changes: 46 additions & 26 deletions devtools/client/netmonitor/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,60 +93,79 @@ const ACTIVITY_TYPE = {

// The panel's window global is an EventEmitter firing the following events:
const EVENTS = {
// When a network or timeline event is received.
// See https://developer.mozilla.org/docs/Tools/Web_Console/remoting for
// more information about what each packet is supposed to deliver.
NETWORK_EVENT: "NetMonitor:NetworkEvent",
NETWORK_EVENT_UPDATED: "NetMonitor:NetworkEventUpdated",
TIMELINE_EVENT: "NetMonitor:TimelineEvent",

// When a network event is added to the view
REQUEST_ADDED: "NetMonitor:RequestAdded",

// When request headers begin and finish receiving.
// When request headers begin receiving.
UPDATING_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdating:RequestHeaders",
RECEIVED_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdated:RequestHeaders",

// When request cookies begin and finish receiving.
// When request cookies begin receiving.
UPDATING_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdating:RequestCookies",
RECEIVED_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdated:RequestCookies",

// When request post data begins and finishes receiving.
// When request post data begins receiving.
UPDATING_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdating:RequestPostData",
RECEIVED_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdated:RequestPostData",

// When security information begins and finishes receiving.
// When security information begins receiving.
UPDATING_SECURITY_INFO: "NetMonitor:NetworkEventUpdating:SecurityInfo",
RECEIVED_SECURITY_INFO: "NetMonitor:NetworkEventUpdated:SecurityInfo",

// When response headers begin and finish receiving.
// When response headers begin receiving.
UPDATING_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdating:ResponseHeaders",
RECEIVED_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdated:ResponseHeaders",

// When response cookies begin and finish receiving.
// When response cookies begin receiving.
UPDATING_RESPONSE_COOKIES: "NetMonitor:NetworkEventUpdating:ResponseCookies",
RECEIVED_RESPONSE_COOKIES: "NetMonitor:NetworkEventUpdated:ResponseCookies",

// When event timings begin and finish receiving.
UPDATING_EVENT_TIMINGS: "NetMonitor:NetworkEventUpdating:EventTimings",
RECEIVED_EVENT_TIMINGS: "NetMonitor:NetworkEventUpdated:EventTimings",

// When response content begins, updates and finishes receiving.
STARTED_RECEIVING_RESPONSE: "NetMonitor:NetworkEventUpdating:ResponseStart",
// When response content updates receiving.
UPDATING_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdating:ResponseContent",
RECEIVED_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdated:ResponseContent",

// When stack-trace finishes receiving.
RECEIVED_EVENT_STACKTRACE: "NetMonitor:NetworkEventUpdated:StackTrace",

UPDATING_RESPONSE_CACHE: "NetMonitor:NetworkEventUpdating:ResponseCache",
RECEIVED_RESPONSE_CACHE: "NetMonitor:NetworkEventUpdated:ResponseCache",

// Fired once the connection is established
CONNECTED: "connected",

// When request payload (HTTP details data) are fetched from the backend.
PAYLOAD_READY: "NetMonitor:PayloadReady",
};

const TEST_EVENTS = {
// When a network or timeline event is received.
// See https://developer.mozilla.org/docs/Tools/Web_Console/remoting for
// more information about what each packet is supposed to deliver.
NETWORK_EVENT: "NetMonitor:NetworkEvent",
NETWORK_EVENT_UPDATED: "NetMonitor:NetworkEventUpdated",
TIMELINE_EVENT: "NetMonitor:TimelineEvent",

// When response content begins receiving.
STARTED_RECEIVING_RESPONSE: "NetMonitor:NetworkEventUpdating:ResponseStart",

// When request headers finish receiving.
RECEIVED_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdated:RequestHeaders",

// When response headers finish receiving.
RECEIVED_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdated:ResponseHeaders",

// When request cookies finish receiving.
RECEIVED_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdated:RequestCookies",

// When request post data finishes receiving.
RECEIVED_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdated:RequestPostData",

// When security information finishes receiving.
RECEIVED_SECURITY_INFO: "NetMonitor:NetworkEventUpdated:SecurityInfo",

// When response cookies finish receiving.
RECEIVED_RESPONSE_COOKIES: "NetMonitor:NetworkEventUpdated:ResponseCookies",

RECEIVED_RESPONSE_CACHE: "NetMonitor:NetworkEventUpdated:ResponseCache",

// When response content finishes receiving.
RECEIVED_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdated:ResponseContent",

// When stack-trace finishes receiving.
RECEIVED_EVENT_STACKTRACE: "NetMonitor:NetworkEventUpdated:StackTrace",

// When throttling is set on the backend.
THROTTLING_CHANGED: "NetMonitor:ThrottlingChanged",
Expand Down Expand Up @@ -514,6 +533,7 @@ const BLOCKED_REASON_MESSAGES = {
const general = {
ACTIVITY_TYPE,
EVENTS,
TEST_EVENTS,
FILTER_SEARCH_DELAY: 200,
UPDATE_PROPS,
HEADERS,
Expand Down
2 changes: 1 addition & 1 deletion devtools/client/netmonitor/test/browser_net_brotli.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_task(async function() {

const wait = waitForDOM(document, ".CodeMirror-code");
const onResponseContent = monitor.panelWin.api.once(
EVENTS.RECEIVED_RESPONSE_CONTENT
TEST_EVENTS.RECEIVED_RESPONSE_CONTENT
);
store.dispatch(Actions.toggleNetworkDetails());
EventUtils.sendMouseEvent(
Expand Down
4 changes: 2 additions & 2 deletions devtools/client/netmonitor/test/browser_net_columns_reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ function waitForRequestsFinished(monitor, event) {
}

// All requests are done - unsubscribe from events and resolve!
window.api.off(EVENTS.NETWORK_EVENT, onRequest);
window.api.off(TEST_EVENTS.NETWORK_EVENT, onRequest);
window.api.off(EVENTS.RECEIVED_EVENT_TIMINGS, onEventRequest);
info("All requests finished");
resolve();
}

window.api.on(EVENTS.NETWORK_EVENT, onRequest);
window.api.on(TEST_EVENTS.NETWORK_EVENT, onRequest);
window.api.on(EVENTS.RECEIVED_EVENT_TIMINGS, onEventRequest);
});
}
4 changes: 2 additions & 2 deletions devtools/client/netmonitor/test/browser_net_content-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ add_task(async function() {

async function selectIndexAndWaitForJSONView(index) {
const onResponseContent = monitor.panelWin.api.once(
EVENTS.RECEIVED_RESPONSE_CONTENT
TEST_EVENTS.RECEIVED_RESPONSE_CONTENT
);
const tabpanel = document.querySelector("#response-panel");
const waitDOM = waitForDOM(tabpanel, ".treeTable");
Expand All @@ -329,7 +329,7 @@ add_task(async function() {

async function selectIndexAndWaitForImageView(index) {
const onResponseContent = monitor.panelWin.api.once(
EVENTS.RECEIVED_RESPONSE_CONTENT
TEST_EVENTS.RECEIVED_RESPONSE_CONTENT
);
const tabpanel = document.querySelector("#response-panel");
const waitDOM = waitForDOM(tabpanel, ".response-image");
Expand Down
6 changes: 4 additions & 2 deletions devtools/client/netmonitor/test/browser_net_pane-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ add_task(async function() {

const { document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
const { EVENTS } = windowRequire("devtools/client/netmonitor/src/constants");
const { TEST_EVENTS } = windowRequire(
"devtools/client/netmonitor/src/constants"
);
const { getSelectedRequest, getSortedRequests } = windowRequire(
"devtools/client/netmonitor/src/selectors/index"
);
Expand All @@ -35,7 +37,7 @@ add_task(async function() {
"There should be no selected item in the requests menu."
);

const networkEvent = monitor.panelWin.api.once(EVENTS.NETWORK_EVENT);
const networkEvent = monitor.panelWin.api.once(TEST_EVENTS.NETWORK_EVENT);
tab.linkedBrowser.reload();
await networkEvent;

Expand Down
Loading

0 comments on commit d7e1f2b

Please sign in to comment.