/* Any copyright is dedicated to the Public Domain. https://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; const { FormAutofillChild } = ChromeUtils.importESModule( "resource://autofill/FormAutofillChild.sys.mjs" ); add_task(async function test_inspectFields() { const doc = MockDocument.createTestDocument( "http://localhost:8080/test/", `
` ); const fac = new FormAutofillChild(); sinon.stub(fac, "document").get(() => { return doc; }); sinon.stub(fac, "browsingContext").get(() => { return {}; }); 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" ); sinon.restore(); });