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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>85881</bug_id>
          
          <creation_ts>2012-05-08 06:46:50 -0700</creation_ts>
          <short_desc>history not correct when performing multiple operations of altering location.hash and then location.replace</short_desc>
          <delta_ts>2021-03-31 09:05:27 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>History</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>OS X 10.7</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Joe Hudson">joehud</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>beidson</cc>
    
    <cc>eric</cc>
    
    <cc>fishd</cc>
    
    <cc>henrit</cc>
    
    <cc>japhet</cc>
    
    <cc>jjjaquanrice</cc>
    
    <cc>kpdecker</cc>
    
    <cc>m</cc>
    
    <cc>ryan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>618470</commentid>
    <comment_count>0</comment_count>
      <attachid>140706</attachid>
    <who name="Joe Hudson">joehud</who>
    <bug_when>2012-05-08 06:46:50 -0700</bug_when>
    <thetext>Created attachment 140706
unit test to demonstrate issue

When performing the following steps, the history is not correctly represented

location.hash = &apos;start&apos;;

location.hash = &apos;toBeReplaced&apos;;
location.replace(&apos;...#hash1&apos;);

location.hash = &apos;toBeReplaced&apos;;
location.replace(&apos;...#hash2&apos;);

history.back();

In this case, I would expect, after the back execution, the hash to be &apos;hash1&apos; but it ends up to be &apos;start&apos;;

Please see attached unit test.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>849351</commentid>
    <comment_count>1</comment_count>
    <who name="M. Dave Auayan">m</who>
    <bug_when>2013-03-06 15:12:14 -0800</bug_when>
    <thetext>This is kind of a strange bug, and I&apos;m not sure I understand what&apos;s happening.

If you use this:

location.hash = &apos;start&apos;;

location.hash = &apos;toBeReplaced&apos;;
location.replace(&apos;...#hash1&apos;);

location.hash = &apos;toBeReplaced-2&apos;; // &lt;-- different from your unit test instructions
location.replace(&apos;...#hash2&apos;);

history.back();

... you get back to &apos;toBeReplaced&apos;. 

I&apos;m kind of expecting it to be &apos;toBeReplaced-2&apos;, but maybe I&apos;m misunderstanding what the location.replace calls are doing. 

All 5 of those actions should introduce a new page in the history, no?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>849404</commentid>
    <comment_count>2</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2013-03-06 16:05:22 -0800</bug_when>
    <thetext>(In reply to comment #1)

&gt; All 5 of those actions should introduce a new page in the history, no?

Why don&apos;t you run the test in the browser one step at a time and inspect the back menu after each step?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>850396</commentid>
    <comment_count>3</comment_count>
    <who name="M. Dave Auayan">m</who>
    <bug_when>2013-03-07 12:57:31 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; 
&gt; &gt; All 5 of those actions should introduce a new page in the history, no?
&gt; 
&gt; Why don&apos;t you run the test in the browser one step at a time and inspect the back menu after each step?

I did the first time around and replicated what Joe is reporting, and ran it again with a different fragment for the third location.hash call and ended up with Yet Another Unexpected Result, hence the confusion. As suspected, I was wrong about what location.replace is supposed to do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>850400</commentid>
    <comment_count>4</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2013-03-07 12:59:15 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; (In reply to comment #1)
&gt; &gt; 
&gt; &gt; &gt; All 5 of those actions should introduce a new page in the history, no?
&gt; &gt; 
&gt; &gt; Why don&apos;t you run the test in the browser one step at a time and inspect the back menu after each step?
&gt; 
&gt; I did the first time around and replicated what Joe is reporting, and ran it again with a different fragment for the third location.hash call and ended up with Yet Another Unexpected Result, hence the confusion. As suspected, I was wrong about what location.replace is supposed to do.

Interesting datum we need is before deciding this is a bug that needs code changes are:
1 - What do other browsers do?
2 - What does the spec say?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>936018</commentid>
    <comment_count>5</comment_count>
    <who name="Henri T.">henrit</who>
    <bug_when>2013-10-03 16:07:49 -0700</bug_when>
    <thetext>
I can reproduce this bug on:
- Safari on an iPad 2 running iOS 6.1.3
- Chrome on a Galaxy Tab 2 10.1 running Android 4.1.1
- Chrome 29.0.1547.76m on windows 8 64bit
- Chrome 29.0.1547.76 on an intel mac mini running osx 10.8.4
- Safari 6.0.5 (8536.30.1) on the same osx 10.8.4 platform

I cannot reproduce this bug on:
- IE 10.0.9200.16688 on windows 8 64bit
- Firefox 24.0 on windows 8 64bit

The minimal steps to reproduce this bug are:

1. location.hash = &quot;#a         // history.length = n
2. location.hash = &quot;#b&quot;;       // history.length = n + 1
3. location.replace(&quot;#c&quot;);     // history.length = n + 1
4. location.hash = &quot;#b&quot;;       // history.length = n + 1 (!)
5. history.back();
// expected behavior: hash == &quot;#c&quot;. problem behavior: hash == &quot;#a&quot;

In practical terms, open a web console on any web page, and paste and run this line:

location.hash=&quot;#a&quot;; location.hash=&quot;#b&quot;; location.replace(&quot;#c&quot;); location.hash=&quot;#b&quot;; history.back()

If you end up with #a in your browser location bar, you have reproduced the problem.

Notes:
- history.length does not change when step 4. runs. 
- if step 4 is instead location.hash = &quot;#d&quot;;, the bug does not appear.
- Effectively, webkit partially behaves as if the current history entry was still &quot;#b&quot; when it is in fact &quot;#c&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1070931</commentid>
    <comment_count>6</comment_count>
      <attachid>247033</attachid>
    <who name="Dawn Brice">dawnelle.m.brice</who>
    <bug_when>2015-02-20 18:49:52 -0800</bug_when>
    <thetext>Created attachment 247033
history

Note</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>140706</attachid>
            <date>2012-05-08 06:46:50 -0700</date>
            <delta_ts>2012-05-08 06:46:50 -0700</delta_ts>
            <desc>unit test to demonstrate issue</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>2266</size>
            <attacher name="Joe Hudson">joehud</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEgVHJhbnNpdGlvbmFs
Ly9FTiIgCiAgICAgICAgICAgICAgICAgICAgImh0dHA6Ly93d3cudzMub3JnL1RSL2h0bWw0L2xv
b3NlLmR0ZCI+CjxodG1sPgo8aGVhZD4KICA8c2NyaXB0IHNyYz0iaHR0cDovL2NvZGUuanF1ZXJ5
LmNvbS9qcXVlcnktbGF0ZXN0LmpzIj48L3NjcmlwdD4KICA8bGluayByZWw9InN0eWxlc2hlZXQi
IGhyZWY9Imh0dHA6Ly9jb2RlLmpxdWVyeS5jb20vcXVuaXQvZ2l0L3F1bml0LmNzcyIgdHlwZT0i
dGV4dC9jc3MiIG1lZGlhPSJzY3JlZW4iIC8+CiAgPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3Jp
cHQiIHNyYz0iaHR0cDovL2NvZGUuanF1ZXJ5LmNvbS9xdW5pdC9naXQvcXVuaXQuanMiPjwvc2Ny
aXB0PgoKICA8c2NyaXB0PgogICAgdmFyIGxvYyA9IHdpbmRvdy5sb2NhdGlvbjsKICAgIGZ1bmN0
aW9uIGdvd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x
PgogIDxoMiBpZD0icXVuaXQtYmFubmVyIj48L2gyPgogIDxkaXYgaWQ9InF1bml0LXRlc3RydW5u
ZXItdG9vbGJhciI+PC9kaXY+CiAgPGgyIGlkPSJxdW5pdC11c2VyQWdlbnQiPjwvaDI+CiAgPG9s
IGlkPSJxdW5pdC10ZXN0cyI+PC9vbD4KICA8ZGl2IGlkPSJxdW5pdC1maXh0dXJlIj50ZXN0IG1h
cmt1cCwgd2lsbCBiZSBoaWRkZW48L2Rpdj4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>247033</attachid>
            <date>2015-02-20 18:49:52 -0800</date>
            <delta_ts>2015-02-24 19:38:17 -0800</delta_ts>
            <desc>history</desc>
            <filename>file_85881.txt</filename>
            <type>text/plain</type>
            <size>144</size>
            <attacher name="Dawn Brice">dawnelle.m.brice</attacher>
            
              <data encoding="base64">amF2YXNjcmlwdDpUVUlfdG9nZ2xlX2NsYXNzKCdhdHRhY2htZW50X3RleHRfZmllbGQnKTsgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqYXZhc2NyaXB0OlRVSV90
b2dnbGVfY2xhc3MoJ2F0dGFjaG1lbnRfZGF0YScp
</data>

          </attachment>
      

    </bug>

</bugzilla>