mirror of
https://github.com/servo/servo
synced 2026-04-29 02:47:55 +02:00
Update CSS tests to revision 2baa72daab8bf37e3e910a9fd311a1eaa5b0f4a8
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
||||
<title>CSSOM - Extensions to the Document Interface: StyleSheetList length reflects dynamically loaded and unloaded sheets</title>
|
||||
<link href="mailto:jesse@codeforamerica.org" rel="author" title="Jesse Bounds" />
|
||||
<link href="http://www.w3.org/TR/cssom/#extensions-to-the-document-interface" rel="help" />
|
||||
<link href="http://www.w3.org/TR/cssom/#the-stylesheetlist-sequence" rel="help" />
|
||||
<link href="http://www.w3.org/TR/cssom/#style-sheet-collections" rel="help" />
|
||||
<link href="stylesheet.css" type="text/css" rel="stylesheet" />
|
||||
<meta content="dom" name="flags" />
|
||||
<meta content="The styleSheets length attribute must reflect the number of sheets at page load and after dynamically" name="assert" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script id="metadata_cache">/*
|
||||
{
|
||||
"stylesheet.css should be loaded and styleSheets.length === 1": {},
|
||||
"stylesheet.css should be unloaded and styleSheets.length === 0": {},
|
||||
"stylesheet-1.css should be loaded and styleSheets.length === 1": {}
|
||||
}
|
||||
*/</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
|
||||
// Get the Document's styleSheets attribute
|
||||
var styleSheets = document.styleSheets;
|
||||
|
||||
// Verify that the styleSheets list length is 1 due to "stylesheet.css" loaded in head section
|
||||
test(function() {
|
||||
assert_equals(styleSheets.length, 1, "styleSheets.length is incorrect:");
|
||||
}, "stylesheet.css should be loaded and styleSheets.length === 1");
|
||||
|
||||
// Verify that the styleSheets list length is 0 after removing the loaded sheet from the DOM
|
||||
test(function() {
|
||||
|
||||
// get the one and only sheet loaded
|
||||
var sheet = styleSheets.item(0);
|
||||
|
||||
// remove the sheet from the DOM
|
||||
sheet.ownerNode.parentNode.removeChild(sheet.ownerNode)
|
||||
|
||||
// assert that there are 0 styleSheets in the styleSheets property
|
||||
assert_equals(styleSheets.length, 0, "styleSheets.length is incorrect:");
|
||||
|
||||
}, "stylesheet.css should be unloaded and styleSheets.length === 0");
|
||||
|
||||
// Verify that the styleSheets list length is back to 1 after loading a new sheet
|
||||
test(function() {
|
||||
|
||||
// create a css file reference
|
||||
var fileReference = document.createElement("link");
|
||||
fileReference.setAttribute("rel", "stylesheet");
|
||||
fileReference.setAttribute("type", "text/css");
|
||||
fileReference.setAttribute("href", "stylesheet-1.css");
|
||||
|
||||
// load the css file reference into the head section
|
||||
var head = document.getElementsByTagName("HEAD")[0];
|
||||
head.appendChild(fileReference);
|
||||
|
||||
// assert that there is 1 styleSheet in the styleSheets property
|
||||
assert_equals(styleSheets.length, 1, "styleSheets.length is incorrect:");
|
||||
|
||||
}, "stylesheet-1.css should be loaded and styleSheets.length === 1");
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body></html>
|
||||
Reference in New Issue
Block a user