mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-02 22:29:06 +00:00
97 lines
2.6 KiB
HTML
97 lines
2.6 KiB
HTML
<SDOCTYPv HTM.>
|
|
<html>
|
|
<!--
|
|
Bug 1060093 - Test DebuggerServer.attachProcess
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Mozilla Bug</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 type="application/javascript;version=1.8">
|
|
|
|
let Cu = Components.utils;
|
|
let Cc = Components.classes;
|
|
let Ci = Components.interfaces;
|
|
|
|
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
|
|
Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
|
|
|
|
window.onload = function() {
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SpecialPowers.pushPrefEnv({
|
|
"set": [
|
|
// Always log packets when running tests.
|
|
["devtools.debugger.log", true],
|
|
["dom.mozBrowserFramesEnabled", true]
|
|
]
|
|
}, runTests);
|
|
}
|
|
|
|
function runTests() {
|
|
// Create a remote iframe with a message manager
|
|
let iframe = document.createElement("iframe");
|
|
iframe.mozbrowser = true;
|
|
iframe.setAttribute("remote", "true");
|
|
iframe.setAttribute("src", "data:text/html,foo");
|
|
document.body.appendChild(iframe);
|
|
|
|
let mm = iframe.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
|
|
|
|
// Instantiate a minimal server
|
|
if (!DebuggerServer.initialized) {
|
|
DebuggerServer.init();
|
|
}
|
|
if (!DebuggerServer.createRootActor) {
|
|
DebuggerServer.addBrowserActors();
|
|
}
|
|
|
|
function firstClient() {
|
|
// Fake a first connection to the content process
|
|
let transport = DebuggerServer.connectPipe();
|
|
let client = new DebuggerClient(transport);
|
|
client.connect(() => {
|
|
client.mainRoot.listProcesses(response => {
|
|
ok(response.processes.length >= 2, "Got at least the parent process and one child");
|
|
|
|
// Connect to the first content processe available
|
|
let content = response.processes.filter(p => (!p.parent))[0];
|
|
|
|
client.attachProcess(content.id).then(response => {
|
|
let actor = response.form;
|
|
ok(actor.consoleActor, "Got the console actor");
|
|
ok(actor.chromeDebugger, "Got the thread actor");
|
|
|
|
// Ensure sending at least one request to an actor...
|
|
client.request({
|
|
to: actor.consoleActor,
|
|
type: "evaluateJS",
|
|
text: "var a = 42; a"
|
|
}, function (response) {
|
|
ok(response.result, 42, "console.eval worked");
|
|
|
|
client.close(cleanup);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
function cleanup() {
|
|
DebuggerServer.destroy();
|
|
iframe.remove();
|
|
SimpleTest.finish()
|
|
}
|
|
|
|
firstClient();
|
|
}
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|