Reclassify heapsnapshot and nsJSInspector as not part of devtools

This resolves Issue #316
This commit is contained in:
Matt A. Tobin 2020-02-22 17:32:39 -05:00 • committed by Roy Tam
commit 95d5dcd8c5
142 changed files with 19 additions and 15 deletions

View file

@ -0,0 +1,8 @@
[DEFAULT]
tags = devtools devtools-memory
skip-if = os == 'android'
support-files =
[test_DominatorTree_01.html]
[test_SaveHeapSnapshot.html]

View file

@ -0,0 +1,6 @@
[DEFAULT]
tags = devtools devtools-memory
support-files =
[test_saveHeapSnapshot_e10s_01.html]

View file

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<!--
Sanity test that we can compute dominator trees from a heap snapshot in a web window.
-->
<head>
<meta charset="utf-8">
<title>ChromeUtils.saveHeapSnapshot test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
SimpleTest.waitForExplicitFinish();
window.onload = function() {
const path = ChromeUtils.saveHeapSnapshot({ runtime: true });
const snapshot = ChromeUtils.readHeapSnapshot(path);
const dominatorTree = snapshot.computeDominatorTree();
ok(dominatorTree);
ok(dominatorTree instanceof DominatorTree);
let threw = false;
try {
new DominatorTree();
} catch (e) {
threw = true;
}
ok(threw, "Constructor shouldn't be usable");
SimpleTest.finish();
};
</script>
</pre>
</body>
</html>

View file

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<!--
Bug 1024774 - Sanity test that we can take a heap snapshot in a web window.
-->
<head>
<meta charset="utf-8">
<title>ChromeUtils.saveHeapSnapshot test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
SimpleTest.waitForExplicitFinish();
window.onload = function() {
ok(ChromeUtils, "The ChromeUtils interface should be exposed in chrome windows.");
ChromeUtils.saveHeapSnapshot({ runtime: true });
ok(true, "Should save a heap snapshot and shouldn't throw.");
SimpleTest.finish();
};
</script>
</pre>
</body>
</html>

View file

@ -0,0 +1,82 @@
<!DOCTYPE HTML>
<!--
Bug 1201597 - Sanity test that we can take a heap snapshot in an e10s child process.
-->
<html>
<head>
<title>saveHeapSnapshot in e10s child processes</title>
<script type="application/javascript"
src="/tests/SimpleTest/SimpleTest.js">
</script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript">
window.onerror = function (msg, url, line, col, err) {
ok(false, "@" + url + ":" + line + ":" + col + ": " + msg + "\n" + err.stack);
};
SimpleTest.waitForExplicitFinish();
var childFrameURL = "data:text/html,<!DOCTYPE HTML><html><body></body></html>";
// This function is stringified and loaded in the child process as a frame
// script.
function childFrameScript() {
try {
ChromeUtils.saveHeapSnapshot({ runtime: true });
} catch (err) {
sendAsyncMessage("testSaveHeapSnapshot:error",
{ error: err.toString() });
return;
}
sendAsyncMessage("testSaveHeapSnapshot:done", {});
}
// Kick everything off on load.
window.onload = function () {
info("window.onload fired");
SpecialPowers.addPermission("browser", true, document);
SpecialPowers.pushPrefEnv({
"set": [
["dom.ipc.browser_frames.oop_by_default", true],
["dom.mozBrowserFramesEnabled", true],
["browser.pagethumbnails.capturing_disabled", true]
]
}, function () {
var iframe = document.createElement("iframe");
SpecialPowers.wrap(iframe).mozbrowser = true;
iframe.id = "iframe";
iframe.src = childFrameURL;
iframe.addEventListener("mozbrowserloadend", function onLoadEnd() {
iframe.removeEventListener("mozbrowserloadend", onLoadEnd);
info("iframe done loading");
var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
function onError(e) {
ok(false, e.data.error);
}
mm.addMessageListener("testSaveHeapSnapshot:error", onError);
mm.addMessageListener("testSaveHeapSnapshot:done", function onMsg() {
mm.removeMessageListener("testSaveHeapSnapshot:done", onMsg);
mm.removeMessageListener("testSaveHeapSnapshot:error", onError);
ok(true, "Saved heap snapshot in child process");
SimpleTest.finish();
});
info("Loading frame script to save heap snapshot");
mm.loadFrameScript("data:,(" + encodeURI(childFrameScript.toString()) + ")();",
false);
});
info("Loading iframe");
document.body.appendChild(iframe);
});
};
</script>
</window>