Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
|
mustaq
2017/05/26 14:56:18
This test should be easily done inside the first t
| |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Pointer Events pointer lock tests</title> | |
| 5 <meta name="viewport" content="width=device-width"> | |
| 6 <link rel="stylesheet" type="text/css" href="../pointerevent_styles.css" > | |
| 7 <script src="/resources/testharness.js"></script> | |
| 8 <script src="/resources/testharnessreport.js"></script> | |
| 9 <!-- Additional helper script for common checks across event types --> | |
| 10 <script type="text/javascript" src="../pointerevent_support.js"></script > | |
| 11 <script> | |
| 12 var capture_count = 0; | |
| 13 var mouse_move_count = 0; | |
| 14 var lock_change_count = 0; | |
| 15 | |
| 16 function resetTestState() { | |
| 17 } | |
| 18 | |
| 19 function run() { | |
| 20 var test_pointerEvent = setup_pointerevent_test("no pointercaptu re while pointerlock", ['mouse']); | |
| 21 var div1 = document.getElementById("div1"); | |
| 22 var div2 = document.getElementById("div2"); | |
| 23 | |
| 24 on_event(div1, 'pointerdown', function(event) { | |
| 25 div1.requestPointerLock(); | |
| 26 }); | |
| 27 on_event(div1, 'pointermove', function(event) { | |
| 28 if (lock_change_count == 1) { | |
| 29 mouse_move_count++; | |
| 30 if (mouse_move_count == 1) { | |
| 31 try { | |
| 32 div2.setPointerCapture(event.pointerId); | |
| 33 test_pointerEvent.step(function () { | |
| 34 assert_unreached("DOMException: InvalidState Error should have been thrown."); | |
| 35 }); | |
| 36 } catch (e) { | |
| 37 test_pointerEvent.step(function () { | |
| 38 assert_equals(e.name, "InvalidStateError", " DOMException should be InvalidStateError"); | |
| 39 }); | |
| 40 } | |
| 41 } else if (mouse_move_count == 2) { | |
| 42 test_pointerEvent.step(function () { | |
| 43 assert_equals(capture_count, 0, "no capture"); | |
| 44 }); | |
| 45 test_pointerEvent.done(); | |
| 46 } | |
| 47 } | |
| 48 }); | |
| 49 on_event(div2, 'gotpointercapture', function(event) { | |
| 50 capture_count++; | |
| 51 }); | |
| 52 on_event(div2, 'lostpointercapture', function(event) { | |
| 53 capture_count++; | |
| 54 }); | |
| 55 on_event(document, 'pointerlockchange', function(event) { | |
| 56 lock_change_count++; | |
| 57 test_pointerEvent.step(function() { | |
| 58 assert_equals(document.pointerLockElement, div1, "docume nt.pointerLockElement should be div1."); | |
| 59 }); | |
| 60 }); | |
| 61 } | |
| 62 </script> | |
| 63 </head> | |
| 64 <body onload="run()"> | |
| 65 <h1>Pointer Events pointer lock test</h1> | |
| 66 <h2 id="pointerTypeDescription"></h2> | |
| 67 <h4> | |
| 68 Test Description: This test checks that we will throw an error when we are trying to set the pointer capture when any element in the page already ge ts a pointer lock. | |
| 69 <ol> | |
| 70 <li>Press left button down on the green rectangle and hold it.< /li> | |
| 71 <li>Move the mouse inside the green rectangle.</li> | |
| 72 </ol> | |
| 73 | |
| 74 Test passes if an InvalidStateError is caught when setting pointer c apture on yellow rectangle while the green rectangle already gets the pointer lo ck. | |
| 75 </h4> | |
| 76 <div id="testContainer"> | |
| 77 <div id="div1" style="width:800px;height:250px;background:green"></d iv> | |
| 78 <div id="div2" style="width:800px;height:250px;background:yellow"></ div> | |
| 79 </div> | |
| 80 <div class="spacer"></div> | |
| 81 </body> | |
| 82 </html> | |
| OLD | NEW |