Page MenuHomePhabricator

Test selections without relying on a ve.dm.Surface select event listener
Closed, ResolvedPublic8 Estimated Story Points

Description

Since 2013 (see I66520e ) we've been using an event listener in our tests to determine the current DM selection. This won't work reliably in the case where another listener for the same event changes the selection and itself causes a second event to be emitted simultaneously: the selections may not arrive in the correct order.

It turns out this can happen in our backspace tests; in https://gerrit.wikimedia.org/r/#/c/303335/4 I observed that the nested emits are as follows:

First, ve.dm.Surface emits 'select' with selection 3,3 . This ends up calling ve.ce.Surface#showModelSelection , which does ve.ce.SurfaceObserver#pollOnceInternal, which signals a branchNodeChange to ve.ce.Surface#handleObservedChanges, which calls ve.dm.Surface#change, which emits a (nested) 'select' with selection 2,2. These two simultaneous select events hit the listener in ve.ce.Surface.test.js#ve.test.utils.runSurfaceHandleSpecialKeyTest in the wrong order.

Therefore, we should use ve.dm.Surface#getSelection instead, unless there are problems with that (it was suggested that back in 2013 there were: see https://gerrit.wikimedia.org/r/#/c/87666/12/modules/ve/test/ce/ve.ce.Surface.test.js ), and discrepancies in our tests should be corrected accordingly.

Event Timeline

Change 311238 had a related patch set uploaded (by Divec):
Test selections without relying on a ve.dm.Surface select event listener

https://gerrit.wikimedia.org/r/311238

Jdforrester-WMF set the point value for this task to 8.
Jdforrester-WMF moved this task from To Triage to TR3: Language support on the VisualEditor board.

Change 311238 merged by jenkins-bot:
Test selections without relying on a ve.dm.Surface select event listener

https://gerrit.wikimedia.org/r/311238