<html>
<head>
<link rel="stylesheet" href="resources/detached-style.css" type="text/css" media="screen">
<style>* { }</style>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p><a href="https://bugs.webkit.org/show_bug.cgi?id=45205">Bug 45205</a>:
Test that <link> elements only have stylesheets when in document.</p>
<div id="console"></div>
<script>
debug("Testing <link>...");
sheet = document.styleSheets[0];
head = document.getElementsByTagName("head")[0];
link = document.getElementsByTagName("link")[0];
shouldBe('sheet.ownerNode', 'link')
shouldBe('link.sheet === sheet', 'true')
debug("Removing <link>...");
head.removeChild(link);
shouldBe('link.sheet', 'null')
shouldBe('sheet.ownerNode', 'null')
shouldBe('sheet.cssRules[0].cssText[0]', '"*"')
debug("Re-adding <link>...");
head.appendChild(link);
shouldBe('sheet.ownerNode', 'null')
shouldBe('link.sheet === sheet', 'false')
shouldBe('link.sheet.ownerNode', 'link')
debug("Testing <style>...");
sheet = document.styleSheets[0];
head = document.getElementsByTagName("head")[0];
style = document.getElementsByTagName("style")[0];
shouldBe('sheet.ownerNode', 'style')
shouldBe('style.sheet', 'sheet')
debug("Removing <style>...");
head.removeChild(style);
shouldBe('style.sheet', 'null')
shouldBe('sheet.ownerNode', 'null')
shouldBe('sheet.cssRules[0].cssText[0]', '"*"')
debug("Re-adding <style>...");
head.appendChild(style);
shouldBe('sheet.ownerNode', 'null')
shouldBe('style.sheet === sheet', 'false')
shouldBe('style.sheet.ownerNode', 'style')
</script>
</body>
</html>