summaryrefslogtreecommitdiffstats
path: root/browser/modules/test/browser/formValidation/browser_validation_invisible.js
blob: 9383ad773be534ea0340db61f3cfd9016c26d7b7 (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
62
63
64
65
66
67
"use strict";

var gInvalidFormPopup =
  gBrowser.selectedBrowser.browsingContext.currentWindowGlobal
    .getActor("FormValidation")
    ._getAndMaybeCreatePanel(document);

function checkPopupHide() {
  ok(
    gInvalidFormPopup.state != "showing" && gInvalidFormPopup.state != "open",
    "[Test " + testId + "] The invalid form popup should not be shown"
  );
}

var testId = 0;

function incrementTest() {
  testId++;
  info("Starting next part of test");
}

/**
 * In this test, we check that no popup appears if the element display is none.
 */
add_task(async function test_display_none() {
  ok(
    gInvalidFormPopup,
    "The browser should have a popup to show when a form is invalid"
  );

  incrementTest();
  let testPage =
    "data:text/html;charset=utf-8," +
    '<form target="t"><input type="url"  placeholder="url" value="http://" style="display: none;"><input id="s" type="button" value="check"></form>';
  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage);
  await BrowserTestUtils.synthesizeMouse(
    "#s",
    0,
    0,
    {},
    gBrowser.selectedBrowser
  );

  checkPopupHide();
  BrowserTestUtils.removeTab(tab);
});

/**
 * In this test, we check that no popup appears if the element visibility is hidden.
 */
add_task(async function test_visibility_hidden() {
  incrementTest();
  let testPage =
    "data:text/html;charset=utf-8," +
    '<form target="t"><input type="url"  placeholder="url" value="http://" style="visibility: hidden;"><input id="s" type="button" value="check"></form>';
  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage);
  await BrowserTestUtils.synthesizeMouse(
    "#s",
    0,
    0,
    {},
    gBrowser.selectedBrowser
  );

  checkPopupHide();
  BrowserTestUtils.removeTab(tab);
});