Bug 1209658 part 2. Add text/json and text/vtt as text MIME types. r=bkelly

This commit is contained in:
Boris Zbarsky 2015-10-05 12:23:26 -04:00
parent d41c82f00d
commit 233fb264ff
5 changed files with 43 additions and 1 deletions

View File

@ -3612,7 +3612,9 @@ nsContentUtils::IsPlainTextType(const nsACString& aContentType)
aContentType.EqualsLiteral(TEXT_ECMASCRIPT) ||
aContentType.EqualsLiteral(APPLICATION_ECMASCRIPT) ||
aContentType.EqualsLiteral(TEXT_JAVASCRIPT) ||
aContentType.EqualsLiteral(APPLICATION_JSON);
aContentType.EqualsLiteral(APPLICATION_JSON) ||
aContentType.EqualsLiteral(TEXT_JSON) ||
aContentType.EqualsLiteral(TEXT_VTT);
}
bool

View File

@ -73,6 +73,7 @@ NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
{ "Gecko-Content-Viewers", APPLICATION_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", APPLICATION_XJAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", APPLICATION_JSON, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", TEXT_JSON, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", APPLICATION_XHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", TEXT_XML, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", APPLICATION_XML, "@mozilla.org/content/document-loader-factory;1" }, \
@ -83,6 +84,7 @@ NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
{ "Gecko-Content-Viewers", VIEWSOURCE_CONTENT_TYPE, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", IMAGE_SVG_XML, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", APPLICATION_MATHML_XML, "@mozilla.org/content/document-loader-factory;1" }, \
{ "Gecko-Content-Viewers", TEXT_VTT, "@mozilla.org/content/document-loader-factory;1" }, \
CONTENTDLF_WEBM_CATEGORIES

View File

@ -137,8 +137,10 @@
#define TEXT_VCARD "text/vcard"
#define TEXT_CSS "text/css"
#define TEXT_JSSS "text/jsss"
#define TEXT_JSON "text/json"
#define TEXT_XML "text/xml"
#define TEXT_RDF "text/rdf"
#define TEXT_VTT "text/vtt"
#define TEXT_XUL "application/vnd.mozilla.xul+xml"
#define TEXT_ECMASCRIPT "text/ecmascript"
#define TEXT_JAVASCRIPT "text/javascript"

View File

@ -148,3 +148,4 @@ skip-if = toolkit == 'android' || e10s #TIMED_OUT
# file_bug568470-script.sjs
# Disable test due to frequent orange on Mac
# test_bug534293.html
[test_bug1209658.html]

View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1209658
-->
<head>
<title>Test for Bug 1209658</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1209658">Mozilla Bug 1209658</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
addLoadEvent(function loaded() {
for (var iframe of document.querySelectorAll("iframe")) {
is(iframe.contentWindow.location.href, iframe.src, "should load correct URL");
is(iframe.contentDocument.body.textContent, '{"<p>Hello</p>": null}',
iframe.getAttribute("mimeType") + " should be treated as text");
}
SimpleTest.finish();
});
</script>
<iframe src="data:text/json,{&quot;<p>Hello</p>&quot;:%20null}"
mimeType="text/json"></iframe>
<!-- Totally not valid VTT data, but doesn't matter for our purposes here -->
<iframe src="data:text/vtt,{&quot;<p>Hello</p>&quot;:%20null}"
mimeType="text/vtt"></iframe>
</body>
</html>