Skip to content
Permalink
Browse files

[giow] (2) Make form submission via .submit(), and page navigation vi…

…a location.href, when either is done before the page has completely loaded, result in a history replacement (like a redirect) rather than a regular load.

git-svn-id: http://svn.whatwg.org/webapps@5685 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Nov 30, 2010
1 parent 82cc161 commit 6f5820ab30bb178fa534246ad7693b358fd7595a
Showing with 120 additions and 123 deletions.
  1. +39 −41 complete.html
  2. +39 −41 index
  3. +42 −41 source
<var title="">scripted-submit</var> flag set, the user agent must
run the following steps:</p>

<ol><li id=sandboxSubmitBlocked><p>If <var title="">form</var> is in
a <code><a href=#document>Document</a></code> that has no associated <a href=#browsing-context>browsing
context</a> or whose <a href=#browsing-context>browsing context</a> had its
<a href=#sandboxed-forms-browsing-context-flag>sandboxed forms browsing context flag</a> set when the
<code><a href=#document>Document</a></code> was created, then abort these steps without
doing anything.</li>
<ol><li><p>Let <var title="">form document</var> be the <var title="">form</var>'s <code><a href=#document>Document</a></code>.</li>

<li id=sandboxSubmitBlocked><p>If <var title="">form
document</var> has no associated <a href=#browsing-context>browsing context</a> or
its <a href=#browsing-context>browsing context</a> had its <a href=#sandboxed-forms-browsing-context-flag>sandboxed forms
browsing context flag</a> set when the <code><a href=#document>Document</a></code> was
created, then abort these steps without doing anything.</li>

<li><p>Let <var title="">form browsing context</var> be the
<a href=#browsing-context>browsing context</a> of <var title="">form
document</var>.</li>

<li><p>If <var title="">form</var> is already being submitted
(i.e. the form was <a href=#concept-form-submit title=concept-form-submit>submitted</a> again while processing

<li>

<p>If <var title="">action</var> is the empty string, let <var title="">action</var> be <a href="#the-document's-address">the document's address</a>.</p>
<p>If <var title="">action</var> is the empty string, let <var title="">action</var> be <a href="#the-document's-address">the document's address</a> of
the <var title="">form document</var>.</p>

<p class=note>This step is a <a href=#willful-violation>willful violation</a> of
RFC 3986, which would require base URL processing here. This
<li><p>If the user indicated a specific <a href=#browsing-context>browsing
context</a> to use when submitting the form, then let <var title="">target browsing context</var> be that <a href=#browsing-context>browsing
context</a>. Otherwise, apply <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a
browsing context given a browsing context name</a> using <var title="">target</var> as the name and the <a href=#browsing-context>browsing
context</a> of <var title="">form</var> as the context in which
the algorithm is executed, and let <var title="">target browsing
context</var> be the resulting <a href=#browsing-context>browsing
context</a>.</li>
browsing context given a browsing context name</a> using <var title="">target</var> as the name and <var title="">form browsing
context</var> as the context in which the algorithm is executed,
and let <var title="">target browsing context</var> be the
resulting <a href=#browsing-context>browsing context</a>.</li>

<li><p>If <var title="">target browsing context</var> was created
in the previous step, then let <var title="">replace</var> be true.
Otherwise, let it be false.</li>
<!-- XXXXX this is about to change -->
in the previous step, or if the <var title="">form document</var>
has not yet <a href=#completely-loaded>completely loaded</a>, then let <var title="">replace</var> be true. Otherwise, let it be
false.</li>

<li>


</dl><!--<p>If <var title="">method</var> is anything but (GET or)
POST, and the <span>origin</span> of <var title="">action</var>
is not the <span>same origin</span> as that of the
<code>form</code> element's <code>Document</code>, then abort
these steps.</p> [or do CORS] (this is commented out since only
POST can trigger this now, and that's historically
unrestricted)--><p>Otherwise, <a href=#navigate>navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">action</var> using the HTTP method given by <var title="">method</var> and with <var title="">entity body</var>
is not the <span>same origin</span> as that of <var
title="">form document</var>, then abort these steps.</p> [or do
CORS] (this is commented out since only POST can trigger this
now, and that's historically unrestricted)--><p>Otherwise, <a href=#navigate>navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">action</var> using the HTTP method given by <var title="">method</var> and with <var title="">entity body</var>
as the entity body, of type <var title="">MIME type</var>. If
<var title="">replace</var> is true, then <var title="">target
browsing context</var> must be navigated with <a href=#replacement-enabled>replacement
address">the current address</a> of the associated
<code><a href=#document>Document</a></code> object, as an <a href=#absolute-url>absolute URL</a>.</p>

<p>On setting, <!-- READ ME WHEN EDITING THIS: Mozilla does this,
but IE doesn't. What should we do?: the behavior depends on the
context in which the script that set the attribute is running. If
the script ran as the direct result of the execution of a
<code>script</code> element in the document represented by the
<code>Location</code> object's associated <code>Document</code>
object, then the user agent must act as if the <code
title="dom-location-replace">replace()</code> method had been called
with the new value as its argument. Otherwise,--> the user agent
must act as if the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code>
method had been called with the new value as its argument.</p><!--
v2: may wish to allow replace instead as a UI improvement -->
<!-- XXXXX the above is about to change -->

<!-- we could change the magic .location setter to simply refer
straight to assign(), so we don't have two levels of indirection -->
<p>On setting, if the <code><a href=#location>Location</a></code> object's associated
<code><a href=#document>Document</a></code> object has <a href=#completely-loaded>completely loaded</a>,
then the user agent must act as if the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> method had been called
with the new value as its argument. Otherwise, the user agent must
act as if the <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code>
method had been called with the new value as its argument.</p>
<!--DONAV location.href, defined in terms of the paragraphs below-->

<p>When the <dfn id=dom-location-assign title=dom-location-assign><code>assign(<var title="">url</var>)</code></dfn> method is invoked, the UA must
<a href=#resolve-a-url title="resolve a url">resolve</a> the argument, relative to
<a href=#resolve-a-url title="resolve a url">resolve</a> the argument, relative to
the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base
URL</a>, and if that is successful,
<a href=#navigate>navigate</a><!--DONAV location.replace--> the
<a href=#navigate>navigate</a><!--DONAV location.href/replace--> the
<a href=#browsing-context>browsing context</a> to the specified <var title="">url</var> with <a href=#replacement-enabled>replacement enabled</a>.</p>

<p>Navigation for the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> and <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code> methods must be done
target <code><a href=#applicationcache>ApplicationCache</a></code> object <var title="">target</var>, the user agent must run the appropriate steps
from the following list:</p>

<dl><dt>If <var title="">target</var>'s <code><a href=#document>Document</a></code> has
<a href=#completely-loaded>completely loaded</a></dt>
<dl><dt>If <var title="">target</var>'s <code><a href=#document>Document</a></code> is
<a href=#ready-for-post-load-tasks>ready for post-load tasks</a></dt>

<dd><p><a href=#queue-a-task title="queue a task">Queue</a> the task <var title="">task</var>.</dd>

for these <a href=#concept-task title=concept-task>tasks</a> is the
<a href=#networking-task-source>networking task source</a>.</li>

<li><p>The <code><a href=#document>Document</a></code> is now <dfn id=completely-loaded>completely
loaded</dfn>.</li>
<li><p>The <code><a href=#document>Document</a></code> is now <dfn id=ready-for-post-load-tasks>ready for post-load
tasks</dfn>.</li>

<li><p><a href=#queue-a-task>Queue a task</a> to mark the <code><a href=#document>Document</a></code>
as <dfn id=completely-loaded>completely loaded</dfn>.</li>

</ol><p>When the user agent is to <dfn id=abort-a-parser>abort a parser</dfn>, it must run
the following steps:</p>
80 index
<var title="">scripted-submit</var> flag set, the user agent must
run the following steps:</p>

<ol><li id=sandboxSubmitBlocked><p>If <var title="">form</var> is in
a <code><a href=#document>Document</a></code> that has no associated <a href=#browsing-context>browsing
context</a> or whose <a href=#browsing-context>browsing context</a> had its
<a href=#sandboxed-forms-browsing-context-flag>sandboxed forms browsing context flag</a> set when the
<code><a href=#document>Document</a></code> was created, then abort these steps without
doing anything.</li>
<ol><li><p>Let <var title="">form document</var> be the <var title="">form</var>'s <code><a href=#document>Document</a></code>.</li>

<li id=sandboxSubmitBlocked><p>If <var title="">form
document</var> has no associated <a href=#browsing-context>browsing context</a> or
its <a href=#browsing-context>browsing context</a> had its <a href=#sandboxed-forms-browsing-context-flag>sandboxed forms
browsing context flag</a> set when the <code><a href=#document>Document</a></code> was
created, then abort these steps without doing anything.</li>

<li><p>Let <var title="">form browsing context</var> be the
<a href=#browsing-context>browsing context</a> of <var title="">form
document</var>.</li>

<li><p>If <var title="">form</var> is already being submitted
(i.e. the form was <a href=#concept-form-submit title=concept-form-submit>submitted</a> again while processing

<li>

<p>If <var title="">action</var> is the empty string, let <var title="">action</var> be <a href="#the-document's-address">the document's address</a>.</p>
<p>If <var title="">action</var> is the empty string, let <var title="">action</var> be <a href="#the-document's-address">the document's address</a> of
the <var title="">form document</var>.</p>

<p class=note>This step is a <a href=#willful-violation>willful violation</a> of
RFC 3986, which would require base URL processing here. This
<li><p>If the user indicated a specific <a href=#browsing-context>browsing
context</a> to use when submitting the form, then let <var title="">target browsing context</var> be that <a href=#browsing-context>browsing
context</a>. Otherwise, apply <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a
browsing context given a browsing context name</a> using <var title="">target</var> as the name and the <a href=#browsing-context>browsing
context</a> of <var title="">form</var> as the context in which
the algorithm is executed, and let <var title="">target browsing
context</var> be the resulting <a href=#browsing-context>browsing
context</a>.</li>
browsing context given a browsing context name</a> using <var title="">target</var> as the name and <var title="">form browsing
context</var> as the context in which the algorithm is executed,
and let <var title="">target browsing context</var> be the
resulting <a href=#browsing-context>browsing context</a>.</li>

<li><p>If <var title="">target browsing context</var> was created
in the previous step, then let <var title="">replace</var> be true.
Otherwise, let it be false.</li>
<!-- XXXXX this is about to change -->
in the previous step, or if the <var title="">form document</var>
has not yet <a href=#completely-loaded>completely loaded</a>, then let <var title="">replace</var> be true. Otherwise, let it be
false.</li>

<li>


</dl><!--<p>If <var title="">method</var> is anything but (GET or)
POST, and the <span>origin</span> of <var title="">action</var>
is not the <span>same origin</span> as that of the
<code>form</code> element's <code>Document</code>, then abort
these steps.</p> [or do CORS] (this is commented out since only
POST can trigger this now, and that's historically
unrestricted)--><p>Otherwise, <a href=#navigate>navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">action</var> using the HTTP method given by <var title="">method</var> and with <var title="">entity body</var>
is not the <span>same origin</span> as that of <var
title="">form document</var>, then abort these steps.</p> [or do
CORS] (this is commented out since only POST can trigger this
now, and that's historically unrestricted)--><p>Otherwise, <a href=#navigate>navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">action</var> using the HTTP method given by <var title="">method</var> and with <var title="">entity body</var>
as the entity body, of type <var title="">MIME type</var>. If
<var title="">replace</var> is true, then <var title="">target
browsing context</var> must be navigated with <a href=#replacement-enabled>replacement
address">the current address</a> of the associated
<code><a href=#document>Document</a></code> object, as an <a href=#absolute-url>absolute URL</a>.</p>

<p>On setting, <!-- READ ME WHEN EDITING THIS: Mozilla does this,
but IE doesn't. What should we do?: the behavior depends on the
context in which the script that set the attribute is running. If
the script ran as the direct result of the execution of a
<code>script</code> element in the document represented by the
<code>Location</code> object's associated <code>Document</code>
object, then the user agent must act as if the <code
title="dom-location-replace">replace()</code> method had been called
with the new value as its argument. Otherwise,--> the user agent
must act as if the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code>
method had been called with the new value as its argument.</p><!--
v2: may wish to allow replace instead as a UI improvement -->
<!-- XXXXX the above is about to change -->

<!-- we could change the magic .location setter to simply refer
straight to assign(), so we don't have two levels of indirection -->
<p>On setting, if the <code><a href=#location>Location</a></code> object's associated
<code><a href=#document>Document</a></code> object has <a href=#completely-loaded>completely loaded</a>,
then the user agent must act as if the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> method had been called
with the new value as its argument. Otherwise, the user agent must
act as if the <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code>
method had been called with the new value as its argument.</p>
<!--DONAV location.href, defined in terms of the paragraphs below-->

<p>When the <dfn id=dom-location-assign title=dom-location-assign><code>assign(<var title="">url</var>)</code></dfn> method is invoked, the UA must
<a href=#resolve-a-url title="resolve a url">resolve</a> the argument, relative to
<a href=#resolve-a-url title="resolve a url">resolve</a> the argument, relative to
the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base
URL</a>, and if that is successful,
<a href=#navigate>navigate</a><!--DONAV location.replace--> the
<a href=#navigate>navigate</a><!--DONAV location.href/replace--> the
<a href=#browsing-context>browsing context</a> to the specified <var title="">url</var> with <a href=#replacement-enabled>replacement enabled</a>.</p>

<p>Navigation for the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> and <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code> methods must be done
target <code><a href=#applicationcache>ApplicationCache</a></code> object <var title="">target</var>, the user agent must run the appropriate steps
from the following list:</p>

<dl><dt>If <var title="">target</var>'s <code><a href=#document>Document</a></code> has
<a href=#completely-loaded>completely loaded</a></dt>
<dl><dt>If <var title="">target</var>'s <code><a href=#document>Document</a></code> is
<a href=#ready-for-post-load-tasks>ready for post-load tasks</a></dt>

<dd><p><a href=#queue-a-task title="queue a task">Queue</a> the task <var title="">task</var>.</dd>

for these <a href=#concept-task title=concept-task>tasks</a> is the
<a href=#networking-task-source>networking task source</a>.</li>

<li><p>The <code><a href=#document>Document</a></code> is now <dfn id=completely-loaded>completely
loaded</dfn>.</li>
<li><p>The <code><a href=#document>Document</a></code> is now <dfn id=ready-for-post-load-tasks>ready for post-load
tasks</dfn>.</li>

<li><p><a href=#queue-a-task>Queue a task</a> to mark the <code><a href=#document>Document</a></code>
as <dfn id=completely-loaded>completely loaded</dfn>.</li>

</ol><p>When the user agent is to <dfn id=abort-a-parser>abort a parser</dfn>, it must run
the following steps:</p>

0 comments on commit 6f5820a

Please sign in to comment.
You can’t perform that action at this time.