@@ -197,34 +197,22 @@ var check_use_counter_iframe = async function(
197197 await ContentTask . spawn ( gBrowser . selectedBrowser , { file : file } , function (
198198 opts
199199 ) {
200- let wu = content . window . windowUtils ;
201-
202200 let iframe = content . document . getElementById ( "content" ) ;
203201 iframe . src = opts . file ;
204202
205203 return new Promise ( resolve => {
206204 let listener = event => {
207205 event . target . removeEventListener ( "load" , listener , true ) ;
208-
209- // We flush the main document first, then the iframe's document to
210- // ensure any propagation that might happen from content->parent should
211- // have already happened when counters are reported to telemetry.
212- wu . forceUseCounterFlush ( content . document ) ;
213- wu . forceUseCounterFlush ( iframe . contentDocument ) ;
214-
215206 resolve ( ) ;
216207 } ;
217208 iframe . addEventListener ( "load" , listener , true ) ;
218209 } ) ;
219210 } ) ;
220211
221212 // Tear down the page.
213+ let tabClosed = BrowserTestUtils . waitForTabClosing ( newTab ) ;
222214 gBrowser . removeTab ( newTab ) ;
223-
224- // The histograms only get recorded when the document actually gets
225- // destroyed, which might not have happened yet due to GC/CC effects, etc.
226- // Try to force document destruction.
227- await waitForDestroyedDocuments ( ) ;
215+ await tabClosed ;
228216
229217 // Grab histograms again and compare.
230218 let [
@@ -290,16 +278,6 @@ var check_use_counter_img = async function(file, use_counter_middlefix) {
290278 return new Promise ( resolve => {
291279 let listener = event => {
292280 img . removeEventListener ( "load" , listener , true ) ;
293-
294- // Flush for the image. It matters what order we do these in, so that
295- // the image can propagate its use counters to the document prior to the
296- // document reporting its use counters.
297- let wu = content . window . windowUtils ;
298- wu . forceUseCounterFlush ( img ) ;
299-
300- // Flush for the main window.
301- wu . forceUseCounterFlush ( content . document ) ;
302-
303281 resolve ( ) ;
304282 } ;
305283 img . addEventListener ( "load" , listener , true ) ;
@@ -308,12 +286,9 @@ var check_use_counter_img = async function(file, use_counter_middlefix) {
308286 ) ;
309287
310288 // Tear down the page.
289+ let tabClosed = BrowserTestUtils . waitForTabClosing ( newTab ) ;
311290 gBrowser . removeTab ( newTab ) ;
312-
313- // The histograms only get recorded when the document actually gets
314- // destroyed, which might not have happened yet due to GC/CC effects, etc.
315- // Try to force document destruction.
316- await waitForDestroyedDocuments ( ) ;
291+ await tabClosed ;
317292
318293 // Grab histograms again and compare.
319294 let [
@@ -372,23 +347,16 @@ var check_use_counter_direct = async function(
372347 await new Promise ( resolve => {
373348 let listener = ( ) => {
374349 removeEventListener ( "load" , listener , true ) ;
375-
376- let wu = content . window . windowUtils ;
377- wu . forceUseCounterFlush ( content . document ) ;
378-
379350 setTimeout ( resolve , 0 ) ;
380351 } ;
381352 addEventListener ( "load" , listener , true ) ;
382353 } ) ;
383354 } ) ;
384355
385356 // Tear down the page.
357+ let tabClosed = BrowserTestUtils . waitForTabClosing ( newTab ) ;
386358 gBrowser . removeTab ( newTab ) ;
387-
388- // The histograms only get recorded when the document actually gets
389- // destroyed, which might not have happened yet due to GC/CC effects, etc.
390- // Try to force document destruction.
391- await waitForDestroyedDocuments ( ) ;
359+ await tabClosed ;
392360
393361 // Grab histograms again and compare.
394362 let [
0 commit comments