Bug 1165994 - Move marker tests to server side, pull out e10s process communication helpers into their own file. r=vp

--HG--
rename : browser/devtools/performance/test/browser_markers-cycle-collection.js => toolkit/devtools/server/tests/browser/browser_markers-cycle-collection.js
rename : browser/devtools/performance/test/browser_markers-gc.js => toolkit/devtools/server/tests/browser/browser_markers-gc.js
rename : browser/devtools/performance/test/browser_markers-parse-html.js => toolkit/devtools/server/tests/browser/browser_markers-parse-html.js
rename : browser/devtools/performance/test/browser_markers-styles.js => toolkit/devtools/server/tests/browser/browser_markers-styles.js
rename : browser/devtools/performance/test/browser_markers-timestamp.js => toolkit/devtools/server/tests/browser/browser_markers-timestamp.js
rename : browser/devtools/performance/test/doc_force_cc.html => toolkit/devtools/server/tests/browser/doc_force_cc.html
rename : browser/devtools/performance/test/doc_force_gc.html => toolkit/devtools/server/tests/browser/doc_force_gc.html
This commit is contained in:
Jordan Santell 2015-08-19 09:49:41 -07:00
Родитель e0c960b99e
Коммит 39c4419032
35 изменённых файлов: 313 добавлений и 330 удалений

Просмотреть файл

@ -3,8 +3,6 @@ tags = devtools
subsuite = devtools
support-files =
doc_allocs.html
doc_force_cc.html
doc_force_gc.html
doc_innerHTML.html
doc_markers.html
doc_simple-test.html
@ -14,11 +12,6 @@ support-files =
# that need to be moved over to performance tool
[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-categories-js-calltree.js]
[browser_perf-clear-01.js]

Просмотреть файл

@ -1,54 +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 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();
}

Просмотреть файл

@ -1,48 +0,0 @@
/* 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;
}
}
}

Просмотреть файл

@ -1,46 +0,0 @@
/* 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);
}
});
}
}

Просмотреть файл

@ -1,41 +0,0 @@
/* 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"));
}
}
}

Просмотреть файл

@ -1,48 +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 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"));
}
}
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -18,8 +18,9 @@ let { merge } = require("sdk/util/object");
let { createPerformanceFront } = require("devtools/server/actors/performance");
let RecordingUtils = require("devtools/toolkit/performance/utils");
let {
PMM_loadProfilerScripts, PMM_isProfilerActive, PMM_stopProfiler, sendProfilerCommand
} = require("devtools/toolkit/shared/profiler");
PMM_loadFrameScripts, PMM_isProfilerActive, PMM_stopProfiler,
sendProfilerCommand, consoleMethod
} = require("devtools/toolkit/performance/process-communication");
let mm = null;
@ -288,21 +289,6 @@ function busyWait(time) {
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) {
let profileStart = once(win.PerformanceController, win.EVENTS.RECORDING_STARTED);
consoleMethod("profile", label);

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,73 @@
/* 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;

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,32 @@
/* 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();
});

Просмотреть файл

@ -0,0 +1,30 @@
/* 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();
});

Просмотреть файл

@ -0,0 +1,28 @@
/* 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();
});

Просмотреть файл

@ -0,0 +1,33 @@
/* 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();
});

Просмотреть файл

@ -0,0 +1,40 @@
/* 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();
});

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,20 @@
<!-- 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>

Просмотреть файл

@ -11,6 +11,7 @@ const {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const {DebuggerClient} = require("devtools/toolkit/client/main");
const {DebuggerServer} = require("devtools/server/main");
const {defer} = require("sdk/core/promise");
const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
const PATH = "browser/toolkit/devtools/server/tests/browser/";
@ -39,7 +40,7 @@ let addTab = Task.async(function* (url) {
yield new Promise(resolve => {
let isBlank = url == "about:blank";
waitForFocus(resolve, content, isBlank);
});;
});
return tab.linkedBrowser.contentWindow.document;
});
@ -168,4 +169,30 @@ function waitUntil(predicate, interval = 10) {
});
}
// EventUtils just doesn't work!
function waitForMarkerType(front, types, predicate) {
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;
}

Просмотреть файл

@ -6,13 +6,11 @@
const { Cc, Ci, Cu } = require("chrome");
const Services = require("Services");
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, "EventTarget", "sdk/event/target", true);
loader.lazyRequireGetter(this, "DevToolsUtils", "devtools/toolkit/DevToolsUtils.js");
loader.lazyRequireGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.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.
const PROFILER_SYSTEM_EVENTS = [
@ -517,49 +515,3 @@ function sanitizeHandler (handler, identifier) {
return handler.call(this, subject, topic, data);
}, 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;