<!DOCTYPE html>
<html>
<body>
<form>
<label id="label1" for="input">label1</label>
<label id="label2" for="input">label2</label>
<input id="input" type="text">
</form>
<script src="../../../resources/js-test.js"></script>
<script>
var form = document.querySelector('form');
var input = document.querySelector('input');
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
var labels, label0, label1;
description("This tests moving a node with labels property from one document to another.\n"
+ "The labels node list should be updated when labels are modified in the new document.")
debug('The input element initially have two label elements #label1 and #label2.');
shouldBe("labels = input.labels; labels.length", "2");
shouldBe("label0 = labels[0]; label1 = labels[1]; iframe.contentDocument.body.appendChild(form); labels.length; label1.parentNode.removeChild(label1); labels.length", "1");
shouldBe("labels[0]", "label0");
shouldBe("label0.parentNode.appendChild(label1); labels.length", "2");
shouldBe("labels[0]", "label0");
shouldBe("labels[1]", "label1");
form.style.display = 'none';
var successfullyParsed = true;
</script>
</body>
</html>