cdp: add Input.setInterceptDrags and Input.dispatchDragEvent
Merged
JA
12d ago+467+467+012345678901234567890123456789-1-1-0123456789
Part of #4186.
Playwright sends Input.setInterceptDrags around every mouse move made with the left button down, so this failed with 'Input.setInterceptDrags' wasn't found, and locator.dragTo() timed out:
await page.mouse.move(10, 20)
await page.mouse.down()
await page.mouse.move(150, 20)
Input.setInterceptDragsstores the flag. Mouse input doesn't start a native drag yet, so noInput.dragInterceptedis sent, as in Chrome when the press isn't on a draggable element. The script above now works and the page gets pointermove/mousemove withbuttons=1.Input.dispatchDragEventdrives a drag from outside the page, as Puppeteer'smouse.dragEnter/dragOver/dropdo. As in Chrome, dragEnter, dragOver and drop each run one step: dragenter (and dragleave on the old target) on a new target, dragover on the same one. A drop then fires drop if that step accepted the drag with an operation the source allows, else dragleave if the page calledpreventDefault(), else nothing.dragCancelfires nothing and ends the drag. Each event gets a DataTransfer built fromdata.items, protected for everything but drop, with effectAllowed and dropEffect fromdragOperationsMask.DataTransfergets the drag data store mode for this.data.filesisn't handled.
As discussed in #4186, drags that start inside the page (dragstart from mouse input, Input.dragIntercepted, the non-intercepted mouse-driven drag, dragend on the source) are left for a follow-up.
Tests: five new cdp.input tests (setInterceptDrags with a held button; dispatchDragEvent enter/move/drop, a drop running its step first, a drop nobody accepted, dragCancel ending the drag). make test: 2069 of 2069.