summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_delete.js
blob: f4a883ea3037820dc536208bddf1042bc3dc231c (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
47
48
49
50
51
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Test deleting the start of urls works correctly.
 */

add_task(async function () {
  let bm = await PlacesUtils.bookmarks.insert({
    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
    url: "http://bug1105244.example.com/",
    title: "test",
  });

  registerCleanupFunction(async function () {
    await PlacesUtils.bookmarks.remove(bm);
  });

  await BrowserTestUtils.withNewTab("about:blank", testDelete);
});

function sendHome() {
  // unclear why VK_HOME doesn't work on Mac, but it doesn't...
  if (AppConstants.platform == "macosx") {
    EventUtils.synthesizeKey("KEY_ArrowLeft", { metaKey: true });
  } else {
    EventUtils.synthesizeKey("KEY_Home");
  }
}

function sendDelete() {
  EventUtils.synthesizeKey("KEY_Delete");
}

async function testDelete() {
  await UrlbarTestUtils.promiseAutocompleteResultPopup({
    window,
    value: "bug1105244",
  });

  // move to the start.
  sendHome();

  // delete the first few chars - each delete should operate on the input field.
  await UrlbarTestUtils.promisePopupOpen(window, sendDelete);
  Assert.equal(gURLBar.inputField.value, "ug1105244.example.com/");
  sendDelete();
  Assert.equal(gURLBar.inputField.value, "g1105244.example.com/");
}