Bug 1308495 - Move event constants into a new module r?Honza
MozReview-Commit-ID: KY5bicBYNWD
new file mode 100644
--- /dev/null
+++ b/devtools/client/netmonitor/events.js
@@ -0,0 +1,86 @@
+"use strict";
+
+// The panel's window global is an EventEmitter firing the following events:
+const EVENTS = {
+ // When the monitored target begins and finishes navigating.
+ TARGET_WILL_NAVIGATE: "NetMonitor:TargetWillNavigate",
+ TARGET_DID_NAVIGATE: "NetMonitor:TargetNavigate",
+
+ // 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",
+ TIMELINE_EVENT: "NetMonitor:TimelineEvent",
+
+ // When a network event is added to the view
+ REQUEST_ADDED: "NetMonitor:RequestAdded",
+
+ // When request headers begin and finish receiving.
+ UPDATING_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdating:RequestHeaders",
+ RECEIVED_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdated:RequestHeaders",
+
+ // When request cookies begin and finish receiving.
+ UPDATING_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdating:RequestCookies",
+ RECEIVED_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdated:RequestCookies",
+
+ // When request post data begins and finishes receiving.
+ UPDATING_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdating:RequestPostData",
+ RECEIVED_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdated:RequestPostData",
+
+ // When security information begins and finishes receiving.
+ UPDATING_SECURITY_INFO: "NetMonitor::NetworkEventUpdating:SecurityInfo",
+ RECEIVED_SECURITY_INFO: "NetMonitor::NetworkEventUpdated:SecurityInfo",
+
+ // When response headers begin and finish receiving.
+ UPDATING_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdating:ResponseHeaders",
+ RECEIVED_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdated:ResponseHeaders",
+
+ // When response cookies begin and finish 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",
+ UPDATING_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdating:ResponseContent",
+ RECEIVED_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdated:ResponseContent",
+
+ // When the request post params are displayed in the UI.
+ REQUEST_POST_PARAMS_DISPLAYED: "NetMonitor:RequestPostParamsAvailable",
+
+ // When the response body is displayed in the UI.
+ RESPONSE_BODY_DISPLAYED: "NetMonitor:ResponseBodyAvailable",
+
+ // When the html response preview is displayed in the UI.
+ RESPONSE_HTML_PREVIEW_DISPLAYED: "NetMonitor:ResponseHtmlPreviewAvailable",
+
+ // When the image response thumbnail is displayed in the UI.
+ RESPONSE_IMAGE_THUMBNAIL_DISPLAYED:
+ "NetMonitor:ResponseImageThumbnailAvailable",
+
+ // When a tab is selected in the NetworkDetailsView and subsequently rendered.
+ TAB_UPDATED: "NetMonitor:TabUpdated",
+
+ // Fired when Sidebar has finished being populated.
+ SIDEBAR_POPULATED: "NetMonitor:SidebarPopulated",
+
+ // Fired when NetworkDetailsView has finished being populated.
+ NETWORKDETAILSVIEW_POPULATED: "NetMonitor:NetworkDetailsViewPopulated",
+
+ // Fired when CustomRequestView has finished being populated.
+ CUSTOMREQUESTVIEW_POPULATED: "NetMonitor:CustomRequestViewPopulated",
+
+ // Fired when charts have been displayed in the PerformanceStatisticsView.
+ PLACEHOLDER_CHARTS_DISPLAYED: "NetMonitor:PlaceholderChartsDisplayed",
+ PRIMED_CACHE_CHART_DISPLAYED: "NetMonitor:PrimedChartsDisplayed",
+ EMPTY_CACHE_CHART_DISPLAYED: "NetMonitor:EmptyChartsDisplayed",
+
+ // Fired once the NetMonitorController establishes a connection to the debug
+ // target.
+ CONNECTED: "connected",
+};
+
+exports.EVENTS = EVENTS;
--- a/devtools/client/netmonitor/moz.build
+++ b/devtools/client/netmonitor/moz.build
@@ -3,16 +3,17 @@
# 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/.
DIRS += [
'har'
]
DevToolsModules(
+ 'events.js',
'filter-predicates.js',
'l10n.js',
'panel.js',
'prefs.js',
'request-utils.js',
'requests-menu-view.js',
)
--- a/devtools/client/netmonitor/netmonitor-controller.js
+++ b/devtools/client/netmonitor/netmonitor-controller.js
@@ -4,99 +4,16 @@
* 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/. */
/* globals window, document, NetMonitorView */
/* exported loader */
"use strict";
var { utils: Cu } = Components;
-// The panel's window global is an EventEmitter firing the following events:
-const EVENTS = {
- // When the monitored target begins and finishes navigating.
- TARGET_WILL_NAVIGATE: "NetMonitor:TargetWillNavigate",
- TARGET_DID_NAVIGATE: "NetMonitor:TargetNavigate",
-
- // 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",
- TIMELINE_EVENT: "NetMonitor:TimelineEvent",
-
- // When a network event is added to the view
- REQUEST_ADDED: "NetMonitor:RequestAdded",
-
- // When request headers begin and finish receiving.
- UPDATING_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdating:RequestHeaders",
- RECEIVED_REQUEST_HEADERS: "NetMonitor:NetworkEventUpdated:RequestHeaders",
-
- // When request cookies begin and finish receiving.
- UPDATING_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdating:RequestCookies",
- RECEIVED_REQUEST_COOKIES: "NetMonitor:NetworkEventUpdated:RequestCookies",
-
- // When request post data begins and finishes receiving.
- UPDATING_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdating:RequestPostData",
- RECEIVED_REQUEST_POST_DATA: "NetMonitor:NetworkEventUpdated:RequestPostData",
-
- // When security information begins and finishes receiving.
- UPDATING_SECURITY_INFO: "NetMonitor::NetworkEventUpdating:SecurityInfo",
- RECEIVED_SECURITY_INFO: "NetMonitor::NetworkEventUpdated:SecurityInfo",
-
- // When response headers begin and finish receiving.
- UPDATING_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdating:ResponseHeaders",
- RECEIVED_RESPONSE_HEADERS: "NetMonitor:NetworkEventUpdated:ResponseHeaders",
-
- // When response cookies begin and finish 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",
- UPDATING_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdating:ResponseContent",
- RECEIVED_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdated:ResponseContent",
-
- // When the request post params are displayed in the UI.
- REQUEST_POST_PARAMS_DISPLAYED: "NetMonitor:RequestPostParamsAvailable",
-
- // When the response body is displayed in the UI.
- RESPONSE_BODY_DISPLAYED: "NetMonitor:ResponseBodyAvailable",
-
- // When the html response preview is displayed in the UI.
- RESPONSE_HTML_PREVIEW_DISPLAYED: "NetMonitor:ResponseHtmlPreviewAvailable",
-
- // When the image response thumbnail is displayed in the UI.
- RESPONSE_IMAGE_THUMBNAIL_DISPLAYED:
- "NetMonitor:ResponseImageThumbnailAvailable",
-
- // When a tab is selected in the NetworkDetailsView and subsequently rendered.
- TAB_UPDATED: "NetMonitor:TabUpdated",
-
- // Fired when Sidebar has finished being populated.
- SIDEBAR_POPULATED: "NetMonitor:SidebarPopulated",
-
- // Fired when NetworkDetailsView has finished being populated.
- NETWORKDETAILSVIEW_POPULATED: "NetMonitor:NetworkDetailsViewPopulated",
-
- // Fired when CustomRequestView has finished being populated.
- CUSTOMREQUESTVIEW_POPULATED: "NetMonitor:CustomRequestViewPopulated",
-
- // Fired when charts have been displayed in the PerformanceStatisticsView.
- PLACEHOLDER_CHARTS_DISPLAYED: "NetMonitor:PlaceholderChartsDisplayed",
- PRIMED_CACHE_CHART_DISPLAYED: "NetMonitor:PrimedChartsDisplayed",
- EMPTY_CACHE_CHART_DISPLAYED: "NetMonitor:EmptyChartsDisplayed",
-
- // Fired once the NetMonitorController establishes a connection to the debug
- // target.
- CONNECTED: "connected",
-};
-
// Descriptions for what this frontend is currently doing.
const ACTIVITY_TYPE = {
// Standing by and handling requests normally.
NONE: 0,
// Forcing the target to reload with cache enabled or disabled.
RELOAD: {
WITH_CACHE_ENABLED: 1,
@@ -119,16 +36,17 @@ var { loader, require } = BrowserLoaderM
const promise = require("promise");
const Services = require("Services");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const EventEmitter = require("devtools/shared/event-emitter");
const Editor = require("devtools/client/sourceeditor/editor");
const {TimelineFront} = require("devtools/shared/fronts/timeline");
const {Task} = require("devtools/shared/task");
const {Prefs} = require("./prefs");
+const {EVENTS} = require("./events");
XPCOMUtils.defineConstant(this, "EVENTS", EVENTS);
XPCOMUtils.defineConstant(this, "ACTIVITY_TYPE", ACTIVITY_TYPE);
XPCOMUtils.defineConstant(this, "Editor", Editor);
XPCOMUtils.defineConstant(this, "Prefs", Prefs);
XPCOMUtils.defineLazyModuleGetter(this, "Chart",
"resource://devtools/client/shared/widgets/Chart.jsm");