summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_switchTab_decodeuri.js
blob: fe23eceaf967b9d5fc1d8d17bf1ec9eeaf5c2356 (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/ */

/**
 * This test ensures that switch to tab still works when the URI contains an
 * encoded part.
 */

"use strict";

const TEST_URL = `${TEST_BASE_URL}dummy_page.html#test%7C1`;

add_task(async function test_switchtab_decodeuri() {
  info("Opening first tab");
  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);

  info("Opening and selecting second tab");
  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);

  info("Wait for autocomplete");
  await UrlbarTestUtils.promiseAutocompleteResultPopup({
    window,
    value: "dummy_page",
  });

  info("Select autocomplete popup entry");
  EventUtils.synthesizeKey("KEY_ArrowDown");
  let result = await UrlbarTestUtils.getDetailsOfResultAt(
    window,
    UrlbarTestUtils.getSelectedRowIndex(window)
  );
  Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.TAB_SWITCH);

  info("switch-to-tab");
  let tabSelectPromise = BrowserTestUtils.waitForEvent(
    window,
    "TabSelect",
    false
  );
  EventUtils.synthesizeKey("KEY_Enter");
  await tabSelectPromise;

  Assert.equal(
    gBrowser.selectedTab,
    tab,
    "Should have switched to the right tab"
  );

  gBrowser.removeCurrentTab();
  await PlacesUtils.history.clear();
});