Changes and notes:
- Created `devtools/client/shared/test/telemetry-test-helpers.js`, which
contains test helpers to aid in creating and running telemetry tests.
- Removed any telemetry monkeypatching as it is not dependable and no longer
needed (there is some left in GCLI but the test is now disabled because
we are removing GCLI soon anyhow).
- Because `telemetry-test-helpers.js` is imported by `shared-head.js` I
have had to make it available everywhere that shared-head.js is used.
- All telemetry tests have been rewritten to use the new helper.
- shared-head.js cannot be imported by tests inside
`devtools/client/performance/test/` because perf have custom `once` and
`waitFor` implementations that act differently from the ones inside
`shared-head.js`. This means I had to import the telemetry helpers into
`devtools/client/performance/test/head.js`
- Created `devtools/client/shared/test/browser_telemetry_misc.js` to be sure
to catch `DEVTOOLS_SCREEN_RESOLUTION_ENUMERATED_PER_USER` (we catch a few
others to be thorough).
- Disabled `browser_inspector_menu-02-copy-items.js`, which was failing to
test some expired scalars. I also corrected the way the scalars are logged
because it was completely wrong.
MozReview-Commit-ID: JjQEGM6hT61
108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
const URL = "data:text/html;charset=utf8,browser_telemetry_activate_rdm.js";
|
|
const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
|
|
const DATA = [
|
|
{
|
|
timestamp: null,
|
|
category: "devtools.main",
|
|
method: "activate",
|
|
object: "responsive_design",
|
|
value: null,
|
|
extra: {
|
|
host: "none",
|
|
width: "1300"
|
|
}
|
|
}, {
|
|
timestamp: null,
|
|
category: "devtools.main",
|
|
method: "deactivate",
|
|
object: "responsive_design",
|
|
value: null,
|
|
extra: {
|
|
host: "bottom",
|
|
width: "1300"
|
|
}
|
|
}, {
|
|
timestamp: null,
|
|
category: "devtools.main",
|
|
method: "activate",
|
|
object: "responsive_design",
|
|
value: null,
|
|
extra: {
|
|
host: "bottom",
|
|
width: "1300"
|
|
}
|
|
}, {
|
|
timestamp: null,
|
|
category: "devtools.main",
|
|
method: "deactivate",
|
|
object: "responsive_design",
|
|
value: null,
|
|
extra: {
|
|
host: "bottom",
|
|
width: "1300"
|
|
}
|
|
}
|
|
];
|
|
|
|
add_task(async function() {
|
|
// Let's reset the counts.
|
|
Services.telemetry.clearEvents();
|
|
|
|
// Ensure no events have been logged
|
|
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
|
|
ok(!snapshot.parent, "No events have been logged for the main process");
|
|
|
|
const tab = await addTab(URL);
|
|
const target = TargetFactory.forTab(tab);
|
|
|
|
await openCloseRDM(tab);
|
|
await gDevTools.showToolbox(target, "inspector");
|
|
await openCloseRDM(tab);
|
|
await checkResults();
|
|
});
|
|
|
|
async function openCloseRDM(tab) {
|
|
let { ui } = await openRDM(tab);
|
|
let clientClosed = waitForClientClose(ui);
|
|
|
|
closeRDM(tab, {
|
|
reason: "TabClose",
|
|
});
|
|
|
|
// This flag is set at the end of `ResponsiveUI.destroy`. If it is true
|
|
// without waiting for `closeRDM` above, then we must have closed
|
|
// synchronously.
|
|
is(ui.destroyed, true, "RDM closed synchronously");
|
|
|
|
await clientClosed;
|
|
}
|
|
|
|
async function checkResults() {
|
|
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
|
|
const events = snapshot.parent.filter(event => event[1] === "devtools.main" &&
|
|
(event[2] === "activate" ||
|
|
event[2] === "deactivate")
|
|
);
|
|
|
|
for (let i in events) {
|
|
const [ timestamp, category, method, object, value, extra ] = events[i];
|
|
|
|
const expected = DATA[i];
|
|
|
|
// ignore timestamp
|
|
ok(timestamp > 0, "timestamp is greater than 0");
|
|
is(category, expected.category, "category is correct");
|
|
is(method, expected.method, "method is correct");
|
|
is(object, expected.object, "object is correct");
|
|
is(value, expected.value, "value is correct");
|
|
|
|
// extras
|
|
is(extra.host, expected.extra.host, "host is correct");
|
|
ok(extra.width > 0, "width is greater than 0");
|
|
}
|
|
}
|