4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"../js/resources/image-preload-helper.js"></script>
6 <style type=
"text/css">
10 <p id=
"description"></p>
11 <p><a href=https://bugs.webkit.org/show_bug.cgi?id=
100550>Bug
100550</a></p>
12 <svg xmlns=
"http://www.w3.org/2000/svg"
13 xmlns:
xlink=
"http://www.w3.org/1999/xlink" width=
"0" height=
"0">
15 <cursor id=
"greenbox" xlink:
href=
"resources/greenbox.png" x=
"0" y=
"0"/>
18 <div id=
"test-container">
19 <div>Implicit default cursor
</div>
20 <div style='cursor: default'
>Explicit default
</div>
21 <div style='cursor: auto'
>Explicit auto
</div>
22 <div style='cursor: none'
>No cursor
</div>
23 <div style='cursor: pointer'
>Pointer
</div>
24 <div style='cursor: -webkit-grabbing'
>-webkit-grabbing
</div>
25 <div style='cursor: url(resources/greenbox.png), hand'
>Existing
25x25 image
</div>
26 <div style='cursor: url(doesntexist_FAIL.png), pointer'
>Invalid URL with fallback to pointer
</div>
27 <div style='cursor: url(doesntexist_FAIL.png), url(resources/greenbox.png), pointer'
>Invalid with fallback to
25x25 image
</div>
28 <div style='cursor: url(resources/greenbox.png)
0 0, pointer'
>Image with explicit hot spot at (
0,
0)
</div>
29 <div style='cursor: url(resources/greenbox.png)
20 10, pointer'
>Image with explicit hot spot at (
20,
10)
</div>
30 <div style='cursor: url(resources/greenbox.png) -
1 -
1, pointer'
>Image with explicit hot spot at (-
1,-
1)
</div>
31 <div style='cursor: url(resources/greenbox.png)
30 30, pointer'
>Image with explicit hot spot outside image at (
30,
30)
</div>
32 <div style='cursor: url(resources/greenbox-hotspot5-
4.cur), pointer'
>Image with implicit hot spot at (
5,
4)
</div>
33 <div style='cursor: url(resources/greenbox-hotspot5-
4.cur)
20 10, pointer'
>Image with explicit hot spot at (
20,
10) overriding implicit hot spot
</div>
34 <div style='cursor: url(resources/greenbox-hotspot35-
4.cur), pointer'
>Image with implicit hot spot outside image at (
35,
4)
</div>
35 <div style='cursor: url(resources/onload-image.png), pointer'
>Over large image with fallback to pointer
</div>
36 <div style='cursor: url(#greenbox), pointer'
>SVG cursor
</div>
37 <div style='cursor: url(mouse-cursor_FAIL.html), url(unknown-scheme:cursor_FAIL.png), pointer'
>Multiple invalid cursors with fallback to pointer
</div>
38 <div style='cursor: url(#nonexistent_FAIL), pointer'
>Nonexistent SVG cursor with fallback to pointer
</div>
39 <div><a href='#'
>A link with default cursor
</a></div>
40 <div style='cursor: wait'
><a href='#'
>Link with default cursor overriding wait
</a></div>
41 <div style='cursor: wait'
><div style='cursor: doesntexist'
>Wait cursor which should not be affected by unknown cursor rule
</div></div>
44 <div id=
"console"></div>
47 var testContainer
= document
.getElementById('test-container');
50 // Can't do anything useful here without eventSender
51 if (window
.eventSender
) {
52 var nodesToTest
= document
.querySelectorAll('#test-container > div');
53 for (var i
= 0; i
< nodesToTest
.length
; i
++) {
54 var node
= nodesToTest
[i
];
55 debug('TEST CASE: ' + node
.textContent
);
57 // Make sure the node is visible and move the mouse over top of it.
58 document
.documentElement
.scrollTop
= node
.offsetTop
- 50;
59 eventSender
.mouseMoveTo(node
.offsetLeft
+ 3, node
.offsetTop
- document
.documentElement
.scrollTop
+ 3);
61 // Get details of the current mouse cursor.
62 // Note that we could return structured data which we then validate, but that's a lot more
63 // work and is redundant with relying on the expected output anyway. Better to just dump
64 // it and inspect that it matches the description.
65 debug('Cursor Info: ' + window
.internals
.getCurrentCursorInfo());
68 // This text is redundant with the test output - hide it
69 testContainer
.style
.display
= 'none';
75 description("Test that mouse cursors are applied correctly.");
77 if (!window
.eventSender
) {
78 testFailed('This test requires DumpRenderTree');
81 if (window
.testRunner
) {
82 testRunner
.dumpAsText();
83 testRunner
.waitUntilDone();
84 window
.jsTestIsAsync
= true;
87 // Now wait for each image to load or fail to load before starting tests.
88 // Without this we can get null images in the cursors - eg. no known size.
89 preloadImagesFromStyle(testContainer
, 9, runTests
, /(#greenbox|_FAIL)/);