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
|
"use strict";
const CC_VALUES = {
"#cc-name": "User",
"#cc-number": "5577000055770004",
"#cc-exp-month": 12,
"#cc-exp-year": 2017,
};
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.formautofill.creditCards.supported", "on"],
["extensions.formautofill.creditCards.enabled", true],
["extensions.formautofill.heuristics.captureOnPageNavigation", true],
],
});
});
/**
* Tests if the credit card is captured (cc doorhanger is shown)
* after adding an entry to the browser's session history stack
*/
add_task(
async function test_creditCard_captured_after_changing_request_state() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_WITH_PAGE_NAVIGATION_BUTTONS },
async function (browser) {
const onPopupShown = waitForPopupShown();
info("Update identified credit card fields");
// We don't submit the form
await focusUpdateSubmitForm(
browser,
{
focusSelector: "#cc-name",
newValues: CC_VALUES,
},
false
);
info("Change request state");
await SpecialPowers.spawn(browser, [], () => {
const historyPushStateButton =
content.document.getElementById("historyPushState");
historyPushStateButton.click();
});
info("Wait for credit card doorhanger");
await onPopupShown;
ok(true, "Credit card doorhanger is shown");
}
);
}
);
/**
* Tests if the credit card is captured (cc doorhanger is shown) after a
* after navigating by opening another resource
*/
add_task(
async function test_creditCard_captured_after_navigation_same_window() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_WITH_PAGE_NAVIGATION_BUTTONS },
async function (browser) {
const onPopupShown = waitForPopupShown();
info("Update identified credit card fields");
// We don't submit the form
await focusUpdateSubmitForm(
browser,
{
focusSelector: "#cc-name",
newValues: CC_VALUES,
},
false
);
info("Change window location");
await SpecialPowers.spawn(browser, [], () => {
const windowLocationButton =
content.document.getElementById("windowLocation");
windowLocationButton.click();
});
info("Wait for credit card doorhanger");
await onPopupShown;
ok(true, "Credit card doorhanger is shown");
}
);
}
);
|