Bug 1020948 - Ensure fetching script sources when DebuggerObject.source fails. r=past
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 26 Jun 2014 06:39:00 +0200
changeset 191171 ccbe51e7e5412433240d8be8dddaf67e881386df
parent 191170 9ea6813cf5cca68c0a8aa88bd4541b2b61aae8f5
child 191172 25e196a33884d1c5a39739ac92e258e20ad701d0
push id8436
push usercbook@mozilla.com
push dateFri, 27 Jun 2014 13:56:57 +0000
treeherderb2g-inbound@22ea396750e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1020948
milestone33.0a1
Bug 1020948 - Ensure fetching script sources when DebuggerObject.source fails. r=past
toolkit/devtools/server/actors/script.js
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -34,17 +34,18 @@ let addonManager = null;
 
 /**
  * This is a wrapper around amIAddonManager.mapURIToAddonID which always returns
  * false on B2G to avoid loading the add-on manager there and reports any
  * exceptions rather than throwing so that the caller doesn't have to worry
  * about them.
  */
 function mapURIToAddonID(uri, id) {
-  if ((Services.appinfo.ID || undefined) == B2G_ID) {
+  if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT ||
+      (Services.appinfo.ID || undefined) == B2G_ID) {
     return false;
   }
 
   if (!addonManager) {
     addonManager = Cc["@mozilla.org/addons/integration;1"].
                    getService(Ci.amIAddonManager);
   }
 
@@ -5053,17 +5054,23 @@ ThreadSources.prototype = {
     // conservative and only use Debugger.Source.prototype.text if we get a
     // normal .js file.
     if (aScript.url) {
       try {
         const url = Services.io.newURI(aScript.url, null, null)
           .QueryInterface(Ci.nsIURL);
         if (url.fileExtension === "js") {
           spec.contentType = "text/javascript";
-          spec.text = aScript.source.text;
+          // If the Debugger API wasn't able to load the source,
+          // because sources were discarded
+          // (javascript.options.discardSystemSource == true),
+          // give source() a chance to fetch them.
+          if (aScript.source.text != "[no source]") {
+            spec.text = aScript.source.text;
+          }
         }
       } catch(ex) {
         // Not a valid URI.
       }
     }
 
     return this.source(spec);
   },