gecko-dev/testing/web-platform/tests/css/support/parsing-testcommon.js
Eric Willigers 5023aeca00 Bug 1504943 [wpt PR 13943] - [svg] Parsing of the pointer-events CSS property, a=testonly
Automatic update from web-platform-tests[svg] Parsing of the pointer-events CSS property (#13943)

https://svgwg.org/svg2-draft/interact.html#PointerEventsProperty
--

wpt-commits: 251c99611691c1afe416f12dcf34d30bfacadeed
wpt-pr: 13943
2018-11-14 13:38:00 +00:00

38 lines
1.6 KiB
JavaScript

'use strict';
// serializedValue can be the expected serialization of value,
// or an array of permitted serializations,
// or omitted if value should serialize as value.
function test_valid_value(property, value, serializedValue) {
if (arguments.length < 3)
serializedValue = value;
var stringifiedValue = JSON.stringify(value);
test(function(){
var div = document.getElementById('target') || document.createElement('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') || document.createElement('div');
div.style[property] = "";
div.style[property] = value;
assert_equals(div.style.getPropertyValue(property), "");
}, "e.style['" + property + "'] = " + stringifiedValue + " should not set the property value");
}