diff options
Diffstat (limited to 'layout/style/test/test_style_attr_listener.html')
-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> |