Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'linux' && ccov OR os == 'android'
- Manifest: browser/extensions/formautofill/test/unit/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
"use strict";
const { FormAutofillChild } = ChromeUtils.importESModule(
"resource://autofill/FormAutofillChild.sys.mjs"
);
add_task(async function test_inspectFields() {
const doc = MockDocument.createTestDocument(
`<form>
<input id="cc-number" autocomplete="cc-number">
<input id="cc-name" autocomplete="cc-name">
<input id="cc-exp" autocomplete="cc-exp">
</form>
<select id="cc-type" autocomplete="cc-type">
<option/>
<option value="visa">VISA</option>
</select>
<form>
<input id="name" autocomplete="name">
<select id="country" autocomplete="country">
<option/>
<option value="US">United States</option>
</select>
</form>
<input id="email" autocomplete="email">
<input id="unknown" autocomplete="unknown">
`
);
const fac = new FormAutofillChild();
Object.defineProperty(fac, "document", {
value: doc,
});
const fields = fac.inspectFields();
const expectedElements = Array.from(doc.querySelectorAll("input, select"));
const inspectedElements = fields.map(field => field.element);
Assert.deepEqual(
expectedElements,
inspectedElements,
"inspectedElements should return all the eligible fields"
);
});