Bug 1583479 - Fix case-insensitive comparison when comparing against the home page ignore list when setting the home page value. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Fri, 04 Oct 2019 11:45:19 +0000
changeset 496327 fc32527395e2f6c83fe7c84708f08abe8ef04fae
parent 496326 4fc14159ba6925ee071ec7d1a2425b4612f5bc0d
child 496328 1cf96914dd193a3a596e6b35a12fdaeb816e095a
push id97168
push usermbanner@mozilla.com
push dateFri, 04 Oct 2019 12:39:27 +0000
treeherderautoland@fc32527395e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1583479
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1583479 - Fix case-insensitive comparison when comparing against the home page ignore list when setting the home page value. r=mikedeboer 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");
+});