<?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>18459</bug_id>
          
          <creation_ts>2012-08-01 09:41:17 +0000</creation_ts>
          <short_desc>So, this makes it sound like the document base URL is computed every time that it&apos;s needed. But that doesn&apos;t seem to be true in Gecko/WebKit - in particular after pushState they don&apos;t recompute the document base URL. So the value probably needs to be stor</short_desc>
          <delta_ts>2013-06-12 19:05:21 +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/#resolving-urls</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>hackwrench</cc>
    
    <cc>ian</cc>
    
    <cc>james</cc>
    
    <cc>justin.lebar</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>71732</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-08-01 09:41:17 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#resolving-urls
Complete: http://www.whatwg.org/c#resolving-urls

Comment:
So, this makes it sound like the document base URL is computed every time that
it&apos;s needed. But that doesn&apos;t seem to be true in Gecko/WebKit - in particular
after pushState they don&apos;t recompute the document base URL. So the value
probably needs to be stored somewhere and computed only at specified times.

Posted from: 2001:4c28:a030:30:2d33:76:f557:82e4
User agent: Opera/9.80 (X11; Linux x86_64; U; Edition Next; en) Presto/2.11.310 Version/12.50</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71733</commentid>
    <comment_count>1</comment_count>
    <who name="James Graham">james</who>
    <bug_when>2012-08-01 10:33:06 +0000</bug_when>
    <thetext>TC, sort of: http://hoppipolla.co.uk/tests/pushState/001.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72712</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-08-24 18:51:36 +0000</bug_when>
    <thetext>Wow, this makes my head hurt.

So, _without_ the base element, the pushState() call _does_ cause the base URL to update. But somehow the &lt;base&gt; element is resolved relative to something different than the document&apos;s address.

So the question is, what on earth is &lt;base href=&quot;&quot;&gt; actually resolved against?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77461</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-30 22:19:12 +0000</bug_when>
    <thetext>bz, do you have any input on this one? (Or know who might know more?)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78802</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-11-26 04:46:46 +0000</bug_when>
    <thetext>Maybe Justin Lebar?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82681</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-02-07 03:49:00 +0000</bug_when>
    <thetext>Justin: any ideas?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83284</commentid>
    <comment_count>6</comment_count>
    <who name="Justin Lebar">justin.lebar</who>
    <bug_when>2013-02-18 18:25:27 +0000</bug_when>
    <thetext>&gt; So, _without_ the base element, the pushState() call _does_ cause the base URL 
&gt; to update.

Correct: http://jsfiddle.net/c7GVu/

&gt; But somehow the &lt;base&gt; element is resolved relative to something different than 
&gt; the document&apos;s address.

It&apos;s resolved relative to the document&apos;s address at the time the base element is created.  http://jsfiddle.net/zZ6Ft/

&gt; So the question is, what on earth is &lt;base href=&quot;&quot;&gt; actually resolved against?

The document&apos;s current URI at the time the node is created.  If that node&apos;s href is later modified, the href is again resolved against the document&apos;s current URI.  http://jsfiddle.net/LkvaR/2/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85798</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-04-09 17:40:45 +0000</bug_when>
    <thetext>So the base URL for &lt;base&gt; elements is a stored value, which is saved:
 * when the element is created
 * when the href=&quot;&quot; attribute is set or changed

And this is used to determine the absolute URL that is then used as the document&apos;s base URL.

And fixing just that would resolve this bug.

Everyone agree?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85803</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-04-09 17:50:40 +0000</bug_when>
    <thetext>Sounds about right to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85805</commentid>
    <comment_count>9</comment_count>
    <who name="Justin Lebar">justin.lebar</who>
    <bug_when>2013-04-09 17:55:03 +0000</bug_when>
    <thetext>This doesn&apos;t quite match what Firefox does.

Suppose I add &lt;base href=&quot;foo&quot;&gt; and then add &lt;base href=&quot;bar&quot;&gt;.  Comment 7 suggests that the second base&apos;s href will be resolved immediately, relative to the first base&apos;s href.  But in fact the second base&apos;s href is not resolved until it becomes the first base!

  var base = document.createElement(&apos;base&apos;);
  base.href = &apos;foo&apos;;
  document.body.appendChild(base);

  var base2 = document.createElement(&apos;base&apos;);
  base2.href = &apos;bar&apos;;
  document.body.appendChild(base2);

  document.body.removeChild(base);

  console.log(document.baseURI); // prints &apos;bar&apos;, not &apos;foo/bar&apos;.

http://jsfiddle.net/rZfnY/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85807</commentid>
    <comment_count>10</comment_count>
    <who name="Justin Lebar">justin.lebar</who>
    <bug_when>2013-04-09 17:57:04 +0000</bug_when>
    <thetext>The testcase works the same if I replace &quot;foo&quot; and &quot;bar&quot; with &quot;foo/&quot; and &quot;bar/&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88471</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-05-30 21:51:30 +0000</bug_when>
    <thetext>I made a bigger testcase:
   http://www.hixie.ch/tests/adhoc/dom/level0/history/pushState/003.html

Looks like when a &lt;base&gt; becomes the relevant &lt;base&gt; (either by being inserted first, or by the only earlier &lt;base&gt; being removed), and when a &lt;base&gt; that is the relevant &lt;base&gt; gets its href=&quot;&quot; changed, its href=&quot;&quot; is to be resolved against the document URL, and that becomes the new document base URL.

That sound better?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88475</commentid>
    <comment_count>12</comment_count>
    <who name="Justin Lebar">justin.lebar</who>
    <bug_when>2013-05-30 22:06:45 +0000</bug_when>
    <thetext>&gt; That sound better?

Yes!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88493</commentid>
    <comment_count>13</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-31 02:03:37 +0000</bug_when>
    <thetext>Comment 11 matches what Gecko does, I believe.  See SetBaseURIUsingFirstBaseWithHref in http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/HTMLSharedElement.cpp</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89192</commentid>
    <comment_count>14</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-06-12 19:05:21 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7962.
Check-in comment: Make &lt;base&gt; elements not be affected by changes by to the document&apos;s address
http://html5.org/tools/web-apps-tracker?from=7961&amp;to=7962</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>