From 52f687379334718a4a410e6ce35d717fb45176a7 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Thu, 12 Mar 2015 11:41:41 -0700 Subject: [PATCH] Bug 1141817 - Fix yield statement to correctly return memory actor state so that the performance tool can poll for allocations during recording. r=vp --- browser/devtools/performance/modules/front.js | 2 +- .../performance/test/browser_perf-front.js | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/browser/devtools/performance/modules/front.js b/browser/devtools/performance/modules/front.js index 108f0421612c..a22280eb8636 100644 --- a/browser/devtools/performance/modules/front.js +++ b/browser/devtools/performance/modules/front.js @@ -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, diff --git a/browser/devtools/performance/test/browser_perf-front.js b/browser/devtools/performance/test/browser_perf-front.js index fae9bf7d1f08..7fa15ed5c5f3 100644 --- a/browser/devtools/performance/test/browser_perf-front.js +++ b/browser/devtools/performance/test/browser_perf-front.js @@ -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, @@ -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, @@ -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", @@ -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(); }