Skip to content

Commit

Permalink
Bug 1790912 - Fix lint issues in js/ductwork/debugger. r=ochameau
Browse files Browse the repository at this point in the history
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
  • Loading branch information
moztcampbell committed Sep 25, 2022
1 parent 69dfb51 commit 410e8df
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 25 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
1 change: 1 addition & 0 deletions .eslintrc-test-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
2 changes: 1 addition & 1 deletion js/ductwork/debugger/JSDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions js/ductwork/debugger/jsdebugger.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
}
Expand All @@ -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());
Expand Down
11 changes: 6 additions & 5 deletions js/ductwork/debugger/tests/head_dbg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
38 changes: 23 additions & 15 deletions js/ductwork/debugger/tests/test_nativewrappers.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
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(() => {
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
});

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();
}

0 comments on commit 410e8df

Please sign in to comment.