summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_clipboard.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/urlbar/tests/browser/browser_clipboard.js')
-rw-r--r--browser/components/urlbar/tests/browser/browser_clipboard.js43
1 files changed, 41 insertions, 2 deletions
diff --git a/browser/components/urlbar/tests/browser/browser_clipboard.js b/browser/components/urlbar/tests/browser/browser_clipboard.js
index f6127ef8d9..2332f595cc 100644
--- a/browser/components/urlbar/tests/browser/browser_clipboard.js
+++ b/browser/components/urlbar/tests/browser/browser_clipboard.js
@@ -19,8 +19,10 @@ add_setup(async function () {
["browser.urlbar.suggest.clipboard", true],
],
});
- registerCleanupFunction(() => {
+
+ registerCleanupFunction(async () => {
SpecialPowers.clipboardCopyString("");
+ await PlacesUtils.history.clear();
});
});
@@ -52,7 +54,7 @@ add_task(async function testFormattingOfClipboardSuggestion() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:home" },
- async browser => {
+ async () => {
let { result } = await searchEmptyStringAndGetFirstRow();
Assert.equal(
@@ -73,6 +75,7 @@ add_task(async function testFormattingOfClipboardSuggestion() {
}
);
});
+
// Verifies that a valid URL copied to the clipboard results in the
// display of a corresponding suggestion in the URL bar as the first
// suggestion with accurate URL and icon. Also ensures that engaging
@@ -121,6 +124,7 @@ add_task(async function testUserEngagementWithClipboardSuggestion() {
await checkClipboardSuggestionAbsent(0);
}
);
+ await PlacesUtils.history.clear();
});
// This test confirms that dismissing the result from the result menu
@@ -347,3 +351,38 @@ add_task(async function testScalarAndStopWatchTelemetry() {
}
);
});
+
+add_task(async function emptySearch_withClipboardEntry() {
+ SpecialPowers.clipboardCopyString("https://example.com/1");
+ const MAX_RESULTS = 3;
+ let expectedHistoryResults = [];
+
+ for (let i = 0; i < MAX_RESULTS; i++) {
+ await PlacesTestUtils.addVisits([`http://mochi.test/${i}`]);
+ expectedHistoryResults.push(`http://mochi.test/${i}`);
+ }
+
+ await BrowserTestUtils.withNewTab("about:robots", async function () {
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: "",
+ });
+ await UrlbarTestUtils.enterSearchMode(window, {
+ source: UrlbarUtils.RESULT_SOURCE.HISTORY,
+ });
+
+ let urls = [];
+
+ for (let i = 0; i < UrlbarTestUtils.getResultCount(window); i++) {
+ let url = (await UrlbarTestUtils.getDetailsOfResultAt(window, i)).url;
+ urls.push(url);
+ }
+
+ urls.reverse();
+ Assert.deepEqual(expectedHistoryResults, urls);
+
+ await UrlbarTestUtils.exitSearchMode(window, { clickClose: true });
+ await UrlbarTestUtils.promisePopupClose(window);
+ });
+ await PlacesUtils.history.clear();
+});