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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
"use strict";
const { Region } = ChromeUtils.importESModule(
"resource://gre/modules/Region.sys.mjs"
);
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.formautofill.addresses.capture.enabled", true],
["extensions.formautofill.addresses.supported", "detect"],
["extensions.formautofill.addresses.supportedCountries", "US,CA"],
],
});
});
add_task(async function test_save_doorhanger_supported_region() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: ADDRESS_FORM_URL },
async function (browser) {
const onPopupShown = waitForPopupShown();
await focusUpdateSubmitForm(browser, {
focusSelector: "#given-name",
newValues: {
"#given-name": "John",
"#family-name": "Doe",
"#organization": "Mozilla",
"#street-address": "123 Sesame Street",
"#country": "US",
},
});
await onPopupShown;
}
);
});
/**
* Do not display the address capture doorhanger if the country field of the
* submitted form is not on the supported list."
*/
add_task(async function test_save_doorhanger_unsupported_region_from_record() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: ADDRESS_FORM_URL },
async function (browser) {
await focusUpdateSubmitForm(browser, {
focusSelector: "#given-name",
newValues: {
"#given-name": "John",
"#family-name": "Doe",
"#organization": "Mozilla",
"#street-address": "123 Sesame Street",
"#country": "DE",
},
});
await ensureNoDoorhanger(browser);
}
);
});
add_task(async function test_save_doorhanger_unsupported_region_from_pref() {
const initialHomeRegion = Region._home;
const initialCurrentRegion = Region._current;
const region = "FR";
Region._setCurrentRegion(region);
Region._setHomeRegion(region);
await BrowserTestUtils.withNewTab(
{ gBrowser, url: ADDRESS_FORM_URL },
async function (browser) {
await focusUpdateSubmitForm(browser, {
focusSelector: "#given-name",
newValues: {
"#given-name": "John",
"#family-name": "Doe",
"#organization": "Mozilla",
"#street-address": "123 Sesame Street",
},
});
await ensureNoDoorhanger(browser);
}
);
Region._setCurrentRegion(initialHomeRegion);
Region._setHomeRegion(initialCurrentRegion);
});
|