diff -r 000000000000 -r 6474c204b198 toolkit/components/passwordmgr/test/pwmgr_common.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolkit/components/passwordmgr/test/pwmgr_common.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,223 @@ +/* + * $_ + * + * Returns the element with the specified |name| attribute. + */ +function $_(formNum, name) { + var form = document.getElementById("form" + formNum); + if (!form) { + logWarning("$_ couldn't find requested form " + formNum); + return null; + } + + var element = form.elements.namedItem(name); + if (!element) { + logWarning("$_ couldn't find requested element " + name); + return null; + } + + // Note that namedItem is a bit stupid, and will prefer an + // |id| attribute over a |name| attribute when looking for + // the element. Login Mananger happens to use .namedItem + // anyway, but let's rigorously check it here anyway so + // that we don't end up with tests that mistakenly pass. + + if (element.getAttribute("name") != name) { + logWarning("$_ got confused."); + return null; + } + + return element; +} + + +/* + * checkForm + * + * Check a form for expected values. If an argument is null, a field's + * expected value will be the default value. + * + *