Bug 1035586 - allow snippets in about:home to highlight sync in the firefox menu. r=Unfocused a=lmandel
authorJared Wein <jwein@mozilla.com>
Tue, 29 Jul 2014 10:26:37 -0400
changeset 208202 4bb3a5226b75
parent 208201 97b81de9d1a5
child 208203 1c3cce4e0395
push id3765
push userjwein@mozilla.com
push date2014-07-30 17:53 +0000
treeherdermozilla-beta@4bb3a5226b75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, lmandel
bugs1035586
milestone32.0
Bug 1035586 - allow snippets in about:home to highlight sync in the firefox menu. r=Unfocused a=lmandel
browser/app/profile/firefox.js
browser/modules/UITour.jsm
toolkit/modules/PermissionsUtils.jsm
toolkit/modules/tests/xpcshell/test_PermissionsUtils.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -247,16 +247,17 @@ pref("lightweightThemes.update.enabled",
 
 // UI tour experience.
 pref("browser.uitour.enabled", true);
 pref("browser.uitour.requireSecure", true);
 pref("browser.uitour.themeOrigin", "https://addons.mozilla.org/%LOCALE%/firefox/themes/");
 pref("browser.uitour.pinnedTabUrl", "https://support.mozilla.org/%LOCALE%/kb/pinned-tabs-keep-favorite-websites-open");
 pref("browser.uitour.url", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/tour/");
 pref("browser.uitour.whitelist.add.260", "www.mozilla.org,support.mozilla.org");
+pref("browser.uitour.whitelist.add.340", "about:home");
 
 pref("browser.customizemode.tip0.shown", false);
 pref("browser.customizemode.tip0.learnMoreUrl", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/customize");
 
 pref("keyword.enabled", true);
 
 pref("general.useragent.locale", "@AB_CD@");
 pref("general.skins.selectedSkin", "classic/1.0");
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -614,17 +614,17 @@ this.UITour = {
       return false;
 
     this.importPermissions();
     let permission = Services.perms.testPermission(uri, UITOUR_PERMISSION);
     return permission == Services.perms.ALLOW_ACTION;
   },
 
   isSafeScheme: function(aURI) {
-    let allowedSchemes = new Set(["https"]);
+    let allowedSchemes = new Set(["https", "about"]);
     if (!Services.prefs.getBoolPref("browser.uitour.requireSecure"))
       allowedSchemes.add("http");
 
     if (!allowedSchemes.has(aURI.scheme))
       return false;
 
     return true;
   },
--- a/toolkit/modules/PermissionsUtils.jsm
+++ b/toolkit/modules/PermissionsUtils.jsm
@@ -21,18 +21,26 @@ function importPrefBranch(aPrefBranch, a
     } catch (e) {}
 
     if (!hosts)
       continue;
 
     hosts = hosts.split(",");
 
     for (let host of hosts) {
+      let uri = null;
       try {
-        let uri = Services.io.newURI("http://" + host, null, null);
+        uri = Services.io.newURI("http://" + host, null, null);
+      } catch (e) {
+        try {
+          uri = Services.io.newURI(host, null, null);
+        } catch (e2) {}
+      }
+
+      try {
         Services.perms.add(uri, aPermission, aAction);
       } catch (e) {}
     }
 
     Services.prefs.setCharPref(pref, "");
   }
 }
 
--- a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js
@@ -4,55 +4,64 @@
 
 // Tests that PerrmissionsUtils.jsm works as expected, including:
 // * PermissionsUtils.importfromPrefs()
 //      <ROOT>.[whitelist|blacklist].add preferences are emptied when
 //       converted into permissions on startup.
 
 
 const PREF_ROOT = "testpermissions.";
-const TEST_PERM = "text-permission";
+const TEST_PERM = "test-permission";
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/PermissionsUtils.jsm");
 
 function run_test() {
   test_importfromPrefs();
 }
 
 
 function test_importfromPrefs() {
   // Create own preferences to test
   Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.EMPTY", "");
   Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.EMPTY2", ",");
   Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.TEST", "whitelist.example.com");
-  Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.TEST2", "whitelist2-1.example.com,whitelist2-2.example.com");
+  Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.TEST2", "whitelist2-1.example.com,whitelist2-2.example.com,about:home");
   Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.EMPTY", "");
   Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.TEST", "blacklist.example.com,");
-  Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.TEST2", ",blacklist2-1.example.com,blacklist2-2.example.com");
+  Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.TEST2", ",blacklist2-1.example.com,blacklist2-2.example.com,about:mozilla");
+
+  // Check they are unknown in the permission manager prior to importing.
+  let whitelisted = ["http://whitelist.example.com",
+                     "http://whitelist2-1.example.com",
+                     "http://whitelist2-2.example.com",
+                     "about:home"];
+  let blacklisted = ["http://blacklist.example.com",
+                     "http://blacklist2-1.example.com",
+                     "http://blacklist2-2.example.com",
+                     "about:mozilla"];
+  let unknown = whitelisted.concat(blacklisted);
+  for (let url of unknown) {
+    let uri = Services.io.newURI(url, null, null);
+    do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.UNKNOWN_ACTION);
+  }
 
   // Import them
   PermissionsUtils.importFromPrefs(PREF_ROOT, TEST_PERM);
 
   // Get list of preferences to check
   let preferences = Services.prefs.getChildList(PREF_ROOT, {});
 
   // Check preferences were emptied
   for (let pref of preferences) {
     do_check_eq(Services.prefs.getCharPref(pref), "");
   }
 
   // Check they were imported into the permissions manager
-  let whitelisted = ["whitelist.example.com",
-                     "whitelist2-1.example.com",
-                     "whitelist2-2.example.com"];
-  let blacklisted = ["blacklist.example.com",
-                     "blacklist2-1.example.com",
-                     "blacklist2-2.example.com"];
   for (let url of whitelisted) {
-    let uri = Services.io.newURI("http://" + url, null, null);
+    let uri = Services.io.newURI(url, null, null);
     do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.ALLOW_ACTION);
   }
   for (let url of blacklisted) {
-    let uri = Services.io.newURI("http://" + url, null, null);
+    let uri = Services.io.newURI(url, null, null);
     do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.DENY_ACTION);
   }
 }