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 /devtools/server/tests/chrome/test_css-logic.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 'devtools/server/tests/chrome/test_css-logic.html')
-rw-r--r-- | devtools/server/tests/chrome/test_css-logic.html | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/devtools/server/tests/chrome/test_css-logic.html b/devtools/server/tests/chrome/test_css-logic.html new file mode 100644 index 0000000000..6378f5a9e7 --- /dev/null +++ b/devtools/server/tests/chrome/test_css-logic.html @@ -0,0 +1,73 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id= +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug </title> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> + <script type="application/javascript" src="inspector-helpers.js"></script> + <script type="application/javascript"> +"use strict"; + +const {CssLogic} = require("devtools/server/actors/inspector/css-logic"); + +window.onload = function() { + SimpleTest.waitForExplicitFinish(); + runNextTest(); +}; + +addTest(function getComputedStyle() { + const node = document.querySelector("#computed-style"); + is(CssLogic.getComputedStyle(node).getPropertyValue("width"), + "50px", "Computed style on a normal node works (width)"); + is(CssLogic.getComputedStyle(node).getPropertyValue("height"), + "10px", "Computed style on a normal node works (height)"); + + const firstChild = new _documentWalker(node, window).firstChild(); + is(CssLogic.getComputedStyle(firstChild).getPropertyValue("content"), + "\"before\"", "Computed style on a ::before node works (content)"); + const lastChild = new _documentWalker(node, window).lastChild(); + is(CssLogic.getComputedStyle(lastChild).getPropertyValue("content"), + "\"after\"", "Computed style on a ::after node works (content)"); + + runNextTest(); +}); + +addTest(function getBindingElementAndPseudo() { + const node = document.querySelector("#computed-style"); + let {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node); + + is(bindingElement, node, + "Binding element is the node itself for a normal node"); + ok(!pseudo, "Pseudo is null for a normal node"); + + const firstChild = new _documentWalker(node, window).firstChild(); + ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(firstChild)); + is(bindingElement, node, + "Binding element is the parent for a pseudo node"); + is(pseudo, "::before", "Pseudo is correct for a ::before node"); + + const lastChild = new _documentWalker(node, window).lastChild(); + ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(lastChild)); + is(bindingElement, node, + "Binding element is the parent for a pseudo node"); + is(pseudo, "::after", "Pseudo is correct for a ::after node"); + + runNextTest(); +}); + + </script> +</head> +<body> + <style type="text/css"> + #computed-style { width: 50px; height: 10px; } + #computed-style::before { content: "before"; } + #computed-style::after { content: "after"; } + </style> + <div id="computed-style"></div> +</body> +</html> |