| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
| 4 <script src="../dom/resources/event-sender-util.js"></script> | 4 <script src="../dom/resources/event-sender-util.js"></script> |
| 5 <script> | 5 <script> |
| 6 description('This test checks if contextmenu event target is correct when handle
d at the document level and in the' + | 6 description('This test checks if contextmenu event target is correct when handle
d at the document level and in the' + |
| 7 ' presence of pinch-zoom. To test manually, first pinch-zoom into th
e page, scroll away from the origin' + | 7 ' presence of pinch-zoom. To test manually, first pinch-zoom into th
e page, scroll away from the origin' + |
| 8 ' and then then press the menu key. There are three cases to check:
nothing focused (the context menu is' + | 8 ' and then then press the menu key. There are three cases to check:
nothing focused (the context menu is' + |
| 9 ' expected to appear in the top left of the viewport), click on the
orange box to focus it then use the' + | 9 ' expected to appear in the top left of the viewport), click on the
orange box to focus it then use the' + |
| 10 ' menu key, and select some text in the box and use the menu key. No
te: on Mac there is no menu key.'); | 10 ' menu key, and select some text in the box and use the menu key. No
te: on Mac there is no menu key.'); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // Start from pinch viewport offset (0, 0). | 82 // Start from pinch viewport offset (0, 0). |
| 83 eventSender.gestureScrollUpdate(-pinchViewportContentX*scale, | 83 eventSender.gestureScrollUpdate(-pinchViewportContentX*scale, |
| 84 -pinchViewportContentY*scale); | 84 -pinchViewportContentY*scale); |
| 85 eventSender.gestureScrollEnd(0, 0); | 85 eventSender.gestureScrollEnd(0, 0); |
| 86 | 86 |
| 87 anchor = document.getElementById("anchor"); | 87 anchor = document.getElementById("anchor"); |
| 88 | 88 |
| 89 // With nothing focused, the context menu should appear in the top left | 89 // With nothing focused, the context menu should appear in the top left |
| 90 // corner of the viewport. | 90 // corner of the viewport. |
| 91 document.addEventListener('contextmenu', handleContextMenuNoFocus, true); | 91 document.addEventListener('contextmenu', handleContextMenuNoFocus, true); |
| 92 eventSender.keyDown("menu"); | 92 eventSender.keyDown("ContextMenu"); |
| 93 eventSender.keyDown("escape"); | 93 eventSender.keyDown("Escape"); |
| 94 document.removeEventListener('contextmenu', handleContextMenuNoFocus, true); | 94 document.removeEventListener('contextmenu', handleContextMenuNoFocus, true); |
| 95 | 95 |
| 96 // Focus the anchor, make sure the client coordinates and screen coordinates | 96 // Focus the anchor, make sure the client coordinates and screen coordinates |
| 97 // take the viewport's position and scale into account. | 97 // take the viewport's position and scale into account. |
| 98 anchor.focus(); | 98 anchor.focus(); |
| 99 document.addEventListener('contextmenu', handleContextMenuFocus, true); | 99 document.addEventListener('contextmenu', handleContextMenuFocus, true); |
| 100 eventSender.keyDown("menu"); | 100 eventSender.keyDown("ContextMenu"); |
| 101 eventSender.keyDown("escape"); | 101 eventSender.keyDown("Escape"); |
| 102 document.removeEventListener('contextmenu', handleContextMenuFocus, true); | 102 document.removeEventListener('contextmenu', handleContextMenuFocus, true); |
| 103 | 103 |
| 104 // Place selection and make sure it still works. | 104 // Place selection and make sure it still works. |
| 105 window.getSelection().selectAllChildren(anchor); | 105 window.getSelection().selectAllChildren(anchor); |
| 106 document.addEventListener('contextmenu', handleContextMenuEditable, true); | 106 document.addEventListener('contextmenu', handleContextMenuEditable, true); |
| 107 eventSender.keyDown("menu"); | 107 eventSender.keyDown("ContextMenu"); |
| 108 eventSender.keyDown("escape"); | 108 eventSender.keyDown("Escape"); |
| 109 document.removeEventListener('contextmenu', handleContextMenuEditable, true)
; | 109 document.removeEventListener('contextmenu', handleContextMenuEditable, true)
; |
| 110 | 110 |
| 111 testRunner.notifyDone(); | 111 testRunner.notifyDone(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (!window.eventSender || !window.testRunner || !window.internals) { | 114 if (!window.eventSender || !window.testRunner || !window.internals) { |
| 115 testFailed('This test needs to run in a test environment.'); | 115 testFailed('This test needs to run in a test environment.'); |
| 116 document.addEventListener('contextmenu', handleContextMenuEditable, true); | 116 document.addEventListener('contextmenu', handleContextMenuEditable, true); |
| 117 } else { | 117 } else { |
| 118 testRunner.waitUntilDone(); | 118 testRunner.waitUntilDone(); |
| 119 window.addEventListener('load', runTest); | 119 window.addEventListener('load', runTest); |
| 120 } | 120 } |
| 121 </script> | 121 </script> |
| 122 | 122 |
| 123 <style> | 123 <style> |
| 124 #anchor { | 124 #anchor { |
| 125 background-color: orange; | 125 background-color: orange; |
| 126 position: absolute; | 126 position: absolute; |
| 127 top: 380px; | 127 top: 380px; |
| 128 left: 530px; | 128 left: 530px; |
| 129 height: 100px; | 129 height: 100px; |
| 130 width: 100px; | 130 width: 100px; |
| 131 } | 131 } |
| 132 </style> | 132 </style> |
| 133 <div id="anchor" tabindex="0">Target</div> | 133 <div id="anchor" tabindex="0">Target</div> |
| 134 <div id="console"></div> | 134 <div id="console"></div> |
| OLD | NEW |