forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1609942 - Display autocomplete popup at the top of the input. r=j…
…descottes,Honza. This prevents the popup to cover the eager evaluation result. In order for the popup to be able to appear outside of the toolbox, we pass the useXulWrapper option to the HTMLTooltip. Differential Revision: https://phabricator.services.mozilla.com/D62431 --HG-- extra : moz-landing-system : lando
- Loading branch information
Showing
13 changed files
with
127 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
devtools/client/shared/test/browser_autocomplete_popup_consecutive-show.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
// Test that calling `showPopup` multiple time does not lead to invalid state. | ||
|
||
add_task(async function() { | ||
const AutocompletePopup = require("devtools/client/shared/autocomplete-popup"); | ||
|
||
info("Create an autocompletion popup"); | ||
const [, , doc] = await createHost(); | ||
const input = doc.createElement("input"); | ||
doc.body.appendChild(input); | ||
|
||
const autocompleteOptions = { | ||
position: "top", | ||
autoSelect: true, | ||
useXulWrapper: true, | ||
}; | ||
const popup = new AutocompletePopup(doc, autocompleteOptions); | ||
const items = [{ label: "a" }, { label: "b" }, { label: "c" }]; | ||
popup.setItems(items); | ||
|
||
input.focus(); | ||
|
||
let onAllEventsReceived = waitForNEvents(popup, "popup-opened", 3); | ||
// Note that the lack of `await` on those function calls are wanted. | ||
popup.openPopup(input, 0, 0, 0); | ||
popup.openPopup(input, 0, 0, 1); | ||
popup.openPopup(input, 0, 0, 2); | ||
await onAllEventsReceived; | ||
|
||
ok(popup.isOpen, "popup is open"); | ||
is( | ||
popup.selectedIndex, | ||
2, | ||
"Selected index matches the one that was set last when calling openPopup" | ||
); | ||
|
||
onAllEventsReceived = waitForNEvents(popup, "popup-opened", 2); | ||
// Note that the lack of `await` on those function calls are wanted. | ||
popup.openPopup(input, 0, 0, 1); | ||
popup.openPopup(input); | ||
await onAllEventsReceived; | ||
|
||
ok(popup.isOpen, "popup is open"); | ||
is( | ||
popup.selectedIndex, | ||
0, | ||
"First item is selected, as last call to openPopup did not specify an index and autoSelect is true" | ||
); | ||
|
||
const onPopupClose = popup.once("popup-closed"); | ||
popup.hidePopup(); | ||
await onPopupClose; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.