summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_copy_and_paste_first_result.js
blob: 236ad49671d50c119122179ff05a9ebc437e28c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_setup(async function () {
  registerCleanupFunction(async function () {
    gURLBar.handleRevert();
    await PlacesUtils.history.clear();
  });
  SpecialPowers.pushPrefEnv({
    set: [
      ["browser.urlbar.autoFill", true],
      ["browser.urlbar.suggest.quickactions", false],
    ],
  });

  await PlacesUtils.history.clear();
  await PlacesTestUtils.addVisits([
    "https://example.com/",
    "https://example.com/foo",
  ]);
});

add_task(async function () {
  await UrlbarTestUtils.promiseAutocompleteResultPopup({
    window,
    value: "exam",
  });
  Assert.equal(
    gURLBar.value,
    "example.com/",
    "autofilled value is as expected"
  );

  await UrlbarTestUtils.promisePopupClose(window);

  goDoCommand("cmd_selectAll");
  goDoCommand("cmd_copy");
  goDoCommand("cmd_paste");
  Assert.equal(
    gURLBar.inputField.value,
    "https://example.com/",
    "pasted value contains scheme"
  );
});