mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 749316 - Put Debugger object into chrome scratchpad. r=dcamp,bholley.
--HG-- extra : rebase_source : 12ab275ac9cdfa0e9890c507e30e0b56e4086816
This commit is contained in:
parent
f103f34e07
commit
68ca935eed
@ -61,6 +61,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource:///modules/PropertyPanel.jsm");
|
||||
Cu.import("resource:///modules/source-editor.jsm");
|
||||
Cu.import("resource:///modules/devtools/scratchpad-manager.jsm");
|
||||
Cu.import("resource://gre/modules/jsdebugger.jsm");
|
||||
|
||||
|
||||
const SCRATCHPAD_CONTEXT_CONTENT = 1;
|
||||
@ -295,6 +296,7 @@ var Scratchpad = {
|
||||
this._chromeSandbox = new Cu.Sandbox(this.browserWindow,
|
||||
{ sandboxPrototype: this.browserWindow, wantXrays: false,
|
||||
sandboxName: 'scratchpad-chrome'});
|
||||
addDebuggerToGlobal(this._chromeSandbox);
|
||||
|
||||
this._previousBrowserWindow = this.browserWindow;
|
||||
}
|
||||
|
@ -40,13 +40,14 @@
|
||||
/**
|
||||
* Do not use this interface. Instead, write:
|
||||
* Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
* addDebuggerToGlobal(global);
|
||||
*/
|
||||
[scriptable, uuid(2fc14cc6-4ed0-4bbf-a7dd-e535bf088eb5)]
|
||||
[scriptable, uuid(a36fa816-31da-4b23-bc97-6412771f0867)]
|
||||
interface IJSDebugger : nsISupports
|
||||
{
|
||||
/**
|
||||
* Define the global Debugger constructor.
|
||||
* Define the global Debugger constructor on a given global.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void addClass();
|
||||
void addClass(in jsval global);
|
||||
};
|
||||
|
@ -69,17 +69,31 @@ JSDebugger::~JSDebugger()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
JSDebugger::AddClass(JSContext *cx)
|
||||
JSDebugger::AddClass(const JS::Value &global, JSContext* cx)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);
|
||||
|
||||
JSObject* global = JS_GetGlobalForScopeChain(cx);
|
||||
if (!global) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
if (!global.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JSObject* obj = &global.toObject();
|
||||
obj = JS_UnwrapObjectAndInnerize(obj);
|
||||
if (!obj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!JS_DefineDebuggerObject(cx, global)) {
|
||||
JSAutoEnterCompartment aec;
|
||||
if (!aec.enter(cx, obj)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (JS_GetGlobalForObject(cx, obj) != obj) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!JS_DefineDebuggerObject(cx, obj)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,12 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
let EXPORTED_SYMBOLS = [ "Debugger" ];
|
||||
let EXPORTED_SYMBOLS = [ "addDebuggerToGlobal" ];
|
||||
|
||||
/*
|
||||
* This is the js module for Debugger. Import it like so:
|
||||
* Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
* addDebuggerToGlobal(this);
|
||||
*
|
||||
* This will create a 'Debugger' object, which provides an interface to debug
|
||||
* JavaScript code running in other compartments in the same process, on the
|
||||
@ -50,6 +51,7 @@ let EXPORTED_SYMBOLS = [ "Debugger" ];
|
||||
* https://wiki.mozilla.org/Debugger
|
||||
*/
|
||||
|
||||
// Initialize the Debugger object. You do not need to do this yourself.
|
||||
const init = Components.classes["@mozilla.org/jsdebugger;1"].createInstance(Components.interfaces.IJSDebugger);
|
||||
init.addClass();
|
||||
function addDebuggerToGlobal(global) {
|
||||
init.addClass(global);
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
function run_test()
|
||||
{
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
var g = testGlobal("test1");
|
||||
|
||||
var dbg = new Debugger();
|
||||
|
@ -1775,6 +1775,12 @@ JS_UnwrapObject(JSObject *obj)
|
||||
return UnwrapObject(obj);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_UnwrapObjectAndInnerize(JSObject *obj)
|
||||
{
|
||||
return UnwrapObject(obj, /* stopAtOuter = */ false);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_CallContextDebugHandler(JSContext *cx)
|
||||
{
|
||||
|
@ -550,6 +550,9 @@ JS_DumpCompartmentPCCounts(JSContext *cx);
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_UnwrapObject(JSObject *obj);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_UnwrapObjectAndInnerize(JSObject *obj);
|
||||
|
||||
/* Call the context debug handler on the topmost scripted frame. */
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_CallContextDebugHandler(JSContext *cx);
|
||||
|
@ -51,6 +51,9 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
|
||||
|
||||
Cu.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
||||
function dumpn(str) {
|
||||
if (wantLogging) {
|
||||
dump("DBG-SERVER: " + str + "\n");
|
||||
@ -97,13 +100,6 @@ var DebuggerServer = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack: Merely loading jsdebugger.jsm will not work, because it will load
|
||||
// in the chrome compartment, and then we'd get a cross-compartment wrapper
|
||||
// of that. The Debugger object must be created in the sandbox compartment,
|
||||
// that is, this file's compartment.
|
||||
const init = Cc["@mozilla.org/jsdebugger;1"].createInstance(Ci.IJSDebugger);
|
||||
init.addClass(); // adds global variable Debugger to this global.
|
||||
|
||||
this.xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
||||
this.initTransport();
|
||||
this.addActors("chrome://global/content/devtools/dbg-script-actors.js");
|
||||
|
@ -1,6 +1,7 @@
|
||||
function run_test()
|
||||
{
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
var xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
||||
var g = testGlobal("test1");
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
function run_test()
|
||||
{
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
var g = testGlobal("test1");
|
||||
|
||||
var dbg = new Debugger();
|
||||
|
Loading…
Reference in New Issue
Block a user