Bug 1100294 - PlacesUtils.keywords.fetch() should, instead of throwing, resolve to null when passing an empty string r=mak
authorTim Taubert <ttaubert@mozilla.com>
Fri, 27 Mar 2015 12:21:27 +0100
changeset 236118 1ba56f4da590a7fc0d02ee581ab19315135fd262
parent 236117 5dce13dd431c9afbed98b5c7928b2481df46ead0
child 236119 58b3c3a8e8a8f24ba81a0cc8135dd9b5cbc3c2c1
push id57588
push userryanvm@gmail.com
push dateFri, 27 Mar 2015 15:17:31 +0000
treeherdermozilla-inbound@44e454b5e93b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1100294
milestone39.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 1100294 - PlacesUtils.keywords.fetch() should, instead of throwing, resolve to null when passing an empty string r=mak
toolkit/components/places/PlacesUtils.jsm
toolkit/components/places/tests/unit/test_keywords.js
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -2020,17 +2020,17 @@ let Keywords = {
    *
    * @param keyword
    *        The keyword to fetch.
    * @return {Promise}
    * @resolves to an object in the form: { keyword, url, postData },
    *           or null if a keyword was not found.
    */
   fetch(keyword) {
-    if (!keyword || typeof(keyword) != "string")
+    if (typeof(keyword) != "string")
       throw new Error("Invalid keyword");
     keyword = keyword.trim().toLowerCase();
     return gKeywordsCachePromise.then(cache => cache.get(keyword) || null);
   },
 
   /**
    * Adds a new keyword and postData for the given URL.
    *
--- a/toolkit/components/places/tests/unit/test_keywords.js
+++ b/toolkit/components/places/tests/unit/test_keywords.js
@@ -69,17 +69,17 @@ function expectBookmarkNotifications() {
   });
   PlacesUtils.bookmarks.addObserver(observer, false);
   return observer;
 }
 
 add_task(function* test_invalid_input() {
   Assert.throws(() => PlacesUtils.keywords.fetch(null),
                 /Invalid keyword/);
-  Assert.throws(() => PlacesUtils.keywords.fetch(""),
+  Assert.throws(() => PlacesUtils.keywords.fetch({}),
                 /Invalid keyword/);
   Assert.throws(() => PlacesUtils.keywords.fetch(5),
                 /Invalid keyword/);
 
   Assert.throws(() => PlacesUtils.keywords.insert(null),
                 /Input should be a valid object/);
   Assert.throws(() => PlacesUtils.keywords.insert("test"),
                 /Input should be a valid object/);