summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_keyword_override.js
blob: b358f3a4ace7129a002ba0a7058ee787a5db0ad7 (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
52
53
54
55
56
57
58
59
60
61
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * This tests that the display of keyword results are not changed when the user
 * presses the override button.
 */

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

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

  await UrlbarTestUtils.promiseAutocompleteResultPopup({
    window,
    value: "keyword search",
  });
  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);

  info("Before override");
  Assert.equal(
    result.type,
    UrlbarUtils.RESULT_TYPE.KEYWORD,
    "Should have a keyword result"
  );
  Assert.equal(
    result.displayed.title,
    "example.com: search",
    "Node should contain the name of the bookmark and query"
  );
  Assert.ok(!result.displayed.action, "Should have an empty action");

  info("During override");
  EventUtils.synthesizeKey("VK_SHIFT", { type: "keydown" });

  Assert.equal(
    result.type,
    UrlbarUtils.RESULT_TYPE.KEYWORD,
    "Should have a keyword result"
  );
  Assert.equal(
    result.displayed.title,
    "example.com: search",
    "Node should contain the name of the bookmark and query"
  );
  Assert.ok(!result.displayed.action, "Should have an empty action");

  EventUtils.synthesizeKey("VK_SHIFT", { type: "keyup" });
});