mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1207645 - Create HeapSnapshotFileActor; r=jryans
This commit creates the HeapSnapshotFileActor and moves the transferHeapSnapshot method from MemoryActor to HeapSnapshotFileActor. This is necessary because child processes in e10s are sandboxed and do not have access to the file system, and because MemoryActor is in the sandboxed child process it cannot open the file and send it over the RDP. This complexity is hidden at the MemoryFront layer. Users of MemoryFront will still simply call its saveHeapSnapshot method, and do not need to worry about the inner workings of how heap snapshot files are transferred over the RDP. This required adding a third parameter to MemoryFront's initialize method: the listTabs response.
This commit is contained in:
parent
f47c8dd0da
commit
c6a2721d28
@ -317,10 +317,28 @@ TabTarget.prototype = {
|
|||||||
return this._form;
|
return this._form;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Get a promise of the root form returned by a listTabs request. This promise
|
||||||
|
// is cached.
|
||||||
get root() {
|
get root() {
|
||||||
|
if (!this._root) {
|
||||||
|
this._root = this._getRoot();
|
||||||
|
}
|
||||||
return this._root;
|
return this._root;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getRoot: function () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.client.listTabs(response => {
|
||||||
|
if (response.error) {
|
||||||
|
reject(new Error(response.error + ": " + response.message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
get client() {
|
get client() {
|
||||||
return this._client;
|
return this._client;
|
||||||
},
|
},
|
||||||
|
@ -3,12 +3,21 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// This shared-head.js file is used for multiple directories in devtools.
|
// This shared-head.js file is used for multiple directories in devtools.
|
||||||
|
|
||||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||||
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
|
||||||
const {gDevTools} = Cu.import("resource:///modules/devtools/client/framework/gDevTools.jsm", {});
|
function scopedCuImport(path) {
|
||||||
const {console} = Cu.import("resource://gre/modules/devtools/shared/Console.jsm", {});
|
const scope = {};
|
||||||
const {ScratchpadManager} = Cu.import("resource:///modules/devtools/client/scratchpad/scratchpad-manager.jsm", {});
|
Cu.import(path, scope);
|
||||||
const {require} = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
const {Services} = scopedCuImport("resource://gre/modules/Services.jsm");
|
||||||
|
const {gDevTools} = scopedCuImport("resource:///modules/devtools/client/framework/gDevTools.jsm");
|
||||||
|
const {console} = scopedCuImport("resource://gre/modules/devtools/shared/Console.jsm");
|
||||||
|
const {ScratchpadManager} = scopedCuImport("resource:///modules/devtools/client/scratchpad/scratchpad-manager.jsm");
|
||||||
|
const {require} = scopedCuImport("resource://gre/modules/devtools/shared/Loader.jsm");
|
||||||
|
|
||||||
const {TargetFactory} = require("devtools/client/framework/target");
|
const {TargetFactory} = require("devtools/client/framework/target");
|
||||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||||
const promise = require("promise");
|
const promise = require("promise");
|
||||||
@ -69,6 +78,25 @@ function addTab(url) {
|
|||||||
return def.promise;
|
return def.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the given tab.
|
||||||
|
* @param {Object} tab The tab to be removed.
|
||||||
|
* @return Promise<undefined> resolved when the tab is successfully removed.
|
||||||
|
*/
|
||||||
|
function removeTab(tab) {
|
||||||
|
info("Removing tab.");
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let tabContainer = gBrowser.tabContainer;
|
||||||
|
tabContainer.addEventListener("TabClose", function onClose(aEvent) {
|
||||||
|
tabContainer.removeEventListener("TabClose", onClose, false);
|
||||||
|
info("Tab removed and finished closing.");
|
||||||
|
resolve();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
gBrowser.removeTab(tab);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function synthesizeKeyFromKeyTag(aKeyId, document) {
|
function synthesizeKeyFromKeyTag(aKeyId, document) {
|
||||||
let key = document.getElementById(aKeyId);
|
let key = document.getElementById(aKeyId);
|
||||||
isnot(key, null, "Successfully retrieved the <key> node");
|
isnot(key, null, "Successfully retrieved the <key> node");
|
||||||
|
@ -19,10 +19,10 @@ var gToolbox, gTarget, gFront;
|
|||||||
*/
|
*/
|
||||||
const MemoryController = {
|
const MemoryController = {
|
||||||
initialize: Task.async(function *() {
|
initialize: Task.async(function *() {
|
||||||
|
yield gFront.attach();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
destroy: Task.async(function *() {
|
destroy: Task.async(function *() {
|
||||||
|
yield gFront.detach();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
@ -12,3 +12,4 @@ DevToolsModules(
|
|||||||
)
|
)
|
||||||
|
|
||||||
MOCHITEST_CHROME_MANIFESTS += ['test/mochitest/chrome.ini']
|
MOCHITEST_CHROME_MANIFESTS += ['test/mochitest/chrome.ini']
|
||||||
|
BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
|
||||||
|
@ -26,14 +26,19 @@ MemoryPanel.prototype = {
|
|||||||
|
|
||||||
this.panelWin.gToolbox = this._toolbox;
|
this.panelWin.gToolbox = this._toolbox;
|
||||||
this.panelWin.gTarget = this.target;
|
this.panelWin.gTarget = this.target;
|
||||||
this.panelWin.gFront = new MemoryFront(this.target.client, this.target.form);
|
|
||||||
|
const rootForm = yield this.target.root;
|
||||||
|
this.panelWin.gFront = new MemoryFront(this.target.client,
|
||||||
|
this.target.form,
|
||||||
|
rootForm);
|
||||||
|
|
||||||
console.log(this.panelWin, this.panelWin.MemoryController);
|
console.log(this.panelWin, this.panelWin.MemoryController);
|
||||||
return this._opening = this.panelWin.MemoryController.initialize().then(() => {
|
this._opening = this.panelWin.MemoryController.initialize().then(() => {
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
this.emit("ready");
|
this.emit("ready");
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
return this._opening;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// DevToolPanel API
|
// DevToolPanel API
|
||||||
@ -48,12 +53,14 @@ MemoryPanel.prototype = {
|
|||||||
return this._destroyer;
|
return this._destroyer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._destroyer = this.panelWin.MemoryController.destroy().then(() => {
|
this._destroyer = this.panelWin.MemoryController.destroy().then(() => {
|
||||||
// Destroy front to ensure packet handler is removed from client
|
// Destroy front to ensure packet handler is removed from client
|
||||||
this.panelWin.gFront.destroy();
|
this.panelWin.gFront.destroy();
|
||||||
|
this.panelWin = null;
|
||||||
this.emit("destroyed");
|
this.emit("destroyed");
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
return this._destroyer;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
7
devtools/client/memory/test/browser/browser.ini
Normal file
7
devtools/client/memory/test/browser/browser.ini
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
tags = devtools
|
||||||
|
subsuite = devtools
|
||||||
|
support-files =
|
||||||
|
head.js
|
||||||
|
|
||||||
|
[browser_memory_transferHeapSnapshot_e10s_01.js]
|
@ -0,0 +1,28 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
// Test that we can save a heap snapshot and transfer it over the RDP in e10s
|
||||||
|
// where the child process is sandboxed and so we have to use
|
||||||
|
// HeapSnapshotFileActor to get the heap snapshot file.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const TEST_URL = "data:text/html,<html><body></body></html>";
|
||||||
|
|
||||||
|
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
|
||||||
|
const memoryFront = panel.panelWin.gFront;
|
||||||
|
ok(memoryFront, "Should get the MemoryFront");
|
||||||
|
|
||||||
|
const snapshotFilePath = yield memoryFront.saveHeapSnapshot({
|
||||||
|
// Force a copy so that we go through the HeapSnapshotFileActor's
|
||||||
|
// transferHeapSnapshot request and exercise this code path on e10s.
|
||||||
|
forceCopy: true
|
||||||
|
});
|
||||||
|
|
||||||
|
ok(!!(yield OS.File.stat(snapshotFilePath)),
|
||||||
|
"Should have the heap snapshot file");
|
||||||
|
|
||||||
|
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
|
||||||
|
ok(snapshot instanceof HeapSnapshot,
|
||||||
|
"And we should be able to read a HeapSnapshot instance from the file");
|
||||||
|
});
|
65
devtools/client/memory/test/browser/head.js
Normal file
65
devtools/client/memory/test/browser/head.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Load the shared test helpers into this compartment.
|
||||||
|
Services.scriptloader.loadSubScript(
|
||||||
|
"chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js",
|
||||||
|
this);
|
||||||
|
|
||||||
|
Services.prefs.setBoolPref("devtools.memory.enabled", true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the memory panel for the given tab.
|
||||||
|
*/
|
||||||
|
this.openMemoryPanel = Task.async(function* (tab) {
|
||||||
|
info("Opening memory panel.");
|
||||||
|
const target = TargetFactory.forTab(tab);
|
||||||
|
const toolbox = yield gDevTools.showToolbox(target, "memory");
|
||||||
|
info("Memory panel shown successfully.");
|
||||||
|
let panel = toolbox.getCurrentPanel();
|
||||||
|
return { tab, panel };
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the memory panel for the given tab.
|
||||||
|
*/
|
||||||
|
this.closeMemoryPanel = Task.async(function* (tab) {
|
||||||
|
info("Closing memory panel.");
|
||||||
|
const target = TargetFactory.forTab(tab);
|
||||||
|
const toolbox = gDevTools.getToolbox(target);
|
||||||
|
yield toolbox.destroy();
|
||||||
|
info("Closed memory panel successfully.");
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a test function that adds a tab with the given url, opens the memory
|
||||||
|
* panel, runs the given generator, closes the memory panel, removes the tab,
|
||||||
|
* and finishes.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
|
||||||
|
* // Your tests go here...
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
function makeMemoryTest(url, generator) {
|
||||||
|
return Task.async(function* () {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
const tab = yield addTab(url);
|
||||||
|
const results = yield openMemoryPanel(tab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
yield* generator(results);
|
||||||
|
} catch (err) {
|
||||||
|
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
yield closeMemoryPanel(tab);
|
||||||
|
yield removeTab(tab);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
}
|
74
devtools/server/actors/heap-snapshot-file.js
Normal file
74
devtools/server/actors/heap-snapshot-file.js
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const protocol = require("devtools/server/protocol");
|
||||||
|
const { method, Arg } = protocol;
|
||||||
|
const Services = require("Services");
|
||||||
|
|
||||||
|
loader.lazyRequireGetter(this, "DevToolsUtils",
|
||||||
|
"devtools/shared/DevToolsUtils");
|
||||||
|
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
|
||||||
|
loader.lazyRequireGetter(this, "Task", "resource://gre/modules/Task.jsm", true);
|
||||||
|
loader.lazyRequireGetter(this, "HeapSnapshotFileUtils",
|
||||||
|
"devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HeapSnapshotFileActor handles transferring heap snapshot files from the
|
||||||
|
* server to the client. This has to be a global actor in the parent process
|
||||||
|
* because child processes are sandboxed and do not have access to the file
|
||||||
|
* system.
|
||||||
|
*/
|
||||||
|
exports.HeapSnapshotFileActor = protocol.ActorClass({
|
||||||
|
typeName: "heapSnapshotFile",
|
||||||
|
|
||||||
|
initialize: function (conn, parent) {
|
||||||
|
if (Services.appInfo &&
|
||||||
|
(Services.appInfo.processType !==
|
||||||
|
Services.appInfo.PROCESS_TYPE_DEFAULT)) {
|
||||||
|
const err = new Error("Attempt to create a HeapSnapshotFileActor in a " +
|
||||||
|
"child process! The HeapSnapshotFileActor *MUST* " +
|
||||||
|
"be in the parent process!");
|
||||||
|
DevToolsUtils.reportException(
|
||||||
|
"HeapSnapshotFileActor.prototype.initialize", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol.Actor.prototype.initialize.call(this, conn, parent);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see MemoryFront.prototype.transferHeapSnapshot
|
||||||
|
*/
|
||||||
|
transferHeapSnapshot: method(Task.async(function* (snapshotId) {
|
||||||
|
const snapshotFilePath =
|
||||||
|
HeapSnapshotFileUtils.getHeapSnapshotTempFilePath(snapshotId);
|
||||||
|
if (!snapshotFilePath) {
|
||||||
|
throw new Error(`No heap snapshot with id: ${snapshotId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const streamPromise = DevToolsUtils.openFileStream(snapshotFilePath);
|
||||||
|
|
||||||
|
const { size } = yield OS.File.stat(snapshotFilePath);
|
||||||
|
const bulkPromise = this.conn.startBulkSend({
|
||||||
|
actor: this.actorID,
|
||||||
|
type: "heap-snapshot",
|
||||||
|
length: size
|
||||||
|
});
|
||||||
|
|
||||||
|
const [bulk, stream] = yield Promise.all([bulkPromise, streamPromise]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
yield bulk.copyFrom(stream);
|
||||||
|
} finally {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
}), {
|
||||||
|
request: {
|
||||||
|
snapshotId: Arg(0, "string")
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
});
|
@ -5,7 +5,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { Cc, Ci, Cu, components } = require("chrome");
|
const { Cc, Ci, Cu, components } = require("chrome");
|
||||||
const { openFileStream } = require("devtools/shared/DevToolsUtils");
|
|
||||||
const protocol = require("devtools/server/protocol");
|
const protocol = require("devtools/server/protocol");
|
||||||
const { method, RetVal, Arg, types } = protocol;
|
const { method, RetVal, Arg, types } = protocol;
|
||||||
const { Memory } = require("devtools/shared/shared/memory");
|
const { Memory } = require("devtools/shared/shared/memory");
|
||||||
@ -17,7 +16,6 @@ loader.lazyRequireGetter(this, "FileUtils",
|
|||||||
"resource://gre/modules/FileUtils.jsm", true);
|
"resource://gre/modules/FileUtils.jsm", true);
|
||||||
loader.lazyRequireGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm", true);
|
loader.lazyRequireGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm", true);
|
||||||
loader.lazyRequireGetter(this, "Task", "resource://gre/modules/Task.jsm", true);
|
loader.lazyRequireGetter(this, "Task", "resource://gre/modules/Task.jsm", true);
|
||||||
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
|
|
||||||
loader.lazyRequireGetter(this, "HeapSnapshotFileUtils",
|
loader.lazyRequireGetter(this, "HeapSnapshotFileUtils",
|
||||||
"devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
|
"devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
|
||||||
loader.lazyRequireGetter(this, "ThreadSafeChromeUtils");
|
loader.lazyRequireGetter(this, "ThreadSafeChromeUtils");
|
||||||
@ -115,35 +113,6 @@ var MemoryActor = exports.MemoryActor = protocol.ActorClass({
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
transferHeapSnapshot: method(Task.async(function* (snapshotId) {
|
|
||||||
const snapshotFilePath =
|
|
||||||
HeapSnapshotFileUtils.getHeapSnapshotTempFilePath(snapshotId);
|
|
||||||
if (!snapshotFilePath) {
|
|
||||||
throw new Error(`No heap snapshot with id: ${snapshotId}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const streamPromise = openFileStream(snapshotFilePath);
|
|
||||||
|
|
||||||
const { size } = yield OS.File.stat(snapshotFilePath);
|
|
||||||
const bulkPromise = this.conn.startBulkSend({
|
|
||||||
actor: this.actorID,
|
|
||||||
type: "heap-snapshot",
|
|
||||||
length: size
|
|
||||||
});
|
|
||||||
|
|
||||||
const [bulk, stream] = yield Promise.all([bulkPromise, streamPromise]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
yield bulk.copyFrom(stream);
|
|
||||||
} finally {
|
|
||||||
stream.close();
|
|
||||||
}
|
|
||||||
}), {
|
|
||||||
request: {
|
|
||||||
snapshotId: Arg(0, "string")
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
takeCensus: actorBridge("takeCensus", {
|
takeCensus: actorBridge("takeCensus", {
|
||||||
request: {},
|
request: {},
|
||||||
response: RetVal("json")
|
response: RetVal("json")
|
||||||
@ -213,10 +182,11 @@ var MemoryActor = exports.MemoryActor = protocol.ActorClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
exports.MemoryFront = protocol.FrontClass(MemoryActor, {
|
exports.MemoryFront = protocol.FrontClass(MemoryActor, {
|
||||||
initialize: function(client, form) {
|
initialize: function(client, form, rootForm) {
|
||||||
protocol.Front.prototype.initialize.call(this, client, form);
|
protocol.Front.prototype.initialize.call(this, client, form);
|
||||||
this._client = client;
|
this._client = client;
|
||||||
this.actorID = form.memoryActor;
|
this.actorID = form.memoryActor;
|
||||||
|
this.heapSnapshotFileActorID = rootForm.heapSnapshotFileActor;
|
||||||
this.manage(this);
|
this.manage(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -225,9 +195,8 @@ exports.MemoryFront = protocol.FrontClass(MemoryActor, {
|
|||||||
* server and client do not share a file system, and return the local file
|
* server and client do not share a file system, and return the local file
|
||||||
* path to the heap snapshot.
|
* path to the heap snapshot.
|
||||||
*
|
*
|
||||||
* NB: This will not work with sandboxed child processes, as they do not have
|
* Note that this is safe to call for actors inside sandoxed child processes,
|
||||||
* access to the filesystem and the hep snapshot APIs do not support that use
|
* as we jump through the correct IPDL hoops.
|
||||||
* case yet.
|
|
||||||
*
|
*
|
||||||
* @params Boolean options.forceCopy
|
* @params Boolean options.forceCopy
|
||||||
* Always force a bulk data copy of the saved heap snapshot, even when
|
* Always force a bulk data copy of the saved heap snapshot, even when
|
||||||
@ -259,7 +228,7 @@ exports.MemoryFront = protocol.FrontClass(MemoryActor, {
|
|||||||
*/
|
*/
|
||||||
transferHeapSnapshot: protocol.custom(function (snapshotId) {
|
transferHeapSnapshot: protocol.custom(function (snapshotId) {
|
||||||
const request = this._client.request({
|
const request = this._client.request({
|
||||||
to: this.actorID,
|
to: this.heapSnapshotFileActorID,
|
||||||
type: "transferHeapSnapshot",
|
type: "transferHeapSnapshot",
|
||||||
snapshotId
|
snapshotId
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,7 @@ DevToolsModules(
|
|||||||
'eventlooplag.js',
|
'eventlooplag.js',
|
||||||
'framerate.js',
|
'framerate.js',
|
||||||
'gcli.js',
|
'gcli.js',
|
||||||
|
'heap-snapshot-file.js',
|
||||||
'highlighters.css',
|
'highlighters.css',
|
||||||
'highlighters.js',
|
'highlighters.js',
|
||||||
'inspector.js',
|
'inspector.js',
|
||||||
|
@ -413,6 +413,11 @@ var DebuggerServer = {
|
|||||||
constructor: "DirectorRegistryActor",
|
constructor: "DirectorRegistryActor",
|
||||||
type: { global: true }
|
type: { global: true }
|
||||||
});
|
});
|
||||||
|
this.registerModule("devtools/server/actors/heap-snapshot-file", {
|
||||||
|
prefix: "heapSnapshotFile",
|
||||||
|
constructor: "HeapSnapshotFileActor",
|
||||||
|
type: { global: true }
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ function startServerAndGetSelectedTabMemory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var form = response.tabs[response.selected];
|
var form = response.tabs[response.selected];
|
||||||
var memory = MemoryFront(client, form);
|
var memory = MemoryFront(client, form, response);
|
||||||
|
|
||||||
resolve({ memory, client });
|
resolve({ memory, client });
|
||||||
});
|
});
|
||||||
|
@ -52,10 +52,21 @@ function makeMemoryActorTest(testGeneratorFunction) {
|
|||||||
return function run_test() {
|
return function run_test() {
|
||||||
do_test_pending();
|
do_test_pending();
|
||||||
startTestDebuggerServer(TEST_GLOBAL_NAME).then(client => {
|
startTestDebuggerServer(TEST_GLOBAL_NAME).then(client => {
|
||||||
getTestTab(client, TEST_GLOBAL_NAME, function (tabForm) {
|
DebuggerServer.registerModule("devtools/server/actors/heap-snapshot-file", {
|
||||||
|
prefix: "heapSnapshotFile",
|
||||||
|
constructor: "HeapSnapshotFileActor",
|
||||||
|
type: { global: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
getTestTab(client, TEST_GLOBAL_NAME, function (tabForm, rootForm) {
|
||||||
|
if (!tabForm || !rootForm) {
|
||||||
|
ok(false, "Could not attach to test tab: " + TEST_GLOBAL_NAME);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Task.spawn(function* () {
|
Task.spawn(function* () {
|
||||||
try {
|
try {
|
||||||
const memoryFront = new MemoryFront(client, tabForm);
|
const memoryFront = new MemoryFront(client, tabForm, rootForm);
|
||||||
yield memoryFront.attach();
|
yield memoryFront.attach();
|
||||||
yield* testGeneratorFunction(client, memoryFront);
|
yield* testGeneratorFunction(client, memoryFront);
|
||||||
yield memoryFront.detach();
|
yield memoryFront.detach();
|
||||||
@ -294,7 +305,7 @@ function getTestTab(aClient, aTitle, aCallback) {
|
|||||||
aClient.listTabs(function (aResponse) {
|
aClient.listTabs(function (aResponse) {
|
||||||
for (let tab of aResponse.tabs) {
|
for (let tab of aResponse.tabs) {
|
||||||
if (tab.title === aTitle) {
|
if (tab.title === aTitle) {
|
||||||
aCallback(tab);
|
aCallback(tab, aResponse);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user