Despite supporting `.val()` and `.textSelection` (added by `jquery.textSelection` module) methods for `$( '#wpTextbox1' )`, CodeMirror has no support for `.focus()` & `.blur()` methods and corresponding events.
In Chrome, listening to these events for the `.CodeMirror-code` element saves the day, but for some reason the DOM for Chrome and Firefox (at least these two) differs, and in Firefox, I have found no reliable way to attach the said event listeners to the editing area. You can listen to `.CodeMirror textarea` which is present only in Firefox, but it isn't present in the DOM from the start, and—what makes the things even worse—there is no `mw.hook` events created for CodeMirror (see {T174811}), so one can't catch a moment when CodeMirror is initialized to attach a listener. `mw.hook( 'wikipage.editform' )` is useless.
Because of this issue [[https://ru.wikipedia.org/wiki/MediaWiki:Gadget-newTopicOnTop.js|an important ruwiki script]] has broken in Firefox after making CodeMirror opt-out last week.