# HG changeset patch
# User t_mrc-ct@users.sourceforge.jp
# Date 1383311402 -32400
# Branch GECKO3110_2014082819_RELBRANCH
# Node ID 6d12ac5c07a0194200f6a0dfb79088ecf60831cc
# Parent  5fb7d1727be53c929306ef431a3fe5d0c7515693
fix test failure caused by TFFx Issue21 workaround

diff --git a/toolkit/components/places/tests/autocomplete/head_autocomplete.js b/toolkit/components/places/tests/autocomplete/head_autocomplete.js
--- a/toolkit/components/places/tests/autocomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/autocomplete/head_autocomplete.js
@@ -81,16 +81,20 @@
     numSearchesStarted++;
     do_check_eq(numSearchesStarted, 1);
   };
 
   input.onSearchComplete = function() {
     do_check_eq(numSearchesStarted, 1);
     aExpected = aExpected.slice();
 
+    // detect TFFx Issue 21 workaround
+    let is_issue21 = controller.matchCount == 1 && controller.getValueAt(0) == "" && controller.getCommentAt(0) == ""&& controller.getImageAt(0) == "";
+
+    if (! is_issue21) {
     // Check to see the expected uris and titles match up (in any order)
     for (let i = 0; i < controller.matchCount; i++) {
       let value = controller.getValueAt(i);
       let comment = controller.getCommentAt(i);
 
       print("Looking for '" + value + "', '" + comment + "' in expected results...");
       let j;
       for (j = 0; j < aExpected.length; j++) {
@@ -115,26 +119,31 @@
           break;
         }
       }
 
       // We didn't hit the break, so we must have not found it
       if (j == aExpected.length)
         do_throw("Didn't find the current result ('" + value + "', '" + comment + "') in expected: " + aExpected);
     }
-
+    }// ! is_issue21
+ 
+    let expected_len = aExpected.length;
+    let expected_stat = aExpected.length ? Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH : Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
+    if (is_issue21) {
+      expected_len = 1;
+      expected_stat = Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH;
+    }
     // Make sure we have the right number of results
-    print("Expecting " + aExpected.length + " results; got " +
+    print("Expecting " + expected_len + " results; got " +
           controller.matchCount + " results");
-    do_check_eq(controller.matchCount, aExpected.length);
+    do_check_eq(controller.matchCount, expected_len);
 
     // If we expect results, make sure we got matches
-    do_check_eq(controller.searchStatus, aExpected.length ?
-                Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH :
-                Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
+    do_check_eq(controller.searchStatus, expected_stat);
 
     // Fetch the next test if we have more
     if (++current_test < gTests.length)
       run_test();
 
     do_test_finished();
   };
 
diff --git a/toolkit/components/places/tests/unit/test_adaptive_bug527311.js b/toolkit/components/places/tests/unit/test_adaptive_bug527311.js
--- a/toolkit/components/places/tests/unit/test_adaptive_bug527311.js
+++ b/toolkit/components/places/tests/unit/test_adaptive_bug527311.js
@@ -73,19 +73,27 @@
 
 function check_results() {
   let controller = Cc["@mozilla.org/autocomplete/controller;1"].
                    getService(Ci.nsIAutoCompleteController);
   let input = new AutoCompleteInput(["history"]);
   controller.input = input;
 
   input.onSearchComplete = function() {
-    do_check_eq(controller.searchStatus,
-                Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
-    do_check_eq(controller.matchCount, 0);
+    // detect TFFx Issue 21 workaround
+    let is_issue21 = controller.matchCount == 1 && controller.getValueAt(0) == "" && controller.getCommentAt(0) == ""&& controller.getImageAt(0) == "";
+
+    let expected_stat = Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
+    let expected_cnt = 0;
+    if (is_issue21) {
+      expected_stat = Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH;
+      expected_cnt = 1;
+    }
+    do_check_eq(controller.searchStatus, expected_stat);
+    do_check_eq(controller.matchCount, expected_cnt);
 
     remove_all_bookmarks();
     do_test_finished();
  };
 
   controller.startSearch(SEARCH_STRING);
 }
 
diff --git a/toolkit/components/places/tests/unit/test_history_autocomplete_tags.js b/toolkit/components/places/tests/unit/test_history_autocomplete_tags.js
--- a/toolkit/components/places/tests/unit/test_history_autocomplete_tags.js
+++ b/toolkit/components/places/tests/unit/test_history_autocomplete_tags.js
@@ -84,27 +84,34 @@
   var numSearchesStarted = 0;
   input.onSearchBegin = function() {
     numSearchesStarted++;
     do_check_eq(numSearchesStarted, 1);
   };
 
   input.onSearchComplete = function() {
     do_check_eq(numSearchesStarted, 1);
-    do_check_eq(controller.searchStatus, 
-                uris.length ?
-                Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH :
-                Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
-    do_check_eq(controller.matchCount, uris.length);
+
+    // detect TFFx Issue 21 workaround
+    let is_issue21 = controller.matchCount == 1 && controller.getValueAt(0) == "" && controller.getCommentAt(0) == "" && controller.getImageAt(0) == "";
+
+    let expected_stat = uris.length ? Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH : Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
+    if (is_issue21) {
+      expected_stat = Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH;
+    }
+
+    do_check_eq(controller.searchStatus, expected_stat);
     let vals = [];
+    if (! is_issue21) {
     for (var i=0; i<controller.matchCount; i++) {
       // Keep the URL for later because order of tag results is undefined
       vals.push(controller.getValueAt(i));
       do_check_eq(controller.getStyleAt(i), "tag");
     }
+    } // ! is_issue21
     // Sort the results then check if we have the right items
     vals.sort().forEach(function(val, i) do_check_eq(val, uris[i].spec))
    
     if (current_test < (tests.length - 1)) {
       current_test++;
       tests[current_test]();
     }
 
