[
https://issues.apache.org/jira/browse/CB-5694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13872004#comment-13872004
]
Ian Clelland commented on CB-5694:
----------------------------------
I just checked this in Cordova (dev branch), as well as with a stock WebView,
on 4.2.2 (emulator) and 4.4.2 (Nexus 7).
{code}
function testHistoryAPI() {
console.log(window.location.href);
window.location.hash = '#foo';
console.log(window.location.href);
window.location.replace('#bar');
console.log(window.location);
window.location.hash = '#baz';
console.log(window.location);
window.history.back(); // Test #1
//window.history.go(-1); // Test #2
//navigator.app.backHistory(); // Test #3
setTimeout(function() {
console.log(window.location);
}, 5000);
}
{code}
On 4.2.2, both Cordova and the stock WebView show this behaviour (final output
after timeout is "{{index.html#foo}}"), when using {{window.history}}.
On 4.2.2, Cordova's {{navigator.app.backHistory}} works properly, and ends at
"{{index.html#bar}}".
On 4.4.2, The WebView doesn't have this bug. window.history works correctly
(ends at "{{index.html#bar}}") in Cordova, and also with a stock WebView.
> location.replace does not behave as expected
> --------------------------------------------
>
> Key: CB-5694
> URL: https://issues.apache.org/jira/browse/CB-5694
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 3.1.0, 3.2.0, 3.3.0
> Environment: Tested on Android 4.1.2 Sony Xperia T
> Android 4.2.2 Samsung Galaxy S4
> Reporter: Clark Pan
> Assignee: Joe Bowser
> Priority: Minor
>
> Using location.replace should replace the current page with the specified
> page. This is not the case when using hash values.
> Steps to reproduce:
> 1. Create new cordova project
> 2. Add android
> 3. Run code similar to this after device ready
> {code:javascript}
> window.location.hash = '#foo';
> expect(window.location.hash).toBe('#foo');
> window.location.replace('#bar');
> expect(window.location.hash).toBe('#bar');
> window.location.hash = '#foobar';
> expect(window.location.hash).toBe('#foobar');
> window.history.back();
> setTimeout(function(){
> expect(window.location.hash).toBe('#bar');
> }, 0);
> {code}
> Expected results:
> All the expectations to be true
> Actual results:
> the last hash value will be '#foo'
> Workaround:
> One could shim location and history and provide their own implementation of
> history state.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)