@@ -88,15 +88,23 @@ define(function (require, exports, module) {
8888 const selected = ProjectManager . getSelectedItem ( ) ;
8989 expect ( selected . fullPath ) . toBe ( testPath + "/jumpToDef.html" ) ;
9090
91- let editor = EditorManager . getActiveEditor ( ) ;
92- editor . setCursorPos ( { line : 5 , ch : 6 } ) ;
91+ const hostEditor = EditorManager . getActiveEditor ( ) ;
92+ hostEditor . setCursorPos ( { line : 5 , ch : 6 } ) ;
9393
9494 await awaitsForDone ( CommandManager . execute ( Commands . NAVIGATE_JUMPTO_DEFINITION ) ,
9595 "jump to def on div" ) ;
9696
97- editor = EditorManager . getFocusedInlineEditor ( ) ;
98- expect ( editor . document . file . fullPath . endsWith ( "LiveDevelopment-MultiBrowser-test-files/simpleShared.css" ) )
99- . toBeTrue ( ) ;
97+ // Ask the host for its inline editors rather than for the focused one:
98+ // an inline editor only holds focus while the window does, so the old
99+ // check came back null whenever the test window was not the OS front
100+ // window, without the inline editor being any less open.
101+ let inlineEditor ;
102+ await awaitsFor ( function ( ) {
103+ inlineEditor = EditorManager . getInlineEditors ( hostEditor ) [ 0 ] ;
104+ return ! ! inlineEditor ;
105+ } , "inline editor to open on the definition" ) ;
106+ expect ( inlineEditor . document . file . fullPath
107+ . endsWith ( "LiveDevelopment-MultiBrowser-test-files/simpleShared.css" ) ) . toBeTrue ( ) ;
100108 await closeSession ( ) ;
101109 } ) ;
102110
@@ -105,14 +113,22 @@ define(function (require, exports, module) {
105113 const selected = ProjectManager . getSelectedItem ( ) ;
106114 expect ( selected . fullPath ) . toBe ( testPath + "/jumpToDef.html" ) ;
107115
108- let editor = EditorManager . getActiveEditor ( ) ;
109- editor . setCursorPos ( { line : 6 , ch : 23 } ) ;
116+ const hostEditor = EditorManager . getActiveEditor ( ) ;
117+ hostEditor . setCursorPos ( { line : 6 , ch : 23 } ) ;
110118
111119 await awaitsForDone ( CommandManager . execute ( Commands . NAVIGATE_JUMPTO_DEFINITION ) ,
112120 "jump to def on div" ) ;
113121
114- editor = EditorManager . getFocusedInlineEditor ( ) ;
115- expect ( editor . document . file . fullPath . endsWith ( "LiveDevelopment-MultiBrowser-test-files/sub/test.css" ) )
122+ // Ask the host for its inline editors rather than for the focused one:
123+ // an inline editor only holds focus while the window does, so the old
124+ // check came back null whenever the test window was not the OS front
125+ // window, without the inline editor being any less open.
126+ let inlineEditor ;
127+ await awaitsFor ( function ( ) {
128+ inlineEditor = EditorManager . getInlineEditors ( hostEditor ) [ 0 ] ;
129+ return ! ! inlineEditor ;
130+ } , "inline editor to open on the definition" ) ;
131+ expect ( inlineEditor . document . file . fullPath . endsWith ( "LiveDevelopment-MultiBrowser-test-files/sub/test.css" ) )
116132 . toBeTrue ( ) ;
117133 await closeSession ( ) ;
118134 } ) ;
@@ -202,9 +218,11 @@ define(function (require, exports, module) {
202218 let editor = EditorManager . getActiveEditor ( ) ;
203219 editor . setCursorPos ( cursor ) ;
204220
205- await awaitsForDone ( CommandManager . execute ( Commands . SHOW_CODE_HINTS ) ,
206- "show code hints" ) ;
207-
221+ // The index has to hold the classes before hints are asked for, not after.
222+ // Showing hints is a one-shot request: made while the index is still
223+ // catching up, the provider has no class hints to offer, no menu opens,
224+ // and nothing asks again once the index is ready - so this passed only
225+ // when the index happened to be warm, and timed out under a full run.
208226 await awaitsFor ( async function ( ) {
209227 for ( let hint of expectedSomeHintsArray ) {
210228 const allSelectors = await CSSUtils . getAllCssSelectorsInProject ( ) ;
@@ -215,6 +233,11 @@ define(function (require, exports, module) {
215233 return true ;
216234 } , "CSSUtils project selectors to be updated" ) ;
217235
236+ // With the editor passed in, the session does not depend on it holding
237+ // focus, which it does not while the test window is in the background.
238+ await awaitsForDone ( CommandManager . execute ( Commands . SHOW_CODE_HINTS , editor ) ,
239+ "show code hints" ) ;
240+
218241 await awaitsFor ( function ( ) {
219242 return $ ( ".codehint-menu" ) . is ( ":visible" ) ;
220243 } , "codehints to be shown" ) ;
0 commit comments