Bug 1232014 - Give wasm Debugger.Sources the text/wasm mimetype and use their .text property. (r=ejpbruel)
authorShu-yu Guo <shu@rfrn.org>
Fri, 11 Mar 2016 21:43:21 -0800
changeset 339760 d89e927c2b7b3b9bd660f8be0a1245c46f64a696
parent 339759 bf4a26491ea5d81df36a1174d126bfe25d86903d
child 339761 ec2bed5822e5af65e700c1dfaf59c41bbe7eb5c6
push id12803
push userjbeich@FreeBSD.org
push dateSun, 13 Mar 2016 09:48:54 +0000
reviewersejpbruel
bugs1232014
milestone48.0a1
Bug 1232014 - Give wasm Debugger.Sources the text/wasm mimetype and use their .text property. (r=ejpbruel)
devtools/server/actors/source.js
devtools/server/actors/utils/TabSources.js
--- a/devtools/server/actors/source.js
+++ b/devtools/server/actors/source.js
@@ -319,26 +319,27 @@ let SourceActor = ActorClass({
             return toResolvedContent(sourceContent);
           }
         } catch (error) {
           this._reportLoadSourceError(error, map);
           throw error;
         }
       }
 
-      // Use `source.text` if it exists, is not the "no source"
-      // string, and the content type of the source is JavaScript. It
-      // will be "no source" if the Debugger API wasn't able to load
+      // Use `source.text` if it exists, is not the "no source" string, and
+      // the content type of the source is JavaScript or it is synthesized
+      // wasm. It will be "no source" if the Debugger API wasn't able to load
       // the source because sources were discarded
-      // (javascript.options.discardSystemSource == true). Re-fetch
-      // non-JS sources to get the contentType from the headers.
+      // (javascript.options.discardSystemSource == true). Re-fetch non-JS
+      // sources to get the contentType from the headers.
       if (this.source &&
           this.source.text !== "[no source]" &&
           this._contentType &&
-          this._contentType.indexOf('javascript') !== -1) {
+          (this._contentType.indexOf("javascript") !== -1 ||
+           this._contentType === "text/wasm")) {
         return toResolvedContent(this.source.text);
       }
       else {
         // Only load the HTML page source from cache (which exists when
         // there are inline sources). Otherwise, we can't trust the
         // cache because we are most likely here because we are
         // fetching the original text for sourcemapped code, and the
         // page hasn't requested it before (if it has, it was a
--- a/devtools/server/actors/utils/TabSources.js
+++ b/devtools/server/actors/utils/TabSources.js
@@ -294,16 +294,19 @@ TabSources.prototype = {
     // sources. Otherwise, use the `originalUrl` property to treat it
     // as an HTML source that manages multiple inline sources.
 
     // Assume the source is inline if the element that introduced it is not a
     // script element, or does not have a src attribute.
     let element = aSource.element ? aSource.element.unsafeDereference() : null;
     if (element && (element.tagName !== "SCRIPT" || !element.hasAttribute("src"))) {
       spec.isInlineSource = true;
+    } else if (aSource.introductionType === "wasm") {
+      // Wasm sources are not JavaScript. Give them their own content-type.
+      spec.contentType = "text/wasm";
     } else {
       if (url) {
         // There are a few special URLs that we know are JavaScript:
         // inline `javascript:` and code coming from the console
         if (url.indexOf("Scratchpad/") === 0 ||
             url.indexOf("javascript:") === 0 ||
             url === "debugger eval code") {
           spec.contentType = "text/javascript";