diff --git a/.eslintrc.js b/.eslintrc.js index 0b05a5ff13..34b91b13c0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -293,8 +293,9 @@ module.exports = { 'rulesdir/check-test-definitions' : 'error', 'rulesdir/compare-arrays-with-assert-deepequal' : 'error', - 'rulesdir/no-assert-equal' : 'error', 'rulesdir/no-assert-deep-strict-equal' : 'error', + 'rulesdir/no-assert-equal' : 'error', + 'rulesdir/no-assert-equal-boolean-null-undefined' : 'error', 'rulesdir/no-repeated-tests' : 'error', 'rulesdir/no-screenshot-test-outside-perf-panel' : 'error', 'rulesdir/prefer-assert-length-of' : 'error', diff --git a/front_end/core/common/CharacterIdMap.test.ts b/front_end/core/common/CharacterIdMap.test.ts index d2d3fb034f..db074d006e 100644 --- a/front_end/core/common/CharacterIdMap.test.ts +++ b/front_end/core/common/CharacterIdMap.test.ts @@ -41,6 +41,6 @@ describe('CharacterIdMap class', () => { it('returns null when trying to convert a character that does not exist in the Map', () => { const characterIdMap = new CharacterIdMap(); - assert.strictEqual(characterIdMap.fromChar('!'), null, 'character was not converted correctly'); + assert.isNull(characterIdMap.fromChar('!'), 'character was not converted correctly'); }); }); diff --git a/front_end/core/common/ColorUtils.test.ts b/front_end/core/common/ColorUtils.test.ts index c76408be4c..6725fdb2b8 100644 --- a/front_end/core/common/ColorUtils.test.ts +++ b/front_end/core/common/ColorUtils.test.ts @@ -95,9 +95,9 @@ describe('ColorUtils', () => { }); it('is able to find APCA threshold by font size and weight', () => { - assert.deepEqual(Common.ColorUtils.getAPCAThreshold('11px', '100'), null); + assert.isNull(Common.ColorUtils.getAPCAThreshold('11px', '100')); assert.deepEqual(Common.ColorUtils.getAPCAThreshold('121px', '100'), 60); - assert.deepEqual(Common.ColorUtils.getAPCAThreshold('16px', '100'), null); + assert.isNull(Common.ColorUtils.getAPCAThreshold('16px', '100')); assert.deepEqual(Common.ColorUtils.getAPCAThreshold('16px', '400'), 90); assert.deepEqual(Common.ColorUtils.getAPCAThreshold('16px', '900'), 50); }); diff --git a/front_end/core/common/Console.test.ts b/front_end/core/common/Console.test.ts index 821ab8bb16..5dde6b7f10 100644 --- a/front_end/core/common/Console.test.ts +++ b/front_end/core/common/Console.test.ts @@ -15,7 +15,7 @@ describe('Console', () => { assert.lengthOf(messages, 1); assert.strictEqual(messages[0].text, 'Foo'); assert.strictEqual(messages[0].level, Common.Console.MessageLevel.INFO); - assert.strictEqual(messages[0].show, true); + assert.isTrue(messages[0].show); }); it('stores messages', () => { @@ -47,7 +47,7 @@ describe('Console', () => { console.log('Lorem Ipsum'); const messages = console.messages(); assert.lengthOf(messages, 1); - assert.strictEqual(messages[0].show, false); // Infos don't popup the Console panel by default + assert.isFalse(messages[0].show); // Infos don't popup the Console panel by default assert.strictEqual(messages[0].level, Common.Console.MessageLevel.INFO); }); }); @@ -58,7 +58,7 @@ describe('Console', () => { console.warn('Lorem Ipsum'); const messages = console.messages(); assert.lengthOf(messages, 1); - assert.strictEqual(messages[0].show, false); // Warnings don't popup the Console panel by default + assert.isFalse(messages[0].show); // Warnings don't popup the Console panel by default assert.strictEqual(messages[0].level, Common.Console.MessageLevel.WARNING); }); }); @@ -69,7 +69,7 @@ describe('Console', () => { console.error('Lorem Ipsum'); const messages = console.messages(); assert.lengthOf(messages, 1); - assert.strictEqual(messages[0].show, true); // Errors popup the Console panel by default + assert.isTrue(messages[0].show); // Errors popup the Console panel by default assert.strictEqual(messages[0].level, Common.Console.MessageLevel.ERROR); }); @@ -79,8 +79,8 @@ describe('Console', () => { console.error('Baz', true); const messages = console.messages(); assert.lengthOf(messages, 2); - assert.strictEqual(messages[0].show, false); - assert.strictEqual(messages[1].show, true); + assert.isFalse(messages[0].show); + assert.isTrue(messages[1].show); }); }); }); diff --git a/front_end/core/common/ParsedURL.test.ts b/front_end/core/common/ParsedURL.test.ts index 754e79c64c..62f3d4619a 100644 --- a/front_end/core/common/ParsedURL.test.ts +++ b/front_end/core/common/ParsedURL.test.ts @@ -159,17 +159,17 @@ describe('Parsed URL', () => { it('checks that URL is valid', () => { const urlTest = 'http://www.example.com#?test'; - assert.strictEqual(ParsedURL.isValidUrlString(urlTest), true, 'URL validation was incorrect'); + assert.isTrue(ParsedURL.isValidUrlString(urlTest), 'URL validation was incorrect'); }); it('checks that file:// URL is valid', () => { const urlTest = 'file:///usr/lib'; - assert.strictEqual(ParsedURL.isValidUrlString(urlTest), true, 'URL validation was incorrect'); + assert.isTrue(ParsedURL.isValidUrlString(urlTest), 'URL validation was incorrect'); }); it('checks that "://" is not a valid URL', () => { const urlTest = '://'; - assert.strictEqual(ParsedURL.isValidUrlString(urlTest), false, 'URL validation was incorrect'); + assert.isFalse(ParsedURL.isValidUrlString(urlTest), 'URL validation was incorrect'); }); it('converts URL with a hash to a URL without a hash', () => { @@ -358,7 +358,7 @@ describe('Parsed URL', () => { const hrefTest = 'www.example.com'; const baseUrlTest = 'www.example.com' as Platform.DevToolsPath.UrlString; const completeUrl = ParsedURL.completeURL(baseUrlTest, hrefTest); - assert.strictEqual(completeUrl, null, 'complete URL is not returned correctly'); + assert.isNull(completeUrl, 'complete URL is not returned correctly'); }); it('uses the completeURL function to return the href if the base URL is a data URL', () => { @@ -421,7 +421,7 @@ describe('Parsed URL', () => { const splitResult = ParsedURL.splitLineAndColumn(stringTest); assert.strictEqual(splitResult.url, 'http://www.example.com/foo.js', 'URL is not correct'); assert.strictEqual(splitResult.lineNumber, 14, 'line number is incorrect'); - assert.strictEqual(splitResult.columnNumber, undefined, 'column number is incorrect'); + assert.isUndefined(splitResult.columnNumber, 'column number is incorrect'); }); it('uses the splitLineAndColumn function to return the line and column numbers if the URL contains them', () => { diff --git a/front_end/core/common/Progress.test.ts b/front_end/core/common/Progress.test.ts index 4c7863430a..7aaea6371d 100644 --- a/front_end/core/common/Progress.test.ts +++ b/front_end/core/common/Progress.test.ts @@ -64,7 +64,7 @@ describe('Composite Progress Bar', () => { const composite = new CompositeProgress(indicator); const subProgress = composite.createSubProgress(); - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0); assert.strictEqual(indicator.getTotalWork, 1); @@ -98,7 +98,7 @@ describe('Composite Progress Bar', () => { // Creates a sub progress with the weight of 3 const subProgress2 = composite.createSubProgress(3); - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0); assert.strictEqual(indicator.getTotalWork, 1); @@ -154,17 +154,17 @@ describe('Composite Progress Bar', () => { const composite1 = new CompositeProgress(subProgress01); const subProgress11 = composite1.createSubProgress(10); // Weight should have no effect - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0); assert.strictEqual(indicator.getTotalWork, 1); subProgress11.setWorked(10); - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0); assert.strictEqual(indicator.getTotalWork, 1); subProgress11.setTotalWork(100); - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0.1); assert.strictEqual(indicator.getTotalWork, 1); @@ -188,14 +188,14 @@ describe('Composite Progress Bar', () => { const composite = new CompositeProgress(indicator); const subProgress = composite.createSubProgress(); - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0); assert.strictEqual(indicator.getTotalWork, 1); assert.strictEqual(subProgress.getWorked(), 0); subProgress.incrementWorked(); - assert.strictEqual(indicator.getTitle, undefined); + assert.isUndefined(indicator.getTitle); assert.strictEqual(indicator.getWorkCompleted, 0); assert.strictEqual(indicator.getTotalWork, 1); assert.strictEqual(subProgress.getWorked(), 1); diff --git a/front_end/core/common/ResolverBase.test.ts b/front_end/core/common/ResolverBase.test.ts index 63aa15894d..bc274cb320 100644 --- a/front_end/core/common/ResolverBase.test.ts +++ b/front_end/core/common/ResolverBase.test.ts @@ -62,7 +62,7 @@ describe('ResolverBase', () => { throw new Error('This should not get called'); }); resolver.assertIsListening(); - assert.strictEqual(obj, null); + assert.isNull(obj); resolver.clear(); }); @@ -70,7 +70,7 @@ describe('ResolverBase', () => { const resolver = new ResolverTestImpl(); const waitForCall = new Promise(resolve => { const obj = resolver.tryGet(id, resolve); - assert.strictEqual(obj, null); + assert.isNull(obj); }); resolver.assertIsListening(); resolver.onResolve(id, testObj); diff --git a/front_end/core/common/ResourceType.test.ts b/front_end/core/common/ResourceType.test.ts index de20b5d75f..842f7f1eb8 100644 --- a/front_end/core/common/ResourceType.test.ts +++ b/front_end/core/common/ResourceType.test.ts @@ -34,7 +34,7 @@ describeWithEnvironment('ResourceType class', () => { assert.strictEqual( resourceType.category().shortTitle(), 'Category Test Short Title', 'category short title was not set correctly'); - assert.strictEqual(resourceType.isTextType(), true, 'resource type was not set correctly'); + assert.isTrue(resourceType.isTextType(), 'resource type was not set correctly'); }); it('is able to return a document resource from the string "text/html"', () => { @@ -411,13 +411,13 @@ describeWithEnvironment('ResourceType class', () => { it('treats a Ping as Other', () => { const resourceType = resourceTypes.Ping; - assert.strictEqual(resourceType.isTextType(), false, 'A ping is not a text type'); + assert.isFalse(resourceType.isTextType(), 'A ping is not a text type'); assert.strictEqual(resourceType.canonicalMimeType(), '', 'A ping does not have an associated mime type'); }); it('treats a CSPViolationsReport as Other', () => { const resourceType = resourceTypes.CSPViolationReport; - assert.strictEqual(resourceType.isTextType(), false, 'A ping is not a text type'); + assert.isFalse(resourceType.isTextType(), 'A ping is not a text type'); assert.strictEqual(resourceType.canonicalMimeType(), '', 'A ping does not have an associated mime type'); }); }); diff --git a/front_end/core/dom_extension/DOMExtension.test.ts b/front_end/core/dom_extension/DOMExtension.test.ts index e1c26b8bd1..f809e3e73d 100644 --- a/front_end/core/dom_extension/DOMExtension.test.ts +++ b/front_end/core/dom_extension/DOMExtension.test.ts @@ -47,7 +47,7 @@ describe('DataGrid', () => { */ let node: HTMLElement = component1; - assert.strictEqual(node.nodeValue, null, 'root node value is incorrect'); + assert.isNull(node.nodeValue, 'root node value is incorrect'); assert.strictEqual(node.nodeName, 'DIV', 'root node name is incorrect'); assert.strictEqual(node.className, 'component1', 'root node class is incorrect'); diff --git a/front_end/core/platform/StringUtilities.test.ts b/front_end/core/platform/StringUtilities.test.ts index 44cb77fcba..dce242fdcd 100644 --- a/front_end/core/platform/StringUtilities.test.ts +++ b/front_end/core/platform/StringUtilities.test.ts @@ -249,7 +249,7 @@ describe('StringUtilities', () => { describe('createSearchRegex', () => { it('returns a case sensitive regex if the call states it is case sensitive', () => { const regex = Platform.StringUtilities.createSearchRegex('foo', true, false); - assert.strictEqual(regex.ignoreCase, false); + assert.isFalse(regex.ignoreCase); assert.strictEqual(regex.source, 'foo'); }); diff --git a/front_end/core/sdk/AnimationModel.test.ts b/front_end/core/sdk/AnimationModel.test.ts index dcbb0c3570..fb268fcee1 100644 --- a/front_end/core/sdk/AnimationModel.test.ts +++ b/front_end/core/sdk/AnimationModel.test.ts @@ -129,7 +129,7 @@ describeWithMockConnection('AnimationModel', () => { }, }); assert.strictEqual(animationImpl.name(), 'animation-name'); - assert.strictEqual(animationImpl.paused(), false); + assert.isFalse(animationImpl.paused()); assert.strictEqual(animationImpl.playState(), 'running'); assert.strictEqual(animationImpl.playbackRate(), 1); assert.strictEqual(animationImpl.startTime(), 0); @@ -160,7 +160,7 @@ describeWithMockConnection('AnimationModel', () => { }); assert.strictEqual(animationImpl.name(), 'updated-name'); - assert.strictEqual(animationImpl.paused(), true); + assert.isTrue(animationImpl.paused()); assert.strictEqual(animationImpl.playState(), 'paused'); assert.strictEqual(animationImpl.playbackRate(), 2); assert.strictEqual(animationImpl.startTime(), 100); @@ -209,7 +209,7 @@ describeWithMockConnection('AnimationModel', () => { }, }); assert.strictEqual(animationImpl.name(), 'animation-name'); - assert.strictEqual(animationImpl.paused(), false); + assert.isFalse(animationImpl.paused()); assert.strictEqual(animationImpl.playState(), 'running'); assert.strictEqual(animationImpl.playbackRate(), 1); assert.strictEqual(animationImpl.startTime(), 100); // in pixels @@ -245,7 +245,7 @@ describeWithMockConnection('AnimationModel', () => { }); assert.strictEqual(animationImpl.name(), 'updated-name'); - assert.strictEqual(animationImpl.paused(), true); + assert.isTrue(animationImpl.paused()); assert.strictEqual(animationImpl.playState(), 'paused'); assert.strictEqual(animationImpl.playbackRate(), 2); assert.strictEqual(animationImpl.startTime(), 0); // in pixels diff --git a/front_end/core/sdk/CSSMatchedStyles.test.ts b/front_end/core/sdk/CSSMatchedStyles.test.ts index 781494bb31..2fd14a1a9c 100644 --- a/front_end/core/sdk/CSSMatchedStyles.test.ts +++ b/front_end/core/sdk/CSSMatchedStyles.test.ts @@ -261,8 +261,8 @@ describe('CSSMatchedStyles', () => { --a: var(--b); --b: var(--a); `; - assert.strictEqual(await compute('--a', [simpleCycle], []), null); - assert.strictEqual(await compute('--b', [simpleCycle], []), null); + assert.isNull(await compute('--a', [simpleCycle], [])); + assert.isNull(await compute('--b', [simpleCycle], [])); const cycleOnUnusedFallback = ` --a: 2; @@ -277,46 +277,46 @@ describe('CSSMatchedStyles', () => { --a: var(--b, 1); --b: var(--a, 2); `; - assert.strictEqual(await compute('--a', [simpleCycleWithFallbacks], []), null); - assert.strictEqual(await compute('--b', [simpleCycleWithFallbacks], []), null); + assert.isNull(await compute('--a', [simpleCycleWithFallbacks], [])); + assert.isNull(await compute('--b', [simpleCycleWithFallbacks], [])); const longerCycle = ` --a: var(--b); --b: var(--c); --c: var(--a); `; - assert.strictEqual(await compute('--a', [longerCycle], []), null); - assert.strictEqual(await compute('--b', [longerCycle], []), null); - assert.strictEqual(await compute('--c', [longerCycle], []), null); + assert.isNull(await compute('--a', [longerCycle], [])); + assert.isNull(await compute('--b', [longerCycle], [])); + assert.isNull(await compute('--c', [longerCycle], [])); const longerCycleWithFallbacks = ` --a: var(--b, 2); --b: var(--c, 3); --c: var(--a, 4); `; - assert.strictEqual(await compute('--a', [longerCycleWithFallbacks], []), null); - assert.strictEqual(await compute('--b', [longerCycleWithFallbacks], []), null); - assert.strictEqual(await compute('--c', [longerCycleWithFallbacks], []), null); + assert.isNull(await compute('--a', [longerCycleWithFallbacks], [])); + assert.isNull(await compute('--b', [longerCycleWithFallbacks], [])); + assert.isNull(await compute('--c', [longerCycleWithFallbacks], [])); const pointingIntoCycle = ` ${longerCycle} --d: var(--a); --e: var(--b); `; - assert.strictEqual(await compute('--a', [pointingIntoCycle], []), null); - assert.strictEqual(await compute('--b', [pointingIntoCycle], []), null); - assert.strictEqual(await compute('--c', [pointingIntoCycle], []), null); - assert.strictEqual(await compute('--d', [pointingIntoCycle], []), null); - assert.strictEqual(await compute('--e', [pointingIntoCycle], []), null); + assert.isNull(await compute('--a', [pointingIntoCycle], [])); + assert.isNull(await compute('--b', [pointingIntoCycle], [])); + assert.isNull(await compute('--c', [pointingIntoCycle], [])); + assert.isNull(await compute('--d', [pointingIntoCycle], [])); + assert.isNull(await compute('--e', [pointingIntoCycle], [])); const pointingIntoCycleWithFallback = ` ${longerCycle} --d: var(--a, 4); --e: var(--b, 5); `; - assert.strictEqual(await compute('--a', [pointingIntoCycleWithFallback], []), null); - assert.strictEqual(await compute('--b', [pointingIntoCycleWithFallback], []), null); - assert.strictEqual(await compute('--c', [pointingIntoCycleWithFallback], []), null); + assert.isNull(await compute('--a', [pointingIntoCycleWithFallback], [])); + assert.isNull(await compute('--b', [pointingIntoCycleWithFallback], [])); + assert.isNull(await compute('--c', [pointingIntoCycleWithFallback], [])); assert.strictEqual(await compute('--d', [pointingIntoCycleWithFallback], []), '4'); assert.strictEqual(await compute('--e', [pointingIntoCycleWithFallback], []), '5'); @@ -326,29 +326,29 @@ describe('CSSMatchedStyles', () => { --c: var(--a) var(--b); --d: var(--c); `; - assert.strictEqual(await compute('--a', [multipleEdges], []), null); - assert.strictEqual(await compute('--b', [multipleEdges], []), null); - assert.strictEqual(await compute('--c', [multipleEdges], []), null); - assert.strictEqual(await compute('--d', [multipleEdges], []), null); + assert.isNull(await compute('--a', [multipleEdges], [])); + assert.isNull(await compute('--b', [multipleEdges], [])); + assert.isNull(await compute('--c', [multipleEdges], [])); + assert.isNull(await compute('--d', [multipleEdges], [])); const pointingIntoMultipleEdgeCycle = ` ${multipleEdges} --e: var(--c) var(--d); `; - assert.strictEqual(await compute('--a', [pointingIntoMultipleEdgeCycle], []), null); - assert.strictEqual(await compute('--b', [pointingIntoMultipleEdgeCycle], []), null); - assert.strictEqual(await compute('--c', [pointingIntoMultipleEdgeCycle], []), null); - assert.strictEqual(await compute('--d', [pointingIntoMultipleEdgeCycle], []), null); - assert.strictEqual(await compute('--e', [pointingIntoMultipleEdgeCycle], []), null); + assert.isNull(await compute('--a', [pointingIntoMultipleEdgeCycle], [])); + assert.isNull(await compute('--b', [pointingIntoMultipleEdgeCycle], [])); + assert.isNull(await compute('--c', [pointingIntoMultipleEdgeCycle], [])); + assert.isNull(await compute('--d', [pointingIntoMultipleEdgeCycle], [])); + assert.isNull(await compute('--e', [pointingIntoMultipleEdgeCycle], [])); const pointingIntoMultipleEdgeCycleWithFallback = ` ${multipleEdges} --e: var(--c, 4) var(--d, 5); `; - assert.strictEqual(await compute('--a', [pointingIntoMultipleEdgeCycleWithFallback], []), null); - assert.strictEqual(await compute('--b', [pointingIntoMultipleEdgeCycleWithFallback], []), null); - assert.strictEqual(await compute('--c', [pointingIntoMultipleEdgeCycleWithFallback], []), null); - assert.strictEqual(await compute('--d', [pointingIntoMultipleEdgeCycleWithFallback], []), null); + assert.isNull(await compute('--a', [pointingIntoMultipleEdgeCycleWithFallback], [])); + assert.isNull(await compute('--b', [pointingIntoMultipleEdgeCycleWithFallback], [])); + assert.isNull(await compute('--c', [pointingIntoMultipleEdgeCycleWithFallback], [])); + assert.isNull(await compute('--d', [pointingIntoMultipleEdgeCycleWithFallback], [])); assert.strictEqual(await compute('--e', [pointingIntoMultipleEdgeCycleWithFallback], []), '4 5'); const multipleCyclesWithFallback = ` @@ -358,12 +358,12 @@ describe('CSSMatchedStyles', () => { --f: var(--d); --g: var(--a, var(--d, 5)); `; - assert.strictEqual(await compute('--a', [multipleCyclesWithFallback], []), null); - assert.strictEqual(await compute('--b', [multipleCyclesWithFallback], []), null); - assert.strictEqual(await compute('--c', [multipleCyclesWithFallback], []), null); - assert.strictEqual(await compute('--d', [multipleCyclesWithFallback], []), null); - assert.strictEqual(await compute('--e', [multipleCyclesWithFallback], []), null); - assert.strictEqual(await compute('--f', [multipleCyclesWithFallback], []), null); + assert.isNull(await compute('--a', [multipleCyclesWithFallback], [])); + assert.isNull(await compute('--b', [multipleCyclesWithFallback], [])); + assert.isNull(await compute('--c', [multipleCyclesWithFallback], [])); + assert.isNull(await compute('--d', [multipleCyclesWithFallback], [])); + assert.isNull(await compute('--e', [multipleCyclesWithFallback], [])); + assert.isNull(await compute('--f', [multipleCyclesWithFallback], [])); assert.strictEqual(await compute('--g', [multipleCyclesWithFallback], []), '5'); const notACycle = ` @@ -374,7 +374,7 @@ describe('CSSMatchedStyles', () => { --b: var(--a); `; assert.strictEqual(await compute('--a', [notACycle], [[inherited]]), '1'); - assert.strictEqual(await compute('--b', [notACycle], [[inherited]]), null); + assert.isNull(await compute('--b', [notACycle], [[inherited]])); }); }); diff --git a/front_end/core/sdk/CSSModel.test.ts b/front_end/core/sdk/CSSModel.test.ts index 583c6492e4..91dbc6f289 100644 --- a/front_end/core/sdk/CSSModel.test.ts +++ b/front_end/core/sdk/CSSModel.test.ts @@ -48,7 +48,7 @@ describeWithMockConnection('CSSModel', () => { const cssModelHeader = await addedPromise; assert.deepEqual(cssModelHeader.sourceURL, ''); - assert.deepEqual(cssModelHeader.isConstructed, true); + assert.isTrue(cssModelHeader.isConstructed); }); describe('on primary page change', () => { diff --git a/front_end/core/sdk/CSSStyleDeclaration.test.ts b/front_end/core/sdk/CSSStyleDeclaration.test.ts index 37d5e344c3..a0f5e05b93 100644 --- a/front_end/core/sdk/CSSStyleDeclaration.test.ts +++ b/front_end/core/sdk/CSSStyleDeclaration.test.ts @@ -58,7 +58,7 @@ describeWithMockConnection('CSSStyleDeclaration', () => { ['implicit', false], ['index', 0], ]); - assert.strictEqual(style.allProperties()[0].activeInStyle(), true); + assert.isTrue(style.allProperties()[0].activeInStyle()); assertPropertValues(style.allProperties()[1], [ ['name', 'margin-top'], @@ -66,7 +66,7 @@ describeWithMockConnection('CSSStyleDeclaration', () => { ['implicit', false], ['index', 1], ]); - assert.strictEqual(style.allProperties()[1].activeInStyle(), true); + assert.isTrue(style.allProperties()[1].activeInStyle()); assertPropertValues(style.allProperties()[2], [ ['name', 'margin-top'], @@ -74,7 +74,7 @@ describeWithMockConnection('CSSStyleDeclaration', () => { ['implicit', true], ['index', 2], ]); - assert.strictEqual(style.allProperties()[2].activeInStyle(), false); + assert.isFalse(style.allProperties()[2].activeInStyle()); assertPropertValues(style.allProperties()[3], [ ['name', 'margin-right'], @@ -82,7 +82,7 @@ describeWithMockConnection('CSSStyleDeclaration', () => { ['implicit', true], ['index', 3], ]); - assert.strictEqual(style.allProperties()[3].activeInStyle(), true); + assert.isTrue(style.allProperties()[3].activeInStyle()); assertPropertValues(style.allProperties()[4], [ ['name', 'margin-bottom'], @@ -90,7 +90,7 @@ describeWithMockConnection('CSSStyleDeclaration', () => { ['implicit', true], ['index', 4], ]); - assert.strictEqual(style.allProperties()[4].activeInStyle(), true); + assert.isTrue(style.allProperties()[4].activeInStyle()); assertPropertValues(style.allProperties()[5], [ ['name', 'margin-left'], @@ -98,7 +98,7 @@ describeWithMockConnection('CSSStyleDeclaration', () => { ['implicit', true], ['index', 5], ]); - assert.strictEqual(style.allProperties()[5].activeInStyle(), true); + assert.isTrue(style.allProperties()[5].activeInStyle()); }); it('should correctly compute active and inactive declarations', () => { diff --git a/front_end/core/sdk/Cookie.test.ts b/front_end/core/sdk/Cookie.test.ts index 24cc16e31f..a996aa8014 100644 --- a/front_end/core/sdk/Cookie.test.ts +++ b/front_end/core/sdk/Cookie.test.ts @@ -14,20 +14,20 @@ describe('Cookie', () => { assert.strictEqual(cookie.name(), 'name'); assert.strictEqual(cookie.value(), 'value'); - assert.strictEqual(cookie.type(), undefined); - assert.strictEqual(cookie.httpOnly(), false); - assert.strictEqual(cookie.secure(), false); - assert.strictEqual(cookie.sameSite(), undefined); + assert.isUndefined(cookie.type()); + assert.isFalse(cookie.httpOnly()); + assert.isFalse(cookie.secure()); + assert.isUndefined(cookie.sameSite()); assert.strictEqual(cookie.priority(), 'Medium'); - assert.strictEqual(cookie.session(), true); - assert.strictEqual(cookie.path(), undefined); - assert.strictEqual(cookie.domain(), undefined); - assert.strictEqual(cookie.expires(), undefined); - assert.strictEqual(cookie.maxAge(), undefined); + assert.isTrue(cookie.session()); + assert.isUndefined(cookie.path()); + assert.isUndefined(cookie.domain()); + assert.isUndefined(cookie.expires()); + assert.isUndefined(cookie.maxAge()); assert.strictEqual(cookie.size(), 0); - assert.strictEqual(cookie.url(), null); - assert.strictEqual(cookie.partitionKey(), undefined); - assert.strictEqual(cookie.getCookieLine(), null); + assert.isNull(cookie.url()); + assert.isUndefined(cookie.partitionKey()); + assert.isNull(cookie.getCookieLine()); }); it('can be created from a protocol Cookie with all optional fields set', () => { @@ -55,24 +55,24 @@ describe('Cookie', () => { assert.strictEqual(cookie.name(), 'name'); assert.strictEqual(cookie.value(), 'value'); - assert.strictEqual(cookie.type(), null); - assert.strictEqual(cookie.httpOnly(), true); - assert.strictEqual(cookie.secure(), true); + assert.isNull(cookie.type()); + assert.isTrue(cookie.httpOnly()); + assert.isTrue(cookie.secure()); assert.strictEqual(cookie.sameSite(), 'Strict'); - assert.strictEqual(cookie.session(), false); + assert.isFalse(cookie.session()); assert.strictEqual(cookie.path(), '/test'); assert.strictEqual(cookie.domain(), '.example.com'); assert.strictEqual(cookie.expires(), expires); - assert.strictEqual(cookie.maxAge(), undefined); + assert.isUndefined(cookie.maxAge()); assert.strictEqual(cookie.size(), 23); assert.strictEqual(String(cookie.url()), 'https://.example.com/test'); - assert.strictEqual(cookie.getCookieLine(), null); + assert.isNull(cookie.getCookieLine()); assert.strictEqual(cookie.sourcePort(), 443); assert.strictEqual(cookie.sourceScheme(), Protocol.Network.CookieSourceScheme.Secure); assert.strictEqual(cookie.partitionKey().topLevelSite, 'https://a.com'); - assert.strictEqual(cookie.partitionKey().hasCrossSiteAncestor, false); - assert.strictEqual(cookie.partitionKeyOpaque(), false); - assert.strictEqual(cookie.partitioned(), true); + assert.isFalse(cookie.partitionKey().hasCrossSiteAncestor); + assert.isFalse(cookie.partitionKeyOpaque()); + assert.isTrue(cookie.partitioned()); }); // The jsdoc states that the fields are required, not optional @@ -97,19 +97,19 @@ describe('Cookie', () => { assert.strictEqual(cookie.name(), 'name'); assert.strictEqual(cookie.value(), 'value'); - assert.strictEqual(cookie.type(), null); - assert.strictEqual(cookie.httpOnly(), false); - assert.strictEqual(cookie.secure(), false); - assert.strictEqual(cookie.sameSite(), undefined); + assert.isNull(cookie.type()); + assert.isFalse(cookie.httpOnly()); + assert.isFalse(cookie.secure()); + assert.isUndefined(cookie.sameSite()); assert.strictEqual(cookie.priority(), 'Medium'); // Session cookie status is derived from the presence of max-age or expires fields. - assert.strictEqual(cookie.session(), true); + assert.isTrue(cookie.session()); assert.strictEqual(cookie.path(), '/test'); assert.strictEqual(cookie.domain(), '.example.com'); - assert.strictEqual(cookie.maxAge(), undefined); + assert.isUndefined(cookie.maxAge()); assert.strictEqual(cookie.size(), 23); assert.strictEqual(String(cookie.url()), 'http://.example.com/test'); - assert.strictEqual(cookie.getCookieLine(), null); + assert.isNull(cookie.getCookieLine()); assert.strictEqual(cookie.sourcePort(), 80); assert.strictEqual(cookie.sourceScheme(), Protocol.Network.CookieSourceScheme.NonSecure); }); @@ -135,19 +135,19 @@ describe('Cookie', () => { assert.strictEqual(cookie.name(), 'name'); assert.strictEqual(cookie.value(), 'value'); - assert.strictEqual(cookie.type(), null); - assert.strictEqual(cookie.httpOnly(), false); - assert.strictEqual(cookie.secure(), false); - assert.strictEqual(cookie.sameSite(), undefined); + assert.isNull(cookie.type()); + assert.isFalse(cookie.httpOnly()); + assert.isFalse(cookie.secure()); + assert.isUndefined(cookie.sameSite()); assert.strictEqual(cookie.priority(), 'Medium'); // Session cookie status is derived from the presence of max-age or expires fields. - assert.strictEqual(cookie.session(), true); + assert.isTrue(cookie.session()); assert.strictEqual(cookie.path(), '/test'); assert.strictEqual(cookie.domain(), '.example.com'); - assert.strictEqual(cookie.maxAge(), undefined); + assert.isUndefined(cookie.maxAge()); assert.strictEqual(cookie.size(), 23); assert.strictEqual(String(cookie.url()), 'http://.example.com:8000/test'); - assert.strictEqual(cookie.getCookieLine(), null); + assert.isNull(cookie.getCookieLine()); assert.strictEqual(cookie.sourcePort(), 8000); assert.strictEqual(cookie.sourceScheme(), Protocol.Network.CookieSourceScheme.NonSecure); }); @@ -170,7 +170,7 @@ describe('Cookie', () => { it('can set SDK.Cookie.Attribute used as flags', () => { const cookie = new SDK.Cookie.Cookie('name', 'value'); cookie.addAttribute(SDK.Cookie.Attribute.HTTP_ONLY); - assert.strictEqual(cookie.httpOnly(), true); + assert.isTrue(cookie.httpOnly()); }); it('can set SDK.Cookie.Attribute used as key=value', () => { @@ -198,7 +198,7 @@ describe('Cookie', () => { it('can calculate the expiration date for session cookies', () => { const cookie = new SDK.Cookie.Cookie('name', 'value'); - assert.strictEqual(cookie.expiresDate(new Date()), null); + assert.isNull(cookie.expiresDate(new Date())); }); it('can calculate the expiration date for max age cookies', () => { diff --git a/front_end/core/sdk/CookieModel.test.ts b/front_end/core/sdk/CookieModel.test.ts index c968be7af4..fc30c03f5a 100644 --- a/front_end/core/sdk/CookieModel.test.ts +++ b/front_end/core/sdk/CookieModel.test.ts @@ -81,13 +81,13 @@ describeWithMockConnection('CookieModel', () => { assert.strictEqual(cookies[0].size(), 23); assert.strictEqual(cookies[0].value(), 'value'); assert.strictEqual(cookies[0].expires(), 42000); - assert.strictEqual(cookies[0].httpOnly(), false); - assert.strictEqual(cookies[0].secure(), false); + assert.isFalse(cookies[0].httpOnly()); + assert.isFalse(cookies[0].secure()); assert.strictEqual(cookies[0].priority(), Protocol.Network.CookiePriority.Medium); assert.strictEqual(cookies[0].sourcePort(), 80); assert.strictEqual(cookies[0].sourceScheme(), Protocol.Network.CookieSourceScheme.NonSecure); assert.strictEqual(cookies[0].partitionKey().topLevelSite, 'https://example.net'); - assert.strictEqual(cookies[0].partitionKey().hasCrossSiteAncestor, false); + assert.isFalse(cookies[0].partitionKey().hasCrossSiteAncestor); } }); @@ -246,7 +246,7 @@ describeWithMockConnection('CookieModel', () => { assert.strictEqual(cookies2[0].domain(), '.example.com'); assert.strictEqual(cookies2[0].name(), 'name'); assert.strictEqual(cookies2[0].partitionKey().topLevelSite, 'https://example.net'); - assert.strictEqual(cookies2[0].partitionKey().hasCrossSiteAncestor, false); + assert.isFalse(cookies2[0].partitionKey().hasCrossSiteAncestor); await model.deleteCookie(SDK.Cookie.Cookie.fromProtocolCookie(PROTOCOL_COOKIE_PARTITIONED)); diff --git a/front_end/core/sdk/DebuggerModel.test.ts b/front_end/core/sdk/DebuggerModel.test.ts index 346ec869cc..665a4d8d19 100644 --- a/front_end/core/sdk/DebuggerModel.test.ts +++ b/front_end/core/sdk/DebuggerModel.test.ts @@ -148,7 +148,7 @@ describeWithMockConnection('DebuggerModel', () => { }); assert.strictEqual(debuggerModel?.createRawLocationByURL(url, 0)?.scriptId, SCRIPT_ID_ONE); assert.strictEqual(debuggerModel?.createRawLocationByURL(url, 20, 1)?.scriptId, SCRIPT_ID_TWO); - assert.strictEqual(debuggerModel?.createRawLocationByURL(url, 5, 5), null); + assert.isNull(debuggerModel?.createRawLocationByURL(url, 5, 5)); }); }); diff --git a/front_end/core/sdk/FrameManager.test.ts b/front_end/core/sdk/FrameManager.test.ts index 13ef38ecd1..c4c9fc4d85 100644 --- a/front_end/core/sdk/FrameManager.test.ts +++ b/front_end/core/sdk/FrameManager.test.ts @@ -134,7 +134,7 @@ describe('FrameManager', () => { assert.strictEqual(frameFromId?.id, parentFrameId); assert.strictEqual(frameFromId?.resourceTreeModel().target().id(), targetId as Protocol.Target.TargetID); frameFromId = frameManager.getFrame(childFrameId); - assert.strictEqual(frameFromId, null); + assert.isNull(frameFromId); }); it('handles removal of target', () => { @@ -163,9 +163,9 @@ describe('FrameManager', () => { assert.deepEqual(dispatchedEvents[3].data, {frameId: childFrameId}); let frameFromId = frameManager.getFrame(parentFrameId); - assert.strictEqual(frameFromId, null); + assert.isNull(frameFromId); frameFromId = frameManager.getFrame(childFrameId); - assert.strictEqual(frameFromId, null); + assert.isNull(frameFromId); }); it('handles a frame transferring to a different target', () => { diff --git a/front_end/core/sdk/NetworkManager.test.ts b/front_end/core/sdk/NetworkManager.test.ts index 299a8167f3..8fdd1f9e35 100644 --- a/front_end/core/sdk/NetworkManager.test.ts +++ b/front_end/core/sdk/NetworkManager.test.ts @@ -258,7 +258,7 @@ describe('NetworkDispatcher', () => { networkDispatcher.requestWillBeSent(requestWillBeSentEvent); networkDispatcher.responseReceived(responseReceivedEvent); - assert.deepEqual(networkDispatcher.requestForId('mockId')?.fromEarlyHints(), true); + assert.isTrue(networkDispatcher.requestForId('mockId')?.fromEarlyHints()); }); it('has populated early hints headers after receiving \'repsonseReceivedEarlyHints\'', () => { diff --git a/front_end/core/sdk/RemoteObject.test.ts b/front_end/core/sdk/RemoteObject.test.ts index 12e5ae8bbc..90eef0f8a8 100644 --- a/front_end/core/sdk/RemoteObject.test.ts +++ b/front_end/core/sdk/RemoteObject.test.ts @@ -14,16 +14,16 @@ describe('RemoteObject', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(undefined); assert.deepEqual(remoteObject.type, 'undefined'); - assert.deepEqual(remoteObject.subtype, undefined); - assert.deepEqual(remoteObject.value, undefined); + assert.isUndefined(remoteObject.subtype); + assert.isUndefined(remoteObject.value); assert.deepEqual(remoteObject.description, 'undefined'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, undefined); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.value); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle null', () => { @@ -31,30 +31,30 @@ describe('RemoteObject', () => { assert.deepEqual(remoteObject.type, 'object'); assert.deepEqual(remoteObject.subtype, 'null'); - assert.deepEqual(remoteObject.value, null); + assert.isNull(remoteObject.value); assert.deepEqual(remoteObject.description, 'null'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, null); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isNull(callArguments.value); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle bigints', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(1n); assert.deepEqual(remoteObject.type, 'bigint'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, 1n); assert.deepEqual(remoteObject.description, '1'); assert.deepEqual(remoteObject.unserializableValue(), '1n'); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, undefined); + assert.isUndefined(callArguments.value); assert.deepEqual(callArguments.unserializableValue, '1n'); }); @@ -62,50 +62,50 @@ describe('RemoteObject', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(42); assert.deepEqual(remoteObject.type, 'number'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, 42); assert.deepEqual(remoteObject.description, '42'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(callArguments.value, 42); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle strings', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject('foo string'); assert.deepEqual(remoteObject.type, 'string'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, 'foo string'); assert.deepEqual(remoteObject.description, 'foo string'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(callArguments.value, 'foo string'); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle NaN', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(NaN); assert.deepEqual(remoteObject.type, 'number'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); // Since equality comparisons don't work for NaN, we check if it is a number and if its string // representation is the correct one. assert.deepEqual(typeof remoteObject.value, 'number'); assert.deepEqual(String(remoteObject.value), String(NaN)); assert.deepEqual(remoteObject.description, 'NaN'); assert.deepEqual(remoteObject.unserializableValue(), 'NaN'); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, undefined); + assert.isUndefined(callArguments.value); assert.deepEqual(callArguments.unserializableValue, 'NaN'); }); @@ -113,15 +113,15 @@ describe('RemoteObject', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(Infinity); assert.deepEqual(remoteObject.type, 'number'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, Infinity); assert.deepEqual(remoteObject.description, 'Infinity'); assert.deepEqual(remoteObject.unserializableValue(), 'Infinity'); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, undefined); + assert.isUndefined(callArguments.value); assert.deepEqual(callArguments.unserializableValue, 'Infinity'); }); @@ -129,15 +129,15 @@ describe('RemoteObject', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(-Infinity); assert.deepEqual(remoteObject.type, 'number'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, -Infinity); assert.deepEqual(remoteObject.description, '-Infinity'); assert.deepEqual(remoteObject.unserializableValue(), '-Infinity'); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, undefined); + assert.isUndefined(callArguments.value); assert.deepEqual(callArguments.unserializableValue, '-Infinity'); }); @@ -145,15 +145,15 @@ describe('RemoteObject', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(-0); assert.deepEqual(remoteObject.type, 'number'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, -0); assert.deepEqual(remoteObject.description, '0'); assert.deepEqual(remoteObject.unserializableValue(), '-0'); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); - assert.deepEqual(callArguments.value, undefined); + assert.isUndefined(callArguments.value); assert.deepEqual(callArguments.unserializableValue, '-0'); }); @@ -164,30 +164,30 @@ describe('RemoteObject', () => { assert.deepEqual(remoteObject.subtype, 'array'); assert.deepEqual(remoteObject.value, [1n, 2, NaN, -0, null, undefined]); assert.deepEqual(remoteObject.description, '[1, 2, NaN, 0, null, undefined]'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); + assert.isUndefined(remoteObject.unserializableValue()); assert.deepEqual(remoteObject.arrayLength(), 6); - assert.deepEqual(remoteObject.hasChildren, true); + assert.isTrue(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(callArguments.value, [1n, 2, NaN, -0, null, undefined]); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle an object', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject({foo: 'bar'}); assert.deepEqual(remoteObject.type, 'object'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, {foo: 'bar'}); assert.deepEqual(remoteObject.description, '{foo: "bar"}'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, true); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isTrue(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(callArguments.value, {foo: 'bar'}); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle a nested object', () => { @@ -195,16 +195,16 @@ describe('RemoteObject', () => { {foo: 'bar', baz: {nested: 34}, another: {nested: {object: true}}}); assert.deepEqual(remoteObject.type, 'object'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); assert.deepEqual(remoteObject.value, {foo: 'bar', baz: {nested: 34}, another: {nested: {object: true}}}); assert.deepEqual(remoteObject.description, '{foo: "bar", baz: {nested: 34}, another: {nested: {object: true}}}'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, true); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isTrue(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(callArguments.value, {foo: 'bar', baz: {nested: 34}, another: {nested: {object: true}}}); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle the function arguments object', () => { @@ -213,28 +213,28 @@ describe('RemoteObject', () => { })(1, 2, 3, 4)); assert.deepEqual(remoteObject.type, 'object'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); // We can't represent an `Arguments` object, but we can compare its structure assert.deepEqual(String(remoteObject.value), '[object Arguments]'); assert.deepEqual(Object.keys(remoteObject.value), ['0', '1', '2', '3']); assert.deepEqual(Object.values(remoteObject.value), [1, 2, 3, 4]); assert.deepEqual(remoteObject.description, '{0: 1, 1: 2, 2: 3, 3: 4}'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, true); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isTrue(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(String(callArguments.value), '[object Arguments]'); assert.deepEqual(Object.keys(callArguments.value), ['0', '1', '2', '3']); assert.deepEqual(Object.values(callArguments.value), [1, 2, 3, 4]); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle a function', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(function func() {}); assert.deepEqual(remoteObject.type, 'function'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); // We can't represent an `Function` object, but we can compare its structure assert.deepEqual(typeof remoteObject.value, 'function'); const funcStrs = [ @@ -244,32 +244,32 @@ describe('RemoteObject', () => { ]; assert.deepInclude(funcStrs, String(remoteObject.value)); assert.deepInclude(funcStrs, remoteObject.description); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepInclude(funcStrs, String(callArguments.value)); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle an error', () => { const remoteObject = SDK.RemoteObject.RemoteObject.fromLocalObject(new Error('Some error message')); assert.deepEqual(remoteObject.type, 'object'); - assert.deepEqual(remoteObject.subtype, undefined); + assert.isUndefined(remoteObject.subtype); // We can't represent an `Error` object, but we can compare its structure assert.deepEqual(typeof remoteObject.value, 'object'); assert.deepEqual(String(remoteObject.value), 'Error: Some error message'); assert.deepEqual(remoteObject.description, '{}'); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(typeof callArguments.value, 'object'); assert.deepEqual(String(callArguments.value), 'Error: Some error message'); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); it('can handle a Date', () => { @@ -299,13 +299,13 @@ describe('RemoteObject', () => { // string as-is and compare that. assert.deepEqual( Date.parse(remoteObject.description), Date.parse('Tue Mar 10 2020 15:38:57 GMT+0000 (Greenwich Mean Time)')); - assert.deepEqual(remoteObject.unserializableValue(), undefined); - assert.deepEqual(remoteObject.hasChildren, false); + assert.isUndefined(remoteObject.unserializableValue()); + assert.isFalse(remoteObject.hasChildren); const callArguments = SDK.RemoteObject.RemoteObject.toCallArgument(remoteObject); assert.deepEqual(callArguments.value, createNewFixedTimeDate()); - assert.deepEqual(callArguments.unserializableValue, undefined); + assert.isUndefined(callArguments.unserializableValue); }); }); diff --git a/front_end/core/sdk/SourceMap.test.ts b/front_end/core/sdk/SourceMap.test.ts index 069eef88e0..8cdd0be87c 100644 --- a/front_end/core/sdk/SourceMap.test.ts +++ b/front_end/core/sdk/SourceMap.test.ts @@ -825,10 +825,10 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///main.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///example.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///other.js' as Platform.DevToolsPath.UrlString), true); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///main.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///example.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///other.js' as Platform.DevToolsPath.UrlString)); }); it('parses the known third parties from the deprecated `x_google_ignoreList` section if `ignoreList` is not present', @@ -849,10 +849,10 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///main.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///example.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///other.js' as Platform.DevToolsPath.UrlString), true); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///main.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///example.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///other.js' as Platform.DevToolsPath.UrlString)); }); it('parses the known third parties from the `ignoreList` section and ignores deprecated `x_google_ignoreList`', @@ -874,10 +874,10 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///main.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///example.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///other.js' as Platform.DevToolsPath.UrlString), true); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///main.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///example.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///other.js' as Platform.DevToolsPath.UrlString)); }); it('computes ranges for third party code in a simple case', () => { @@ -897,10 +897,10 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString), true); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString)); assert.deepEqual(sourceMap.findRanges(url => sourceMap.hasIgnoreListHint(url)) as [], [ { @@ -935,12 +935,12 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///bar.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///baz.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString), true); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///bar.js' as Platform.DevToolsPath.UrlString)); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///baz.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString)); assert.deepEqual(sourceMap.findRanges(url => sourceMap.hasIgnoreListHint(url)) as [], [ { @@ -981,10 +981,10 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString), true); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString)); assert.deepEqual(sourceMap.findRanges(url => sourceMap.hasIgnoreListHint(url)) as [], [ { @@ -1023,10 +1023,10 @@ describeWithEnvironment('SourceMap', () => { const sourceMapJsonUrl = 'wp://test/source-map.json' as Platform.DevToolsPath.UrlString; const sourceMap = new SDK.SourceMap.SourceMap(compiledUrl, sourceMapJsonUrl, mappingPayload); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString), false); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString), true); - assert.strictEqual(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString), true); + assert.isFalse(sourceMap.hasIgnoreListHint('wp:///foo.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor1.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor2.js' as Platform.DevToolsPath.UrlString)); + assert.isTrue(sourceMap.hasIgnoreListHint('wp:///vendor3.js' as Platform.DevToolsPath.UrlString)); assert.deepEqual(sourceMap.findRanges(url => sourceMap.hasIgnoreListHint(url)) as [], [ { diff --git a/front_end/entrypoints/formatter_worker/FormattedContentBuilder.test.ts b/front_end/entrypoints/formatter_worker/FormattedContentBuilder.test.ts index 67d2d76d4a..36a5800722 100644 --- a/front_end/entrypoints/formatter_worker/FormattedContentBuilder.test.ts +++ b/front_end/entrypoints/formatter_worker/FormattedContentBuilder.test.ts @@ -15,7 +15,7 @@ describe('FormattedContentBuilder', () => { const formattedContentBuilder = new FormatterWorker.FormattedContentBuilder.FormattedContentBuilder(' '); formattedContentBuilder.setEnforceSpaceBetweenWords(false); const result = formattedContentBuilder.setEnforceSpaceBetweenWords(true); - assert.strictEqual(result, false); + assert.isFalse(result); }); it('should squash new lines by default', () => { diff --git a/front_end/models/bindings/FileUtils.test.ts b/front_end/models/bindings/FileUtils.test.ts index 69073ceb71..47782eaf69 100644 --- a/front_end/models/bindings/FileUtils.test.ts +++ b/front_end/models/bindings/FileUtils.test.ts @@ -37,7 +37,7 @@ describe('FileUtils', () => { const hasNoError = await reader.read(output); - assert.strictEqual(hasNoError, true); + assert.isTrue(hasNoError); assert.strictEqual(chunkCount, 41); assert.strictEqual(text.join(''), output.data(), 'Read text is different from written text'); }); @@ -71,7 +71,7 @@ describe('FileUtils', () => { const cfreader = new ChunkedFileReader(compressedFile, chunkSize, () => ++chunkCount); const hasNoError = await cfreader.read(output); - assert.strictEqual(hasNoError, true); + assert.isTrue(hasNoError); assert.strictEqual(expectedText, output.data(), 'Read text is different from written text'); }); }); diff --git a/front_end/models/breakpoints/BreakpointManager.test.ts b/front_end/models/breakpoints/BreakpointManager.test.ts index 999468f937..4825a09842 100644 --- a/front_end/models/breakpoints/BreakpointManager.test.ts +++ b/front_end/models/breakpoints/BreakpointManager.test.ts @@ -410,6 +410,7 @@ describeWithMockConnection('BreakpointManager', () => { assert.exists(modelBreakpoint); // Make sure that we do not have a linked script yet. + // eslint-disable-next-line rulesdir/no-assert-equal-boolean-null-undefined assert.strictEqual(modelBreakpoint.currentState, null); // Now await restoring the breakpoint. diff --git a/front_end/models/extensions/ExtensionServer.test.ts b/front_end/models/extensions/ExtensionServer.test.ts index cb5c2909c4..36974308c7 100644 --- a/front_end/models/extensions/ExtensionServer.test.ts +++ b/front_end/models/extensions/ExtensionServer.test.ts @@ -640,8 +640,7 @@ describe('ExtensionServer', () => { const extensionOrigin = 'chrome://abcdef' as Platform.DevToolsPath.UrlString; const almostOrigin = `${extensionOrigin}/` as Platform.DevToolsPath.UrlString; const expectation = `${extensionOrigin}/foo` as Platform.DevToolsPath.UrlString; - assert.strictEqual( - undefined, + assert.isUndefined( Extensions.ExtensionServer.ExtensionServer.expandResourcePath(extensionOrigin, 'http://example.com/foo')); assert.strictEqual( expectation, Extensions.ExtensionServer.ExtensionServer.expandResourcePath(extensionOrigin, expectation)); @@ -650,8 +649,7 @@ describe('ExtensionServer', () => { assert.strictEqual( expectation, Extensions.ExtensionServer.ExtensionServer.expandResourcePath(extensionOrigin, 'foo')); - assert.strictEqual( - undefined, + assert.isUndefined( Extensions.ExtensionServer.ExtensionServer.expandResourcePath(almostOrigin, 'http://example.com/foo')); assert.strictEqual( expectation, Extensions.ExtensionServer.ExtensionServer.expandResourcePath(almostOrigin, expectation)); diff --git a/front_end/models/har/Importer.test.ts b/front_end/models/har/Importer.test.ts index 12f19eaf01..67c994aff7 100644 --- a/front_end/models/har/Importer.test.ts +++ b/front_end/models/har/Importer.test.ts @@ -204,8 +204,8 @@ describe('HAR Importer', () => { assert.strictEqual(parsedRequest.requestId(), 'har-0'); assert.strictEqual(parsedRequest.url(), 'https://example.com/api/testEndpoint?param1=test'); assert.strictEqual(parsedRequest.documentURL, 'https://example.com/api/testEndpoint?param1=test'); - assert.strictEqual(parsedRequest.frameId, null); - assert.strictEqual(parsedRequest.loaderId, null); + assert.isNull(parsedRequest.frameId); + assert.isNull(parsedRequest.loaderId); assert.deepEqual( parsedRequest.initiator() as HAR.HARFormat.HARInitiator, { @@ -258,7 +258,7 @@ describe('HAR Importer', () => { it('Parses service worker info in entries', () => { const parsedRequest = requests[0]; - assert.strictEqual(parsedRequest.fetchedViaServiceWorker, true); + assert.isTrue(parsedRequest.fetchedViaServiceWorker); assert.strictEqual(parsedRequest.getResponseCacheStorageCacheName(), 'v1'); assert.strictEqual(parsedRequest.serviceWorkerResponseSource(), 'cache-storage'); }); diff --git a/front_end/models/har/Log.test.ts b/front_end/models/har/Log.test.ts index c0241e615a..f7f8621a2f 100644 --- a/front_end/models/har/Log.test.ts +++ b/front_end/models/har/Log.test.ts @@ -174,7 +174,7 @@ describe('HAR', () => { const entry = await build(request, {sanitize: false}); - assert.strictEqual(entry.response._fetchedViaServiceWorker, true); + assert.isTrue(entry.response._fetchedViaServiceWorker); assert.strictEqual(entry.response._responseCacheStorageCacheName, cacheName); assert.strictEqual( entry.response._serviceWorkerResponseSource, Protocol.Network.ServiceWorkerResponseSource.CacheStorage); diff --git a/front_end/models/issues_manager/IssueResolver.test.ts b/front_end/models/issues_manager/IssueResolver.test.ts index 3559bc6288..b482741629 100644 --- a/front_end/models/issues_manager/IssueResolver.test.ts +++ b/front_end/models/issues_manager/IssueResolver.test.ts @@ -29,7 +29,7 @@ describe('IssueResolver', () => { throw new Error('This should not get called'); }); assert.isTrue(issuesManager.hasEventListeners(IssuesManager.IssuesManager.Events.ISSUE_ADDED)); - assert.strictEqual(issue, null); + assert.isNull(issue); issueResolver.clear(); }); @@ -39,7 +39,7 @@ describe('IssueResolver', () => { const issueResolver = new IssuesManager.IssueResolver.IssueResolver(issuesManager); const waitForCall = new Promise(resolve => { const issue = issueResolver.tryGet(issueId1, resolve); - assert.strictEqual(issue, null); + assert.isNull(issue); }); assert.isTrue(issuesManager.hasEventListeners(IssuesManager.IssuesManager.Events.ISSUE_ADDED)); const mockIssue = StubIssue.createFromIssueId(issueId1); diff --git a/front_end/models/javascript_metadata/JavaScriptMetadata.test.ts b/front_end/models/javascript_metadata/JavaScriptMetadata.test.ts index abc8519220..af288b2c78 100644 --- a/front_end/models/javascript_metadata/JavaScriptMetadata.test.ts +++ b/front_end/models/javascript_metadata/JavaScriptMetadata.test.ts @@ -18,7 +18,7 @@ describe('JavaScriptMetadata', () => { it('does not retrieve native signatures that are bound to an instance', () => { const signatures = metadata.signaturesForNativeFunction('find'); - assert.deepEqual(signatures, null); + assert.isNull(signatures); }); describe('with static methods', () => { @@ -29,12 +29,12 @@ describe('JavaScriptMetadata', () => { it('does not retrieve methods that are bound to an instance', () => { const signatures = metadata.signaturesForStaticMethod('includes', 'Array'); - assert.deepEqual(signatures, null); + assert.isNull(signatures); }); it('handles a non-existing class', () => { const signatures = metadata.signaturesForStaticMethod('includes', 'bogus'); - assert.deepEqual(signatures, null); + assert.isNull(signatures); }); }); @@ -46,17 +46,17 @@ describe('JavaScriptMetadata', () => { it('does not retrieve methods that are unbound', () => { const signatures = metadata.signaturesForInstanceMethod('webkitRequestFullScreen', 'window'); - assert.deepEqual(signatures, null); + assert.isNull(signatures); }); it('does not retrieve static methods', () => { const signatures = metadata.signaturesForInstanceMethod('from', 'Array'); - assert.deepEqual(signatures, null); + assert.isNull(signatures); }); it('handles a non-existing class', () => { const signatures = metadata.signaturesForInstanceMethod('from', 'Sheep'); - assert.deepEqual(signatures, null); + assert.isNull(signatures); }); }); }); diff --git a/front_end/models/logs/RequestResolver.test.ts b/front_end/models/logs/RequestResolver.test.ts index 98f624155b..ca4a09137b 100644 --- a/front_end/models/logs/RequestResolver.test.ts +++ b/front_end/models/logs/RequestResolver.test.ts @@ -29,7 +29,7 @@ describe('RequestResolver', () => { throw new Error('This should not get called'); }); assert.isTrue(networkLog.hasEventListeners(Logs.NetworkLog.Events.RequestAdded)); - assert.strictEqual(request, null); + assert.isNull(request); requestResolver.clear(); }); @@ -39,7 +39,7 @@ describe('RequestResolver', () => { const requestResolver = new Logs.RequestResolver.RequestResolver(networkLog); const waitForCall = new Promise(resolve => { const request = requestResolver.tryGet(requestId1, resolve); - assert.strictEqual(request, null); + assert.isNull(request); }); assert.isTrue(networkLog.hasEventListeners(Logs.NetworkLog.Events.RequestAdded)); const mockRequest = createNetworkRequest(requestId1); diff --git a/front_end/models/text_utils/TextUtils.test.ts b/front_end/models/text_utils/TextUtils.test.ts index 882d56dafb..1451355553 100644 --- a/front_end/models/text_utils/TextUtils.test.ts +++ b/front_end/models/text_utils/TextUtils.test.ts @@ -8,16 +8,15 @@ describe('TextUtils', () => { describe('Utils', () => { describe('isSpaceChar', () => { it('returns the correct result for various inputs', () => { - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar(' '), true, 'space was not a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('\t'), true, 'tab was not a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('\f'), true, 'formfeed was not a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('\r'), true, 'return was not a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('\v'), true, 'vertical tab was not a space char'); - assert.strictEqual( - TextUtils.TextUtils.Utils.isSpaceChar('\xA0'), true, 'non-breaking space was not a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('\0'), false, 'null was a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('a'), false, 'a was a space char'); - assert.strictEqual(TextUtils.TextUtils.Utils.isSpaceChar('A'), false, 'A was a space char'); + assert.isTrue(TextUtils.TextUtils.Utils.isSpaceChar(' '), 'space was not a space char'); + assert.isTrue(TextUtils.TextUtils.Utils.isSpaceChar('\t'), 'tab was not a space char'); + assert.isTrue(TextUtils.TextUtils.Utils.isSpaceChar('\f'), 'formfeed was not a space char'); + assert.isTrue(TextUtils.TextUtils.Utils.isSpaceChar('\r'), 'return was not a space char'); + assert.isTrue(TextUtils.TextUtils.Utils.isSpaceChar('\v'), 'vertical tab was not a space char'); + assert.isTrue(TextUtils.TextUtils.Utils.isSpaceChar('\xA0'), 'non-breaking space was not a space char'); + assert.isFalse(TextUtils.TextUtils.Utils.isSpaceChar('\0'), 'null was a space char'); + assert.isFalse(TextUtils.TextUtils.Utils.isSpaceChar('a'), 'a was a space char'); + assert.isFalse(TextUtils.TextUtils.Utils.isSpaceChar('A'), 'A was a space char'); }); }); @@ -105,7 +104,7 @@ describe('TextUtils', () => { const filterParser = new TextUtils.TextUtils.FilterParser(['TestVal1']); const result = filterParser.parse(testVal); assert.strictEqual(result[0].text, testVal, 'text value was not returned correctly'); - assert.strictEqual(result[0].negative, false, 'negative value was not returned correctly'); + assert.isFalse(result[0].negative, 'negative value was not returned correctly'); }); describe('parse', () => { @@ -330,7 +329,7 @@ describe('TextUtils', () => { assert.strictEqual(cloned.key, 'a', 'key was incorrect'); assert.strictEqual(cloned.text, 'b', 'text was incorrect'); assert.deepEqual(cloned.regex, /a/, 'regex was incorrect'); - assert.strictEqual(cloned.negative, true, 'negative was incorrect'); + assert.isTrue(cloned.negative, 'negative was incorrect'); }); }); @@ -351,11 +350,11 @@ describe('TextUtils', () => { const tokenizer = new TextUtils.TextUtils.BalancedJSONTokenizer(callback, findMultiple); let result = tokenizer.write('a'); - assert.strictEqual(result, true, 'return value was incorrect'); + assert.isTrue(result, 'return value was incorrect'); assert.deepEqual(callbackResults, [], 'callback was called'); result = tokenizer.write('{}'); - assert.strictEqual(result, true, 'return value was incorrect'); + assert.isTrue(result, 'return value was incorrect'); assert.deepEqual(callbackResults, ['a{}'], 'callback had unexpected results'); }); @@ -368,7 +367,7 @@ describe('TextUtils', () => { const tokenizer = new TextUtils.TextUtils.BalancedJSONTokenizer(callback, findMultiple); const result = tokenizer.write('{}}'); - assert.strictEqual(result, true, 'return value was incorrect'); + assert.isTrue(result, 'return value was incorrect'); assert.deepEqual(callbackResults, ['{}'], 'callback had unexpected results'); assert.strictEqual(tokenizer.remainder(), '}', 'remainder was incorrect'); }); @@ -382,7 +381,7 @@ describe('TextUtils', () => { const tokenizer = new TextUtils.TextUtils.BalancedJSONTokenizer(callback, findMultiple); const result = tokenizer.write('"""'); - assert.strictEqual(result, true, 'return value was incorrect'); + assert.isTrue(result, 'return value was incorrect'); assert.deepEqual(callbackResults, [], 'callback had unexpected results'); assert.strictEqual(tokenizer.remainder(), '"""', 'remainder was incorrect'); }); @@ -396,7 +395,7 @@ describe('TextUtils', () => { const tokenizer = new TextUtils.TextUtils.BalancedJSONTokenizer(callback, findMultiple); const result = tokenizer.write('}}'); - assert.strictEqual(result, false, 'return value was incorrect'); + assert.isFalse(result, 'return value was incorrect'); assert.deepEqual(callbackResults, [], 'callback had unexpected results'); assert.strictEqual(tokenizer.remainder(), '}}', 'remainder was incorrect'); }); @@ -410,7 +409,7 @@ describe('TextUtils', () => { const tokenizer = new TextUtils.TextUtils.BalancedJSONTokenizer(callback, findMultiple); const result = tokenizer.write(']]'); - assert.strictEqual(result, false, 'return value was incorrect'); + assert.isFalse(result, 'return value was incorrect'); assert.deepEqual(callbackResults, [], 'callback had unexpected results'); assert.strictEqual(tokenizer.remainder(), ']]', 'remainder was incorrect'); }); @@ -421,7 +420,7 @@ describe('TextUtils', () => { it('handles empty string', () => { const result = isMinified(''); - assert.strictEqual(result, false, 'was minified'); + assert.isFalse(result, 'was minified'); }); it('correctly detects a minified HTML document', () => { @@ -432,7 +431,7 @@ describe('TextUtils', () => { `; - assert.strictEqual(isMinified(text), true); + assert.isTrue(isMinified(text)); }); it('correctly detects minified Closure-style modules', () => { @@ -450,7 +449,7 @@ for(let e=0;e { @@ -464,7 +463,7 @@ for(let e=0;e entries.length), [2, 1, 1]); const secondTrackData = extensionHandlerOutput.extensionTrackData[1]; assert.strictEqual(secondTrackData.name, 'Group 2'); - assert.strictEqual(secondTrackData.isTrackGroup, true); + assert.isTrue(secondTrackData.isTrackGroup); assert.deepEqual(Object.keys(secondTrackData.entriesByTrack), ['Track 1']); assert.deepEqual(Object.values(secondTrackData.entriesByTrack).map(entries => entries.length), [1]); diff --git a/front_end/models/trace/helpers/SamplesIntegrator.test.ts b/front_end/models/trace/helpers/SamplesIntegrator.test.ts index bdbd08d2d4..326717825a 100644 --- a/front_end/models/trace/helpers/SamplesIntegrator.test.ts +++ b/front_end/models/trace/helpers/SamplesIntegrator.test.ts @@ -67,7 +67,7 @@ describeWithEnvironment('SamplesIntegrator', function() { ...Trace.Types.Configuration.defaults(), }; config.debugMode = true; - assert.strictEqual(Trace.Types.Configuration.defaults().debugMode, false, 'Default config should not be mutable'); + assert.isFalse(Trace.Types.Configuration.defaults().debugMode, 'Default config should not be mutable'); const integrator = new Trace.Helpers.SamplesIntegrator.SamplesIntegrator(parsedBasicProfile, PROFILE_ID, pid, tid, config); diff --git a/front_end/models/trace/helpers/TreeHelpers.test.ts b/front_end/models/trace/helpers/TreeHelpers.test.ts index 60d5b23220..ec580e55eb 100644 --- a/front_end/models/trace/helpers/TreeHelpers.test.ts +++ b/front_end/models/trace/helpers/TreeHelpers.test.ts @@ -507,12 +507,12 @@ describe('TreeHelpers', () => { // Now we can make sure the pre-serialized data is also correct. assert.strictEqual(v8RunNode.name, 'v8.run'); - assert.strictEqual(v8RunNode.selected, true); + assert.isTrue(v8RunNode.selected); assert.strictEqual(v8RunNode.duration, 0.49); assert.strictEqual(v8RunNode.children?.length, 3); assert.strictEqual(aiNodeTree.name, 'EvaluateScript'); - assert.strictEqual(aiNodeTree.selected, undefined); + assert.isUndefined(aiNodeTree.selected); assert.strictEqual(aiNodeTree.duration, 0.5); assert.strictEqual(aiNodeTree.children?.length, 1); @@ -520,9 +520,9 @@ describe('TreeHelpers', () => { assert.exists(v8RunNode); assert.strictEqual(parseFnAINode.name, 'V8.ParseFunction'); - assert.strictEqual(parseFnAINode.selected, undefined); + assert.isUndefined(parseFnAINode.selected); assert.strictEqual(parseFnAINode.duration, 0.001); - assert.strictEqual(parseFnAINode.children, undefined); + assert.isUndefined(parseFnAINode.children); }); }); }); diff --git a/front_end/models/trace/insights/LCPDiscovery.test.ts b/front_end/models/trace/insights/LCPDiscovery.test.ts index c20822f1a6..12299b0960 100644 --- a/front_end/models/trace/insights/LCPDiscovery.test.ts +++ b/front_end/models/trace/insights/LCPDiscovery.test.ts @@ -12,9 +12,9 @@ describeWithEnvironment('LCPDiscovery', function() { const insight = getInsightOrError('LCPDiscovery', insights, firstNav); const {shouldIncreasePriorityHint, shouldPreloadImage, shouldRemoveLazyLoading} = insight; - assert.strictEqual(shouldRemoveLazyLoading, false); - assert.strictEqual(shouldPreloadImage, false); - assert.strictEqual(shouldIncreasePriorityHint, true); + assert.isFalse(shouldRemoveLazyLoading); + assert.isFalse(shouldPreloadImage); + assert.isTrue(shouldIncreasePriorityHint); }); it('calculates the LCP optimal time as the document request download start time', async () => { diff --git a/front_end/models/trace/insights/LCPPhases.test.ts b/front_end/models/trace/insights/LCPPhases.test.ts index c113d5677f..0b50464361 100644 --- a/front_end/models/trace/insights/LCPPhases.test.ts +++ b/front_end/models/trace/insights/LCPPhases.test.ts @@ -45,8 +45,8 @@ describeWithEnvironment('LCPPhases', function() { const firstNav = getFirstOrError(data.Meta.navigationsByNavigationId.values()); const insight = getInsightOrError('LCPPhases', insights, firstNav); - assert.strictEqual(insight.lcpMs, undefined); - assert.strictEqual(insight.phases, undefined); + assert.isUndefined(insight.lcpMs); + assert.isUndefined(insight.phases); assert.strictEqual(insight.warnings?.[0], 'NO_LCP'); }); @@ -56,7 +56,7 @@ describeWithEnvironment('LCPPhases', function() { const insight = getInsightOrError('LCPPhases', insights, firstNav); assert.strictEqual(insight.lcpMs, 204.909); - assert.strictEqual(insight.phases, undefined); + assert.isUndefined(insight.phases); assert.strictEqual(insight.warnings?.[0], 'NO_DOCUMENT_REQUEST'); }); }); diff --git a/front_end/models/trace/insights/Viewport.test.ts b/front_end/models/trace/insights/Viewport.test.ts index c98399b7fd..4121431349 100644 --- a/front_end/models/trace/insights/Viewport.test.ts +++ b/front_end/models/trace/insights/Viewport.test.ts @@ -17,7 +17,7 @@ describeWithEnvironment('Viewport', function() { const insight = getInsightOrError('Viewport', insights, getFirstOrError(data.Meta.navigationsByNavigationId.values())); - assert.strictEqual(insight.mobileOptimized, true); + assert.isTrue(insight.mobileOptimized); }); it('detects mobile unoptimized viewport', async () => { @@ -32,6 +32,6 @@ describeWithEnvironment('Viewport', function() { } const insight = Trace.Insights.Models.Viewport.generateInsight(data, context); - assert.strictEqual(insight.mobileOptimized, false); + assert.isFalse(insight.mobileOptimized); }); }); diff --git a/front_end/models/trace/lantern/core/NetworkAnalyzer.test.ts b/front_end/models/trace/lantern/core/NetworkAnalyzer.test.ts index dc4cb4fa9b..c26d60f73e 100644 --- a/front_end/models/trace/lantern/core/NetworkAnalyzer.test.ts +++ b/front_end/models/trace/lantern/core/NetworkAnalyzer.test.ts @@ -340,8 +340,8 @@ describe('NetworkAnalyzer', () => { } it('should return null for no/missing records', () => { - assert.strictEqual(estimateThroughput([]), null); - assert.strictEqual(estimateThroughput([createThroughputRecord(0, 0, {finished: false})]), null); + assert.isNull(estimateThroughput([])); + assert.isNull(estimateThroughput([createThroughputRecord(0, 0, {finished: false})])); }); it('should compute correctly for a basic waterfall', () => { diff --git a/front_end/models/trace/lantern/graph/BaseNode.test.ts b/front_end/models/trace/lantern/graph/BaseNode.test.ts index c5b1b58e2f..fe290b01eb 100644 --- a/front_end/models/trace/lantern/graph/BaseNode.test.ts +++ b/front_end/models/trace/lantern/graph/BaseNode.test.ts @@ -230,8 +230,8 @@ describe('BaseNode', () => { assert.ok(clonedIdMap.has('E'), 'did not include dependency'); assert.ok(clonedIdMap.has('B'), 'did not include branched dependency'); assert.ok(clonedIdMap.has('C'), 'did not include branched dependency'); - assert.strictEqual(clonedIdMap.get('G'), undefined); - assert.strictEqual(clonedIdMap.get('H'), undefined); + assert.isUndefined(clonedIdMap.get('G')); + assert.isUndefined(clonedIdMap.get('H')); }); it('should throw if original node is not in cloned graph', () => { @@ -288,7 +288,7 @@ describe('BaseNode', () => { describe('#hasCycle', () => { it('should return false for DAGs', () => { const graph = createComplexGraph(); - assert.strictEqual(BaseNode.hasCycle(graph.nodeA), false); + assert.isFalse(BaseNode.hasCycle(graph.nodeA)); }); it('should return false for triangular DAGs', () => { @@ -303,7 +303,7 @@ describe('BaseNode', () => { nodeA.addDependent(nodeB); nodeB.addDependent(nodeC); - assert.strictEqual(BaseNode.hasCycle(nodeA), false); + assert.isFalse(BaseNode.hasCycle(nodeA)); }); it('should return true for basic cycles', () => { @@ -316,7 +316,7 @@ describe('BaseNode', () => { nodeB.addDependent(nodeC); nodeC.addDependent(nodeA); - assert.strictEqual(BaseNode.hasCycle(nodeA), true); + assert.isTrue(BaseNode.hasCycle(nodeA)); }); it('should return true for children', () => { @@ -331,7 +331,7 @@ describe('BaseNode', () => { nodeB.addDependent(nodeC); nodeB.addDependent(nodeA); - assert.strictEqual(BaseNode.hasCycle(nodeC), true); + assert.isTrue(BaseNode.hasCycle(nodeC)); }); it('should return true for complex cycles', () => { @@ -357,14 +357,14 @@ describe('BaseNode', () => { nodeF.addDependent(nodeG); nodeG.addDependent(nodeC); - assert.strictEqual(BaseNode.hasCycle(nodeA), true); - assert.strictEqual(BaseNode.hasCycle(nodeB), true); - assert.strictEqual(BaseNode.hasCycle(nodeC), true); - assert.strictEqual(BaseNode.hasCycle(nodeD), true); - assert.strictEqual(BaseNode.hasCycle(nodeE), true); - assert.strictEqual(BaseNode.hasCycle(nodeF), true); - assert.strictEqual(BaseNode.hasCycle(nodeG), true); - assert.strictEqual(BaseNode.hasCycle(nodeH), true); + assert.isTrue(BaseNode.hasCycle(nodeA)); + assert.isTrue(BaseNode.hasCycle(nodeB)); + assert.isTrue(BaseNode.hasCycle(nodeC)); + assert.isTrue(BaseNode.hasCycle(nodeD)); + assert.isTrue(BaseNode.hasCycle(nodeE)); + assert.isTrue(BaseNode.hasCycle(nodeF)); + assert.isTrue(BaseNode.hasCycle(nodeG)); + assert.isTrue(BaseNode.hasCycle(nodeH)); }); it('works for very large graphs', () => { @@ -378,7 +378,7 @@ describe('BaseNode', () => { } lastNode.addDependent(root); - assert.strictEqual(BaseNode.hasCycle(root), true); + assert.isTrue(BaseNode.hasCycle(root)); }); }); }); diff --git a/front_end/models/trace/lantern/graph/PageDependencyGraph.test.ts b/front_end/models/trace/lantern/graph/PageDependencyGraph.test.ts index e2d8b47393..23f64a4e6e 100644 --- a/front_end/models/trace/lantern/graph/PageDependencyGraph.test.ts +++ b/front_end/models/trace/lantern/graph/PageDependencyGraph.test.ts @@ -502,9 +502,9 @@ describe('PageDependencyGraph', () => { assert.lengthOf(nodes, 3); assert.strictEqual(nodes[0].id, 1); - assert.strictEqual(nodes[0].isMainDocument(), false); - assert.strictEqual(nodes[1].isMainDocument(), true); - assert.strictEqual(nodes[2].isMainDocument(), false); + assert.isFalse(nodes[0].isMainDocument()); + assert.isTrue(nodes[1].isMainDocument()); + assert.isFalse(nodes[2].isMainDocument()); }); it('should link up script initiators', () => { diff --git a/front_end/models/trace/lantern/simulation/ConnectionPool.test.ts b/front_end/models/trace/lantern/simulation/ConnectionPool.test.ts index 403e639d48..fabe25be60 100644 --- a/front_end/models/trace/lantern/simulation/ConnectionPool.test.ts +++ b/front_end/models/trace/lantern/simulation/ConnectionPool.test.ts @@ -49,7 +49,7 @@ describe('ConnectionPool', () => { // Make sure 6 connections are created for each origin assert.lengthOf(pool.connectionsByOrigin.get('http://example.com'), 6); // Make sure it populates connectionWasReused - assert.strictEqual(pool.connectionReusedByRequestId.get('1'), false); + assert.isFalse(pool.connectionReusedByRequestId.get('1')); const connection = pool.connectionsByOrigin.get('http://example.com')[0]; assert.strictEqual(connection.rtt, rtt); @@ -164,7 +164,7 @@ describe('ConnectionPool', () => { it('noop for request without connection', () => { const requestA = request(); const pool = new ConnectionPool([requestA], simulationOptions({rtt, throughput})); - assert.strictEqual(pool.release(requestA), undefined); + assert.isUndefined(pool.release(requestA)); }); it('frees the connection for reissue', () => { diff --git a/front_end/models/workspace/UISourceCode.test.ts b/front_end/models/workspace/UISourceCode.test.ts index 2c36010713..649ddbfb27 100644 --- a/front_end/models/workspace/UISourceCode.test.ts +++ b/front_end/models/workspace/UISourceCode.test.ts @@ -77,7 +77,7 @@ describe('UISourceCode', () => { const result = await sutObject.sut.requestMetadata(); - assert.strictEqual(result, null); + assert.isNull(result); }); it('can return full display name', async () => { diff --git a/front_end/panels/ai_assistance/AiAssistancePanel.test.ts b/front_end/panels/ai_assistance/AiAssistancePanel.test.ts index d574a6129c..b062a3c9c0 100644 --- a/front_end/panels/ai_assistance/AiAssistancePanel.test.ts +++ b/front_end/panels/ai_assistance/AiAssistancePanel.test.ts @@ -787,7 +787,7 @@ describeWithEnvironment('FreestylerPanel', () => { assert.instanceOf(button, HTMLElement); dispatchClickEvent(button); assert.deepEqual(mockView.lastCall.args[0].messages, []); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); }); it('should select default agent based on open panel after clearing the chat', async () => { @@ -880,7 +880,7 @@ describeWithEnvironment('FreestylerPanel', () => { contextMenu.invokeHandler(clearAll.id()); await drainMicroTasks(); assert.deepEqual(mockView.lastCall.args[0].messages, []); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); await drainMicroTasks(); contextMenu.discard(); @@ -976,7 +976,7 @@ describeWithEnvironment('FreestylerPanel', () => { mockView.lastCall.args[0].onTextSubmit('test2'); await drainMicroTasks(); - assert.strictEqual(mockView.lastCall.args[0].isReadOnly, false); + assert.isFalse(mockView.lastCall.args[0].isReadOnly); assert.deepEqual(mockView.lastCall.args[0].messages, [ { entity: AiAssistance.ChatMessageEntity.USER, @@ -1054,7 +1054,7 @@ describeWithEnvironment('FreestylerPanel', () => { })); UI.Context.Context.instance().setFlavor(ElementsPanel.ElementsPanel.ElementsPanel, null); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); @@ -1076,7 +1076,7 @@ describeWithEnvironment('FreestylerPanel', () => { panel.markAsRoot(); panel.show(document.body); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); }); @@ -1126,7 +1126,7 @@ describeWithEnvironment('FreestylerPanel', () => { })); UI.Context.Context.instance().setFlavor(NetworkPanel.NetworkPanel.NetworkPanel, null); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); @@ -1149,7 +1149,7 @@ describeWithEnvironment('FreestylerPanel', () => { panel.markAsRoot(); panel.show(document.body); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); }); @@ -1199,7 +1199,7 @@ describeWithEnvironment('FreestylerPanel', () => { })); UI.Context.Context.instance().setFlavor(SourcesPanel.SourcesPanel.SourcesPanel, null); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); @@ -1222,7 +1222,7 @@ describeWithEnvironment('FreestylerPanel', () => { panel.markAsRoot(); panel.show(document.body); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); }); @@ -1274,7 +1274,7 @@ describeWithEnvironment('FreestylerPanel', () => { })); UI.Context.Context.instance().setFlavor(TimelinePanel.TimelinePanel.TimelinePanel, null); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); @@ -1297,7 +1297,7 @@ describeWithEnvironment('FreestylerPanel', () => { panel.markAsRoot(); panel.show(document.body); - assert.deepEqual(mockView.lastCall.args[0].agentType, undefined); + assert.isUndefined(mockView.lastCall.args[0].agentType); stub.restore(); }); }); diff --git a/front_end/panels/ai_assistance/agents/AiAgent.test.ts b/front_end/panels/ai_assistance/agents/AiAgent.test.ts index 79d317163a..e44472ba17 100644 --- a/front_end/panels/ai_assistance/agents/AiAgent.test.ts +++ b/front_end/panels/ai_assistance/agents/AiAgent.test.ts @@ -83,10 +83,7 @@ describeWithEnvironment('AiAgent', () => { aidaClient: {} as Host.AidaClient.AidaClient, }); agent.options.temperature = -1; - assert.strictEqual( - agent.buildRequest({text: 'test input'}).options?.temperature, - undefined, - ); + assert.isUndefined(agent.buildRequest({text: 'test input'}).options?.temperature); }); it('builds a request with a model id', async () => { @@ -104,10 +101,7 @@ describeWithEnvironment('AiAgent', () => { aidaClient: {} as Host.AidaClient.AidaClient, serverSideLoggingEnabled: true, }); - assert.strictEqual( - agent.buildRequest({text: 'test input'}).metadata?.disable_user_content_logging, - false, - ); + assert.isFalse(agent.buildRequest({text: 'test input'}).metadata?.disable_user_content_logging); }); it('builds a request without logging', async () => { @@ -115,14 +109,11 @@ describeWithEnvironment('AiAgent', () => { aidaClient: {} as Host.AidaClient.AidaClient, serverSideLoggingEnabled: false, }); - assert.strictEqual( - agent - .buildRequest({ - text: 'test input', - }) - .metadata?.disable_user_content_logging, - true, - ); + assert.isTrue(agent + .buildRequest({ + text: 'test input', + }) + .metadata?.disable_user_content_logging); }); it('builds a request with input', async () => { @@ -132,7 +123,7 @@ describeWithEnvironment('AiAgent', () => { }); const request = agent.buildRequest({text: 'test input'}); assert.deepEqual(request.current_message?.parts[0], {text: 'test input'}); - assert.strictEqual(request.historical_contexts, undefined); + assert.isUndefined(request.historical_contexts); }); it('builds a request with a sessionId', async () => { @@ -150,7 +141,7 @@ describeWithEnvironment('AiAgent', () => { const request = agent.buildRequest({text: 'test input'}); assert.deepEqual(request.current_message?.parts[0], {text: 'test input'}); assert.strictEqual(request.preamble, 'preamble'); - assert.strictEqual(request.historical_contexts, undefined); + assert.isUndefined(request.historical_contexts); }); it('builds a request with chat history', async () => { @@ -239,7 +230,7 @@ describeWithEnvironment('AiAgent', () => { ]; const request = agent.buildRequest({text: 'test input'}); assert.deepEqual(request.current_message?.parts[0], {text: 'test input'}); - assert.deepEqual(request.historical_contexts, undefined); + assert.isUndefined(request.historical_contexts); }); it('builds a request with aborted query in history before a real request', async () => { diff --git a/front_end/panels/ai_assistance/agents/StylingAgent.test.ts b/front_end/panels/ai_assistance/agents/StylingAgent.test.ts index 251e01d186..179f39a4b3 100644 --- a/front_end/panels/ai_assistance/agents/StylingAgent.test.ts +++ b/front_end/panels/ai_assistance/agents/StylingAgent.test.ts @@ -748,7 +748,7 @@ c`; const errorStep = responses.at(-1) as AiAssistance.ErrorResponse; assert.exists(errorStep); assert.strictEqual(errorStep.error, ErrorType.ABORT); - assert.strictEqual(await sideEffectConfirmationPromise.promise, false); + assert.isFalse(await sideEffectConfirmationPromise.promise); }); }); diff --git a/front_end/panels/ai_assistance/components/ChatView.test.ts b/front_end/panels/ai_assistance/components/ChatView.test.ts index 242acb8356..965d67ea01 100644 --- a/front_end/panels/ai_assistance/components/ChatView.test.ts +++ b/front_end/panels/ai_assistance/components/ChatView.test.ts @@ -58,8 +58,7 @@ css for (const linkCase of linkCases) { const elem = renderToElem(linkCase, linklessRenderer); assert.lengthOf(elem.querySelectorAll('a, x-link, devtools-link'), 0); - assert.strictEqual( - [' elem.outerHTML.includes(tagName)), false); + assert.isFalse([' elem.outerHTML.includes(tagName))); assert.ok(elem.textContent?.includes('( https://z.com )'), linkCase); } }); @@ -69,9 +68,8 @@ css for (const linkCase of linkCases) { const elem = renderToElem(linkCase, linkfulRenderer); assert.lengthOf(elem.querySelectorAll('a, x-link, devtools-link'), 1); - assert.strictEqual( - [' elem.outerHTML.includes(tagName)), true); - assert.strictEqual(elem.textContent?.includes('( https://z.com )'), false); + assert.isTrue([' elem.outerHTML.includes(tagName))); + assert.isFalse(elem.textContent?.includes('( https://z.com )')); } }); @@ -89,10 +87,8 @@ css for (const imageCase of imageCases) { const elem = renderToElem(imageCase, linklessRenderer); assert.lengthOf(elem.querySelectorAll('a, x-link, devtools-link, img, devtools-markdown-image'), 0); - assert.strictEqual( - [' elem.outerHTML.includes(tagName)), - false); + assert.isFalse([' elem.outerHTML.includes(tagName))); assert.ok(elem.textContent?.includes('( https://z.com/i.png )'), imageCase); } diff --git a/front_end/panels/application/ApplicationPanelSidebar.test.ts b/front_end/panels/application/ApplicationPanelSidebar.test.ts index 54e883763a..d3c1370992 100644 --- a/front_end/panels/application/ApplicationPanelSidebar.test.ts +++ b/front_end/panels/application/ApplicationPanelSidebar.test.ts @@ -364,7 +364,7 @@ describeWithMockConnection('ApplicationPanelSidebar', () => { sinon.stub(model, getter).returns([MOCK_GETTER_ITEM]); SDK.TargetManager.TargetManager.instance().setScopeTarget(target); await new Promise(resolve => setTimeout(resolve, 0)); - assert.strictEqual(expectedCall.called, true); + assert.isTrue(expectedCall.called); }; it('adds DOM storage element after scope change', diff --git a/front_end/panels/application/preloading/PreloadingView.test.ts b/front_end/panels/application/preloading/PreloadingView.test.ts index 5cefb49f77..c6997c8129 100644 --- a/front_end/panels/application/preloading/PreloadingView.test.ts +++ b/front_end/panels/application/preloading/PreloadingView.test.ts @@ -791,7 +791,7 @@ describeWithMockConnection('PreloadingAttemptView', () => { const buttons = report.querySelectorAll('devtools-report-value:nth-of-type(2) devtools-button'); assert.strictEqual(buttons[0].textContent?.trim(), 'Inspect'); - assert.strictEqual(buttons[0].getAttribute('disabled'), null); + assert.isNull(buttons[0].getAttribute('disabled')); }); it('shows prerender details with Investigate button for Ready', async () => { @@ -862,7 +862,7 @@ describeWithMockConnection('PreloadingAttemptView', () => { const buttons = report.querySelectorAll('devtools-report-value:nth-of-type(2) devtools-button'); assert.strictEqual(buttons[0].textContent?.trim(), 'Inspect'); - assert.strictEqual(buttons[0].getAttribute('disabled'), null); + assert.isNull(buttons[0].getAttribute('disabled')); }); it('shows prerender details with Investigate (disabled) button for Failure', async () => { diff --git a/front_end/panels/application/preloading/components/RuleSetDetailsView.test.ts b/front_end/panels/application/preloading/components/RuleSetDetailsView.test.ts index 60b7d3b10e..18afec0a27 100644 --- a/front_end/panels/application/preloading/components/RuleSetDetailsView.test.ts +++ b/front_end/panels/application/preloading/components/RuleSetDetailsView.test.ts @@ -53,7 +53,7 @@ describeWithEnvironment('RuleSetDetailsView', () => { backendNodeId: 1 as Protocol.DOM.BackendNodeId, }; const component = await renderRuleSetDetailsView(data, false); - assert.deepEqual(component.shadowRoot?.getElementById('error-message-text')?.textContent, undefined); + assert.isUndefined(component.shadowRoot?.getElementById('error-message-text')?.textContent); const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor; assert.strictEqual(textEditor.state.doc.toString(), data.sourceText); @@ -77,7 +77,7 @@ describeWithEnvironment('RuleSetDetailsView', () => { requestId: 'reqeustId' as Protocol.Network.RequestId, }; const component = await renderRuleSetDetailsView(data, false); - assert.deepEqual(component.shadowRoot?.getElementById('error-message-text')?.textContent, undefined); + assert.isUndefined(component.shadowRoot?.getElementById('error-message-text')?.textContent); const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor; assert.strictEqual(textEditor.state.doc.toString(), data.sourceText); }); @@ -136,7 +136,7 @@ describeWithEnvironment('RuleSetDetailsView', () => { backendNodeId: 1 as Protocol.DOM.BackendNodeId, }; const component = await renderRuleSetDetailsView(data, true); - assert.deepEqual(component.shadowRoot?.getElementById('error-message-text')?.textContent, undefined); + assert.isUndefined(component.shadowRoot?.getElementById('error-message-text')?.textContent); const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor; // Formatted sourceText should be different from the data.sourceText in this case. diff --git a/front_end/panels/elements/ElementStatePaneWidget.test.ts b/front_end/panels/elements/ElementStatePaneWidget.test.ts index 3c1e5d0b88..6d4b62c588 100644 --- a/front_end/panels/elements/ElementStatePaneWidget.test.ts +++ b/front_end/panels/elements/ElementStatePaneWidget.test.ts @@ -106,7 +106,7 @@ describeWithMockConnection('ElementStatePaneWidget', () => { const args = checkboxes.lastCall.args; assert.strictEqual(args[0], node, 'Called forcePseudoState with wrong node'); assert.strictEqual(args[1], pseudoClass, 'Called forcePseudoState with wrong pseudo-state'); - assert.strictEqual(args[2], true, 'Called forcePseudoState with wrong enable state'); + assert.isTrue(args[2], 'Called forcePseudoState with wrong enable state'); } }); diff --git a/front_end/panels/elements/components/QueryContainer.test.ts b/front_end/panels/elements/components/QueryContainer.test.ts index 6e943e376e..30ebe7d738 100644 --- a/front_end/panels/elements/components/QueryContainer.test.ts +++ b/front_end/panels/elements/components/QueryContainer.test.ts @@ -122,7 +122,7 @@ describe('QueryContainer', () => { height: '300px', }); const nonExistentDetailsElement = component.shadowRoot!.querySelector('.queried-size-details'); - assert.strictEqual(nonExistentDetailsElement, null, 'query details without any axis should not be rendered'); + assert.isNull(nonExistentDetailsElement, 'query details without any axis should not be rendered'); component.updateContainerQueriedSizeDetails({ physicalAxis: SDK.CSSContainerQuery.PhysicalAxis.HORIZONTAL, diff --git a/front_end/panels/explain/PromptBuilder.test.ts b/front_end/panels/explain/PromptBuilder.test.ts index a9c8a5d043..e040946bba 100644 --- a/front_end/panels/explain/PromptBuilder.test.ts +++ b/front_end/panels/explain/PromptBuilder.test.ts @@ -202,8 +202,8 @@ export const y = ""; it('Extracts expected whitespace from beginnings of lines', () => { assert.strictEqual(Explain.lineWhitespace(' a'), ' '); assert.strictEqual(Explain.lineWhitespace('a'), ''); - assert.strictEqual(Explain.lineWhitespace(' '), null); - assert.strictEqual(Explain.lineWhitespace(''), null); + assert.isNull(Explain.lineWhitespace(' ')); + assert.isNull(Explain.lineWhitespace('')); assert.strictEqual(Explain.lineWhitespace('\t\ta'), '\t\t'); }); diff --git a/front_end/panels/linear_memory_inspector/LinearMemoryInspectorController.test.ts b/front_end/panels/linear_memory_inspector/LinearMemoryInspectorController.test.ts index f4587e74e7..e3e6c2698e 100644 --- a/front_end/panels/linear_memory_inspector/LinearMemoryInspectorController.test.ts +++ b/front_end/panels/linear_memory_inspector/LinearMemoryInspectorController.test.ts @@ -119,7 +119,7 @@ describeWithEnvironment('LinearMemoryInspectorController', () => { const instance = LinearMemoryInspectorController.LinearMemoryInspectorController.instance(); const expressionName = 'myCar'; const result = await instance.evaluateExpression(callFrame, expressionName); - assert.strictEqual(result, undefined); + assert.isUndefined(result); assert.isTrue(stub.calledOnceWithExactly( `Tried to evaluate the expression '${expressionName}' but got an error: ${errorText}`)); }); @@ -140,7 +140,7 @@ describeWithEnvironment('LinearMemoryInspectorController', () => { const instance = LinearMemoryInspectorController.LinearMemoryInspectorController.instance(); const expressionName = 'myCar.manufacturer'; const result = await instance.evaluateExpression(callFrame, expressionName); - assert.strictEqual(result, undefined); + assert.isUndefined(result); assert.isTrue(stub.calledOnceWithExactly( `Tried to evaluate the expression '${expressionName}' but got an exception: ${exceptionText}`)); }); @@ -171,7 +171,7 @@ describeWithEnvironment('LinearMemoryInspectorController', () => { assert.deepEqual(instance.getHighlightInfo(bufferId), highlightInfo); instance.removeHighlight(bufferId, highlightInfo); - assert.deepEqual(instance.getHighlightInfo(bufferId), undefined); + assert.isUndefined(instance.getHighlightInfo(bufferId)); }); it('does not change the stored highlight when the provided highlightInfo does not match', () => { diff --git a/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.test.ts b/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.test.ts index 43efd23218..57039e1b46 100644 --- a/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.test.ts +++ b/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.test.ts @@ -398,13 +398,13 @@ describeWithLocale('LinearMemoryInspector', () => { it('returns undefined on parsing invalid address', () => { const address = '20a'; const parsedAddress = LinearMemoryInspectorComponents.LinearMemoryInspectorUtils.parseAddress(address); - assert.strictEqual(parsedAddress, undefined); + assert.isUndefined(parsedAddress); }); it('returns undefined on parsing negative address', () => { const address = '-20'; const parsedAddress = LinearMemoryInspectorComponents.LinearMemoryInspectorUtils.parseAddress(address); - assert.strictEqual(parsedAddress, undefined); + assert.isUndefined(parsedAddress); }); it('can hide the value inspector', async () => { diff --git a/front_end/panels/network/components/HeaderSectionRow.test.ts b/front_end/panels/network/components/HeaderSectionRow.test.ts index 87949eb5e1..4cd6b319ec 100644 --- a/front_end/panels/network/components/HeaderSectionRow.test.ts +++ b/front_end/panels/network/components/HeaderSectionRow.test.ts @@ -424,7 +424,7 @@ describeWithEnvironment('HeaderSectionRow', () => { assert.instanceOf(nameEditable, HTMLElement); const row = component.shadowRoot.querySelector('.row'); assert.instanceOf(row, HTMLDivElement); - assert.strictEqual(row.querySelector('devtools-icon.disallowed-characters'), null); + assert.isNull(row.querySelector('devtools-icon.disallowed-characters')); assert.isTrue(hasReloadPrompt(component.shadowRoot)); nameEditable.focus(); @@ -436,7 +436,7 @@ describeWithEnvironment('HeaderSectionRow', () => { dispatchKeyDownEvent(nameEditable, {key: 'Escape', bubbles: true, composed: true}); await coordinator.done(); - assert.strictEqual(row.querySelector('devtools-icon.disallowed-characters'), null); + assert.isNull(row.querySelector('devtools-icon.disallowed-characters')); assert.isTrue(hasReloadPrompt(component.shadowRoot)); }); @@ -580,11 +580,11 @@ describeWithEnvironment('HeaderSectionRow', () => { }); it('recoginzes only alphanumeric characters, dashes, and underscores as valid in header names', () => { - assert.strictEqual(NetworkComponents.HeaderSectionRow.isValidHeaderName('AlphaNumeric123'), true); - assert.strictEqual(NetworkComponents.HeaderSectionRow.isValidHeaderName('Alpha Numeric'), false); - assert.strictEqual(NetworkComponents.HeaderSectionRow.isValidHeaderName('AlphaNumeric123!'), false); - assert.strictEqual(NetworkComponents.HeaderSectionRow.isValidHeaderName('With-dashes_and_underscores'), true); - assert.strictEqual(NetworkComponents.HeaderSectionRow.isValidHeaderName('no*'), false); + assert.isTrue(NetworkComponents.HeaderSectionRow.isValidHeaderName('AlphaNumeric123')); + assert.isFalse(NetworkComponents.HeaderSectionRow.isValidHeaderName('Alpha Numeric')); + assert.isFalse(NetworkComponents.HeaderSectionRow.isValidHeaderName('AlphaNumeric123!')); + assert.isTrue(NetworkComponents.HeaderSectionRow.isValidHeaderName('With-dashes_and_underscores')); + assert.isFalse(NetworkComponents.HeaderSectionRow.isValidHeaderName('no*')); }); it('allows removing a header override', async () => { diff --git a/front_end/panels/network/components/RequestHeadersView.test.ts b/front_end/panels/network/components/RequestHeadersView.test.ts index 8f15fed763..d2d3c585c9 100644 --- a/front_end/panels/network/components/RequestHeadersView.test.ts +++ b/front_end/panels/network/components/RequestHeadersView.test.ts @@ -430,7 +430,7 @@ describeWithMockConnection('RequestHeadersView', () => { assert.strictEqual(valueEditable.textContent?.trim(), headerValue); } else { assert.strictEqual(shadowRoot.querySelector('.header-value')?.textContent?.trim(), headerValue); - assert.strictEqual(valueEditableComponent, null); + assert.isNull(valueEditableComponent); } }; diff --git a/front_end/panels/network/components/ResponseHeaderSection.test.ts b/front_end/panels/network/components/ResponseHeaderSection.test.ts index 723ac9d1c9..1ed21bffce 100644 --- a/front_end/panels/network/components/ResponseHeaderSection.test.ts +++ b/front_end/panels/network/components/ResponseHeaderSection.test.ts @@ -147,7 +147,7 @@ function checkHeaderSectionRow( nameEditable.textContent?.trim() + (row.shadowRoot.querySelector('.header-name')?.textContent || '').trim(); assert.strictEqual(textContent, headerName); } else { - assert.strictEqual(nameEditableComponent, null); + assert.isNull(nameEditableComponent); assert.strictEqual(row.shadowRoot.querySelector('.header-name')?.textContent?.trim(), headerName); } @@ -160,7 +160,7 @@ function checkHeaderSectionRow( assert.instanceOf(valueEditable, HTMLSpanElement); assert.strictEqual(valueEditable.textContent?.trim(), headerValue); } else { - assert.strictEqual(valueEditableComponent, null); + assert.isNull(valueEditableComponent); assert.strictEqual(row.shadowRoot.querySelector('.header-value')?.textContent?.trim(), headerValue); } } @@ -1331,7 +1331,7 @@ describeWithEnvironment('ResponseHeaderSection', () => { assert.isNotNull(rows[0].shadowRoot); assert.strictEqual(rows[0].shadowRoot.querySelector('.header-name')?.textContent?.trim(), 'set-cookie:'); assert.strictEqual(rows[0].shadowRoot.querySelector('.header-value')?.textContent?.trim(), 'user=123'); - assert.strictEqual(rows[0].shadowRoot.querySelector('.row')?.classList.contains('header-overridden'), false); + assert.isFalse(rows[0].shadowRoot.querySelector('.row')?.classList.contains('header-overridden')); }); it('does not mark unset headers (which cause the request to be blocked) as overridden', async () => { diff --git a/front_end/panels/recorder/models/recording-storage.test.ts b/front_end/panels/recorder/models/recording-storage.test.ts index 5ded30bf45..cf240e4bf7 100644 --- a/front_end/panels/recorder/models/recording-storage.test.ts +++ b/front_end/panels/recorder/models/recording-storage.test.ts @@ -48,7 +48,7 @@ describeWithEnvironment('RecordingStorage', () => { storageName: 'recording_2', flow: flow2, }); - assert.deepEqual(await storage.getRecording('recording_3'), undefined); + assert.isUndefined(await storage.getRecording('recording_3')); assert.deepEqual(await storage.updateRecording('recording_2', flow3), { storageName: 'recording_2', flow: flow3, diff --git a/front_end/panels/security/CookieControlsView.test.ts b/front_end/panels/security/CookieControlsView.test.ts index 9d1d4ef062..2d84a36108 100644 --- a/front_end/panels/security/CookieControlsView.test.ts +++ b/front_end/panels/security/CookieControlsView.test.ts @@ -20,10 +20,10 @@ describeWithMockConnection('CookieControlsView', () => { const view = new Security.CookieControlsView.CookieControlsView(undefined, mockView); const reloadRequiredInfobarSpy = sinon.spy(UI.InspectorView.InspectorView.instance(), 'displayDebuggedTabReloadRequiredWarning'); - assert.strictEqual(testSetting.get(), true); + assert.isTrue(testSetting.get()); view.inputChanged(false, testSetting); - assert.strictEqual(testSetting.get(), false); + assert.isFalse(testSetting.get()); assert.isTrue(reloadRequiredInfobarSpy.calledOnce); }); }); diff --git a/front_end/panels/sources/TabbedEditorContainer.test.ts b/front_end/panels/sources/TabbedEditorContainer.test.ts index a002af0c73..1e3b4a45fd 100644 --- a/front_end/panels/sources/TabbedEditorContainer.test.ts +++ b/front_end/panels/sources/TabbedEditorContainer.test.ts @@ -51,16 +51,16 @@ describe('TabbedEditorContainer', () => { assert.lengthOf(keys, 3); assert.propertyVal(keys[0], 'url', 'http://localhost/foo.js'); assert.propertyVal(keys[0], 'resourceType', Common.ResourceType.resourceTypes.Script); - assert.strictEqual(history.selectionRange(keys[0]), undefined); - assert.strictEqual(history.scrollLineNumber(keys[0]), undefined); + assert.isUndefined(history.selectionRange(keys[0])); + assert.isUndefined(history.scrollLineNumber(keys[0])); assert.propertyVal(keys[1], 'url', 'webpack:///src/foo.vue'); assert.propertyVal(keys[1], 'resourceType', Common.ResourceType.resourceTypes.SourceMapScript); - assert.strictEqual(history.selectionRange(keys[1]), undefined); + assert.isUndefined(history.selectionRange(keys[1])); assert.strictEqual(history.scrollLineNumber(keys[1]), 5); assert.propertyVal(keys[2], 'url', 'http://localhost/foo.js'); assert.propertyVal(keys[2], 'resourceType', Common.ResourceType.resourceTypes.SourceMapScript); - assert.strictEqual(history.selectionRange(keys[2]), undefined); - assert.strictEqual(history.scrollLineNumber(keys[2]), undefined); + assert.isUndefined(history.selectionRange(keys[2])); + assert.isUndefined(history.scrollLineNumber(keys[2])); }); it('gracefully ignores items with invalid resource type names', () => { diff --git a/front_end/panels/sources/components/BreakpointsView.test.ts b/front_end/panels/sources/components/BreakpointsView.test.ts index 8d222e164c..b380f9a625 100644 --- a/front_end/panels/sources/components/BreakpointsView.test.ts +++ b/front_end/panels/sources/components/BreakpointsView.test.ts @@ -478,10 +478,10 @@ describeWithEnvironment('BreakpointsSidebarController', () => { {forceNew: true, breakpointManager, settings}); settings.moduleSetting('breakpoints-active').set(true); let data = await controller.getUpdatedBreakpointViewData(); - assert.strictEqual(data.breakpointsActive, true); + assert.isTrue(data.breakpointsActive); settings.moduleSetting('breakpoints-active').set(false); data = await controller.getUpdatedBreakpointViewData(); - assert.strictEqual(data.breakpointsActive, false); + assert.isFalse(data.breakpointsActive); }); it('marks groups as editable based on conditional breakpoint support', async () => { diff --git a/front_end/panels/timeline/Initiators.test.ts b/front_end/panels/timeline/Initiators.test.ts index ec575a8c8e..207747aafe 100644 --- a/front_end/panels/timeline/Initiators.test.ts +++ b/front_end/panels/timeline/Initiators.test.ts @@ -136,7 +136,7 @@ describeWithEnvironment('Initiators', () => { assert.strictEqual(initiatorsData[0].event, functionCallByRAF); assert.strictEqual(initiatorsData[0].initiator, rAFParent.entry); // Ensure the expandable entry is marked as hidden - assert.strictEqual(initiatorsData[0].isInitiatorHidden, true); + assert.isTrue(initiatorsData[0].isInitiatorHidden); }); it('will return the closest expandable ancestor as an initiated event in a pair if the event itself is hidden', @@ -151,7 +151,7 @@ describeWithEnvironment('Initiators', () => { assert.strictEqual(initiatorsData[0].event, functionCallByRAFParent?.entry); assert.strictEqual(initiatorsData[0].initiator, rAFCall); // Ensure the expandable entry is marked as hidden - assert.strictEqual(initiatorsData[0].isEntryHidden, true); + assert.isTrue(initiatorsData[0].isEntryHidden); }); }); diff --git a/front_end/panels/timeline/TimelineFlameChartView.test.ts b/front_end/panels/timeline/TimelineFlameChartView.test.ts index 1ad9af074d..71456e8185 100644 --- a/front_end/panels/timeline/TimelineFlameChartView.test.ts +++ b/front_end/panels/timeline/TimelineFlameChartView.test.ts @@ -413,47 +413,37 @@ describeWithEnvironment('TimelineFlameChartView', function() { assert.strictEqual(flameChartView.getMainFlameChart().getContextMenu()?.defaultSection().items.length, 5); // Hide function enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(0) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(0) + ?.buildDescriptor() + .enabled); // Rest of the actions disabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(1) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(2) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(3) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(4) - ?.buildDescriptor() - .enabled, - false); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(1) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(2) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(3) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(4) + ?.buildDescriptor() + .enabled); }); it('When an entry has children, correctly make only Hide Entry and Hide Children enabled in the Context Menu action', @@ -487,48 +477,38 @@ describeWithEnvironment('TimelineFlameChartView', function() { // This entry has URL, so there are 5 always-shown actions, and one to add script to ignore list. assert.strictEqual(flameChartView.getMainFlameChart().getContextMenu()?.defaultSection().items.length, 6); // Hide function enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(0) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(0) + ?.buildDescriptor() + .enabled); // Hide children enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(1) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(1) + ?.buildDescriptor() + .enabled); // Rest of the actions disabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(2) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(3) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(4) - ?.buildDescriptor() - .enabled, - false); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(2) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(3) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(4) + ?.buildDescriptor() + .enabled); }); it('When an entry has repeating children, correctly make only Hide Entry, Hide Children and Hide repeating children enabled in the Context Menu action', @@ -564,49 +544,39 @@ describeWithEnvironment('TimelineFlameChartView', function() { // This entry has URL, so there are 5 always-shown actions, and one to add script to ignore list. assert.strictEqual(flameChartView.getMainFlameChart().getContextMenu()?.defaultSection().items.length, 6); // Hide function enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(0) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(0) + ?.buildDescriptor() + .enabled); // Hide children enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(1) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(1) + ?.buildDescriptor() + .enabled); // Hide repeating children enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(2) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(2) + ?.buildDescriptor() + .enabled); // Rest of the actions disabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(3) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(4) - ?.buildDescriptor() - .enabled, - false); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(3) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(4) + ?.buildDescriptor() + .enabled); }); it('When an entry has no parent and has children, correctly make only Hide Children enabled in the Context Menu action', @@ -648,48 +618,38 @@ describeWithEnvironment('TimelineFlameChartView', function() { generateContextMenuForNodeId(nodeId); // Hide function disabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(0) - ?.buildDescriptor() - .enabled, - false); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(0) + ?.buildDescriptor() + .enabled); // Hide children enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(1) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(1) + ?.buildDescriptor() + .enabled); // Rest of the actions disabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(2) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(3) - ?.buildDescriptor() - .enabled, - false); - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(4) - ?.buildDescriptor() - .enabled, - false); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(2) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(3) + ?.buildDescriptor() + .enabled); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(4) + ?.buildDescriptor() + .enabled); }); it('Reset Trace Context Menu action is disabled before some action has been applied', async function() { @@ -722,27 +682,23 @@ describeWithEnvironment('TimelineFlameChartView', function() { flameChartView.getMainFlameChart().getContextMenu()?.defaultSection().items.at(4)?.buildDescriptor().label, 'Reset trace'); // Check that Reset Trace is disabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(4) - ?.buildDescriptor() - .enabled, - false); + assert.isFalse(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(4) + ?.buildDescriptor() + .enabled); flameChartView.getMainFlameChart().modifyTree(PerfUI.FlameChart.FilterAction.MERGE_FUNCTION, nodeId); generateContextMenuForNodeId(nodeId); // Check that Reset Trace is enabled - assert.strictEqual( - flameChartView.getMainFlameChart() - .getContextMenu() - ?.defaultSection() - .items.at(4) - ?.buildDescriptor() - .enabled, - true); + assert.isTrue(flameChartView.getMainFlameChart() + .getContextMenu() + ?.defaultSection() + .items.at(4) + ?.buildDescriptor() + .enabled); }); it('When an entry has URL and is not ignored, correctly show the Add script to ignore list in the Context Menu action', diff --git a/front_end/panels/timeline/components/IgnoreListSetting.test.ts b/front_end/panels/timeline/components/IgnoreListSetting.test.ts index 69cf468270..9ca8c4285f 100644 --- a/front_end/panels/timeline/components/IgnoreListSetting.test.ts +++ b/front_end/panels/timeline/components/IgnoreListSetting.test.ts @@ -80,9 +80,9 @@ describeWithEnvironment('Ignore List Setting', () => { // There is a default rule `/node_modules/|/bower_components/` assert.lengthOf(ignoredRules, 2); assert.deepEqual(ignoredRules[0].regex, '/node_modules/|/bower_components/'); - assert.deepEqual(ignoredRules[0].disabled, false); + assert.isFalse(ignoredRules[0].disabled); assert.deepEqual(ignoredRules[1].regex, 'rule 1'); - assert.deepEqual(ignoredRules[1].disabled, false); + assert.isFalse(ignoredRules[1].disabled); // Check the remove buttons are rendered assert.isNotNull(component.shadowRoot); @@ -102,9 +102,9 @@ describeWithEnvironment('Ignore List Setting', () => { // There is a default rule `/node_modules/|/bower_components/` assert.lengthOf(ignoredRules, 2); assert.deepEqual(ignoredRules[0].regex, '/node_modules/|/bower_components/'); - assert.deepEqual(ignoredRules[0].disabled, false); + assert.isFalse(ignoredRules[0].disabled); assert.deepEqual(ignoredRules[1].regex, 'rule 1'); - assert.deepEqual(ignoredRules[1].disabled, true); + assert.isTrue(ignoredRules[1].disabled); }); it('Able to toggle the disable status of an ignore listed rules', async () => { diff --git a/front_end/panels/timeline/components/Utils.test.ts b/front_end/panels/timeline/components/Utils.test.ts index 1f03f7a4e6..f4a8c7beac 100644 --- a/front_end/panels/timeline/components/Utils.test.ts +++ b/front_end/panels/timeline/components/Utils.test.ts @@ -54,12 +54,12 @@ describeWithEnvironment('Utils', () => { assert.deepEqual(NumberWithUnit.parse('[Sek]() 100'), {firstPart: '', unitPart: 'Sek', lastPart: ' 100'}); // error cases - assert.deepEqual(NumberWithUnit.parse(''), null); - assert.deepEqual(NumberWithUnit.parse('100s'), null); - assert.deepEqual(NumberWithUnit.parse('100[s]('), null); - assert.deepEqual(NumberWithUnit.parse('100[s]'), null); - assert.deepEqual(NumberWithUnit.parse('100[s'), null); - assert.deepEqual(NumberWithUnit.parse('100 s]('), null); + assert.isNull(NumberWithUnit.parse('')); + assert.isNull(NumberWithUnit.parse('100s')); + assert.isNull(NumberWithUnit.parse('100[s](')); + assert.isNull(NumberWithUnit.parse('100[s]')); + assert.isNull(NumberWithUnit.parse('100[s')); + assert.isNull(NumberWithUnit.parse('100 s](')); }); }); diff --git a/front_end/panels/timeline/track_appenders/ExtensionTrackAppender.test.ts b/front_end/panels/timeline/track_appenders/ExtensionTrackAppender.test.ts index 2cbf53d1be..f5a510b84f 100644 --- a/front_end/panels/timeline/track_appenders/ExtensionTrackAppender.test.ts +++ b/front_end/panels/timeline/track_appenders/ExtensionTrackAppender.test.ts @@ -241,7 +241,7 @@ describeWithEnvironment('ExtensionTrackAppender', function() { assert.strictEqual(info.title, 'A hint if needed'); // The i18n encodes spaces using the u00A0 unicode character. assert.strictEqual(info.formattedTime, '1.00\u00A0s'); - assert.strictEqual(info.additionalElements?.at(0)?.nodeName, undefined); + assert.isUndefined(info.additionalElements?.at(0)?.nodeName); }); }); }); diff --git a/front_end/panels/timeline/track_appenders/ThreadAppender.test.ts b/front_end/panels/timeline/track_appenders/ThreadAppender.test.ts index 5a5812ae18..4cb4780e00 100644 --- a/front_end/panels/timeline/track_appenders/ThreadAppender.test.ts +++ b/front_end/panels/timeline/track_appenders/ThreadAppender.test.ts @@ -130,18 +130,18 @@ describeWithEnvironment('ThreadAppender', function() { // This group corresponds to the header that wraps the raster tracks // together. It isn't selectable and isn't nested assert.strictEqual(flameChartData.groups[1].name, 'Raster'); - assert.strictEqual(flameChartData.groups[1].selectable, false); + assert.isFalse(flameChartData.groups[1].selectable); assert.strictEqual(flameChartData.groups[1].style.nestingLevel, 0); // These groups correspond to the raster tracks titles, or the // individual raster tracks themselves. They are selectable and // nested assert.strictEqual(flameChartData.groups[2].name, 'Rasterizer thread 1'); - assert.strictEqual(flameChartData.groups[2].selectable, true); + assert.isTrue(flameChartData.groups[2].selectable); assert.strictEqual(flameChartData.groups[2].style.nestingLevel, 1); assert.strictEqual(flameChartData.groups[3].name, 'Rasterizer thread 2'); - assert.strictEqual(flameChartData.groups[3].selectable, true); + assert.isTrue(flameChartData.groups[3].selectable); assert.strictEqual(flameChartData.groups[3].style.nestingLevel, 1); }); diff --git a/front_end/panels/timeline/utils/AICallTree.test.ts b/front_end/panels/timeline/utils/AICallTree.test.ts index 59902b2eb0..0dc4ec945d 100644 --- a/front_end/panels/timeline/utils/AICallTree.test.ts +++ b/front_end/panels/timeline/utils/AICallTree.test.ts @@ -147,39 +147,39 @@ describe('AITreeFilter', () => { it('always includes the selected event', () => { const selectedEvent = makeEvent('selected', 0, 100); const filter = new Utils.AICallTree.AITreeFilter(selectedEvent); - assert.strictEqual(filter.accept(selectedEvent), true); + assert.isTrue(filter.accept(selectedEvent)); }); it('includes events that are long enough', () => { const selectedEvent = makeEvent('selected', 0, 100); const filter = new Utils.AICallTree.AITreeFilter(selectedEvent); - assert.strictEqual(filter.accept(makeEvent('short', 0, 1)), true); - assert.strictEqual(filter.accept(makeEvent('short', 0, 0.6)), true); - assert.strictEqual(filter.accept(makeEvent('long', 0, 101)), true); - assert.strictEqual(filter.accept(makeEvent('long', 0, 200)), true); - assert.strictEqual(filter.accept(makeEvent('long', 0, 1000)), true); + assert.isTrue(filter.accept(makeEvent('short', 0, 1))); + assert.isTrue(filter.accept(makeEvent('short', 0, 0.6))); + assert.isTrue(filter.accept(makeEvent('long', 0, 101))); + assert.isTrue(filter.accept(makeEvent('long', 0, 200))); + assert.isTrue(filter.accept(makeEvent('long', 0, 1000))); }); it('excludes events that are too short', () => { const selectedEvent = makeEvent('selected', 0, 100); const filter = new Utils.AICallTree.AITreeFilter(selectedEvent); - assert.strictEqual(filter.accept(makeEvent('short', 0, 0)), false); - assert.strictEqual(filter.accept(makeEvent('short', 0, 0.1)), false); - assert.strictEqual(filter.accept(makeEvent('short', 0, 0.4)), false); + assert.isFalse(filter.accept(makeEvent('short', 0, 0))); + assert.isFalse(filter.accept(makeEvent('short', 0, 0.1))); + assert.isFalse(filter.accept(makeEvent('short', 0, 0.4))); }); it('excludes COMPILE_CODE nodes if non-selected', () => { const selectedEvent = makeEvent('selected', 0, 100); const compileCodeEvent = makeEvent(Trace.Types.Events.Name.COMPILE_CODE, 0, 100); const filter = new Utils.AICallTree.AITreeFilter(selectedEvent); - assert.strictEqual(filter.accept(compileCodeEvent), false); + assert.isFalse(filter.accept(compileCodeEvent)); }); it('includes COMPILE_CODE nodes if selected', () => { const selectedEvent = makeEvent(Trace.Types.Events.Name.COMPILE_CODE, 0, 100); const filter = new Utils.AICallTree.AITreeFilter(selectedEvent); - assert.strictEqual(filter.accept(selectedEvent), true); + assert.isTrue(filter.accept(selectedEvent)); }); }); diff --git a/front_end/panels/timeline/utils/ImageCache.test.ts b/front_end/panels/timeline/utils/ImageCache.test.ts index 9e86b1db42..8fb5d5b895 100644 --- a/front_end/panels/timeline/utils/ImageCache.test.ts +++ b/front_end/panels/timeline/utils/ImageCache.test.ts @@ -48,11 +48,11 @@ describe('ImageCache', () => { it('loadImage resolves invalid images to null', async () => { const datauri = 'data:image/jpg;base64,INVALIDDATA'; const res = await loadImage(datauri); - assert.strictEqual(res, null); + assert.isNull(res); }); it('getOrQueue should return null for a new screenshot', () => { - assert.strictEqual(getOrQueue(syntheticScreenshot1), null); + assert.isNull(getOrQueue(syntheticScreenshot1)); }); it('getOrQueue should return the same image for the same screenshot', async () => { diff --git a/front_end/ui/components/data_grid/DataGrid.test.ts b/front_end/ui/components/data_grid/DataGrid.test.ts index b50d953162..04db63bbab 100644 --- a/front_end/ui/components/data_grid/DataGrid.test.ts +++ b/front_end/ui/components/data_grid/DataGrid.test.ts @@ -300,7 +300,7 @@ describe('DataGrid', () => { await coordinator.done(); const table = component.shadowRoot.querySelector('table'); assert.instanceOf(table, HTMLTableElement); - assert.strictEqual(table.getAttribute('aria-label'), null); + assert.isNull(table.getAttribute('aria-label')); }); it('adds rowcount and colcount to the table', async () => { @@ -333,7 +333,7 @@ describe('DataGrid', () => { const cityHeader = getHeaderCellForColumnId(component.shadowRoot, 'city'); const countryHeader = getHeaderCellForColumnId(component.shadowRoot, 'country'); assert.strictEqual(cityHeader.getAttribute('aria-sort'), 'none'); - assert.strictEqual(countryHeader.getAttribute('aria-sort'), null); + assert.isNull(countryHeader.getAttribute('aria-sort')); }); it('labels a column when it is sorted in ASC order', async () => { diff --git a/front_end/ui/components/panel_feedback/PreviewToggle.test.ts b/front_end/ui/components/panel_feedback/PreviewToggle.test.ts index 4a109fbd22..face3a6389 100644 --- a/front_end/ui/components/panel_feedback/PreviewToggle.test.ts +++ b/front_end/ui/components/panel_feedback/PreviewToggle.test.ts @@ -43,7 +43,7 @@ describeWithLocale('Preview toggle', () => { setEnabledStub.firstCall.calledWith('testExperiment', true), 'experiments.setEnabled was not called with the correct experiment'); assert.strictEqual(spy.callCount, 1); - assert.strictEqual(spy.firstCall.firstArg, true); + assert.isTrue(spy.firstCall.firstArg); }); it('calls out correctly to disable experiment', async () => { @@ -73,6 +73,6 @@ describeWithLocale('Preview toggle', () => { setEnabledStub.firstCall.calledWith('testExperiment', false), 'experiments.setEnabled was not called with the correct experiment'); assert.strictEqual(spy.callCount, 1); - assert.strictEqual(spy.firstCall.firstArg, false); + assert.isFalse(spy.firstCall.firstArg); }); }); diff --git a/front_end/ui/components/tree_outline/TreeOutline.test.ts b/front_end/ui/components/tree_outline/TreeOutline.test.ts index 20bb710b84..887c4be4d3 100644 --- a/front_end/ui/components/tree_outline/TreeOutline.test.ts +++ b/front_end/ui/components/tree_outline/TreeOutline.test.ts @@ -1190,7 +1190,7 @@ describe('TreeOutline', () => { await component.expandRecursively(Number.POSITIVE_INFINITY); await waitForRenderedTreeNodeCount(shadowRoot, NODE_COUNT_BASIC_DATA_FULLY_EXPANDED); const leafNodeCSGOffice = getVisibleTreeNodeByText(shadowRoot, 'CSG'); - assert.strictEqual(leafNodeCSGOffice.getAttribute('aria-expanded'), null); + assert.isNull(leafNodeCSGOffice.getAttribute('aria-expanded')); }); }); @@ -1377,7 +1377,7 @@ describe('TreeOutlineUtils', () => { it('returns null if no path is found', async () => { const path = await TreeOutline.TreeOutlineUtils.getPathToTreeNode(basicTreeData, '-1'); - assert.strictEqual(path, null); + assert.isNull(path); }); }); }); diff --git a/front_end/ui/legacy/DockController.test.ts b/front_end/ui/legacy/DockController.test.ts index 5de71bd9bf..b10383101e 100644 --- a/front_end/ui/legacy/DockController.test.ts +++ b/front_end/ui/legacy/DockController.test.ts @@ -60,13 +60,13 @@ describe('DockController', () => { */ await registerDockingSettings('left'); const dockController = LegacyUI.DockController.DockController.instance({forceNew: true, canDock: true}); - assert.strictEqual(dockController.dockSide(), undefined); + assert.isUndefined(dockController.dockSide()); }); it('falls back to undefined if the setting value is unexpected', async () => { await registerDockingSettings('woah-not-a-real-setting-value'); const dockController = LegacyUI.DockController.DockController.instance({forceNew: true, canDock: true}); - assert.strictEqual(dockController.dockSide(), undefined); + assert.isUndefined(dockController.dockSide()); }); it('sets the dockSide to undocked if the dock cannot be docked', async () => { diff --git a/front_end/ui/legacy/components/inline_editor/CSSAngle.test.ts b/front_end/ui/legacy/components/inline_editor/CSSAngle.test.ts index 6f57300054..a5730c25f5 100644 --- a/front_end/ui/legacy/components/inline_editor/CSSAngle.test.ts +++ b/front_end/ui/legacy/components/inline_editor/CSSAngle.test.ts @@ -196,10 +196,10 @@ describe('CSSAngle', () => { assert.deepEqual( InlineEditor.CSSAngleUtils.parseText('ray(20.8deg closest-side)'), {value: 20.8, unit: InlineEditor.CSSAngleUtils.AngleUnit.DEG}); - assert.deepEqual(InlineEditor.CSSAngleUtils.parseText('rotate(12345)'), null); - assert.deepEqual(InlineEditor.CSSAngleUtils.parseText(''), null); + assert.isNull(InlineEditor.CSSAngleUtils.parseText('rotate(12345)')); + assert.isNull(InlineEditor.CSSAngleUtils.parseText('')); // TODO(changhaohan): crbug.com/1138628 handle unitless 0 case - assert.deepEqual(InlineEditor.CSSAngleUtils.parseText('rotate(0)'), null); + assert.isNull(InlineEditor.CSSAngleUtils.parseText('rotate(0)')); }); it('converts angles in degree to other units correctly', () => { diff --git a/scripts/eslint_rules/lib/no-assert-equal-boolean-null-undefined.js b/scripts/eslint_rules/lib/no-assert-equal-boolean-null-undefined.js new file mode 100644 index 0000000000..ad34a40718 --- /dev/null +++ b/scripts/eslint_rules/lib/no-assert-equal-boolean-null-undefined.js @@ -0,0 +1,125 @@ +// Copyright 2024 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +'use strict'; + +/** + * @fileoverview Don't use assert equality on `boolean`, `null` or `undefined`. + * + * Prefer the more specific `assert.isTrue`, `assert.notIsTrue`, `assert.isFalse`, + * `assert.isNotFalse`, `assert.isNull`, `assert.isNotNull`, `assert.isDefined`, + * and `assert.isUndefined` methods. + */ + +// ------------------------------------------------------------------------------ +// Rule Definition +// ------------------------------------------------------------------------------ + +const EQUALITY_ASSERTIONS = new Set(['deepEqual', 'strictEqual']); +const INEQUALITY_ASSERTIONS = new Set(['notDeepEqual', 'notStrictEqual']); + +/** @type {import('eslint').Rule.RuleModule} */ +module.exports = { + meta: { + type: 'suggestion', + + docs: { + description: 'Don\'t use equality assertions on `boolean`, `null` or `undefined`.', + category: 'Best Practices', + }, + messages: { + useAssertIsDefined: 'Use `assert.isDefined` instead of `assert.{{ methodName }}` to check that a value is not `undefined`', + useAssertIsFalse: 'Use `assert.isFalse` instead of `assert.{{ methodName }}` to check that a value is `false`', + useAssertIsNotFalse: 'Use `assert.isNotFalse` instead of `assert.{{ methodName }}` to check that a value is not `undefined`', + useAssertIsNotNull: 'Use `assert.isNotNull` instead of `assert.{{ methodName }}` to check that a value is not `null`', + useAssertIsNotTrue: 'Use `assert.isNotTrue` instead of `assert.{{ methodName }}` to check that a value is not `true`', + useAssertIsNull: 'Use `assert.isNull` instead of `assert.{{ methodName }}` to check that a value is `null`', + useAssertIsTrue: 'Use `assert.isTrue` instead of `assert.{{ methodName }}` to check that a value is `true`', + useAssertIsUndefined: 'Use `assert.isUndefined` instead of `assert.{{ methodName }}` to check that a value is `undefined`', + }, + fixable: 'code', + schema: [], // no options + }, + create: function (context) { + function isAssertEquality(calleeNode) { + return calleeNode.type === 'MemberExpression' && calleeNode.object.type === 'Identifier' && + calleeNode.object.name === 'assert' && calleeNode.property.type === 'Identifier' && + EQUALITY_ASSERTIONS.has(calleeNode.property.name); + } + + function isAssertInequality(calleeNode) { + return calleeNode.type === 'MemberExpression' && calleeNode.object.type === 'Identifier' && + calleeNode.object.name === 'assert' && calleeNode.property.type === 'Identifier' && + INEQUALITY_ASSERTIONS.has(calleeNode.property.name); + } + + function isLiteral(argumentNode, value) { + return argumentNode.type === 'Literal' && argumentNode.value === value; + } + + function isUndefinedLiteral(argumentNode) { + return argumentNode.type === 'Identifier' && argumentNode.name === 'undefined'; + } + + function reportError(node, calleeText, argumentIndex, messageId) { + const methodName = node.callee.property.name; + context.report({ + node, + messageId, + data: {methodName}, + fix(fixer) { + const {sourceCode} = context; + const args = [node.arguments[argumentIndex]].concat(node.arguments.slice(2)); + const argsText = args.map(node => sourceCode.getText(node)).join(', '); + return fixer.replaceText(node, `${calleeText}(${argsText})`); + } + }); + } + + return { + CallExpression(node) { + if (node.arguments.length < 2) { + return; + } + + if (isAssertEquality(node.callee)) { + if (isLiteral(node.arguments[1], false)) { + reportError(node, 'assert.isFalse', 0, 'useAssertIsFalse'); + } else if (isLiteral(node.arguments[0], false)) { + reportError(node, 'assert.isFalse', 1, 'useAssertIsFalse'); + } else if (isLiteral(node.arguments[1], null)) { + reportError(node, 'assert.isNull', 0, 'useAssertIsNull'); + } else if (isLiteral(node.arguments[0], null)) { + reportError(node, 'assert.isNull', 1, 'useAssertIsNull'); + } else if (isLiteral(node.arguments[0], true)) { + reportError(node, 'assert.isTrue', 1, 'useAssertIsTrue'); + } else if (isLiteral(node.arguments[1], true)) { + reportError(node, 'assert.isTrue', 0, 'useAssertIsTrue'); + } else if (isUndefinedLiteral(node.arguments[1])) { + reportError(node, 'assert.isUndefined', 0, 'useAssertIsUndefined'); + } else if (isUndefinedLiteral(node.arguments[0])) { + reportError(node, 'assert.isUndefined', 1, 'useAssertIsUndefined'); + } + } else if (isAssertInequality(node.callee)) { + if (isLiteral(node.arguments[1], false)) { + reportError(node, 'assert.isNotFalse', 0, 'useAssertIsNotFalse'); + } else if (isLiteral(node.arguments[0], false)) { + reportError(node, 'assert.isNotFalse', 1, 'useAssertIsNotFalse'); + } else if (isLiteral(node.arguments[1], null)) { + reportError(node, 'assert.isNotNull', 0, 'useAssertIsNotNull'); + } else if (isLiteral(node.arguments[0], null)) { + reportError(node, 'assert.isNotNull', 1, 'useAssertIsNotNull'); + } else if (isLiteral(node.arguments[0], true)) { + reportError(node, 'assert.isNotTrue', 1, 'useAssertIsNotTrue'); + } else if (isLiteral(node.arguments[1], true)) { + reportError(node, 'assert.isNotTrue', 0, 'useAssertIsNotTrue'); + } else if (isUndefinedLiteral(node.arguments[1])) { + reportError(node, 'assert.isDefined', 0, 'useAssertIsDefined'); + } else if (isUndefinedLiteral(node.arguments[0])) { + reportError(node, 'assert.isDefined', 1, 'useAssertIsDefined'); + } + } + } + }; + }, +}; diff --git a/scripts/eslint_rules/tests/no-assert-equal-boolean-null-undefined.test.js b/scripts/eslint_rules/tests/no-assert-equal-boolean-null-undefined.test.js new file mode 100644 index 0000000000..387ca9cf2a --- /dev/null +++ b/scripts/eslint_rules/tests/no-assert-equal-boolean-null-undefined.test.js @@ -0,0 +1,209 @@ +// Copyright 2024 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +'use strict'; + +const rule = require('../lib/no-assert-equal-boolean-null-undefined.js'); +const ruleTester = new (require('eslint').RuleTester)({ + parserOptions: {ecmaVersion: 9, sourceType: 'module'}, +}); + +ruleTester.run('no-assert-equal-boolean-null-undefined', rule, { + valid: [ + { + code: 'assert.equal(foo, false);', + filename: 'foo.ts', + }, + { + code: 'assert.equal(foo, null);', + filename: 'foo.ts', + }, + { + code: 'assert.equal(foo, true);', + filename: 'foo.ts', + }, + { + code: 'assert.equal(foo, undefined);', + filename: 'foo.ts', + }, + { + code: 'assert.notEqual(foo, false);', + filename: 'foo.ts', + }, + { + code: 'assert.notEqual(foo, null);', + filename: 'foo.ts', + }, + { + code: 'assert.notEqual(foo, true);', + filename: 'foo.ts', + }, + { + code: 'assert.notEqual(foo, undefined);', + filename: 'foo.ts', + }, + ], + + invalid: [ + { + code: 'assert.deepEqual(foo, false);', + output: 'assert.isFalse(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsFalse', + }, + ], + }, + { + code: 'assert.strictEqual(foo, false);', + output: 'assert.isFalse(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsFalse', + }, + ], + }, + { + code: 'assert.deepEqual(foo, null);', + output: 'assert.isNull(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNull', + }, + ], + }, + { + code: 'assert.strictEqual(foo, null);', + output: 'assert.isNull(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNull', + }, + ], + }, + { + code: 'assert.deepEqual(foo, true);', + output: 'assert.isTrue(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsTrue', + }, + ], + }, + { + code: 'assert.strictEqual(foo, true);', + output: 'assert.isTrue(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsTrue', + }, + ], + }, + { + code: 'assert.deepEqual(foo, undefined);', + output: 'assert.isUndefined(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsUndefined', + }, + ], + }, + { + code: 'assert.strictEqual(foo, undefined);', + output: 'assert.isUndefined(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsUndefined', + }, + ], + }, + { + code: 'assert.notDeepEqual(foo, false);', + output: 'assert.isNotFalse(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNotFalse', + }, + ], + }, + { + code: 'assert.notStrictEqual(foo, false);', + output: 'assert.isNotFalse(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNotFalse', + }, + ], + }, + { + code: 'assert.notDeepEqual(foo, null);', + output: 'assert.isNotNull(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNotNull', + }, + ], + }, + { + code: 'assert.notStrictEqual(foo, null);', + output: 'assert.isNotNull(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNotNull', + }, + ], + }, + { + code: 'assert.notDeepEqual(foo, true);', + output: 'assert.isNotTrue(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNotTrue', + }, + ], + }, + { + code: 'assert.notStrictEqual(foo, true);', + output: 'assert.isNotTrue(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsNotTrue', + }, + ], + }, + { + code: 'assert.notDeepEqual(foo, undefined);', + output: 'assert.isDefined(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsDefined', + }, + ], + }, + { + code: 'assert.notStrictEqual(foo, undefined);', + output: 'assert.isDefined(foo);', + filename: 'foo.ts', + errors: [ + { + messageId: 'useAssertIsDefined', + }, + ], + }, + ], +}); diff --git a/test/e2e/console/console-stack-trace_test.ts b/test/e2e/console/console-stack-trace_test.ts index 0047fdbcc4..c0a92e3668 100644 --- a/test/e2e/console/console-stack-trace_test.ts +++ b/test/e2e/console/console-stack-trace_test.ts @@ -90,12 +90,12 @@ describe('The Console Tab', () => { // assert that hidden rows are not shown initially let showHidden = stack ? await stack.evaluate(x => x.classList.contains('show-hidden-rows')) : null; - assert.strictEqual(showHidden, false); + assert.isFalse(showHidden); // assert that after clicking 'show all'-button, hidden rows are shown await click(SHOW_MORE_LINK); showHidden = stack ? await stack.evaluate(x => x.classList.contains('show-hidden-rows')) : null; - assert.strictEqual(showHidden, true); + assert.isTrue(showHidden); const expectedUnhidden = [ {text: '\nshown3 @ showMe.js:10', visible: true}, @@ -123,6 +123,6 @@ describe('The Console Tab', () => { // assert that after clicking 'show less'-button, hidden rows are hidden again await click(SHOW_LESS_LINK); showHidden = stack ? await stack.evaluate(x => x.classList.contains('show-hidden-rows')) : null; - assert.strictEqual(showHidden, false); + assert.isFalse(showHidden); }); }); diff --git a/test/e2e/elements/style-pane-properties_test.ts b/test/e2e/elements/style-pane-properties_test.ts index d122445d69..e0552b1d9f 100644 --- a/test/e2e/elements/style-pane-properties_test.ts +++ b/test/e2e/elements/style-pane-properties_test.ts @@ -1255,7 +1255,7 @@ describe('The Styles pane', () => { const innerText = await infobox.evaluate(node => { return node.shadowRoot?.querySelector('span')?.innerText; }); - assert.strictEqual(innerText?.toLowerCase().startsWith('specificity'), true); + assert.isTrue(innerText?.toLowerCase().startsWith('specificity')); }); describe('Editing', () => { diff --git a/test/e2e/lighthouse/navigation_test.ts b/test/e2e/lighthouse/navigation_test.ts index b1be8c3a1a..e51c625735 100644 --- a/test/e2e/lighthouse/navigation_test.ts +++ b/test/e2e/lighthouse/navigation_test.ts @@ -98,10 +98,10 @@ describe('Navigation', function() { assert.match(lhr.finalUrl, /^https:\/\/localhost:[0-9]+\/test\/e2e\/resources\/lighthouse\/hello.html/); assert.strictEqual(lhr.configSettings.throttlingMethod, 'simulate'); - assert.strictEqual(lhr.configSettings.disableStorageReset, false); + assert.isFalse(lhr.configSettings.disableStorageReset); assert.strictEqual(lhr.configSettings.formFactor, 'mobile'); assert.strictEqual(lhr.configSettings.throttling.rttMs, 150); - assert.strictEqual(lhr.configSettings.screenEmulation.disabled, true); + assert.isTrue(lhr.configSettings.screenEmulation.disabled); assert.include(lhr.configSettings.emulatedUserAgent, 'Mobile'); assert.include(lhr.environment.networkUserAgent, 'Mobile'); @@ -240,10 +240,10 @@ describe('Navigation', function() { assert.deepEqual(erroredAudits, []); assert.deepEqual(Object.keys(lhr.categories), ['performance', 'best-practices']); - assert.strictEqual(lhr.configSettings.disableStorageReset, true); + assert.isTrue(lhr.configSettings.disableStorageReset); assert.strictEqual(lhr.configSettings.formFactor, 'desktop'); assert.strictEqual(lhr.configSettings.throttling.rttMs, 40); - assert.strictEqual(lhr.configSettings.screenEmulation.disabled, true); + assert.isTrue(lhr.configSettings.screenEmulation.disabled); assert.notInclude(lhr.configSettings.emulatedUserAgent, 'Mobile'); assert.notInclude(lhr.environment.networkUserAgent, 'Mobile'); diff --git a/test/e2e/lighthouse/snapshot_test.ts b/test/e2e/lighthouse/snapshot_test.ts index 0a353521c6..30ca103e5a 100644 --- a/test/e2e/lighthouse/snapshot_test.ts +++ b/test/e2e/lighthouse/snapshot_test.ts @@ -89,9 +89,9 @@ describe('Snapshot', function() { // No trace was collected in snapshot mode. const viewTrace = await $textContent('View Trace', reportEl); - assert.strictEqual(viewTrace, null); + assert.isNull(viewTrace); const viewOriginalTrace = await $textContent('View Original Trace', reportEl); - assert.strictEqual(viewOriginalTrace, null); + assert.isNull(viewOriginalTrace); // Ensure service worker is not cleared in snapshot mode. assert.strictEqual(await getServiceWorkerCount(), 1); diff --git a/test/e2e/network/network-datagrid_test.ts b/test/e2e/network/network-datagrid_test.ts index 6e4f85774a..aa86317ccc 100644 --- a/test/e2e/network/network-datagrid_test.ts +++ b/test/e2e/network/network-datagrid_test.ts @@ -77,7 +77,7 @@ describe('The Network Tab', function() { const checkbox = await waitFor('[title^="Disable cache"]'); const checked = await checkbox.evaluate(box => (box as HTMLInputElement).checked); - assert.strictEqual(checked, false, 'The disable cache checkbox should be unchecked'); + assert.isFalse(checked, 'The disable cache checkbox should be unchecked'); }); it('shows Last-Modified', async () => { diff --git a/test/e2e/recorder/replay_test.ts b/test/e2e/recorder/replay_test.ts index 5f552790e5..e8672658f7 100644 --- a/test/e2e/recorder/replay_test.ts +++ b/test/e2e/recorder/replay_test.ts @@ -98,10 +98,7 @@ describe('Recorder', function() { }, ], }); - assert.strictEqual( - await target.evaluate(() => document.querySelector('input')?.checked), - true, - ); + assert.isTrue(await target.evaluate(() => document.querySelector('input')?.checked)); }); it('should be able to replay keyboard events', async () => { diff --git a/test/e2e/sources/watch-expressions_test.ts b/test/e2e/sources/watch-expressions_test.ts index 6afe771e33..b00c745532 100644 --- a/test/e2e/sources/watch-expressions_test.ts +++ b/test/e2e/sources/watch-expressions_test.ts @@ -30,12 +30,12 @@ describe('Watch Expression Pane', () => { // Retrieve watch element and ensure that it is expanded const initialExpandCheck = await element.evaluate(e => e.classList.contains('expanded')); - assert.strictEqual(initialExpandCheck, true); + assert.isTrue(initialExpandCheck); // Begin editing and check that element is now collapsed. await frontend.keyboard.press('Enter'); const editingExpandCheck = await element.evaluate(e => e.classList.contains('expanded')); - assert.strictEqual(editingExpandCheck, false); + assert.isFalse(editingExpandCheck); // Remove the watch so that it does not interfere with other tests. await frontend.keyboard.press('Escape'); diff --git a/test/interactions/panels/recorder/injected/injected_test.ts b/test/interactions/panels/recorder/injected/injected_test.ts index fc5d24b806..5afaeef9e0 100644 --- a/test/interactions/panels/recorder/injected/injected_test.ts +++ b/test/interactions/panels/recorder/injected/injected_test.ts @@ -223,7 +223,7 @@ describe('Injected', () => { }); it('should not return a text selector for elements > maximum length', async () => { const selectors = await getSelectorOfButtonWithLength(MAXIMUM_LENGTH + 1); - assert.deepEqual(selectors, undefined); + assert.isUndefined(selectors); }); it('should return a text selector correctly with same prefix elements', async () => { let selectors = await getSelectorOfButtonWithLength(