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

"use strict";

// Tests that the view results are cleared and the view is closed, when an empty
// result set arrives after a non-empty one.

add_task(async function () {
  await UrlbarTestUtils.promiseAutocompleteResultPopup({
    window,
    value: "foo",
  });
  Assert.ok(
    UrlbarTestUtils.getResultCount(window) > 0,
    `There should be some results in the view.`
  );
  Assert.ok(gURLBar.view.isOpen, `The view should be open.`);

  // Register an high priority empty result provider.
  let provider = new UrlbarTestUtils.TestProvider({
    results: [],
    priority: 999,
  });
  UrlbarProvidersManager.registerProvider(provider);
  registerCleanupFunction(async function () {
    UrlbarProvidersManager.unregisterProvider(provider);
    await PlacesUtils.history.clear();
  });

  await UrlbarTestUtils.promiseAutocompleteResultPopup({
    window,
    value: "foo",
  });
  Assert.ok(
    UrlbarTestUtils.getResultCount(window) == 0,
    `There should be no results in the view.`
  );
  Assert.ok(!gURLBar.view.isOpen, `The view should have been closed.`);
});