<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("Test the behavior of CSSStyleDeclaration.setProperty()");

var div = document.createElement("div");
debug("* Not enough parameters");
shouldThrow("div.style.setProperty()");
shouldThrow("div.style.setProperty('color')");

debug("");
debug("* Should treat null as empty string for 'value' parameter");
shouldNotThrow("div.style.setProperty('color', null)");
shouldBeEqualToString("div.style.getPropertyValue('color')", "");
shouldBeEqualToString("div.style.getPropertyPriority('color')", "");

debug("");
debug("* Should treat null as empty string for 'priority' parameter");
shouldNotThrow("div.style.setProperty('background-color', 'green', null)");
shouldBeEqualToString("div.style.getPropertyValue('background-color')", "green");
shouldBeEqualToString("div.style.getPropertyPriority('background-color')", "");

debug("");
debug("* Last parameter should do a case-insensitive match to 'important'");
shouldNotThrow("div.style.setProperty('border-left-color', 'green', 'important')");
shouldBeEqualToString("div.style.getPropertyValue('border-left-color')", "green");
shouldBeEqualToString("div.style.getPropertyPriority('border-left-color')", "important");
shouldNotThrow("div.style.setProperty('border-right-color', 'green', 'IMPORTANT')");
shouldBeEqualToString("div.style.getPropertyValue('border-right-color')", "green");
shouldBeEqualToString("div.style.getPropertyPriority('border-right-color')", "important");

debug("");
debug("* Invalid 'priority' value, should abort");
shouldNotThrow("div.style.setProperty('border-top-color', 'red', 'invalid')");
shouldBeEqualToString("div.style.getPropertyValue('border-top-color')", "");
shouldBeEqualToString("div.style.getPropertyPriority('border-top-color')", "");
shouldNotThrow("div.style.setProperty('border-top-color', 'red', 'important invalid')");
shouldBeEqualToString("div.style.getPropertyValue('border-top-color')", "");
shouldBeEqualToString("div.style.getPropertyPriority('border-top-color')", "");
shouldNotThrow("div.style.setProperty('border-top-color', 'red', '!important')");
shouldBeEqualToString("div.style.getPropertyValue('border-top-color')", "");
shouldBeEqualToString("div.style.getPropertyPriority('border-top-color')", "");

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
