Files
sousa-gecko/testing/web-platform/mozilla/tests/resources/GleanTest.js
T
Kagami Sascha Rosylight 54e123f5c4 Bug 1969357 - Add telemetry for DWP payloads r=asuth,dom-worker-reviewers
Also extend the data clear telemetry, which is also relevant for DWP as one of the arguments was that DWP subscription should not be cleared with other data as long as the permission exists.

Differential Revision: https://phabricator.services.mozilla.com/D274428
2025-12-04 13:28:26 +00:00

60 lines
1.6 KiB
JavaScript

/* 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/. */
"use strict";
// This file is a copy of testing/mochitest/tests/SimpleTest/GleanTest.js,
// as WPT does not serve SimpleTest.
var GleanTest;
(function () {
async function testResetFOG() {
return SpecialPowers.spawnChrome([], async () => {
await Services.fog.testFlushAllChildren();
Services.fog.testResetFOG();
});
}
async function flush() {
return SpecialPowers.spawnChrome([], async () => {
await Services.fog.testFlushAllChildren();
});
}
async function testGetValue(chain) {
return SpecialPowers.spawnChrome([chain], async chain => {
await Services.fog.testFlushAllChildren();
const window = this.browsingContext.topChromeWindow;
let glean = window.Glean;
while (chain.length) {
glean = glean[chain.shift()];
}
return glean.testGetValue();
});
}
function recurse(chain = []) {
return new Proxy(
{},
{
get(_, prop) {
if (chain.length === 0) {
if (prop === "testResetFOG") {
return testResetFOG;
} else if (prop === "flush") {
return flush;
}
}
if (chain.length >= 2 && prop === "testGetValue") {
return () => testGetValue(chain);
}
return recurse(chain.concat(prop));
},
}
);
}
window.GleanTest = recurse();
})();