Commit 7de741c1 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Web UI: Replace ==/!= with ===/!== in chrome/test/data/webui


This is the remainder of
https://chromium-review.googlesource.com/c/chromium/src/+/2003795
by dbeam@ generated using the same command line (updated several
sub folders in previous CLs, to reduce the final size).

Bug: 720034
Change-Id: Ia787fcbc1f1f493f1769790db6cd9e652ccd5cd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2196829Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768030}
parent 88854e15
...@@ -8,5 +8,6 @@ module.exports = { ...@@ -8,5 +8,6 @@ module.exports = {
'no-restricted-properties': 'off', 'no-restricted-properties': 'off',
'no-var': 'off', 'no-var': 'off',
'prefer-const': 'off', 'prefer-const': 'off',
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
}, },
}; };
...@@ -87,7 +87,7 @@ AccessibilityTest.runAudit_ = function(testDef) { ...@@ -87,7 +87,7 @@ AccessibilityTest.runAudit_ = function(testDef) {
* @return {!Array<axe.Result>} List of filtered violations. * @return {!Array<axe.Result>} List of filtered violations.
*/ */
AccessibilityTest.filterViolations_ = function(violations, filter) { AccessibilityTest.filterViolations_ = function(violations, filter) {
if (Object.keys(filter).length == 0) { if (Object.keys(filter).length === 0) {
return violations; return violations;
} }
......
...@@ -31,7 +31,7 @@ TEST_F('InvalidationsWebUITest', 'testRegisteringNewInvalidation', function() { ...@@ -31,7 +31,7 @@ TEST_F('InvalidationsWebUITest', 'testRegisteringNewInvalidation', function() {
var isContained = var isContained =
invalidationsLog.value.indexOf( invalidationsLog.value.indexOf(
'Received Invalidation with type ' + 'Received Invalidation with type ' +
'"EXTENSIONS" version "Unknown" with payload "undefined"') != -1; '"EXTENSIONS" version "Unknown" with payload "undefined"') !== -1;
expectTrue(isContained, 'Actual log is:' + invalidationsLog.value); expectTrue(isContained, 'Actual log is:' + invalidationsLog.value);
}); });
...@@ -46,17 +46,17 @@ TEST_F('InvalidationsWebUITest', 'testChangingInvalidationsState', function() { ...@@ -46,17 +46,17 @@ TEST_F('InvalidationsWebUITest', 'testChangingInvalidationsState', function() {
chrome.invalidations.updateInvalidatorState(newState); chrome.invalidations.updateInvalidatorState(newState);
var isContainedState = var isContainedState =
invalidationsState.textContent.indexOf('INVALIDATIONS_ENABLED') != -1; invalidationsState.textContent.indexOf('INVALIDATIONS_ENABLED') !== -1;
expectTrue(isContainedState, 'could not change the invalidations text'); expectTrue(isContainedState, 'could not change the invalidations text');
invalidationsLog.value = ''; invalidationsLog.value = '';
chrome.invalidations.updateInvalidatorState(newNewState); chrome.invalidations.updateInvalidatorState(newNewState);
var isContainedState2 = invalidationsState.textContent.indexOf( var isContainedState2 = invalidationsState.textContent.indexOf(
'TRANSIENT_INVALIDATION_ERROR') != -1; 'TRANSIENT_INVALIDATION_ERROR') !== -1;
expectTrue(isContainedState2, 'could not change the invalidations text'); expectTrue(isContainedState2, 'could not change the invalidations text');
var isContainedLog = invalidationsLog.value.indexOf( var isContainedLog = invalidationsLog.value.indexOf(
'Invalidations service state changed to ' + 'Invalidations service state changed to ' +
'"TRANSIENT_INVALIDATION_ERROR"') != -1; '"TRANSIENT_INVALIDATION_ERROR"') !== -1;
expectTrue(isContainedLog, 'Actual log is:' + invalidationsLog.value); expectTrue(isContainedLog, 'Actual log is:' + invalidationsLog.value);
}); });
...@@ -83,9 +83,9 @@ TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() { ...@@ -83,9 +83,9 @@ TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() {
var pattern2Test = true; var pattern2Test = true;
for (var cell = 0; cell < oidTable.rows[row].cells.length; cell++) { for (var cell = 0; cell < oidTable.rows[row].cells.length; cell++) {
pattern1Test = pattern1Test && pattern1Test = pattern1Test &&
(pattern1[cell] == oidTable.rows[row].cells[cell].textContent); (pattern1[cell] === oidTable.rows[row].cells[cell].textContent);
pattern2Test = pattern2Test && pattern2Test = pattern2Test &&
(pattern2[cell] == oidTable.rows[row].cells[cell].textContent); (pattern2[cell] === oidTable.rows[row].cells[cell].textContent);
} }
if (pattern1Test) { if (pattern1Test) {
expectEquals('greyed', oidTable.rows[row].className); expectEquals('greyed', oidTable.rows[row].className);
......
...@@ -758,7 +758,7 @@ TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { ...@@ -758,7 +758,7 @@ TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() {
value = value[part]; value = value[part];
} }
if (propName == 'isGattConnected') { if (propName === 'isGattConnected') {
value = value ? 'Connected' : 'Not Connected'; value = value ? 'Connected' : 'Not Connected';
} }
......
...@@ -139,7 +139,7 @@ class FakeNetworkConfig { ...@@ -139,7 +139,7 @@ class FakeNetworkConfig {
const networkState = OncMojo.managedPropertiesToNetworkState(network); const networkState = OncMojo.managedPropertiesToNetworkState(network);
const idx = this.networkStates_.findIndex(state => { const idx = this.networkStates_.findIndex(state => {
return state.guid == network.guid; return state.guid === network.guid;
}); });
if (idx >= 0) { if (idx >= 0) {
this.networkStates_[idx] = networkState; this.networkStates_[idx] = networkState;
...@@ -154,7 +154,7 @@ class FakeNetworkConfig { ...@@ -154,7 +154,7 @@ class FakeNetworkConfig {
*/ */
setNetworkConnectionStateForTest(guid, state) { setNetworkConnectionStateForTest(guid, state) {
const network = this.networkStates_.find(state => { const network = this.networkStates_.find(state => {
return state.guid == guid; return state.guid === guid;
}); });
assertTrue(!!network, 'Network not found: ' + guid); assertTrue(!!network, 'Network not found: ' + guid);
network.connectionState = state; network.connectionState = state;
...@@ -211,7 +211,7 @@ class FakeNetworkConfig { ...@@ -211,7 +211,7 @@ class FakeNetworkConfig {
state.connectRequested === undefined) { state.connectRequested === undefined) {
console.error('BAD STATE: ' + JSON.stringify(state)); console.error('BAD STATE: ' + JSON.stringify(state));
} }
return state.connectionState != return state.connectionState !==
chromeos.networkConfig.mojom.ConnectionStateType.kNotConnected; chromeos.networkConfig.mojom.ConnectionStateType.kNotConnected;
}); });
this.observers_.forEach(o => o.onActiveNetworksChanged(activeNetworks)); this.observers_.forEach(o => o.onActiveNetworksChanged(activeNetworks));
...@@ -251,7 +251,7 @@ class FakeNetworkConfig { ...@@ -251,7 +251,7 @@ class FakeNetworkConfig {
getNetworkState(guid) { getNetworkState(guid) {
return new Promise(resolve => { return new Promise(resolve => {
const result = this.networkStates_.find(state => { const result = this.networkStates_.find(state => {
return state.guid == guid; return state.guid === guid;
}); });
this.methodCalled('getNetworkState'); this.methodCalled('getNetworkState');
resolve({result: result || null}); resolve({result: result || null});
...@@ -267,10 +267,10 @@ class FakeNetworkConfig { ...@@ -267,10 +267,10 @@ class FakeNetworkConfig {
return new Promise(resolve => { return new Promise(resolve => {
const type = filter.networkType; const type = filter.networkType;
let result; let result;
if (type == chromeos.networkConfig.mojom.NetworkType.kAll) { if (type === chromeos.networkConfig.mojom.NetworkType.kAll) {
result = this.networkStates_.slice(); result = this.networkStates_.slice();
} else { } else {
result = this.networkStates_.filter(state => state.type == type); result = this.networkStates_.filter(state => state.type === type);
} }
this.methodCalled('getNetworkStateList'); this.methodCalled('getNetworkStateList');
resolve({result: result}); resolve({result: result});
...@@ -285,7 +285,7 @@ class FakeNetworkConfig { ...@@ -285,7 +285,7 @@ class FakeNetworkConfig {
return new Promise(resolve => { return new Promise(resolve => {
const devices = []; const devices = [];
this.deviceStates_.forEach((state, type) => { this.deviceStates_.forEach((state, type) => {
if (state.deviceState != if (state.deviceState !==
chromeos.networkConfig.mojom.DeviceStateType.kUninitialized) { chromeos.networkConfig.mojom.DeviceStateType.kUninitialized) {
devices.push(state); devices.push(state);
} }
...@@ -305,7 +305,7 @@ class FakeNetworkConfig { ...@@ -305,7 +305,7 @@ class FakeNetworkConfig {
let result = this.managedProperties_.get(guid); let result = this.managedProperties_.get(guid);
if (!result) { if (!result) {
const foundState = this.networkStates_.find(state => { const foundState = this.networkStates_.find(state => {
return state.guid == guid; return state.guid === guid;
}); });
if (foundState) { if (foundState) {
result = OncMojo.getDefaultManagedProperties( result = OncMojo.getDefaultManagedProperties(
......
...@@ -943,7 +943,7 @@ import {eventToPromise} from '../test_util.m.js'; ...@@ -943,7 +943,7 @@ import {eventToPromise} from '../test_util.m.js';
importButton.click(); importButton.click();
return browserProxy.whenCalled(proxyMethodName) return browserProxy.whenCalled(proxyMethodName)
.then(function(arg) { .then(function(arg) {
if (proxyMethodName == 'importPersonalCertificate') { if (proxyMethodName === 'importPersonalCertificate') {
assertNotEquals(arg, undefined); assertNotEquals(arg, undefined);
assertEquals(arg, bindBtn); assertEquals(arg, bindBtn);
} }
......
...@@ -41,8 +41,8 @@ suite('discards', function() { ...@@ -41,8 +41,8 @@ suite('discards', function() {
.forEach((sortKey) => { .forEach((sortKey) => {
assertTrue(compareTabDiscardsInfos(sortKey, dummy1, dummy2) < 0); assertTrue(compareTabDiscardsInfos(sortKey, dummy1, dummy2) < 0);
assertTrue(compareTabDiscardsInfos(sortKey, dummy2, dummy1) > 0); assertTrue(compareTabDiscardsInfos(sortKey, dummy2, dummy1) > 0);
assertTrue(compareTabDiscardsInfos(sortKey, dummy1, dummy1) == 0); assertTrue(compareTabDiscardsInfos(sortKey, dummy1, dummy1) === 0);
assertTrue(compareTabDiscardsInfos(sortKey, dummy2, dummy2) == 0); assertTrue(compareTabDiscardsInfos(sortKey, dummy2, dummy2) === 0);
}); });
}); });
......
...@@ -8,7 +8,7 @@ var embedder = null; ...@@ -8,7 +8,7 @@ var embedder = null;
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
var data = JSON.parse(e.data)[0]; var data = JSON.parse(e.data)[0];
window.console.log('guest gets message ' + data); window.console.log('guest gets message ' + data);
if (data == 'create-channel') { if (data === 'create-channel') {
embedder = e.source; embedder = e.source;
doPostMessage('connected'); doPostMessage('connected');
} }
...@@ -27,21 +27,21 @@ var destNode = document.getElementById('dest'); ...@@ -27,21 +27,21 @@ var destNode = document.getElementById('dest');
var testStep = 0; var testStep = 0;
destNode.addEventListener('dragenter', function(e) { destNode.addEventListener('dragenter', function(e) {
console.log('node drag enter'); console.log('node drag enter');
if (testStep == 0) { if (testStep === 0) {
doPostMessage('Step1: destNode gets dragenter'); doPostMessage('Step1: destNode gets dragenter');
testStep = 1; testStep = 1;
} }
}); });
destNode.addEventListener('dragover', function(e) { destNode.addEventListener('dragover', function(e) {
if (testStep == 1) { if (testStep === 1) {
doPostMessage('Step2: destNode gets dragover'); doPostMessage('Step2: destNode gets dragover');
testStep = 2; testStep = 2;
} }
}); });
destNode.addEventListener('drop', function(e) { destNode.addEventListener('drop', function(e) {
if (testStep == 2) { if (testStep === 2) {
doPostMessage('Step3: destNode gets drop'); doPostMessage('Step3: destNode gets drop');
testStep = 3; testStep = 3;
} }
......
...@@ -46,7 +46,7 @@ suite('I18nBehaviorModuleTest', function() { ...@@ -46,7 +46,7 @@ suite('I18nBehaviorModuleTest', function() {
I18nBehavior.i18nAdvanced('customAttr', { I18nBehavior.i18nAdvanced('customAttr', {
attrs: { attrs: {
is: function(el, val) { is: function(el, val) {
return el.tagName == 'A' && val == 'action-link'; return el.tagName === 'A' && val === 'action-link';
}, },
}, },
}); });
......
...@@ -54,8 +54,8 @@ var CrManagementA11yTest = class extends PolymerTest { ...@@ -54,8 +54,8 @@ var CrManagementA11yTest = class extends PolymerTest {
}, },
'list': function(nodeResult) { 'list': function(nodeResult) {
return nodeResult && nodeResult.element && return nodeResult && nodeResult.element &&
nodeResult.element.tagName == 'UL' && nodeResult.element.tagName === 'UL' &&
nodeResult.element.getElementsByTagName('DOM-REPEAT').length != 0; nodeResult.element.getElementsByTagName('DOM-REPEAT').length !== 0;
}, },
}; };
} }
......
...@@ -38,7 +38,7 @@ function BrowserTestReporter(runner) { ...@@ -38,7 +38,7 @@ function BrowserTestReporter(runner) {
if (err.stack) { if (err.stack) {
var stack = err.stack.split('\n'); var stack = err.stack.split('\n');
for (var i = 0; i < stack.length; i++) { for (var i = 0; i < stack.length; i++) {
if (stack[i].indexOf('mocha.js:') == -1) { if (stack[i].indexOf('mocha.js:') === -1) {
message += stack[i] + '\n'; message += stack[i] + '\n';
} }
} }
...@@ -51,7 +51,7 @@ function BrowserTestReporter(runner) { ...@@ -51,7 +51,7 @@ function BrowserTestReporter(runner) {
// Report the results to the test API. // Report the results to the test API.
runner.on('end', function() { runner.on('end', function() {
if (failures == 0) { if (failures === 0) {
if (passes > 0) { if (passes > 0) {
testDone(); testDone();
} else { } else {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
var fn = function() { var fn = function() {
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
var callbacks = args.filter(function(arg) { var callbacks = args.filter(function(arg) {
return (typeof arg == 'function'); return (typeof arg === 'function');
}); });
if (callbacks.length > 1) { if (callbacks.length > 1) {
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
} }
fn.recordCall(args); fn.recordCall(args);
if (callbacks.length == 1) { if (callbacks.length === 1) {
callbacks[0].apply(undefined, fn.callbackData); callbacks[0].apply(undefined, fn.callbackData);
return; return;
} }
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
* @return True if arg is not function type. * @return True if arg is not function type.
*/ */
notFunction_(arg) { notFunction_(arg) {
return typeof arg != 'function'; return typeof arg !== 'function';
} }
} }
......
...@@ -74,7 +74,7 @@ cr.define('multidevice_setup', () => { ...@@ -74,7 +74,7 @@ cr.define('multidevice_setup', () => {
const optionNodeList = const optionNodeList =
startSetupPageElement.$.deviceDropdown.querySelectorAll('option'); startSetupPageElement.$.deviceDropdown.querySelectorAll('option');
for (option of optionNodeList.values()) { for (option of optionNodeList.values()) {
if (option.textContent.trim() == optionText) { if (option.textContent.trim() === optionText) {
MockInteractions.tap(option); MockInteractions.tap(option);
return; return;
} }
......
...@@ -24,11 +24,11 @@ DebugLogsStatusWatcher.prototype = { ...@@ -24,11 +24,11 @@ DebugLogsStatusWatcher.prototype = {
}, },
onStoreDebugLogs: function(status) { onStoreDebugLogs: function(status) {
if (status.indexOf('Created') != -1) { if (status.indexOf('Created') !== -1) {
this.onTaskDone(true); this.onTaskDone(true);
return; return;
} }
if (status.indexOf('Failed') != -1) { if (status.indexOf('Failed') !== -1) {
this.onTaskDone(false); this.onTaskDone(false);
return; return;
} }
......
...@@ -52,7 +52,7 @@ CheckQueryResultTask.prototype = { ...@@ -52,7 +52,7 @@ CheckQueryResultTask.prototype = {
// Each case has its own validation function because of the design of the // Each case has its own validation function because of the design of the
// test reporting infrastructure. // test reporting infrastructure.
if (result.error != undefined) { if (result.error !== undefined) {
this.checkError_(result); this.checkError_(result);
} else if (!result.result) { } else if (!result.result) {
this.checkNotFound_(result); this.checkNotFound_(result);
......
...@@ -99,7 +99,7 @@ var NetInternalsTest = (function() { ...@@ -99,7 +99,7 @@ var NetInternalsTest = (function() {
* @return {node} The tbody node, or null. * @return {node} The tbody node, or null.
*/ */
NetInternalsTest.getTbodyDescendent = function(ancestorId) { NetInternalsTest.getTbodyDescendent = function(ancestorId) {
if ($(ancestorId).nodeName == 'TBODY') { if ($(ancestorId).nodeName === 'TBODY') {
return $(ancestorId); return $(ancestorId);
} }
// The tbody element of the first styled table in |parentId|. // The tbody element of the first styled table in |parentId|.
...@@ -154,7 +154,7 @@ var NetInternalsTest = (function() { ...@@ -154,7 +154,7 @@ var NetInternalsTest = (function() {
var currentChild = tbody.children[0]; var currentChild = tbody.children[0];
while (currentChild) { while (currentChild) {
if (NetInternalsTest.nodeIsVisible(currentChild)) { if (NetInternalsTest.nodeIsVisible(currentChild)) {
if (row == 0) { if (row === 0) {
return currentChild.children[column].innerText; return currentChild.children[column].innerText;
} }
--row; --row;
...@@ -190,7 +190,7 @@ var NetInternalsTest = (function() { ...@@ -190,7 +190,7 @@ var NetInternalsTest = (function() {
* @return {bool} Whether or not the node is visible. * @return {bool} Whether or not the node is visible.
*/ */
NetInternalsTest.nodeIsVisible = function(node) { NetInternalsTest.nodeIsVisible = function(node) {
return node.style.display != 'none'; return node.style.display !== 'none';
}; };
/** /**
...@@ -275,7 +275,7 @@ var NetInternalsTest = (function() { ...@@ -275,7 +275,7 @@ var NetInternalsTest = (function() {
var tabIdToView = tabSwitcher.getAllTabViews(); var tabIdToView = tabSwitcher.getAllTabViews();
for (var curTabId in tabIdToView) { for (var curTabId in tabIdToView) {
expectEquals( expectEquals(
curTabId == tabId, tabSwitcher.getTabView(curTabId).isVisible(), curTabId === tabId, tabSwitcher.getTabView(curTabId).isVisible(),
curTabId + ': Unexpected visibility state.'); curTabId + ': Unexpected visibility state.');
} }
}; };
...@@ -529,7 +529,7 @@ var NetInternalsTest = (function() { ...@@ -529,7 +529,7 @@ var NetInternalsTest = (function() {
*/ */
NetInternalsTest.isDisplayed = function(node) { NetInternalsTest.isDisplayed = function(node) {
var style = getComputedStyle(node); var style = getComputedStyle(node);
return style.getPropertyValue('display') != 'none'; return style.getPropertyValue('display') !== 'none';
}; };
/** /**
...@@ -544,7 +544,7 @@ var NetInternalsTest = (function() { ...@@ -544,7 +544,7 @@ var NetInternalsTest = (function() {
for (var i = 0; i < allIds.length; ++i) { for (var i = 0; i < allIds.length; ++i) {
var curId = allIds[i]; var curId = allIds[i];
expectEquals(nodeId == curId, NetInternalsTest.nodeIsVisible($(curId))); expectEquals(nodeId === curId, NetInternalsTest.nodeIsVisible($(curId)));
} }
}; };
......
...@@ -158,7 +158,7 @@ suite('NewTabPageGridFocusTest', () => { ...@@ -158,7 +158,7 @@ suite('NewTabPageGridFocusTest', () => {
// Assert. // Assert.
const focusedIndex = const focusedIndex =
(param.size % param.columns == 0 ? param.size : param.columns) - 1; (param.size % param.columns === 0 ? param.size : param.columns) - 1;
assertFocus(grid.children[focusedIndex]); assertFocus(grid.children[focusedIndex]);
}); });
...@@ -184,7 +184,7 @@ suite('NewTabPageGridFocusTest', () => { ...@@ -184,7 +184,7 @@ suite('NewTabPageGridFocusTest', () => {
// Assert. // Assert.
const focusedIndex = const focusedIndex =
(param.size % param.columns == 0 ? param.size : param.columns) - 1; (param.size % param.columns === 0 ? param.size : param.columns) - 1;
assertFocus(grid.children[focusedIndex]); assertFocus(grid.children[focusedIndex]);
}); });
......
...@@ -14,7 +14,7 @@ function DISABLED_testAssertFalse() { ...@@ -14,7 +14,7 @@ function DISABLED_testAssertFalse() {
} }
function testInitialFocus() { function testInitialFocus() {
assertTrue(document.activeElement.id == 'term', ''); assertTrue(document.activeElement.id === 'term', '');
} }
function testConsoleError() { function testConsoleError() {
......
...@@ -116,7 +116,7 @@ TEST_F('GPUSandboxStatusUITest', 'DISABLED_testGPUSandboxEnabled', function() { ...@@ -116,7 +116,7 @@ TEST_F('GPUSandboxStatusUITest', 'DISABLED_testGPUSandboxEnabled', function() {
let gpuno = addedNode.innerText.match(gpunostring); let gpuno = addedNode.innerText.match(gpunostring);
if (gpuyes || gpuno) { if (gpuyes || gpuno) {
expectEquals(null, gpuno); expectEquals(null, gpuno);
expectTrue(gpuyes && (gpuyes[0] == gpuyesstring)); expectTrue(gpuyes && (gpuyes[0] === gpuyesstring));
testDone(); testDone();
} }
} }
......
...@@ -80,7 +80,7 @@ LineChartTest.DataSeries = function() { ...@@ -80,7 +80,7 @@ LineChartTest.DataSeries = function() {
assertDeepEquals(dataSeries.getValues(0, 1000, 3), [null, 10, 20]); assertDeepEquals(dataSeries.getValues(0, 1000, 3), [null, 10, 20]);
assertEquals(dataSeries.getMaxValue(0, 1000, 3), 20); assertEquals(dataSeries.getMaxValue(0, 1000, 3), 20);
/* (10 + 20) / 2 == 15 */ /* (10 + 20) / 2 === 15 */
assertDeepEquals(dataSeries.getValues(0, 3000, 1), [15]); assertDeepEquals(dataSeries.getValues(0, 3000, 1), [15]);
assertEquals(dataSeries.getMaxValue(0, 3000, 1), 15); assertEquals(dataSeries.getMaxValue(0, 3000, 1), 15);
......
...@@ -40,15 +40,15 @@ PageTest.Switch = function() { ...@@ -40,15 +40,15 @@ PageTest.Switch = function() {
const lineChart = SysInternals.lineChart; const lineChart = SysInternals.lineChart;
assertTrue(lineChart.shouldRender()); assertTrue(lineChart.shouldRender());
const PAGE_HASH = SysInternals.PAGE_HASH; const PAGE_HASH = SysInternals.PAGE_HASH;
if (hash == PAGE_HASH.CPU) { if (hash === PAGE_HASH.CPU) {
assertEquals(lineChart.subCharts_[0].dataSeriesList_.length, 0); assertEquals(lineChart.subCharts_[0].dataSeriesList_.length, 0);
assertEquals(lineChart.subCharts_[1].dataSeriesList_.length, 9); assertEquals(lineChart.subCharts_[1].dataSeriesList_.length, 9);
assertEquals(lineChart.menu_.buttons_.length, 9); assertEquals(lineChart.menu_.buttons_.length, 9);
} else if (hash == PAGE_HASH.MEMORY) { } else if (hash === PAGE_HASH.MEMORY) {
assertEquals(lineChart.subCharts_[0].dataSeriesList_.length, 2); assertEquals(lineChart.subCharts_[0].dataSeriesList_.length, 2);
assertEquals(lineChart.subCharts_[1].dataSeriesList_.length, 2); assertEquals(lineChart.subCharts_[1].dataSeriesList_.length, 2);
assertEquals(lineChart.menu_.buttons_.length, 4); assertEquals(lineChart.menu_.buttons_.length, 4);
} else if (hash == PAGE_HASH.ZRAM) { } else if (hash === PAGE_HASH.ZRAM) {
assertEquals(lineChart.subCharts_[0].dataSeriesList_.length, 2); assertEquals(lineChart.subCharts_[0].dataSeriesList_.length, 2);
assertEquals(lineChart.subCharts_[1].dataSeriesList_.length, 3); assertEquals(lineChart.subCharts_[1].dataSeriesList_.length, 3);
assertEquals(lineChart.menu_.buttons_.length, 5); assertEquals(lineChart.menu_.buttons_.length, 5);
...@@ -69,7 +69,7 @@ PageTest.Switch = function() { ...@@ -69,7 +69,7 @@ PageTest.Switch = function() {
clickDrawerBtn(btnIndex); clickDrawerBtn(btnIndex);
return promiseResolvers.waitOnHashChangeCompleted.promise.then( return promiseResolvers.waitOnHashChangeCompleted.promise.then(
function() { function() {
if (hash == SysInternals.PAGE_HASH.INFO) { if (hash === SysInternals.PAGE_HASH.INFO) {
checkInfoPage(); checkInfoPage();
} else { } else {
checkChartPage(hash); checkChartPage(hash);
......
...@@ -79,7 +79,7 @@ Test.disableAnimationsAndTransitions = function() { ...@@ -79,7 +79,7 @@ Test.disableAnimationsAndTransitions = function() {
var realElementAnimate = Element.prototype.animate; var realElementAnimate = Element.prototype.animate;
Element.prototype.animate = function(keyframes, opt_options) { Element.prototype.animate = function(keyframes, opt_options) {
if (typeof opt_options == 'object') { if (typeof opt_options === 'object') {
opt_options.duration = 0; opt_options.duration = 0;
} else { } else {
opt_options = 0; opt_options = 0;
...@@ -247,7 +247,7 @@ Test.prototype = { ...@@ -247,7 +247,7 @@ Test.prototype = {
* @type {Function} * @type {Function}
*/ */
tearDown: function() { tearDown: function() {
if (typeof document != 'undefined') { if (typeof document !== 'undefined') {
var noAnimationStyle = document.getElementById('no-animation'); var noAnimationStyle = document.getElementById('no-animation');
if (noAnimationStyle) { if (noAnimationStyle) {
noAnimationStyle.parentNode.removeChild(noAnimationStyle); noAnimationStyle.parentNode.removeChild(noAnimationStyle);
...@@ -536,7 +536,7 @@ function makeMockFunctions(functionNames) { ...@@ -536,7 +536,7 @@ function makeMockFunctions(functionNames) {
*/ */
function send(messageName) { function send(messageName) {
var callback = sendCallbacks[messageName]; var callback = sendCallbacks[messageName];
if (callback != undefined) { if (callback !== undefined) {
callback[1].apply(callback[0], Array.prototype.slice.call(arguments, 1)); callback[1].apply(callback[0], Array.prototype.slice.call(arguments, 1));
} else { } else {
this.__proto__.send.apply(this.__proto__, arguments); this.__proto__.send.apply(this.__proto__, arguments);
...@@ -855,7 +855,7 @@ function runTest(isAsync, testFunction, testArguments) { ...@@ -855,7 +855,7 @@ function runTest(isAsync, testFunction, testArguments) {
// Depending on how we were called, |this| might not resolve to the global // Depending on how we were called, |this| might not resolve to the global
// context. // context.
if (testName == 'RUN_TEST_F' && testBody === undefined) { if (testName === 'RUN_TEST_F' && testBody === undefined) {
testBody = RUN_TEST_F; testBody = RUN_TEST_F;
} }
...@@ -863,7 +863,7 @@ function runTest(isAsync, testFunction, testArguments) { ...@@ -863,7 +863,7 @@ function runTest(isAsync, testFunction, testArguments) {
testBody = /** @type{Function} */ (eval(testFunction)); testBody = /** @type{Function} */ (eval(testFunction));
testName = testBody.toString(); testName = testBody.toString();
} }
if (testBody != RUN_TEST_F) { if (testBody !== RUN_TEST_F) {
console.log('Running test ' + testName); console.log('Running test ' + testName);
} }
...@@ -1321,8 +1321,8 @@ RunAllAction.prototype = { ...@@ -1321,8 +1321,8 @@ RunAllAction.prototype = {
result = this.actions_[i].invoke(); result = this.actions_[i].invoke();
} }
if ((this.whenTestDone_ == WhenTestDone.EXPECT && errors.length) || if ((this.whenTestDone_ === WhenTestDone.EXPECT && errors.length) ||
this.whenTestDone_ == WhenTestDone.ALWAYS) { this.whenTestDone_ === WhenTestDone.ALWAYS) {
testDone(); testDone();
} }
...@@ -1337,7 +1337,7 @@ RunAllAction.prototype = { ...@@ -1337,7 +1337,7 @@ RunAllAction.prototype = {
} }
errors.push(e); errors.push(e);
if (this.whenTestDone_ != WhenTestDone.NEVER) { if (this.whenTestDone_ !== WhenTestDone.NEVER) {
testDone(); testDone();
} }
} }
......
...@@ -19,14 +19,14 @@ cr.define('test_util', function() { ...@@ -19,14 +19,14 @@ cr.define('test_util', function() {
/* #export */ function whenAttributeIs( /* #export */ function whenAttributeIs(
target, attributeName, attributeValue) { target, attributeName, attributeValue) {
function isDone() { function isDone() {
return target.getAttribute(attributeName) == attributeValue; return target.getAttribute(attributeName) === attributeValue;
} }
return isDone() ? Promise.resolve() : new Promise(function(resolve) { return isDone() ? Promise.resolve() : new Promise(function(resolve) {
new MutationObserver(function(mutations, observer) { new MutationObserver(function(mutations, observer) {
for (const mutation of mutations) { for (const mutation of mutations) {
assertEquals('attributes', mutation.type); assertEquals('attributes', mutation.type);
if (mutation.attributeName == attributeName && isDone()) { if (mutation.attributeName === attributeName && isDone()) {
observer.disconnect(); observer.disconnect();
resolve(); resolve();
return; return;
......
...@@ -48,7 +48,7 @@ cr.define('user_manager.control_bar_tests', function() { ...@@ -48,7 +48,7 @@ cr.define('user_manager.control_bar_tests', function() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
// We expect to go to the 'create-profile' page. // We expect to go to the 'create-profile' page.
listenOnce(controlBarElement, 'change-page', function(event) { listenOnce(controlBarElement, 'change-page', function(event) {
if (event.detail.page == 'create-user-page') { if (event.detail.page === 'create-user-page') {
resolve(); resolve();
} }
}); });
...@@ -123,7 +123,7 @@ cr.define('user_manager.control_bar_tests', function() { ...@@ -123,7 +123,7 @@ cr.define('user_manager.control_bar_tests', function() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
// We expect to go to the 'create-profile' page. // We expect to go to the 'create-profile' page.
listenOnce(controlBarElement, 'change-page', function(event) { listenOnce(controlBarElement, 'change-page', function(event) {
if (event.detail.page == 'create-user-page') { if (event.detail.page === 'create-user-page') {
resolve(); resolve();
} }
}); });
......
...@@ -66,7 +66,7 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -66,7 +66,7 @@ cr.define('user_manager.create_profile_tests', function() {
// Create shortcut checkbox is invisible. // Create shortcut checkbox is invisible.
const createShortcutCheckbox = const createShortcutCheckbox =
createProfileElement.$.createShortcutCheckbox; createProfileElement.$.createShortcutCheckbox;
assertTrue(createShortcutCheckbox.clientHeight == 0); assertTrue(createShortcutCheckbox.clientHeight === 0);
// Enter a profile name. // Enter a profile name.
createProfileElement.$.nameInput.value = 'profile name'; createProfileElement.$.nameInput.value = 'profile name';
...@@ -85,7 +85,7 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -85,7 +85,7 @@ cr.define('user_manager.create_profile_tests', function() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
// Create is not in progress. We expect to leave the page. // Create is not in progress. We expect to leave the page.
createProfileElement.addEventListener('change-page', function(event) { createProfileElement.addEventListener('change-page', function(event) {
if (event.detail.page == 'user-pods-page') { if (event.detail.page === 'user-pods-page') {
resolve(); resolve();
} }
}); });
...@@ -99,7 +99,7 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -99,7 +99,7 @@ cr.define('user_manager.create_profile_tests', function() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
// Create was successful. We expect to leave the page. // Create was successful. We expect to leave the page.
createProfileElement.addEventListener('change-page', function(event) { createProfileElement.addEventListener('change-page', function(event) {
if (event.detail.page == 'user-pods-page') { if (event.detail.page === 'user-pods-page') {
resolve(); resolve();
} }
}); });
......
...@@ -14,7 +14,7 @@ function createWebview() { ...@@ -14,7 +14,7 @@ function createWebview() {
} }
function onGetBackgroundExecuted(results) { function onGetBackgroundExecuted(results) {
chrome.send('testResult', [results.length == 1 && results[0] == 'red']); chrome.send('testResult', [results.length === 1 && results[0] === 'red']);
} }
function testExecuteScriptCode(url) { function testExecuteScriptCode(url) {
...@@ -77,11 +77,11 @@ function testAddContentScript(url) { ...@@ -77,11 +77,11 @@ function testAddContentScript(url) {
}); });
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
if (e.source != webview.contentWindow) { if (e.source !== webview.contentWindow) {
return; return;
} }
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data == RESPONSE_FROM_COMM_CHANNEL_1) { if (data[0] === RESPONSE_FROM_COMM_CHANNEL_1) {
console.log( console.log(
'Step 3: A communication channel has been established with webview.'); 'Step 3: A communication channel has been established with webview.');
chrome.send('testResult', [true]); chrome.send('testResult', [true]);
...@@ -129,11 +129,11 @@ function testAddMultiContentScripts(url) { ...@@ -129,11 +129,11 @@ function testAddMultiContentScripts(url) {
var response_1 = false; var response_1 = false;
var response_2 = false; var response_2 = false;
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
if (e.source != webview.contentWindow) { if (e.source !== webview.contentWindow) {
return; return;
} }
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data == RESPONSE_FROM_COMM_CHANNEL_1) { if (data[0] === RESPONSE_FROM_COMM_CHANNEL_1) {
console.log( console.log(
'Step 4: A communication channel has been established with webview.'); 'Step 4: A communication channel has been established with webview.');
response_1 = true; response_1 = true;
...@@ -141,7 +141,7 @@ function testAddMultiContentScripts(url) { ...@@ -141,7 +141,7 @@ function testAddMultiContentScripts(url) {
chrome.send('testResult', [true]); chrome.send('testResult', [true]);
} }
return; return;
} else if (data == RESPONSE_FROM_COMM_CHANNEL_2) { } else if (data[0] === RESPONSE_FROM_COMM_CHANNEL_2) {
console.log( console.log(
'Step 5: A communication channel has been established with webview.'); 'Step 5: A communication channel has been established with webview.');
response_2 = true; response_2 = true;
...@@ -191,11 +191,11 @@ function testAddContentScriptWithSameNameShouldOverwriteTheExistingOne(url) { ...@@ -191,11 +191,11 @@ function testAddContentScriptWithSameNameShouldOverwriteTheExistingOne(url) {
var should_get_response_from_script_1 = true; var should_get_response_from_script_1 = true;
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
if (e.source != webview.contentWindow) { if (e.source !== webview.contentWindow) {
return; return;
} }
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data == RESPONSE_FROM_COMM_CHANNEL_1) { if (data[0] === RESPONSE_FROM_COMM_CHANNEL_1) {
if (should_get_response_from_script_1) { if (should_get_response_from_script_1) {
console.log( console.log(
'Step 2: A communication channel has been established with webview.'); 'Step 2: A communication channel has been established with webview.');
...@@ -215,7 +215,7 @@ function testAddContentScriptWithSameNameShouldOverwriteTheExistingOne(url) { ...@@ -215,7 +215,7 @@ function testAddContentScriptWithSameNameShouldOverwriteTheExistingOne(url) {
chrome.send('testResult', [false]); chrome.send('testResult', [false]);
} }
return; return;
} else if (data == RESPONSE_FROM_COMM_CHANNEL_2) { } else if (data[0] === RESPONSE_FROM_COMM_CHANNEL_2) {
console.log( console.log(
'Step 4: Another communication channel has been established ' + 'Step 4: Another communication channel has been established ' +
'with webview.'); 'with webview.');
...@@ -257,11 +257,11 @@ function testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView(url) { ...@@ -257,11 +257,11 @@ function testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView(url) {
}); });
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
if (e.source != webview2.contentWindow) { if (e.source !== webview2.contentWindow) {
return; return;
} }
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data == RESPONSE_FROM_COMM_CHANNEL_1) { if (data[0] === RESPONSE_FROM_COMM_CHANNEL_1) {
chrome.send('testResult', [false]); chrome.send('testResult', [false]);
return; return;
} }
...@@ -295,12 +295,12 @@ function testAddAndRemoveContentScripts(url) { ...@@ -295,12 +295,12 @@ function testAddAndRemoveContentScripts(url) {
var count = 0; var count = 0;
webview.addEventListener('loadstop', function() { webview.addEventListener('loadstop', function() {
if (count == 0) { if (count === 0) {
console.log('Step 2: post message to build connect.'); console.log('Step 2: post message to build connect.');
var msg = [REQUEST_TO_COMM_CHANNEL_1]; var msg = [REQUEST_TO_COMM_CHANNEL_1];
webview.contentWindow.postMessage(JSON.stringify(msg), '*'); webview.contentWindow.postMessage(JSON.stringify(msg), '*');
++count; ++count;
} else if (count == 1) { } else if (count === 1) {
console.log('Step 5: post message to build connect again.'); console.log('Step 5: post message to build connect again.');
var msg = [REQUEST_TO_COMM_CHANNEL_1]; var msg = [REQUEST_TO_COMM_CHANNEL_1];
webview.contentWindow.postMessage(JSON.stringify(msg), '*'); webview.contentWindow.postMessage(JSON.stringify(msg), '*');
...@@ -311,11 +311,11 @@ function testAddAndRemoveContentScripts(url) { ...@@ -311,11 +311,11 @@ function testAddAndRemoveContentScripts(url) {
}); });
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
if (e.source != webview.contentWindow) { if (e.source !== webview.contentWindow) {
return; return;
} }
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data[0] == RESPONSE_FROM_COMM_CHANNEL_1 && if (data[0] === RESPONSE_FROM_COMM_CHANNEL_1 &&
should_get_response_from_script_1) { should_get_response_from_script_1) {
console.log( console.log(
'Step 3: A communication channel has been established ' + 'Step 3: A communication channel has been established ' +
...@@ -367,12 +367,12 @@ function testAddContentScriptsWithNewWindowAPI(url) { ...@@ -367,12 +367,12 @@ function testAddContentScriptsWithNewWindowAPI(url) {
}); });
window.addEventListener('message', function(e) { window.addEventListener('message', function(e) {
if (!newwebview || e.source != newwebview.contentWindow) { if (!newwebview || e.source !== newwebview.contentWindow) {
return; return;
} }
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data == RESPONSE_FROM_COMM_CHANNEL_1 && if (data[0] === RESPONSE_FROM_COMM_CHANNEL_1 &&
e.source == newwebview.contentWindow) { e.source === newwebview.contentWindow) {
console.log( console.log(
'Step 5: a communication channel has been established ' + 'Step 5: a communication channel has been established ' +
'with the new webview.'); 'with the new webview.');
...@@ -406,12 +406,12 @@ function testContentScriptIsInjectedAfterTerminateAndReloadWebView(url) { ...@@ -406,12 +406,12 @@ function testContentScriptIsInjectedAfterTerminateAndReloadWebView(url) {
var count = 0; var count = 0;
webview.addEventListener('loadstop', function() { webview.addEventListener('loadstop', function() {
if (count == 0) { if (count === 0) {
console.log('Step 2: call webview.terminate().'); console.log('Step 2: call webview.terminate().');
webview.terminate(); webview.terminate();
++count; ++count;
return; return;
} else if (count == 1) { } else if (count === 1) {
console.log('Step 4: call <webview>.executeScript to check result.'); console.log('Step 4: call <webview>.executeScript to check result.');
webview.executeScript( webview.executeScript(
{code: 'document.body.style.backgroundColor;'}, {code: 'document.body.style.backgroundColor;'},
...@@ -443,7 +443,7 @@ function testContentScriptExistsAsLongAsWebViewTagExists(url) { ...@@ -443,7 +443,7 @@ function testContentScriptExistsAsLongAsWebViewTagExists(url) {
var count = 0; var count = 0;
webview.addEventListener('loadstop', function() { webview.addEventListener('loadstop', function() {
if (count == 0) { if (count === 0) {
console.log('Step 2: check the result of content script injected.'); console.log('Step 2: check the result of content script injected.');
webview.executeScript( webview.executeScript(
{code: 'document.body.style.backgroundColor;'}, function(results) { {code: 'document.body.style.backgroundColor;'}, function(results) {
...@@ -456,7 +456,7 @@ function testContentScriptExistsAsLongAsWebViewTagExists(url) { ...@@ -456,7 +456,7 @@ function testContentScriptExistsAsLongAsWebViewTagExists(url) {
document.body.appendChild(webview); document.body.appendChild(webview);
++count; ++count;
}); });
} else if (count == 1) { } else if (count === 1) {
console.log('Step 5: check the result of content script injected again.'); console.log('Step 5: check the result of content script injected again.');
webview.executeScript( webview.executeScript(
{code: 'document.body.style.backgroundColor;'}, {code: 'document.body.style.backgroundColor;'},
...@@ -517,7 +517,7 @@ function testDragAndDropToInput() { ...@@ -517,7 +517,7 @@ function testDragAndDropToInput() {
}); });
webview.addEventListener('loadstop', function(e) { webview.addEventListener('loadstop', function(e) {
if (webview.src != 'about:blank') { if (webview.src !== 'about:blank') {
return; return;
} }
console.log('load stop of src = :' + webview.src); console.log('load stop of src = :' + webview.src);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment