mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 917227 - Part 1: network monitor client changes; r=ochameau
This commit is contained in:
parent
8864c363fd
commit
bd072b9ce6
@ -11,13 +11,16 @@ function test() {
|
||||
|
||||
addTab("about:blank", function() {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
idIndex = 0;
|
||||
|
||||
target.makeRemote().then(() => {
|
||||
toolIDs = gDevTools.getToolDefinitionArray()
|
||||
.filter(def => def.isTargetSupported(target))
|
||||
.map(def => def.id);
|
||||
idIndex = 0;
|
||||
gDevTools.showToolbox(target, toolIDs[0], Toolbox.HostType.BOTTOM)
|
||||
.then(testShortcuts);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testShortcuts(aToolbox, aIndex) {
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
function test() {
|
||||
addTab().then(function(data) {
|
||||
data.target.makeRemote().then(performChecks.bind(null, data));
|
||||
}).then(null, console.error);
|
||||
|
||||
function performChecks(data) {
|
||||
let toolIds = gDevTools.getToolDefinitionArray()
|
||||
.filter(def => def.isTargetSupported(data.target))
|
||||
.map(def => def.id);
|
||||
@ -32,5 +36,5 @@ function test() {
|
||||
};
|
||||
|
||||
open(0);
|
||||
}).then(null, console.error);
|
||||
}
|
||||
}
|
||||
|
@ -253,21 +253,20 @@ Toolbox.prototype = {
|
||||
this._addZoomKeys();
|
||||
this._loadInitialZoom();
|
||||
|
||||
// Load the toolbox-level actor fronts and utilities now
|
||||
this._target.makeRemote().then(() => {
|
||||
this._telemetry.toolOpened("toolbox");
|
||||
|
||||
this.selectTool(this._defaultToolId).then(panel => {
|
||||
this.emit("ready");
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Load the toolbox-level actor fronts and utilities now
|
||||
this._target.makeRemote().then(() => {
|
||||
iframe.setAttribute("src", this._URL);
|
||||
|
||||
let domHelper = new DOMHelpers(iframe.contentWindow);
|
||||
domHelper.onceDOMReady(domReady);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
});
|
||||
|
@ -239,7 +239,8 @@ Tools.netMonitor = {
|
||||
inMenu: true,
|
||||
|
||||
isTargetSupported: function(target) {
|
||||
return !target.isApp;
|
||||
let root = target.client.mainRoot;
|
||||
return root.traits.networkMonitor || !target.isApp;
|
||||
},
|
||||
|
||||
build: function(iframeWindow, toolbox) {
|
||||
|
@ -78,7 +78,11 @@ const EVENTS = {
|
||||
// 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"
|
||||
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.
|
||||
@ -200,7 +204,10 @@ let NetMonitorController = {
|
||||
this._startMonitoringTab(client, form, deferred.resolve);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
return deferred.promise.then((result) => {
|
||||
window.emit(EVENTS.CONNECTED);
|
||||
return result;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -362,6 +369,25 @@ let NetMonitorController = {
|
||||
return promise.reject(new Error("Invalid activity type"));
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter that tells if the server supports sending custom network requests.
|
||||
* @type boolean
|
||||
*/
|
||||
get supportsCustomRequest() {
|
||||
return this.webConsoleClient &&
|
||||
(this.webConsoleClient.traits.customNetworkRequest ||
|
||||
!this._target.isApp);
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter that tells if the server can do network performance statistics.
|
||||
* @type boolean
|
||||
*/
|
||||
get supportsPerfStats() {
|
||||
return this.tabClient &&
|
||||
(this.tabClient.traits.reconfigure || !this._target.isApp);
|
||||
},
|
||||
|
||||
_startup: null,
|
||||
_shutdown: null,
|
||||
_connection: null,
|
||||
@ -493,6 +519,11 @@ NetworkEventsHandler.prototype = {
|
||||
* The message received from the server.
|
||||
*/
|
||||
_onNetworkEvent: function(aType, aPacket) {
|
||||
if (aPacket.from != this.webConsoleClient.actor) {
|
||||
// Skip events from different console actors.
|
||||
return;
|
||||
}
|
||||
|
||||
let { actor, startedDateTime, method, url, isXHR } = aPacket.eventActor;
|
||||
NetMonitorView.RequestsMenu.addRequest(actor, startedDateTime, method, url, isXHR);
|
||||
window.emit(EVENTS.NETWORK_EVENT);
|
||||
@ -508,6 +539,10 @@ NetworkEventsHandler.prototype = {
|
||||
*/
|
||||
_onNetworkEventUpdate: function(aType, aPacket) {
|
||||
let actor = aPacket.from;
|
||||
if (!NetMonitorView.RequestsMenu.getItemByValue(actor)) {
|
||||
// Skip events from unknown actors.
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aPacket.updateType) {
|
||||
case "requestHeaders":
|
||||
|
@ -374,16 +374,32 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
||||
$("#request-menu-context-newtab").addEventListener("command", this._onContextNewTabCommand, false);
|
||||
$("#request-menu-context-copy-url").addEventListener("command", this._onContextCopyUrlCommand, false);
|
||||
$("#request-menu-context-copy-image-as-data-uri").addEventListener("command", this._onContextCopyImageAsDataUriCommand, false);
|
||||
|
||||
window.once("connected", this._onConnect.bind(this));
|
||||
},
|
||||
|
||||
_onConnect: function() {
|
||||
if (NetMonitorController.supportsCustomRequest) {
|
||||
$("#request-menu-context-resend").addEventListener("command", this._onContextResendCommand, false);
|
||||
$("#request-menu-context-perf").addEventListener("command", this._onContextPerfCommand, false);
|
||||
|
||||
$("#requests-menu-perf-notice-button").addEventListener("command", this._onContextPerfCommand, false);
|
||||
$("#requests-menu-network-summary-button").addEventListener("command", this._onContextPerfCommand, false);
|
||||
$("#requests-menu-network-summary-label").addEventListener("click", this._onContextPerfCommand, false);
|
||||
|
||||
$("#custom-request-send-button").addEventListener("click", this.sendCustomRequestEvent, false);
|
||||
$("#custom-request-close-button").addEventListener("click", this.closeCustomRequestEvent, false);
|
||||
$("#headers-summary-resend").addEventListener("click", this.cloneSelectedRequestEvent, false);
|
||||
} else {
|
||||
$("#request-menu-context-resend").hidden = true;
|
||||
$("#headers-summary-resend").hidden = true;
|
||||
}
|
||||
|
||||
if (NetMonitorController.supportsPerfStats) {
|
||||
$("#request-menu-context-perf").addEventListener("command", this._onContextPerfCommand, false);
|
||||
$("#requests-menu-perf-notice-button").addEventListener("command", this._onContextPerfCommand, false);
|
||||
$("#requests-menu-network-summary-button").addEventListener("command", this._onContextPerfCommand, false);
|
||||
$("#requests-menu-network-summary-label").addEventListener("click", this._onContextPerfCommand, false);
|
||||
} else {
|
||||
$("#notice-perf-message").hidden = true;
|
||||
$("#request-menu-context-perf").hidden = true;
|
||||
$("#requests-menu-network-summary-button").hidden = true;
|
||||
$("#requests-menu-network-summary-label").hidden = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -546,8 +562,12 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
||||
*/
|
||||
sendCustomRequest: function() {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let data = Object.create(selected);
|
||||
|
||||
let data = {
|
||||
method: selected.method,
|
||||
url: selected.url,
|
||||
httpVersion: selected.httpVersion,
|
||||
};
|
||||
if (selected.requestHeaders) {
|
||||
data.headers = selected.requestHeaders.headers;
|
||||
}
|
||||
@ -1534,7 +1554,8 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
||||
let selectedItem = this.selectedItem;
|
||||
|
||||
let resendElement = $("#request-menu-context-resend");
|
||||
resendElement.hidden = !selectedItem || selectedItem.attachment.isCustom;
|
||||
resendElement.hidden = !NetMonitorController.supportsCustomRequest ||
|
||||
!selectedItem || selectedItem.attachment.isCustom;
|
||||
|
||||
let copyUrlElement = $("#request-menu-context-copy-url");
|
||||
copyUrlElement.hidden = !selectedItem;
|
||||
|
@ -30,6 +30,8 @@ exports.WebConsoleClient = WebConsoleClient;
|
||||
WebConsoleClient.prototype = {
|
||||
_longStrings: null,
|
||||
|
||||
get actor() { return this._actor; },
|
||||
|
||||
/**
|
||||
* Retrieve the cached messages from the server.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user