Bug 1881701 - Automatically fix new issues raised in devtools. r=devtools-reviewers,frontend-codestyle-reviewers,mossop,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D249956
This commit is contained in:
Mark Banner
2025-05-24 17:08:34 +00:00
committed by mbanner@mozilla.com
parent ce1e9e39d2
commit ee9933d77b
12 changed files with 50 additions and 37 deletions

View File

@@ -178,7 +178,12 @@ export default [
}, },
}, },
{ {
files: ["client/framework/**"], files: [
// Bug 1467784 - Fix these instances to have strict enabled.
"client/framework/**",
"client/shared/components/object-inspector/**",
"client/shared/components/test/node/stubs/object-inspector/",
],
rules: { rules: {
strict: "off", strict: "off",
}, },

View File

@@ -275,7 +275,9 @@ async function onTracingToggled() {
function onDocumentEventAvailable(events) { function onDocumentEventAvailable(events) {
for (const event of events) { for (const event of events) {
// Only consider top level document, and ignore remote iframes top document // Only consider top level document, and ignore remote iframes top document
if (!event.targetFront.isTopLevel) continue; if (!event.targetFront.isTopLevel) {
continue;
}
// The browser toolbox debugger doesn't support the iframe dropdown. // The browser toolbox debugger doesn't support the iframe dropdown.
// you will always see all the sources of all targets of your debugging context. // you will always see all the sources of all targets of your debugging context.
// //

View File

@@ -488,7 +488,9 @@ function findSourceInThreadItem(source, threadItem) {
const groupItem = threadItem.children.find(item => { const groupItem = threadItem.children.find(item => {
return item.groupName == group; return item.groupName == group;
}); });
if (!groupItem) return null; if (!groupItem) {
return null;
}
const parentPath = path.substring(0, path.lastIndexOf("/")); const parentPath = path.substring(0, path.lastIndexOf("/"));
@@ -503,7 +505,9 @@ function findSourceInThreadItem(source, threadItem) {
const directoryItem = groupItem._allGroupDirectoryItems.find(item => { const directoryItem = groupItem._allGroupDirectoryItems.find(item => {
return item.type == "directory" && item.path == parentPath; return item.type == "directory" && item.path == parentPath;
}); });
if (!directoryItem) return null; if (!directoryItem) {
return null;
}
return directoryItem.children.find(item => { return directoryItem.children.find(item => {
return item.type == "source" && item.source == source; return item.type == "source" && item.source == source;

View File

@@ -196,7 +196,9 @@ function update(state = initialState(), action) {
case "SET_SELECTED_LOCATION": { case "SET_SELECTED_LOCATION": {
// Traces are reference to the generated location only, so ignore any original source being selected // Traces are reference to the generated location only, so ignore any original source being selected
// and wait for SET_GENERATED_SELECTED_LOCATION instead. // and wait for SET_GENERATED_SELECTED_LOCATION instead.
if (action.location.source.isOriginal) return state; if (action.location.source.isOriginal) {
return state;
}
// Ignore if the currently selected trace matches the new location. // Ignore if the currently selected trace matches the new location.
if ( if (

View File

@@ -15,7 +15,9 @@ import { createSelector } from "devtools/client/shared/vendor/reselect";
export const getSelectedFrame = createSelector( export const getSelectedFrame = createSelector(
(state, thread) => state.pause.threads[thread || getCurrentThread(state)], (state, thread) => state.pause.threads[thread || getCurrentThread(state)],
threadPauseState => { threadPauseState => {
if (!threadPauseState) return null; if (!threadPauseState) {
return null;
}
const { selectedFrameId, frames } = threadPauseState; const { selectedFrameId, frames } = threadPauseState;
if (frames) { if (frames) {
return frames.find(frame => frame.id == selectedFrameId); return frames.find(frame => frame.id == selectedFrameId);

View File

@@ -195,7 +195,7 @@ class ObjectInspector extends Component {
const length = roots.length; const length = roots.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let rootItem = roots[i]; const rootItem = roots[i];
if (evaluations.has(rootItem.path)) { if (evaluations.has(rootItem.path)) {
roots[i] = getEvaluatedItem(rootItem, evaluations); roots[i] = getEvaluatedItem(rootItem, evaluations);
@@ -371,7 +371,7 @@ const OI = connect(mapStateToProps, actions)(ObjectInspector);
module.exports = props => { module.exports = props => {
const { roots, standalone = false } = props; const { roots, standalone = false } = props;
if (roots.length == 0) { if (!roots.length) {
return null; return null;
} }

View File

@@ -53,7 +53,7 @@ function reducer(state = initialOIState(), action = {}) {
path, path,
updateObject(obj, property, null) updateObject(obj, property, null)
), ),
watchpoints: watchpoints, watchpoints,
}); });
} }

View File

@@ -106,11 +106,11 @@ function mergeResponses(responses) {
data.ownProperties = { ...data.ownProperties, ...response.ownProperties }; data.ownProperties = { ...data.ownProperties, ...response.ownProperties };
} }
if (response.privateProperties && response.privateProperties.length > 0) { if (response.privateProperties && response.privateProperties.length) {
data.privateProperties = response.privateProperties; data.privateProperties = response.privateProperties;
} }
if (response.ownSymbols && response.ownSymbols.length > 0) { if (response.ownSymbols && response.ownSymbols.length) {
data.ownSymbols = response.ownSymbols; data.ownSymbols = response.ownSymbols;
} }

View File

@@ -497,7 +497,7 @@ function makeDefaultPropsBucket(propertiesNames, parent, ownProperties) {
ownProperties ownProperties
); );
if (defaultProperties.length > 0) { if (defaultProperties.length) {
const defaultPropertiesNode = createNode({ const defaultPropertiesNode = createNode({
parent, parent,
name: "<default properties>", name: "<default properties>",

View File

@@ -342,7 +342,7 @@ const previewers = {
grip.preview = { grip.preview = {
kind: "ArrayLike", kind: "ArrayLike",
length: length, length,
}; };
if (depth > 1) { if (depth > 1) {
@@ -462,7 +462,7 @@ const previewers = {
grip.preview = { grip.preview = {
kind: "MapLike", kind: "MapLike",
size: size, size,
}; };
if (depth > 1) { if (depth > 1) {
@@ -908,7 +908,7 @@ function GenericObject(objectActor, grip, depth) {
const privatePropertiesSymbols = ObjectUtils.getSafePrivatePropertiesSymbols( const privatePropertiesSymbols = ObjectUtils.getSafePrivatePropertiesSymbols(
obj obj
); );
if (privatePropertiesSymbols.length > 0) { if (privatePropertiesSymbols.length) {
preview.privatePropertiesLength = privatePropertiesSymbols.length; preview.privatePropertiesLength = privatePropertiesSymbols.length;
preview.privateProperties = []; preview.privateProperties = [];
@@ -945,7 +945,7 @@ function GenericObject(objectActor, grip, depth) {
} }
const symbols = ObjectUtils.getSafeOwnPropertySymbols(obj); const symbols = ObjectUtils.getSafeOwnPropertySymbols(obj);
if (symbols.length > 0) { if (symbols.length) {
preview.ownSymbolsLength = symbols.length; preview.ownSymbolsLength = symbols.length;
preview.ownSymbols = []; preview.ownSymbols = [];
@@ -1244,7 +1244,7 @@ previewers.Object = [
const privatePropertiesSymbols = ObjectUtils.getSafePrivatePropertiesSymbols( const privatePropertiesSymbols = ObjectUtils.getSafePrivatePropertiesSymbols(
obj obj
); );
if (privatePropertiesSymbols.length > 0) { if (privatePropertiesSymbols.length) {
preview.privatePropertiesLength = privatePropertiesSymbols.length; preview.privatePropertiesLength = privatePropertiesSymbols.length;
} }
} else if (className == "Attr") { } else if (className == "Attr") {

View File

@@ -299,7 +299,7 @@ function enumMapEntries(objectActor, depth) {
const entries = getMapEntries(objectActor); const entries = getMapEntries(objectActor);
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, value].map(val => gripFromEntry(objectActor, val, depth)); yield [key, value].map(val => gripFromEntry(objectActor, val, depth));
} }
@@ -335,7 +335,7 @@ function enumStorageEntries(objectActor, depth) {
keys.push(rawObj.key(i)); keys.push(rawObj.key(i));
} }
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const key of keys) { for (const key of keys) {
const value = rawObj.getItem(key); const value = rawObj.getItem(key);
yield [key, value].map(val => gripFromEntry(objectActor, val, depth)); yield [key, value].map(val => gripFromEntry(objectActor, val, depth));
@@ -366,7 +366,7 @@ function enumURLSearchParamsEntries(objectActor, depth) {
const entries = [...waiveXrays(URLSearchParams.prototype.entries.call(objectActor.rawObj))]; const entries = [...waiveXrays(URLSearchParams.prototype.entries.call(objectActor.rawObj))];
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, value]; yield [key, value];
} }
@@ -398,7 +398,7 @@ function enumFormDataEntries(objectActor, depth) {
const entries = [...waiveXrays(FormData.prototype.entries.call(objectActor.rawObj))]; const entries = [...waiveXrays(FormData.prototype.entries.call(objectActor.rawObj))];
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, value]; yield [key, value];
} }
@@ -428,7 +428,7 @@ function enumHeadersEntries(objectActor, depth) {
const entries = [...waiveXrays(Headers.prototype.entries.call(objectActor.rawObj))]; const entries = [...waiveXrays(Headers.prototype.entries.call(objectActor.rawObj))];
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, value]; yield [key, value];
} }
@@ -454,7 +454,7 @@ function enumHighlightRegistryEntries(objectActor, depth) {
: []; : [];
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, gripFromEntry(objectActor, value, depth)]; yield [key, gripFromEntry(objectActor, value, depth)];
} }
@@ -470,7 +470,7 @@ function enumHighlightRegistryEntries(objectActor, depth) {
value: { value: {
type: "highlightRegistryEntry", type: "highlightRegistryEntry",
preview: { preview: {
key: key, key,
value: gripFromEntry(objectActor, value, depth), value: gripFromEntry(objectActor, value, depth),
}, },
}, },
@@ -488,7 +488,7 @@ function enumMidiInputMapEntries(objectActor, depth) {
); );
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, gripFromEntry(objectActor, value, depth)]; yield [key, gripFromEntry(objectActor, value, depth)];
} }
@@ -515,7 +515,7 @@ function enumMidiOutputMapEntries(objectActor, depth) {
); );
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const [key, value] of entries) { for (const [key, value] of entries) {
yield [key, gripFromEntry(objectActor, value, depth)]; yield [key, gripFromEntry(objectActor, value, depth)];
} }
@@ -553,7 +553,7 @@ function enumWeakMapEntries(objectActor, depth) {
const entries = getWeakMapEntries(objectActor.rawObj); const entries = getWeakMapEntries(objectActor.rawObj);
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (let i = 0; i < entries.length; i++) { for (let i = 0; i < entries.length; i++) {
yield entries[i].map(val => gripFromEntry(objectActor, val, depth)); yield entries[i].map(val => gripFromEntry(objectActor, val, depth));
} }
@@ -601,7 +601,7 @@ function enumSetEntries(objectActor, depth) {
); );
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const item of values) { for (const item of values) {
yield gripFromEntry(objectActor, item, depth); yield gripFromEntry(objectActor, item, depth);
} }
@@ -638,7 +638,7 @@ function enumWeakSetEntries(objectActor, depth) {
const keys = getWeakSetEntries(objectActor.rawObj); const keys = getWeakSetEntries(objectActor.rawObj);
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const item of keys) { for (const item of keys) {
yield gripFromEntry(objectActor, item, depth); yield gripFromEntry(objectActor, item, depth);
} }
@@ -658,7 +658,7 @@ function enumWeakSetEntries(objectActor, depth) {
} }
function enumCustomStateSetEntries(objectActor, depth) { function enumCustomStateSetEntries(objectActor, depth) {
let { rawObj } = objectActor; const { rawObj } = objectActor;
// We need to waive `rawObj` as we can't get the iterator from the Xray for SetLike (See Bug 1173651). // We need to waive `rawObj` as we can't get the iterator from the Xray for SetLike (See Bug 1173651).
// We also need to waive Xrays on the result of the call to `values` as we don't have // We also need to waive Xrays on the result of the call to `values` as we don't have
// Xrays to Iterator objects (see Bug 1023984) // Xrays to Iterator objects (see Bug 1023984)
@@ -667,7 +667,7 @@ function enumCustomStateSetEntries(objectActor, depth) {
); );
return { return {
[Symbol.iterator]: function*() { *[Symbol.iterator]() {
for (const item of values) { for (const item of values) {
yield gripFromEntry(objectActor, item, depth); yield gripFromEntry(objectActor, item, depth);
} }

View File

@@ -2,16 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
import { TEST_PAGE_HTML, CONTEXTS, AllObjects } from "resource://testing-common/AllJavascriptTypes.mjs";
export { CONTEXTS } from "resource://testing-common/AllJavascriptTypes.mjs";
import { ObjectUtils } from "resource://gre/modules/ObjectUtils.sys.mjs"; import { ObjectUtils } from "resource://gre/modules/ObjectUtils.sys.mjs";
import { TEST_PAGE_HTML, CONTEXTS, AllObjects } from "resource://testing-common/AllJavascriptTypes.mjs";
import { AddonTestUtils } from "resource://testing-common/AddonTestUtils.sys.mjs"
// Name of the environment variable to set while running the test to update the expected values // Name of the environment variable to set while running the test to update the expected values
const UPDATE_SNAPSHOT_ENV = "UPDATE_SNAPSHOT"; const UPDATE_SNAPSHOT_ENV = "UPDATE_SNAPSHOT";
const { AddonTestUtils } = ChromeUtils.importESModule( export { CONTEXTS } from "resource://testing-common/AllJavascriptTypes.mjs";
"resource://testing-common/AddonTestUtils.sys.mjs"
);
// To avoid totally unrelated exceptions about missing appinfo when running from xpcshell tests // To avoid totally unrelated exceptions about missing appinfo when running from xpcshell tests
const isXpcshell = Services.env.exists("XPCSHELL_TEST_PROFILE_DIR"); const isXpcshell = Services.env.exists("XPCSHELL_TEST_PROFILE_DIR");
@@ -54,7 +52,7 @@ function init(testScope) {
}); });
// Lookup for all preferences to toggle in order to have all the expected objects type functional // Lookup for all preferences to toggle in order to have all the expected objects type functional
let prefValues = new Map(); const prefValues = new Map();
for (const { prefs } of AllObjects) { for (const { prefs } of AllObjects) {
if (!prefs) { if (!prefs) {
continue; continue;