<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<p><a href=https://bugs.webkit.org/show_bug.cgi?id=99493>Bug 99493</a></p>
<div id="console"></div>
<script>
description("Test the parsing of the cursor property when used with image-set and -webkit-image-set.");
function makeCursorRule(rule)
{
return `cursor: ${rule};`;
}
function testCursorRule(rule, expected)
{
const cssText = makeCursorRule(rule);
const expectedCssText = expected ? makeCursorRule(expected) : cssText;
shouldBeEqualToString('roundtripCssRule(`' + cssText + '`)', expectedCssText);
}
function testCursorRules(rule)
{
testCursorRule(rule);
// The '-webkit-' prefixed 'image-set' is expected to serialize to the same
// value as standard 'image-set'.
// https://drafts.csswg.org/css-images-4/#deprecated
// "Implementations must accept -webkit-image-set() as a parse-time alias of
// image-set(). (It’s a valid value, with identical arguments to image-set(),
// and is turned into image-set() during parsing.)"
testCursorRule(`-webkit-${rule}`, rule);
}
function roundtripCssRule(cssText)
{
const div = document.createElement("div");
div.setAttribute("style", cssText);
document.body.appendChild(div);
const result = div.style.cssText;
document.body.removeChild(div);
return result;
}
// Note that any absolute URL will suffice for these tests (can't use relative URLs
// since they'll be converted to absolute form in the output). I chose file URLs just
// to avoid triggering any network activity.
debug('Test a bunch of cursor rules which should round-trip exactly.');
testCursorRules('image-set(url("file:///foo.png") 1x), auto');
testCursorRules('image-set(url("file:///foo.png") 1x, url("file:///foo2x.png") 2x), auto');
testCursorRules('image-set(url("file:///foo.png") 1x, url("file:///foo2x.png") 2x) 2 3, auto');
testCursorRules('image-set(url("file:///foo03.png") 0.3x, url("file:///foo5x.png") 5x) 6 5, url("file:///foo.png") 12 3, pointer');
successfullyParsed = true;
</script>
</body>
</html>