1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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>
|