Bug 1338539: files with application/manifest+json Mime type should be rendered as json r=Honza
authorPascal Chevrel <pascal.chevrel@free.fr>
Wed, 22 Feb 2017 15:33:39 +0100
changeset 394364 47ae8eb50ef42d3d67d7b6420ae4bd5728af2d69
parent 394363 6b64847df21632cb07da14fa4eab6de0851b14c8
child 394365 706398e37dbba13604d924820340e9ecb37b20b1
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1338539
milestone54.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 1338539: files with application/manifest+json Mime type should be rendered as json r=Honza MozReview-Commit-ID: 9SXz6dO7Fms
devtools/client/jsonview/converter-sniffer.js
devtools/client/jsonview/test/browser.ini
devtools/client/jsonview/test/browser_jsonview_manifest.js
devtools/client/jsonview/test/manifest_json.json
devtools/client/jsonview/test/manifest_json.json^headers^
--- a/devtools/client/jsonview/converter-sniffer.js
+++ b/devtools/client/jsonview/converter-sniffer.js
@@ -9,17 +9,17 @@
 const {Cc, Ci, Cu, Cm, Cr, components} = require("chrome");
 const registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
 const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
 
 const categoryManager = Cc["@mozilla.org/categorymanager;1"]
   .getService(Ci.nsICategoryManager);
 
 // Constants
-const JSON_TYPE = "application/json";
+const JSON_TYPES = ["application/json", "application/manifest+json"];
 const CONTRACT_ID = "@mozilla.org/devtools/jsonview-sniffer;1";
 const CLASS_ID = components.ID("{4148c488-dca1-49fc-a621-2a0097a62422}");
 const CLASS_DESCRIPTION = "JSONView content sniffer";
 const JSON_VIEW_MIME_TYPE = "application/vnd.mozilla.json.view";
 const JSON_VIEW_TYPE = "JSON View";
 const CONTENT_SNIFFER_CATEGORY = "net-content-sniffers";
 
 function isTopLevelLoad(request) {
@@ -57,19 +57,20 @@ Sniffer.prototype = {
         if (request.contentDisposition ==
           Ci.nsIChannel.DISPOSITION_ATTACHMENT) {
           return "";
         }
       } catch (e) {
         // Channel doesn't support content dispositions
       }
 
-      // Check the response content type and if it's application/json
+      // Check the response content type and if it's a valid type
+      // such as application/json or application/manifest+json
       // change it to new internal type consumed by JSON View.
-      if (request.contentType == JSON_TYPE) {
+      if (JSON_TYPES.includes(request.contentType)) {
         return JSON_VIEW_MIME_TYPE;
       }
     }
 
     return "";
   }
 };
 
--- a/devtools/client/jsonview/test/browser.ini
+++ b/devtools/client/jsonview/test/browser.ini
@@ -3,16 +3,18 @@ tags = devtools
 subsuite = devtools
 support-files =
   array_json.json
   array_json.json^headers^
   doc_frame_script.js
   head.js
   invalid_json.json
   invalid_json.json^headers^
+  manifest_json.json
+  manifest_json.json^headers^
   simple_json.json
   simple_json.json^headers^
   valid_json.json
   valid_json.json^headers^
   !/devtools/client/commandline/test/head.js
   !/devtools/client/framework/test/head.js
   !/devtools/client/framework/test/shared-head.js
 
@@ -24,8 +26,9 @@ subsuite = clipboard
 skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
 [browser_jsonview_copy_rawdata.js]
 subsuite = clipboard
 skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
 [browser_jsonview_filter.js]
 [browser_jsonview_invalid_json.js]
 [browser_jsonview_valid_json.js]
 [browser_jsonview_save_json.js]
+[browser_jsonview_manifest.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_manifest.js
@@ -0,0 +1,17 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "manifest_json.json";
+
+add_task(function* () {
+  info("Test manifest JSON file started");
+
+  yield addJsonViewTab(TEST_JSON_URL);
+
+  let count = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
+  is(count, 37, "There must be expected number of rows");
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/jsonview/test/manifest_json.json
@@ -0,0 +1,39 @@
+{
+  "name": "HackerWeb",
+  "short_name": "HackerWeb",
+  "start_url": ".",
+  "display": "standalone",
+  "background_color": "#fff",
+  "description": "A simply readable Hacker News app.",
+  "icons": [{
+    "src": "images/touch/homescreen48.png",
+    "sizes": "48x48",
+    "type": "image/png"
+  }, {
+    "src": "images/touch/homescreen72.png",
+    "sizes": "72x72",
+    "type": "image/png"
+  }, {
+    "src": "images/touch/homescreen96.png",
+    "sizes": "96x96",
+    "type": "image/png"
+  }, {
+    "src": "images/touch/homescreen144.png",
+    "sizes": "144x144",
+    "type": "image/png"
+  }, {
+    "src": "images/touch/homescreen168.png",
+    "sizes": "168x168",
+    "type": "image/png"
+  }, {
+    "src": "images/touch/homescreen192.png",
+    "sizes": "192x192",
+    "type": "image/png"
+  }],
+  "related_applications": [{
+    "platform": "web"
+  }, {
+    "platform": "play",
+    "url": "https://play.google.com/store/apps/details?id=cheeaun.hackerweb"
+  }]
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/jsonview/test/manifest_json.json^headers^
@@ -0,0 +1,1 @@
+Content-Type: application/manifest+json; charset=utf-8