Skip to content

Commit

Permalink
Apply and enforce strict eqeqeq to c/b/r/c/accessibility
Browse files Browse the repository at this point in the history
Strategy:
- manually edit the Eslinter rule:
third_party/node/node_modules/eslint/lib/rules/eqeqeq.js

to allow for auto fixing; this was intentionally disabled upstream.

- run tools/web_dev_style/eslint.py --fix and git cl format --js on the
  directory

R=akihiroota@chromium.org, josiahk@chromium.org

Test: assumed automated test coverage
Change-Id: I97913d8d198e2fe049eeeb52473a8c58aebcd94b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503851
Reviewed-by: Akihiro Ota <akihiroota@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821818}
  • Loading branch information
dtsengchromium authored and Commit Bot committed Oct 28, 2020
1 parent b93b914 commit 5dcd99b
Show file tree
Hide file tree
Showing 102 changed files with 961 additions and 940 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
'rules': {
'brace-style': ['error', '1tbs'],
'curly': ['error', 'multi-line', 'consistent'],
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
'prefer-const': ['error', {'destructuring': 'all'}],
'object-shorthand': ['error', 'always'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ class Autoclick {
onAutomationHitTestResult_(event) {
// Walk up to the nearest scrollale area containing the point.
let node = event.target;
while (node.parent && node.role != chrome.automation.RoleType.WINDOW &&
node.role != chrome.automation.RoleType.ROOT_WEB_AREA &&
node.role != chrome.automation.RoleType.DESKTOP &&
node.role != chrome.automation.RoleType.DIALOG &&
node.role != chrome.automation.RoleType.ALERT_DIALOG &&
node.role != chrome.automation.RoleType.TOOLBAR) {
while (node.parent && node.role !== chrome.automation.RoleType.WINDOW &&
node.role !== chrome.automation.RoleType.ROOT_WEB_AREA &&
node.role !== chrome.automation.RoleType.DESKTOP &&
node.role !== chrome.automation.RoleType.DIALOG &&
node.role !== chrome.automation.RoleType.ALERT_DIALOG &&
node.role !== chrome.automation.RoleType.TOOLBAR) {
if (this.shouldHighlightAsScrollable_(node)) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class BrailleIme {
var dotsToSend = this.accumulated_;
this.accumulated_ = 0;
if (dotsToSend & this.SPACE) {
if (dotsToSend != this.SPACE) {
if (dotsToSend !== this.SPACE) {
// Can't combine space and actual dot keys.
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Background = class extends ChromeVoxState {
start.setAccessibilityFocus();

const root = AutomationUtil.getTopLevelRoot(start);
if (!root || root.role == RoleType.DESKTOP || root == start) {
if (!root || root.role === RoleType.DESKTOP || root === start) {
return;
}

Expand Down Expand Up @@ -313,8 +313,8 @@ Background = class extends ChromeVoxState {
const curRootEnd = range.end.node.root;

// Deny crossing over the start of the page selection and roots.
if (pageRootStart != pageRootEnd || pageRootStart != curRootStart ||
pageRootEnd != curRootEnd) {
if (pageRootStart !== pageRootEnd || pageRootStart !== curRootStart ||
pageRootEnd !== curRootEnd) {
o.format('@end_selection');
DesktopAutomationHandler.instance.ignoreDocumentSelectionFromAction(
false);
Expand All @@ -337,8 +337,8 @@ Background = class extends ChromeVoxState {
selectedRange = prevRange;
}
const wasBackwardSel =
this.pageSel_.start.compare(this.pageSel_.end) == Dir.BACKWARD ||
dir == Dir.BACKWARD;
this.pageSel_.start.compare(this.pageSel_.end) === Dir.BACKWARD ||
dir === Dir.BACKWARD;
this.pageSel_ = new cursors.Range(
this.pageSel_.start, wasBackwardSel ? range.start : range.end);
if (this.pageSel_) {
Expand Down Expand Up @@ -398,13 +398,13 @@ Background = class extends ChromeVoxState {

switch (target) {
case 'next':
if (action == 'getIsClassicEnabled') {
if (action === 'getIsClassicEnabled') {
const url = msg['url'];
const isClassicEnabled = false;
port.postMessage({target: 'next', isClassicEnabled});
} else if (action == 'onCommand') {
} else if (action === 'onCommand') {
CommandHandler.onCommand(msg['command']);
} else if (action == 'flushNextUtterance') {
} else if (action === 'flushNextUtterance') {
Output.forceModeForNextSpeechUtterance(QueueMode.FLUSH);
}
break;
Expand Down Expand Up @@ -437,14 +437,14 @@ Background = class extends ChromeVoxState {
*/
onClipboardEvent_(evt) {
let text = '';
if (evt.type == 'paste') {
if (evt.type === 'paste') {
if (this.preventPasteOutput_) {
this.preventPasteOutput_ = false;
return;
}
text = evt.clipboardData.getData('text');
ChromeVox.tts.speak(Msgs.getMsg(evt.type, [text]), QueueMode.QUEUE);
} else if (evt.type == 'copy' || evt.type == 'cut') {
} else if (evt.type === 'copy' || evt.type === 'cut') {
this.preventPasteOutput_ = true;
const textarea = document.createElement('textarea');
document.body.appendChild(textarea);
Expand Down Expand Up @@ -486,8 +486,8 @@ Background = class extends ChromeVoxState {

entered
.filter((f) => {
return f.role == RoleType.PLUGIN_OBJECT ||
f.role == RoleType.IFRAME;
return f.role === RoleType.PLUGIN_OBJECT ||
f.role === RoleType.IFRAME;
})
.forEach((container) => {
if (!container.state[StateType.FOCUSED]) {
Expand Down Expand Up @@ -523,7 +523,7 @@ Background = class extends ChromeVoxState {

// If a common ancestor of |start| and |end| is a link, focus that.
let ancestor = AutomationUtil.getLeastCommonAncestor(start, end);
while (ancestor && ancestor.root == start.root) {
while (ancestor && ancestor.root === start.root) {
if (isFocusableLinkOrControl(ancestor)) {
if (!ancestor.state[StateType.FOCUSED]) {
ancestor.focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ TEST_F(
// Return if the iframe hasn't loaded yet.
const iframe = rootNode.find({role: RoleType.IFRAME});
const childDoc = iframe.firstChild;
if (!childDoc || childDoc.children.length == 0) {
if (!childDoc || childDoc.children.length === 0) {
return;
}

Expand Down Expand Up @@ -677,7 +677,7 @@ TEST_F(
// Return if the iframe hasn't loaded yet.
const iframe = rootNode.find({role: 'iframe'});
const childDoc = iframe.firstChild;
if (!childDoc || childDoc.children.length == 0) {
if (!childDoc || childDoc.children.length === 0) {
return;
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ TEST_F('ChromeVoxBackgroundTest', 'Selection', function() {
function(root) {
// Fakes a toggleSelection command.
root.addEventListener('textSelectionChanged', function() {
if (root.focusOffset == 3) {
if (root.focusOffset === 3) {
CommandHandler.onCommand('toggleSelection');
}
}, true);
Expand Down Expand Up @@ -2486,7 +2486,7 @@ TEST_F('ChromeVoxBackgroundTest', 'ReadWindowTitle', function() {
const clickButtonThenReadCurrentTitle = () => {
const desktop = root.parent.root;
desktop.addEventListener(EventType.TREE_CHANGED, (evt) => {
if (evt.target.role == RoleType.WINDOW &&
if (evt.target.role === RoleType.WINDOW &&
/bar/.test(evt.target.name)) {
doCmd('readCurrentTitle')();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ BaseAutomationHandler = class {
}

// Decide whether to announce and sync this event.
const isFocusOnRoot = evt.type == 'focus' && evt.target == evt.target.root;
const isFocusOnRoot =
evt.type === 'focus' && evt.target === evt.target.root;
if (!DesktopAutomationHandler.announceActions &&
evt.eventFrom == 'action' &&
(EventSourceState.get() != EventSourceType.TOUCH_GESTURE ||
evt.eventFrom === 'action' &&
(EventSourceState.get() !== EventSourceType.TOUCH_GESTURE ||
isFocusOnRoot)) {
return;
}
Expand All @@ -113,9 +114,9 @@ BaseAutomationHandler = class {

// Don't output if focused node hasn't changed. Allow focus announcements
// when interacting via touch. Touch never sets focus without a double tap.
if (prevRange && evt.type == 'focus' &&
if (prevRange && evt.type === 'focus' &&
ChromeVoxState.instance.currentRange.equalsWithoutRecovery(prevRange) &&
EventSourceState.get() != EventSourceType.TOUCH_GESTURE) {
EventSourceState.get() !== EventSourceType.TOUCH_GESTURE) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BrailleBackground = class {
return;
}

if (localStorage['enableBrailleLogging'] == 'true') {
if (localStorage['enableBrailleLogging'] === 'true') {
const logStr = 'Braille "' + params.text.toString() + '"';
LogStore.getInstance().writeTextLog(logStr, LogStore.LogType.BRAILLE);
console.log(logStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ BrailleCaptionsBackground.groupBrailleAndText = function(

for (let i = 0; i < brailleChars.length; ++i) {
const textSliceIndex = calculateTextIndex(i);
if (i != 0 && textSliceIndex != textIndex) {
if (i !== 0 && textSliceIndex !== textIndex) {
groups.push(
[text.substr(textIndex, textSliceIndex - textIndex), brailleBuf]);
brailleBuf = '';
Expand All @@ -136,7 +136,7 @@ BrailleCaptionsBackground.groupBrailleAndText = function(
}

// Puts the rest of the text into the last group.
if (brailleBuf.length > 0 && text.charAt(textIndex) != ' ') {
if (brailleBuf.length > 0 && text.charAt(textIndex) !== ' ') {
groups.push([text.substr(textIndex), brailleBuf]);
}
return groups;
Expand All @@ -150,7 +150,7 @@ BrailleCaptionsBackground.setActive = function(newValue) {
const self = BrailleCaptionsBackground;
const oldValue = self.isEnabled();
window['prefs'].setPref(self.PREF_KEY, String(newValue));
if (oldValue != newValue) {
if (oldValue !== newValue) {
if (self.stateCallback_) {
self.stateCallback_();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BrailleCommandData.makeShortcutText = function(pattern, opt_chord) {
let msgid;
if (dots.length > 1) {
msgid = 'braille_dots';
} else if (dots.length == 1) {
} else if (dots.length === 1) {
msgid = 'braille_dot';
}

Expand All @@ -83,7 +83,7 @@ BrailleCommandData.makeShortcutText = function(pattern, opt_chord) {
BrailleCommandData.getDots = function(command) {
for (let key in BrailleCommandData.DOT_PATTERN_TO_COMMAND) {
key = parseInt(key, 10);
if (command == BrailleCommandData.DOT_PATTERN_TO_COMMAND[key]) {
if (command === BrailleCommandData.DOT_PATTERN_TO_COMMAND[key]) {
return key;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ BrailleCommandHandler.onRoutingCommand_ = function(text, position) {
}
actionNode.doDefault();

if (actionNode.role != RoleType.STATIC_TEXT &&
if (actionNode.role !== RoleType.STATIC_TEXT &&
!actionNode.state[StateType.EDITABLE]) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ChromeVoxState = function() {
// Only install the singleton instance if we are within the background page
// context. Otherwise, take the instance from the background page (e.g. for
// the panel page).
if (backgroundWindow == window) {
if (backgroundWindow === window) {
ChromeVoxState.instance = this;
} else {
Object.defineProperty(ChromeVoxState, 'instance', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ChromeVoxBackground = class {

const consoleTts = ConsoleTts.getInstance();
consoleTts.setEnabled(
ChromeVoxPrefs.instance.getPrefs()['enableSpeechLogging'] == 'true');
ChromeVoxPrefs.instance.getPrefs()['enableSpeechLogging'] === 'true');

LogStore.getInstance();

Expand Down Expand Up @@ -113,10 +113,10 @@ ChromeVoxBackground = class {
* @param {boolean} announce
*/
static setPref(pref, value, announce) {
if (pref == 'earcons') {
if (pref === 'earcons') {
AbstractEarcons.enabled = !!value;
} else if (pref == 'sticky' && announce) {
if (typeof (value) != 'boolean') {
} else if (pref === 'sticky' && announce) {
if (typeof (value) !== 'boolean') {
throw new Error('Unexpected sticky mode value ' + value);
}
chrome.accessibilityPrivate.setKeyboardListener(true, !!value);
Expand All @@ -126,7 +126,7 @@ ChromeVoxBackground = class {
value ? Msgs.getMsg('sticky_mode_enabled') :
Msgs.getMsg('sticky_mode_disabled'))
.go();
} else if (pref == 'typingEcho' && announce) {
} else if (pref === 'typingEcho' && announce) {
let announceStr = '';
switch (value) {
case TypingEcho.CHARACTER:
Expand All @@ -150,9 +150,9 @@ ChromeVoxBackground = class {
.withString(announceStr)
.go();
}
} else if (pref == 'brailleCaptions') {
} else if (pref === 'brailleCaptions') {
BrailleCaptionsBackground.setActive(!!value);
} else if (pref == 'position') {
} else if (pref === 'position') {
ChromeVox.position =
/** @type {Object<string, constants.Point>} */ (JSON.parse(
/** @type {string} */ (value)));
Expand All @@ -167,8 +167,8 @@ ChromeVoxBackground = class {
static readPrefs() {
const prefs = ChromeVoxPrefs.instance.getPrefs();
ChromeVoxEditableTextBase.useIBeamCursor =
(prefs['useIBeamCursor'] == 'true');
ChromeVox.isStickyPrefOn = (prefs['sticky'] == 'true');
(prefs['useIBeamCursor'] === 'true');
ChromeVox.isStickyPrefOn = (prefs['sticky'] === 'true');
}

/**
Expand Down Expand Up @@ -242,19 +242,19 @@ ChromeVoxBackground = class {
* @param {Object} msg The TTS message.
*/
onTtsMessage(msg) {
if (msg['action'] == 'speak') {
if (msg['action'] === 'speak') {
// The only caller sending this message is a ChromeVox Classic api client.
// Deny empty strings.
if (msg['text'] == '') {
if (msg['text'] === '') {
return;
}

this.tts.speak(
msg['text'],
/** QueueMode */ msg['queueMode'], msg['properties']);
} else if (msg['action'] == 'stop') {
} else if (msg['action'] === 'stop') {
this.tts.stop();
} else if (msg['action'] == 'increaseOrDecrease') {
} else if (msg['action'] === 'increaseOrDecrease') {
this.tts.increaseOrDecreaseProperty(msg['property'], msg['increase']);
const property = msg['property'];
const engine = this.backgroundTts_;
Expand All @@ -276,7 +276,7 @@ ChromeVoxBackground = class {
this.tts.speak(
announcement, QueueMode.FLUSH, AbstractTts.PERSONALITY_ANNOTATION);
}
} else if (msg['action'] == 'cyclePunctuationEcho') {
} else if (msg['action'] === 'cyclePunctuationEcho') {
this.tts.speak(
Msgs.getMsg(this.backgroundTts_.cyclePunctuationEcho()),
QueueMode.FLUSH);
Expand All @@ -294,7 +294,7 @@ ChromeVoxBackground = class {

switch (target) {
case 'TTS':
if (msg['startCallbackId'] != undefined) {
if (msg['startCallbackId'] !== undefined) {
msg['properties']['startCallback'] = function(opt_cleanupOnly) {
port.postMessage({
'message': 'TTS_CALLBACK',
Expand All @@ -303,7 +303,7 @@ ChromeVoxBackground = class {
});
};
}
if (msg['endCallbackId'] != undefined) {
if (msg['endCallbackId'] !== undefined) {
msg['properties']['endCallback'] = function(opt_cleanupOnly) {
port.postMessage({
'message': 'TTS_CALLBACK',
Expand Down
Loading

0 comments on commit 5dcd99b

Please sign in to comment.