mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
f6c774eb5e
--HG-- rename : toolkit/devtools/debugger/Makefile.in => toolkit/devtools/client/Makefile.in rename : toolkit/devtools/debugger/dbg-client.jsm => toolkit/devtools/client/dbg-client.jsm rename : toolkit/devtools/debugger/moz.build => toolkit/devtools/client/moz.build rename : toolkit/devtools/debugger/Makefile.in => toolkit/devtools/server/Makefile.in rename : toolkit/devtools/gcli/dbg-gcli-actors.js => toolkit/devtools/server/actors/gcli.js rename : toolkit/devtools/debugger/server/dbg-profiler-actors.js => toolkit/devtools/server/actors/profiler.js rename : toolkit/devtools/debugger/server/dbg-script-actors.js => toolkit/devtools/server/actors/script.js rename : toolkit/devtools/styleeditor/dbg-styleeditor-actors.js => toolkit/devtools/server/actors/styleeditor.js rename : toolkit/devtools/debugger/server/dbg-browser-actors.js => toolkit/devtools/server/actors/webbrowser.js rename : toolkit/devtools/webconsole/dbg-webconsole-actors.js => toolkit/devtools/server/actors/webconsole.js rename : toolkit/devtools/debugger/server/dbg-server.jsm => toolkit/devtools/server/dbg-server.jsm rename : toolkit/devtools/debugger/server/dbg-server.js => toolkit/devtools/server/main.js rename : toolkit/devtools/debugger/moz.build => toolkit/devtools/server/moz.build rename : toolkit/devtools/debugger/nsIJSInspector.idl => toolkit/devtools/server/nsIJSInspector.idl rename : toolkit/devtools/debugger/nsJSInspector.cpp => toolkit/devtools/server/nsJSInspector.cpp rename : toolkit/devtools/debugger/nsJSInspector.h => toolkit/devtools/server/nsJSInspector.h rename : toolkit/devtools/debugger/tests/mochitest/Makefile.in => toolkit/devtools/server/tests/mochitest/Makefile.in rename : toolkit/devtools/debugger/tests/mochitest/moz.build => toolkit/devtools/server/tests/mochitest/moz.build rename : toolkit/devtools/debugger/tests/mochitest/nonchrome_unsafeDereference.html => toolkit/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html rename : toolkit/devtools/debugger/tests/mochitest/test_unsafeDereference.html => toolkit/devtools/server/tests/mochitest/test_unsafeDereference.html rename : toolkit/devtools/debugger/tests/moz.build => toolkit/devtools/server/tests/moz.build rename : toolkit/devtools/debugger/tests/unit/head_dbg.js => toolkit/devtools/server/tests/unit/head_dbg.js rename : toolkit/devtools/debugger/tests/unit/post_init_global_actors.js => toolkit/devtools/server/tests/unit/post_init_global_actors.js rename : toolkit/devtools/debugger/tests/unit/post_init_tab_actors.js => toolkit/devtools/server/tests/unit/post_init_tab_actors.js rename : toolkit/devtools/debugger/tests/unit/pre_init_global_actors.js => toolkit/devtools/server/tests/unit/pre_init_global_actors.js rename : toolkit/devtools/debugger/tests/unit/pre_init_tab_actors.js => toolkit/devtools/server/tests/unit/pre_init_tab_actors.js rename : toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee => toolkit/devtools/server/tests/unit/source-map-data/sourcemapped.coffee rename : toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map => toolkit/devtools/server/tests/unit/source-map-data/sourcemapped.map rename : toolkit/devtools/debugger/tests/unit/sourcemapped.js => toolkit/devtools/server/tests/unit/sourcemapped.js rename : toolkit/devtools/debugger/tests/unit/test_add_actors.js => toolkit/devtools/server/tests/unit/test_add_actors.js rename : toolkit/devtools/debugger/tests/unit/test_attach.js => toolkit/devtools/server/tests/unit/test_attach.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-01.js => toolkit/devtools/server/tests/unit/test_breakpoint-01.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-02.js => toolkit/devtools/server/tests/unit/test_breakpoint-02.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-03.js => toolkit/devtools/server/tests/unit/test_breakpoint-03.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-04.js => toolkit/devtools/server/tests/unit/test_breakpoint-04.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-05.js => toolkit/devtools/server/tests/unit/test_breakpoint-05.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-06.js => toolkit/devtools/server/tests/unit/test_breakpoint-06.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-07.js => toolkit/devtools/server/tests/unit/test_breakpoint-07.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-08.js => toolkit/devtools/server/tests/unit/test_breakpoint-08.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-09.js => toolkit/devtools/server/tests/unit/test_breakpoint-09.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-10.js => toolkit/devtools/server/tests/unit/test_breakpoint-10.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-11.js => toolkit/devtools/server/tests/unit/test_breakpoint-11.js rename : toolkit/devtools/debugger/tests/unit/test_breakpoint-12.js => toolkit/devtools/server/tests/unit/test_breakpoint-12.js rename : toolkit/devtools/debugger/tests/unit/test_breakpointstore.js => toolkit/devtools/server/tests/unit/test_breakpointstore.js rename : toolkit/devtools/debugger/tests/unit/test_dbgactor.js => toolkit/devtools/server/tests/unit/test_dbgactor.js rename : toolkit/devtools/debugger/tests/unit/test_dbgclient_debuggerstatement.js => toolkit/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js rename : toolkit/devtools/debugger/tests/unit/test_dbgglobal.js => toolkit/devtools/server/tests/unit/test_dbgglobal.js rename : toolkit/devtools/debugger/tests/unit/test_dbgsocket.js => toolkit/devtools/server/tests/unit/test_dbgsocket.js rename : toolkit/devtools/debugger/tests/unit/test_eval-01.js => toolkit/devtools/server/tests/unit/test_eval-01.js rename : toolkit/devtools/debugger/tests/unit/test_eval-02.js => toolkit/devtools/server/tests/unit/test_eval-02.js rename : toolkit/devtools/debugger/tests/unit/test_eval-03.js => toolkit/devtools/server/tests/unit/test_eval-03.js rename : toolkit/devtools/debugger/tests/unit/test_eval-04.js => toolkit/devtools/server/tests/unit/test_eval-04.js rename : toolkit/devtools/debugger/tests/unit/test_eval-05.js => toolkit/devtools/server/tests/unit/test_eval-05.js rename : toolkit/devtools/debugger/tests/unit/test_frameactor-01.js => toolkit/devtools/server/tests/unit/test_frameactor-01.js rename : toolkit/devtools/debugger/tests/unit/test_frameactor-02.js => toolkit/devtools/server/tests/unit/test_frameactor-02.js rename : toolkit/devtools/debugger/tests/unit/test_frameactor-03.js => toolkit/devtools/server/tests/unit/test_frameactor-03.js rename : toolkit/devtools/debugger/tests/unit/test_frameactor-04.js => toolkit/devtools/server/tests/unit/test_frameactor-04.js rename : toolkit/devtools/debugger/tests/unit/test_frameactor-05.js => toolkit/devtools/server/tests/unit/test_frameactor-05.js rename : toolkit/devtools/debugger/tests/unit/test_framearguments-01.js => toolkit/devtools/server/tests/unit/test_framearguments-01.js rename : toolkit/devtools/debugger/tests/unit/test_framebindings-01.js => toolkit/devtools/server/tests/unit/test_framebindings-01.js rename : toolkit/devtools/debugger/tests/unit/test_framebindings-02.js => toolkit/devtools/server/tests/unit/test_framebindings-02.js rename : toolkit/devtools/debugger/tests/unit/test_framebindings-03.js => toolkit/devtools/server/tests/unit/test_framebindings-03.js rename : toolkit/devtools/debugger/tests/unit/test_framebindings-04.js => toolkit/devtools/server/tests/unit/test_framebindings-04.js rename : toolkit/devtools/debugger/tests/unit/test_framebindings-05.js => toolkit/devtools/server/tests/unit/test_framebindings-05.js rename : toolkit/devtools/debugger/tests/unit/test_framebindings-06.js => toolkit/devtools/server/tests/unit/test_framebindings-06.js rename : toolkit/devtools/debugger/tests/unit/test_frameclient-01.js => toolkit/devtools/server/tests/unit/test_frameclient-01.js rename : toolkit/devtools/debugger/tests/unit/test_frameclient-02.js => toolkit/devtools/server/tests/unit/test_frameclient-02.js rename : toolkit/devtools/debugger/tests/unit/test_functiongrips-01.js => toolkit/devtools/server/tests/unit/test_functiongrips-01.js rename : toolkit/devtools/debugger/tests/unit/test_getyoungestframe.js => toolkit/devtools/server/tests/unit/test_getyoungestframe.js rename : toolkit/devtools/debugger/tests/unit/test_interrupt.js => toolkit/devtools/server/tests/unit/test_interrupt.js rename : toolkit/devtools/debugger/tests/unit/test_listsources-01.js => toolkit/devtools/server/tests/unit/test_listsources-01.js rename : toolkit/devtools/debugger/tests/unit/test_listsources-02.js => toolkit/devtools/server/tests/unit/test_listsources-02.js rename : toolkit/devtools/debugger/tests/unit/test_listsources-03.js => toolkit/devtools/server/tests/unit/test_listsources-03.js rename : toolkit/devtools/debugger/tests/unit/test_longstringactor.js => toolkit/devtools/server/tests/unit/test_longstringactor.js rename : toolkit/devtools/debugger/tests/unit/test_longstringgrips-01.js => toolkit/devtools/server/tests/unit/test_longstringgrips-01.js rename : toolkit/devtools/debugger/tests/unit/test_longstringgrips-02.js => toolkit/devtools/server/tests/unit/test_longstringgrips-02.js rename : toolkit/devtools/debugger/tests/unit/test_nativewrappers.js => toolkit/devtools/server/tests/unit/test_nativewrappers.js rename : toolkit/devtools/debugger/tests/unit/test_new_source-01.js => toolkit/devtools/server/tests/unit/test_new_source-01.js rename : toolkit/devtools/debugger/tests/unit/test_nsjsinspector.js => toolkit/devtools/server/tests/unit/test_nsjsinspector.js rename : toolkit/devtools/debugger/tests/unit/test_objectgrips-01.js => toolkit/devtools/server/tests/unit/test_objectgrips-01.js rename : toolkit/devtools/debugger/tests/unit/test_objectgrips-02.js => toolkit/devtools/server/tests/unit/test_objectgrips-02.js rename : toolkit/devtools/debugger/tests/unit/test_objectgrips-03.js => toolkit/devtools/server/tests/unit/test_objectgrips-03.js rename : toolkit/devtools/debugger/tests/unit/test_objectgrips-04.js => toolkit/devtools/server/tests/unit/test_objectgrips-04.js rename : toolkit/devtools/debugger/tests/unit/test_pause_exceptions-01.js => toolkit/devtools/server/tests/unit/test_pause_exceptions-01.js rename : toolkit/devtools/debugger/tests/unit/test_pause_exceptions-02.js => toolkit/devtools/server/tests/unit/test_pause_exceptions-02.js rename : toolkit/devtools/debugger/tests/unit/test_pauselifetime-01.js => toolkit/devtools/server/tests/unit/test_pauselifetime-01.js rename : toolkit/devtools/debugger/tests/unit/test_pauselifetime-02.js => toolkit/devtools/server/tests/unit/test_pauselifetime-02.js rename : toolkit/devtools/debugger/tests/unit/test_pauselifetime-03.js => toolkit/devtools/server/tests/unit/test_pauselifetime-03.js rename : toolkit/devtools/debugger/tests/unit/test_pauselifetime-04.js => toolkit/devtools/server/tests/unit/test_pauselifetime-04.js rename : toolkit/devtools/debugger/tests/unit/test_profiler_actor.js => toolkit/devtools/server/tests/unit/test_profiler_actor.js rename : toolkit/devtools/debugger/tests/unit/test_source-01.js => toolkit/devtools/server/tests/unit/test_source-01.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-01.js => toolkit/devtools/server/tests/unit/test_sourcemaps-01.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-02.js => toolkit/devtools/server/tests/unit/test_sourcemaps-02.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-03.js => toolkit/devtools/server/tests/unit/test_sourcemaps-03.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js => toolkit/devtools/server/tests/unit/test_sourcemaps-04.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js => toolkit/devtools/server/tests/unit/test_sourcemaps-05.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-06.js => toolkit/devtools/server/tests/unit/test_sourcemaps-06.js rename : toolkit/devtools/debugger/tests/unit/test_sourcemaps-07.js => toolkit/devtools/server/tests/unit/test_sourcemaps-07.js rename : toolkit/devtools/debugger/tests/unit/test_sources_backwards_compat-01.js => toolkit/devtools/server/tests/unit/test_sources_backwards_compat-01.js rename : toolkit/devtools/debugger/tests/unit/test_sources_backwards_compat-02.js => toolkit/devtools/server/tests/unit/test_sources_backwards_compat-02.js rename : toolkit/devtools/debugger/tests/unit/test_stepping-01.js => toolkit/devtools/server/tests/unit/test_stepping-01.js rename : toolkit/devtools/debugger/tests/unit/test_stepping-02.js => toolkit/devtools/server/tests/unit/test_stepping-02.js rename : toolkit/devtools/debugger/tests/unit/test_stepping-03.js => toolkit/devtools/server/tests/unit/test_stepping-03.js rename : toolkit/devtools/debugger/tests/unit/test_stepping-04.js => toolkit/devtools/server/tests/unit/test_stepping-04.js rename : toolkit/devtools/debugger/tests/unit/test_stepping-05.js => toolkit/devtools/server/tests/unit/test_stepping-05.js rename : toolkit/devtools/debugger/tests/unit/test_threadlifetime-01.js => toolkit/devtools/server/tests/unit/test_threadlifetime-01.js rename : toolkit/devtools/debugger/tests/unit/test_threadlifetime-02.js => toolkit/devtools/server/tests/unit/test_threadlifetime-02.js rename : toolkit/devtools/debugger/tests/unit/test_threadlifetime-03.js => toolkit/devtools/server/tests/unit/test_threadlifetime-03.js rename : toolkit/devtools/debugger/tests/unit/test_threadlifetime-04.js => toolkit/devtools/server/tests/unit/test_threadlifetime-04.js rename : toolkit/devtools/debugger/tests/unit/test_threadlifetime-05.js => toolkit/devtools/server/tests/unit/test_threadlifetime-05.js rename : toolkit/devtools/debugger/tests/unit/test_threadlifetime-06.js => toolkit/devtools/server/tests/unit/test_threadlifetime-06.js rename : toolkit/devtools/debugger/tests/unit/test_unsafeDereference.js => toolkit/devtools/server/tests/unit/test_unsafeDereference.js rename : toolkit/devtools/debugger/tests/unit/testactors.js => toolkit/devtools/server/tests/unit/testactors.js rename : toolkit/devtools/debugger/tests/unit/testcompatactors.js => toolkit/devtools/server/tests/unit/testcompatactors.js rename : toolkit/devtools/debugger/tests/unit/xpcshell.ini => toolkit/devtools/server/tests/unit/xpcshell.ini rename : toolkit/devtools/debugger/dbg-transport.js => toolkit/devtools/server/transport.js
135 lines
6.2 KiB
JavaScript
135 lines
6.2 KiB
JavaScript
// Any copyright is dedicated to the Public Domain.
|
|
// http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
// Test Debugger.Object.prototype.unsafeDereference in the presence of
|
|
// interesting cross-compartment wrappers.
|
|
//
|
|
// This is not really a debugger server test; it's more of a Debugger test.
|
|
// But we need xpcshell and Components.utils.Sandbox to get
|
|
// cross-compartment wrappers with interesting properties, and this is the
|
|
// xpcshell test directory most closely related to the JS Debugger API.
|
|
|
|
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
|
addDebuggerToGlobal(this);
|
|
|
|
// Add a method to Debugger.Object for fetching value properties
|
|
// conveniently.
|
|
Debugger.Object.prototype.getProperty = function (aName) {
|
|
let desc = this.getOwnPropertyDescriptor(aName);
|
|
if (!desc)
|
|
return undefined;
|
|
if (!desc.value) {
|
|
throw Error("Debugger.Object.prototype.getProperty: " +
|
|
"not a value property: " + aName);
|
|
}
|
|
return desc.value;
|
|
};
|
|
|
|
function run_test() {
|
|
// Create a low-privilege sandbox, and a chrome-privilege sandbox.
|
|
let contentBox = Components.utils.Sandbox('http://www.example.com');
|
|
let chromeBox = Components.utils.Sandbox(this);
|
|
|
|
// Create an objects in this compartment, and one in each sandbox. We'll
|
|
// refer to the objects as "mainObj", "contentObj", and "chromeObj", in
|
|
// variable and property names.
|
|
var mainObj = { name: "mainObj" };
|
|
Components.utils.evalInSandbox('var contentObj = { name: "contentObj" };',
|
|
contentBox);
|
|
Components.utils.evalInSandbox('var chromeObj = { name: "chromeObj" };',
|
|
chromeBox);
|
|
|
|
// Give each global a pointer to all the other globals' objects.
|
|
contentBox.mainObj = chromeBox.mainObj = mainObj;
|
|
var contentObj = chromeBox.contentObj = contentBox.contentObj;
|
|
var chromeObj = contentBox.chromeObj = chromeBox.chromeObj;
|
|
|
|
// First, a whole bunch of basic sanity checks, to ensure that JavaScript
|
|
// evaluated in various scopes really does see the world the way this
|
|
// test expects it to.
|
|
|
|
// The objects appear as global variables in the sandbox, and as
|
|
// the sandbox object's properties in chrome.
|
|
do_check_true(Components.utils.evalInSandbox('mainObj', contentBox)
|
|
=== contentBox.mainObj);
|
|
do_check_true(Components.utils.evalInSandbox('contentObj', contentBox)
|
|
=== contentBox.contentObj);
|
|
do_check_true(Components.utils.evalInSandbox('chromeObj', contentBox)
|
|
=== contentBox.chromeObj);
|
|
do_check_true(Components.utils.evalInSandbox('mainObj', chromeBox)
|
|
=== chromeBox.mainObj);
|
|
do_check_true(Components.utils.evalInSandbox('contentObj', chromeBox)
|
|
=== chromeBox.contentObj);
|
|
do_check_true(Components.utils.evalInSandbox('chromeObj', chromeBox)
|
|
=== chromeBox.chromeObj);
|
|
|
|
// We (the main global) can see properties of all objects in all globals.
|
|
do_check_true(contentBox.mainObj.name === "mainObj");
|
|
do_check_true(contentBox.contentObj.name === "contentObj");
|
|
do_check_true(contentBox.chromeObj.name === "chromeObj");
|
|
|
|
// chromeBox can see properties of all objects in all globals.
|
|
do_check_eq(Components.utils.evalInSandbox('mainObj.name', chromeBox),
|
|
'mainObj');
|
|
do_check_eq(Components.utils.evalInSandbox('contentObj.name', chromeBox),
|
|
'contentObj');
|
|
do_check_eq(Components.utils.evalInSandbox('chromeObj.name', chromeBox),
|
|
'chromeObj');
|
|
|
|
// contentBox can see properties of the content object, but not of either
|
|
// chrome object, because by default, content -> chrome wrappers hide all
|
|
// object properties.
|
|
do_check_eq(Components.utils.evalInSandbox('mainObj.name', contentBox),
|
|
undefined);
|
|
do_check_eq(Components.utils.evalInSandbox('contentObj.name', contentBox),
|
|
'contentObj');
|
|
do_check_eq(Components.utils.evalInSandbox('chromeObj.name', contentBox),
|
|
undefined);
|
|
|
|
// When viewing an object in compartment A from the vantage point of
|
|
// compartment B, Debugger should give the same results as debuggee code
|
|
// would.
|
|
|
|
// Create a debugger, debugging our two sandboxes.
|
|
let dbg = new Debugger;
|
|
|
|
// Create Debugger.Object instances referring to the two sandboxes, as
|
|
// seen from their own compartments.
|
|
let contentBoxDO = dbg.addDebuggee(contentBox);
|
|
let chromeBoxDO = dbg.addDebuggee(chromeBox);
|
|
|
|
// Use Debugger to view the objects from contentBox. We should get the
|
|
// same D.O instance from both getProperty and makeDebuggeeValue, and the
|
|
// same property visibility we checked for above.
|
|
let mainFromContentDO = contentBoxDO.getProperty('mainObj');
|
|
do_check_eq(mainFromContentDO, contentBoxDO.makeDebuggeeValue(mainObj));
|
|
do_check_eq(mainFromContentDO.getProperty('name'), undefined);
|
|
do_check_eq(mainFromContentDO.unsafeDereference(), mainObj);
|
|
|
|
let contentFromContentDO = contentBoxDO.getProperty('contentObj');
|
|
do_check_eq(contentFromContentDO, contentBoxDO.makeDebuggeeValue(contentObj));
|
|
do_check_eq(contentFromContentDO.getProperty('name'), 'contentObj');
|
|
do_check_eq(contentFromContentDO.unsafeDereference(), contentObj);
|
|
|
|
let chromeFromContentDO = contentBoxDO.getProperty('chromeObj');
|
|
do_check_eq(chromeFromContentDO, contentBoxDO.makeDebuggeeValue(chromeObj));
|
|
do_check_eq(chromeFromContentDO.getProperty('name'), undefined);
|
|
do_check_eq(chromeFromContentDO.unsafeDereference(), chromeObj);
|
|
|
|
// Similarly, viewing from chromeBox.
|
|
let mainFromChromeDO = chromeBoxDO.getProperty('mainObj');
|
|
do_check_eq(mainFromChromeDO, chromeBoxDO.makeDebuggeeValue(mainObj));
|
|
do_check_eq(mainFromChromeDO.getProperty('name'), 'mainObj');
|
|
do_check_eq(mainFromChromeDO.unsafeDereference(), mainObj);
|
|
|
|
let contentFromChromeDO = chromeBoxDO.getProperty('contentObj');
|
|
do_check_eq(contentFromChromeDO, chromeBoxDO.makeDebuggeeValue(contentObj));
|
|
do_check_eq(contentFromChromeDO.getProperty('name'), 'contentObj');
|
|
do_check_eq(contentFromChromeDO.unsafeDereference(), contentObj);
|
|
|
|
let chromeFromChromeDO = chromeBoxDO.getProperty('chromeObj');
|
|
do_check_eq(chromeFromChromeDO, chromeBoxDO.makeDebuggeeValue(chromeObj));
|
|
do_check_eq(chromeFromChromeDO.getProperty('name'), 'chromeObj');
|
|
do_check_eq(chromeFromChromeDO.unsafeDereference(), chromeObj);
|
|
}
|