Backed out changeset f5d2323f5d65 (bug 1165994) for M-e10s(dt2) failure. r=backout

--HG--
rename : toolkit/devtools/server/tests/browser/browser_markers-cycle-collection.js => browser/devtools/performance/test/browser_markers-cycle-collection.js
rename : toolkit/devtools/server/tests/browser/browser_markers-gc.js => browser/devtools/performance/test/browser_markers-gc.js
rename : toolkit/devtools/server/tests/browser/browser_markers-parse-html.js => browser/devtools/performance/test/browser_markers-parse-html.js
rename : toolkit/devtools/server/tests/browser/browser_markers-styles.js => browser/devtools/performance/test/browser_markers-styles.js
rename : toolkit/devtools/server/tests/browser/browser_markers-timestamp.js => browser/devtools/performance/test/browser_markers-timestamp.js
rename : toolkit/devtools/server/tests/browser/doc_force_cc.html => browser/devtools/performance/test/doc_force_cc.html
rename : toolkit/devtools/server/tests/browser/doc_force_gc.html => browser/devtools/performance/test/doc_force_gc.html
This commit is contained in:
Sebastian Hengst 2015-08-21 19:55:00 +02:00
parent 26c67a63da
commit e0c960b99e
35 changed files with 330 additions and 313 deletions

View File

@ -3,6 +3,8 @@ tags = devtools
subsuite = devtools subsuite = devtools
support-files = support-files =
doc_allocs.html doc_allocs.html
doc_force_cc.html
doc_force_gc.html
doc_innerHTML.html doc_innerHTML.html
doc_markers.html doc_markers.html
doc_simple-test.html doc_simple-test.html
@ -12,6 +14,11 @@ support-files =
# that need to be moved over to performance tool # that need to be moved over to performance tool
[browser_aaa-run-first-leaktest.js] [browser_aaa-run-first-leaktest.js]
[browser_markers-cycle-collection.js]
[browser_markers-gc.js]
[browser_markers-parse-html.js]
[browser_markers-styles.js]
[browser_markers-timestamp.js]
[browser_perf-allocations-to-samples.js] [browser_perf-allocations-to-samples.js]
[browser_perf-categories-js-calltree.js] [browser_perf-categories-js-calltree.js]
[browser_perf-clear-01.js] [browser_perf-clear-01.js]

View File

@ -0,0 +1,54 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get "nsCycleCollector::Collect" and
* "nsCycleCollector::ForgetSkippable" markers when we force cycle collection.
*/
const TEST_URL = EXAMPLE_URL + "doc_force_cc.html"
function waitForMarkerType(front, type) {
info("Waiting for marker of type = " + type);
const { promise, resolve } = Promise.defer();
const handler = (name, data) => {
if (name !== "markers") {
return;
}
let markers = data.markers;
info("Got markers: " + JSON.stringify(markers, null, 2));
if (markers.some(m => m.name === type)) {
ok(true, "Found marker of type = " + type);
front.off("timeline-data", handler);
resolve();
}
};
front.on("timeline-data", handler);
return promise;
}
function* spawnTest () {
// This test runs very slowly on linux32 debug EC2 instances.
requestLongerTimeout(2);
let { target, front } = yield initBackend(TEST_URL);
let rec = yield front.startRecording({ withMarkers: true, withTicks: true });
yield Promise.all([
waitForMarkerType(front, "nsCycleCollector::Collect"),
waitForMarkerType(front, "nsCycleCollector::ForgetSkippable")
]);
ok(true, "Got expected cycle collection events");
yield front.stopRecording(rec);
// Destroy the front before removing tab to ensure no
// lingering requests
yield front.destroy();
yield removeTab(target.tab);
finish();
}

View File

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get a "GarbageCollection" marker.
*/
const TIME_CLOSE_TO = 10000;
const TEST_URL = EXAMPLE_URL + "doc_force_gc.html"
function* spawnTest () {
let { target, front } = yield initBackend(TEST_URL);
let markers;
front.on("timeline-data", handler);
let model = yield front.startRecording({ withTicks: true });
yield waitUntil(() => {
return !!markers;
}, 100);
front.off("timeline-data", handler);
yield front.stopRecording(model);
info(`Got ${markers.length} markers.`);
ok(markers.every(({name}) => name === "GarbageCollection"), "All markers found are GC markers");
ok(markers.length > 0, "found atleast one GC marker");
ok(markers.every(({start, end}) => typeof start === "number" && start > 0 && start < end),
"All markers have a start time between the valid range.");
ok(markers.every(({end}) => typeof end === "number"),
"All markers have an end time between the valid range.");
ok(markers.every(({causeName}) => typeof causeName === "string"),
"All markers have a causeName.");
// Destroy the front before removing tab to ensure no
// lingering requests
yield front.destroy();
yield removeTab(target.tab);
finish();
function handler (name, m) {
m = m.markers;
if (name === "markers" && m[0].name === "GarbageCollection") {
markers = m;
}
}
}

View File

@ -0,0 +1,46 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get a "Parse HTML" marker when a page sets innerHTML.
*/
const TEST_URL = EXAMPLE_URL + "doc_innerHTML.html"
function* spawnTest () {
let { target, front } = yield initBackend(TEST_URL);
let markers = [];
front.on("timeline-data", handler);
let model = yield front.startRecording({ withTicks: true });
yield waitUntil(() => {
return markers.length;
}, 100);
front.off("timeline-data", handler);
yield front.stopRecording(model);
info(`Got ${markers.length} markers.`);
ok(markers.every(({name}) => name === "Parse HTML"), "All markers found are Parse HTML markers");
// Destroy the front before removing tab to ensure no
// lingering requests
yield front.destroy();
yield removeTab(target.tab);
finish();
function handler (name, data) {
if (name !== "markers") {
return;
}
data.markers.forEach(marker => {
info(marker.name);
if (marker.name === "Parse HTML") {
markers.push(marker);
}
});
}
}

View File

@ -0,0 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get a "Styles" marker with the correct meta.
*/
function* spawnTest () {
let { target, front } = yield initBackend(SIMPLE_URL);
let markers = [];
front.on("timeline-data", handler);
let model = yield front.startRecording({ withTicks: true });
yield waitUntil(() => {
return markers.some(({restyleHint}) => restyleHint != void 0);
});
front.off("timeline-data", handler);
yield front.stopRecording(model);
info(`Got ${markers.length} markers.`);
ok(markers.every(({name}) => name === "Styles"), "All markers found are Styles markers");
ok(markers.length, "found some restyle markers");
ok(markers.some(({restyleHint}) => restyleHint != void 0), "some markers have a restyleHint property");
// Destroy the front before removing tab to ensure no
// lingering requests
yield front.destroy();
yield removeTab(target.tab);
finish();
function handler (name, data) {
if (name === "markers") {
markers = markers.concat(data.markers.filter(marker => marker.name === "Styles"));
}
}
}

View File

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get a "TimeStamp" marker.
*/
const TIME_CLOSE_TO = 10000;
function* spawnTest () {
let { target, front } = yield initBackend(SIMPLE_URL);
loadFrameScripts();
let markers = [];
front.on("timeline-data", handler);
let model = yield front.startRecording({ withTicks: true });
consoleMethod("timeStamp");
consoleMethod("timeStamp", "myLabel");
yield waitUntil(() => { return markers.length === 2; }, 100);
front.off("timeline-data", handler);
yield front.stopRecording(model);
info(`Got ${markers.length} markers.`);
let maxMarkerTime = model._timelineStartTime + model.getDuration() + TIME_CLOSE_TO;
ok(markers.every(({stack}) => typeof stack === "number"), "All markers have stack references.");
ok(markers.every(({name}) => name === "TimeStamp"), "All markers found are TimeStamp markers");
ok(markers.length === 2, "found 2 TimeStamp markers");
ok(markers.every(({start, end}) => typeof start === "number" && start === end),
"All markers have equal start and end times");
is(markers[0].causeName, void 0, "Unlabeled timestamps have an empty causeName");
is(markers[1].causeName, "myLabel", "Labeled timestamps have correct causeName");
// Destroy the front before removing tab to ensure no
// lingering requests
yield front.destroy();
yield removeTab(target.tab);
finish();
function handler (name, data) {
if (name === "markers") {
markers = markers.concat(data.markers.filter(marker => marker.name === "TimeStamp"));
}
}
}

View File

@ -7,7 +7,7 @@
*/ */
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL); let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView } = panel.panelWin; let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView } = panel.panelWin;

View File

@ -7,7 +7,7 @@
*/ */
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL); let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView } = panel.panelWin; let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView } = panel.panelWin;

View File

@ -6,7 +6,7 @@
*/ */
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL); let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView, WaterfallView } = panel.panelWin; let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView, WaterfallView } = panel.panelWin;

View File

@ -8,7 +8,7 @@
*/ */
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL); let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView, WaterfallView } = panel.panelWin; let { $, EVENTS, gFront, PerformanceController, OverviewView, RecordingsView, WaterfallView } = panel.panelWin;

View File

@ -22,7 +22,7 @@ function testRecordings (win, expected) {
} }
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL); let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, PerformanceController, OverviewView, RecordingsView, WaterfallView } = panel.panelWin; let { EVENTS, PerformanceController, OverviewView, RecordingsView, WaterfallView } = panel.panelWin;

View File

@ -7,7 +7,7 @@
*/ */
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL); let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let win = panel.panelWin; let win = panel.panelWin;
let { gFront, PerformanceController } = win; let { gFront, PerformanceController } = win;

View File

@ -7,7 +7,7 @@
* displayed. * displayed.
*/ */
function* spawnTest() { function* spawnTest() {
PMM_loadFrameScripts(gBrowser); loadFrameScripts();
// Keep it large, but still get to 1% relatively quick // Keep it large, but still get to 1% relatively quick
Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000000); Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000000);
let { panel } = yield initPerformance(SIMPLE_URL); let { panel } = yield initPerformance(SIMPLE_URL);

View File

@ -10,7 +10,7 @@ function* spawnTest() {
let { gFront, EVENTS, $, PerformanceController, PerformanceView } = panel.panelWin; let { gFront, EVENTS, $, PerformanceController, PerformanceView } = panel.panelWin;
// Make sure the profiler module is stopped so we can set a new buffer limit // Make sure the profiler module is stopped so we can set a new buffer limit
PMM_loadFrameScripts(gBrowser); PMM_loadProfilerScripts(gBrowser);
yield PMM_stopProfiler(); yield PMM_stopProfiler();
Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000); Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000);
// Set a fast profiler-status update interval // Set a fast profiler-status update interval

View File

@ -11,7 +11,7 @@ function* spawnTest() {
let { panel } = yield initPerformance(SIMPLE_URL); let { panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, PerformanceController } = panel.panelWin; let { EVENTS, PerformanceController } = panel.panelWin;
let front = panel.panelWin.gFront; let front = panel.panelWin.gFront;
PMM_loadFrameScripts(gBrowser); PMM_loadProfilerScripts(gBrowser);
ok(!(yield PMM_isProfilerActive()), ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started."); "The built-in profiler module should not have been automatically started.");

View File

@ -18,9 +18,8 @@ let { merge } = require("sdk/util/object");
let { createPerformanceFront } = require("devtools/server/actors/performance"); let { createPerformanceFront } = require("devtools/server/actors/performance");
let RecordingUtils = require("devtools/toolkit/performance/utils"); let RecordingUtils = require("devtools/toolkit/performance/utils");
let { let {
PMM_loadFrameScripts, PMM_isProfilerActive, PMM_stopProfiler, PMM_loadProfilerScripts, PMM_isProfilerActive, PMM_stopProfiler, sendProfilerCommand
sendProfilerCommand, consoleMethod } = require("devtools/toolkit/shared/profiler");
} = require("devtools/toolkit/performance/process-communication");
let mm = null; let mm = null;
@ -289,6 +288,21 @@ function busyWait(time) {
while (Date.now() - start < time) { stack = Components.stack; } while (Date.now() - start < time) { stack = Components.stack; }
} }
function consoleMethod (...args) {
if (!mm) {
throw new Error("`loadFrameScripts()` must be called before using frame scripts.");
}
// Terrible ugly hack -- this gets stringified when it uses the
// message manager, so an undefined arg in `console.profileEnd()`
// turns into a stringified "null", which is terrible. This method is only used
// for test helpers, so swap out the argument if its undefined with an empty string.
// Differences between empty string and undefined are tested on the front itself.
if (args[1] == null) {
args[1] = "";
}
mm.sendAsyncMessage("devtools:test:console", args);
}
function* consoleProfile(win, label) { function* consoleProfile(win, label) {
let profileStart = once(win.PerformanceController, win.EVENTS.RECORDING_STARTED); let profileStart = once(win.PerformanceController, win.EVENTS.RECORDING_STARTED);
consoleMethod("profile", label); consoleMethod("profile", label);

View File

@ -6,7 +6,6 @@
EXTRA_JS_MODULES.devtools.performance += [ EXTRA_JS_MODULES.devtools.performance += [
'io.js', 'io.js',
'process-communication.js',
'recorder.js', 'recorder.js',
'utils.js', 'utils.js',
] ]

View File

@ -1,73 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* The following functions are used in testing to control and inspect
* the nsIProfiler in child process content. These should be called from
* the parent process.
*/
const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js";
loader.lazyRequireGetter(this, "Task", "resource://gre/modules/Task.jsm", true);
loader.lazyRequireGetter(this, "uuid", "sdk/util/uuid", true);
let mm = null;
exports.consoleMethod = function (...args) {
if (!mm) {
throw new Error("`PMM_loadFrameScripts()` must be called before using frame scripts.");
}
// Terrible ugly hack -- this gets stringified when it uses the
// message manager, so an undefined arg in `console.profileEnd()`
// turns into a stringified "null", which is terrible. This method is only used
// for test helpers, so swap out the argument if its undefined with an empty string.
// Differences between empty string and undefined are tested on the front itself.
if (args[1] == null) {
args[1] = "";
}
mm.sendAsyncMessage("devtools:test:console", args);
};
exports.PMM_isProfilerActive = function () {
return sendProfilerCommand("IsActive");
};
exports.PMM_stopProfiler = function () {
return Task.spawn(function*() {
let isActive = (yield sendProfilerCommand("IsActive")).isActive;
if (isActive) {
return sendProfilerCommand("StopProfiler");
}
});
};
exports.PMM_loadFrameScripts = function (gBrowser) {
mm = gBrowser.selectedBrowser.messageManager;
mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
};
function sendProfilerCommand (method, args=[]) {
if (!mm) {
throw new Error("`PMM_loadFrameScripts()` must be called when using MessageManager.");
}
let id = uuid().toString();
return new Promise(resolve => {
mm.addMessageListener("devtools:test:profiler:response", handler);
mm.sendAsyncMessage("devtools:test:profiler", { method, args, id });
function handler ({ data }) {
if (id !== data.id) {
return;
}
mm.removeMessageListener("devtools:test:profiler:response", handler);
resolve(data.data);
}
});
}
exports.sendProfilerCommand = sendProfilerCommand;

View File

@ -4,9 +4,6 @@ subsuite = devtools
support-files = support-files =
head.js head.js
animation.html animation.html
doc_force_cc.html
doc_force_gc.html
doc_innerHTML.html
doc_perf.html doc_perf.html
navigate-first.html navigate-first.html
navigate-second.html navigate-second.html
@ -48,11 +45,6 @@ skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are
[browser_canvasframe_helper_05.js] [browser_canvasframe_helper_05.js]
skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are still disabled in E10S skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are still disabled in E10S
[browser_canvasframe_helper_06.js] [browser_canvasframe_helper_06.js]
[browser_markers-cycle-collection.js]
[browser_markers-gc.js]
[browser_markers-parse-html.js]
[browser_markers-styles.js]
[browser_markers-timestamp.js]
skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are still disabled in E10S skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are still disabled in E10S
[browser_navigateEvents.js] [browser_navigateEvents.js]
skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are still disabled in E10S skip-if = e10s # Bug 1183605 - toolkit/devtools/server/tests/browser/ tests are still disabled in E10S

View File

@ -1,32 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get "nsCycleCollector::Collect" and
* "nsCycleCollector::ForgetSkippable" markers when we force cycle collection.
*/
const { PerformanceFront } = require("devtools/server/actors/performance");
add_task(function*() {
// This test runs very slowly on linux32 debug EC2 instances.
requestLongerTimeout(2);
let doc = yield addTab(MAIN_DOMAIN + "doc_force_cc.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
let markers = yield waitForMarkerType(front, ["nsCycleCollector::Collect", "nsCycleCollector::ForgetSkippable"])
yield front.stopRecording(rec);
ok(markers.some(m => m.name === "nsCycleCollector::Collect"), "got some nsCycleCollector::Collect markers");
ok(markers.some(m => m.name === "nsCycleCollector::ForgetSkippable"), "got some nsCycleCollector::Collect markers");
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});

View File

@ -1,30 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get "GarbageCollection" markers.
*/
const { PerformanceFront } = require("devtools/server/actors/performance");
const MARKER_NAME = "GarbageCollection";
add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "doc_force_gc.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
let markers = yield waitForMarkerType(front, MARKER_NAME);
yield front.stopRecording(rec);
ok(markers.some(m => m.name === MARKER_NAME), `got some ${MARKER_NAME} markers`);
ok(markers.every(({causeName}) => typeof causeName === "string"),
"All markers have a causeName.");
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});

View File

@ -1,28 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get "Parse HTML" markers.
*/
const { PerformanceFront } = require("devtools/server/actors/performance");
const MARKER_NAME = "Parse HTML";
add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "doc_innerHTML.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
let markers = yield waitForMarkerType(front, MARKER_NAME);
yield front.stopRecording(rec);
ok(markers.some(m => m.name === MARKER_NAME), `got some ${MARKER_NAME} markers`);
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});

View File

@ -1,33 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get "Styles" markers with correct meta.
*/
const { PerformanceFront } = require("devtools/server/actors/performance");
const MARKER_NAME = "Styles";
add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
let markers = yield waitForMarkerType(front, MARKER_NAME, function (markers) {
return markers.some(({restyleHint}) => restyleHint != void 0);
});
yield front.stopRecording(rec);
ok(markers.some(m => m.name === MARKER_NAME), `got some ${MARKER_NAME} markers`);
ok(markers.some(({restyleHint}) => restyleHint != void 0),
"Some markers have a restyleHint.");
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});

View File

@ -1,40 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we get a "TimeStamp" marker.
*/
const { PerformanceFront } = require("devtools/server/actors/performance");
const { consoleMethod, PMM_loadFrameScripts } = require("devtools/toolkit/performance/process-communication");
const MARKER_NAME = "TimeStamp";
add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
PMM_loadFrameScripts(gBrowser);
consoleMethod("timeStamp");
consoleMethod("timeStamp", "myLabel");
let markers = yield waitForMarkerType(front, MARKER_NAME, markers => markers.length >= 2);
yield front.stopRecording(rec);
ok(markers.every(({stack}) => typeof stack === "number"), "All markers have stack references.");
ok(markers.every(({name}) => name === "TimeStamp"), "All markers found are TimeStamp markers");
ok(markers.length === 2, "found 2 TimeStamp markers");
ok(markers.every(({start, end}) => typeof start === "number" && start === end),
"All markers have equal start and end times");
is(markers[0].causeName, void 0, "Unlabeled timestamps have an empty causeName");
is(markers[1].causeName, "myLabel", "Labeled timestamps have correct causeName");
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});

View File

@ -9,6 +9,7 @@ let WAIT_TIME = 100;
const { TargetFactory } = require("devtools/framework/target"); const { TargetFactory } = require("devtools/framework/target");
const { LegacyPerformanceFront } = require("devtools/toolkit/performance/legacy/front"); const { LegacyPerformanceFront } = require("devtools/toolkit/performance/legacy/front");
const { defer } = require("sdk/core/promise");
const { merge } = require("sdk/util/object"); const { merge } = require("sdk/util/object");
add_task(function*() { add_task(function*() {

View File

@ -9,6 +9,7 @@ let WAIT_TIME = 100;
const { TargetFactory } = require("devtools/framework/target"); const { TargetFactory } = require("devtools/framework/target");
const { LegacyPerformanceFront } = require("devtools/toolkit/performance/legacy/front"); const { LegacyPerformanceFront } = require("devtools/toolkit/performance/legacy/front");
const { defer } = require("sdk/core/promise");
const { merge } = require("sdk/util/object"); const { merge } = require("sdk/util/object");
add_task(function*() { add_task(function*() {

View File

@ -8,7 +8,7 @@
*/ */
const { PerformanceFront } = require("devtools/server/actors/performance"); const { PerformanceFront } = require("devtools/server/actors/performance");
const { sendProfilerCommand, PMM_isProfilerActive, PMM_stopProfiler, PMM_loadFrameScripts } = require("devtools/toolkit/performance/process-communication"); const { PMM_isProfilerActive, PMM_stopProfiler, PMM_loadProfilerScripts } = require("devtools/toolkit/shared/profiler");
add_task(function*() { add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "doc_perf.html"); let doc = yield addTab(MAIN_DOMAIN + "doc_perf.html");
@ -19,7 +19,7 @@ add_task(function*() {
let front = PerformanceFront(client, form); let front = PerformanceFront(client, form);
yield front.connect(); yield front.connect();
PMM_loadFrameScripts(gBrowser); PMM_loadProfilerScripts(gBrowser);
ok(!(yield PMM_isProfilerActive()), ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started."); "The built-in profiler module should not have been automatically started.");

View File

@ -7,7 +7,7 @@
*/ */
const { PerformanceFront } = require("devtools/server/actors/performance"); const { PerformanceFront } = require("devtools/server/actors/performance");
const { sendProfilerCommand, PMM_isProfilerActive, PMM_stopProfiler, PMM_loadFrameScripts } = require("devtools/toolkit/performance/process-communication"); const { PMM_isProfilerActive, PMM_stopProfiler, PMM_loadProfilerScripts } = require("devtools/toolkit/shared/profiler");
add_task(function*() { add_task(function*() {
yield addTab(MAIN_DOMAIN + "doc_perf.html"); yield addTab(MAIN_DOMAIN + "doc_perf.html");
@ -17,7 +17,7 @@ add_task(function*() {
let firstFront = PerformanceFront(client, form); let firstFront = PerformanceFront(client, form);
yield firstFront.connect(); yield firstFront.connect();
PMM_loadFrameScripts(gBrowser); PMM_loadProfilerScripts(gBrowser);
yield firstFront.startRecording(); yield firstFront.startRecording();
@ -26,7 +26,7 @@ add_task(function*() {
let form2 = yield connectDebuggerClient(client2); let form2 = yield connectDebuggerClient(client2);
let secondFront = PerformanceFront(client2, form2); let secondFront = PerformanceFront(client2, form2);
yield secondFront.connect(); yield secondFront.connect();
PMM_loadFrameScripts(gBrowser); PMM_loadProfilerScripts(gBrowser);
yield secondFront.startRecording(); yield secondFront.startRecording();

View File

@ -9,11 +9,11 @@
*/ */
const { PerformanceFront } = require("devtools/server/actors/performance"); const { PerformanceFront } = require("devtools/server/actors/performance");
const { sendProfilerCommand, PMM_isProfilerActive, PMM_stopProfiler, PMM_loadFrameScripts } = require("devtools/toolkit/performance/process-communication"); const { sendProfilerCommand, PMM_isProfilerActive, PMM_stopProfiler, PMM_loadProfilerScripts } = require("devtools/toolkit/shared/profiler");
add_task(function*() { add_task(function*() {
// Ensure the profiler is already running when the test starts. // Ensure the profiler is already running when the test starts.
PMM_loadFrameScripts(gBrowser); PMM_loadProfilerScripts(gBrowser);
let ENTRIES = 1000000; let ENTRIES = 1000000;
let INTERVAL = 1; let INTERVAL = 1;
let FEATURES = ["js"]; let FEATURES = ["js"];

View File

@ -6,6 +6,7 @@
*/ */
const { PerformanceFront } = require("devtools/server/actors/performance"); const { PerformanceFront } = require("devtools/server/actors/performance");
const { defer } = require("sdk/core/promise");
add_task(function*() { add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "doc_perf.html"); let doc = yield addTab(MAIN_DOMAIN + "doc_perf.html");

View File

@ -1,20 +0,0 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Performance tool + innerHTML test page</title>
</head>
<body>
<script type="text/javascript">
window.test = function () {
document.body.innerHTML = "<h1>LOL</h1>";
};
setInterval(window.test, 100);
</script>
</body>
</html>

View File

@ -11,7 +11,6 @@ const {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const {DebuggerClient} = require("devtools/toolkit/client/main"); const {DebuggerClient} = require("devtools/toolkit/client/main");
const {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
const {defer} = require("sdk/core/promise");
const DevToolsUtils = require("devtools/toolkit/DevToolsUtils"); const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
const PATH = "browser/toolkit/devtools/server/tests/browser/"; const PATH = "browser/toolkit/devtools/server/tests/browser/";
@ -40,7 +39,7 @@ let addTab = Task.async(function* (url) {
yield new Promise(resolve => { yield new Promise(resolve => {
let isBlank = url == "about:blank"; let isBlank = url == "about:blank";
waitForFocus(resolve, content, isBlank); waitForFocus(resolve, content, isBlank);
}); });;
return tab.linkedBrowser.contentWindow.document; return tab.linkedBrowser.contentWindow.document;
}); });
@ -169,30 +168,4 @@ function waitUntil(predicate, interval = 10) {
}); });
} }
function waitForMarkerType(front, types, predicate) { // EventUtils just doesn't work!
types = [].concat(types);
predicate = predicate || function(){ return true; };
let filteredMarkers = [];
let { promise, resolve } = defer();
info("Waiting for markers of type: " + types);
function handler (name, data) {
if (name !== "markers") {
return;
}
let markers = data.markers;
info("Got markers: " + JSON.stringify(markers, null, 2));
filteredMarkers = filteredMarkers.concat(markers.filter(m => types.indexOf(m.name) !== -1));
if (types.every(t => filteredMarkers.some(m => m.name === t)) && predicate(filteredMarkers)) {
front.off("timeline-data", handler);
resolve(filteredMarkers);
}
}
front.on("timeline-data", handler);
return promise;
}

View File

@ -6,11 +6,13 @@
const { Cc, Ci, Cu } = require("chrome"); const { Cc, Ci, Cu } = require("chrome");
const Services = require("Services"); const Services = require("Services");
const { Class } = require("sdk/core/heritage"); const { Class } = require("sdk/core/heritage");
const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js";
loader.lazyRequireGetter(this, "events", "sdk/event/core"); loader.lazyRequireGetter(this, "events", "sdk/event/core");
loader.lazyRequireGetter(this, "EventTarget", "sdk/event/target", true); loader.lazyRequireGetter(this, "EventTarget", "sdk/event/target", true);
loader.lazyRequireGetter(this, "DevToolsUtils", "devtools/toolkit/DevToolsUtils.js"); loader.lazyRequireGetter(this, "DevToolsUtils", "devtools/toolkit/DevToolsUtils.js");
loader.lazyRequireGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm", true); loader.lazyRequireGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm", true);
loader.lazyRequireGetter(this, "Task", "resource://gre/modules/Task.jsm", true); loader.lazyRequireGetter(this, "Task", "resource://gre/modules/Task.jsm", true);
loader.lazyRequireGetter(this, "uuid", "sdk/util/uuid", true);
// Events piped from system observers to Profiler instances. // Events piped from system observers to Profiler instances.
const PROFILER_SYSTEM_EVENTS = [ const PROFILER_SYSTEM_EVENTS = [
@ -515,3 +517,49 @@ function sanitizeHandler (handler, identifier) {
return handler.call(this, subject, topic, data); return handler.call(this, subject, topic, data);
}, identifier); }, identifier);
} }
/**
* The following functions are used in testing to control and inspect
* the nsIProfiler in child process content. These should be called from
* the parent process.
*/
let mm = null;
exports.PMM_isProfilerActive = function () {
return sendProfilerCommand("IsActive");
}
exports.PMM_stopProfiler = function () {
return Task.spawn(function*() {
let isActive = (yield sendProfilerCommand("IsActive")).isActive;
if (isActive) {
return sendProfilerCommand("StopProfiler");
}
});
}
exports.PMM_loadProfilerScripts = function (gBrowser) {
mm = gBrowser.selectedBrowser.messageManager;
mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
};
function sendProfilerCommand (method, args=[]) {
if (!mm) {
throw new Error("`loadFrameScripts()` must be called when using MessageManager.");
}
let id = uuid().toString();
return new Promise(resolve => {
mm.addMessageListener("devtools:test:profiler:response", handler);
mm.sendAsyncMessage("devtools:test:profiler", { method, args, id });
function handler ({ data }) {
if (id !== data.id) {
return;
}
mm.removeMessageListener("devtools:test:profiler:response", handler);
resolve(data.data);
}
});
}
exports.sendProfilerCommand = sendProfilerCommand;