Bug 1155168 - Always use the same actor pool. r=ochameau

This commit is contained in:
Jan Odvarko 2015-04-23 20:10:32 +02:00
parent 97345d6f8a
commit 4928b0eb31
4 changed files with 159 additions and 30 deletions

View File

@ -860,14 +860,19 @@ TabActor.prototype = {
response.outerWindowID = windowUtils.outerWindowID;
}
// Walk over tab actors added by extensions and add them to a new ActorPool.
let actorPool = new ActorPool(this.conn);
this._createExtraActors(DebuggerServer.tabActorFactories, actorPool);
if (!actorPool.isEmpty()) {
this._tabActorPool = actorPool;
// Always use the same ActorPool, so existing actor instances
// (created in createExtraActors) are not lost.
if (!this._tabActorPool) {
this._tabActorPool = new ActorPool(this.conn);
this.conn.addActorPool(this._tabActorPool);
}
// Walk over tab actor factories and make sure they are all
// instantiated and added into the ActorPool. Note that some
// factories can be added dynamically by extensions.
this._createExtraActors(DebuggerServer.tabActorFactories,
this._tabActorPool);
this._appendExtraActors(response);
return response;
},

View File

@ -2,32 +2,39 @@
tags = devtools
skip-if = buildapp == 'b2g'
support-files =
Debugger.Source.prototype.element.js
Debugger.Source.prototype.element-2.js
Debugger.Source.prototype.element.html
director-helpers.js
hello-actor.js
inspector_getImageData.html
inspector-helpers.js
inspector-styles-data.css
inspector-styles-data.html
inspector-traversal-data.html
nonchrome_unsafeDereference.html
inspector_getImageData.html
large-image.jpg
memory-helpers.js
nonchrome_unsafeDereference.html
small-image.gif
Debugger.Source.prototype.element.js
Debugger.Source.prototype.element-2.js
Debugger.Source.prototype.element.html
[test_Debugger.Source.prototype.introductionScript.html]
[test_Debugger.Source.prototype.introductionType.html]
[test_Debugger.Source.prototype.element.html]
[test_Debugger.Script.prototype.global.html]
[test_connection-manager.html]
skip-if = buildapp == 'mulet'
[test_connectToChild.html]
skip-if = buildapp == 'mulet'
[test_css-logic.html]
[test_css-logic-inheritance.html]
[test_css-logic-media-queries.html]
[test_css-logic-specificity.html]
[test_Debugger.Source.prototype.introductionScript.html]
[test_Debugger.Source.prototype.introductionType.html]
[test_Debugger.Source.prototype.element.html]
[test_Debugger.Script.prototype.global.html]
[test_device.html]
skip-if = buildapp == 'mulet'
[test_director.html]
[test_director_connectToChild.html]
skip-if = buildapp == 'mulet'
[test_evalInGlobal-outerized_this.html]
[test_framerate_01.html]
skip-if = buildapp == 'mulet'
[test_framerate_02.html]
@ -38,10 +45,14 @@ skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet'
[test_framerate_05.html]
skip-if = buildapp == 'mulet'
[test_getProcess.html]
skip-if = buildapp == 'mulet'
[test_inspector-anonymous.html]
[test_inspector-changeattrs.html]
[test_inspector-changevalue.html]
[test_inspector-dead-nodes.html]
[test_inspector_getImageData.html]
skip-if = buildapp == 'mulet'
[test_inspector-hide.html]
[test_inspector-insert.html]
[test_inspector-mutations-attr.html]
@ -56,15 +67,6 @@ skip-if = buildapp == 'mulet'
[test_inspector-scroll-into-view.html]
[test_inspector-traversal.html]
[test_makeGlobalObjectReference.html]
[test_styles-applied.html]
[test_styles-computed.html]
[test_styles-matched.html]
[test_styles-modify.html]
[test_styles-svg.html]
[test_unsafeDereference.html]
[test_evalInGlobal-outerized_this.html]
[test_inspector_getImageData.html]
skip-if = buildapp == 'mulet'
[test_memory.html]
[test_memory_allocations_01.html]
[test_memory_allocations_02.html]
@ -78,11 +80,11 @@ skip-if = buildapp == 'mulet'
[test_memory_gc_01.html]
[test_memory_gc_events.html]
[test_preference.html]
[test_registerActor.html]
[test_settings.html]
[test_connectToChild.html]
skip-if = buildapp == 'mulet'
[test_getProcess.html]
skip-if = buildapp == 'mulet'
[test_director.html]
[test_director_connectToChild.html]
skip-if = buildapp == 'mulet'
[test_styles-applied.html]
[test_styles-computed.html]
[test_styles-matched.html]
[test_styles-modify.html]
[test_styles-svg.html]
[test_unsafeDereference.html]

View File

@ -0,0 +1,20 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const protocol = require("devtools/server/protocol");
const HelloActor = protocol.ActorClass({
typeName: "helloActor",
initialize: function() {
protocol.Actor.prototype.initialize.apply(this, arguments);
this.counter = 0;
},
count: protocol.method(function () {
return ++this.counter;
}, {
request: {},
response: {count: protocol.RetVal("number")}
})
});

View File

@ -0,0 +1,102 @@
<!DOCTYPE HTML>
<html>
<!--
Bug 895360 - [app manager] Device meta data actor
-->
<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>
var gClient;
window.onload = function() {
var Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
Cu.import("resource://gre/modules/devtools/Loader.jsm");
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
Cu.import("resource://gre/modules/Services.jsm");
SimpleTest.waitForExplicitFinish();
var {ActorRegistryFront} = devtools.require("devtools/server/actors/actor-registry");
var actorURL = "chrome://mochitests/content/chrome/toolkit/devtools/server/tests/mochitest/hello-actor.js";
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect(function onConnect() {
gClient.listTabs(function onListTabs(aResponse) {
var options = {
prefix: "helloActor",
constructor: "HelloActor",
type: { tab: true }
};
var registry = ActorRegistryFront(gClient, aResponse);
registry.registerActor(actorURL, options).then(actorFront => {
gClient.listTabs(response => {
var tab = response.tabs[response.selected];
ok(!!tab.helloActor, "Hello actor must exist");
// Make sure actor's state is maintained across listTabs requests.
checkActorState(tab.helloActor, () => {
// Clean up
actorFront.unregister().then(() => {
gClient.close(() => {
DebuggerServer.destroy();
SimpleTest.finish();
});
});
});
});
});
});
});
}
function checkActorState(helloActor, callback) {
getCount(helloActor, response => {
ok(!response.error, "No error");
is(response.count, 1, "The counter must be valid");
getCount(helloActor, response => {
ok(!response.error, "No error");
is(response.count, 2, "The counter must be valid");
gClient.listTabs(response => {
var tab = response.tabs[response.selected];
is(tab.helloActor, helloActor, "Hello actor must be valid");
getCount(helloActor, response => {
ok(!response.error, "No error");
is(response.count, 3, "The counter must be valid");
callback();
});
});
});
});
}
function getCount(actor, callback) {
gClient.request({
to: actor,
type: "count"
}, callback);
}
</script>
</pre>
</body>
</html>