Bug 1414340 part 1 - Remove non-standard array/generator comprehensions from browser code. r=mossop
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 10 Nov 2017 11:52:22 +0100
changeset 444436 71e5015934c2e085a46575934d3de04ee7e57681
parent 444435 915df99dbfe737cfa9e1ee6b231100761e229191
child 444437 67fe0ac257b8a1169a208bf4c7f5c2369c3239ee
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1414340
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1414340 part 1 - Remove non-standard array/generator comprehensions from browser code. r=mossop
browser/base/content/newtab/grid.js
dom/animation/test/chrome/test_animation_observers_async.html
dom/base/test/chrome/bug418986-1.js
dom/manifest/test/browser_ManifestObtainer_obtain.js
testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js
--- a/browser/base/content/newtab/grid.js
+++ b/browser/base/content/newtab/grid.js
@@ -30,17 +30,17 @@ var gGrid = {
    * All cells contained in the grid.
    */
   _cells: [],
   get cells() { return this._cells; },
 
   /**
    * All sites contained in the grid's cells. Sites may be empty.
    */
-  get sites() { return [for (cell of this.cells) cell.site]; },
+  get sites() { return this.cells.map(cell => cell.site); },
 
   // Tells whether the grid has already been initialized.
   get ready() { return !!this._ready; },
 
   // Returns whether the page has finished loading yet.
   get isDocumentLoaded() { return document.readyState == "complete"; },
 
   /**
--- a/dom/animation/test/chrome/test_animation_observers_async.html
+++ b/dom/animation/test/chrome/test_animation_observers_async.html
@@ -1135,24 +1135,25 @@ addAsyncAnimTest("tree_ordering", { obse
 
   // Check all animations we have in this document
   var docAnims = document.getAnimations();
   is(docAnims.length, 10, "total animations");
 
   var divAnimations = div.getAnimations();
   var childAAnimations = childA.getAnimations();
   var childBAnimations = childB.getAnimations();
+
   var divBeforeAnimations =
-    [ for (x of docAnims) if (x.effect.target.parentElement == div &&
-                              x.effect.target.type == "::before") x ];
+    docAnims.filter(x => (x.effect.target.parentElement == div &&
+                          x.effect.target.type == "::before"));
   var divAfterAnimations =
-    [ for (x of docAnims) if (x.effect.target.parentElement == div &&
-                              x.effect.target.type == "::after") x ];
+    docAnims.filter(x => (x.effect.target.parentElement == div &&
+                          x.effect.target.type == "::after"));
   var childBPseudoAnimations =
-    [ for (x of docAnims) if (x.effect.target.parentElement == childB) x ];
+    docAnims.filter(x => x.effect.target.parentElement == childB);
 
   // The order in which we get the corresponding records is currently
   // based on the order we visit these nodes when updating styles.
   //
   // That is because we don't do any document-level batching of animation
   // mutation records when we flush styles. We may introduce that in the
   // future but for now all we are interested in testing here is that the
   // right records are generated, but we allow them to occur in any order.
--- a/dom/base/test/chrome/bug418986-1.js
+++ b/dom/base/test/chrome/bug418986-1.js
@@ -29,17 +29,17 @@ var test = function (isContent) {
   ];
 
   // checkPair: tests if members of pair [a, b] are equal when evaluated.
   let checkPair = function (a, b) {
     is(eval(a), eval(b), a + " should be equal to " + b);
   };
 
   // Returns generator object that iterates through pref values.
-  let prefVals = (for (prefVal of [false, true]) prefVal);
+  let prefVals = (function*() { yield false; yield true; })();
 
   // The main test function, runs until all pref values are exhausted.
   let nextTest = function () {
     let {value : prefValue, done} = prefVals.next();
     if (done) {
       SimpleTest.finish();
       return;
     }
--- a/dom/manifest/test/browser_ManifestObtainer_obtain.js
+++ b/dom/manifest/test/browser_ManifestObtainer_obtain.js
@@ -147,28 +147,31 @@ add_task(async function() {
     `http://test2.example.com:80${defaultPath}`,
     `http://test2.example.org:80${defaultPath}`,
     `http://test2.example.org:8000${defaultPath}`,
     `http://test2.mochi.test:8888${defaultPath}`,
     `http://test:80${defaultPath}`,
     `http://www.example.com:80${defaultPath}`,
   ];
   // Open tabs an collect corresponding browsers
-  let browsers = [
-    for (url of tabURLs) BrowserTestUtils.addTab(gBrowser, url).linkedBrowser
-  ];
+  let browsers = tabURLs.map(url => BrowserTestUtils.addTab(gBrowser, url).linkedBrowser);
+
   // Once all the pages have loaded, run a bunch of tests in "parallel".
-  await Promise.all((
-    for (browser of browsers) BrowserTestUtils.browserLoaded(browser)
-  ));
+  await Promise.all((function*() {
+    for (let browser of browsers) {
+      yield BrowserTestUtils.browserLoaded(browser);
+    }
+  })());
   // Flood random browsers with requests. Once promises settle, check that
   // responses all pass.
-  const results = await Promise.all((
-    for (browser of randBrowsers(browsers, 50)) ManifestObtainer.browserObtainManifest(browser)
-  ));
+  const results = await Promise.all((function*() {
+    for (let browser of randBrowsers(browsers, 50)) {
+      yield ManifestObtainer.browserObtainManifest(browser);
+    }
+  })());
   const pass = results.every(manifest => manifest.name === 'pass');
   ok(pass, 'Expect every manifest to have name equal to `pass`.');
   //cleanup
   browsers
     .map(browser => gBrowser.getTabForBrowser(browser))
     .forEach(tab => gBrowser.removeTab(tab));
 
   //Helper generator, spits out random browsers
--- a/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js
+++ b/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js
@@ -23,23 +23,24 @@ add_task(async function() {
 // promise.all().
 add_task(async function() {
   let tabURLs = [
     `http://example.org`,
     `http://mochi.test:8888`,
     `http://test:80`,
   ];
   //Add tabs, get the respective browsers
-  let browsers = [
-    for (u of tabURLs) BrowserTestUtils.addTab(gBrowser, u).linkedBrowser
-  ];
+  let browsers = tabURLs.map(u => BrowserTestUtils.addTab(gBrowser, u).linkedBrowser);
+
   //wait for promises to settle
-  await Promise.all((
-    for (b of browsers) BrowserTestUtils.browserLoaded(b)
-  ));
+  await Promise.all((function*() {
+    for (let b of browsers) {
+      yield BrowserTestUtils.browserLoaded(b);
+    }
+  })());
   let expected = 'Expected all promised browsers to have loaded.';
   for (const browser of browsers) {
     await isDOMLoaded(browser);
   }
   //cleanup
   browsers
     .map(browser => gBrowser.getTabForBrowser(browser))
     .forEach(tab => gBrowser.removeTab(tab));