Skip to content

Commit

Permalink
Bug 1141817 - Fix yield statement to correctly return memory actor st…
Browse files Browse the repository at this point in the history
…ate so that the performance tool can poll for allocations during recording. r=vp
  • Loading branch information
jsantell committed Mar 12, 2015
1 parent b64b2d9 commit 52f6873
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser/devtools/performance/modules/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ PerformanceFront.prototype = {
*/
_pullAllocationSites: Task.async(function *() {
let memoryData = yield this._request("memory", "getAllocations");
let isStillAttached = yield this._request("memory", "getState") == "attached";
let isStillAttached = (yield this._request("memory", "getState")) === "attached";

this.emit("allocations", {
sites: memoryData.allocations,
Expand Down
17 changes: 16 additions & 1 deletion browser/devtools/performance/test/browser_perf-front.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ let WAIT_TIME = 1000;
function spawnTest () {
let { target, front } = yield initBackend(SIMPLE_URL);

let count = 0;
let counter = () => count++;

let {
profilerStartTime,
timelineStartTime,
Expand All @@ -25,7 +28,14 @@ function spawnTest () {
ok(typeof memoryStartTime === "number",
"The front.startRecording() emits a memory start time.");

yield busyWait(WAIT_TIME);
// Record allocation events to ensure it's called more than once
// so we know it's polling
front.on("allocations", counter);

yield Promise.all([
busyWait(WAIT_TIME),
waitUntil(() => count > 1)
]);

let {
profilerEndTime,
Expand All @@ -35,6 +45,8 @@ function spawnTest () {
withAllocations: true
});

front.off("allocations", counter);

ok(typeof profilerEndTime === "number",
"The front.stopRecording() emits a profiler end time.");
ok(typeof timelineEndTime === "number",
Expand All @@ -49,6 +61,9 @@ function spawnTest () {
ok(memoryEndTime > memoryStartTime,
"The memoryEndTime is after memoryStartTime.");

is((yield front._request("memory", "getState")), "detached",
"memory actor is detached when stopping recording with allocations");

yield removeTab(target.tab);
finish();
}

0 comments on commit 52f6873

Please sign in to comment.