Skip to content

Commit 3dffd37

Browse files
bmeurerDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
Consistently use assert.deepEqual instead of assert.deepStrictEqual.
Previously we have been a bit sloppy with sometimes using one or the other. In Chai both methods perform exactly the same comparison, but the name `deepStrictEqual` can be a bit confusing to developers not familiar with the Chai implementation, and particularly might leave you wondering what exactly is *strict* about this method. Fixed: 386330115 Change-Id: Idda55ee784b01cce650996ab3d56f76e220e6b2c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6110227 Commit-Queue: Samiya Caur <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Reviewed-by: Samiya Caur <[email protected]>
1 parent 586a9a5 commit 3dffd37

File tree

139 files changed

+898
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+898
-794
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ module.exports = {
293293

294294
'rulesdir/check-test-definitions' : 'error',
295295
'rulesdir/no-assert-equal' : 'error',
296+
'rulesdir/no-assert-deep-strict-equal' : 'error',
296297
'rulesdir/no-repeated-tests' : 'error',
297298
'rulesdir/compare-arrays-with-assert-deepequal' : 'error',
298299
'rulesdir/no-screenshot-test-outside-perf-panel' : 'error',

front_end/core/host/AidaClient.test.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describeWithEnvironment('AidaClient', () => {
1212
it('adds no model temperature if console insights is not enabled', () => {
1313
const stub = getGetHostConfigStub({});
1414
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
15-
assert.deepStrictEqual(request, {
15+
assert.deepEqual(request, {
1616
current_message: {parts: [{text: 'foo'}], role: Host.AidaClient.Role.USER},
1717
client: 'CHROME_DEVTOOLS',
1818
client_feature: 1,
@@ -29,7 +29,7 @@ describeWithEnvironment('AidaClient', () => {
2929
},
3030
});
3131
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
32-
assert.deepStrictEqual(request, {
32+
assert.deepEqual(request, {
3333
current_message: {parts: [{text: 'foo'}], role: Host.AidaClient.Role.USER},
3434
client: 'CHROME_DEVTOOLS',
3535
options: {
@@ -49,7 +49,7 @@ describeWithEnvironment('AidaClient', () => {
4949
},
5050
});
5151
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
52-
assert.deepStrictEqual(request, {
52+
assert.deepEqual(request, {
5353
current_message: {parts: [{text: 'foo'}], role: Host.AidaClient.Role.USER},
5454
client: 'CHROME_DEVTOOLS',
5555
options: {
@@ -69,7 +69,7 @@ describeWithEnvironment('AidaClient', () => {
6969
},
7070
});
7171
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
72-
assert.deepStrictEqual(request, {
72+
assert.deepEqual(request, {
7373
current_message: {parts: [{text: 'foo'}], role: Host.AidaClient.Role.USER},
7474
client: 'CHROME_DEVTOOLS',
7575
client_feature: 1,
@@ -87,7 +87,7 @@ describeWithEnvironment('AidaClient', () => {
8787
},
8888
});
8989
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
90-
assert.deepStrictEqual(request, {
90+
assert.deepEqual(request, {
9191
current_message: {parts: [{text: 'foo'}], role: Host.AidaClient.Role.USER},
9292
client: 'CHROME_DEVTOOLS',
9393
options: {
@@ -111,7 +111,7 @@ describeWithEnvironment('AidaClient', () => {
111111
},
112112
});
113113
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
114-
assert.deepStrictEqual(request, {
114+
assert.deepEqual(request, {
115115
current_message: {parts: [{text: 'foo'}], role: Host.AidaClient.Role.USER},
116116
client: 'CHROME_DEVTOOLS',
117117
metadata: {
@@ -153,7 +153,7 @@ describeWithEnvironment('AidaClient', () => {
153153

154154
const provider = new Host.AidaClient.AidaClient();
155155
const results = await getAllResults(provider);
156-
assert.deepStrictEqual(results, [
156+
assert.deepEqual(results, [
157157
{
158158
explanation: 'hello ',
159159
metadata: {rpcGlobalId: 123},
@@ -191,7 +191,7 @@ describeWithEnvironment('AidaClient', () => {
191191

192192
const provider = new Host.AidaClient.AidaClient();
193193
const results = await getAllResults(provider);
194-
assert.deepStrictEqual(results, [
194+
assert.deepEqual(results, [
195195
{
196196
explanation: 'hello world',
197197
metadata: {rpcGlobalId: 123},
@@ -233,7 +233,7 @@ describeWithEnvironment('AidaClient', () => {
233233

234234
const provider = new Host.AidaClient.AidaClient();
235235
const results = await getAllResults(provider);
236-
assert.deepStrictEqual(results, [
236+
assert.deepEqual(results, [
237237
{
238238
explanation: 'Friends, Romans, countrymen, lend me your ears;\n' +
239239
'I come to bury Caesar, not to praise him.\n',
@@ -313,7 +313,7 @@ describeWithEnvironment('AidaClient', () => {
313313

314314
const provider = new Host.AidaClient.AidaClient();
315315
const results = await getAllResults(provider);
316-
assert.deepStrictEqual(results, [
316+
assert.deepEqual(results, [
317317
{
318318
explanation: 'Chunk1\n' +
319319
'Chunk2\n',
@@ -391,7 +391,7 @@ describeWithEnvironment('AidaClient', () => {
391391

392392
const provider = new Host.AidaClient.AidaClient();
393393
const results = (await getAllResults(provider)).map(r => r.explanation);
394-
assert.deepStrictEqual(results, [
394+
assert.deepEqual(results, [
395395
'hello ',
396396
'hello \n`````\nbrave \n`````\n',
397397
'hello \n`````\nbrave new World()\n`````\n',

front_end/core/platform/ArrayUtilities.test.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ describe('ArrayUtilities', () => {
2727
const actualFirstOnlyTrue = [...testCase.input];
2828

2929
Platform.ArrayUtilities.removeElement(actualFirstOnlyTrue, 2, true);
30-
assert.deepStrictEqual(actualFirstOnlyTrue, testCase.expectedFirstOnlyTrue, 'Removing firstOnly (true) failed');
30+
assert.deepEqual(actualFirstOnlyTrue, testCase.expectedFirstOnlyTrue, 'Removing firstOnly (true) failed');
3131

3232
const actualFirstOnlyFalse = [...testCase.input];
3333
Platform.ArrayUtilities.removeElement(actualFirstOnlyFalse, 2, false);
34-
assert.deepStrictEqual(
35-
actualFirstOnlyFalse, testCase.expectedFirstOnlyFalse, 'Removing firstOnly (false) failed');
34+
assert.deepEqual(actualFirstOnlyFalse, testCase.expectedFirstOnlyFalse, 'Removing firstOnly (false) failed');
3635
}
3736
});
3837
});
@@ -54,20 +53,20 @@ describe('ArrayUtilities', () => {
5453
for (let count = 1, k = right - first + 1; count <= k; ++count) {
5554
const actual = fixture.slice(0);
5655
Platform.ArrayUtilities.sortRange(actual, comparator, left, right, first, first + count - 1);
57-
assert.deepStrictEqual(
56+
assert.deepEqual(
5857
fixture.slice(0, left), actual.slice(0, left), 'left ' + left + ' ' + right + ' ' + count);
59-
assert.deepStrictEqual(
58+
assert.deepEqual(
6059
fixture.slice(right + 1), actual.slice(right + 1), 'right ' + left + ' ' + right + ' ' + count);
6160

6261
const middle = fixture.slice(left, right + 1);
6362
middle.sort(comparator);
64-
assert.deepStrictEqual(
63+
assert.deepEqual(
6564
middle.slice(first - left, first - left + count), actual.slice(first, first + count),
6665
'sorted ' + left + ' ' + right + ' ' + first + ' ' + count);
6766

6867
const actualRest = actual.slice(first + count, right + 1);
6968
actualRest.sort(comparator);
70-
assert.deepStrictEqual(
69+
assert.deepEqual(
7170
middle.slice(first - left + count), actualRest,
7271
'unsorted ' + left + ' ' + right + ' ' + first + ' ' + count);
7372
}
@@ -137,7 +136,7 @@ describe('ArrayUtilities', () => {
137136
}
138137

139138
const shallowCopy = [...actual];
140-
assert.deepStrictEqual(actual.sort(), shallowCopy, 'Result array is ordered');
139+
assert.deepEqual(actual.sort(), shallowCopy, 'Result array is ordered');
141140
}
142141

143142
const fixtures = new Map([

front_end/core/root/Runtime.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ describe('Runtime', () => {
4242

4343
const experiments = Root.Runtime.experiments.allConfigurableExperiments();
4444

45-
assert.deepStrictEqual(experiments.map(experiment => experiment.name), ['example', 'configurable']);
45+
assert.deepEqual(experiments.map(experiment => experiment.name), ['example', 'configurable']);
4646
});
4747
});

front_end/core/sdk/AutofillModel.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ describeWithMockConnection('AutofillModel', () => {
7979
};
8080
autofillModel!.addressFormFilled(addressFormFilledEvent);
8181
assert.lengthOf(dispatchedEvents, 1);
82-
assert.deepStrictEqual(dispatchedEvents[0].event, addressFormFilledEvent);
82+
assert.deepEqual(dispatchedEvents[0].event, addressFormFilledEvent);
8383
});
8484
});

front_end/core/sdk/CSSMatchedStyles.test.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,12 @@ describe('CSSMatchedStyles', () => {
398398
inheritedPayload,
399399
});
400400

401-
assert.deepStrictEqual(
402-
matchedStyles.nodeStyles().map(style => style.allProperties().map(prop => prop.propertyText)), [
403-
['--var: red;'],
404-
['color: var(--var);'],
405-
['--var: blue;'],
406-
['--var: red;'],
407-
]);
401+
assert.deepEqual(matchedStyles.nodeStyles().map(style => style.allProperties().map(prop => prop.propertyText)), [
402+
['--var: red;'],
403+
['color: var(--var);'],
404+
['--var: blue;'],
405+
['--var: red;'],
406+
]);
408407
});
409408

410409
describe('resolveGlobalKeyword', () => {

front_end/core/sdk/CookieModel.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describeWithMockConnection('CookieModel', () => {
197197
cookieModel.addBlockedCookie(cookie, [blockedReason]);
198198
const cookieToBlockedReasons = cookieModel.getCookieToBlockedReasonsMap();
199199
assert.strictEqual(cookieToBlockedReasons.size, 1);
200-
assert.deepStrictEqual(cookieToBlockedReasons.get(cookie), [blockedReason]);
200+
assert.deepEqual(cookieToBlockedReasons.get(cookie), [blockedReason]);
201201

202202
navigate(getMainFrame(target));
203203
assert.strictEqual(cookieModel.getCookieToBlockedReasonsMap().size, 0);

front_end/core/sdk/DebuggerModel.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ describe('DebuggerModel', () => {
327327
}
328328

329329
assert.lengthOf(consoleMessages, 1);
330-
assert.deepStrictEqual(consoleMessages[0].text, expectedWarning);
330+
assert.deepEqual(consoleMessages[0].text, expectedWarning);
331331
}
332332

333333
it('prioritizes external DWARF over all types', () => {

front_end/core/sdk/FrameManager.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('FrameManager', () => {
102102
addMockFrame(mockModel, frameId);
103103

104104
const frameIds = dispatchedEvents.map(event => event.data.frame.id);
105-
assert.deepStrictEqual(frameIds, [frameId]);
105+
assert.deepEqual(frameIds, [frameId]);
106106
const frameFromId = frameManager.getFrame(frameId);
107107
assert.strictEqual(frameFromId?.id, frameId);
108108
});

front_end/core/sdk/NetworkManager.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,6 @@ describeWithMockConnection('InterceptedRequest', () => {
11031103
{name: 'set-cookie', value: 'override_duplicate'},
11041104
{name: 'set-cookie', value: 'malformed_override'},
11051105
];
1106-
assert.deepStrictEqual(SDK.NetworkManager.InterceptedRequest.mergeSetCookieHeaders(original, overrides), expected);
1106+
assert.deepEqual(SDK.NetworkManager.InterceptedRequest.mergeSetCookieHeaders(original, overrides), expected);
11071107
});
11081108
});

front_end/core/sdk/NetworkRequest.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ describeWithMockConnection('NetworkRequest', () => {
293293
'Setting this cookie was blocked either because of Chrome flags or browser configuration. Learn more in the Issues panel.',
294294
},
295295
]));
296-
assert.deepStrictEqual(await cookieModel.getCookiesForDomain(''), [cookie]);
296+
assert.deepEqual(await cookieModel.getCookiesForDomain(''), [cookie]);
297297

298298
request.addExtraResponseInfo({
299299
responseHeaders: [{name: 'Set-Cookie', value: 'name=value; Path=/'}],
@@ -358,8 +358,8 @@ describeWithMockConnection('ServerSentEvents', () => {
358358
});
359359

360360
assert.lengthOf(networkEvents, 2);
361-
assert.deepStrictEqual(networkEvents[0], {data: 'foo', eventId: 'fooId', eventName: 'fooName', time: 21});
362-
assert.deepStrictEqual(networkEvents[1], {data: 'bar', eventId: 'barId', eventName: 'barName', time: 42});
361+
assert.deepEqual(networkEvents[0], {data: 'foo', eventId: 'fooId', eventName: 'fooName', time: 21});
362+
assert.deepEqual(networkEvents[1], {data: 'bar', eventId: 'barId', eventName: 'barName', time: 42});
363363
});
364364

365365
it('sends EventSourceMessageAdded events for raw text/event-stream', async () => {

front_end/core/sdk/ResourceTreeModel.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describeWithMockConnection('ResourceTreeModel', () => {
116116
assert.isNotNull(resourceTreeModel.mainFrame);
117117
resourceTreeModel.reloadPage();
118118
assert.isTrue(reload.calledOnce);
119-
assert.deepStrictEqual(
119+
assert.deepEqual(
120120
reload.args[0], [{ignoreCache: undefined, loaderId: LOADER_ID, scriptToEvaluateOnLoad: undefined}]);
121121
});
122122

front_end/core/sdk/ServiceWorkerManager.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ describe('ServiceWorkerVersion', () => {
4242
assert.strictEqual(version.status, VERSION_PAYLOAD.status);
4343
assert.strictEqual(version.scriptLastModified, VERSION_PAYLOAD.scriptLastModified);
4444
assert.strictEqual(version.scriptResponseTime, VERSION_PAYLOAD.scriptResponseTime);
45-
assert.deepStrictEqual(version.controlledClients, VERSION_PAYLOAD.controlledClients);
45+
assert.deepEqual(version.controlledClients, VERSION_PAYLOAD.controlledClients);
4646
assert.strictEqual(version.targetId, VERSION_PAYLOAD.targetId);
47-
assert.deepStrictEqual(version.routerRules, expectedRouterRules);
47+
assert.deepEqual(version.routerRules, expectedRouterRules);
4848
});
4949

5050
it('should update the version with the given payload', () => {
@@ -67,7 +67,7 @@ describe('ServiceWorkerVersion', () => {
6767
assert.strictEqual(version.status, 'installing');
6868
assert.strictEqual(version.scriptLastModified, 1234567891);
6969
assert.strictEqual(version.scriptResponseTime, 12346);
70-
assert.deepStrictEqual(version.controlledClients, ['client3', 'client4']);
70+
assert.deepEqual(version.controlledClients, ['client3', 'client4']);
7171
assert.strictEqual(version.targetId, 'target2');
7272
});
7373

front_end/models/autofill_manager/AutofillManager.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describeWithMockConnection('AutofillManager', () => {
4141
SDK.AutofillModel.Events.ADDRESS_FORM_FILLED, {autofillModel: model, event: inEvent});
4242
await new Promise(resolve => setTimeout(resolve, 0));
4343
assert.isTrue(showViewStub.calledOnceWithExactly('autofill-view'));
44-
assert.deepStrictEqual(dispatchedAutofillEvents, [outEvent]);
44+
assert.deepEqual(dispatchedAutofillEvents, [outEvent]);
4545
};
4646

4747
it('with a single match', async () => {

front_end/models/bindings/DebuggerLanguagePlugins.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('DebuggerLanguagePlugins', () => {
103103
const location = sinon.createStubInstance(SDK.DebuggerModel.Location);
104104
const result = await pluginManager.getFunctionInfo(script, location);
105105
Platform.assertNotNullOrUndefined(result);
106-
assert.deepStrictEqual(result, {missingSymbolFiles: [MISSING_DEBUG_FILES]});
106+
assert.deepEqual(result, {missingSymbolFiles: [MISSING_DEBUG_FILES]});
107107
});
108108

109109
it('correctly returns frames if available', async () => {
@@ -116,7 +116,7 @@ describe('DebuggerLanguagePlugins', () => {
116116

117117
const result = await pluginManager.getFunctionInfo(script, location);
118118
Platform.assertNotNullOrUndefined(result);
119-
assert.deepStrictEqual(result, {frames: [{name: FUNCTION_NAME}]});
119+
assert.deepEqual(result, {frames: [{name: FUNCTION_NAME}]});
120120
});
121121

122122
it('correctly returns frames and missing debug info if both are available', async () => {
@@ -130,7 +130,7 @@ describe('DebuggerLanguagePlugins', () => {
130130

131131
const result = await pluginManager.getFunctionInfo(script, location);
132132
Platform.assertNotNullOrUndefined(result);
133-
assert.deepStrictEqual(result, {frames: [{name: FUNCTION_NAME}], missingSymbolFiles: [MISSING_DEBUG_FILES]});
133+
assert.deepEqual(result, {frames: [{name: FUNCTION_NAME}], missingSymbolFiles: [MISSING_DEBUG_FILES]});
134134
});
135135
});
136136
});

front_end/models/breakpoints/BreakpointManager.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ describeWithMockConnection('BreakpointManager', () => {
16361636

16371637
// Expect that the breakpoint is only added to the network UI source code.
16381638
assert.strictEqual(breakpoint, addedBreakpoint);
1639-
assert.deepStrictEqual(Array.from(breakpoint.getUiSourceCodes()), [uiSourceCode]);
1639+
assert.deepEqual(Array.from(breakpoint.getUiSourceCodes()), [uiSourceCode]);
16401640
});
16411641

16421642
it('updates a breakpoint after live editing the underlying script', async () => {

0 commit comments

Comments
 (0)