Backed out changeset 6ed0ffc2329d (bug 1692064) for test_telemetry.html failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2021-02-13 14:04:59 +02:00
Родитель 0e5bbc3675
Коммит 5a8a0d9f6b
5 изменённых файлов: 0 добавлений и 130 удалений

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

@ -8,7 +8,6 @@
#include "nsIContentSink.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentL10nBinding.h"
#include "mozilla/Telemetry.h"
using namespace mozilla::dom;
@ -31,8 +30,6 @@ NS_IMPL_RELEASE_INHERITED(DocumentL10n, DOMLocalization)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DocumentL10n)
NS_INTERFACE_MAP_END_INHERITING(DOMLocalization)
bool DocumentL10n::mIsFirstBrowserWindow = true;
/* static */
RefPtr<DocumentL10n> DocumentL10n::Create(Document* aDocument,
const bool aSync) {
@ -104,7 +101,6 @@ void DocumentL10n::TriggerInitialTranslation() {
if (mState >= DocumentL10nState::InitialTranslationTriggered) {
return;
}
mInitialTranslationStart = mozilla::TimeStamp::NowUnfuzzed();
AutoAllowLegacyScriptExecution exemption;
@ -245,41 +241,6 @@ already_AddRefed<Promise> DocumentL10n::TranslateDocument(ErrorResult& aRv) {
return promise.forget();
}
void DocumentL10n::MaybeRecordTelemetry() {
mozilla::TimeStamp initialTranslationEnd = mozilla::TimeStamp::NowUnfuzzed();
nsAutoString documentURI;
ErrorResult rv;
rv = mDocument->GetDocumentURI(documentURI);
if (rv.Failed()) {
return;
}
nsCString key;
if (documentURI.Find("chrome://browser/content/browser.xhtml") == 0) {
if (mIsFirstBrowserWindow) {
key = "browser_first_window";
mIsFirstBrowserWindow = false;
} else {
key = "browser_new_window";
}
} else if (documentURI.Find("about:home") == 0) {
key = "about:home";
} else if (documentURI.Find("about:newtab") == 0) {
key = "about:newtab";
} else if (documentURI.Find("about:preferences") == 0) {
key = "about:preferences";
} else {
return;
}
mozilla::TimeDuration totalTime(initialTranslationEnd -
mInitialTranslationStart);
Accumulate(Telemetry::L10N_DOCUMENT_INITIAL_TRANSLATION_TIME_US, key,
totalTime.ToMicroseconds());
}
void DocumentL10n::InitialTranslationCompleted(bool aL10nCached) {
if (mState >= DocumentL10nState::Ready) {
return;
@ -292,8 +253,6 @@ void DocumentL10n::InitialTranslationCompleted(bool aL10nCached) {
mState = DocumentL10nState::Ready;
MaybeRecordTelemetry();
mDocument->InitialTranslationCompleted(aL10nCached);
// In XUL scenario contentSink is nullptr.

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

@ -78,12 +78,7 @@ class DocumentL10n final : public DOMLocalization {
DocumentL10nState GetState() { return mState; };
void MaybeRecordTelemetry();
bool mBlockingLayout = false;
mozilla::TimeStamp mInitialTranslationStart;
static bool mIsFirstBrowserWindow;
};
} // namespace dom

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

@ -42,4 +42,3 @@
[document_l10n/test_docl10n_lazy.html]
[document_l10n/test_connectRoot_webcomponent.html]
[document_l10n/test_connectRoot_webcomponent_lazy.html]
[document_l10n/test_telemetry.html]

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

@ -1,64 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test DocumentL10n Telemetry</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
"use strict";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { BrowserTestUtils } = ChromeUtils.import(
"resource://testing-common/BrowserTestUtils.jsm"
);
SimpleTest.waitForExplicitFinish();
function countValues(values) {
return Object.values(values).reduce((sum, n) => sum + n, 0);
}
(async function() {
let snapshot = Services.telemetry
.getKeyedHistogramById("L10N_DOCUMENT_INITIAL_TRANSLATION_TIME_US").snapshot();
// Make sure we collected telemetry from the first window
is(snapshot.hasOwnProperty("browser_first_window"), true);
// And we collected only one value
is(countValues(snapshot.browser_first_window.values), 1);
// No other window has been recorded yet
is(snapshot.hasOwnProperty("browser_new_window"), false);
is(snapshot.hasOwnProperty("about:preferences"), false);
// Open a new window
let win = await BrowserTestUtils.openNewBrowserWindow({
waitForTabURL: "about:blank",
});
snapshot = Services.telemetry
.getKeyedHistogramById("L10N_DOCUMENT_INITIAL_TRANSLATION_TIME_US").snapshot();
is(countValues(snapshot.browser_first_window.values), 1);
is(snapshot.hasOwnProperty("browser_new_window"), true);
is(countValues(snapshot.browser_new_window.values), 1);
// Open preferences in a new tab
let tab = BrowserTestUtils.addTab(
win.gBrowser,
"about:preferences"
);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
snapshot = Services.telemetry
.getKeyedHistogramById("L10N_DOCUMENT_INITIAL_TRANSLATION_TIME_US").snapshot();
is(snapshot.hasOwnProperty("about:preferences"), true);
is(countValues(snapshot["about:preferences"].values), 1);
await BrowserTestUtils.closeWindow(win);
SimpleTest.finish();
})();
</script>
</head>
<body>
</body>
</html>

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

@ -16380,25 +16380,6 @@
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"],
"bug_numbers": [1682555]
},
"L10N_DOCUMENT_INITIAL_TRANSLATION_TIME_US": {
"record_in_processes": ["main", "content"],
"products": ["firefox"],
"expires_in_version": "100",
"kind": "exponential",
"high": 1000000,
"n_buckets": 100,
"description": "Time it took to perform initial translation of the document (in microseconds)",
"alert_emails": ["zbraniecki@mozilla.com"],
"bug_numbers": [1692064],
"keyed": true,
"keys": [
"browser_first_window",
"browser_new_window",
"about:newtab",
"about:home",
"about:preferences"
]
},
"HTTPS_RR_PRESENTED": {
"record_in_processes": ["main"],
"products": ["firefox"],