"use strict"; var LabelUtils; add_task(async function() { ({ LabelUtils } = ChromeUtils.import( "resource://autofill/FormAutofillUtils.jsm" )); }); const TESTCASES = [ { description: "A label element contains one input element.", document: ``, inputId: "typeA", expectedStrings: ["label type A"], }, { description: "A label element with inner div contains one input element.", document: ``, inputId: "typeB", expectedStrings: ["label type B", "inner div"], }, { description: "A label element with inner prefix/postfix strings contains span elements.", document: ``, inputId: "typeC", expectedStrings: [ "label type C", "inner div prefix", "test C-1", "test C-2", "inner div postfix", ], }, ]; TESTCASES.forEach(testcase => { add_task(async function() { info("Starting testcase: " + testcase.description); LabelUtils._labelStrings = new WeakMap(); let doc = MockDocument.createTestDocument( "http://localhost:8080/test/", testcase.document ); let element = doc.getElementById(testcase.inputId); let strings = LabelUtils.extractLabelStrings(element); Assert.deepEqual(strings, testcase.expectedStrings); }); });