mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 873054 - Disable FHR prefs checkbox if pref is locked; r=rnewman
This commit is contained in:
parent
a487fb09ec
commit
22811e33cf
@ -250,7 +250,7 @@ var gAdvancedPane = {
|
||||
|
||||
let checkbox = document.getElementById("submitHealthReportBox");
|
||||
|
||||
if (!policy) {
|
||||
if (!policy || policy.healthReportUploadLocked) {
|
||||
checkbox.setAttribute("disabled", "true");
|
||||
return;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ var gAdvancedPane = {
|
||||
|
||||
let checkbox = document.getElementById("submitHealthReportBox");
|
||||
|
||||
if (!policy) {
|
||||
if (!policy || policy.healthReportUploadLocked) {
|
||||
checkbox.setAttribute("disabled", "true");
|
||||
return;
|
||||
}
|
||||
|
@ -3,26 +3,32 @@
|
||||
|
||||
"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);
|
||||
open_preferences(runTest);
|
||||
runPaneTest(testBasic);
|
||||
}
|
||||
|
||||
function runTest(win) {
|
||||
let doc = win.document;
|
||||
|
||||
win.gotoPref("paneAdvanced");
|
||||
let advancedPrefs = doc.getElementById("advancedPrefs");
|
||||
let dataChoicesTab = doc.getElementById("dataChoicesTab");
|
||||
advancedPrefs.selectedTab = dataChoicesTab;
|
||||
|
||||
let policy = Components.classes["@mozilla.org/datareporting/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject
|
||||
.policy;
|
||||
ok(policy);
|
||||
function testBasic(win, doc, policy) {
|
||||
is(policy.dataSubmissionPolicyAccepted, false, "Data submission policy not accepted.");
|
||||
is(policy.healthReportUploadEnabled, true, "Health Report upload enabled on app first run.");
|
||||
|
||||
@ -38,6 +44,17 @@ function runTest(win) {
|
||||
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();
|
||||
}
|
||||
|
@ -3,28 +3,46 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
function runPaneTest(fn) {
|
||||
function observer(win, topic, data) {
|
||||
Services.obs.removeObserver(observer, "advanced-pane-loaded");
|
||||
|
||||
let policy = Components.classes["@mozilla.org/datareporting/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject
|
||||
.policy;
|
||||
ok(policy, "Policy object defined");
|
||||
|
||||
fn(win, policy);
|
||||
}
|
||||
|
||||
Services.obs.addObserver(observer, "advanced-pane-loaded", false);
|
||||
openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",
|
||||
"chrome,titlebar,toolbar,centerscreen,dialog=no", "paneAdvanced");
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
resetPreferences();
|
||||
registerCleanupFunction(resetPreferences);
|
||||
|
||||
function observer(win, topic, data) {
|
||||
Services.obs.removeObserver(observer, "advanced-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
Services.obs.addObserver(observer, "advanced-pane-loaded", false);
|
||||
openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",
|
||||
"chrome,titlebar,toolbar,centerscreen,dialog=no", "paneAdvanced");
|
||||
Services.prefs.lockPref("datareporting.healthreport.uploadEnabled");
|
||||
runPaneTest(testUploadDisabled);
|
||||
}
|
||||
|
||||
function runTest(win) {
|
||||
function testUploadDisabled(win, policy) {
|
||||
ok(policy.healthReportUploadLocked, "Upload enabled flag is locked.");
|
||||
let checkbox = win.document.getElementById("submitHealthReportBox");
|
||||
is(checkbox.getAttribute("disabled"), "true", "Checkbox is disabled if upload setting is locked.");
|
||||
policy._healthReportPrefs.unlock("uploadEnabled");
|
||||
|
||||
win.close();
|
||||
runPaneTest(testBasic);
|
||||
}
|
||||
|
||||
function testBasic(win, policy) {
|
||||
let doc = win.document;
|
||||
|
||||
let policy = Components.classes["@mozilla.org/datareporting/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject
|
||||
.policy;
|
||||
ok(policy);
|
||||
is(policy.dataSubmissionPolicyAccepted, false, "Data submission policy not accepted.");
|
||||
is(policy.healthReportUploadEnabled, true, "Health Report upload enabled on app first run.");
|
||||
|
||||
|
@ -650,6 +650,13 @@ DataReportingPolicy.prototype = Object.freeze({
|
||||
this._healthReportPrefs.set("uploadEnabled", !!value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Whether the FHR upload enabled setting is locked and can't be changed.
|
||||
*/
|
||||
get healthReportUploadLocked() {
|
||||
return this._healthReportPrefs.locked("uploadEnabled");
|
||||
},
|
||||
|
||||
/**
|
||||
* Record user acceptance of data submission policy.
|
||||
*
|
||||
|
@ -120,6 +120,12 @@ add_test(function test_prefs() {
|
||||
do_check_false(hrPrefs.get("uploadEnabled"));
|
||||
do_check_false(policy.healthReportUploadEnabled);
|
||||
|
||||
do_check_false(policy.healthReportUploadLocked);
|
||||
hrPrefs.lock("uploadEnabled");
|
||||
do_check_true(policy.healthReportUploadLocked);
|
||||
hrPrefs.unlock("uploadEnabled");
|
||||
do_check_false(policy.healthReportUploadLocked);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user