Bug 1338539: files with application/manifest+json Mime type should be rendered as json r=Honza

MozReview-Commit-ID: 9SXz6dO7Fms

--HG--
extra : rebase_source : 5c69d330e3ee346d7a3ecd563e684c8da3c589b8
This commit is contained in:
Pascal Chevrel 2017-02-22 15:33:39 +01:00
Родитель 15ef9bead3
Коммит 2a2d568974
5 изменённых файлов: 64 добавлений и 3 удалений

Просмотреть файл

@ -14,7 +14,7 @@ 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";
@ -62,9 +62,10 @@ Sniffer.prototype = {
// 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;
}
}

Просмотреть файл

@ -8,6 +8,8 @@ support-files =
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
@ -29,3 +31,4 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32
[browser_jsonview_invalid_json.js]
[browser_jsonview_valid_json.js]
[browser_jsonview_save_json.js]
[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");
});

Просмотреть файл

@ -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"
}]
}

Просмотреть файл

@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8