Bug 1790912 - Fix lint issues in js/ductwork/debugger. r=ochameau

When we move this out of the js/ directory, a number of lint exceptions stop
applying so we should just fix the issues now.

Differential Revision: https://phabricator.services.mozilla.com/D157521
This commit is contained in:
Ted Campbell 2022-09-25 09:03:33 +00:00
parent 69dfb519c2
commit 410e8dff3f
6 changed files with 36 additions and 25 deletions

View File

@ -136,7 +136,6 @@ dom/workers/test/threadErrors_worker1.js
intl/l10n/
# Exclude everything but self-hosted JS
js/ductwork/
js/examples/
js/public/
js/xpconnect/

View File

@ -54,6 +54,7 @@ const extraXpcshellTestPaths = [
"intl/benchmarks/",
"intl/l10n/test/",
"ipc/testshell/tests/",
"js/ductwork/debugger/tests/",
"memory/replace/dmd/test/",
"netwerk/test/httpserver/test/",
"testing/modules/tests/xpcshell/",

View File

@ -35,7 +35,7 @@ JSDebugger::AddClass(JS::Handle<JS::Value> global, JSContext* cx) {
return NS_ERROR_INVALID_ARG;
}
JS::RootedObject obj(cx, &global.toObject());
JS::Rooted<JSObject*> obj(cx, &global.toObject());
obj = js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false);
if (!obj) {
return NS_ERROR_FAILURE;

View File

@ -3,7 +3,9 @@
* 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/. */
var EXPORTED_SYMBOLS = [ "addDebuggerToGlobal", "addSandboxedDebuggerToGlobal" ];
"use strict";
var EXPORTED_SYMBOLS = ["addDebuggerToGlobal", "addSandboxedDebuggerToGlobal"];
/*
* This is the js module for Debugger. Import it like so:
@ -29,7 +31,7 @@ function addDebuggerToGlobal(global) {
// Defines the Debugger in a sandbox global in a separate compartment. This
// ensures the debugger and debuggee are in different compartments.
function addSandboxedDebuggerToGlobal(global) {
var sb = Cu.Sandbox(global, {freshCompartment: true});
const sb = Cu.Sandbox(global, { freshCompartment: true });
addDebuggerToGlobal(sb);
global.Debugger = sb.Debugger;
}
@ -50,7 +52,7 @@ function initPromiseDebugging(global) {
global.eval(polyfillSource);
}
let polyfillSource = `
const polyfillSource = `
Object.defineProperty(Debugger.Object.prototype, "promiseState", {
get() {
const state = this.PromiseDebugging.getState(this.unsafeDereference());

View File

@ -3,11 +3,12 @@
"use strict";
function testGlobal(aName) {
let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
.createInstance(Ci.nsIPrincipal);
function testGlobal(name) {
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(
Ci.nsIPrincipal
);
let sandbox = Cu.Sandbox(systemPrincipal);
Cu.evalInSandbox("this.__name = '" + aName + "'", sandbox);
const sandbox = Cu.Sandbox(systemPrincipal);
Cu.evalInSandbox("this.__name = '" + name + "'", sandbox);
return sandbox;
}

View File

@ -1,6 +1,9 @@
function run_test()
{
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
"use strict";
function run_test() {
const { addDebuggerToGlobal } = ChromeUtils.import(
"resource://gre/modules/jsdebugger.jsm"
);
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
registerCleanupFunction(() => {
@ -8,30 +11,35 @@ function run_test()
});
addDebuggerToGlobal(globalThis);
var g = testGlobal("test1");
const g = testGlobal("test1");
var dbg = new Debugger();
const dbg = new Debugger();
dbg.addDebuggee(g);
dbg.onDebuggerStatement = function(aFrame) {
let args = aFrame["arguments"];
dbg.onDebuggerStatement = function(frame) {
const args = frame.arguments;
try {
args[0];
Assert.ok(true);
} catch(ex) {
} catch (ex) {
Assert.ok(false);
}
};
g.eval("function stopMe(arg) {debugger;}");
g2 = testGlobal("test2");
const g2 = testGlobal("test2");
g2.g = g;
g2.eval("(" + function createBadEvent() {
Cu.importGlobalProperties(["DOMParser"]);
let parser = new DOMParser();
let doc = parser.parseFromString("<foo></foo>", "text/xml");
g.stopMe(doc.createEvent("MouseEvent"));
} + ")()");
g2.eval(
"(" +
function createBadEvent() {
// eslint-disable-next-line mozilla/reject-importGlobalProperties
Cu.importGlobalProperties(["DOMParser"]);
const parser = new DOMParser();
const doc = parser.parseFromString("<foo></foo>", "text/xml");
g.stopMe(doc.createEvent("MouseEvent"));
} +
")()"
);
dbg.removeAllDebuggees();
}