diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 18f4dbfb65a0..5de319c6f39c 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -4632,8 +4632,8 @@ bool nsContentUtils::IsChildOfSameType(Document* aDoc) { } bool nsContentUtils::IsPlainTextType(const nsACString& aContentType) { - // NOTE: if you add a type here, add it to the CONTENTDLF_CATEGORIES - // define in nsContentDLF.h as well. + // NOTE: if you add a type here, add it to the content_types array in + // layout/build/components.conf as well. return aContentType.EqualsLiteral(TEXT_PLAIN) || aContentType.EqualsLiteral(TEXT_CSS) || aContentType.EqualsLiteral(TEXT_CACHE_MANIFEST) || @@ -4644,7 +4644,8 @@ bool nsContentUtils::IsPlainTextType(const nsACString& aContentType) { aContentType.EqualsLiteral(APPLICATION_ECMASCRIPT) || aContentType.EqualsLiteral(TEXT_JAVASCRIPT) || aContentType.EqualsLiteral(APPLICATION_JSON) || - aContentType.EqualsLiteral(TEXT_JSON); + aContentType.EqualsLiteral(TEXT_JSON) || + aContentType.EqualsLiteral(TEXT_EVENT_STREAM); } bool nsContentUtils::IsUtf8OnlyPlainTextType(const nsACString& aContentType) { diff --git a/layout/build/components.conf b/layout/build/components.conf index 2df60e3a84da..ec9eb24aeb0f 100644 --- a/layout/build/components.conf +++ b/layout/build/components.conf @@ -28,6 +28,7 @@ content_types = [ 'text/cache-manifest', 'text/css', 'text/ecmascript', + 'text/event-stream', 'text/html', 'text/javascript', 'text/json', diff --git a/layout/build/nsContentDLF.h b/layout/build/nsContentDLF.h index b16ec7550368..4743f4ee877d 100644 --- a/layout/build/nsContentDLF.h +++ b/layout/build/nsContentDLF.h @@ -55,38 +55,4 @@ class nsContentDLF final : public nsIDocumentLoaderFactory { nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult); -// clang-format off -#ifdef MOZ_WEBM -#define CONTENTDLF_WEBM_CATEGORIES \ - { "Gecko-Content-Viewers", VIDEO_WEBM, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", AUDIO_WEBM, "@mozilla.org/content/document-loader-factory;1" }, -#else -#define CONTENTDLF_WEBM_CATEGORIES -#endif - -#define CONTENTDLF_CATEGORIES \ - { "Gecko-Content-Viewers", TEXT_HTML, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", TEXT_PLAIN, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", TEXT_CACHE_MANIFEST, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", TEXT_CSS, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", TEXT_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", TEXT_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", APPLICATION_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ - { "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" }, \ - { "Gecko-Content-Viewers", APPLICATION_RDF_XML, "@mozilla.org/content/document-loader-factory;1" }, \ - { "Gecko-Content-Viewers", TEXT_RDF, "@mozilla.org/content/document-loader-factory;1" }, \ - { "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" }, \ - { "Gecko-Content-Viewers", APPLICATION_WAPXHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \ - CONTENTDLF_WEBM_CATEGORIES -// clang-format on - #endif diff --git a/netwerk/test/browser/browser.toml b/netwerk/test/browser/browser.toml index 87296e917b36..39db35f2a27b 100644 --- a/netwerk/test/browser/browser.toml +++ b/netwerk/test/browser/browser.toml @@ -160,6 +160,9 @@ skip-if = ["os == 'win'"] # Bug 1775761 ["browser_cookie_sync_across_tabs.js"] +["browser_display_plaintext_types.js"] +support-files = ["res_hello_h1.sjs"] + ["browser_dns_prefetch_link_header.js"] ["browser_fetch_lnk.js"] diff --git a/netwerk/test/browser/browser_display_plaintext_types.js b/netwerk/test/browser/browser_display_plaintext_types.js new file mode 100644 index 000000000000..1b47be6f0c91 --- /dev/null +++ b/netwerk/test/browser/browser_display_plaintext_types.js @@ -0,0 +1,64 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const BASE_URI = + "http://mochi.test:8888/browser/netwerk/test/browser/res_hello_h1.sjs?type="; + +async function expectOutcome(aContentType, aBehavior) { + info(`Expecting ${aContentType} to be loaded as ${aBehavior}`); + const url = BASE_URI + aContentType; + + await BrowserTestUtils.withNewTab(url, async browser => { + await SpecialPowers.spawn(browser, [url, aBehavior], (url, aBehavior) => { + is(content.location.href, url, "expected url was loaded"); + switch (aBehavior) { + case "html": + is( + content.document.querySelector("h1").textContent, + "hello", + "parsed as HTML, so document should contain an