forked from mirrors/gecko-dev
--HG-- rename : browser/extensions/formautofill/bootstrap.js => browser/extensions/formautofill/api.js rename : browser/extensions/formautofill/install.rdf.in => browser/extensions/formautofill/manifest.json rename : browser/extensions/formautofill/skin/shared/autocomplete-item.css => browser/extensions/formautofill/skin/shared/autocomplete-item-shared.css rename : browser/extensions/formautofill/skin/shared/editDialog.css => browser/extensions/formautofill/skin/shared/editDialog-shared.css extra : rebase_source : 233ea805630209a07d347e19f19710d9755f595f extra : source : ecda6532c852b3f225fce998e3ce83ad157760e6
69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
"use strict";
|
|
|
|
add_task(async function() {
|
|
ChromeUtils.import("resource://formautofill/FormAutofillHeuristics.jsm");
|
|
});
|
|
|
|
const TESTCASES = [
|
|
{
|
|
description: "A label element contains one input element.",
|
|
document: `<label id="typeA"> label type A
|
|
<!-- This comment should not be extracted. -->
|
|
<input type="text">
|
|
<script>FOO</script>
|
|
<noscript>FOO</noscript>
|
|
<option>FOO</option>
|
|
<style>FOO</style>
|
|
</label>`,
|
|
inputId: "typeA",
|
|
expectedStrings: ["label type A"],
|
|
},
|
|
{
|
|
description: "A label element with inner div contains one input element.",
|
|
document: `<label id="typeB"> label type B
|
|
<!-- This comment should not be extracted. -->
|
|
<script>FOO</script>
|
|
<noscript>FOO</noscript>
|
|
<option>FOO</option>
|
|
<style>FOO</style>
|
|
<div> inner div
|
|
<input type="text">
|
|
</div>
|
|
</label>`,
|
|
inputId: "typeB",
|
|
expectedStrings: ["label type B", "inner div"],
|
|
},
|
|
{
|
|
description: "A label element with inner prefix/postfix strings contains span elements.",
|
|
document: `<label id="typeC"> label type C
|
|
<!-- This comment should not be extracted. -->
|
|
<script>FOO</script>
|
|
<noscript>FOO</noscript>
|
|
<option>FOO</option>
|
|
<style>FOO</style>
|
|
<div> inner div prefix
|
|
<span>test C-1 </span>
|
|
<span> test C-2</span>
|
|
inner div postfix
|
|
</div>
|
|
</label>`,
|
|
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);
|
|
});
|
|
});
|