Skip to content

Commit

Permalink
Detail how javascript: return values become response bodies
Browse files Browse the repository at this point in the history
Fixes #301, by aligning with the 3/4 browser majority and checking the
type of the completion value, turning non-strings and thrown errors into
204s. (Thrown errors are still reported, however.)

While working on this algorithm, we fix #945 by copying the HTTPS state
to response.

This also does some minor cleanup to clarify that "run a classic script"
returns undefined when scripting is disabled.

#1129 was opened to track a remaining open issue discovered, which is
exactly how the JS string completion value becomes a response body. For
now the spec includes a warning saying that this is underspecified.
  • Loading branch information
domenic committed Apr 26, 2016
1 parent 8edcc5b commit 9997cd9
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -82536,9 +82536,8 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O

<li><p>If the <span>origin</span> of the <span>source browsing context</span> is not the
<span>same origin</span> as the <span>origin</span> of the <span>active document</span> of
the <span>browsing context</span> being navigated, then act as if the result of evaluating
the script was the void value, and jump to the step labeled <i>process results</i>
below.</p></li>
the <span>browsing context</span> being navigated, then let <var>result</var> be undefined,
and jump to the step labeled <i>process result</i> below.</p></li>

<li><p>Let <var>urlRecord</var> be the result of running the <span>URL parser</span> on the
<span>URL</span> being navigated.</p></li>
Expand Down Expand Up @@ -82584,22 +82583,28 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O

<li><p>Let <var>result</var> be the result of <span data-x="run a classic script">running the
classic script</span> <var>script</var>. If evaluation was unsuccessful, let
<var>result</var> be void instead. (The result will be void also if <span
<var>result</var> be undefined instead. (The result will also be undefined if <span
data-x="concept-bc-noscript">scripting is disabled</span>.)</p></li>

<li>

<p><i>Process results</i>: If <var>result</var> is void (there is no return value), then
the result of obtaining the resource for the URL is a <span
<p><i>Process result</i>: If <span data-x="js-Type">Type</span>(<var>result</var>) is not
String, then the result of obtaining the resource for the URL is a <span
data-x="concept-response">response</span> whose <span
data-x="concept-response-status">status</span> is <code data-x="">204</code>.</p>

<p>Otherwise, the result of obtaining the resource for the URL is a <span
data-x="concept-response">response</span> whose <span
data-x="concept-response-header-list">header list</span> consists of <code
data-x="">Content-Type</code>/<code>text/html</code> and whose <span
data-x="concept-response-body">body</span> is the return value converted to a string
value.</p>
data-x="">Content-Type</code>/<code>text/html</code>, whose <span
data-x="concept-response-body">body</span> is <var>result</var>, and whose <span
data-x="concept-response-https-state">HTTPS state</span> is <var>settings</var>'s
<span>HTTPS state</span>.</p>

<p class="warning">The exact conversion between the JavaScript string <var>result</var> and
the bytes that comprise a <span data-x="concept-response-body">response body</span> is
not yet specified, pending further investigation into user agent behavior. See <a
href="https://github.com/whatwg/html/issues/1129">issue #1129</a>.</p>

<p>When it comes time to <span>set the document's address</span> in the <span
data-x="navigate">navigation algorithm</span>, use <var>address</var> as the
Expand Down Expand Up @@ -87358,8 +87363,8 @@ interface <dfn>NavigatorOnLine</dfn> {

<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>s</var>.</p></li>

<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
not run" then abort these steps.</p></li>
<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do not
run", then return undefined and abort these steps.</p></li>

<li><p>Let <var>realm</var> be <var>settings</var>'s <span
data-x="environment settings object's Realm">Realm</span>.</p></li>
Expand Down

0 comments on commit 9997cd9

Please sign in to comment.