Bug 1058898 - Enable e10s tests on the performance tool. r=vp

This commit is contained in:
Jordan Santell 2015-05-10 01:20:56 -07:00
parent 78f2cfeb51
commit 0bbbd5be84
10 changed files with 94 additions and 35 deletions

View File

@ -1,6 +1,5 @@
[DEFAULT]
tags = devtools
skip-if = e10s # Handle in Bug 1077464 for profiler
subsuite = devtools
support-files =
doc_innerHTML.html
@ -10,9 +9,10 @@ support-files =
# Commented out tests are profiler tests
# that need to be moved over to performance tool
[browser_perf-aaa-run-first-leaktest.js]
[browser_aaa-run-first-leaktest.js]
[browser_marker-utils.js]
[browser_markers-gc.js]
skip-if = e10s # GC events seem unreliable in multiprocess
[browser_markers-parse-html.js]
[browser_markers-styles.js]
[browser_markers-timestamp.js]

View File

@ -10,28 +10,32 @@
let test = Task.async(function*() {
let { target, panel, toolbox } = yield initPerformance(SIMPLE_URL);
let front = panel.panelWin.gFront;
loadFrameScripts();
ok(!nsIProfilerModule.IsActive(),
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started.");
let activated = front.once("profiler-activated");
let rec = yield front.startRecording();
yield activated;
yield front.stopRecording(rec);
ok(nsIProfilerModule.IsActive(),
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active (1).");
let alreadyActive = front.once("profiler-already-active");
rec = yield front.startRecording();
yield alreadyActive;
yield front.stopRecording(rec);
ok(nsIProfilerModule.IsActive(),
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active (2).");
yield teardown(panel);
ok(!nsIProfilerModule.IsActive(),
"The built-in profiler module should have been automatically stoped.");
// Manually tear down so we can check profiler status
let tab = panel.target.tab;
yield panel._toolbox.destroy();
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should no longer be active.");
yield removeTab(tab);
tab = null;
finish();
});

View File

@ -16,18 +16,25 @@ let test = Task.async(function*() {
let { panel: secondPanel } = yield initPerformance(SIMPLE_URL);
let secondFront = secondPanel.panelWin.gFront;
loadFrameScripts();
let alreadyActive = secondFront.once("profiler-already-active");
yield secondFront.startRecording();
yield alreadyActive;
yield teardown(firstPanel);
ok(nsIProfilerModule.IsActive(),
// Manually teardown the tabs so we can check profiler status
let tab1 = firstPanel.target.tab;
let tab2 = secondPanel.target.tab;
yield firstPanel._toolbox.destroy();
yield removeTab(tab1);
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active.");
yield teardown(secondPanel);
ok(!nsIProfilerModule.IsActive(),
"The built-in profiler module should have been automatically stoped.");
yield secondPanel._toolbox.destroy();
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should no longer be active.");
yield removeTab(tab2);
tab1 = tab2 = null;
finish();
});

View File

@ -10,10 +10,11 @@
let test = Task.async(function*() {
// Ensure the profiler is already running when the test starts.
loadFrameScripts();
let ENTRIES = 1000000;
let INTERVAL = 1;
let FEATURES = ["js"];
nsIProfilerModule.StartProfiler(ENTRIES, INTERVAL, FEATURES, FEATURES.length);
yield sendProfilerCommand("StartProfiler", [ENTRIES, INTERVAL, FEATURES, FEATURES.length]);
let { panel: firstPanel } = yield initPerformance(SIMPLE_URL);
let firstFront = firstPanel.panelWin.gFront;
@ -32,11 +33,11 @@ let test = Task.async(function*() {
ok(secondRecording._profilerStartTime > 0, "The profiler was not restarted.");
yield teardown(firstPanel);
ok(nsIProfilerModule.IsActive(),
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active.");
yield teardown(secondPanel);
ok(!nsIProfilerModule.IsActive(),
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should have been automatically stoped.");
finish();

View File

@ -6,13 +6,14 @@
* a class is assigned to the recording notices.
*/
function spawnTest () {
// Make sure the profiler module is stopped so we can set a new buffer limit
nsIProfilerModule.StopProfiler();
Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000);
let { panel } = yield initPerformance(SIMPLE_URL, void 0, { TEST_MOCK_PROFILER_CHECK_TIMER: 10 });
let { EVENTS, $, PerformanceController, PerformanceView } = panel.panelWin;
// Make sure the profiler module is stopped so we can set a new buffer limit
loadFrameScripts();
yield PMM_stopProfiler();
Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000);
yield startRecording(panel);
let percent = 0;

View File

@ -9,19 +9,21 @@ function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL);
let front = panel.panelWin.gFront;
ok(!nsIProfilerModule.IsActive(),
loadFrameScripts();
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started.");
let result = yield front._request("profiler", "startProfiler");
is(result.started, true,
"The request finished successfully and the profiler should've been started.");
ok(nsIProfilerModule.IsActive(),
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should now be active.");
result = yield front._request("profiler", "stopProfiler");
is(result.started, false,
"The request finished successfully and the profiler should've been stopped.");
ok(!nsIProfilerModule.IsActive(),
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should now be inactive.");
yield teardown(panel);

View File

@ -11,19 +11,20 @@ function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, PerformanceController } = panel.panelWin;
let front = panel.panelWin.gFront;
loadFrameScripts();
ok(!nsIProfilerModule.IsActive(),
ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started.");
yield startRecording(panel);
busyWait(WAIT_TIME); // allow the profiler module to sample some cpu activity
ok(nsIProfilerModule.IsActive(),
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should now be active.");
yield stopRecording(panel);
ok(nsIProfilerModule.IsActive(),
ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active.");
yield teardown(panel);

View File

@ -13,10 +13,10 @@ let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let { DevToolsUtils } = Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm", {});
let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
let { merge } = devtools.require("sdk/util/object");
let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
let { getPerformanceActorsConnection, PerformanceFront } = devtools.require("devtools/performance/front");
let nsIProfilerModule = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
let TargetFactory = devtools.TargetFactory;
let mm = null;
const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js"
@ -71,9 +71,7 @@ Services.prefs.setBoolPref("devtools.debugger.log", false);
/**
* Call manually in tests that use frame script utils after initializing
* the tool. Must be called after initializing so we can detect
* whether or not `content` is a CPOW or not. Call after init but before navigating
* to different pages.
* the tool. Must be called after initializing (once we have a tab).
*/
function loadFrameScripts () {
mm = gBrowser.selectedBrowser.messageManager;
@ -89,9 +87,6 @@ registerCleanupFunction(() => {
Preferences.set(pref, DEFAULT_PREFS[pref]);
});
// Make sure the profiler module is stopped when the test finishes.
nsIProfilerModule.StopProfiler();
Cu.forceGC();
});
@ -577,3 +572,39 @@ function synthesizeProfileForTest(samples) {
markers: []
}, uniqueStacks);
}
function PMM_isProfilerActive () {
return sendProfilerCommand("IsActive");
}
function PMM_stopProfiler () {
return Task.spawn(function*() {
let isActive = (yield sendProfilerCommand("IsActive")).isActive;
if (isActive) {
return sendProfilerCommand("StopProfiler");
}
});
}
function sendProfilerCommand (method, args=[]) {
let deferred = Promise.defer();
if (!mm) {
throw new Error("`loadFrameScripts()` must be called when using MessageManager.");
}
let id = generateUUID().toString();
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);
deferred.resolve(data.data);
}
return deferred.promise;
}

View File

@ -11,6 +11,9 @@ const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
let EventUtils = {};
loader.loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils);
devtools.lazyGetter(this, "nsIProfilerModule", () => {
return Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
});
addMessageListener("devtools:test:history", function ({ data }) {
content.history[data.direction]();
@ -103,6 +106,15 @@ addMessageListener("devtools:test:xhr", Task.async(function* ({ data }) {
sendAsyncMessage("devtools:test:xhr", responses);
}));
addMessageListener("devtools:test:profiler", function ({ data: { method, args, id }}) {
let result = nsIProfilerModule[method](...args);
sendAsyncMessage("devtools:test:profiler:response", {
data: result,
id: id
});
});
// To eval in content, look at `evalInDebuggee` in the head.js of canvasdebugger
// for an example.
addMessageListener("devtools:test:eval", function ({ data }) {