Backed out changeset 82fac7af188e (bug 1184486) for Static Analysis failures.
This commit is contained in:
@@ -49,7 +49,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "finalizer",
|
|||||||
// and that we can release/close the probes it holds.
|
// and that we can release/close the probes it holds.
|
||||||
const FINALIZATION_TOPIC = "performancemonitor-finalize";
|
const FINALIZATION_TOPIC = "performancemonitor-finalize";
|
||||||
|
|
||||||
const PROPERTIES_META_IMMUTABLE = ["addonId", "isSystem", "isChildProcess", "groupId", "processId"];
|
const PROPERTIES_META_IMMUTABLE = ["addonId", "isSystem", "isChildProcess", "groupId"];
|
||||||
const PROPERTIES_META = [...PROPERTIES_META_IMMUTABLE, "windowId", "title", "name"];
|
const PROPERTIES_META = [...PROPERTIES_META_IMMUTABLE, "windowId", "title", "name"];
|
||||||
|
|
||||||
// How long we wait for children processes to respond.
|
// How long we wait for children processes to respond.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* All values are monotonic and are updated only when
|
* All values are monotonic and are updated only when
|
||||||
* `nsIPerformanceStatsService.isStopwatchActive` is `true`.
|
* `nsIPerformanceStatsService.isStopwatchActive` is `true`.
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(80e638bf-db19-4550-97bd-06e1f74c1c1f)]
|
[scriptable, uuid(1bc2d016-e9ae-4186-97c6-9478eddda245)]
|
||||||
interface nsIPerformanceStats: nsISupports {
|
interface nsIPerformanceStats: nsISupports {
|
||||||
/**
|
/**
|
||||||
* An identifier unique to the component.
|
* An identifier unique to the component.
|
||||||
@@ -91,11 +91,6 @@ interface nsIPerformanceStats: nsISupports {
|
|||||||
*/
|
*/
|
||||||
readonly attribute bool isSystem;
|
readonly attribute bool isSystem;
|
||||||
|
|
||||||
/**
|
|
||||||
* The process running this group.
|
|
||||||
*/
|
|
||||||
readonly attribute unsigned long long processId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jank indicator.
|
* Jank indicator.
|
||||||
*
|
*
|
||||||
@@ -109,7 +104,7 @@ interface nsIPerformanceStats: nsISupports {
|
|||||||
/**
|
/**
|
||||||
* A snapshot of the performance data of the process.
|
* A snapshot of the performance data of the process.
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(2e0c50e2-3aff-4cc8-88a6-c0dc200da8fc)]
|
[scriptable, uuid(29ecebd0-908a-4b34-8f62-a6015dea1141)]
|
||||||
interface nsIPerformanceSnapshot: nsISupports {
|
interface nsIPerformanceSnapshot: nsISupports {
|
||||||
/**
|
/**
|
||||||
* Data on all individual components.
|
* Data on all individual components.
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public:
|
|||||||
const nsAString& aAddonId,
|
const nsAString& aAddonId,
|
||||||
const nsAString& aTitle,
|
const nsAString& aTitle,
|
||||||
const uint64_t aWindowId,
|
const uint64_t aWindowId,
|
||||||
const uint64_t aProcessId,
|
|
||||||
const bool aIsSystem,
|
const bool aIsSystem,
|
||||||
const js::PerformanceData& aPerformanceData)
|
const js::PerformanceData& aPerformanceData)
|
||||||
: mName(aName)
|
: mName(aName)
|
||||||
@@ -43,7 +42,6 @@ public:
|
|||||||
, mAddonId(aAddonId)
|
, mAddonId(aAddonId)
|
||||||
, mTitle(aTitle)
|
, mTitle(aTitle)
|
||||||
, mWindowId(aWindowId)
|
, mWindowId(aWindowId)
|
||||||
, mProcessId(aProcessId)
|
|
||||||
, mIsSystem(aIsSystem)
|
, mIsSystem(aIsSystem)
|
||||||
, mPerformanceData(aPerformanceData)
|
, mPerformanceData(aPerformanceData)
|
||||||
{
|
{
|
||||||
@@ -123,7 +121,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* void getDurations (out unsigned long aCount, [array, size_is (aCount), retval] out unsigned long long aNumberOfOccurrences); */
|
/* void getDurations (out unsigned long aCount, [array, size_is (aCount), retval] out unsigned long long aNumberOfOccurrences); */
|
||||||
NS_IMETHOD GetDurations(uint32_t *aCount, uint64_t **aNumberOfOccurrences) override {
|
NS_IMETHODIMP GetDurations(uint32_t *aCount, uint64_t **aNumberOfOccurrences) override {
|
||||||
const size_t length = mozilla::ArrayLength(mPerformanceData.durations);
|
const size_t length = mozilla::ArrayLength(mPerformanceData.durations);
|
||||||
if (aCount) {
|
if (aCount) {
|
||||||
*aCount = length;
|
*aCount = length;
|
||||||
@@ -135,15 +133,6 @@ public:
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
readonly attribute unsigned long long processId;
|
|
||||||
*/
|
|
||||||
NS_IMETHODIMP GetProcessId(uint64_t* processId)
|
|
||||||
{
|
|
||||||
*processId = mProcessId;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsString mName;
|
nsString mName;
|
||||||
nsString mParentId;
|
nsString mParentId;
|
||||||
@@ -151,7 +140,6 @@ private:
|
|||||||
nsString mAddonId;
|
nsString mAddonId;
|
||||||
nsString mTitle;
|
nsString mTitle;
|
||||||
uint64_t mWindowId;
|
uint64_t mWindowId;
|
||||||
uint64_t mProcessId;
|
|
||||||
bool mIsSystem;
|
bool mIsSystem;
|
||||||
|
|
||||||
js::PerformanceData mPerformanceData;
|
js::PerformanceData mPerformanceData;
|
||||||
@@ -370,7 +358,7 @@ nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& per
|
|||||||
bool isSystem = GetIsSystem(cx, global);
|
bool isSystem = GetIsSystem(cx, global);
|
||||||
|
|
||||||
nsCOMPtr<nsIPerformanceStats> result =
|
nsCOMPtr<nsIPerformanceStats> result =
|
||||||
new nsPerformanceStats(name, parent, groupId, addonId, title, windowId, mProcessId, isSystem, performance);
|
new nsPerformanceStats(name, parent, groupId, addonId, title, windowId, isSystem, performance);
|
||||||
return result.forget();
|
return result.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +402,6 @@ nsPerformanceSnapshot::Init(JSContext* cx, uint64_t processId) {
|
|||||||
NS_LITERAL_STRING(""), // add-on id
|
NS_LITERAL_STRING(""), // add-on id
|
||||||
NS_LITERAL_STRING(""), // title
|
NS_LITERAL_STRING(""), // title
|
||||||
0, // window id
|
0, // window id
|
||||||
mProcessId, // process id
|
|
||||||
true, // isSystem
|
true, // isSystem
|
||||||
processStats);
|
processStats);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -9,16 +9,12 @@
|
|||||||
* to the top window.
|
* to the top window.
|
||||||
*/
|
*/
|
||||||
Cu.import("resource://gre/modules/PerformanceStats.jsm", this);
|
Cu.import("resource://gre/modules/PerformanceStats.jsm", this);
|
||||||
Cu.import("resource://gre/modules/Services.jsm", this);
|
|
||||||
Cu.import("resource://testing-common/ContentTask.jsm", this);
|
Cu.import("resource://testing-common/ContentTask.jsm", this);
|
||||||
|
|
||||||
|
|
||||||
const URL = "http://example.com/browser/toolkit/components/perfmonitoring/tests/browser/browser_compartments.html?test=" + Math.random();
|
const URL = "http://example.com/browser/toolkit/components/perfmonitoring/tests/browser/browser_compartments.html?test=" + Math.random();
|
||||||
const PARENT_TITLE = `Main frame for test browser_compartments.js ${Math.random()}`;
|
const PARENT_TITLE = `Main frame for test browser_compartments.js ${Math.random()}`;
|
||||||
const FRAME_TITLE = `Subframe for test browser_compartments.js ${Math.random()}`;
|
const FRAME_TITLE = `Subframe for test browser_compartments.js ${Math.random()}`;
|
||||||
|
|
||||||
const PARENT_PID = Services.appinfo.processID;
|
|
||||||
|
|
||||||
// This function is injected as source as a frameScript
|
// This function is injected as source as a frameScript
|
||||||
function frameScript() {
|
function frameScript() {
|
||||||
try {
|
try {
|
||||||
@@ -26,7 +22,7 @@ function frameScript() {
|
|||||||
|
|
||||||
const { utils: Cu, classes: Cc, interfaces: Ci } = Components;
|
const { utils: Cu, classes: Cc, interfaces: Ci } = Components;
|
||||||
Cu.import("resource://gre/modules/PerformanceStats.jsm");
|
Cu.import("resource://gre/modules/PerformanceStats.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
|
||||||
let performanceStatsService =
|
let performanceStatsService =
|
||||||
Cc["@mozilla.org/toolkit/performance-stats-service;1"].
|
Cc["@mozilla.org/toolkit/performance-stats-service;1"].
|
||||||
getService(Ci.nsIPerformanceStatsService);
|
getService(Ci.nsIPerformanceStatsService);
|
||||||
@@ -37,7 +33,7 @@ function frameScript() {
|
|||||||
addMessageListener("compartments-test:getStatistics", () => {
|
addMessageListener("compartments-test:getStatistics", () => {
|
||||||
try {
|
try {
|
||||||
monitor.promiseSnapshot().then(snapshot => {
|
monitor.promiseSnapshot().then(snapshot => {
|
||||||
sendAsyncMessage("compartments-test:getStatistics", {snapshot, pid: Services.appinfo.processID});
|
sendAsyncMessage("compartments-test:getStatistics", snapshot);
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
Cu.reportError("Error in content (getStatistics): " + ex);
|
Cu.reportError("Error in content (getStatistics): " + ex);
|
||||||
@@ -139,21 +135,19 @@ function monotinicity_tester(source, testName) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let name = `${testName}: ${iteration++}`;
|
let name = `${testName}: ${iteration++}`;
|
||||||
let result = yield source();
|
let snapshot = yield source();
|
||||||
if (!result) {
|
if (!snapshot) {
|
||||||
// This can happen at the end of the test when we attempt
|
// This can happen at the end of the test when we attempt
|
||||||
// to communicate too late with the content process.
|
// to communicate too late with the content process.
|
||||||
window.clearInterval(interval);
|
window.clearInterval(interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let {pid, snapshot} = result;
|
|
||||||
|
|
||||||
// Sanity check on the process data.
|
// Sanity check on the process data.
|
||||||
sanityCheck(previous.processData, snapshot.processData);
|
sanityCheck(previous.processData, snapshot.processData);
|
||||||
SilentAssert.equal(snapshot.processData.isSystem, true);
|
SilentAssert.equal(snapshot.processData.isSystem, true);
|
||||||
SilentAssert.equal(snapshot.processData.name, "<process>");
|
SilentAssert.equal(snapshot.processData.name, "<process>");
|
||||||
SilentAssert.equal(snapshot.processData.addonId, "");
|
SilentAssert.equal(snapshot.processData.addonId, "");
|
||||||
SilentAssert.equal(snapshot.processData.processId, pid);
|
|
||||||
previous.procesData = snapshot.processData;
|
previous.procesData = snapshot.processData;
|
||||||
|
|
||||||
// Sanity check on components data.
|
// Sanity check on components data.
|
||||||
@@ -166,14 +160,10 @@ function monotinicity_tester(source, testName) {
|
|||||||
]) {
|
]) {
|
||||||
// Note that we cannot expect components data to be always smaller
|
// Note that we cannot expect components data to be always smaller
|
||||||
// than process data, as `getrusage` & co are not monotonic.
|
// than process data, as `getrusage` & co are not monotonic.
|
||||||
SilentAssert.leq(item[probe][k], 3 * snapshot.processData[probe][k],
|
SilentAssert.leq(item[probe][k], 2 * snapshot.processData[probe][k],
|
||||||
`Sanity check (${name}): ${k} of component is not impossibly larger than that of process`);
|
`Sanity check (${testName}): ${k} of component is not impossibly larger than that of process`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let isCorrectPid = (item.processId == pid && !item.isChildProcess)
|
|
||||||
|| (item.processId != pid && item.isChildProcess);
|
|
||||||
SilentAssert.ok(isCorrectPid, `Pid check (${name}): the item comes from the right process`);
|
|
||||||
|
|
||||||
let key = item.groupId;
|
let key = item.groupId;
|
||||||
if (map.has(key)) {
|
if (map.has(key)) {
|
||||||
let old = map.get(key);
|
let old = map.get(key);
|
||||||
@@ -232,7 +222,7 @@ add_task(function* test() {
|
|||||||
info("Deactivating sanity checks under Windows (bug 1151240)");
|
info("Deactivating sanity checks under Windows (bug 1151240)");
|
||||||
} else {
|
} else {
|
||||||
info("Setting up sanity checks");
|
info("Setting up sanity checks");
|
||||||
monotinicity_tester(() => monitor.promiseSnapshot().then(snapshot => ({snapshot, pid: PARENT_PID})), "parent process");
|
monotinicity_tester(() => monitor.promiseSnapshot(), "parent process");
|
||||||
monotinicity_tester(() => promiseContentResponseOrNull(browser, "compartments-test:getStatistics", null), "content process" );
|
monotinicity_tester(() => promiseContentResponseOrNull(browser, "compartments-test:getStatistics", null), "content process" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +242,7 @@ add_task(function* test() {
|
|||||||
});
|
});
|
||||||
info("Titles set");
|
info("Titles set");
|
||||||
|
|
||||||
let {snapshot: stats} = (yield promiseContentResponse(browser, "compartments-test:getStatistics", null));
|
let stats = (yield promiseContentResponse(browser, "compartments-test:getStatistics", null));
|
||||||
|
|
||||||
let titles = [for(stat of stats.componentsData) stat.title];
|
let titles = [for(stat of stats.componentsData) stat.title];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user