mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
The data reporting notification was over-complicated. It wasn't displayed for +24hr after first run and it had a weird, non-required policy around what constituted acceptance of the policy. The notification is now shown shortly after first startup. The logic around "notification accepted" has been greatly simplified by rolling it into "notification shown." Where we once were checking whether the notification has been "accepted," we now check whether it has been displayed. The overly complicated logic around the implicit acceptance of the policy has also been removed. The end result is the code for managing the state of the notification is greatly simplified.
64 lines
2 KiB
JavaScript
64 lines
2 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
function runPaneTest(fn) {
|
|
open_preferences((win) => {
|
|
let doc = win.document;
|
|
win.gotoPref("paneAdvanced");
|
|
let advancedPrefs = doc.getElementById("advancedPrefs");
|
|
let tab = doc.getElementById("dataChoicesTab");
|
|
advancedPrefs.selectedTab = tab;
|
|
|
|
let policy = Components.classes["@mozilla.org/datareporting/service;1"]
|
|
.getService(Components.interfaces.nsISupports)
|
|
.wrappedJSObject
|
|
.policy;
|
|
|
|
ok(policy, "Policy object is defined.");
|
|
fn(win, doc, policy);
|
|
});
|
|
}
|
|
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
resetPreferences();
|
|
registerCleanupFunction(resetPreferences);
|
|
runPaneTest(testBasic);
|
|
}
|
|
|
|
function testBasic(win, doc, policy) {
|
|
is(policy.healthReportUploadEnabled, true, "Health Report upload enabled on app first run.");
|
|
|
|
let checkbox = doc.getElementById("submitHealthReportBox");
|
|
ok(checkbox);
|
|
is(checkbox.checked, true, "Health Report checkbox is checked on app first run.");
|
|
|
|
checkbox.checked = false;
|
|
checkbox.doCommand();
|
|
is(policy.healthReportUploadEnabled, false, "Unchecking checkbox opts out of FHR upload.");
|
|
|
|
checkbox.checked = true;
|
|
checkbox.doCommand();
|
|
is(policy.healthReportUploadEnabled, true, "Checking checkbox allows FHR upload.");
|
|
|
|
win.close();
|
|
Services.prefs.lockPref("datareporting.healthreport.uploadEnabled");
|
|
runPaneTest(testUploadDisabled);
|
|
}
|
|
|
|
function testUploadDisabled(win, doc, policy) {
|
|
ok(policy.healthReportUploadLocked, "Upload enabled flag is locked.");
|
|
let checkbox = doc.getElementById("submitHealthReportBox");
|
|
is(checkbox.getAttribute("disabled"), "true", "Checkbox is disabled if upload flag is locked.");
|
|
policy._healthReportPrefs.unlock("uploadEnabled");
|
|
|
|
win.close();
|
|
finish();
|
|
}
|
|
|
|
function resetPreferences() {
|
|
Services.prefs.clearUserPref("datareporting.healthreport.uploadEnabled");
|
|
}
|
|
|