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=
99493>Bug
99493</a></p>
12 <div id=
"test-container">
13 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
1x), pointer'
>25x25 image at
1x
</div>
14 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
2x), pointer'
>25x25 image at
2x
</div>
15 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
1x, url(resources/greenbox30.png)
2x), pointer'
>25x25 image at
1x,
30x30 image at
2x
</div>
16 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
1.5x, url(resources/greenbox30.png)
5x), pointer'
>25x25 image at
1.5x,
30x30 image at
5x
</div>
17 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
0.0001x), pointer'
>Invalid tiny scale with fallback to pointer
</div>
18 <div style='cursor: -webkit-image-set(url(resources/greenbox200.png)
1x), pointer'
>Over-large image with fallback to pointer
</div>
19 <div style='cursor: -webkit-image-set(url(resources/greenbox200.png)
4x), pointer'
>200x200 image at
4x (not over-large in UI pixels)
</div>
20 <div style='cursor: -webkit-image-set(url(doesntexist.png)
1x), url(resources/greenbox.png), pointer'
>Non-existent image in image-set with fallback to
25x25 image
</div>
21 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
1x, url(resources/greenbox30.png)
2x)
5 3, pointer'
>Explicit hotspot at (
5,
3) logical in
1x and
2x
</div>
22 <div style='cursor: -webkit-image-set(url(resources/greenbox.png)
0.7x, url(resources/greenbox30.png)
1.4x)
7 3, pointer'
>Explicit hotspot at (
7,
3) logical in
0.7x and
1.4x - should round to nearest integer
</div>
23 <div style='cursor: -webkit-image-set(url(resources/greenbox-hotspot5-
4.cur)
1x, url(resources/greenbox30-hotspot28-
3.cur)
2x), pointer'
>Implicit hot-spot at (
5,
4) physical for
1x and (
28,
3) physical for
2x
</div>
26 <div id=
"console"></div>
28 var imagesLeftToLoad
= 0;
29 var testContainer
= document
.getElementById('test-container');
31 function checkCursors() {
32 debug('Checking cursors with device pixel ratio of ' + window
.devicePixelRatio
);
33 debug('----------------------------------------------');
35 var nodesToTest
= document
.querySelectorAll('#test-container > div');
36 for (var i
= 0; i
< nodesToTest
.length
; i
++) {
37 var node
= nodesToTest
[i
];
38 debug('TEST CASE: ' + node
.textContent
);
39 // Make sure the node is visible and move the mouse over top of it.
40 document
.documentElement
.scrollTop
= node
.offsetTop
- 50;
41 eventSender
.mouseMoveTo(node
.offsetLeft
+ 3, node
.offsetTop
- document
.documentElement
.scrollTop
+ 3);
43 // Get details of the current mouse cursor.
44 // Note that we could return structured data which we then validate, but that's a lot more
45 // work and is redundant with relying on the expected output anyway. Better to just dump
46 // it and inspect that it matches the description.
47 debug('Cursor Info: ' + window
.internals
.getCurrentCursorInfo());
53 if (window
.eventSender
) {
55 // Repeat in high-dpi mode
56 testRunner
.setBackingScaleFactor(2, function() {
57 // Failed images are apparently reset on scale factor change.
58 loadImages([{ url
: 'doesntexist.png', error
: true }], function() {
60 testContainer
.style
.display
= 'none';
69 description("Test that mouse cursors are applied correctly.");
71 if (!window
.eventSender
) {
72 testFailed('This test requires DumpRenderTree');
75 if (window
.testRunner
) {
76 testRunner
.dumpAsText();
77 testRunner
.waitUntilDone();
78 window
.jsTestIsAsync
= true;
81 // Now wait for each image to load or fail to load before starting tests.
82 // Without this we can get null images in the cursors - eg. no known size.
83 preloadImagesFromStyle(testContainer
, 6, runTests
, /doesntexist/);