<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
// Test for WebKit Bug 15136 - HTML5 spec violation: </h1> doesn't end <h3> element in Webkit
// https://bugs.webkit.org/show_bug.cgi?id=15136
// rdar://problem/5762882
description('Test that any numbered header element end tag can close any other open numbered header element.');
var testParent = document.createElement('div');
testParent.id = 'test0';
document.body.appendChild(testParent);
// h1
debug('<h1> closes <h1>:');
testParent.innerHTML = '<h1 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h1.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h2> closes <h1>:');
testParent.innerHTML = '<h1 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h1.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h3> closes <h1>:');
testParent.innerHTML = '<h1 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h1.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h4> closes <h1>:');
testParent.innerHTML = '<h1 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h1.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h5> closes <h1>:');
testParent.innerHTML = '<h1 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h1.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h6> closes <h1>:');
testParent.innerHTML = '<h1 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h1.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
// h2
debug('<h1> closes <h2>:');
testParent.innerHTML = '<h2 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h2.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h2> closes <h2>:');
testParent.innerHTML = '<h2 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h2.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h3> closes <h2>:');
testParent.innerHTML = '<h2 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h2.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h4> closes <h2>:');
testParent.innerHTML = '<h2 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h2.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h5> closes <h2>:');
testParent.innerHTML = '<h2 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h2.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h6> closes <h2>:');
testParent.innerHTML = '<h2 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h2.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
// h3
debug('<h1> closes <h3>:');
testParent.innerHTML = '<h3 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h3.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h2> closes <h3>:');
testParent.innerHTML = '<h3 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h3.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h3> closes <h3>:');
testParent.innerHTML = '<h3 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h3.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h4> closes <h3>:');
testParent.innerHTML = '<h3 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h3.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h5> closes <h3>:');
testParent.innerHTML = '<h3 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h3.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h6> closes <h3>:');
testParent.innerHTML = '<h3 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h3.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
// h4
debug('<h1> closes <h4>:');
testParent.innerHTML = '<h4 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h4.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h2> closes <h4>:');
testParent.innerHTML = '<h4 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h4.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h3> closes <h4>:');
testParent.innerHTML = '<h4 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h4.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h4> closes <h4>:');
testParent.innerHTML = '<h4 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h4.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h5> closes <h4>:');
testParent.innerHTML = '<h4 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h4.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h6> closes <h4>:');
testParent.innerHTML = '<h4 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h4.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
// h5
debug('<h1> closes <h5>:');
testParent.innerHTML = '<h5 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h5.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h2> closes <h5>:');
testParent.innerHTML = '<h5 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h5.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h3> closes <h5>:');
testParent.innerHTML = '<h5 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h5.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h4> closes <h5>:');
testParent.innerHTML = '<h5 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h5.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h5> closes <h5>:');
testParent.innerHTML = '<h5 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h5.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h6> closes <h5>:');
testParent.innerHTML = '<h5 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h5.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
// h6
debug('<h1> closes <h6>:');
testParent.innerHTML = '<h6 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h6.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h2> closes <h6>:');
testParent.innerHTML = '<h6 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h6.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h3> closes <h6>:');
testParent.innerHTML = '<h6 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h6.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h4> closes <h6>:');
testParent.innerHTML = '<h6 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h6.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h5> closes <h6>:');
testParent.innerHTML = '<h6 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h6.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
debug('<h6> closes <h6>:');
testParent.innerHTML = '<h6 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h6.</p>';
var h1 = document.getElementById('test2');
shouldBeFalse('test2.parentNode.id == "test1"');
shouldBeTrue('test2.parentNode.id == "test0"');
document.body.removeChild(testParent);
</script>
</body>
</html>