mouseEvent.html (1681B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <head> 4 <title>CSSOM MouseEvent tests</title> 5 <div style="background:lightblue; height:10000px"> 6 Hello 7 </div> 8 <script src=/resources/testharness.js></script> 9 <script src=/resources/testharnessreport.js></script> 10 <script> 11 test(function () { 12 var mouseEvent = new MouseEvent('mousedown', {clientX: 10, clientY: 20}); 13 assert_equals(mouseEvent.x, 10); 14 assert_equals(mouseEvent.y, 20); 15 mouseEvent = new MouseEvent('mousedown', {clientX: 30, clientY: 40}); 16 assert_equals(mouseEvent.x, 30); 17 assert_equals(mouseEvent.y, 40); 18 }, 'MouseEvent\'s x and y must be equal to clientX and clientY.'); 19 20 test(function () { 21 var mouseEvent1 = new MouseEvent('mousedown', {clientX: 10, clientY: 20}); 22 assert_equals(mouseEvent1.pageX, 10); 23 assert_equals(mouseEvent1.pageY, 20); 24 scrollBy(0, 5000); 25 assert_equals(mouseEvent1.pageX, 10); 26 assert_equals(mouseEvent1.pageY, 5020); 27 28 var mouseEvent2 = new MouseEvent('mousedown', {clientX: 10, clientY: 20}); 29 assert_equals(mouseEvent2.pageX, 10); 30 assert_equals(mouseEvent2.pageY, 5020); 31 }, 'MouseEvent\'s pageX and pageY attributes should be the sum of the scroll offset and clientX/clientY'); 32 33 test(function () { 34 var mouseEvent = new MouseEvent('mousedown', {clientX: 10, clientY: 20}); 35 assert_equals(mouseEvent.offsetX, mouseEvent.pageX); 36 assert_equals(mouseEvent.offsetY, mouseEvent.pageY); 37 scrollBy(0, 5000); 38 assert_equals(mouseEvent.offsetX, mouseEvent.pageX); 39 assert_equals(mouseEvent.offsetY, mouseEvent.pageY); 40 }, 'MouseEvent\'s offsetX/offsetY attributes should be the same value as its pageX/pageY attributes.'); 41 </script> 42 </head>