From fcd36849650e28cab2bd7e2c61cc334a83bcb454 Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Tue, 30 Sep 2014 13:56:06 +1300 Subject: [PATCH] Bug 1070778 - Selecting a moz-action: result then typing more can result in "Search X for moz-action:..." item. r=mak --HG-- extra : transplant_source : P/b%9D%B6T%85%22%A8%1B%F0%18%3A%827%C2qx%F6%97 --- browser/base/content/test/general/browser.ini | 2 + .../test/general/browser_bug1070778.js | 66 +++++++++++++++++++ .../content/test/general/browser_bug556061.js | 10 +-- browser/base/content/urlbarBindings.xml | 19 ++---- toolkit/content/widgets/autocomplete.xml | 5 -- 5 files changed, 78 insertions(+), 24 deletions(-) create mode 100644 browser/base/content/test/general/browser_bug1070778.js diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 75269e1812ca..50935671bc39 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -296,6 +296,8 @@ skip-if = e10s # Bug ?????? - test directly manipulates content (directly gets e [browser_bug1015721.js] skip-if = os == 'win' || e10s # Bug 1056146 - FullZoomHelper uses promiseTabLoadEvent() which isn't e10s friendly [browser_bug1064280_changeUrlInPinnedTab.js] +[browser_bug1070778.js] +skip-if = os == "linux" # Bug 1073339 - Investigate autocomplete test unreliability on Linux [browser_canonizeURL.js] skip-if = e10s # Bug ?????? - [JavaScript Error: "Error in AboutHome.sendAboutHomeData TypeError: target.messageManager is undefined" {file: "resource:///modules/AboutHome.jsm" line: 208}] [browser_contentAreaClick.js] diff --git a/browser/base/content/test/general/browser_bug1070778.js b/browser/base/content/test/general/browser_bug1070778.js new file mode 100644 index 000000000000..31ee7b19551a --- /dev/null +++ b/browser/base/content/test/general/browser_bug1070778.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function* promiseAutoComplete(inputText) { + gURLBar.focus(); + gURLBar.value = inputText.slice(0, -1); + EventUtils.synthesizeKey(inputText.slice(-1) , {}); + yield promiseSearchComplete(); +} + +function is_selected(index) { + is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`); +} + +add_task(function*() { + // This test is only relevant if UnifiedComplete is enabled. + if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) + return; + + let itemIds = []; + registerCleanupFunction(() => { + itemIds.forEach(PlacesUtils.bookmarks.removeItem); + }); + + let itemId = + PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, + NetUtil.newURI("http://example.com/?q=%s"), + PlacesUtils.bookmarks.DEFAULT_INDEX, + "test"); + PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword"); + itemIds.push(itemId); + + // This item only needed so we can select the keyword item, select something + // else, then select the keyword item again. + itemId = + PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, + NetUtil.newURI("http://example.com/keyword"), + PlacesUtils.bookmarks.DEFAULT_INDEX, + "keyword abc"); + itemIds.push(itemId); + + yield promiseAutoComplete("keyword a"); + + // Select keyword item + EventUtils.synthesizeKey("VK_DOWN", {}); + is_selected(0); + // Select next one (important!) + EventUtils.synthesizeKey("VK_DOWN", {}); + is_selected(1); + // Re-select keyword item + EventUtils.synthesizeKey("VK_UP", {}); + is_selected(0); + + EventUtils.synthesizeKey("b", {}); + yield promiseSearchComplete(); + + is(gURLBar.value, "keyword ab", "urlbar should have expected input"); + + let result = gURLBar.popup.richlistbox.firstChild; + isnot(result, null, "Should have first item"); + let uri = NetUtil.newURI(result.getAttribute("url")); + is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=ab", input: "keyword ab"}).spec, "Expect correct url"); + + EventUtils.synthesizeKey("VK_ESCAPE", {}); + yield promisePopupHidden(gURLBar.popup); +}); diff --git a/browser/base/content/test/general/browser_bug556061.js b/browser/base/content/test/general/browser_bug556061.js index 98185233ec3b..1a0563d5a312 100644 --- a/browser/base/content/test/general/browser_bug556061.js +++ b/browser/base/content/test/general/browser_bug556061.js @@ -31,7 +31,8 @@ let tests = [ setup: function() { gURLBar.value = testActionURL; gURLBar.valueIsTyped = true; - is(gURLBar.value, testActionURL, "gURLBar.value starts with correct value"); + is(gURLBar._value, testActionURL, "gURLBar starts with the correct real value"); + is(gURLBar.value, testURL, "gURLBar starts with the correct display value"); // Focus the urlbar so we can select it all & copy gURLBar.focus(); @@ -39,7 +40,7 @@ let tests = [ goDoCommand("cmd_copy"); }, success: function() { - is(gURLBar.value, testActionURL, "gURLBar.value didn't change when copying"); + is(gURLBar._value, testActionURL, "gURLBar.value didn't change when copying"); } }, { @@ -51,7 +52,7 @@ let tests = [ goDoCommand("cmd_copy"); }, success: function() { - is(gURLBar.value, testActionURL, "gURLBar.value didn't change when copying"); + is(gURLBar._value, testActionURL, "gURLBar.value didn't change when copying"); } }, { @@ -73,7 +74,8 @@ let tests = [ gURLBar.value = testActionURL; gURLBar.valueIsTyped = true; // Sanity check that we have the right value - is(gURLBar.value, testActionURL, "gURLBar.value starts with correct value"); + is(gURLBar._value, testActionURL, "gURLBar starts with the correct real value"); + is(gURLBar.value, testURL, "gURLBar starts with the correct display value"); // Now just select part of the value & cut that. gURLBar.selectionStart = testURL.length - 10; diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index a5feea220f45..24acdd622ed5 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -125,19 +125,6 @@ "" - - - - -