Bug 886546 - implement metro debug actors for developer tools.r=sfoster

This commit is contained in:
Allison Naaktgeboren 2013-06-27 21:18:39 -07:00
parent e782df1f32
commit df2d146ff9
3 changed files with 75 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Cu.import("resource://gre/modules/PageThumbs.jsm");
Cu.import("resource://gre/modules/devtools/dbg-server.jsm")
/**
* Constants
@ -1341,6 +1342,13 @@ var StartUI = {
if (section.init)
section.init();
});
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
DebuggerServer.addActors('chrome://browser/content/dbg-metro-actors.js');
}
DebuggerServer.openListener(6000);
},
uninit: function() {

View File

@ -0,0 +1,66 @@
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 error = Components.utils.reportError;
/* Metrofx specific actors, modelled from the android fennec actors */
/** aConnection DebuggerServerConnection, the conection to the client.
*/
function createRootActor(aConnection) {
let parameters = {
tabList: new MetroTabList(aConnection),
globalActorFactories: DebuggerServer.globalActorFactories,
onShutdown: sendShutdownEvent
};
return new RootActor(aConnection, parameters);
}
/** aConnection DebuggerServerConnection, the conection to the client.
*/
function MetroTabList(aConnection) {
BrowserTabList.call(this, aConnection);
}
MetroTabList.prototype = Object.create(BrowserTabList.prototype);
MetroTabList.prototype.constructor = MetroTabList;
/**
* We want to avoid mysterious behavior if tabs are closed or opened mid-iteration.
* We want at the end, a list of the actors that were live when we began the iteration.
* So, we update the map first, iterate over it again to yield the actors.
*/
MetroTabList.prototype.iterator = function() {
let initialMapSize = this._actorByBrowser.size;
let foundCount = 0;
for (let win of allAppShellDOMWindows("navigator:browser")) {
let selectedTab = win.Browser.selectedBrowser;
for (let browser of win.Browser.browsers) {
let actor = this._actorByBrowser.get(browser);
if (actor) {
foundCount++;
} else {
actor = new BrowserTabActor(this._connection, browser);
this._actorByBrowser.set(browser, actor);
}
// Set the 'selected' properties on all actors correctly.
actor.selected = (browser === selectedTab);
}
}
if (this._testing && initialMapSize !== foundCount) {
throw error("_actorByBrowser map contained actors for dead tabs");
}
this._mustNotify = true;
this._checkListening();
for (let [browser, actor] of this._actorByBrowser) {
yield actor;
}
};

View File

@ -88,6 +88,7 @@ chrome.jar:
content/TopSites.js (content/TopSites.js)
content/console.js (content/console.js)
content/AnimatedZoom.js (content/AnimatedZoom.js)
content/dbg-metro-actors.js (content/dbg-metro-actors.js)
#ifdef MOZ_SERVICES_SYNC
* content/sync.js (content/sync.js)
content/RemoteTabs.js (content/RemoteTabs.js)