DELETE: 1 patches - 939636-browser
authorNikhil Marathe <nsm.nikhil@gmail.com>
Wed, 23 Jul 2014 17:33:38 -0700
changeset 1114 82d7962b2e2891dac83099c833b67b46878fb460
parent 1113 167eeaee89df77e7d3d396dddbce870b9b35ba71
child 1115 1fe757dfd53e1355931e584bd047388fd8e4a9d2
push id32
push usernsm.nikhil@gmail.com
push dateThu, 24 Jul 2014 00:32:46 +0000
bugs939636
DELETE: 1 patches - 939636-browser DELETE: 939636-browser qparent: 666e5e6b3abf qtip: 666e5e6b3abf top: (none)
939636-browser
series
deleted file mode 100644
--- a/939636-browser
+++ /dev/null
@@ -1,553 +0,0 @@
-# HG changeset patch
-# Parent 6ac21e2b4eb2f5097e5ecc13c97c80413c632aa2
-# User Nikhil Marathe <nsm.nikhil@gmail.com>
-Bug 939636 - DOM Promise conversion in browser/ r=?
-
-diff --git a/browser/base/content/newtab/newTab.js b/browser/base/content/newtab/newTab.js
---- a/browser/base/content/newtab/newTab.js
-+++ b/browser/base/content/newtab/newTab.js
-@@ -7,17 +7,17 @@
- let Cu = Components.utils;
- let Ci = Components.interfaces;
- 
- Cu.import("resource://gre/modules/XPCOMUtils.jsm");
- Cu.import("resource://gre/modules/Services.jsm");
- Cu.import("resource://gre/modules/PageThumbs.jsm");
- Cu.import("resource://gre/modules/BackgroundPageThumbs.jsm");
- Cu.import("resource://gre/modules/NewTabUtils.jsm");
--Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
-+Cu.importGlobalProperties(['Promise']);
- 
- XPCOMUtils.defineLazyModuleGetter(this, "Rect",
-   "resource://gre/modules/Geometry.jsm");
- XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
-   "resource://gre/modules/PrivateBrowsingUtils.jsm");
- 
- let {
-   links: gLinks,
-diff --git a/browser/base/content/newtab/transformations.js b/browser/base/content/newtab/transformations.js
---- a/browser/base/content/newtab/transformations.js
-+++ b/browser/base/content/newtab/transformations.js
-@@ -174,33 +174,31 @@ let gTransformation = {
-     let callback = aOptions && aOptions.callback;
-     let unfreeze = aOptions && aOptions.unfreeze;
- 
-     aSites.forEach(function (aSite, aIndex) {
-       // Do not re-arrange empty cells or the dragged site.
-       if (!aSite || aSite == gDrag.draggedSite)
-         return;
- 
--      let deferred = Promise.defer();
--      batch.push(deferred.promise);
--      let cb = function () deferred.resolve();
--
--      if (!cells[aIndex])
--        // The site disappeared from the grid, hide it.
--        this.hideSite(aSite, cb);
--      else if (this._getNodeOpacity(aSite.node) != 1)
--        // The site disappeared before but is now back, show it.
--        this.showSite(aSite, cb);
--      else
--        // The site's position has changed, move it around.
--        this._moveSite(aSite, aIndex, {unfreeze: unfreeze, callback: cb});
-+      let self = this;
-+      batch.push(new Promise(function(resolve) {
-+        if (!cells[aIndex])
-+          // The site disappeared from the grid, hide it.
-+          self.hideSite(aSite, resolve);
-+        else if (self._getNodeOpacity(aSite.node) != 1)
-+          // The site disappeared before but is now back, show it.
-+          self.showSite(aSite, resolve);
-+        else
-+          // The site's position has changed, move it around.
-+          self._moveSite(aSite, aIndex, {unfreeze: unfreeze, callback: resolve});
-+      }));
-     }, this);
- 
--    let wait = Promise.promised(function () callback && callback());
--    wait.apply(null, batch);
-+    Promise.all(batch).then(function() callback && callback());
-   },
- 
-   /**
-    * Listens for the 'transitionend' event on a given node and calls the given
-    * callback.
-    * @param aNode The node that is transitioned.
-    * @param aProperties The properties we'll wait to be transitioned.
-    * @param aCallback The callback to call when finished.
-diff --git a/browser/base/content/newtab/updater.js b/browser/base/content/newtab/updater.js
---- a/browser/base/content/newtab/updater.js
-+++ b/browser/base/content/newtab/updater.js
-@@ -129,58 +129,55 @@ let gUpdater = {
-     let batch = [];
- 
-     // Delete sites that were removed from the grid.
-     gGrid.sites.forEach(function (aSite) {
-       // The site must be valid and not in the current grid.
-       if (!aSite || aSites.indexOf(aSite) != -1)
-         return;
- 
--      let deferred = Promise.defer();
--      batch.push(deferred.promise);
-+      batch.push(new Promise(function(resolve) {
-+        // Fade out the to-be-removed site.
-+        gTransformation.hideSite(aSite, function () {
-+          let node = aSite.node;
- 
--      // Fade out the to-be-removed site.
--      gTransformation.hideSite(aSite, function () {
--        let node = aSite.node;
--
--        // Remove the site from the DOM.
--        node.parentNode.removeChild(node);
--        deferred.resolve();
--      });
-+          // Remove the site from the DOM.
-+          node.parentNode.removeChild(node);
-+          resolve();
-+        });
-+      }));
-     });
- 
--    let wait = Promise.promised(aCallback);
--    wait.apply(null, batch);
-+    Promise.all(batch).then(aCallback);
-   },
- 
-   /**
-    * Tries to fill empty cells with new links if available.
-    * @param aLinks The array of links.
-    * @param aCallback The callback to call when finished.
-    */
-   _fillEmptyCells: function Updater_fillEmptyCells(aLinks, aCallback) {
-     let {cells, sites} = gGrid;
-     let batch = [];
- 
-     // Find empty cells and fill them.
-     sites.forEach(function (aSite, aIndex) {
-       if (aSite || !aLinks[aIndex])
-         return;
- 
--      let deferred = Promise.defer();
--      batch.push(deferred.promise);
--
-       // Create the new site and fade it in.
-       let site = gGrid.createSite(aLinks[aIndex], cells[aIndex]);
- 
-       // Set the site's initial opacity to zero.
-       site.node.style.opacity = 0;
- 
-       // Flush all style changes for the dynamically inserted site to make
-       // the fade-in transition work.
-       window.getComputedStyle(site.node).opacity;
--      gTransformation.showSite(site, function () deferred.resolve());
-+
-+      batch.push(new Promise(function(resolve) {
-+        gTransformation.showSite(site, resolve);
-+      }));
-     });
- 
--    let wait = Promise.promised(aCallback);
--    wait.apply(null, batch);
-+    Promise.all(batch).then(aCallback);
-   }
- };
-diff --git a/browser/base/content/test/chrome/test_aboutCrashed.xul b/browser/base/content/test/chrome/test_aboutCrashed.xul
---- a/browser/base/content/test/chrome/test_aboutCrashed.xul
-+++ b/browser/base/content/test/chrome/test_aboutCrashed.xul
-@@ -12,47 +12,50 @@
-   <iframe type="content" id="frame1"/>
-   <iframe type="content" id="frame2" onload="doTest()"/>
-   <script type="application/javascript"><![CDATA[
-     const Ci = Components.interfaces;
-     const Cu = Components.utils;
- 
-     Cu.import("resource://gre/modules/Services.jsm");
-     Cu.import("resource://gre/modules/Task.jsm");
--    Cu.import("resource://gre/modules/Promise.jsm");
-     Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-+    Cu.importGlobalProperties(["Promise"]);
- 
-     SimpleTest.waitForExplicitFinish();
- 
-     // Load error pages do not fire "load" events, so let's use a progressListener.
-     function waitForErrorPage(frame) {
--      let errorPageDeferred = Promise.defer();
-+      // Breaking the Promise encapsulation, but I couldn't think of a cleaner way.
-+      let resolveFunc;
- 
-       let progressListener = {
-         onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
-           if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
-             frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIWebProgress)
-                           .removeProgressListener(progressListener,
-                                                   Ci.nsIWebProgress.NOTIFY_LOCATION);
- 
--            errorPageDeferred.resolve();
-+            resolveFunc();
-           }
-         },
- 
-         QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
-                                                Ci.nsISupportsWeakReference])
-       };
- 
-       frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
-                     .getInterface(Ci.nsIWebProgress)
-                     .addProgressListener(progressListener,
-                                          Ci.nsIWebProgress.NOTIFY_LOCATION);
- 
--      return errorPageDeferred.promise;
-+      return new Promise(function(resolve) {
-+        resolveFunc = resolve;
-+      });
-     }
- 
-   function doTest() {
-     Task.spawn(function test_aboutCrashed() {
-       let frame1 = document.getElementById("frame1");
-       let frame2 = document.getElementById("frame2");
-       let uri1 = Services.io.newURI("http://www.example.com/1", null, null);
-       let uri2 = Services.io.newURI("http://www.example.com/2", null, null);
-diff --git a/browser/base/content/test/general/browser_aboutHome.js b/browser/base/content/test/general/browser_aboutHome.js
---- a/browser/base/content/test/general/browser_aboutHome.js
-+++ b/browser/base/content/test/general/browser_aboutHome.js
-@@ -1,18 +1,17 @@
- /* Any copyright is dedicated to the Public Domain.
-  * http://creativecommons.org/publicdomain/zero/1.0/
-  */
- 
--XPCOMUtils.defineLazyModuleGetter(this, "Promise",
--  "resource://gre/modules/commonjs/sdk/core/promise.js");
- XPCOMUtils.defineLazyModuleGetter(this, "Task",
-   "resource://gre/modules/Task.jsm");
- XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils",
-   "resource:///modules/AboutHome.jsm");
-+Components.utils.importGlobalProperties(["Promise"]);
- 
- let gRightsVersion = Services.prefs.getIntPref("browser.rights.version");
- 
- registerCleanupFunction(function() {
-   // Ensure we don't pollute prefs for next tests.
-   Services.prefs.clearUserPref("network.cookies.cookieBehavior");
-   Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
-   Services.prefs.clearUserPref("browser.rights.override");
-@@ -98,46 +97,45 @@ let gTests = [
-       let cm = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
-       cm.getCategoryEntry("healthreport-js-provider-default", "SearchesProvider");
-     } catch (ex) {
-       // Health Report disabled, or no SearchesProvider.
-       return Promise.resolve();
-     }
- 
-     let numSearchesBefore = 0;
--    let deferred = Promise.defer();
-     let doc = gBrowser.contentDocument;
-     let engineName = doc.documentElement.getAttribute("searchEngineName");
- 
--    doc.addEventListener("AboutHomeSearchEvent", function onSearch(e) {
--      let data = JSON.parse(e.detail);
--      is(data.engineName, engineName, "Detail is search engine name");
--
--      // We use executeSoon() to ensure that this code runs after the
--      // count has been updated in browser.js, since it uses the same
--      // event.
--      executeSoon(function () {
--        getNumberOfSearches(engineName).then(num => {
--          is(num, numSearchesBefore + 1, "One more search recorded.");
--          deferred.resolve();
--        });
--      });
--    }, true, true);
--
-     // Get the current number of recorded searches.
-     getNumberOfSearches(engineName).then(num => {
-       numSearchesBefore = num;
- 
-       info("Perform a search.");
-       doc.getElementById("searchText").value = "a search";
-       doc.getElementById("searchSubmit").click();
-       gBrowser.stop();
-     });
- 
--    return deferred.promise;
-+    return new Promise(function(resolve) {
-+      doc.addEventListener("AboutHomeSearchEvent", function onSearch(e) {
-+        let data = JSON.parse(e.detail);
-+        is(data.engineName, engineName, "Detail is search engine name");
-+
-+        // We use executeSoon() to ensure that this code runs after the
-+        // count has been updated in browser.js, since it uses the same
-+        // event.
-+        executeSoon(function () {
-+          getNumberOfSearches(engineName).then(num => {
-+            is(num, numSearchesBefore + 1, "One more search recorded.");
-+            resolve();
-+          });
-+        });
-+      }, true, true);
-+    });
-   }
- },
- 
- {
-   desc: "Check snippets map is cleared if cached version is old",
-   setup: function (aSnippetsMap)
-   {
-     aSnippetsMap.set("snippets", "test");
-@@ -238,44 +236,42 @@ let gTests = [
-         is(logoElt.alt, engineName, "Alt text of logo image should match search engine name")
-       } else {
-         is(searchText.placeholder, engineName, "Placeholder text should match search engine name");
-       }
-     }
-     // Do a sanity check that all attributes are correctly set to begin with
-     checkSearchUI(currEngine);
- 
--    let deferred = Promise.defer();
--    promiseBrowserAttributes(gBrowser.selectedTab).then(function() {
--      // Test if the update propagated
--      checkSearchUI(unusedEngines[0]);
--      searchbar.currentEngine = currEngine;
--      deferred.resolve();
--    });
--
-     // The following cleanup function will set currentEngine back to the previous
-     // engine if we fail to do so above.
-     registerCleanupFunction(function() {
-       searchbar.currentEngine = currEngine;
-     });
-+
-     // Set the current search engine to an unused one
-     searchbar.currentEngine = unusedEngines[0];
-     searchbar.select();
--    return deferred.promise;
-+
-+    return promiseBrowserAttributes(gBrowser.selectedTab).then(function() {
-+      // Test if the update propagated
-+      checkSearchUI(unusedEngines[0]);
-+      searchbar.currentEngine = currEngine;
-+    });
-   }
- },
- 
- {
-   desc: "Check POST search engine support",
-   setup: function() {},
-   run: function()
-   {
-     let deferred = Promise.defer();
-     let currEngine = Services.search.defaultEngine;
--    let searchObserver = function search_observer(aSubject, aTopic, aData) {
-+    let searchObserver = function search_observer(resolve, aSubject, aTopic, aData) {
-       let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
-       info("Observer: " + aData + " for " + engine.name);
- 
-       if (aData != "engine-added")
-         return;
- 
-       if (engine.name != "POST Search")
-         return;
-@@ -309,26 +305,29 @@ let gTests = [
- 
- 
-       // When the search results load, check them for correctness.
-       waitForLoad(function() {
-         let loadedText = gBrowser.contentDocument.body.textContent;
-         ok(loadedText, "search page loaded");
-         is(loadedText, "searchterms=" + escape(needle.replace(/\s/g, "+")),
-            "Search text should arrive correctly");
--        deferred.resolve();
-+        resolve();
-       });
-     };
--    Services.obs.addObserver(searchObserver, "browser-search-engine-modified", false);
--    registerCleanupFunction(function () {
--      Services.obs.removeObserver(searchObserver, "browser-search-engine-modified");
-+
-+    return new Promise(function(resolve) {
-+      var resolverBoundSearchObserver = searchObserver.bind(null, resolve);
-+      Services.obs.addObserver(resolverBoundSearchObserver, "browser-search-engine-modified", false);
-+      registerCleanupFunction(function () {
-+        Services.obs.removeObserver(resolverBoundSearchObserver, "browser-search-engine-modified");
-+      });
-+      Services.search.addEngine("http://test:80/browser/browser/base/content/test/general/POSTSearchEngine.xml",
-+                                Ci.nsISearchEngine.DATA_XML, null, false);
-     });
--    Services.search.addEngine("http://test:80/browser/browser/base/content/test/general/POSTSearchEngine.xml",
--                              Ci.nsISearchEngine.DATA_XML, null, false);
--    return deferred.promise;
-   }
- }
- 
- ];
- 
- function test()
- {
-   waitForExplicitFinish();
-diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js
---- a/browser/base/content/test/newtab/head.js
-+++ b/browser/base/content/test/newtab/head.js
-@@ -1,22 +1,22 @@
- /* Any copyright is dedicated to the Public Domain.
-    http://creativecommons.org/publicdomain/zero/1.0/ */
- 
- const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
- 
- Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true);
- 
- let tmp = {};
--Cu.import("resource://gre/modules/Promise.jsm", tmp);
- Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp);
-+Cu.importGlobalProperties(["Promise"]);
- Cc["@mozilla.org/moz/jssubscript-loader;1"]
-   .getService(Ci.mozIJSSubScriptLoader)
-   .loadSubScript("chrome://browser/content/sanitize.js", tmp);
--let {Promise, NewTabUtils, Sanitizer} = tmp;
-+let {NewTabUtils, Sanitizer} = tmp;
- 
- let uri = Services.io.newURI("about:newtab", null, null);
- let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
- 
- let isMac = ("nsILocalFileMac" in Ci);
- let isLinux = ("@mozilla.org/gnome-gconf-service;1" in Cc);
- let isWindows = ("@mozilla.org/windows-registry-key;1" in Cc);
- let gWindow = window;
-@@ -388,32 +388,31 @@ function startAndCompleteDragOperation(a
-  * Helper function that creates a temporary iframe in the about:newtab
-  * document. This will contain a link we can drag to the test the dropping
-  * of links from external documents.
-  */
- function createExternalDropIframe() {
-   const url = "data:text/html;charset=utf-8," +
-               "<a id='link' href='http://example.com/%2399'>link</a>";
- 
--  let deferred = Promise.defer();
-   let doc = getContentDocument();
-   let iframe = doc.createElement("iframe");
-   iframe.setAttribute("src", url);
-   iframe.style.width = "50px";
-   iframe.style.height = "50px";
- 
-   let margin = doc.getElementById("newtab-margin-top");
-   margin.appendChild(iframe);
- 
--  iframe.addEventListener("load", function onLoad() {
--    iframe.removeEventListener("load", onLoad);
--    executeSoon(() => deferred.resolve(iframe));
-+  return new Promise(function(resolve) {
-+    iframe.addEventListener("load", function onLoad() {
-+      iframe.removeEventListener("load", onLoad);
-+      resolve(iframe);
-+    });
-   });
--
--  return deferred.promise;
- }
- 
- /**
-  * Fires a synthetic 'mousedown' event on the current about:newtab page.
-  * @param aElement The element used to determine the cursor position.
-  */
- function synthesizeNativeMouseLDown(aElement) {
-   if (isLinux) {
-diff --git a/browser/base/content/test/social/head.js b/browser/base/content/test/social/head.js
---- a/browser/base/content/test/social/head.js
-+++ b/browser/base/content/test/social/head.js
-@@ -1,20 +1,19 @@
- /* This Source Code Form is subject to the terms of the Mozilla Public
-  * License, v. 2.0. If a copy of the MPL was not distributed with this
-  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
- Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
- 
--XPCOMUtils.defineLazyModuleGetter(this, "Promise",
--  "resource://gre/modules/commonjs/sdk/core/promise.js");
- XPCOMUtils.defineLazyModuleGetter(this, "Task",
-   "resource://gre/modules/Task.jsm");
- XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
-   "resource://gre/modules/PlacesUtils.jsm");
-+Components.utils.importGlobalProperties(["Promise"]);
- 
- function waitForCondition(condition, nextTest, errorMsg) {
-   var tries = 0;
-   var interval = setInterval(function() {
-     if (tries >= 30) {
-       ok(false, errorMsg);
-       moveOn();
-     }
-@@ -31,23 +30,23 @@ function waitForCondition(condition, nex
-     tries++;
-   }, 100);
-   var moveOn = function() { clearInterval(interval); nextTest(); };
- }
- 
- // Check that a specified (string) URL hasn't been "remembered" (ie, is not
- // in history, will not appear in about:newtab or auto-complete, etc.)
- function promiseSocialUrlNotRemembered(url) {
--  let deferred = Promise.defer();
-   let uri = Services.io.newURI(url, null, null);
--  PlacesUtils.asyncHistory.isURIVisited(uri, function(aURI, aIsVisited) {
--    ok(!aIsVisited, "social URL " + url + " should not be in global history");
--    deferred.resolve();
-+  return new Promise(function(resolve) {
-+    PlacesUtils.asyncHistory.isURIVisited(uri, function(aURI, aIsVisited) {
-+      ok(!aIsVisited, "social URL " + url + " should not be in global history");
-+      resolve();
-+    });
-   });
--  return deferred.promise;
- }
- 
- let gURLsNotRemembered = [];
- 
- 
- function checkProviderPrefsEmpty(isError) {
-   let MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
-   let prefs = MANIFEST_PREFS.getChildList("", []);
-diff --git a/browser/components/sessionstore/src/SessionFile.jsm b/browser/components/sessionstore/src/SessionFile.jsm
---- a/browser/components/sessionstore/src/SessionFile.jsm
-+++ b/browser/components/sessionstore/src/SessionFile.jsm
-@@ -28,19 +28,20 @@ this.EXPORTED_SYMBOLS = ["SessionFile"];
- const Cu = Components.utils;
- const Cc = Components.classes;
- const Ci = Components.interfaces;
- 
- Cu.import("resource://gre/modules/Services.jsm");
- Cu.import("resource://gre/modules/XPCOMUtils.jsm");
- Cu.import("resource://gre/modules/osfile.jsm");
- Cu.import("resource://gre/modules/osfile/_PromiseWorker.jsm", this);
--Cu.import("resource://gre/modules/Promise.jsm");
- Cu.import("resource://gre/modules/AsyncShutdown.jsm");
- 
-+Cu.importGlobalProperties(['Promise']);
-+
- XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
-   "resource://gre/modules/TelemetryStopwatch.jsm");
- XPCOMUtils.defineLazyModuleGetter(this, "Task",
-   "resource://gre/modules/Task.jsm");
- XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
-   "@mozilla.org/base/telemetry;1", "nsITelemetry");
- 
- this.SessionFile = {
-@@ -217,18 +218,17 @@ let SessionFileInternal = {
- 
- // Interface to a dedicated thread handling I/O
- let SessionWorker = (function () {
-   let worker = new PromiseWorker("resource:///modules/sessionstore/SessionWorker.js",
-     OS.Shared.LOG.bind("SessionWorker"));
-   return {
-     post: function post(...args) {
-       let promise = worker.post.apply(worker, args);
--      return promise.then(
--        null,
-+      return promise.catch(
-         function onError(error) {
-           // Decode any serialized error
-           if (error instanceof PromiseWorker.WorkerError) {
-             throw OS.File.Error.fromMsg(error.data);
-           } else {
-             throw error;
-           }
-         }
--- a/series
+++ b/series
@@ -13,12 +13,11 @@ 903441-setup-request
 903441-intercepts
 903441-sw-nointercept
 foo
 898524-cache
 sw-install-tests2
 sw-more-install-tests
 943704-importscripts
 939636-toolkit
-939636-browser
 promise-nsresult
 984048-swutil-fetcher
 984048-swm-update+