Bug 1260386 - Global search in sources fails with two TypeErrors draft
authorJarda Snajdr <jsnajdr@gmail.com>
Tue, 29 Mar 2016 13:23:04 +0200
changeset 398526 fe53e7004d8fa0c51dc6655957dfbc2bd7fe781d
parent 398252 720b5d2c84d5b253d4dfde4897e13384dc97a46a
child 398527 1a979f1603ec752ab61ad4731fd25a8ea553a659
push id25563
push userbmo:jsnajdr@gmail.com
push dateTue, 09 Aug 2016 09:41:28 +0000
bugs1260386
milestone51.0a1
Bug 1260386 - Global search in sources fails with two TypeErrors
devtools/client/debugger/content/actions/sources.js
--- a/devtools/client/debugger/content/actions/sources.js
+++ b/devtools/client/debugger/content/actions/sources.js
@@ -164,16 +164,19 @@ function togglePrettyPrint(source) {
 }
 
 function loadSourceText(source) {
   return (dispatch, getState) => {
     // Fetch the source text only once.
     let textInfo = getSourceText(getState(), source.actor);
     if (textInfo) {
       // It's already loaded or is loading
+      if (textInfo.error) {
+        return promise.reject(textInfo.error);
+      }
       return promise.resolve(textInfo);
     }
 
     const sourceClient = getSourceClient(source);
 
     return dispatch({
       type: constants.LOAD_SOURCE_TEXT,
       source: source,
@@ -200,18 +203,18 @@ function loadSourceText(source) {
       })
     });
   };
 }
 
 /**
  * Starts fetching all the sources, silently.
  *
- * @param array aUrls
- *        The urls for the sources to fetch. If fetching a source's text
+ * @param array actors
+ *        The actors for the sources to fetch. If fetching a source's text
  *        takes too long, it will be discarded.
  * @return object
  *         A promise that is resolved after source texts have been fetched.
  */
 function getTextForSources(actors) {
   return (dispatch, getState) => {
     let deferred = promise.defer();
     let pending = new Set(actors);
@@ -247,18 +250,18 @@ function getTextForSources(actors) {
         return;
       }
       pending.delete(aSource.actor);
       fetched.push([aSource.actor, aText, aContentType]);
       maybeFinish();
     }
 
     /* Called if fetching a source failed because of an error. */
-    function onError([aSource, aError]) {
-      pending.delete(aSource.actor);
+    function onError(source, error) {
+      pending.delete(source.actor);
       maybeFinish();
     }
 
     /* Called every time something interesting happens while fetching sources. */
     function maybeFinish() {
       if (pending.size == 0) {
         // Sort the fetched sources alphabetically by their url.
         deferred.resolve(fetched.sort(([aFirst], [aSecond]) => aFirst > aSecond));