summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/browser/heuristics/browser_label_rules.js
blob: 16b5e8a56b4a27a251bee5613bd850c781cbe18a (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
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

/* global add_heuristic_tests */

"use strict";

add_heuristic_tests([
  {
    fixtureData: `
        <html>
        <body>
          <form>
            <input type="text" id="name" autocomplete="name"/>
            <input type="text" id="country" autocomplete="country"/>
            <label for="test1">sender-address</label>
            <input type="text" id="test1"/>
            <input type="text" id="test2" name="sender-address"/>
          </form>
        </body>
        </html>`,
    expectedResult: [
      {
        default: {
          reason: "regex-heuristic",
        },
        description: `Only "sender-address" keywords in labels"`,
        fields: [
          { fieldName: "name", reason: "autocomplete" },
          { fieldName: "country", reason: "autocomplete" },
          { fieldName: "address-line1" },
        ],
      },
    ],
  },
  {
    fixtureData: `
        <html>
        <body>
          <form>
            <input type="text" id="name" autocomplete="name"/>
            <input type="text" id="country" autocomplete="country"/>
            <input type="text" id="test" aria-label="street-address"/>
          </form>
        </body>
        </html>`,
    expectedResult: [
      {
        description: `keywords are in aria-label`,
        fields: [
          { fieldName: "name", reason: "autocomplete" },
          { fieldName: "country", reason: "autocomplete" },
          { fieldName: "street-address", reason: "regex-heuristic" },
        ],
      },
    ],
  },
]);