Commit b3ab249e authored by beidson@apple.com's avatar beidson@apple.com

REGRESSION (r51644): WebCore/manual-tests/linkjump-1.html fails

<rdar://problem/7595694> and https://bugs.webkit.org/show_bug.cgi?id=34550

Reviewed by Alexey Proskuryakov.

WebCore: 

Tests: fast/loader/document-with-fragment-url-1.html
       fast/loader/document-with-fragment-url-2.html
       fast/loader/document-with-fragment-url-3.html
       fast/loader/document-with-fragment-url-4.html

* platform/KURL.cpp:
(WebCore::KURL::init): When resolving new URL from an empty reference relative to an absolute URL,
  any fragment identifier from the absolute URL should be removed from the resulting resolution.

LayoutTests: 

* fast/loader/document-with-fragment-url-1-expected.txt: Added.
* fast/loader/document-with-fragment-url-1.html: Added.
* fast/loader/document-with-fragment-url-2-expected.txt: Added.
* fast/loader/document-with-fragment-url-2.html: Added.
* fast/loader/document-with-fragment-url-3-expected.txt: Added.
* fast/loader/document-with-fragment-url-3.html: Added.
* fast/loader/document-with-fragment-url-4-expected.txt: Added.
* fast/loader/document-with-fragment-url-4.html: Added.
* fast/loader/resources/document-with-fragment-url-test.html: Added.



git-svn-id: svn://svn.chromium.org/blink/trunk@54321 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 742c9664
2010-02-03 Brady Eidson <beidson@apple.com>
Reviewed by Alexey Proskuryakov.
REGRESSION (r51644): WebCore/manual-tests/linkjump-1.html fails
<rdar://problem/7595694> and https://bugs.webkit.org/show_bug.cgi?id=34550
* fast/loader/document-with-fragment-url-1-expected.txt: Added.
* fast/loader/document-with-fragment-url-1.html: Added.
* fast/loader/document-with-fragment-url-2-expected.txt: Added.
* fast/loader/document-with-fragment-url-2.html: Added.
* fast/loader/document-with-fragment-url-3-expected.txt: Added.
* fast/loader/document-with-fragment-url-3.html: Added.
* fast/loader/document-with-fragment-url-4-expected.txt: Added.
* fast/loader/document-with-fragment-url-4.html: Added.
* fast/loader/resources/document-with-fragment-url-test.html: Added.
2010-02-03 Fumitoshi Ukai <ukai@chromium.org> 2010-02-03 Fumitoshi Ukai <ukai@chromium.org>
Reviewed by Alexey Proskuryakov. Reviewed by Alexey Proskuryakov.
......
ALERT: First load complete. URL's current hash is
ALERT: Hash changed to #foo
ALERT: Second load complete. URL's current hash is
Click the following link to navigate to #foo on this page. Then click the second link, which has an empty href and should take you back to the original URL without the #foo.
Click here to go to #foo
Click here to return to the original page with the original url
<script>
if (!sessionStorage.in_document_with_fragment_url_1)
sessionStorage.in_document_with_fragment_url_1 = true;
else
delete sessionStorage.in_document_with_fragment_url_1;
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function documentURLHash()
{
var index = document.URL.lastIndexOf("#");
if (index == -1)
return "";
return document.URL.substring(index);
}
function hashChanged()
{
alert("Hash changed to " + documentURLHash());
setTimeout("clickSecondAnchor();", 0);
}
function clickSecondAnchor()
{
var rect = document.getElementById("secondanchor").getBoundingClientRect();
eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
eventSender.mouseDown();
eventSender.mouseUp();
}
function loaded()
{
if (sessionStorage.in_document_with_fragment_url_1) {
alert("First load complete. URL's current hash is " + documentURLHash());
var rect = document.getElementById("firstanchor").getBoundingClientRect();
eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
eventSender.mouseDown();
eventSender.mouseUp();
} else {
alert("Second load complete. URL's current hash is " + documentURLHash());
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
<body onhashchange="hashChanged();" onload="loaded();">
Click the following link to navigate to #foo on this page. Then click the second link, which has an empty href and should take you back to the original URL without the #foo.<br>
<a id="firstanchor" href="#foo">Click here to go to #foo</a><br>
<div id="foo"><a id="secondanchor" href="">Click here to return to the original page with the original url</a></div>
</body>
ALERT: First load complete. URL's current hash is #foo
ALERT: Second load complete. URL's current hash is
Click here to go to the top of the page
This page should manually be loaded with "#foo" appended to the URL. When you then click the link, the page should navigate to the url without #foo.
<script>
if (window.layoutTestController) {
layoutTestController.waitUntilDone();
layoutTestController.dumpAsText();
}
location = "resources/document-with-fragment-url-test.html#foo";
</script>
ALERT: First load complete. URL's current hash is
ALERT: After pushState, the URL's current hash is #foo
ALERT: Second load complete. URL's current hash is
This page uses history.pushState() to add #foo to its URL. Then click the second link, which has an empty href and should take you back to the original URL without the #foo.
Click here to return to the original page with the original url
<script>
if (!sessionStorage.in_document_with_fragment_url_3)
sessionStorage.in_document_with_fragment_url_3 = true;
else
delete sessionStorage.in_document_with_fragment_url_3;
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function documentURLHash()
{
var index = document.URL.lastIndexOf("#");
if (index == -1)
return "";
return document.URL.substring(index);
}
function hashChanged()
{
alert("Hash changed to " + documentURLHash() + " which is interesting because we shouldn't get a hashchange event in this test.");
}
function loaded()
{
if (sessionStorage.in_document_with_fragment_url_3) {
alert("First load complete. URL's current hash is " + documentURLHash());
history.pushState(null, null, "#foo");
alert("After pushState, the URL's current hash is " + documentURLHash());
var rect = document.getElementById("clickanchor").getBoundingClientRect();
eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
eventSender.mouseDown();
eventSender.mouseUp();
} else {
alert("Second load complete. URL's current hash is " + documentURLHash());
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
<body onhashchange="hashChanged();" onload="loaded();">
This page uses history.pushState() to add #foo to its URL. Then click the second link, which has an empty href and should take you back to the original URL without the #foo.<br>
<a id="clickanchor" href="">Click here to return to the original page with the original url</a>
</body>
ALERT: First load complete. URL's current hash is
ALERT: After replaceState, the URL's current hash is #foo
ALERT: Second load complete. URL's current hash is
This page uses history.replaceState() to add #foo to its URL. Then click the second link, which has an empty href and should take you back to the original URL without the #foo.
Click here to return to the original page with the original url
<script>
if (!sessionStorage.in_document_with_fragment_url_4)
sessionStorage.in_document_with_fragment_url_4 = true;
else
delete sessionStorage.in_document_with_fragment_url_4;
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function documentURLHash()
{
var index = document.URL.lastIndexOf("#");
if (index == -1)
return "";
return document.URL.substring(index);
}
function hashChanged()
{
alert("Hash changed to " + documentURLHash() + " which is interesting because we shouldn't get a hashchange event in this test.");
}
function loaded()
{
if (sessionStorage.in_document_with_fragment_url_4) {
alert("First load complete. URL's current hash is " + documentURLHash());
history.replaceState(null, null, "#foo");
alert("After replaceState, the URL's current hash is " + documentURLHash());
var rect = document.getElementById("clickanchor").getBoundingClientRect();
eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
eventSender.mouseDown();
eventSender.mouseUp();
} else {
alert("Second load complete. URL's current hash is " + documentURLHash());
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
<body onhashchange="hashChanged();" onload="loaded();">
This page uses history.replaceState() to add #foo to its URL. Then click the second link, which has an empty href and should take you back to the original URL without the #foo.<br>
<a id="clickanchor" href="">Click here to return to the original page with the original url</a>
</body>
<script>
if (!sessionStorage.in_document_with_fragment_url_2)
sessionStorage.in_document_with_fragment_url_2 = true;
else
delete sessionStorage.in_document_with_fragment_url_2;
function documentURLHash()
{
var index = document.URL.lastIndexOf("#");
if (index == -1)
return "";
return document.URL.substring(index);
}
function hashChanged()
{
alert("hashChanged to " + documentURLHash() + " which is interesting because this particular test shouldn't generated a hashchange event");
}
function loaded()
{
if (sessionStorage.in_document_with_fragment_url_2) {
alert("First load complete. URL's current hash is " + documentURLHash());
var rect = document.getElementById("clickElement").getBoundingClientRect();
eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
eventSender.mouseDown();
eventSender.mouseUp();
} else {
alert("Second load complete. URL's current hash is " + documentURLHash());
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
<body onhashchange="hashChanged();" onload="loaded();">
<div id="foo"><a id="clickElement" href="">Click here to go to the top of the page</a></div><br>
This page should manually be loaded with "#foo" appended to the URL. When you then click the link, the page should navigate to the url without #foo.
</body>
2010-02-03 Brady Eidson <beidson@apple.com>
Reviewed by Alexey Proskuryakov.
REGRESSION (r51644): WebCore/manual-tests/linkjump-1.html fails
<rdar://problem/7595694> and https://bugs.webkit.org/show_bug.cgi?id=34550
Tests: fast/loader/document-with-fragment-url-1.html
fast/loader/document-with-fragment-url-2.html
fast/loader/document-with-fragment-url-3.html
fast/loader/document-with-fragment-url-4.html
* platform/KURL.cpp:
(WebCore::KURL::init): When resolving new URL from an empty reference relative to an absolute URL,
any fragment identifier from the absolute URL should be removed from the resulting resolution.
2010-02-03 Kwang Yul Seo <skyul@company100.net> 2010-02-03 Kwang Yul Seo <skyul@company100.net>
Reviewed by Eric Seidel. Reviewed by Eric Seidel.
......
...@@ -422,9 +422,9 @@ void KURL::init(const KURL& base, const String& relative, const TextEncoding& en ...@@ -422,9 +422,9 @@ void KURL::init(const KURL& base, const String& relative, const TextEncoding& en
switch (str[0]) { switch (str[0]) {
case '\0': case '\0':
// the reference must be empty - the RFC says this is a // The reference is empty, so this is a reference to the same document with any fragment identifier removed.
// reference to the same document
*this = base; *this = base;
removeFragmentIdentifier();
break; break;
case '#': { case '#': {
// must be fragment-only reference // must be fragment-only reference
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment