summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/healthreport_testRemoteCommands.html
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/general/healthreport_testRemoteCommands.html')
-rw-r--r--browser/base/content/test/general/healthreport_testRemoteCommands.html243
1 files changed, 0 insertions, 243 deletions
diff --git a/browser/base/content/test/general/healthreport_testRemoteCommands.html b/browser/base/content/test/general/healthreport_testRemoteCommands.html
deleted file mode 100644
index 7978914f2..000000000
--- a/browser/base/content/test/general/healthreport_testRemoteCommands.html
+++ /dev/null
@@ -1,243 +0,0 @@
-<html>
- <head>
- <meta charset="utf-8">
-<script type="application/javascript;version=1.7"
- src="healthreport_pingData.js">
-</script>
-<script type="application/javascript;version=1.7">
-
-function init() {
- window.addEventListener("message", doTest, false);
- doTest();
-}
-
-function checkSubmissionValue(payload, expectedValue) {
- return payload.enabled == expectedValue;
-}
-
-function isArray(arg) {
- return Object.prototype.toString.call(arg) === '[object Array]';
-}
-
-function writeDiagnostic(text) {
- let node = document.createTextNode(text);
- let br = document.createElement("br");
- document.body.appendChild(node);
- document.body.appendChild(br);
-}
-
-function validateCurrentTelemetryEnvironment(data) {
- // Simple check for now: check that the received object has the expected
- // top-level properties.
- const expectedKeys = ["profile", "settings", "system", "build", "partner", "addons"];
- return expectedKeys.every(key => (key in data));
-}
-
-function validateCurrentTelemetryPingData(ping) {
- // Simple check for now: check that the received object has the expected
- // top-level properties and that the type and reason match.
- const expectedKeys = ["environment", "clientId", "payload", "application",
- "version", "type", "id"];
- return expectedKeys.every(key => (key in ping)) &&
- (ping.type == "main") &&
- ("info" in ping.payload) &&
- ("reason" in ping.payload.info) &&
- (ping.payload.info.reason == "gather-subsession-payload");
-}
-
-function validateTelemetryPingList(list) {
- if (!isArray(list)) {
- console.log("Telemetry ping list is not an array.");
- return false;
- }
-
- // Telemetry may generate other pings (e.g. "deletion" pings), so filter those
- // out.
- const TEST_TYPES_REGEX = /^test-telemetryArchive/;
- list = list.filter(p => TEST_TYPES_REGEX.test(p.type));
-
- if (list.length != TEST_PINGS.length) {
- console.log("Telemetry ping length is not correct.");
- return false;
- }
-
- let valid = true;
- for (let i=0; i<list.length; ++i) {
- let received = list[i];
- let expected = TEST_PINGS[i];
- if (received.type != expected.type ||
- received.timestampCreated != expected.date.getTime()) {
- writeDiagnostic("Telemetry ping " + i + " does not match.");
- writeDiagnostic("Expected: " + JSON.stringify(expected));
- writeDiagnostic("Received: " + JSON.stringify(received));
- valid = false;
- } else {
- writeDiagnostic("Telemetry ping " + i + " matches.");
- }
- }
-
- return true;
-}
-
-function validateTelemetryPingData(expected, received) {
- const receivedDate = new Date(received.creationDate);
- if (received.id != expected.id ||
- received.type != expected.type ||
- receivedDate.getTime() != expected.date.getTime()) {
- writeDiagnostic("Telemetry ping data for " + expected.id + " doesn't match.");
- writeDiagnostic("Expected: " + JSON.stringify(expected));
- writeDiagnostic("Received: " + JSON.stringify(received));
- return false;
- }
-
- writeDiagnostic("Telemetry ping data for " + expected.id + " matched.");
- return true;
-}
-
-var tests = [
-{
- info: "Checking initial value is enabled",
- event: "RequestCurrentPrefs",
- payloadType: "prefs",
- validateResponse: function(payload) {
- return checkSubmissionValue(payload, true);
- },
-},
-{
- info: "Verifying disabling works",
- event: "DisableDataSubmission",
- payloadType: "prefs",
- validateResponse: function(payload) {
- return checkSubmissionValue(payload, false);
- },
-},
-{
- info: "Verifying we're still disabled",
- event: "RequestCurrentPrefs",
- payloadType: "prefs",
- validateResponse: function(payload) {
- return checkSubmissionValue(payload, false);
- },
-},
-{
- info: "Verifying that we can get the current ping data while submission is disabled",
- event: "RequestCurrentPingData",
- payloadType: "telemetry-current-ping-data",
- validateResponse: function(payload) {
- return validateCurrentTelemetryPingData(payload);
- },
-},
-{
- info: "Verifying enabling works",
- event: "EnableDataSubmission",
- payloadType: "prefs",
- validateResponse: function(payload) {
- return checkSubmissionValue(payload, true);
- },
-},
-{
- info: "Verifying we're still re-enabled",
- event: "RequestCurrentPrefs",
- payloadType: "prefs",
- validateResponse: function(payload) {
- return checkSubmissionValue(payload, true);
- },
-},
-{
- info: "Verifying that we can get the current Telemetry environment data",
- event: "RequestCurrentEnvironment",
- payloadType: "telemetry-current-environment-data",
- validateResponse: function(payload) {
- return validateCurrentTelemetryEnvironment(payload);
- },
-},
-{
- info: "Verifying that we can get the current Telemetry ping data",
- event: "RequestCurrentPingData",
- payloadType: "telemetry-current-ping-data",
- validateResponse: function(payload) {
- return validateCurrentTelemetryPingData(payload);
- },
-},
-{
- info: "Verifying that we get the proper Telemetry ping list",
- event: "RequestTelemetryPingList",
- payloadType: "telemetry-ping-list",
- validateResponse: function(payload) {
- // Validate the ping list
- if (!validateTelemetryPingList(payload)) {
- return false;
- }
-
- // Now that we received the ping ids, set up additional test tasks
- // that check loading the individual pings.
- for (let i=0; i<TEST_PINGS.length; ++i) {
- TEST_PINGS[i].id = payload[i].id;
- tests.push({
- info: "Verifying that we can get the proper Telemetry ping data #" + (i + 1),
- event: "RequestTelemetryPingData",
- eventData: { id: TEST_PINGS[i].id },
- payloadType: "telemetry-ping-data",
- validateResponse: function(payload) {
- return validateTelemetryPingData(TEST_PINGS[i], payload.pingData);
- },
- });
- }
-
- return true;
- },
-},
-];
-
-var currentTest = -1;
-function doTest(evt) {
- if (evt) {
- if (currentTest < 0 || !evt.data.content)
- return; // not yet testing
-
- var test = tests[currentTest];
- if (evt.data.type != test.payloadType)
- return; // skip unrequested events
-
- var error = JSON.stringify(evt.data.content);
- var pass = false;
- try {
- pass = test.validateResponse(evt.data.content)
- } catch (e) {}
- reportResult(test.info, pass, error);
- }
- // start the next test if there are any left
- if (tests[++currentTest])
- sendToBrowser(tests[currentTest].event, tests[currentTest].eventData);
- else
- reportFinished();
-}
-
-function reportResult(info, pass, error) {
- var data = {type: "testResult", info: info, pass: pass, error: error};
- var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data: data}, bubbles: true});
- document.dispatchEvent(event);
-}
-
-function reportFinished(cmd) {
- var data = {type: "testsComplete", count: tests.length};
- var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data: data}, bubbles: true});
- document.dispatchEvent(event);
-}
-
-function sendToBrowser(type, eventData) {
- eventData = eventData || {};
- let detail = {command: type};
- for (let key of Object.keys(eventData)) {
- detail[key] = eventData[key];
- }
-
- var event = new CustomEvent("RemoteHealthReportCommand", {detail: detail, bubbles: true});
- document.dispatchEvent(event);
-}
-
-</script>
- </head>
- <body onload="init()">
- </body>
-</html>