Bug 1316135 - Convert eslint warnings to errors under /accessible. r=standard8
authorJared Wein <jwein@mozilla.com>
Wed, 09 Nov 2016 22:57:11 -0500
changeset 352023 496f18cd01fe699632200eb17b703da8491ded8e
parent 352022 0d6a2bc1dc0f8aa9c1ccdbf36dda905bd4d69a45
child 352024 8ce219611df17502318a030a7d512a019df8c220
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1316135
milestone52.0a1
Bug 1316135 - Convert eslint warnings to errors under /accessible. r=standard8 MozReview-Commit-ID: KDJ195PX3h4
accessible/tests/browser/.eslintrc.js
accessible/tests/browser/e10s/browser_events_statechange.js
accessible/tests/browser/e10s/browser_events_textchange.js
accessible/tests/browser/e10s/browser_treeupdate_ariadialog.js
accessible/tests/browser/e10s/browser_treeupdate_ariaowns.js
accessible/tests/browser/e10s/browser_treeupdate_doc.js
accessible/tests/browser/e10s/browser_treeupdate_imagemap.js
accessible/tests/browser/e10s/browser_treeupdate_optgroup.js
accessible/tests/browser/e10s/browser_treeupdate_textleaf.js
accessible/tests/browser/shared-head.js
--- a/accessible/tests/browser/.eslintrc.js
+++ b/accessible/tests/browser/.eslintrc.js
@@ -129,21 +129,21 @@ module.exports = { // eslint-disable-lin
     "no-plusplus": "off",
     "no-process-env": "off",
     "no-process-exit": "off",
     "no-proto": "error",
     "no-redeclare": "error",
     "no-regex-spaces": "error",
     "no-reserved-keys": "off",
     "no-restricted-modules": "off",
-    "no-return-assign": "warn",
+    "no-return-assign": "error",
     "no-script-url": "off",
     "no-self-compare": "error",
     "no-sequences": "error",
-    "no-shadow": "warn",
+    "no-shadow": "error",
     "no-shadow-restricted-names": "error",
     "no-space-before-semi": "off",
     "no-spaced-func": "error",
     "no-sparse-arrays": "error",
     "no-sync": "off",
     "no-ternary": "off",
     "no-throw-literal": "error",
     "no-trailing-spaces": "error",
--- a/accessible/tests/browser/e10s/browser_events_statechange.js
+++ b/accessible/tests/browser/e10s/browser_events_statechange.js
@@ -36,25 +36,27 @@ let iframeSrc = `data:text/html,
  *   - isEnabled
  */
 addAccessibleTask(`
   <iframe id="iframe" src="${iframeSrc}"></iframe>
   <input id="checkbox" type="checkbox" />`, function*(browser) {
   // Test state change
   let onStateChange = waitForEvent(EVENT_STATE_CHANGE, 'checkbox');
   // Set checked for a checkbox.
-  yield ContentTask.spawn(browser, {}, () =>
-    content.document.getElementById('checkbox').checked = true);
+  yield ContentTask.spawn(browser, {}, () => {
+    content.document.getElementById('checkbox').checked = true;
+  });
   let event = yield onStateChange;
 
   checkStateChangeEvent(event, STATE_CHECKED, false, true);
   testStates(event.accessible, STATE_CHECKED, 0);
 
   // Test extra state
   onStateChange = waitForEvent(EVENT_STATE_CHANGE, 'iframe');
   // Set design mode on.
-  yield ContentTask.spawn(browser, {}, () =>
-    content.document.getElementById('iframe').contentDocument.designMode = 'on');
+  yield ContentTask.spawn(browser, {}, () => {
+    content.document.getElementById('iframe').contentDocument.designMode = 'on';
+  });
   event = yield onStateChange;
 
   checkStateChangeEvent(event, EXT_STATE_EDITABLE, true, true);
   testStates(event.accessible, 0, EXT_STATE_EDITABLE);
 });
--- a/accessible/tests/browser/e10s/browser_events_textchange.js
+++ b/accessible/tests/browser/e10s/browser_events_textchange.js
@@ -19,32 +19,34 @@ function checkTextChangeEvent(event, id,
 }
 
 function* changeText(browser, id, value, events) {
   let onEvents = waitForMultipleEvents(events.map(({ isInserted }) => {
     let eventType = isInserted ? EVENT_TEXT_INSERTED : EVENT_TEXT_REMOVED;
     return { id, eventType };
   }));
   // Change text in the subtree.
-  yield ContentTask.spawn(browser, { id, value }, ({ id, value }) =>
-    content.document.getElementById(id).firstChild.textContent = value);
+  yield ContentTask.spawn(browser, [id, value], ([contentId, contentValue]) => {
+    content.document.getElementById(contentId).firstChild.textContent =
+      contentValue;
+  });
   let resolvedEvents = yield onEvents;
 
   events.forEach(({ isInserted, str, offset }, idx) =>
     checkTextChangeEvent(resolvedEvents[idx],
       id, str, offset, offset + str.length, isInserted, false));
 }
 
 function* removeTextFromInput(browser, id, value, start, end) {
   let onTextRemoved = waitForEvent(EVENT_TEXT_REMOVED, id);
   // Select text and delete it.
-  yield ContentTask.spawn(browser, { id, start, end }, ({ id, start, end }) => {
-    let el = content.document.getElementById(id);
+  yield ContentTask.spawn(browser, [id, start, end], ([contentId, contentStart, contentEnd]) => {
+    let el = content.document.getElementById(contentId);
     el.focus();
-    el.setSelectionRange(start, end);
+    el.setSelectionRange(contentStart, contentEnd);
   });
   yield BrowserTestUtils.sendChar('VK_DELETE', browser);
 
   let event = yield onTextRemoved;
   checkTextChangeEvent(event, id, value, start, end, false, true);
 }
 
 /**
--- a/accessible/tests/browser/e10s/browser_treeupdate_ariadialog.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_ariadialog.js
@@ -13,18 +13,19 @@ loadScripts({ name: 'role.js', dir: MOCH
 addAccessibleTask('doc_treeupdate_ariadialog.html', function*(browser, accDoc) {
   testAccessibleTree(accDoc, {
     role: ROLE_DOCUMENT,
     children: [ ]
   });
 
   // Make dialog visible and update its inner content.
   let onShow = waitForEvent(EVENT_SHOW, 'dialog');
-  yield ContentTask.spawn(browser, {}, () =>
-    content.document.getElementById('dialog').style.display = 'block');
+  yield ContentTask.spawn(browser, {}, () => {
+    content.document.getElementById('dialog').style.display = 'block';
+  });
   yield onShow;
 
   testAccessibleTree(accDoc, {
     role: ROLE_DOCUMENT,
     children: [
       {
         role: ROLE_DIALOG,
         children: [
--- a/accessible/tests/browser/e10s/browser_treeupdate_ariaowns.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_ariaowns.js
@@ -88,21 +88,21 @@ function* testContainer1(browser, accDoc
       { SECTION: [ ] }, // subdiv from the subtree, t1_subdiv
       { GROUPING: [ ] } // group from outside, t1_group
     ]
   };
   testAccessibleTree(acc, tree);
 
   /* ================ Append element ======================================== */
   onReorder = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     let div = content.document.createElement('div');
     div.setAttribute('id', 't1_child3');
     div.setAttribute('role', 'radio');
-    content.document.getElementById(id).appendChild(div);
+    content.document.getElementById(contentId).appendChild(div);
   });
   yield onReorder;
 
   // children are invalidated, they includes aria-owns swapped kids and
   // newly inserted child.
   tree = {
     SECTION: [
       { CHECKBUTTON: [ ] }, // existing explicit, t1_checkbox
@@ -289,19 +289,20 @@ function* removeNotARIAOwnedEl(browser, 
     SECTION: [
       { TEXT_LEAF: [ ] },
       { GROUPING: [ ] }
     ]
   };
   testAccessibleTree(acc, tree);
 
   let onReorder = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id =>
-    content.document.getElementById(id).removeChild(
-      content.document.getElementById('t6_span')));
+  yield ContentTask.spawn(browser, id, contentId => {
+    content.document.getElementById(contentId).removeChild(
+      content.document.getElementById('t6_span'));
+  });
   yield onReorder;
 
   tree = {
     SECTION: [
       { GROUPING: [ ] }
     ]
   };
   testAccessibleTree(acc, tree);
--- a/accessible/tests/browser/e10s/browser_treeupdate_doc.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_doc.js
@@ -29,22 +29,22 @@ addAccessibleTask(`
   let tree = {
     role: ROLE_DOCUMENT,
     children: [ ]
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Write iframe document ================================ */
   let reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     let docNode = content.document.getElementById('iframe').contentDocument;
     let newHTMLNode = docNode.createElement('html');
     let newBodyNode = docNode.createElement('body');
     let newTextNode = docNode.createTextNode('New Wave');
-    newBodyNode.id = id;
+    newBodyNode.id = contentId;
     newBodyNode.appendChild(newTextNode);
     newHTMLNode.appendChild(newBodyNode);
     docNode.replaceChild(newHTMLNode, docNode.documentElement);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_DOCUMENT,
@@ -54,24 +54,24 @@ addAccessibleTask(`
         name: 'New Wave'
       }
     ]
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Replace iframe HTML element ========================== */
   reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     let docNode = content.document.getElementById('iframe').contentDocument;
     // We can't use open/write/close outside of iframe document because of
     // security error.
     let script = docNode.createElement('script');
     script.textContent = `
       document.open();
-      document.write('<body id="${id}">hello</body>');
+      document.write('<body id="${contentId}">hello</body>');
       document.close();`;
     docNode.body.appendChild(script);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_DOCUMENT,
     children: [
@@ -80,21 +80,21 @@ addAccessibleTask(`
         name: 'hello'
       }
     ]
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Replace iframe body ================================== */
   reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     let docNode = content.document.getElementById('iframe').contentDocument;
     let newBodyNode = docNode.createElement('body');
     let newTextNode = docNode.createTextNode('New Hello');
-    newBodyNode.id = id;
+    newBodyNode.id = contentId;
     newBodyNode.appendChild(newTextNode);
     newBodyNode.setAttribute('role', 'button');
     docNode.documentElement.replaceChild(newBodyNode, docNode.body);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_PUSHBUTTON,
@@ -104,28 +104,28 @@ addAccessibleTask(`
         name: 'New Hello'
       }
     ]
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Open iframe document ================================= */
   reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     // Open document.
     let docNode = content.document.getElementById('iframe').contentDocument;
     let script = docNode.createElement('script');
     script.textContent = `
       function closeMe() {
         document.write('Works?');
         document.close();
       }
       window.closeMe = closeMe;
       document.open();
-      document.write('<body id="${id}"></body>');`;
+      document.write('<body id="${contentId}"></body>');`;
     docNode.body.appendChild(script);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_DOCUMENT,
     children: [ ]
   };
@@ -166,24 +166,24 @@ addAccessibleTask(`
   tree = {
     role: ROLE_DOCUMENT,
     children: [ ]
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Insert HTML to iframe document ======================= */
   reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     // Insert HTML element.
     let docNode = content.document.getElementById('iframe').contentDocument;
     let html = docNode.createElement('html');
     let body = docNode.createElement('body');
     let text = docNode.createTextNode('Haha');
     body.appendChild(text);
-    body.id = id;
+    body.id = contentId;
     html.appendChild(body);
     docNode.appendChild(html);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_DOCUMENT,
     children: [
@@ -242,24 +242,24 @@ addAccessibleTask(`
   tree = {
     role: ROLE_DOCUMENT,
     children: [ ]
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Insert body to iframe document ======================= */
   reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     // Write and close document.
     let docNode = content.document.getElementById('iframe').contentDocument;
     // Insert body element.
     let body = docNode.createElement('body');
     let text = docNode.createTextNode('Yo ho ho i butylka roma!');
     body.appendChild(text);
-    body.id = id;
+    body.id = contentId;
     docNode.documentElement.appendChild(body);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_DOCUMENT,
     children: [
       {
@@ -283,23 +283,23 @@ addAccessibleTask(`
       ] }
     ]
   };
   testAccessibleTree(event.accessible, tree);
   iframe = findAccessibleChildByID(event.accessible, id);
 
   /* ================= Replace iframe body on ARIA role body ================ */
   reorderEventPromise = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     let docNode = content.document.getElementById('iframe').contentDocument;
     let newBodyNode = docNode.createElement('body');
     let newTextNode = docNode.createTextNode('New Hello');
     newBodyNode.appendChild(newTextNode);
     newBodyNode.setAttribute('role', 'button');
-    newBodyNode.id = id;
+    newBodyNode.id = contentId;
     docNode.documentElement.replaceChild(newBodyNode, docNode.body);
   });
   yield reorderEventPromise;
 
   tree = {
     role: ROLE_PUSHBUTTON,
     children: [
       {
--- a/accessible/tests/browser/e10s/browser_treeupdate_imagemap.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_imagemap.js
@@ -127,31 +127,31 @@ function* testContainer(browser) {
     SECTION: [
       { GRAPHIC: [ ] }
     ]
   };
   testAccessibleTree(acc, tree);
 
   /* ================= Insert map =========================================== */
   onReorder = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id => {
+  yield ContentTask.spawn(browser, id, contentId => {
     let map = content.document.createElement('map');
     let area = content.document.createElement('area');
 
     map.setAttribute('name', 'atoz_map');
     map.setAttribute('id', 'map');
 
     area.setAttribute('href',
                       'http://www.bbc.co.uk/radio4/atoz/index.shtml#b');
     area.setAttribute('coords', '17,0,30,14');
     area.setAttribute('alt', 'b');
     area.setAttribute('shape', 'rect');
 
     map.appendChild(area);
-    content.document.getElementById(id).appendChild(map);
+    content.document.getElementById(contentId).appendChild(map);
   });
   yield onReorder;
 
   tree = {
     SECTION: [ {
       IMAGE_MAP: [
         { LINK: [ ] }
       ]
--- a/accessible/tests/browser/e10s/browser_treeupdate_optgroup.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_optgroup.js
@@ -10,32 +10,32 @@ loadScripts({ name: 'role.js', dir: MOCH
 
 addAccessibleTask('<select id="select"></select>', function*(browser, accDoc) {
   let select = findAccessibleChildByID(accDoc, 'select');
 
   let onEvent = waitForEvent(EVENT_REORDER, 'select');
   // Create a combobox with grouping and 2 standalone options
   yield ContentTask.spawn(browser, {}, () => {
     let doc = content.document;
-    let select = doc.getElementById('select');
+    let contentSelect = doc.getElementById('select');
     let optGroup = doc.createElement('optgroup');
 
     for (let i = 0; i < 2; i++) {
       let opt = doc.createElement('option');
       opt.value = i;
       opt.text = 'Option: Value ' + i;
       optGroup.appendChild(opt);
     }
-    select.add(optGroup, null);
+    contentSelect.add(optGroup, null);
 
     for (let i = 0; i < 2; i++) {
       let opt = doc.createElement('option');
-      select.add(opt, null);
+      contentSelect.add(opt, null);
     }
-    select.firstChild.firstChild.id = 'option1Node';
+    contentSelect.firstChild.firstChild.id = 'option1Node';
   });
   let event = yield onEvent;
   let option1Node = findAccessibleChildByID(event.accessible, 'option1Node');
 
   let tree = {
     COMBOBOX: [ {
       COMBOBOX_LIST: [ {
         GROUPING: [
@@ -50,18 +50,18 @@ addAccessibleTask('<select id="select"><
     } ]
   };
   testAccessibleTree(select, tree);
   ok(!isDefunct(option1Node), 'option shouldn\'t be defunct');
 
   onEvent = waitForEvent(EVENT_REORDER, 'select');
   // Remove grouping from combobox
   yield ContentTask.spawn(browser, {}, () => {
-    let select = content.document.getElementById('select');
-    select.removeChild(select.firstChild);
+    let contentSelect = content.document.getElementById('select');
+    contentSelect.removeChild(contentSelect.firstChild);
   });
   yield onEvent;
 
   tree = {
     COMBOBOX: [ {
       COMBOBOX_LIST: [
         { COMBOBOX_OPTION: [] },
         { COMBOBOX_OPTION: [] }
@@ -70,19 +70,19 @@ addAccessibleTask('<select id="select"><
   };
   testAccessibleTree(select, tree);
   ok(isDefunct(option1Node),
     'removed option shouldn\'t be accessible anymore!');
 
   onEvent = waitForEvent(EVENT_REORDER, 'select');
   // Remove all options from combobox
   yield ContentTask.spawn(browser, {}, () => {
-    let select = content.document.getElementById('select');
-    while (select.length) {
-      select.remove(0);
+    let contentSelect = content.document.getElementById('select');
+    while (contentSelect.length) {
+      contentSelect.remove(0);
     }
   });
   yield onEvent;
 
   tree = {
     COMBOBOX: [ {
       COMBOBOX_LIST: [ ]
     } ]
--- a/accessible/tests/browser/e10s/browser_treeupdate_textleaf.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_textleaf.js
@@ -11,18 +11,19 @@ loadScripts({ name: 'role.js', dir: MOCH
 function* removeTextData(browser, accessible, id, role) {
   let tree = {
     role: role,
     children: [ { role: ROLE_TEXT_LEAF, name: "text" } ]
   };
   testAccessibleTree(accessible, tree);
 
   let onReorder = waitForEvent(EVENT_REORDER, id);
-  yield ContentTask.spawn(browser, id, id =>
-    content.document.getElementById(id).firstChild.textContent = '');
+  yield ContentTask.spawn(browser, id, contentId => {
+    content.document.getElementById(contentId).firstChild.textContent = '';
+  });
   yield onReorder;
 
   tree = { role: role, children: [] };
   testAccessibleTree(accessible, tree);
 }
 
 addAccessibleTask(`
   <p id="p">text</p>
--- a/accessible/tests/browser/shared-head.js
+++ b/accessible/tests/browser/shared-head.js
@@ -109,23 +109,23 @@ function isDefunct(accessible) {
  * @return {Promise}          promise indicating that attribute is set/removed
  */
 function invokeSetAttribute(browser, id, attr, value) {
   if (value) {
     Logger.log(`Setting ${attr} attribute to ${value} for node with id: ${id}`);
   } else {
     Logger.log(`Removing ${attr} attribute from node with id: ${id}`);
   }
-  return ContentTask.spawn(browser, { id, attr, value },
-    ({ id, attr, value }) => {
-      let elm = content.document.getElementById(id);
-      if (value) {
-        elm.setAttribute(attr, value);
+  return ContentTask.spawn(browser, [id, attr, value],
+    ([contentId, contentAttr, contentValue]) => {
+      let elm = content.document.getElementById(contentId);
+      if (contentValue) {
+        elm.setAttribute(contentAttr, contentValue);
       } else {
-        elm.removeAttribute(attr);
+        elm.removeAttribute(contentAttr);
       }
     });
 }
 
 /**
  * Asynchronously set or remove content element's style (in content process if
  * e10s is enabled).
  * @param  {Object}  browser  current "tabbrowser" element
@@ -136,38 +136,38 @@ function invokeSetAttribute(browser, id,
  * @return {Promise}          promise indicating that style is set/removed
  */
 function invokeSetStyle(browser, id, style, value) {
   if (value) {
     Logger.log(`Setting ${style} style to ${value} for node with id: ${id}`);
   } else {
     Logger.log(`Removing ${style} style from node with id: ${id}`);
   }
-  return ContentTask.spawn(browser, { id, style, value },
-    ({ id, style, value }) => {
-      let elm = content.document.getElementById(id);
-      if (value) {
-        elm.style[style] = value;
+  return ContentTask.spawn(browser, [id, style, value],
+    ([contentId, contentStyle, contentValue]) => {
+      let elm = content.document.getElementById(contentId);
+      if (contentValue) {
+        elm.style[contentStyle] = contentValue;
       } else {
-        delete elm.style[style];
+        delete elm.style[contentStyle];
       }
     });
 }
 
 /**
  * Asynchronously set focus on a content element (in content process if e10s is
  * enabled).
  * @param  {Object}  browser  current "tabbrowser" element
  * @param  {String}  id       content element id
  * @return {Promise} promise  indicating that focus is set
  */
 function invokeFocus(browser, id) {
   Logger.log(`Setting focus on a node with id: ${id}`);
-  return ContentTask.spawn(browser, id, id => {
-    let elm = content.document.getElementById(id);
+  return ContentTask.spawn(browser, id, contentId => {
+    let elm = content.document.getElementById(contentId);
     if (elm instanceof Ci.nsIDOMNSEditableElement && elm.editor ||
         elm instanceof Ci.nsIDOMXULTextBoxElement) {
       elm.selectionStart = elm.selectionEnd = elm.value.length;
     }
     elm.focus();
   });
 }