Bug 1066474 - Make browser_timeline.js not fail intermittently. r=paul
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 16 Dec 2014 12:37:00 -0500
changeset 220236 396c9b403e26e0eb53dde463506a647fd12105b9
parent 220235 b23e9e43fb8adc1c66668f5d5aedb128f71e6fb7
child 220237 0d78284bbf8b0801f1adcc6e4845d83fbd6b7012
push id10459
push userryanvm@gmail.com
push dateThu, 18 Dec 2014 02:56:54 +0000
treeherderfx-team@14e17056fc81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul
bugs1066474
milestone37.0a1
Bug 1066474 - Make browser_timeline.js not fail intermittently. r=paul
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");
 
 add_task(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();