diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/css/cssom/ttwf-cssom-doc-ext-load-count.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/cssom/ttwf-cssom-doc-ext-load-count.html')
-rw-r--r-- | testing/web-platform/tests/css/cssom/ttwf-cssom-doc-ext-load-count.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/cssom/ttwf-cssom-doc-ext-load-count.html b/testing/web-platform/tests/css/cssom/ttwf-cssom-doc-ext-load-count.html new file mode 100644 index 0000000000..5c2b9e6f46 --- /dev/null +++ b/testing/web-platform/tests/css/cssom/ttwf-cssom-doc-ext-load-count.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<html> +<head> + <title>CSSOM - Extensions to the Document Interface: StyleSheetList length reflects dynamically loaded and unloaded sheets</title> + <link rel="author" title="Jesse Bounds" href="mailto:jesse@codeforamerica.org"> + <link rel="help" href="http://www.w3.org/TR/cssom-1/#extensions-to-the-document-interface"> + <link rel="help" href="http://www.w3.org/TR/cssom-1/#the-stylesheetlist-interface"> + <link rel="help" href="http://www.w3.org/TR/cssom-1/#css-style-sheet-collections"> + <link rel="stylesheet" href="stylesheet.css" type="text/css"> + <meta name="flags" content="dom"> + <meta name="assert" content="The styleSheets length attribute must reflect the number of sheets at page load and after dynamically"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></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 + async_test(function(t) { + + // 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"); + fileReference.onerror = t.step_func_done(function() { + // assert that there is 1 styleSheet in the styleSheets property + assert_equals(styleSheets.length, 1, "styleSheets.length is incorrect:"); + }); + + // load the css file reference into the head section + var head = document.getElementsByTagName("HEAD")[0]; + head.appendChild(fileReference); + }, "stylesheet-1.css should be loaded and styleSheets.length === 1"); + + </script> +</body> +</html> |