Bug 750794 - Add pref UI to enable do-not-track (DNT) in Thunderbird. r,ui-r=mconley
authorSid Stamm <sstamm@mozilla.com>
Thu, 03 May 2012 17:40:40 -0400
changeset 10066 8c4f6f448f5a
parent 10065 eae8f8e14ac3
child 10067 03830819b583
push id7660
push userryanvm@gmail.com
push date2012-05-03 21:40 +0000
treeherdercomm-central@8c4f6f448f5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs750794
Bug 750794 - Add pref UI to enable do-not-track (DNT) in Thunderbird. r,ui-r=mconley
mail/components/preferences/security.xul
mail/locales/en-US/chrome/messenger/preferences/security.dtd
mail/test/mozmill/pref-window/test-donottrack-prefs.js
--- a/mail/components/preferences/security.xul
+++ b/mail/components/preferences/security.xul
@@ -90,16 +90,21 @@
                   name="network.cookie.cookieBehavior"
                   type="int"/>
       <preference id="network.cookie.lifetimePolicy"
                   name="network.cookie.lifetimePolicy"
                   type="int"/>
       <preference id="network.cookie.blockFutureCookies"
                   name="network.cookie.blockFutureCookies"
                   type="bool"/>
+
+      <!-- Do Not Track -->
+      <preference id="privacy.donottrackheader.enabled"
+                  name="privacy.donottrackheader.enabled"
+                  type="bool"/>
     </preferences>
 
     <tabbox id="securityPrefs" flex="1" onselect="gSecurityPane.tabSelectionChanged();">
       <tabs>
         <tab label="&itemJunk.label;"/>
         <tab label="&itemPhishing.label;"/>
         <tab label="&itemAntiVirus.label;"/>
         <tab label="&itemPasswords.label;"/>
@@ -225,16 +230,25 @@
               </menulist>
             </hbox>
             <hbox flex="1"/>
             <button id="showCookiesButton" label="&showCookies.label;"
                     accesskey="&showCookies.accesskey;"
                     oncommand="gSecurityPane.showCookies();"
                     preference="pref.privacy.disable_button.view_cookies"/>
           </hbox>
+
+          <separator class="thin"/>
+          <hbox id="dntBox">
+            <checkbox id="privacyDoNotTrackPref"
+                      label="&doNotTrack.label;"
+                      accesskey="&doNotTrack.accesskey;"
+                      preference="privacy.donottrackheader.enabled"/>
+          </hbox>
+
         </tabpanel>
       </tabpanels>
     </tabbox>
 
     <separator/>
 
   </prefpane>
 </overlay>
--- a/mail/locales/en-US/chrome/messenger/preferences/security.dtd
+++ b/mail/locales/en-US/chrome/messenger/preferences/security.dtd
@@ -52,8 +52,11 @@
 <!ENTITY expire.label                   "they expire">
 <!ENTITY close.label                    "I close &brandShortName;">
 <!ENTITY askEachTime.label              "ask me every time">
 <!ENTITY cookieExceptions.label         "Exceptions…">
 <!ENTITY cookieExceptions.accesskey     "E">
 <!ENTITY showCookies.label              "Show Cookies…">
 <!ENTITY showCookies.accesskey          "S">
 
+<!-- Do Not Track -->
+<!ENTITY doNotTrack.label               "Tell web sites I do not want to be tracked">
+<!ENTITY doNotTrack.accesskey           "d">
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/pref-window/test-donottrack-prefs.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * Tests the do-not-track toggle checkbox
+ */
+
+const DNT_PREF_NAME = 'privacy.donottrackheader.enabled';
+
+const MODULE_NAME = 'test-donottrack-prefs';
+
+const RELATIVE_ROOT = '../shared-modules';
+const MODULE_REQUIRES = ['folder-display-helpers',
+                         'pref-window-helpers'];
+
+function setupModule(module) {
+  collector.getModule('folder-display-helpers').installInto(module);
+  collector.getModule('pref-window-helpers').installInto(module);
+}
+
+/**
+ * Test that selecting the checkbox for the do not track feature actually sets
+ * the preference.
+ */
+function test_donottrack_checkbox() {
+  open_pref_window("paneSecurity", function(w) {
+
+    // select the "Web Content" panel
+    w.e("securityPrefs").selectedIndex = 4;
+
+    // tick the DNT box (and make sure it's ticked.
+    w.click(w.eid("privacyDoNotTrackPref"));
+    assert_true(w.e("privacyDoNotTrackPref").checked,
+                "The DNT checkbox didn't get set");
+
+    // close the window to accept the changes
+    w.e("MailPreferences").acceptDialog();
+  });
+
+  open_pref_window("paneSecurity", function(w) {
+    // Inspect the pref.
+    assert_true(Services.prefs.getBoolPref(DNT_PREF_NAME),
+                "The DNT pref did not get set");
+
+    // Make sure the box stays ticked
+    assert_true(w.e("privacyDoNotTrackPref").checked,
+                "The DNT checkbox should be checked when the pref is set");
+
+    // clear the DNT checkbox (and make sure it's not ticked);
+    w.click(w.eid("privacyDoNotTrackPref"));
+    assert_false(w.e("privacyDoNotTrackPref").checked,
+                 "The DNT checkbox did not get unset");
+
+    // close the window to accept the changes
+    w.e("MailPreferences").acceptDialog();
+  });
+
+  open_pref_window("paneSecurity", function(w) {
+    // make sure all is still reset.
+    assert_false(w.e("privacyDoNotTrackPref").checked,
+                 "The DNT checkbox should still be unset");
+    assert_false(Services.prefs.getBoolPref(DNT_PREF_NAME),
+                 "The DNT pref should be cleared.");
+
+    w.e("MailPreferences").acceptDialog();
+  });
+}