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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
"use strict";
add_task(async function test_submit_creditCard_with_sync_account() {
await SpecialPowers.pushPrefEnv({
set: [
[SYNC_USERNAME_PREF, "foo@bar.com"],
[SYNC_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function (browser) {
let onPopupShown = waitForPopupShown();
await focusUpdateSubmitForm(browser, {
focusSelector: "#cc-name",
newValues: {
"#cc-name": "User 2",
"#cc-number": "6387060366272981",
},
});
await onPopupShown;
let cb = getDoorhangerCheckbox();
ok(!cb.hidden, "Sync checkbox should be visible");
is(
SpecialPowers.getBoolPref(SYNC_CREDITCARDS_PREF),
false,
"creditCards sync should be disabled by default"
);
// Verify if the checkbox and button state is changed.
let secondaryButton = getDoorhangerButton(SECONDARY_BUTTON);
let menuButton = getDoorhangerButton(MENU_BUTTON);
is(
cb.checked,
false,
"Checkbox state should match creditCards sync state"
);
is(
secondaryButton.disabled,
false,
"Not saving button should be enabled"
);
is(
menuButton.disabled,
false,
"Never saving menu button should be enabled"
);
// Click the checkbox to enable credit card sync.
cb.click();
is(
SpecialPowers.getBoolPref(SYNC_CREDITCARDS_PREF),
true,
"creditCards sync should be enabled after checked"
);
is(
secondaryButton.disabled,
true,
"Not saving button should be disabled"
);
is(
menuButton.disabled,
true,
"Never saving menu button should be disabled"
);
// Click the checkbox again to disable credit card sync.
cb.click();
is(
SpecialPowers.getBoolPref(SYNC_CREDITCARDS_PREF),
false,
"creditCards sync should be disabled after unchecked"
);
is(
secondaryButton.disabled,
false,
"Not saving button should be enabled again"
);
is(
menuButton.disabled,
false,
"Never saving menu button should be enabled again"
);
await clickDoorhangerButton(SECONDARY_BUTTON);
}
);
});
add_task(async function test_submit_creditCard_with_synced_already() {
await SpecialPowers.pushPrefEnv({
set: [
[SYNC_CREDITCARDS_PREF, true],
[SYNC_USERNAME_PREF, "foo@bar.com"],
[SYNC_CREDITCARDS_AVAILABLE_PREF, true],
],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function (browser) {
let onPopupShown = waitForPopupShown();
await focusUpdateSubmitForm(browser, {
focusSelector: "#cc-name",
newValues: {
"#cc-name": "User 2",
"#cc-number": "6387060366272981",
},
});
await onPopupShown;
let cb = getDoorhangerCheckbox();
ok(cb.hidden, "Sync checkbox should be hidden");
await clickDoorhangerButton(SECONDARY_BUTTON);
}
);
});
|