Bug 1084525 - Part 1: Create initial PromisesActor skeleton r=fitzgen

This commit is contained in:
Gabriel Luong 2015-06-02 14:52:46 -07:00
parent dd5bb481cf
commit 83a240b339
6 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,38 @@
/* 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, RetVal, Arg, types } = protocol;
/**
* The Promises Actor provides support for getting the list of live promises and
* observing changes to their settlement state.
*/
let PromisesActor = protocol.ActorClass({
typeName: "promises",
/**
* @param conn DebuggerServerConnection.
* @param parent TabActor|RootActor
*/
initialize: function(conn, parent) {
protocol.Actor.prototype.initialize.call(this, conn);
},
destroy: function() {
protocol.Actor.prototype.destroy.call(this, conn);
},
});
exports.PromisesActor = PromisesActor;
exports.PromisesFront = protocol.FrontClass(PromisesActor, {
initialize: function(client, form) {
protocol.Front.prototype.initialize.call(this, client, form);
this.actorID = form.promisesActor;
this.manage(this);
}
});

View File

@ -544,6 +544,11 @@ var DebuggerServer = {
constructor: "AnimationsActor",
type: { tab: true }
});
this.registerModule("devtools/server/actors/promises", {
prefix: "promises",
constructor: "PromisesActor",
type: { global: true, tab: true }
});
},
/**

View File

@ -77,6 +77,7 @@ EXTRA_JS_MODULES.devtools.server.actors += [
'actors/preference.js',
'actors/pretty-print-worker.js',
'actors/profiler.js',
'actors/promises.js',
'actors/root.js',
'actors/script.js',
'actors/settings.js',

View File

@ -301,6 +301,20 @@ function initTestDebuggerServer(aServer = DebuggerServer)
aServer.init(function () { return true; });
}
/**
* Initialize the testing debugger server with a tab whose title is |title|.
*/
function startTestDebuggerServer(title, server = DebuggerServer) {
initTestDebuggerServer(server);
addTestGlobal(title);
DebuggerServer.addTabActors();
let transport = DebuggerServer.connectPipe();
let client = new DebuggerClient(transport);
return connect(client).then(() => client);
}
function initTestTracerServer(aServer = DebuggerServer)
{
aServer.registerModule("xpcshell-test/testactors");
@ -338,6 +352,11 @@ function get_chrome_actors(callback)
});
}
function getChromeActors(client, server = DebuggerServer) {
server.allowChromeProcess = true;
return client.getProcess().then(response => response.form);
}
/**
* Takes a relative file path and returns the absolute file url for it.
*/

View File

@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that the PromisesActor exists in the TabActors and ChromeActors.
*/
add_task(function*() {
let client = yield startTestDebuggerServer("promises-actor-test");
let response = yield listTabs(client);
let targetTab = findTab(response.tabs, "promises-actor-test");
ok(targetTab, "Found our target tab.")
// Attach to the TabActor and check the response
client.request({ to: targetTab.actor, type: "attach" }, response => {
ok(!("error" in response), "Expect no error in response.");
ok(response.from, targetTab.actor,
"Expect the target TabActor in response form field.");
ok(response.type, "tabAttached",
"Expect tabAttached in the response type.");
is(typeof response.promisesActor === "string",
"Should have a tab context PromisesActor.");
});
let chromeActors = yield getChromeActors(client);
ok(typeof chromeActors.promisesActor === "string",
"Should have a chrome context PromisesActor.");
});

View File

@ -80,6 +80,7 @@ support-files =
[test_eval-03.js]
[test_eval-04.js]
[test_eval-05.js]
[test_promises_actor_exist.js]
[test_protocol_abort.js]
[test_protocol_async.js]
[test_protocol_children.js]