Closed Bug 1886604 Opened 8 months ago Closed 4 months ago

Add MockDragService to allow DND testing in tabs and pages

Categories

(Core :: Widget, task)

task

Tracking

()

RESOLVED FIXED
129 Branch
Tracking Status
firefox-esr128 --- fixed
firefox129 --- fixed

People

(Reporter: handyman, Assigned: handyman)

Details

Attachments

(6 files, 1 obsolete file)

This is spun off of bug 1871222, which uses this to test that DND respects content analysis. I've broken it off to simplify the bug history and review. I've also added a somewhat elementary test of basic DND behavior. In the future, we hope to migrate existing DND tests to this setup.

Severity: -- → S2

Removes builtinclass, notxpcom and nostdcall and updates clients.

Introduces MockDragService as a subclass/implementation of nsBaseDragService.
This class is based on the Windows implementation of nsBaseDragService. The
service is created with a MockDragServiceController that JS can use to
initiate drag events that would normally come from the system. Native
drag-and-drop is not permitted in automation because it puts the browser into
a state where, if anything goes wrong (e.g. a test failure), it cannot be
killed without manual intervention. This allows us to avoid that limitation
while still testing most of the browser's drag-and-drop behavior, including
the (substantial and complex) nsBaseDragService base-class that is common to
all platforms.

Depends on D205639

Add synthesizeMockDragAndDrop test function to test elements
drag-dropped inside of Firefox. This uses the new MockDragService to
avoid native DND. It is a more-complete variant of synthesizeDragAndDrop
and synthesizePlainDragAndDrop. It works by:

  1. Creating the environment for the test.
  2. Gathering coordinates of the source and target elements from their
    respective content processes.
  3. Setting up event handlers on the elements to detect any relevant events
    they may receive. This allows us to detect not only events that aren't sent
    when they should be but also events that are sent that shouldn't be.
  4. Synthesizing mouse events to initiate the drag-session. This and
    the remaining steps work by first telling the relevant content process(es)
    what events to expect (and which not to), then sending the event, and
    finally collecting the results and submitting them to mochitest.
  5. Synthesizing drag events with the MockDragServiceController, to emulate
    the behavior of (Windows) native drag-and-drop. This is a coarse
    approximation of the Win32 API DoDragDrop.
  6. Cleaning up the event handlers.

The test does not yet try to mock things like the drag cursor image, although
that should be possible without native DND behavior. The same is true for
some more minor aspects of the platform-specific behavior of our DND.

Depends on D205640

Test of basic DND functionality between content pages, using the
MockDragService.

Depends on D205641

Attachment #9393169 - Attachment description: Bug 1886604: Part 2: Add JS-scriptable MockDragService r=#win-reviewers! → Bug 1886604: Part 1: Add JS-scriptable MockDragService r=#win-reviewers!
Attachment #9393170 - Attachment description: Bug 1886604: Part 3: Add synthesizeMockDragAndDrop r=m_kato! → Bug 1886604: Part 2: Add synthesizeMockDragAndDrop r=edgar!
Attachment #9393171 - Attachment description: Bug 1886604: Part 4: Test drag and drop events between windows and iframes r=m_kato! → Bug 1886604: Part 3: Test drag and drop events between windows and iframes r=edgar!
Attachment #9393168 - Attachment is obsolete: true
Pushed by daparks@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/da0dd76615c1 Part 1: Add JS-scriptable MockDragService r=win-reviewers,edgar,rkraesig https://hg.mozilla.org/integration/autoland/rev/cb68ed9008a9 Part 2: Add synthesizeMockDragAndDrop r=edgar https://hg.mozilla.org/integration/autoland/rev/7cdf4136ca78 Part 3: Test drag and drop events between windows and iframes r=edgar
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch

Introduces MockDragService as a subclass/implementation of nsBaseDragService.
This class is based on the Windows implementation of nsBaseDragService. The
service is created with a MockDragServiceController that JS can use to
initiate drag events that would normally come from the system. Native
drag-and-drop is not permitted in automation because it puts the browser into
a state where, if anything goes wrong (e.g. a test failure), it cannot be
killed without manual intervention. This allows us to avoid that limitation
while still testing most of the browser's drag-and-drop behavior, including
the (substantial and complex) nsBaseDragService base-class that is common to
all platforms.

Original Revision: https://phabricator.services.mozilla.com/D205640

Attachment #9422862 - Flags: approval-mozilla-esr128?

Add synthesizeMockDragAndDrop test function to test elements
drag-dropped inside of Firefox. This uses the new MockDragService to
avoid native DND. It is a more-complete variant of synthesizeDragAndDrop
and synthesizePlainDragAndDrop. It works by:

  1. Creating the environment for the test.
  2. Gathering coordinates of the source and target elements from their
    respective content processes.
  3. Setting up event handlers on the elements to detect any relevant events
    they may receive. This allows us to detect not only events that aren't sent
    when they should be but also events that are sent that shouldn't be.
  4. Synthesizing mouse events to initiate the drag-session. This and
    the remaining steps work by first telling the relevant content process(es)
    what events to expect (and which not to), then sending the event, and
    finally collecting the results and submitting them to mochitest.
  5. Synthesizing drag events with the MockDragServiceController, to emulate
    the behavior of (Windows) native drag-and-drop. This is a coarse
    approximation of the Win32 API DoDragDrop.
  6. Cleaning up the event handlers.

The test does not yet try to mock things like the drag cursor image, although
that should be possible without native DND behavior. The same is true for
some more minor aspects of the platform-specific behavior of our DND.

Original Revision: https://phabricator.services.mozilla.com/D205641

Attachment #9422863 - Flags: approval-mozilla-esr128?

Test of basic DND functionality between content pages of different domains,
using the MockDragService.

Original Revision: https://phabricator.services.mozilla.com/D205642

Attachment #9422864 - Flags: approval-mozilla-esr128?
Attachment #9422862 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
Attachment #9422863 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
Attachment #9422864 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+

esr128 Uplift Approval Request

  • User impact if declined: Won't be able to test DLP drag and drop
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: n/a
  • Risk associated with taking this patch: medium
  • Explanation of risk level: deals with drag and drop code, but has already made it to release and further patches add tests
  • String changes made/needed: no
  • Is Android affected?: no
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: