2014-09-09 19:43:39 +00:00
|
|
|
/* 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/ */
|
2014-09-18 09:12:33 +00:00
|
|
|
|
2014-09-09 19:43:39 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-09-18 09:12:33 +00:00
|
|
|
// 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.
|
2014-12-16 17:37:00 +00:00
|
|
|
// 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.
|
2014-09-18 09:12:33 +00:00
|
|
|
|
|
|
|
const {TimelineFront} = require("devtools/server/actors/timeline");
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2016-05-17 18:25:54 +00:00
|
|
|
add_task(function* () {
|
2016-01-07 18:40:41 +00:00
|
|
|
let browser = yield addTab("data:text/html;charset=utf-8,mop");
|
|
|
|
let doc = browser.contentDocument;
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-09-18 09:12:33 +00:00
|
|
|
initDebuggerServer();
|
2014-09-09 19:43:39 +00:00
|
|
|
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
2014-09-18 09:12:33 +00:00
|
|
|
let form = yield connectDebuggerClient(client);
|
2014-09-09 19:43:39 +00:00
|
|
|
let front = TimelineFront(client, form);
|
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
ok(front, "The TimelineFront was created");
|
|
|
|
|
2014-09-09 19:43:39 +00:00
|
|
|
let isActive = yield front.isRecording();
|
2014-12-16 17:37:00 +00:00
|
|
|
ok(!isActive, "The TimelineFront is not initially recording");
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
info("Flush any pending reflows");
|
|
|
|
let forceSyncReflow = doc.body.innerHeight;
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
info("Start recording");
|
2015-11-11 22:11:40 +00:00
|
|
|
yield front.start({ withMarkers: true });
|
2014-09-09 19:43:39 +00:00
|
|
|
|
|
|
|
isActive = yield front.isRecording();
|
2014-12-16 17:37:00 +00:00
|
|
|
ok(isActive, "The TimelineFront is now recording");
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
info("Change some style on the page to cause style/reflow/paint");
|
|
|
|
let onMarkers = once(front, "markers");
|
2014-09-09 19:43:39 +00:00
|
|
|
doc.body.style.padding = "10px";
|
2014-12-16 17:37:00 +00:00
|
|
|
let markers = yield onMarkers;
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
ok(true, "The markers event was fired");
|
|
|
|
ok(markers.length > 0, "Markers were returned");
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
info("Flush pending reflows again");
|
|
|
|
forceSyncReflow = doc.body.innerHeight;
|
2014-09-09 19:43:39 +00:00
|
|
|
|
2014-12-16 17:37:00 +00:00
|
|
|
info("Change some style on the page to cause style/paint");
|
|
|
|
onMarkers = once(front, "markers");
|
2014-09-09 19:43:39 +00:00
|
|
|
doc.body.style.backgroundColor = "red";
|
2014-12-16 17:37:00 +00:00
|
|
|
markers = yield onMarkers;
|
2014-09-09 19:43:39 +00:00
|
|
|
|
|
|
|
ok(markers.length > 0, "markers were returned");
|
|
|
|
|
|
|
|
yield front.stop();
|
|
|
|
|
|
|
|
isActive = yield front.isRecording();
|
|
|
|
ok(!isActive, "Not recording after stop()");
|
|
|
|
|
2014-09-18 09:12:33 +00:00
|
|
|
yield closeDebuggerClient(client);
|
2014-09-09 19:43:39 +00:00
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
});
|