Bug 1066474 - Make browser_timeline.js not fail intermittently. r=paul, a=test-only
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 16 Dec 2014 12:37:00 -0500
changeset 235563 89251274ac9ede329665e8e0ba676a9289b434f6
parent 235562 096a9cc7a37904b23d17ba65ea4554d03c97ac78
child 235564 6758b70a72cdb6d2525395f75fa5f8188434e603
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul, test-only
bugs1066474
milestone35.0
Bug 1066474 - Make browser_timeline.js not fail intermittently. r=paul, a=test-only
toolkit/devtools/server/tests/browser/browser_timeline.js
--- a/toolkit/devtools/server/tests/browser/browser_timeline.js
+++ b/toolkit/devtools/server/tests/browser/browser_timeline.js
@@ -1,55 +1,61 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Test that the timeline front's start/stop/isRecording methods work in a
 // simple use case, and that markers events are sent when operations occur.
+// Note that this test isn't concerned with which markers are actually recorded,
+// just that markers are recorded at all.
+// Trying to check marker types here may lead to intermittents, see bug 1066474.
 
 const {TimelineFront} = require("devtools/server/actors/timeline");
 
 let test = asyncTest(function*() {
   let doc = yield addTab("data:text/html;charset=utf-8,mop");
 
   initDebuggerServer();
   let client = new DebuggerClient(DebuggerServer.connectPipe());
-
   let form = yield connectDebuggerClient(client);
   let front = TimelineFront(client, form);
 
+  ok(front, "The TimelineFront was created");
+
   let isActive = yield front.isRecording();
-  ok(!isActive, "Not initially recording");
+  ok(!isActive, "The TimelineFront is not initially recording");
 
-  doc.body.innerHeight; // flush any pending reflow
+  info("Flush any pending reflows");
+  let forceSyncReflow = doc.body.innerHeight;
 
+  info("Start recording");
   yield front.start();
 
   isActive = yield front.isRecording();
-  ok(isActive, "Recording after start()");
+  ok(isActive, "The TimelineFront is now recording");
 
+  info("Change some style on the page to cause style/reflow/paint");
+  let onMarkers = once(front, "markers");
   doc.body.style.padding = "10px";
+  let markers = yield onMarkers;
 
-  let markers = yield once(front, "markers");
+  ok(true, "The markers event was fired");
+  ok(markers.length > 0, "Markers were returned");
+
+  info("Flush pending reflows again");
+  forceSyncReflow = doc.body.innerHeight;
+
+  info("Change some style on the page to cause style/paint");
+  onMarkers = once(front, "markers");
+  doc.body.style.backgroundColor = "red";
+  markers = yield onMarkers;
 
   ok(markers.length > 0, "markers were returned");
-  ok(markers.some(m => m.name == "Reflow"), "markers includes Reflow");
-  ok(markers.some(m => m.name == "Paint"), "markers includes Paint");
-  ok(markers.some(m => m.name == "Styles"), "markers includes Restyle");
-
-  doc.body.style.backgroundColor = "red";
-
-  markers = yield once(front, "markers");
-
-  ok(markers.length > 0, "markers were returned");
-  ok(!markers.some(m => m.name == "Reflow"), "markers doesn't include Reflow");
-  ok(markers.some(m => m.name == "Paint"), "markers includes Paint");
-  ok(markers.some(m => m.name == "Styles"), "markers includes Restyle");
 
   yield front.stop();
 
   isActive = yield front.isRecording();
   ok(!isActive, "Not recording after stop()");
 
   yield closeDebuggerClient(client);
   gBrowser.removeCurrentTab();