Skip to content

Commit e14187c

Browse files
committed
State what happens to <embed> with an unhandled MIME type
Also rewrites the algorithm in more modern style, which clears up some confusion around "resources" and load events and such. Fixes #3876.
1 parent 85e842a commit e14187c

File tree

1 file changed

+127
-129
lines changed

1 file changed

+127
-129
lines changed

source

+127-129
Original file line numberDiff line numberDiff line change
@@ -30308,182 +30308,180 @@ interface <dfn>HTMLEmbedElement</dfn> : <span>HTMLElement</span> {
3030830308
data-x="attr-embed-type">src</code> attribute set, changed, or removed or its <code
3030930309
data-x="attr-embed-type">type</code> attribute set, changed, or removed, the user agent must
3031030310
<span>queue a task</span> using the <dfn>embed task source</dfn> to run <span>the
30311-
<code>embed</code> element setup steps</span>.</p>
30311+
<code>embed</code> element setup steps</span> for that element.</p>
3031230312

30313-
<p><dfn>The <code>embed</code> element setup steps</dfn> are as follows:</p>
30313+
<p><dfn>The <code>embed</code> element setup steps</dfn> for a given <code>embed</code> element
30314+
<var>element</var> are as follows:</p>
3031430315

3031530316
<ol>
3031630317

3031730318
<li><p>If another <span data-x="concept-task">task</span> has since been queued to run <span>the
30318-
<code>embed</code> element setup steps</span> for this element, then return.</p></li>
30319+
<code>embed</code> element setup steps</span> for <var>element</var>, then return.</p></li>
3031930320

3032030321
<li><p>If the <span>Should element be blocked <i lang="la">a priori</i> by Content Security
30321-
Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed on the element,
30322-
then return. <ref spec="CSP"></p></li>
30322+
Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed on
30323+
<var>element</var>, then return. <ref spec="CSP"></p></li>
3032330324

3032430325
<li>
30326+
<p>If <var>element</var> has a <code data-x="attr-embed-src">src</code> attribute set, then:</p>
3032530327

30326-
<dl class="switch">
30328+
<ol>
30329+
<li><p>Let <var>url</var> be the result of <span data-x="parse a url">parsing</span> the value
30330+
of <var>element</var>'s <code data-x="attr-embed-src">src</code> attribute, relative to
30331+
<var>element</var>'s <span>node document</span>.</p></li>
3032730332

30328-
<dt>If the element has a <code data-x="attr-embed-src">src</code> attribute set</dt>
30333+
<li><p>If <var>url</var> is failure, then return.</p></li>
3032930334

30330-
<dd>
30331-
30332-
<p>The user agent must <span data-x="parse a url">parse</span> the value of the element's
30333-
<code data-x="attr-embed-src">src</code> attribute, relative to the element's <span>node
30334-
document</span>. If that is successful, the user agent should run these steps:
30335+
<li><p>Let <var>request</var> be a new <span data-x="concept-request">request</span> whose
30336+
<span data-x="concept-request-url">url</span> is <var>url</var>, <span
30337+
data-x="concept-request-client">client</span> is <var>element</var>'s <span>node
30338+
document</span>'s <span>relevant settings object</span>, <span
30339+
data-x="concept-request-destination">destination</span> is "<code data-x="">embed</code>",
30340+
<span data-x="concept-request-credentials-mode">credentials mode</span> is "<code
30341+
data-x="">include</code>", and whose <span>use-URL-credentials flag</span> is set.</p></li>
3033530342

30336-
<ol>
30337-
<!-- identical for <embed>/<object> -->
30338-
<li><p>Let <var>request</var> be a new <span data-x="concept-request">request</span> whose
30339-
<span data-x="concept-request-url">url</span> is the <span>resulting URL record</span>,
30340-
<span data-x="concept-request-client">client</span> is the element's <span>node
30341-
document</span>'s <code>Window</code> object's <span>environment settings object</span>,
30342-
<span data-x="concept-request-destination">destination</span> is "<code
30343-
data-x="">embed</code>", <span data-x="concept-request-credentials-mode">credentials
30344-
mode</span> is "<code data-x="">include</code>", and whose <span>use-URL-credentials
30345-
flag</span> is set.</p></li>
30346-
30347-
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
30348-
</ol>
30343+
<li>
30344+
<p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p>
3034930345

30350-
<p>The <span data-x="concept-task">task</span> that is <span
30351-
data-x="queue a task">queued</span> by the <span>networking task source</span> once the
30352-
resource has been fetched must run the following steps:</p>
30353-
<!-- Note that this doesn't happen when the base URL changes. -->
30346+
<p>Fetching the resource must <span>delay the load event</span> of <var>element</var>'s
30347+
<span>node document</span>.</p>
30348+
</li>
3035430349

30355-
<ol>
30350+
<li><p>Return from this algorithm, and run the following steps as part of the fetch's
30351+
<span>process response</span> for the <span data-x="concept-response">response</span>
30352+
<var>response</var>.</p></li>
3035630353

30357-
<li><p>If another <span data-x="concept-task">task</span> has since been queued to run
30358-
<span>the <code>embed</code> element setup steps</span> for this element, then return.</p></li>
30354+
<li><p>If another <span data-x="concept-task">task</span> has since been queued to run
30355+
<span>the <code>embed</code> element setup steps</span> for <var>element</var>, then
30356+
return.</p></li>
3035930357

30360-
<li>
30358+
<li><p>Let <var>type</var> be the result of determining the <span
30359+
data-x="concept-embed-type">type of content</span> given <var>element</var> and
30360+
<var>response</var>.</p></li>
3036130361

30362-
<p>Determine the <dfn data-x="concept-embed-type">type of the content</dfn> being embedded, as
30363-
follows (stopping at the first substep that determines the type):</p>
30362+
<li>
30363+
<p>Switch on <var>type</var>:</p>
3036430364

30365+
<dl class="switch">
30366+
<dt>null</dt>
30367+
<dd>
3036530368
<ol>
30369+
<li><p>The user agent may optionally display an indication that no <span>plugin</span> could
30370+
be found for <var>element</var>.</p></li>
3036630371

30367-
<li><p>If the element has a <code data-x="attr-embed-type">type</code> attribute, and that
30368-
attribute's value is a type that a <span>plugin</span> supports, then the value of the
30369-
<code data-x="attr-embed-type">type</code> attribute is the <span
30370-
data-x="concept-embed-type">content's type</span>.</p></li>
30372+
<li><p><var>element</var> <span>represents</span> nothing.</p></li>
30373+
</ol>
30374+
</dd>
3037130375

30376+
<dt><code>image/svg+xml</code></dt>
30377+
<dd>
30378+
<ol>
3037230379
<li>
30380+
<p>If <var>element</var>'s <span>nested browsing context</span> is null, then:</p>
3037330381

30374-
<!-- if we get to this point we know we can successfully parsed the URL, since this algorithm is
30375-
only used after fetching the resource in the steps above -->
30376-
30377-
<p>Otherwise, if applying the <span>URL parser</span> algorithm to the <span>URL</span> of
30378-
the specified resource (after any redirects) results in a <span>URL record</span> whose
30379-
<span data-x="concept-url-path">path</span> component matches a pattern that a
30380-
<span>plugin</span> supports, then the <span data-x="concept-embed-type">content's
30381-
type</span> is the type that that plugin can handle.</p>
30382-
30383-
<p class="example">For example, a plugin might say that it can handle resources with <span
30384-
data-x="concept-url-path">path</span> components that end with the four character string
30385-
"<code data-x="">.swf</code>".</p>
30386-
30387-
<!-- it's sad that we have to do extension sniffing. sigh. -->
30388-
<!-- see also <object> which has a similar step -->
30389-
30382+
<ol>
30383+
<li><p>Set <var>element</var>'s <span>nested browsing context</span> to a <span
30384+
data-x="creating a new browsing context">newly-created browsing context</span>.</p></li>
30385+
30386+
<li><p>If <var>element</var> has a <code data-x="attr-embed-name">name</code> attribute,
30387+
then set the <span>browsing context name</span> of <var>element</var>'s new
30388+
<span>nested browsing context</span> to the value of this attribute.</p></li>
30389+
<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2291 - dynamic changes
30390+
to 'name' don't do anything -->
30391+
</ol>
3039030392
</li>
3039130393

30392-
<li><p>Otherwise, if the specified resource has <span data-x="Content-Type">explicit
30393-
Content-Type metadata</span>, then that is the <span data-x="concept-embed-type">content's
30394-
type</span>.</p></li>
30394+
<li>
30395+
<p><span>Navigate</span> <var>element</var>'s <span>nested browsing context</span> to
30396+
<var>response</var>, with <span>replacement enabled</span>, and with <var>element</var>'s
30397+
<span>node document</span>'s <span data-x="concept-document-bc">browsing context</span> as
30398+
the <span>source browsing context</span>.</p>
3039530399

30396-
<li><p>Otherwise, the content has no <span data-x="concept-embed-type">type</span> and there
30397-
can be no appropriate <span>plugin</span> for it.</p></li>
30400+
<p class="note"><var>element</var>'s <code data-x="attr-embed-src">src</code> attribute does
30401+
not get updated if the browsing context gets further navigated to other locations.</p>
30402+
</li>
3039830403

30399-
<!-- This algorithm is a monument to bad design. Go legacy! -->
30404+
<li><p><var>embed</var> element now <span>represents</span> its <span>nested browsing
30405+
context</span>.</p></li>
3040030406

30407+
<li><p>When the <code>Document</code> of the <span>nested browsing context</span> is marked
30408+
as <span>completely loaded</span>, <span>queue a task</span> to <span
30409+
data-x="concept-event-fire">fire an event</span> named <code
30410+
data-x="event-load">load</code> at <var>element</var>.</p></li>
3040130411
</ol>
30412+
</dd>
3040230413

30403-
</li>
30404-
30405-
<li>
30406-
30407-
<p>If the previous step determined that the <span data-x="concept-embed-type">content's
30408-
type</span> is <code data-x="">image/svg+xml</code>, then run the following substeps:</p>
30409-
30414+
<dt>Otherwise</dt>
30415+
<dd>
3041030416
<ol>
30417+
<li><p>Find and instantiate an appropriate <span>plugin</span> based on <var>type</var>,
30418+
and hand that <span>plugin</span> <var>response</var>, replacing any
30419+
previously-instantiated plugin for <var>element</var>.</p></li>
3041130420

30412-
<li><p>If the <code>embed</code> element's <span>nested browsing context</span> is null,
30413-
set the element's <span>nested browsing context</span> to a <span data-x="creating a new
30414-
browsing context">newly-created browsing context</span>, and, if the element has a <code
30415-
data-x="attr-embed-name">name</code> attribute, set the <span>browsing context name</span>
30416-
of the element's new <span>nested browsing context</span> to the value of this
30417-
attribute.</p>
30418-
<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2291 - dynamic changes to 'name' don't do anything -->
30419-
30420-
<li><p><span>Navigate</span><!--DONAV embed--> the <span>nested browsing context</span> to
30421-
the fetched resource, with <span>replacement enabled</span>, and with the
30422-
<code>embed</code> element's <span>node document</span>'s <span
30423-
data-x="concept-document-bc">browsing context</span> as the <span>source browsing
30424-
context</span>. (The <code data-x="attr-embed-src">src</code> attribute of the
30425-
<code>embed</code> element doesn't get updated if the browsing context gets further
30426-
navigated to other locations.)</p></li>
30427-
30428-
<li><p>The <code>embed</code> element now <span>represents</span> its <span>nested browsing
30429-
context</span>.</p></li>
30421+
<li><p><var>element</var> now <span>represents</span> this <span>plugin</span>
30422+
instance.</p></li>
3043030423

30424+
<li><p>Once the plugin and resource are completely loaded, <span>queue a task</span> to
30425+
<span data-x="concept-event-fire">fire an event</span> named <code
30426+
data-x="event-load">load</code> at <var>element</var>.</p></li>
3043130427
</ol>
30428+
</dd>
30429+
</dl>
30430+
</li>
30431+
</ol>
30432+
</li>
3043230433

30433-
</li>
30434-
30435-
<li>
30436-
30437-
<p>Otherwise, find and instantiate an appropriate <span>plugin</span> based on the <span
30438-
data-x="concept-embed-type">content's type</span>, and hand that <span>plugin</span> the
30439-
content of the resource, replacing any previously instantiated plugin for the element. The
30440-
<code>embed</code> element now represents this <span>plugin</span> instance.</p>
30441-
30442-
</li>
30443-
30444-
<li><p>Once the resource or plugin has completely loaded, <span>queue a task</span> to <span
30445-
data-x="concept-event-fire">fire an event</span> named <code data-x="event-load">load</code>
30446-
at the element.</p></li>
30447-
30448-
</ol>
30449-
30450-
<p>Whether the resource is fetched successfully or not (e.g. whether the response status was
30451-
an <span>ok status</span>) must be ignored when determining the <span
30452-
data-x="concept-embed-type">content's type</span> and when handing the resource to the
30453-
plugin.</p>
30454-
30455-
<p class="note">This allows servers to return data for plugins even with error responses (e.g.
30456-
HTTP 500 Internal Server Error codes can still contain plugin data).</p>
30457-
30458-
<p>Fetching the resource must <span>delay the load event</span> of the element's <span>node document</span>.</p>
30459-
<!-- if we add load/error events, then replace the previous paragraph with the text one: -->
30460-
<!-- similar text in various places -->
30461-
<!--<p>Fetching the resource must <span>delay the load event</span> of the element's <span>node document</span>
30462-
until the final <span data-x="concept-task">task</span> that is <span data-x="queue a
30463-
task">queued</span> by the <span>networking task source</span> once the resource has been
30464-
<span data-x="fetch">fetched</span> has been run.</p>-->
30434+
<li>
30435+
<p>Otherwise:</p>
3046530436

30466-
</dd>
30437+
<ol>
30438+
<li><p>The user agent should find and instantiate an appropriate <span>plugin</span> based on
30439+
the value of <var>element</var>'s <code data-x="attr-embed-type">type</code>
30440+
attribute.</p></li>
3046730441

30468-
<dt>If the element has no <code data-x="attr-embed-src">src</code> attribute set</dt>
30442+
<li><p><var>element</var> now <span>represents</span> this <span>plugin</span>
30443+
instance.</p></li>
3046930444

30470-
<dd>
30445+
<li><p>Once the plugin is completely loaded, <span>queue a task</span> to <span
30446+
data-x="concept-event-fire">fire an event</span> named <code data-x="event-load">load</code>
30447+
at <var>element</var>.</p></li>
30448+
</ol>
30449+
</li>
30450+
</ol>
3047130451

30472-
<p>The user agent should find and instantiate an appropriate <span>plugin</span> based on the
30473-
value of the <code data-x="attr-embed-type">type</code> attribute. The <code>embed</code>
30474-
element now represents this <span>plugin</span> instance.</p>
30452+
<p>To determine the <dfn data-x="concept-embed-type">type of the content</dfn> given an
30453+
<code>embed</code> element <var>element</var> and a <span
30454+
data-x="concept-response">response</span> <var>response</var>, run the following steps:</p>
3047530455

30476-
<p>Once the plugin is completely loaded, <span>queue a task</span> to <span
30477-
data-x="concept-event-fire">fire an event</span> named <code data-x="event-load">load</code>
30478-
at the element.</p>
30456+
<ol>
30457+
<li><p>If <var>element</var> has a <code data-x="attr-embed-type">type</code> attribute, and that
30458+
attribute's value is a type that a <span>plugin</span> supports, then return the value of the
30459+
<code data-x="attr-embed-type">type</code> attribute.</p></li>
3047930460

30480-
</dd>
30461+
<li>
30462+
<p>If the <span data-x="concept-url-path">path</span> component of <var>response</var>'s
30463+
<span data-x="concept-response-url">url</span> matches a pattern that a <span>plugin</span>
30464+
supports, then return the type that that plugin can handle.</p>
3048130465

30482-
</dl>
30466+
<p class="example">For example, a plugin might say that it can handle URLs with <span
30467+
data-x="concept-url-path">path</span> components that end with the four character string
30468+
"<code data-x="">.swf</code>".</p>
3048330469

30470+
<!-- it's sad that we have to do extension sniffing. sigh. -->
30471+
<!-- see also <object> which has a similar step -->
3048430472
</li>
3048530473

30474+
<li><p>If <var>response</var> has <span data-x="Content-Type">explicit Content-Type
30475+
metadata</span>, then return that value.</p></li>
30476+
30477+
<li><p>Return null.</p></li>
3048630478
</ol>
30479+
<!-- This algorithm is a monument to bad design. Go legacy! -->
30480+
30481+
<p class="note">It is intentional that the above algorithm allows <var>response</var> to be a
30482+
<span>network error</span> or to have a non-<span>ok status</span>. This allows servers to return
30483+
data for plugins even with error responses (e.g. HTTP 500 Internal Server Error codes can still
30484+
contain plugin data).</p>
3048730485

3048830486
<p>The <code>embed</code> element has no <span>fallback content</span>. If the user agent can't
3048930487
find a suitable plugin when attempting to find and instantiate one for the algorithm above, then

0 commit comments

Comments
 (0)