Bug 1657449 - Add "Show tab" button to about:webrtc; r=ng

This adds the current browserId to the internal stats report. The peer
connections are sorted by browserId, and a "Show tab" button is added that will
select the tab associated with the peer connection to make it easier to keep
track of which peerconnection is associated with a tab.

Differential Revision: https://phabricator.services.mozilla.com/D86699
This commit is contained in:
Dan Minor 2020-08-12 18:48:21 +00:00
parent 0a102a5434
commit a6e858b6ff
4 changed files with 31 additions and 3 deletions

View File

@ -119,7 +119,7 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(
DEFINE_IPC_SERIALIZER_WITH_SUPER_CLASS_AND_FIELDS(
mozilla::dom::RTCStatsReportInternal, mozilla::dom::RTCStatsCollection,
mClosed, mLocalSdp, mSdpHistory, mPcid, mRemoteSdp, mTimestamp,
mClosed, mLocalSdp, mSdpHistory, mPcid, mBrowserId, mRemoteSdp, mTimestamp,
mCallDurationMs, mIceRestarts, mIceRollbacks, mOfferer, mConfiguration);
typedef mozilla::dom::RTCStats RTCStats;

View File

@ -2789,6 +2789,7 @@ RefPtr<dom::RTCStatsReportPromise> PeerConnectionImpl::GetStats(
UniquePtr<dom::RTCStatsReportInternal> report(
new dom::RTCStatsReportInternal);
report->mPcid = NS_ConvertASCIItoUTF16(mName.c_str());
report->mBrowserId = mWindow->GetBrowsingContext()->BrowserId();
report->mConfiguration.Construct(mJsConfiguration);
// TODO(bug 1589416): We need to do better here.
if (!mIceStartTime.IsNull()) {

View File

@ -181,6 +181,27 @@ class AecLogging extends Control {
}
}
class ShowTab extends Control {
constructor(browserId) {
super();
this.label = string("show_tab_label");
this.message = null;
this.browserId = browserId;
}
onClick() {
const gBrowser =
window.ownerGlobal.browsingContext.topChromeWindow.gBrowser;
for (const tab of gBrowser.visibleTabs) {
if (tab.linkedBrowser && tab.linkedBrowser.browserId == this.browserId) {
gBrowser.selectedTab = tab;
return;
}
}
this.ctrl.disabled = true;
}
}
(async () => {
// Setup. Retrieve reports & log while page loads.
const haveReports = getStats();
@ -207,6 +228,8 @@ class AecLogging extends Control {
let reports = await haveReports;
let log = await haveLog;
reports.sort((a, b) => a.browserId - b.browserId);
let peerConnections = renderElement("div");
let connectionLog = renderElement("div");
let userPrefs = renderElement("div");
@ -283,7 +306,7 @@ class AecLogging extends Control {
})();
function renderPeerConnection(report) {
const { pcid, closed, timestamp, configuration } = report;
const { pcid, browserId, closed, timestamp, configuration } = report;
const pcDiv = renderElement("div", { className: "peer-connection" });
{
@ -292,7 +315,10 @@ function renderPeerConnection(report) {
const closedStr = closed ? `(${string("connection_closed")})` : "";
const now = new Date(timestamp).toString();
pcDiv.append(renderText("h3", `[ ${id} ] ${url} ${closedStr} ${now}`));
pcDiv.append(
renderText("h3", `[ ${browserId} | ${id} ] ${url} ${closedStr} ${now}`)
);
pcDiv.append(new ShowTab(browserId).render()[0]);
}
{
const section = renderFoldableSection(pcDiv);

View File

@ -144,6 +144,7 @@ packets = packets
lost_label = Lost
jitter_label = Jitter
sent_label = Sent
show_tab_label = Show tab
frame_stats_heading = Video Frame Statistics
n_a = N/A