From ce3b7ee3967092721c9c9e9c2fe0470c52194495 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 14 Nov 2014 10:57:00 +0100 Subject: [PATCH] Bug 1091463 - wait for all expected markers from docshell. r=paul --- .../test/browser/browser_timelineMarkers-04.js | 17 ++++++++--------- docshell/test/browser/timelineMarkers-04.html | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/docshell/test/browser/browser_timelineMarkers-04.js b/docshell/test/browser/browser_timelineMarkers-04.js index bea5f8a6caf..dfb99d189ba 100644 --- a/docshell/test/browser/browser_timelineMarkers-04.js +++ b/docshell/test/browser/browser_timelineMarkers-04.js @@ -43,13 +43,13 @@ let test = Task.async(function*() { docShell.popProfileTimelineMarkers(); info("Running the test setup function"); - let onMarkers = waitForMarkers(docShell); + let onMarkers = waitForDOMMarkers(docShell, 5); setup(); info("Waiting for new markers on the docShell"); let markers = yield onMarkers; info("Running the test check function"); - check(markers.filter(m => m.name == "DOMEvent")); + check(markers); } info("Stop recording"); @@ -73,21 +73,20 @@ function openUrl(url) { }); } -function waitForMarkers(docshell) { +function waitForDOMMarkers(docshell, numExpected) { return new Promise(function(resolve, reject) { let waitIterationCount = 0; let maxWaitIterationCount = 10; // Wait for 2sec maximum + let markers = []; let interval = setInterval(() => { - let markers = docshell.popProfileTimelineMarkers(); - if (markers.length > 0) { + let newMarkers = docshell.popProfileTimelineMarkers(); + markers = [...markers, ...newMarkers.filter(m => m.name == "DOMEvent")]; + if (markers.length >= numExpected + || waitIterationCount > maxWaitIterationCount) { clearInterval(interval); resolve(markers); } - if (waitIterationCount > maxWaitIterationCount) { - clearInterval(interval); - resolve([]); - } waitIterationCount++; }, 200); }); diff --git a/docshell/test/browser/timelineMarkers-04.html b/docshell/test/browser/timelineMarkers-04.html index 67d4f3debbc..ecb25cadb13 100644 --- a/docshell/test/browser/timelineMarkers-04.html +++ b/docshell/test/browser/timelineMarkers-04.html @@ -14,7 +14,7 @@ xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { - // Nothing. + dump("ReadyState = " + xhr.readyState + "\n"); }; xhr.open("get", theURL, true); xhr.send();