Bug 897074 - Lower MAX_SEARCH_TOKENS to 10 in FormHistory.jsm. r=dolske
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 11 Dec 2013 00:05:31 -0800
changeset 159813 1c7402403124dc848840130b2629bb159847104b
parent 159812 166d27bf3b4b2c1ea8970659d35e88506eb59034
child 159814 ad1aec75ad509bfaab43febaf6f98877dc116b3d
push id3909
push usermozilla@noorenberghe.ca
push dateWed, 11 Dec 2013 08:09:41 +0000
treeherderfx-team@1c7402403124 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs897074
milestone29.0a1
Bug 897074 - Lower MAX_SEARCH_TOKENS to 10 in FormHistory.jsm. r=dolske
toolkit/components/satchel/FormHistory.jsm
toolkit/components/satchel/test/unit/test_autocomplete.js
--- a/toolkit/components/satchel/FormHistory.jsm
+++ b/toolkit/components/satchel/FormHistory.jsm
@@ -93,17 +93,17 @@ Components.utils.import("resource://gre/
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "uuidService",
                                    "@mozilla.org/uuid-generator;1",
                                    "nsIUUIDGenerator");
 
 const DB_SCHEMA_VERSION = 4;
 const DAY_IN_MS  = 86400000; // 1 day in milliseconds
-const MAX_SEARCH_TOKENS = 30;
+const MAX_SEARCH_TOKENS = 10;
 const NOOP = function noop() {};
 
 let supportsDeletedTable =
 #ifdef ANDROID
   true;
 #else
   false;
 #endif
--- a/toolkit/components/satchel/test/unit/test_autocomplete.js
+++ b/toolkit/components/satchel/test/unit/test_autocomplete.js
@@ -238,43 +238,42 @@ add_test(function test13() {
   run_next_test();
 });
 
 add_test(function test_token_limit_DB() {
     function test_token_limit_previousResult(previousResult) {
         do_log_info("Check that the number of tokens used in a search is not capped to " +
                     "MAX_SEARCH_TOKENS when using a previousResult");
         // This provide more accuracy since performance is less of an issue.
-        let changes = [ ];
-        // Search for a string where the first 30 tokens match the value above but the 31st does not
+        // Search for a string where the first 10 tokens match the previous value but the 11th does not
         // when re-using a previous result.
         fac.autoCompleteSearchAsync("field_token_cap",
-                                    "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 .",
+                                    "a b c d e f g h i j .",
                                     null, previousResult, {
                                         onSearchCompletion : function(aResults) {
                                             do_check_eq(aResults.matchCount, 0,
                                                         "All search tokens should be used with " +
                                                         "previous results");
                                             run_next_test();
                                         }
                                     });
     }
 
     do_log_info("Check that the number of tokens used in a search is capped to MAX_SEARCH_TOKENS " +
                 "for performance when querying the DB");
     let changes = [ ];
     changes.push({ op : "add", fieldname: "field_token_cap",
-                   // value with 36 unique tokens
-                   value: "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0",
+                   // value with 15 unique tokens
+                   value: "a b c d e f g h i j k l m n o",
                    timesUsed: 1, firstUsed: 0, lastUsed: 0 });
     updateFormHistory(changes, () => {
-        // Search for a string where the first 30 tokens match the value above but the 31st does not
-        // (which would prevent the result from being returned if the 31st term was used).
+        // Search for a string where the first 10 tokens match the value above but the 11th does not
+        // (which would prevent the result from being returned if the 11th term was used).
         fac.autoCompleteSearchAsync("field_token_cap",
-                                    "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 .",
+                                    "a b c d e f g h i j .",
                                     null, null, {
                                         onSearchCompletion : function(aResults) {
                                             do_check_eq(aResults.matchCount, 1,
                                                         "Only the first MAX_SEARCH_TOKENS tokens " +
                                                         "should be used for DB queries");
                                             test_token_limit_previousResult(aResults);
                                         }
         });