Bug 1046062 - unified version of test_swap_protocol.js is disabled without a reason. r=ttaubert
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -129,54 +129,57 @@ function* check_autocomplete(test) {
controller.startSearch(test.search);
yield deferred.promise;
// We should be running only one query.
Assert.equal(numSearchesStarted, 1, "Only one search started");
// Check to see the expected uris and titles match up (in any order)
if (test.matches) {
+ // Do not modify the test original matches.
+ let matches = test.matches.slice();
+
for (let i = 0; i < controller.matchCount; i++) {
let value = controller.getValueAt(i);
let comment = controller.getCommentAt(i);
do_log_info("Looking for '" + value + "', '" + comment + "' in expected results...");
let j;
- for (j = 0; j < test.matches.length; j++) {
+ for (j = 0; j < matches.length; j++) {
// Skip processed expected results
- if (test.matches[j] == undefined)
+ if (matches[j] == undefined)
continue;
- let { uri, title, tags } = test.matches[j];
+ let { uri, title, tags } = matches[j];
if (tags)
title += " \u2013 " + tags.sort().join(", ");
do_log_info("Checking against expected '" + uri.spec + "', '" + title + "'...");
// Got a match on both uri and title?
if (stripPrefix(uri.spec) == stripPrefix(value) && title == comment) {
do_log_info("Got a match at index " + j + "!");
// Make it undefined so we don't process it again
- test.matches[j] = undefined;
+ matches[j] = undefined;
if (uri.spec.startsWith("moz-action:")) {
let style = controller.getStyleAt(i);
Assert.ok(style.contains("action"));
}
break;
}
}
// We didn't hit the break, so we must have not found it
- if (j == test.matches.length)
+ if (j == matches.length)
do_throw("Didn't find the current result ('" + value + "', '" + comment + "') in matches");
}
- Assert.equal(controller.matchCount, test.matches.length,
+ Assert.equal(controller.matchCount, matches.length,
"Got as many results as expected");
// If we expect results, make sure we got matches.
- do_check_eq(controller.searchStatus, test.matches.length ?
+ do_check_eq(controller.searchStatus, matches.length ?
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH :
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
}
if (test.autofilled) {
// Check the autoFilled result.
Assert.equal(input.textValue, test.autofilled,
"Autofilled value is correct");
--- a/toolkit/components/places/tests/unifiedcomplete/test_swap_protocol.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_swap_protocol.js
@@ -33,34 +33,35 @@ add_task(function* test_swap_protocol()
{ uri: uri1, title: "title" },
{ uri: uri2, title: "title" },
{ uri: uri3, title: "title" },
{ uri: uri4, title: "title" },
{ uri: uri5, title: "title" },
{ uri: uri6, title: "title" }
];
+ // Disable autoFill to avoid handling the first result.
Services.prefs.setBoolPref("browser.urlbar.autoFill", "false");
do_log_info("http://www.site matches all site");
yield check_autocomplete({
search: "http://www.site",
matches: allMatches
});
-/*
+
do_log_info("http://site matches all site");
yield check_autocomplete({
search: "http://site",
matches: allMatches
});
do_log_info("ftp://ftp.site matches itself");
yield check_autocomplete({
search: "ftp://ftp.site",
- matches: { uri: uri3, title: "title"}
+ matches: [ { uri: uri3, title: "title" } ]
});
do_log_info("ftp://site matches all site");
yield check_autocomplete({
search: "ftp://site",
matches: allMatches
});
@@ -139,11 +140,11 @@ add_task(function* test_swap_protocol()
matches: [ { uri: uri8, title: "title" } ]
});
do_log_info("http://www.www matches none of www.");
yield check_autocomplete({
search: "http://www.www",
matches: [ { uri: uri8, title: "title" } ]
});
-*/
+
yield cleanup();
});