<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test the parsing of the cursor property.");

var style;

function makeCursorRule(rule)
{
    return "cursor: " + rule + ";";
}

function testCursorRule(rule)
{
    var cssText = makeCursorRule(rule);
    style = roundtripCssRule(cssText);
    shouldBeEqualToString('style.cssText', cssText);
}

function testInvalidCursorRule(rule)
{
    shouldBeEqualToString('roundtripCssRule("' + makeCursorRule(rule) + '").cssText', '');
}

function roundtripCssRule(cssText)
{
    var div = document.createElement("div");
    div.setAttribute("style", cssText);
    document.body.appendChild(div);
    var result = div.style;
    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.');

testCursorRule('auto');
testCursorRule('default');
testCursorRule('none');
testCursorRule('context-menu');
testCursorRule('help');
testCursorRule('pointer');
testCursorRule('progress');
testCursorRule('wait');
testCursorRule('cell');
testCursorRule('crosshair');
testCursorRule('text');
testCursorRule('vertical-text');
testCursorRule('alias');
testCursorRule('copy');
testCursorRule('move');
testCursorRule('no-drop');
testCursorRule('not-allowed');
testCursorRule('grab');
testCursorRule('grabbing');
testCursorRule('e-resize');
testCursorRule('n-resize');
testCursorRule('ne-resize');
testCursorRule('nw-resize');
testCursorRule('s-resize');
testCursorRule('se-resize');
testCursorRule('sw-resize');
testCursorRule('w-resize');
testCursorRule('ew-resize');
testCursorRule('ns-resize');
testCursorRule('nesw-resize');
testCursorRule('nwse-resize');
testCursorRule('col-resize');
testCursorRule('row-resize');
testCursorRule('all-scroll');
testCursorRule('zoom-in');
testCursorRule('zoom-out');
testCursorRule('-webkit-grab');
testCursorRule('-webkit-grabbing');
testCursorRule('-webkit-zoom-in');
testCursorRule('-webkit-zoom-out');

testCursorRule('url("file:///foo.png"), crosshair');
testCursorRule('url("file:///foo.png"), url("file:///foo2.png"), pointer');
testCursorRule('url("file:///foo.png") 12 3, pointer');
testCursorRule('url("file:///foo.png") 0 0, pointer');
testCursorRule('url("file:///foo.png") 12 3, url("file:///foo2.png"), url("file:///foo3.png") 6 7, crosshair');
testCursorRule('url("file:///foo.png") -2 3, pointer');
testCursorRule('url("file:///foo.png") 2 -3, pointer');
testCursorRule('url("file:///foo.png") -1 -1, pointer');

debug('');
debug('Test a bunch of invalid cursor rules which shouldn\'t parse at all.');
testInvalidCursorRule('nonexistent');
testInvalidCursorRule('ltr');
testInvalidCursorRule('inline');
testInvalidCursorRule('url(file:///foo.png), url(file:///foo2.png)');
testInvalidCursorRule('url(file:///foo.png) 12');
testInvalidCursorRule('url(file:///foo.png) 12 3 5');
testInvalidCursorRule('url(file:///foo.png) x y');
testInvalidCursorRule('url(file:///foo.png) auto');

debug('');
debug('Test a bunch of cursor rules with generated images.');
testInvalidCursorRule('linear-gradient(red, white) -1 -1, pointer');
testInvalidCursorRule('image-set(linear-gradient(red, white) 1x) -1 -1, pointer');

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