Bug 859372 - Refactor script.js; r=past

This commit is contained in:
Eddy Bruel 2014-04-29 17:52:44 +02:00
Родитель 627501df02
Коммит 2baf4e8ddf
10 изменённых файлов: 67 добавлений и 30 удалений

Просмотреть файл

@ -509,12 +509,13 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, {
if (stackframeItem) {
// The container is not empty and an actual item was selected.
let depth = stackframeItem.attachment.depth;
DebuggerController.StackFrames.selectFrame(depth);
// Mirror the selected item in the classic list.
this.suppressSelectionEvents = true;
this._mirror.selectedItem = e => e.attachment.depth == depth;
this.suppressSelectionEvents = false;
DebuggerController.StackFrames.selectFrame(depth);
}
},

Просмотреть файл

@ -749,10 +749,11 @@ function openVarPopup(aPanel, aCoords, aWaitForFetchedProperties) {
let fetchedProperties = aWaitForFetchedProperties
? waitForDebuggerEvents(aPanel, events.FETCHED_BUBBLE_PROPERTIES)
: promise.resolve(null);
let updatedFrame = waitForDebuggerEvents(aPanel, events.FETCHED_SCOPES);
let { left, top } = editor.getCoordsFromPosition(aCoords);
bubble._findIdentifier(left, top);
return promise.all([popupShown, fetchedProperties]).then(waitForTick);
return promise.all([popupShown, fetchedProperties, updatedFrame]).then(waitForTick);
}
// Simulates the mouse hovering a variable in the debugger

Просмотреть файл

@ -6,6 +6,18 @@
"use strict";
const Debugger = require("Debugger");
const Services = require("Services");
const { Cc, Ci, Cu, components } = require("chrome");
const { ActorPool } = require("devtools/server/actors/common");
const { DebuggerServer } = require("devtools/server/main");
const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
const { dbg_assert, dumpn } = DevToolsUtils;
const { SourceMapConsumer, SourceMapGenerator } = require("source-map");
const { all, defer, resolve } = promise;
Cu.import("resource://gre/modules/NetUtil.jsm");
let B2G_ID = "{3c2e2abc-06d4-11e1-ac3b-374f68613e61}";
let TYPED_ARRAY_CLASSES = ["Uint8Array", "Uint8ClampedArray", "Uint16Array",
@ -38,7 +50,7 @@ function mapURIToAddonID(uri, id) {
return addonManager.mapURIToAddonID(uri, id);
}
catch (e) {
DevtoolsUtils.reportException("mapURIToAddonID", e);
DevToolsUtils.reportException("mapURIToAddonID", e);
return false;
}
}
@ -313,6 +325,8 @@ BreakpointStore.prototype = {
},
};
exports.BreakpointStore = BreakpointStore;
/**
* Manages pushing event loops and automatically pops and exits them in the
* correct order as they are resolved.
@ -2398,6 +2412,7 @@ ThreadActor.prototype.requestTypes = {
"prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties
};
exports.ThreadActor = ThreadActor;
/**
* Creates a PauseActor.
@ -3461,6 +3476,7 @@ ObjectActor.prototype.requestTypes = {
"scope": ObjectActor.prototype.onScope,
};
exports.ObjectActor = ObjectActor;
/**
* Functions for adding information to ObjectActor grips for the purpose of
@ -4236,6 +4252,7 @@ LongStringActor.prototype.requestTypes = {
"release": LongStringActor.prototype.onRelease
};
exports.LongStringActor = LongStringActor;
/**
* Creates an actor for the specified stack frame.
@ -4647,6 +4664,8 @@ EnvironmentActor.prototype.requestTypes = {
"bindings": EnvironmentActor.prototype.onBindings
};
exports.EnvironmentActor = EnvironmentActor;
/**
* Override the toString method in order to get more meaningful script output
* for debugging the debugger.
@ -4748,6 +4767,8 @@ update(ChromeDebuggerActor.prototype, {
}
});
exports.ChromeDebuggerActor = ChromeDebuggerActor;
/**
* Creates an actor for handling add-on debugging. AddonThreadActor is
* a thin wrapper over ThreadActor.
@ -4923,6 +4944,8 @@ update(AddonThreadActor.prototype.requestTypes, {
"attach": AddonThreadActor.prototype.onAttach
});
exports.AddonThreadActor = AddonThreadActor;
/**
* Manages the sources for a thread. Handles source maps, locations in the
* sources, etc for ThreadActors.
@ -5285,6 +5308,8 @@ ThreadSources.prototype = {
}
};
exports.ThreadSources = ThreadSources;
// Utility functions.
// TODO bug 863089: use Debugger.Script.prototype.getOffsetColumn when it is
@ -5393,7 +5418,7 @@ function fetch(aURL, aOptions={ loadFromCache: true }) {
case "resource":
try {
NetUtil.asyncFetch(url, function onFetch(aStream, aStatus, aRequest) {
if (!Components.isSuccessCode(aStatus)) {
if (!components.isSuccessCode(aStatus)) {
deferred.reject(new Error("Request failed with status code = "
+ aStatus
+ " after NetUtil.asyncFetch for url = "
@ -5424,7 +5449,7 @@ function fetch(aURL, aOptions={ loadFromCache: true }) {
let chunks = [];
let streamListener = {
onStartRequest: function(aRequest, aContext, aStatusCode) {
if (!Components.isSuccessCode(aStatusCode)) {
if (!components.isSuccessCode(aStatusCode)) {
deferred.reject(new Error("Request failed with status code = "
+ aStatusCode
+ " in onStartRequest handler for url = "
@ -5435,7 +5460,7 @@ function fetch(aURL, aOptions={ loadFromCache: true }) {
chunks.push(NetUtil.readInputStreamToString(aStream, aCount));
},
onStopRequest: function(aRequest, aContext, aStatusCode) {
if (!Components.isSuccessCode(aStatusCode)) {
if (!components.isSuccessCode(aStatusCode)) {
deferred.reject(new Error("Request failed with status code = "
+ aStatusCode
+ " in onStopRequest handler for url = "
@ -5600,3 +5625,15 @@ function getInnerId(window) {
return window.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
};
exports.register = function(handle) {
ThreadActor.breakpointStore = new BreakpointStore();
ThreadSources._blackBoxedSources = new Set(["self-hosted"]);
ThreadSources._prettyPrintedSources = new Map();
};
exports.unregister = function(handle) {
ThreadActor.breakpointStore = null;
ThreadSources._blackBoxedSources.clear();
ThreadSources._prettyPrintedSources.clear();
};

Просмотреть файл

@ -6,12 +6,13 @@
"use strict";
let {Ci,Cu} = require("chrome");
let {createExtraActors, appendExtraActors} = require("devtools/server/actors/common");
let { Ci, Cu } = require("chrome");
let Services = require("Services");
let { createExtraActors, appendExtraActors } = require("devtools/server/actors/common");
let { AddonThreadActor, ThreadActor } = require("devtools/server/actors/script");
let DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");

Просмотреть файл

@ -6,17 +6,13 @@
"use strict";
let {Cc, Ci, Cu} = require("chrome");
const { Cc, Ci, Cu } = require("chrome");
const Debugger = require("Debugger");
const { DebuggerServer, ActorPool } = require("devtools/server/main");
const { EnvironmentActor, LongStringActor, ObjectActor, ThreadActor } = require("devtools/server/actors/script");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
let { DebuggerServer, ActorPool } = require("devtools/server/main");
// Symbols from script.js
let { ThreadActor, EnvironmentActor, ObjectActor, LongStringActor } = DebuggerServer;
Cu.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "NetworkMonitor", () => {

Просмотреть файл

@ -346,7 +346,8 @@ var DebuggerServer = {
if (!restrictPrivileges) {
this.addTabActors();
this.addGlobalActor(this.ChromeDebuggerActor, "chromeDebugger");
let { ChromeDebuggerActor } = require("devtools/server/actors/script");
this.addGlobalActor(ChromeDebuggerActor, "chromeDebugger");
this.registerModule("devtools/server/actors/preference");
}
@ -377,7 +378,7 @@ var DebuggerServer = {
* Install tab actors.
*/
addTabActors: function() {
this.addActors("resource://gre/modules/devtools/server/actors/script.js");
this.registerModule("devtools/server/actors/script");
this.registerModule("devtools/server/actors/webconsole");
this.registerModule("devtools/server/actors/inspector");
this.registerModule("devtools/server/actors/call-watcher");

Просмотреть файл

@ -8,11 +8,11 @@ const Cu = Components.utils;
const Cr = Components.results;
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const Services = devtools.require("Services");
const { ActorPool, createExtraActors, appendExtraActors } = devtools.require("devtools/server/actors/common");
const DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js");
const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
const Services = devtools.require("Services");
const DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js");
// Always log packets when running tests. runxpcshelltests.py will throw
// the output away anyway, unless you give it the --verbose flag.
Services.prefs.setBoolPref("devtools.debugger.log", true);
@ -34,6 +34,8 @@ tryImport("resource://gre/modules/devtools/dbg-client.jsm");
tryImport("resource://gre/modules/devtools/Loader.jsm");
tryImport("resource://gre/modules/devtools/Console.jsm");
let { BreakpointStore, LongStringActor, ThreadActor } = devtools.require("devtools/server/actors/script");
function testExceptionHook(ex) {
try {
do_report_unexpected_exception(ex);
@ -182,7 +184,7 @@ function attachTestTabAndResume(aClient, aTitle, aCallback) {
function initTestDebuggerServer()
{
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/root.js");
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/script.js");
DebuggerServer.registerModule("devtools/server/actors/script");
DebuggerServer.addActors("resource://test/testactors.js");
// Allow incoming connections.
DebuggerServer.init(function () { return true; });
@ -191,7 +193,7 @@ function initTestDebuggerServer()
function initTestTracerServer()
{
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/root.js");
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/script.js");
DebuggerServer.registerModule("devtools/server/actors/script");
DebuggerServer.addActors("resource://test/testactors.js");
DebuggerServer.registerModule("devtools/server/actors/tracer");
// Allow incoming connections.

Просмотреть файл

@ -8,9 +8,6 @@ function run_test()
{
Cu.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("resource://gre/modules/devtools/server/actors/script.js");
test_has_breakpoint();
test_bug_754251();

Просмотреть файл

@ -6,9 +6,6 @@ function run_test()
{
Cu.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("resource://gre/modules/devtools/server/actors/script.js");
test_LSA_disconnect();
test_LSA_grip();

Просмотреть файл

@ -1,6 +1,10 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Cu = Components.utils;
const devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
const { ThreadActor } = devtools.require("devtools/server/actors/script");
var gTestGlobals = [];
DebuggerServer.addTestGlobal = function(aGlobal) {
gTestGlobals.push(aGlobal);