forked from mirrors/gecko-dev
Bug 1790912 - Use globalThis instead of this with jsdebugger.jsm. r=jandem,ochameau
Use 'globalThis' instead of 'this' when trying to attach a debugger to the current global to avoid subtle footguns with the varied definitions of 'this'. The debugger interface needs a true GlobalObject so this is much clearer. In particular, this is a problem in test_nativewrappers.js when the test runs in strict mode since the 'this' in the test function is no long implicitly the global. Differential Revision: https://phabricator.services.mozilla.com/D157544
This commit is contained in:
parent
70902f1067
commit
69dfb519c2
28 changed files with 28 additions and 28 deletions
|
|
@ -49,7 +49,7 @@ This tutorial was tested against Firefox 58 Beta and Nightly. It does not work i
|
|||
|
||||
// This defines 'Debugger' in this Scratchpad;
|
||||
// it doesn't actually start debugging anything.
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
// Create a 'Debugger' instance.
|
||||
var dbg = new Debugger;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Debugger.Script.prototype.global should return innerize globals, not WindowProxi
|
|||
"use strict";
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ element to which code is attached (if any), and how.
|
|||
"use strict";
|
||||
|
||||
const {addSandboxedDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addSandboxedDebuggerToGlobal(this);
|
||||
addSandboxedDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ behave when 'eval' is called with no scripted frames active at all.
|
|||
"use strict";
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ JavaScrip appearing in an inline event handler attribute.
|
|||
"use strict";
|
||||
|
||||
const {addSandboxedDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addSandboxedDebuggerToGlobal(this);
|
||||
addSandboxedDebuggerToGlobal(globalThis);
|
||||
|
||||
let dbg;
|
||||
let iframeDO, doc;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ object.
|
|||
"use strict";
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Debugger.prototype.makeGlobalObjectReference should dereference WindowProxy
|
|||
"use strict";
|
||||
|
||||
const {addSandboxedDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addSandboxedDebuggerToGlobal(this);
|
||||
addSandboxedDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ xray wrapper.
|
|||
"use strict";
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function run_test() {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(
|
||||
Ci.nsIJSInspector
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function run_test() {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
const g = createTestGlobal("test1");
|
||||
|
||||
const dbg = makeDebugger();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function run_test() {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
const g = createTestGlobal("test", {
|
||||
wantGlobalProperties: ["ChromeUtils"],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// cross-compartment wrappers with interesting properties, and this is the
|
||||
// xpcshell test directory most closely related to the JS Debugger API.
|
||||
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
// Add a method to Debugger.Object for fetching value properties
|
||||
// conveniently.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if (typeof Debugger != "function") {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ if (typeof Debugger != "function") {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if (typeof Debugger != "function") {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ var {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
'resource://gre/modules/jsdebugger.jsm'
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
`,
|
||||
sandbox
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
/**
|
||||
* Ensure that sandboxes created via the Dev Tools loader respect the
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const {
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
"resource://gre/modules/jsdebugger.jsm"
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
function run_test() {
|
||||
Services.prefs.setBoolPref(
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1346936
|
|||
/** Test for Bug 1346936 **/
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=765993
|
|||
/** Test for Bug 765993 **/
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// Hook up the debugger statement to extract the calling script's
|
||||
// introductionType and set it in a property on the parent global.
|
||||
const {addSandboxedDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addSandboxedDebuggerToGlobal(this);
|
||||
addSandboxedDebuggerToGlobal(globalThis);
|
||||
var dbg = new Debugger;
|
||||
dbg.addDebuggee(parent);
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ var EXPORTED_SYMBOLS = [ "addDebuggerToGlobal", "addSandboxedDebuggerToGlobal" ]
|
|||
* const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
* "resource://gre/modules/jsdebugger.jsm"
|
||||
* );
|
||||
* addDebuggerToGlobal(this);
|
||||
* addDebuggerToGlobal(globalThis);
|
||||
*
|
||||
* This will create a 'Debugger' object, which provides an interface to debug
|
||||
* JavaScript code running in other compartments in the same process, on the
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function run_test()
|
|||
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
|
||||
});
|
||||
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
var g = testGlobal("test1");
|
||||
|
||||
var dbg = new Debugger();
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ This tutorial was tested against Firefox 58 Beta and Nightly. It does not work i
|
|||
|
||||
// This simply defines 'Debugger' in this Scratchpad;
|
||||
// it doesn't actually start debugging anything.
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
// Create a 'Debugger' instance.
|
||||
var dbg = new Debugger;
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
|
|||
Cu.evalInSandbox('checkExplicitVersions();', outerSB);
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
try {
|
||||
let dbg = new Debugger();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
const { addDebuggerToGlobal } = ChromeUtils.import(
|
||||
'resource://gre/modules/jsdebugger.jsm'
|
||||
);
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
`, sandbox
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// un-privileged globals.
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
const lowP = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
const highP = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// that frame's principals.
|
||||
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
addDebuggerToGlobal(globalThis);
|
||||
|
||||
const lowP = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
const midP = [lowP, "http://other.com"];
|
||||
|
|
|
|||
Loading…
Reference in a new issue