gecko-dev/dom/interfaces
Masayuki Nakano 87ca855ece Bug 1603074 - part 1: Make `synthesizePlainDragAndDrop()` synthesize drag events without `DataTransfer` object r=smaug
`synthesizePlainDragAndDrop()` synthesizes drag events with `DataTransfer`
object which is set to `DragEvent.dataTransfer` of `dragstart` after starting
drag session explicitly.  However, this causes
`EventStateManager::DoDefaltDragStart()` does not initialize `nsIDragService`
instance.  Therefore, synthesized drag events cannot work with editor because
`DragEvent::GetMozSourceNode()` returns `nullptr` due to
`nsIDragSession::GetSourceNode()` returning `nullptr`.

On the other hand, synthesized drag events cannot use
`nsIDragService::InvodeDragSession()` normally because of hitting an assertion.
https://searchfox.org/mozilla-central/rev/690e903ef689a4eca335b96bd903580394864a1c/widget/nsBaseDragService.cpp#230-233

This patch does:
- mark drag events caused by synthesized mouse events as "synthesized for tests"
- make `synthesizePlainDragAndDrop()` stop using
  `nsIDragService.startDragSession()`
- make `nsBaseDragService` initialize and start session even for synthesized
  `dragstart` event
- make `synthesizePlainDragAndDrop()` stop synthesizing drag events with
  `DataTransfer` object since it's normal behavior and it'll be initialized
  with `nsIDragService::GetDataTransfer()`
- make `nsBaseDragService` store `effectAllowed` for the session only when
  it's synthesized session because it's required at initializing synthesized
  default `dropEffect` value of `dragenter`, `dragover`, `dragexit` and `drop`
  events' `dataTransfer`
- make all tests which use `nsIDragService.startDragSession()` use new
  API, `nsIDragService.startDragSessionForTests()` to initialize session's
  `effectAllowed` value
- make `EventStateManager::PostHandleEvent()` set drag end point of the test
  session to `eDrop` event's screen point
- make `synthesizePlainDragAndDrop()` set drag end point of the session if
  it does not synthesize `drop` event because following `endDragSession()`
  use it at dispatching `dragend` event on the source element

Additionally, this adds `dumpFunc` new param to `synthesizePlainDragAndDrop()`
because it's really useful to investigate the reason why requesting DnD isn't
performed as expected.

Differential Revision: https://phabricator.services.mozilla.com/D57425

--HG--
extra : moz-landing-system : lando
2019-12-21 12:27:06 +00:00
..
base Bug 1603074 - part 1: Make `synthesizePlainDragAndDrop()` synthesize drag events without `DataTransfer` object r=smaug 2019-12-21 12:27:06 +00:00
events Bug 1552795 - Remove all trailing whitespaces in idl files r=Ehsan 2019-05-22 22:37:14 +00:00
geolocation Bug 1575144 - Update Geolocation implementation to match latest spec r=baku,marcosc 2019-11-06 12:35:42 +00:00
html Bug 1566186: Part 1 - Remove DocShell support for isolated mozbrowsers. r=nika 2019-07-16 16:40:19 -07:00
notification
payments
push
security Bug 1597704 - Move is OriginPotentially Trustworthy into Principal r=ckerschb 2019-12-05 16:04:53 +00:00
sidebar Bug 1552795 - Remove all trailing whitespaces in idl files r=Ehsan 2019-05-22 22:37:14 +00:00
storage Bug 1558420 - Part 1: Add an API for creating a sessionstorage manager and a cache object; r=baku 2019-11-12 15:40:02 +00:00
xul Bug 1476659, remove invertSelection from mozilla-central, r=NeilDeakin 2019-10-28 20:58:38 +00:00