Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 function runPaneTest(fn) {
7 open_preferences((win) => {
8 let doc = win.document;
9 win.gotoPref("paneAdvanced");
10 let advancedPrefs = doc.getElementById("advancedPrefs");
11 let tab = doc.getElementById("dataChoicesTab");
12 advancedPrefs.selectedTab = tab;
14 let policy = Components.classes["@mozilla.org/datareporting/service;1"]
15 .getService(Components.interfaces.nsISupports)
16 .wrappedJSObject
17 .policy;
19 ok(policy, "Policy object is defined.");
20 fn(win, doc, policy);
21 });
22 }
24 function test() {
25 waitForExplicitFinish();
26 resetPreferences();
27 registerCleanupFunction(resetPreferences);
28 runPaneTest(testBasic);
29 }
31 function testBasic(win, doc, policy) {
32 is(policy.dataSubmissionPolicyAccepted, false, "Data submission policy not accepted.");
33 is(policy.healthReportUploadEnabled, true, "Health Report upload enabled on app first run.");
35 let checkbox = doc.getElementById("submitHealthReportBox");
36 ok(checkbox);
37 is(checkbox.checked, true, "Health Report checkbox is checked on app first run.");
39 checkbox.checked = false;
40 checkbox.doCommand();
41 is(policy.healthReportUploadEnabled, false, "Unchecking checkbox opts out of FHR upload.");
43 checkbox.checked = true;
44 checkbox.doCommand();
45 is(policy.healthReportUploadEnabled, true, "Checking checkbox allows FHR upload.");
47 win.close();
48 Services.prefs.lockPref("datareporting.healthreport.uploadEnabled");
49 runPaneTest(testUploadDisabled);
50 }
52 function testUploadDisabled(win, doc, policy) {
53 ok(policy.healthReportUploadLocked, "Upload enabled flag is locked.");
54 let checkbox = doc.getElementById("submitHealthReportBox");
55 is(checkbox.getAttribute("disabled"), "true", "Checkbox is disabled if upload flag is locked.");
56 policy._healthReportPrefs.unlock("uploadEnabled");
58 win.close();
59 finish();
60 }
62 function resetPreferences() {
63 Services.prefs.clearUserPref("datareporting.healthreport.uploadEnabled");
64 }