function checkFormIDLAttribute(aElement)
{
is('form' in aElement, false, " shouldn't have a form attribute");
}
function checkAttribute(aElement, aAttribute, aNewValue, aExpectedValueForIDL)
{ var expectedValueForIDL = aNewValue; var expectedValueForContent = String(aNewValue);
if (aExpectedValueForIDL !== undefined) {
expectedValueForIDL = aExpectedValueForIDL;
}
if (aNewValue != null) {
aElement.setAttribute(aAttribute, aNewValue);
is(aElement.getAttribute(aAttribute), expectedValueForContent,
aAttribute + " content attribute should be " + expectedValueForContent);
is(aElement[aAttribute], expectedValueForIDL,
aAttribute + " IDL attribute should be " + expectedValueForIDL);
if (parseFloat(aNewValue) == aNewValue) {
aElement[aAttribute] = aNewValue;
is(aElement.getAttribute(aAttribute), expectedValueForContent,
aAttribute + " content attribute should be " + expectedValueForContent);
is(aElement[aAttribute], parseFloat(expectedValueForIDL),
aAttribute + " IDL attribute should be " + parseFloat(expectedValueForIDL));
}
} else {
aElement.removeAttribute(aAttribute);
is(aElement.getAttribute(aAttribute), null,
aAttribute + " content attribute should be null");
is(aElement[aAttribute], expectedValueForIDL,
aAttribute + " IDL attribute should be " + expectedValueForIDL);
}
}
function checkValueAttribute()
{ var tests = [
// value has to be a valid float, its default value is 0.0 otherwise.
[ null, 0.0 ],
[ 'foo', 0.0 ],
// If value < 0.0, 0.0 is used instead.
[ -1.0, 0.0 ],
// If value >= max, max is used instead (max default value is 1.0).
[ 2.0, 1.0 ],
[ 1.0, 0.5, 0.5 ],
[ 10.0, 5.0, 5.0 ],
[ 13.37, 13.37, 42.0 ],
// If value <= min, min is used instead (min default value is 0.0).
[ 0.5, 1.0, 10.0 ,1.0 ],
[ 10.0, 13.37, 42.0 , 13.37],
// Regular reflection.
[ 0.0 ],
[ 0.5 ],
[ 1.0 ],
// Check double-precision value.
[ 0.234567898765432 ],
];
var element = document.createElement('meter');
for (var test of tests) {
if (test[2]) {
element.setAttribute('max', test[2]);
}
if (test[3]) {
element.setAttribute('min', test[3]);
}
function checkNotResetableAndFormSubmission(aElement)
{
// Creating an input element to check the submission worked. varform = document.forms[0]; varinput = document.createElement('input');
document.getElementsByName('submit_frame')[0].addEventListener("load", function() {
is(frames.submit_frame.location.href,
`${location.origin}/tests/dom/html/test/forms/foo?a=tulip`, "The meter element value should not be submitted");
checkNotResetable();
}, {once: true});
form.submit();
}
function checkNotResetable()
{
// Try to reset the form. varform = document.forms[0]; var element = document.getElementById('m');
element.value = 3.0;
element.max = 42.0;
form.reset();
SimpleTest.executeSoon(function() {
is(element.value, 3.0, "meter.value should not have changed");
is(element.max, 42.0, "meter.max should not have changed");
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();
var m = document.getElementById('m');
ok(m instanceof HTMLMeterElement, "The meter element should be instance of HTMLMeterElement");
is(m.constructor, HTMLMeterElement, "The meter element constructor should be HTMLMeterElement");
// There is no such attribute.
checkFormIDLAttribute(m);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.