Backed out changeset 766458123a64 (bug 1743630) for causing mochitest failures on browser_103_telemetry.js. CLOSED TREE

This commit is contained in:
criss 2021-12-02 18:05:19 +02:00
Родитель b8de8f45dd
Коммит 3c9369510c
15 изменённых файлов: 1 добавлений и 329 удалений

Просмотреть файл

@ -391,7 +391,6 @@ NS_INTERFACE_MAP_BEGIN(DocumentLoadListener)
NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
NS_INTERFACE_MAP_ENTRY(nsIMultiPartChannelListener)
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
NS_INTERFACE_MAP_ENTRY(nsIEarlyHintObserver)
NS_INTERFACE_MAP_ENTRY_CONCRETE(DocumentLoadListener)
NS_INTERFACE_MAP_END
@ -641,10 +640,6 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
RefPtr<nsHttpChannel> httpChannelImpl = do_QueryObject(mChannel);
if (httpChannelImpl) {
httpChannelImpl->SetWarningReporter(this);
if (mIsDocumentLoad && loadingContext->IsTop()) {
httpChannelImpl->SetEarlyHintObserver(this);
}
}
nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(mChannel);
@ -1075,11 +1070,8 @@ void DocumentLoadListener::Disconnect() {
RefPtr<nsHttpChannel> httpChannelImpl = do_QueryObject(mChannel);
if (httpChannelImpl) {
httpChannelImpl->SetWarningReporter(nullptr);
httpChannelImpl->SetEarlyHintObserver(nullptr);
}
mEarlyHintsPreloader.Cancel();
if (auto* ctx = GetDocumentBrowsingContext()) {
ctx->EndDocumentLoad(mDoingProcessSwitch);
}
@ -2263,14 +2255,6 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
}
}
if (httpChannel) {
uint32_t responseStatus;
Unused << httpChannel->GetResponseStatus(&responseStatus);
mEarlyHintsPreloader.FinalResponse(responseStatus);
} else {
mEarlyHintsPreloader.Cancel();
}
// If we're going to be delivering this channel to a remote content
// process, then we want to install any required content conversions
// in the content process.
@ -2622,13 +2606,6 @@ NS_IMETHODIMP DocumentLoadListener::OnStatus(nsIRequest* aRequest,
return NS_OK;
}
NS_IMETHODIMP DocumentLoadListener::EarlyHint(const nsACString& linkHeader) {
LOG(("DocumentLoadListener::EarlyHint.\n"));
mEarlyHintsPreloader.EarlyHint(linkHeader);
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/WeakPtr.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/dom/SessionHistoryEntry.h"
#include "EarlyHintsPreloader.h"
#include "mozilla/net/NeckoCommon.h"
#include "mozilla/net/NeckoParent.h"
#include "mozilla/net/PDocumentChannelParent.h"
@ -20,7 +19,6 @@
#include "nsDOMNavigationTiming.h"
#include "nsIBrowser.h"
#include "nsIChannelEventSink.h"
#include "nsIEarlyHintObserver.h"
#include "nsIInterfaceRequestor.h"
#include "nsIMultiPartChannel.h"
#include "nsIParentChannel.h"
@ -98,8 +96,7 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
public nsIChannelEventSink,
public HttpChannelSecurityWarningReporter,
public nsIMultiPartChannelListener,
public nsIProgressEventSink,
public nsIEarlyHintObserver {
public nsIProgressEventSink {
public:
// See the comment on GetLoadingBrowsingContext for explanation of
// aLoadingBrowsingContext.
@ -214,7 +211,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSIMULTIPARTCHANNELLISTENER
NS_DECL_NSIPROGRESSEVENTSINK
NS_DECL_NSIEARLYHINTOBSERVER
// We suspend the underlying channel when replacing ourselves with
// the real listener channel.
@ -595,8 +591,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
bool mOpenPromiseResolved = false;
const bool mIsDocumentLoad;
EarlyHintsPreloader mEarlyHintsPreloader;
};
NS_DEFINE_STATIC_IID_ACCESSOR(DocumentLoadListener, DOCUMENT_LOAD_LISTENER_IID)

Просмотреть файл

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* 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/. */
#include "EarlyHintsPreloader.h"
#include "mozilla/Telemetry.h"
namespace mozilla::net {
void EarlyHintsPreloader::EarlyHint(const nsACString& linkHeader) {
mEarlyHintsCount++;
if (!mFirstEarlyHint) {
mFirstEarlyHint.emplace(TimeStamp::NowLoRes());
}
}
void EarlyHintsPreloader::FinalResponse(uint32_t aResponseStatus) {
// We will collect telemetry mosly once for a document.
// In case of a reddirect this will be called multiple times.
CollectTelemetry(Some(aResponseStatus));
}
void EarlyHintsPreloader::Cancel() {
if (!mCanceled) {
CollectTelemetry(Nothing());
mCanceled = true;
}
}
void EarlyHintsPreloader::CollectTelemetry(Maybe<uint32_t> aResponseStatus) {
// EH_NUM_OF_HINTS_PER_PAGE is only collected for the 2xx responses,
// regardless of the number of received mEarlyHintsCount.
// Other telemetry probes are only collected if there was at least one
// EarlyHins response.
if (aResponseStatus && (*aResponseStatus <= 299)) {
Telemetry::Accumulate(Telemetry::EH_NUM_OF_HINTS_PER_PAGE,
mEarlyHintsCount);
}
if (mEarlyHintsCount == 0) {
return;
}
Telemetry::LABELS_EH_FINAL_RESPONSE label =
Telemetry::LABELS_EH_FINAL_RESPONSE::Cancel;
if (aResponseStatus) {
if (*aResponseStatus <= 299) {
label = Telemetry::LABELS_EH_FINAL_RESPONSE::R2xx;
MOZ_ASSERT(mFirstEarlyHint);
Telemetry::AccumulateTimeDelta(Telemetry::EH_TIME_TO_FINAL_RESPONSE,
*mFirstEarlyHint, TimeStamp::NowLoRes());
} else if (*aResponseStatus <= 399) {
label = Telemetry::LABELS_EH_FINAL_RESPONSE::R3xx;
} else if (*aResponseStatus <= 499) {
label = Telemetry::LABELS_EH_FINAL_RESPONSE::R4xx;
} else {
label = Telemetry::LABELS_EH_FINAL_RESPONSE::Other;
}
}
Telemetry::AccumulateCategorical(label);
// Reset telemetry counters and timestamps.
mEarlyHintsCount = 0;
mFirstEarlyHint = Nothing();
}
} // namespace mozilla::net

Просмотреть файл

@ -1,35 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* 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/. */
#ifndef mozilla_net_EarlyHintsPreload_h
#define mozilla_net_EarlyHintsPreload_h
#include "nsStringFwd.h"
#include "mozilla/Maybe.h"
#include "mozilla/TimeStamp.h"
namespace mozilla::net {
class EarlyHintsPreloader {
public:
EarlyHintsPreloader() = default;
~EarlyHintsPreloader() = default;
void EarlyHint(const nsACString& linkHeader);
void FinalResponse(uint32_t aResponseStatus);
void Cancel();
private:
void CollectTelemetry(Maybe<uint32_t> aResponseStatus);
Maybe<TimeStamp> mFirstEarlyHint;
uint32_t mEarlyHintsCount{0};
bool mCanceled{false};
};
} // namespace mozilla::net
#endif // mozilla_net_EarlyHintsPreload_h

Просмотреть файл

@ -49,7 +49,6 @@ EXPORTS.mozilla.net += [
"ClassifierDummyChannel.h",
"ClassifierDummyChannelChild.h",
"ClassifierDummyChannelParent.h",
"EarlyHintsPreloader.h",
"HttpAuthUtils.h",
"HttpBackgroundChannelChild.h",
"HttpBackgroundChannelParent.h",
@ -100,7 +99,6 @@ UNIFIED_SOURCES += [
"ConnectionEntry.cpp",
"ConnectionHandle.cpp",
"DnsAndConnectSocket.cpp",
"EarlyHintsPreloader.cpp",
"Http2Compression.cpp",
"Http2Push.cpp",
"Http2Session.cpp",

Просмотреть файл

@ -1,26 +0,0 @@
<head>
</head>
<body>
<script class="testbody" type="text/javascript">
function checkNumberOfLoads(shouldBe) {
var numDownloads = 0;
window.performance.getEntriesByName("http://example.com/browser/netwerk/test/browser/square.png").forEach(entry => {
if (entry.transferSize > 0) {
numDownloads++;
}
});
window.parent.ok(numDownloads == shouldBe, "The number of downloads of square.png is not correct");
};
var img = document.createElement("img");
img.src = "http://example.com/browser/netwerk/test/browser/square.png";
img.addEventListener("load",() => {
checkNumberOfLoads(1);
window.parent.iframeTestCompleted();
});
document.body.appendChild(img);
</script>
</body>

Просмотреть файл

@ -1,2 +0,0 @@
HTTP 103 Too Early
Link: <http://example.com/browser/netwerk/test/browser/square.png>; rel=preload; as=image

Просмотреть файл

@ -1,6 +0,0 @@
<html>
<head><title>404 Not Found</title></head>
<body>
<h1>404 Not Found</h1>
</body>
</html>

Просмотреть файл

@ -1 +0,0 @@
HTTP 404 Not Found

Просмотреть файл

@ -1,2 +0,0 @@
HTTP 103 Early Hints
Link: <http://example.com/browser/netwerk/test/browser/square.png>; rel=preload; as=image

Просмотреть файл

@ -31,13 +31,6 @@ support-files =
res_img_for_unknown_decoder^headers^
res_object.html
res_sub_document.html
square.png
103_preload.html
103_preload.html^informationalResponse^
no_103_preload.html
103_preload_and_404.html^informationalResponse^
103_preload_and_404.html^headers^
103_preload_and_404.html
[browser_about_cache.js]
[browser_bug1535877.js]
@ -65,4 +58,3 @@ run-if = os == "win"
support-files =
file_lnk.lnk
[browser_post_auth.js]
[browser_103_telemetry.js]

Просмотреть файл

@ -1,85 +0,0 @@
"use strict";
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
Services.prefs.setCharPref("dom.securecontext.whitelist", "example.com");
var kTest103 =
"http://example.com/browser/netwerk/test/browser/103_preload.html";
var kTestNo103 =
"http://example.com/browser/netwerk/test/browser/no_103_preload.html";
var kTest404 =
"http://example.com/browser/netwerk/test/browser/103_preload_and_404.html";
add_task(async function() {
let hist_hints = TelemetryTestUtils.getAndClearHistogram(
"EH_NUM_OF_HINTS_PER_PAGE"
);
let hist_final = TelemetryTestUtils.getAndClearHistogram("EH_FINAL_RESPONSE");
let hist_time = TelemetryTestUtils.getAndClearHistogram(
"EH_TIME_TO_FINAL_RESPONSE"
);
await BrowserTestUtils.openNewForegroundTab(gBrowser, kTest103, true);
// This is a 200 response with 103:
// EH_NUM_OF_HINTS_PER_PAGE should record 1.
// EH_FINAL_RESPONSE should record 1 on position 0 (R2xx).
// EH_TIME_TO_FINAL_RESPONSE should have a new value
// (we cannot determine what the timing will be therefore we only check that
// the histogram sum is > 0).
TelemetryTestUtils.assertHistogram(hist_hints, 1, 1);
TelemetryTestUtils.assertHistogram(hist_final, 0, 1);
const snapshot = hist_time.snapshot();
Assert.ok(snapshot.sum > 0);
gBrowser.removeCurrentTab();
});
add_task(async function() {
let hist_hints = TelemetryTestUtils.getAndClearHistogram(
"EH_NUM_OF_HINTS_PER_PAGE"
);
let hist_final = TelemetryTestUtils.getAndClearHistogram("EH_FINAL_RESPONSE");
let hist_time = TelemetryTestUtils.getAndClearHistogram(
"EH_TIME_TO_FINAL_RESPONSE"
);
await BrowserTestUtils.openNewForegroundTab(gBrowser, kTestNo103, true);
// This is a 200 response without 103:
// EH_NUM_OF_HINTS_PER_PAGE should record 0.
// EH_FINAL_RESPONSE andd EH_TIME_TO_FINAL_RESPONSE should not be recorded.
TelemetryTestUtils.assertHistogram(hist_hints, 0, 1);
const snapshot_final = hist_final.snapshot();
Assert.equal(snapshot_final.sum, 0);
const snapshot_time = hist_time.snapshot();
Assert.equal(snapshot_time.sum, 0);
gBrowser.removeCurrentTab();
});
add_task(async function() {
let hist_hints = TelemetryTestUtils.getAndClearHistogram(
"EH_NUM_OF_HINTS_PER_PAGE"
);
let hist_final = TelemetryTestUtils.getAndClearHistogram("EH_FINAL_RESPONSE");
let hist_time = TelemetryTestUtils.getAndClearHistogram(
"EH_TIME_TO_FINAL_RESPONSE"
);
await BrowserTestUtils.openNewForegroundTab(gBrowser, kTest404, true);
// This is a 404 response with 103:
// EH_NUM_OF_HINTS_PER_PAGE and EH_TIME_TO_FINAL_RESPONSE should not be recorded.
// EH_FINAL_RESPONSE should record 1 on index 2 (R4xx).
const snapshot_hints = hist_hints.snapshot();
Assert.equal(snapshot_hints.sum, 0);
TelemetryTestUtils.assertHistogram(hist_final, 2, 1);
const snapshot_time = hist_time.snapshot();
Assert.equal(snapshot_time.sum, 0);
gBrowser.removeCurrentTab();
});

Просмотреть файл

@ -1,26 +0,0 @@
<head>
</head>
<body>
<script class="testbody" type="text/javascript">
function checkNumberOfLoads(shouldBe) {
var numDownloads = 0;
window.performance.getEntriesByName("http://example.com/browser/netwerk/test/browser/square.png").forEach(entry => {
if (entry.transferSize > 0) {
numDownloads++;
}
});
window.parent.ok(numDownloads == shouldBe, "The number of downloads of square.png is not correct");
};
var img = document.createElement("img");
img.src = "http://example.com/browser/netwerk/test/browser/square.png";
img.addEventListener("load",() => {
checkNumberOfLoads(1);
window.parent.iframeTestCompleted();
});
document.body.appendChild(img);
</script>
</body>

Двоичные данные
netwerk/test/browser/square.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 18 KiB

Просмотреть файл

@ -16867,40 +16867,5 @@
"n_values": 3,
"keyed": true,
"description": "Users action on blocked download, keyed by verdict type (0=Number of blocked downloads, 1=Confirm block, 2=Confirm unblock)"
},
"EH_NUM_OF_HINTS_PER_PAGE": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
"bug_numbers": [1743630],
"expires_in_version": "103",
"releaseChannelCollection": "opt-out",
"kind": "exponential",
"high": 30,
"n_buckets": 20,
"description": "Number of 103 responses received for a top level load."
},
"EH_FINAL_RESPONSE": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
"bug_numbers": [1743630],
"expires_in_version": "103",
"releaseChannelCollection": "opt-out",
"kind": "categorical",
"labels": ["R2xx", "R3xx", "R4xx", "Other", "Cancel"],
"description": "The final response status code after one or more 103 responses."
},
"EH_TIME_TO_FINAL_RESPONSE": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
"bug_numbers": [1743630],
"expires_in_version": "103",
"releaseChannelCollection": "opt-out",
"kind": "exponential",
"high": 3000,
"n_buckets": 100,
"description": "Collect the time elapsed between receiving a 103 response and the final response for a page load."
}
}