Backed out 2 changesets (bug 1663857) for failures on browser_pioneer_ui.js. CLOSED TREE

Backed out changeset f1dd8a993206 (bug 1663857)
Backed out changeset 8872cde42a12 (bug 1663857)
This commit is contained in:
Narcis Beleuzu 2020-09-11 01:12:56 +03:00
Родитель da37a0a877
Коммит ece3375c66
3 изменённых файлов: 4 добавлений и 267 удалений

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

@ -144,10 +144,6 @@ async function toggleEnrolled(studyAddonId, cachedAddons) {
await install.install();
document.l10n.setAttributes(joinBtn, "pioneer-leave-study");
joinBtn.disabled = false;
// Send an enrollment ping for this study. Note that this could be sent again
// if we are re-joining.
await sendEnrollmentPing(studyAddonId);
}
await updateStudy(cachedAddon.addon_id);
@ -474,10 +470,6 @@ async function setup(cachedAddons) {
}
document.querySelector("dialog").close();
}
// A this point we should have a valid pioneer id, so we should be able to send
// the enrollment ping.
await sendEnrollmentPing();
showEnrollmentStatus();
});
@ -730,9 +722,7 @@ async function sendDeletionPing(studyAddonId) {
},
schemaName: "deletion-request",
schemaVersion: 1,
// The schema namespace needs to be the study addon id, as we
// want to route the ping to the specific study table.
schemaNamespace: studyAddonId,
schemaNamespace: "pioneer-debug",
};
const payload = {
@ -741,48 +731,3 @@ async function sendDeletionPing(studyAddonId) {
await TelemetryController.submitExternalPing(type, payload, options);
}
/**
* Sends a Pioneer enrollment ping.
*
* The `creationDate` provided by the telemetry APIs will be used as the timestamp for
* considering the user enrolled in pioneer and/or the study.
*
* @param [studyAddonid=undefined] - optional study id. It's sent in the ping, if present,
* to signal that user enroled in the study.
*/
async function sendEnrollmentPing(studyAddonId) {
let options = {
addPioneerId: true,
useEncryption: true,
// NOTE - while we're not actually sending useful data in this payload, the current Pioneer v2 Telemetry
// pipeline requires that pings are shaped this way so they are routed to the correct environment.
//
// At the moment, the public key used here isn't important but we do need to use *something*.
encryptionKeyId: "debug",
publicKey: {
crv: "P-256",
kty: "EC",
x: "XLkI3NaY3-AF2nRMspC63BT1u0Y3moXYSfss7VuQ0mk",
y: "SB0KnIW-pqk85OIEYZenoNkEyOOp5GeWQhS1KeRtEUE",
},
schemaName: "pioneer-enrollment",
schemaVersion: 1,
// Note that the schema namespace directly informs how data is segregated after ingestion.
// If this is an enrollment ping for the pioneer program (in contrast to the enrollment to
// a specific study), use a meta namespace.
schemaNamespace: "pioneer-meta",
};
// If we were provided with a study id, then this is an enrollment to a study.
// Send the id alongside with the data and change the schema namespace to simplify
// the work on the ingestion pipeline.
if (typeof studyAddonId != "undefined") {
options.studyName = studyAddonId;
// The schema namespace needs to be the study addon id, as we
// want to route the ping to the specific study table.
options.schemaNamespace = studyAddonId;
}
await TelemetryController.submitExternalPing("pioneer-study", {}, options);
}

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

@ -301,29 +301,6 @@ const clearLocale = async () => {
Services.locale.requestedLocales = ORIG_REQUESTED_LOCALES;
};
/**
* Wait for DOM attribute change on target.
*
* @param {Object} target
* The Node on which to observe DOM mutations.
* @return A promise that resolves when a change on the target DOM is detected.
*/
function waitForDOMAttributeChange(target) {
return new Promise(resolve => {
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
resolve();
});
});
observer.observe(target, {
attributes: true,
childList: false,
subtree: false,
});
});
}
add_task(async function testMockSchema() {
for (const [schemaName, values] of [
["PioneerContentSchema", CACHED_CONTENT],
@ -397,7 +374,6 @@ add_task(async function testBadDefaultAddon() {
const acceptDialogButton = content.document.getElementById(
"join-pioneer-accept-dialog-button"
);
let promiseDialogAccepted = waitForDOMAttributeChange(enrollmentButton);
acceptDialogButton.click();
const pioneerEnrolled = Services.prefs.getStringPref(
@ -406,7 +382,7 @@ add_task(async function testBadDefaultAddon() {
);
ok(pioneerEnrolled, "after enrollment, Pioneer pref is set.");
await promiseDialogAccepted;
await waitForAnimationFrame();
ok(
document.l10n.getAttributes(enrollmentButton).id ==
"pioneer-unenrollment-button",
@ -499,7 +475,6 @@ add_task(async function testAboutPage() {
const acceptDialogButton = content.document.getElementById(
"join-pioneer-accept-dialog-button"
);
let promiseDialogAccepted = waitForDOMAttributeChange(enrollmentButton);
acceptDialogButton.click();
const pioneerEnrolled = Services.prefs.getStringPref(
@ -508,7 +483,7 @@ add_task(async function testAboutPage() {
);
ok(pioneerEnrolled, "after enrollment, Pioneer pref is set.");
await promiseDialogAccepted;
await waitForAnimationFrame();
ok(
document.l10n.getAttributes(enrollmentButton).id ==
"pioneer-unenrollment-button",
@ -642,9 +617,8 @@ add_task(async function testAboutPage() {
"leave-study-accept-dialog-button"
);
let promiseJoinButtonDisabled = waitForDOMAttributeChange(joinButton);
acceptStudyCancelButton.click();
await promiseJoinButtonDisabled;
await waitForAnimationFrame();
ok(
joinButton.disabled,
@ -761,130 +735,6 @@ add_task(async function testAboutPage() {
);
});
add_task(async function testEnrollmentPings() {
const CACHED_TEST_ADDON = CACHED_ADDONS[2];
const cachedContent = JSON.stringify(CACHED_CONTENT);
const cachedAddons = JSON.stringify([CACHED_TEST_ADDON]);
await SpecialPowers.pushPrefEnv({
set: [
[PREF_TEST_CACHED_ADDONS, cachedAddons],
[PREF_TEST_CACHED_CONTENT, cachedContent],
[PREF_TEST_ADDONS, "[]"],
],
clear: [
[PREF_PIONEER_ID, ""],
[PREF_PIONEER_COMPLETED_STUDIES, "[]"],
],
});
// Clear any pending pings.
await TelemetryStorage.testClearPendingPings();
await BrowserTestUtils.withNewTab(
{
url: "about:pioneer",
gBrowser,
},
async function taskFn(browser) {
const beforePref = Services.prefs.getStringPref(PREF_PIONEER_ID, null);
ok(beforePref === null, "before enrollment, Pioneer pref is null.");
// Enroll in pioneer.
const enrollmentButton = content.document.getElementById(
"enrollment-button"
);
enrollmentButton.click();
const acceptDialogButton = content.document.getElementById(
"join-pioneer-accept-dialog-button"
);
let promiseDialogAccepted = waitForDOMAttributeChange(enrollmentButton);
acceptDialogButton.click();
const pioneerId = Services.prefs.getStringPref(PREF_PIONEER_ID, null);
ok(pioneerId, "after enrollment, Pioneer pref is set.");
await promiseDialogAccepted;
// Enroll in the CACHED_TEST_ADDON study.
const joinButton = content.document.getElementById(
`${CACHED_TEST_ADDON.addon_id}-join-button`
);
const joinDialogOpen = new Promise(resolve => {
content.document
.getElementById("join-study-consent-dialog")
.addEventListener("open", () => {
resolve();
});
});
await waitForAnimationFrame();
joinButton.click();
await waitForAnimationFrame();
await joinDialogOpen;
await waitForAnimationFrame();
// Accept consent for the study.
const studyAcceptButton = content.document.getElementById(
"join-study-accept-dialog-button"
);
studyAcceptButton.click();
await waitForAnimationFrame();
// Verify that the proper pings were generated.
let pings;
await TestUtils.waitForCondition(async function() {
pings = await TelemetryArchive.promiseArchivedPingList();
return pings.length >= 2;
}, "Wait until we have at least 2 pings in the telemetry archive");
let pingDetails = [];
for (const ping of pings) {
ok(
ping.type == "pioneer-study",
"ping is of expected type pioneer-study"
);
const details = await TelemetryArchive.promiseArchivedPingById(ping.id);
pingDetails.push({
schemaName: details.payload.schemaName,
schemaNamespace: details.payload.schemaNamespace,
studyName: details.payload.studyName,
pioneerId: details.payload.pioneerId,
});
}
// We expect 1 ping with just the pioneer id (pioneer consent) and another
// with both the pioneer id and the study id (study consent).
ok(
pingDetails.find(
p =>
p.schemaName == "pioneer-enrollment" &&
p.schemaNamespace == "pioneer-meta" &&
p.pioneerId == pioneerId &&
!p.studyName
),
"We expect the Pioneer program consent to be present"
);
ok(
pingDetails.find(
p =>
p.schemaName == "pioneer-enrollment" &&
p.schemaNamespace == CACHED_TEST_ADDON.addon_id &&
p.pioneerId == pioneerId &&
p.studyName == CACHED_TEST_ADDON.addon_id
),
"We expect the study consent to be present"
);
}
);
});
add_task(async function testPioneerBadge() {
await SpecialPowers.pushPrefEnv({
set: [[PREF_PIONEER_NEW_STUDIES_AVAILABLE, true]],

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

@ -1,58 +0,0 @@
=============
Pioneer Study
=============
The `pioneer-study` ping is the main transport used by the Pioneer components.
-------
Payload
-------
It is made up of a clear text payload and an encrypted data payload, following the structure described below.
Structure:
.. code-block:: js
"payload": {
"encryptedData": "<encrypted token>",
"schemaVersion": 1,
"schemaName": "debug",
"schemaNamespace": "<namespace>",
"encryptionKeyId": "debug",
"pioneerId": "<UUID>",
"studyName": "pioneer-v2-example"
}
See also the `JSON schemas <https://github.com/mozilla-services/mozilla-pipeline-schemas/tree/master/schemas/pioneer-debug>`_.
encryptedData
The encrypted data sent using the Pioneer platform.
schemaVersion
The payload format version.
schemaName
The name of the schema of the encrypted data.
schemaNamespace
The namespace used to segregate data on the pipeline.
encryptionKeyId
The id of the key used to encrypt the data.
pioneerId
The id of the pioneer client.
studyName (optional)
The id of the study for which the data is being collected.
------------------------
Special Pioneer Payloads
------------------------
This ping has two special Pioneer payload configurations, indicated by the different `schemaName`: `deletion-request` and `pioneer-enrollemnt`.
The `deletion-request` is sent when a user opts out from a Pioneer study: it contains the `pioneerId` and the `studyName`.
The `pioneer-enrollment` is sent when a user opts into the Pioneer program: in this case it reports `schemaNamespace: "pioneer-meta"` and will have no `studyName`. It is also sent when enrolling into a study, in which case it reports the same namespace as the `deletion-request` (i.e. the id the study making the request) and the `pioneer-enrollment` schema name.