'use strict'; function test_valid_value(property, value, serializedValue){ if (_AN_Read_length('length', arguments) < 3) serializedValue = value; var stringifiedValue = JSON.stringify(value); test(function (){ var div = document.getElementById('target') || _AN_Call_createelement('createElement', document, 'div'); div.style[property] = ""; div.style[property] = value; var readValue = div.style.getPropertyValue(property); assert_not_equals(readValue, "", "property should be set"); if (Array.isArray(serializedValue)) assert_in_array(readValue, serializedValue, "serialization should be sound"); else assert_equals(readValue, serializedValue, "serialization should be canonical"); div.style[property] = readValue; assert_equals(div.style.getPropertyValue(property), readValue, "serialization should round-trip"); } , "e.style['" + property + "'] = " + stringifiedValue + " should set the property value"); } function test_invalid_value(property, value){ var stringifiedValue = JSON.stringify(value); test(function (){ var div = document.getElementById('target') || _AN_Call_createelement('createElement', document, 'div'); div.style[property] = ""; div.style[property] = value; assert_equals(div.style.getPropertyValue(property), ""); } , "e.style['" + property + "'] = " + stringifiedValue + " should not set the property value"); }