Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
replaceState cause back/forward malfunction on html page with <base h…
…ref="/"> tag https://bugs.webkit.org/show_bug.cgi?id=182678 <rdar://problem/37517821> Patch by Sihui Liu <sihui_liu@apple.com> on 2018-03-07 Reviewed by Chris Dumez. Source/WebCore: replaceState should not change URL when the URL argument is NULL, but should change URL when the URL argument is an empty string. Test: http/tests/history/replacestate-no-url.html * page/History.cpp: (WebCore::History::urlForState): LayoutTests: * http/tests/history/replacestate-no-url-expected.txt: Added. * http/tests/history/replacestate-no-url.html: Added. Add layout test coverage. * fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange-expected.txt: Rebaseline a layout test as empty string for URL is handled differently. Canonical link: https://commits.webkit.org/199083@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229375 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
97 additions
and 6 deletions.
- +15 −0 LayoutTests/ChangeLog
- +2 −1 LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange-expected.txt
- +18 −0 LayoutTests/http/tests/history/replacestate-no-url-expected.txt
- +44 −0 LayoutTests/http/tests/history/replacestate-no-url.html
- +15 −0 Source/WebCore/ChangeLog
- +3 −5 Source/WebCore/page/History.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,18 @@ | ||
Tests that ReplaceState should not change document URL if URL argument is null. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
Push item one | ||
Replace item one with null url | ||
Push item two | ||
Going back to item one | ||
PASS document.location.href is "http://127.0.0.1:8000/one" | ||
Replace item one with empty url | ||
Push item two | ||
Going back to item one | ||
PASS document.location.href is "http://127.0.0.1:8000/" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<base href="/"> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
jsTestIsAsync = true; | ||
description('Tests that ReplaceState should not change document URL if URL argument is null.'); | ||
|
||
function testNullUrl() { | ||
debug('Push item one'); | ||
history.pushState({}, 'page 1', '/one'); | ||
debug('Replace item one with null url'); | ||
history.replaceState({}, 'replaced page 1'); | ||
debug('Push item two'); | ||
history.pushState({}, 'page 2', '/two'); | ||
debug('Going back to item one'); | ||
history.back(); | ||
} | ||
|
||
function testEmptyUrl() { | ||
debug('Replace item one with empty url'); | ||
history.replaceState('StopEntry', 'replaced page 1 again', ''); | ||
debug('Push item two'); | ||
history.pushState({}, 'page 2', '/two'); | ||
debug('Going back to item one'); | ||
history.back(); | ||
} | ||
|
||
window.onpopstate = function(event) { | ||
if (event.state != 'StopEntry') { | ||
shouldBeEqualToString('document.location.href', 'http://127.0.0.1:8000/one'); | ||
setTimeout(testEmptyUrl, 0); | ||
} else { | ||
shouldBeEqualToString('document.location.href', 'http://127.0.0.1:8000/'); | ||
finishJSTest(); | ||
} | ||
} | ||
</script> | ||
</head> | ||
|
||
<body onload="testNullUrl()"> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters