Bug 1583479 - Fix case-insensitive comparison when comparing against the home page ignore list when setting the home page value. r=mikedeboer a=lizzard
authorMark Banner <standard8@mozilla.com>
Fri, 04 Oct 2019 11:45:19 +0000
changeset 552286 baa92051f2a0bf4890f8c7cffffbf2e838b1bb45
parent 552285 281ce5e6022b3239c517fb93b231e4109031c8ee
child 552287 115767617f565a5ea82c9fdfed8e275c6a210418
push id12127
push userarchaeopteryx@coole-files.de
push dateMon, 07 Oct 2019 18:30:11 +0000
treeherdermozilla-beta@115767617f56 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, lizzard
bugs1583479
milestone70.0
Bug 1583479 - Fix case-insensitive comparison when comparing against the home page ignore list when setting the home page value. r=mikedeboer a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D48169
browser/modules/HomePage.jsm
browser/modules/test/unit/test_HomePage_ignore.js
--- a/browser/modules/HomePage.jsm
+++ b/browser/modules/HomePage.jsm
@@ -232,17 +232,17 @@ let HomePage = {
    *   A string that is the url or urls to be ignored.
    * @returns {boolean}
    *   True if the url should be ignored.
    */
   async shouldIgnore(url) {
     await this.init();
 
     const lowerURL = url.toLowerCase();
-    return this._ignoreList.some(code => lowerURL.includes(code));
+    return this._ignoreList.some(code => lowerURL.includes(code.toLowerCase()));
   },
 
   /**
    * Handles updates of the ignore list, checking the existing preference and
    * correcting it as necessary.
    *
    * @param {Object} eventData
    *   The event data as received from RemoteSettings.
--- a/browser/modules/test/unit/test_HomePage_ignore.js
+++ b/browser/modules/test/unit/test_HomePage_ignore.js
@@ -21,17 +21,17 @@ const HOMEPAGE_IGNORELIST = "homepage-ur
 /**
  * Provides a basic set of remote settings for use in tests.
  */
 async function setupRemoteSettings() {
   const settings = await RemoteSettings("hijack-blocklists");
   sinon.stub(settings, "get").returns([
     {
       id: HOMEPAGE_IGNORELIST,
-      matches: ["ignore=me"],
+      matches: ["ignore=me", "ignoreCASE=ME"],
       _status: "synced",
     },
   ]);
 }
 
 add_task(async function setup() {
   await setupRemoteSettings();
 });
@@ -75,17 +75,17 @@ add_task(async function test_updateIgnor
   // Simulate an ignore list update.
   await RemoteSettings("hijack-blocklists").emit("sync", {
     data: {
       current: [
         {
           id: HOMEPAGE_IGNORELIST,
           schema: 1553857697843,
           last_modified: 1553859483588,
-          matches: ["ignore=me", "new=ignore"],
+          matches: ["ignore=me", "ignoreCASE=ME", "new=ignore"],
         },
       ],
     },
   });
 
   Assert.ok(
     !HomePage.overridden,
     "Should no longer be overriding the homepage."
@@ -99,29 +99,35 @@ add_task(async function test_updateIgnor
     [{ object: "ignore", value: "saved_reset" }],
     {
       category: "homepage",
       method: "preference",
     }
   );
 });
 
-add_task(async function test_setIgnoredUrl() {
+async function testSetIgnoredUrl(url) {
   Assert.ok(!HomePage.overriden, "Should not be overriding the homepage");
 
-  await HomePage.set("http://bad/?ignore=me");
+  await HomePage.set(url);
 
   Assert.equal(
     HomePage.get(),
     HomePage.getDefault(),
     "Should still have the default homepage."
   );
   Assert.ok(!HomePage.overriden, "Should not be overriding the homepage.");
   TelemetryTestUtils.assertEvents(
     [{ object: "ignore", value: "set_blocked" }],
     {
       category: "homepage",
       method: "preference",
     }
   );
+}
+
+add_task(async function test_setIgnoredUrl() {
+  await testSetIgnoredUrl("http://bad/?ignore=me");
 });
 
-// Also need an integration mochitest with an extension (if we can).
+add_task(async function test_setIgnoredUrl_case() {
+  await testSetIgnoredUrl("http://bad/?Ignorecase=me");
+});