зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1488375 - Use target.getFront to instantiate MemoryFront; r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D7097 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0b730425b6
Коммит
c22cefe4e6
|
@ -5,7 +5,6 @@
|
|||
"use strict";
|
||||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const { MemoryFront } = require("devtools/shared/fronts/memory");
|
||||
const { Cu } = require("chrome");
|
||||
const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient");
|
||||
|
||||
|
@ -31,11 +30,7 @@ MemoryPanel.prototype = {
|
|||
|
||||
this.panelWin.gToolbox = this._toolbox;
|
||||
this.panelWin.gTarget = this.target;
|
||||
|
||||
const rootForm = await this.target.root;
|
||||
this.panelWin.gFront = new MemoryFront(this.target.client,
|
||||
this.target.form,
|
||||
rootForm);
|
||||
this.panelWin.gFront = this.target.getFront("memory");
|
||||
this.panelWin.gHeapAnalysesClient = new HeapAnalysesClient();
|
||||
|
||||
await this.panelWin.gFront.attach();
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const Services = require("Services");
|
||||
const { DebuggerClient } = require("devtools/shared/client/debugger-client");
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
|
||||
const { MemoryFront } = require("devtools/shared/fronts/memory");
|
||||
const { TargetFactory } = require("devtools/client/framework/target");
|
||||
|
||||
// Always log packets when running tests.
|
||||
Services.prefs.setBoolPref("devtools.debugger.log", true);
|
||||
|
@ -18,26 +15,21 @@ SimpleTest.registerCleanupFunction(function() {
|
|||
Services.prefs.setBoolPref("privacy.reduceTimerPrecision", gReduceTimePrecision);
|
||||
});
|
||||
|
||||
function startServerAndGetSelectedTabMemory() {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
|
||||
return client.connect()
|
||||
.then(() => client.listTabs())
|
||||
.then(response => {
|
||||
const form = response.tabs[response.selected];
|
||||
const memory = MemoryFront(client, form, response);
|
||||
|
||||
return { memory, client };
|
||||
});
|
||||
async function getTargetForSelectedTab() {
|
||||
const browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const target = await TargetFactory.forTab(browserWindow.gBrowser.selectedTab);
|
||||
return target;
|
||||
}
|
||||
|
||||
function destroyServerAndFinish(client) {
|
||||
client.close().then(() => {
|
||||
DebuggerServer.destroy();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
async function startServerAndGetSelectedTabMemory() {
|
||||
const target = await getTargetForSelectedTab();
|
||||
const memory = target.getFront("memory");
|
||||
return {memory, target};
|
||||
}
|
||||
|
||||
async function destroyServerAndFinish(target) {
|
||||
await target.destroy();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function waitForTime(ms) {
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
const measurement = await memory.measure();
|
||||
ok(measurement.total > 0, "total memory is valid");
|
||||
ok(measurement.domSize > 0, "domSize is valid");
|
||||
|
@ -30,7 +30,7 @@ window.onload = function() {
|
|||
ok(measurement.otherSize > 0, "otherSize is valid");
|
||||
ok(measurement.jsMilliseconds, "jsMilliseconds is valid");
|
||||
ok(measurement.nonJSMilliseconds, "nonJSMilliseconds is valid");
|
||||
destroyServerAndFinish(client);
|
||||
await destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
await memory.startRecordingAllocations();
|
||||
|
@ -95,7 +95,7 @@ window.onload = function() {
|
|||
"Should have found all the expected lines");
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const allocs = [];
|
||||
|
@ -71,7 +71,7 @@ window.onload = function() {
|
|||
|
||||
memory.off("allocations", onAlloc);
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
await memory.startRecordingAllocations();
|
||||
|
@ -71,7 +71,7 @@ window.onload = function() {
|
|||
}
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const allocs = [];
|
||||
|
@ -53,7 +53,7 @@ window.onload = function() {
|
|||
// (js/src/jit-test/tests/debug/Memory-allocationsSamplingProbability-*.js).
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const allocs = [];
|
||||
|
@ -84,7 +84,7 @@ window.onload = function() {
|
|||
}
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const allocs = [];
|
||||
|
@ -42,7 +42,7 @@ window.onload = function() {
|
|||
"There should only be one entry in the allocations log.");
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const allocs = [];
|
||||
|
@ -45,7 +45,7 @@ window.onload = function() {
|
|||
"every bytesize is a positive number");
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
ok(true, "Shouldn't have gotten an error attaching.");
|
||||
await memory.detach();
|
||||
ok(true, "Shouldn't have gotten an error detaching.");
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
|
||||
let e = null;
|
||||
try {
|
||||
|
@ -40,7 +40,7 @@ window.onload = function() {
|
|||
ok(e, "Should have hit the wrongState error");
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,14 +19,14 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const census = await memory.takeCensus();
|
||||
is(typeof census, "object");
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ window.onload = function() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
|
||||
let beforeGC, afterGC;
|
||||
|
||||
|
@ -41,7 +41,7 @@ window.onload = function() {
|
|||
|
||||
ok(true, "The amount of memory after GC should eventually decrease");
|
||||
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -21,7 +21,7 @@ window.onload = function() {
|
|||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
(async function() {
|
||||
const { memory, client } = await startServerAndGetSelectedTabMemory();
|
||||
const { memory, target } = await startServerAndGetSelectedTabMemory();
|
||||
await memory.attach();
|
||||
|
||||
const gotGcEvent = new Promise(resolve => {
|
||||
|
@ -35,7 +35,7 @@ window.onload = function() {
|
|||
await gotGcEvent;
|
||||
|
||||
await memory.detach();
|
||||
destroyServerAndFinish(client);
|
||||
destroyServerAndFinish(target);
|
||||
})();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -12,13 +12,11 @@ loader.lazyRequireGetter(this, "HeapSnapshotFileUtils",
|
|||
"devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
|
||||
|
||||
const MemoryFront = protocol.FrontClassWithSpec(memorySpec, {
|
||||
initialize: function(client, form, rootForm = null) {
|
||||
initialize: function(client, form) {
|
||||
protocol.Front.prototype.initialize.call(this, client, form);
|
||||
this._client = client;
|
||||
this.actorID = form.memoryActor;
|
||||
this.heapSnapshotFileActorID = rootForm
|
||||
? rootForm.heapSnapshotFileActor
|
||||
: null;
|
||||
this.heapSnapshotFileActorID = null;
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
|
@ -64,7 +62,8 @@ const MemoryFront = protocol.FrontClassWithSpec(memorySpec, {
|
|||
*/
|
||||
transferHeapSnapshot: protocol.custom(async function(snapshotId) {
|
||||
if (!this.heapSnapshotFileActorID) {
|
||||
throw new Error("MemoryFront initialized without a rootForm");
|
||||
const form = await this._client.mainRoot.rootForm;
|
||||
this.heapSnapshotFileActorID = form.heapSnapshotFileActor;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Загрузка…
Ссылка в новой задаче