blob: 41a876c4986f03ae70588c1213e215c0c13eb02c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("This test checks the form attribute of the legend element.");
var container = document.createElement('div');
document.body.appendChild(container);
debug('');
debug('- Ensures that the form attribute of legend element depends on whether its parent is a fieldset element or not.');
container.innerHTML = '<form id=owner>' +
' <fieldset><legend id=legendElement1 name=victim /></fieldset>' +
' <legend id=legendElement2 name=victim />' +
' <fieldset><div><legend id=legendElement3 name=victim /></div></fieldset>' +
'</form>';
owner = document.getElementById('owner');
var legendElement1 = document.getElementById('legendElement1');
var legendElement2 = document.getElementById('legendElement2');
shouldBe('legendElement1.form', 'owner');
shouldBe('legendElement2.form', 'null');
shouldBe('legendElement3.form', 'null');
debug('');
debug('- Ensures that the legend\'s form attribute points its parent fieldset\'s form owner even if the element is within another form element.');
container.innerHTML = '<form id=owner></form>' +
'<form id=shouldNotBeOwner>' +
' <fieldset id=fieldsetElement name=victim form=owner>' +
' <legend id=legendElement name=victim />' +
' </fieldset>' +
'</form>';
owner = document.getElementById('owner');
var inputElement = document.getElementById('fieldsetElement');
var labelElement = document.getElementById('legendElement');
shouldBe('fieldsetElement.form', 'owner');
shouldBe('legendElement.form', 'owner');
debug('');
debug('- Ensures whether the form owner is set correctly for the legend when the value of form attribute of its parent fieldset changed.');
container.innerHTML = '<form id=form1></form>' +
'<form id=form2></form>' +
'<fieldset id=fieldsetElement name=victim form=form1>' +
' <legend id=legendElement />' +
'</fieldset>';
var form1 = document.getElementById('form1');
var form2 = document.getElementById('form2');
fieldsetElement = document.getElementById('fieldsetElement');
legendElement = document.getElementById('legendElement');
shouldBe('fieldsetElement.form', 'form1');
shouldBe('legendElement.form', 'form1');
fieldsetElement.attributes['form'].value = 'form2';
shouldBe('fieldsetElement.form', 'form2');
shouldBe('legendElement.form', 'form2');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>