summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/browser/browser_dropdown_layout.js
blob: bc1d2fccabe72a467d70a55c7c0bf2b2caf52a26 (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
"use strict";

const URL =
  "http://example.org/browser/browser/extensions/formautofill/test/browser/autocomplete_basic.html";

add_task(async function setup_storage() {
  await setStorage(TEST_ADDRESS_1, TEST_ADDRESS_2, TEST_ADDRESS_3);
});

async function reopenPopupWithResizedInput(browser, selector, newSize) {
  await closePopup(browser);
  /* eslint no-shadow: ["error", { "allow": ["selector", "newSize"] }] */
  await SpecialPowers.spawn(
    browser,
    [{ selector, newSize }],
    async function ({ selector, newSize }) {
      const input = content.document.querySelector(selector);

      input.style.boxSizing = "border-box";
      input.style.width = newSize + "px";
    }
  );
  await openPopupOn(browser, selector);
}

add_task(async function test_address_dropdown() {
  await BrowserTestUtils.withNewTab(
    { gBrowser, url: URL },
    async function (browser) {
      const focusInput = "#organization";
      await openPopupOn(browser, focusInput);
      const firstItem = getDisplayedPopupItems(browser)[0];

      is(firstItem.getAttribute("ac-image"), "", "Should not show icon");

      // The breakpoint of two-lines layout is 150px
      await reopenPopupWithResizedInput(browser, focusInput, 140);
      is(
        firstItem._itemBox.getAttribute("size"),
        "small",
        "Show two-lines layout"
      );
      await reopenPopupWithResizedInput(browser, focusInput, 160);
      is(
        firstItem._itemBox.hasAttribute("size"),
        false,
        "Show one-line layout"
      );

      await closePopup(browser);
    }
  );
});