<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>18854</bug_id>
          
          <creation_ts>2012-09-12 09:40:50 +0000</creation_ts>
          <short_desc>Make hyperlink navigation from clicking links asynchronously start /navigate/ rather than being synchronous as now</short_desc>
          <delta_ts>2013-04-08 20:41:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#navigate</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>james</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>73692</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-09-12 09:40:50 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#navigate
Complete: http://www.whatwg.org/c#navigate

Comment:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1759 seems to be a
special case where navigating to a javascript URL should not affect the
existing navigation

Posted from: 2001:4c28:a030:30:c9a:9910:b30b:8b12
User agent: Opera/9.80 (X11; Linux x86_64; Edition Next) Presto/2.12.378 Version/12.50</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73706</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-09-12 17:41:06 +0000</bug_when>
    <thetext>what does IE do on http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1760 ?

WebKit runs the script but appears to discard the results.
Opera and Gecko seem to just not run the script.

Based on http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1762 it looks like Gecko is just never bothering to follow the link. This is consistent with the submission navigation being started async and immediately canceling the hyperlink navigation; javascript: is thus not special for Gecko. Opera and WebKit seem to follow the spec for that case, so javascript: is special for them.

Would love to know what IE is doing here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73764</commentid>
    <comment_count>2</comment_count>
    <who name="James Graham">james</who>
    <bug_when>2012-09-13 12:41:39 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; what does IE do on
&gt; http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1760 ?

Looks like IE runs the javascript url, navigates to the javascript URL and then navigates to the form submission URL.

&gt; WebKit runs the script but appears to discard the results.
&gt; Opera and Gecko seem to just not run the script.
&gt; 
&gt; Based on http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1762

This test doesn&apos;t really work in IE due to broken data url handling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74014</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-09-17 21:32:59 +0000</bug_when>
    <thetext>Would anyone object to us just making .submit() queue a task to do its work?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74019</commentid>
    <comment_count>4</comment_count>
    <who name="James Graham">james</who>
    <bug_when>2012-09-18 07:43:42 +0000</bug_when>
    <thetext>Does that fix the issue? It seems that normal navigations actually work the same way as form submissions: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1774</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74060</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-09-18 23:54:24 +0000</bug_when>
    <thetext>Guess there&apos;s no getting away from making javascript: magical somehow then. Maybe the same way as frag IDs, except don&apos;t run the JS?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79226</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-12-01 03:02:58 +0000</bug_when>
    <thetext>More tests (they don&apos;t add anything that wasn&apos;t said above):
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1956
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1957
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1962

A more interesting test:
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1958

That last test shows a difference between Opera and Gecko. Gecko seems to special-case javascript: in links, but otherwise treats it normally. Opera, however, seems to ignore a second *JS-initiated* navigation entirely, regardless of what it is.

WebKit seems to never navigate to the return value of a javascript: link, it just acts like it always returns HTTP 204.

I didn&apos;t test IE myself, but what comment 2 above suggests that it just runs both navigations in parallel, or something.

More interesting tests:
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1965
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1966
  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1967

For WebKit, this is consistent with doing what the spec says except for acting like javascript: always returns 204. (Also, it doesn&apos;t abort running navigations.)

For Gecko, the first test is consistent with it not running javascript: links when a navigation is in process, but the second test shows that&apos;s not right... looks like it&apos;s more that javascript: isn&apos;t followed if there&apos;s a document.location navigation going on. Though the third tests suggests it&apos;s not that simple either. Maybe it&apos;s something like &quot;if the current task has already set location&quot;?

Opera is consistent with what I said above, about it not allowing a second JS-initiated navigation regardless of source.

So basically none of the browsers do anything sane.

Assuming we want to support javascript: return values, we can&apos;t do what that but otherwise do what WebKit does, because that doesn&apos;t match any UAs and ends up at the wrong page.

Opera seems to be off alone in doing something weird with JS-triggered navigations; I&apos;m not comfortable with that level of magic.

IE, insofar as it has been tested here, runs multiple navigations, and I don&apos;t even _know_ what that means.

So we&apos;re left with doing what Gecko does, but I can&apos;t work what that is exactly.

bz, any chance you know what Gecko is doing here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79227</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-01 03:54:57 +0000</bug_when>
    <thetext>We don&apos;t do any special-casing of javascript: in links, that I know of.  Why do you think we do?

&gt; WebKit seems to never navigate to the return value of a javascript: link

Yep.  They special-case &lt;(i)frame src=&quot;javascript:&quot;&gt;, basically.

On your &quot;more interesting tests&quot;, here&apos;s what happens in Gecko:

&gt;  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1965

The button&apos;s click event starts a navigation.  Then the javascript: runs, and starts _another_ navigation from the location set it does; this cancels both the already-pending navigation to &apos;document&apos; and the pending navigation to the return value of &apos;javascript:&apos;, if any.  Note that the log shows both &quot;JS handler ran&quot; and &quot;JS URL ran&quot;, so I&apos;m not sure how you concluded something about not running javascript: links.

&gt;  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1966

Starts a navigation to &apos;document&apos;, then runs the javascript: which starts a navigation to &apos;/&apos;, which cancels everything else that&apos;s going on, just like in the previous test.

&gt;  http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1967

I&apos;m not sure what the steps to reproduce are for this testcase...

&gt; bz, any chance you know what Gecko is doing here?

I believe the summary of Gecko behavior around this stuff is as follows:

1)  When a javascript: load starts, we don&apos;t immediately start a navigation
    (hence don&apos;t do the normal &quot;stop other things&quot; behavior).
2)  If the return value is not &quot;undefined&quot;, we start a navigation to that
    return value if the load has not been stopped in the meantime.
3)  The &quot;stop other things&quot; behavior when a navigation starts stops javascript:
    loads too.  If a navigation starts between when the javascript: load starts
    and when the script would actually run, the script does not run (because
    the javascript: load gets stopped).
4)  Clicking a link doesn&apos;t start the load of the href immediately in Gecko: it
    grabs some metadata from the link (target, URI, etc) and then posts an
    event to start the load.  So if your script calls click() on a javascript:
    link and then immediately sets location, that javascript: will still run. 
    Note that we could possibly change this to cancel the event when a
    navigation starts; would have to check compat issues.

Again, there is no special-casing of the specific case of &quot;link to javascript:&quot; anywhere here, apart from what follows from the separate special-casings for &quot;javascript:&quot; and &quot;link&quot; above.  ;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83062</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-02-12 23:03:56 +0000</bug_when>
    <thetext>Ok so #4 explains the original test&apos;s behaviour.

That&apos;s relatively straight-forward for us to do, I guess. Would people be ok with that? It&apos;s just making hyperlink navigation start the navigate algorithm asynchronously instead of the top bit of the navigate being synchronous as now. It limits the magic quite a lot.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85736</commentid>
    <comment_count>9</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-04-08 20:41:40 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7794.
Check-in comment: Rewrite the link following stuff to better match reality.
http://html5.org/tools/web-apps-tracker?from=7793&amp;to=7794</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>