Skip to content

Commit

Permalink
Fix #124: make more types follow text/plain navigate logic
Browse files Browse the repository at this point in the history
This change makes JavaScript MIME types, JSON MIME types (including
text/json due to https://bugzilla.mozilla.org/show_bug.cgi?id=1201632),
text/cache-manifest, text/css, and text/vtt follow the text/plain
navigate logic.

It also blocks text/vtt from being used by registerContentHandler() as
the user agent needs to handle it natively.

It further changes the navigate algorithm to use the abstract terms
HTML MIME type and XML MIME type rather than the explicit MIME types to
make them consistent with what is done for JavaScript and JSON. As
especially for JavaScript listing all MIME types again in duplicate
would be quite cumbersome.
  • Loading branch information
annevk committed Sep 29, 2015
1 parent be37ac7 commit f94f3c4
Showing 1 changed file with 40 additions and 23 deletions.
63 changes: 40 additions & 23 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -82194,27 +82194,26 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O

<dl class="switch">

<!-- an <span>HTML MIME type</span> -->
<dt>"<code>text/html</code>"</dt>
<dt>an <span>HTML MIME type</span></dt>
<dd>Follow the steps given in the <span data-x="navigate-html">HTML document</span> section,
and then, once they have completed, abort this <span>navigate</span> algorithm.</dd>

<!-- an <span>XML MIME type</span> -->
<dt>"<code>application/xml</code>"</dt>
<dt>"<code>text/xml</code>"</dt>
<dt>"<code>image/svg+xml</code>"</dt>
<dt>"<code>application/xhtml+xml</code>"</dt>
<dt>Any other type ending in "<code data-x="">+xml</code>" that is not an <span>explicitly
supported XML type</span></dt> <!-- no need to say that the _subtype_ ends in "+xml" so long as
the "sniffed type" algorithm continues to drop parameters -->
<dt>an <span>XML MIME type</span> that is not an <span>explicitly supported XML
type</span></dt>

<dd>Follow the steps given in the <span data-x="navigate-xml">XML document</span> section. If
that section determines that the content is <em>not</em> to be displayed as a generic XML
document, then proceed to the next step in this overall set of steps. Otherwise, once the steps
given in the <span data-x="navigate-xml">XML document</span> section have completed, abort this
<span>navigate</span> algorithm.</dd>

<dt>a <span>JavaScript MIME type</span></dt>
<dt>a <span>JSON MIME type</span> that is not an <span>explicitly supported JSON
type</span></dt>
<dt>"<code>text/cache-manifest</code>"</dt>
<dt>"<code>text/css</code>"</dt>
<dt>"<code>text/plain</code>"</dt>
<dt>"<code>text/vtt</code>"</dt>
<dd>Follow the steps given in the <span data-x="navigate-text">plain text file</span> section,
and then, once they have completed, abort this <span>navigate</span> algorithm.</dd>

Expand Down Expand Up @@ -82242,6 +82241,17 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
which the user agent has a dedicated handler (e.g. one registered using <code
data-x="dom-navigator-registerContentHandler">registerContentHandler()</code>).</p>

<p>The term <dfn>JSON MIME type</dfn> is used to refer to the <span data-x="MIME type">MIME
types</span> <code>application/json</code>, <code>text/json</code>, and any <span>MIME
type</span> whose subtype ends with the five characters "<code data-x="">+json</code>".

<p>An <dfn>explicitly supported JSON type</dfn> is one for which the user agent is configured to
use an external application to render the content (either a <span>plugin</span> rendering
directly in the <span>browsing context</span>, or a separate application), or one for which the
user agent has dedicated processing rules, or one for which the user agent has a dedicated
handler (e.g. one registered using <code
data-x="dom-navigator-registerContentHandler">registerContentHandler()</code>).</p>

<p><dfn data-x="set the document's address">Setting the document's address</dfn>: If there is no
<dfn>override URL</dfn>, then any <code>Document</code> created by these steps must have its
<span data-x="the document's address">address</span> set to the <span>URL</span> that was
Expand Down Expand Up @@ -82534,20 +82544,20 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
<p>When a plain text document is to be loaded in a <span>browsing context</span>, the user agent
must <span>queue a task</span> to create a <code>Document</code> object, mark it as being an <span
data-x="HTML documents">HTML document</span>, set its <span
data-x="concept-document-content-type">content type</span> to "<code data-x="">text/plain</code>",
<span>initialise the <code>Document</code> object</span>, create an <span>HTML parser</span>,
associate it with the <code>Document</code>, act as if the tokenizer had emitted a start tag token
with the tag name "pre" followed by a single U+000A LINE FEED (LF) character<!-- to get eaten, so
that a leading LF in the text/plain stream doesn't get eaten itself-->, and switch the <span>HTML
parser</span>'s tokenizer to the <span>PLAINTEXT state</span>. Each <span
data-x="concept-task">task</span> that the <span>networking task source</span> places on the
<span>task queue</span> while fetching runs must then fill the parser's <span>input byte
stream</span> with the fetched bytes and cause the <span>HTML parser</span> to perform the
appropriate processing of the input stream.</p>
data-x="concept-document-content-type">content type</span> to the sniffed MIME type of the
resource (<var>type</var> in the <span>navigate</span> algorithm), <span>initialise the
<code>Document</code> object</span>, create an <span>HTML parser</span>, associate it with the
<code>Document</code>, act as if the tokenizer had emitted a start tag token with the tag name
"pre" followed by a single U+000A LINE FEED (LF) character<!-- to get eaten, so that a leading LF
in the text/plain stream doesn't get eaten itself-->, and switch the <span>HTML parser</span>'s
tokenizer to the <span>PLAINTEXT state</span>. Each <span data-x="concept-task">task</span> that
the <span>networking task source</span> places on the <span>task queue</span> while fetching runs
must then fill the parser's <span>input byte stream</span> with the fetched bytes and cause the
<span>HTML parser</span> to perform the appropriate processing of the input stream.</p>

<p>The rules for how to convert the bytes of the plain text document into actual characters, and
the rules for actually rendering the text to the user, are defined in RFC 2046, RFC 3676, and
subsequent versions thereof. <ref spec=RFC2046> <ref spec=RFC3676></p>
the rules for actually rendering the text to the user, are defined by the specifications for the
sniffed MIME type of the resource (<var>type</var> in the <span>navigate</span> algorithm).</p>

<p>The <span>document's character encoding</span> must be set to the character encoding used to
decode the document.</p>
Expand Down Expand Up @@ -89917,6 +89927,7 @@ interface <dfn>NavigatorContentUtils</dfn> {
<li><code>text/html</code></li>
<li><code>text/ping</code></li>
<li><code>text/plain</code></li>
<li><code>text/vtt</code></li>
<li><code>text/xml</code></li>
<li>All types that the user agent supports displaying natively in a <span>browsing context</span> during <span data-x="navigate">navigation</span>, except for <code>application/rss+xml</code> and <code>application/atom+xml</code></li>

Expand Down Expand Up @@ -117459,11 +117470,14 @@ INSERT INTERFACES HERE
<dt><dfn><code>text/jscript</code></dfn></dt>
<dd>JavaScript (legacy type) <ref spec=ECMA&#x32;62>

<dt><dfn><code>text/json</code></dfn></dt>
<dd>JSON (legacy type)</dd>

<dt><dfn><code>text/livescript</code></dfn></dt>
<dd>JavaScript (legacy type) <ref spec=ECMA&#x32;62>

<dt><dfn data-x-href="https://tools.ietf.org/html/rfc2046#section-4.1.3"><code>text/plain</code></dfn></dt>
<dd>Generic plain text <ref spec=RFC2046></dd>
<dd>Generic plain text <ref spec=RFC2046> <ref spec=RFC3676></dd>

<dt><code>text/html</code></dt>
<dd>HTML</dd>
Expand All @@ -117477,6 +117491,9 @@ INSERT INTERFACES HERE
<dt><dfn><code>text/vcard</code></dfn></dt>
<dd>vCard <ref spec =RFC6350>

<dt><dfn><code>text/vtt</code></dfn></dt>
<dd>WebVTT <ref spec=WEBVTT></dd>

<dt><dfn><code>text/x-ecmascript</code></dfn></dt>
<dd>JavaScript (legacy type) <ref spec=ECMA&#x32;62>

Expand Down

0 comments on commit f94f3c4

Please sign in to comment.