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 /layout/style/test/test_style_attr_listener.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.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 '')
-rw-r--r-- | layout/style/test/test_style_attr_listener.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/layout/style/test/test_style_attr_listener.html b/layout/style/test/test_style_attr_listener.html new file mode 100644 index 0000000000..b824fe7ff4 --- /dev/null +++ b/layout/style/test/test_style_attr_listener.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<html> +<head> + <title>Test for Bug 338679 (from bug 1340341)</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<div style=""></div> +<script> +SimpleTest.waitForExplicitFinish(); + +// Run the test first with mutation events enabled and then disabled. +SpecialPowers.pushPrefEnv( + { 'set': [['dom.mutation-events.cssom.disabled', false]] }, + runTest +); + +function runTest(stop) { + let div = document.querySelector('div'); + let expectation; + let count = 0; + div.style.color = "red"; + div.addEventListener('DOMAttrModified', function(evt) { + count++; + is(evt.prevValue, expectation.prevValue, `Previous value for event ${count}`); + is(evt.newValue, expectation.newValue, `New value for event ${count}`); + }); + expectation = { prevValue: 'color: red;', newValue: 'color: green;' }; + div.style.color = "green"; + expectation = { prevValue: 'color: green;', newValue: '' }; + div.style.color = ''; + if (SpecialPowers.getBoolPref("dom.mutation-events.cssom.disabled")) { + is(count, 0, "No DOMAttrModified event should be triggered"); + } else { + is(count, 2, "DOMAttrModified events should have been triggered"); + } + + if (!stop) { + div.setAttribute("style", ""); + SpecialPowers.pushPrefEnv( + { 'set': [['dom.mutation-events.cssom.disabled', true]] }, + function() { + runTest(true); + SimpleTest.finish(); + } + ); + } +} +</script> +</body> +</html> |