RESOLVED DUPLICATE of bug 98184 47348
Update behaviour of href when document base URI is changed after href attribute has been set
https://bugs.webkit.org/show_bug.cgi?id=47348
Summary Update behaviour of href when document base URI is changed after href attribu...
Steve Block
Reported 2010-10-07 07:17:12 PDT
When href attributes are set from JavaScript, the href's URL is not correctly re-based when the document's base URL is changed. The problem is that when an href attribute is set, the href is updated to the absolute URL that is the result of resolving against the current base URL. When the base URL is updated and the href is re-resolved, the result is the same absolute URL. See, for example, HTMLAnchorElement::setSearch(). If the initial href is relative, it should remain relative after the attribute is set, so it can be correctly resolved against the new base URL.
Attachments
Test case (1.84 KB, text/plain)
2010-10-07 07:21 PDT, Steve Block
no flags
Steve Block
Comment 1 2010-10-07 07:21:30 PDT
Created attachment 70088 [details] Test case
Steve Block
Comment 2 2010-10-12 00:45:40 PDT
If somebody could confirm that this is indeed a bug and that we want to fix it, I'll provide a patch.
Adam Barth
Comment 3 2010-10-12 09:46:13 PDT
Can you provide a matrix of how other browsers behave on this test? That will let us figure out what behavior we'd like to adopt.
Steve Block
Comment 4 2010-10-13 05:48:10 PDT
I tried this on Chrome, Safari, FF 4 (FF 3 does not support updating the document base) and IE 8. All pass the first part of the test ... debug("Base case, rebase URL without attribute having been set"); base.href = "http://old_base/"; a.href = "foo?query"; shouldBe("a.href", "'http://old_base/foo?query'"); base.href = "http://new_base/"; shouldBe("a.href", "'http://new_base/foo?query'"); PASS a.href is http://old_base/foo?query PASS a.href is http://new_base/foo?query All fail the second part of the test in the same way - the href is not rebased ... debug("Rebase URL where search attribute has been set"); base.href = "http://old_base/"; a.href = "foo"; a.search = "query"; shouldBe("a.href", "'http://old_base/foo?query'"); base.href = "http://new_base/"; shouldBe("a.href", "'http://new_base/foo?query'"); PASS a.href is http://old_base/foo?query FAIL a.href should be http://new_base/foo?query, was http://old_base/foo?query I don't see anything in the spec - http://dev.w3.org/html5/spec/urls.html - which suggests that setting an attribute should make the href absolute and therefore not subject to changes to the document base URI.
Adam Barth
Comment 5 2010-10-13 09:32:18 PDT
> I tried this on Chrome, Safari, FF 4 (FF 3 does not support updating the document base) and IE 8. So, from these results, it looks like all the browsers already behave in the same way? It sounds like we shouldn't change anything then. > I don't see anything in the spec - http://dev.w3.org/html5/spec/urls.html - which suggests that setting an attribute should make the href absolute and therefore not subject to changes to the document base URI. That part of the spec needs a lot of love. Fixing that spec is on my list of thing to do. It seems like the right thing to here is to land these tests to document our behavior and update the spec to say what all the browsers do.
Steve Block
Comment 6 2010-10-13 09:35:51 PDT
> So, from these results, it looks like all the browsers already behave in the > same way? Correct. > It seems like the right thing to here is to land these tests to document our > behavior and update the spec to say what all the browsers do. OK, will do.
Steve Block
Comment 7 2010-10-14 05:17:40 PDT
This bug now tracks updating our behaviour to match the spec, once it's been fixed. The current behaviour will be documented through tests added in Bug 47665.
Erik Arvidsson
Comment 8 2012-10-03 08:36:37 PDT
Based on the tests for bug 47665, if a.search is set then the href should be "locked" to the current base. This contradicts comment 4: debug("Rebase URL where search attribute has been set"); base.href = "http://old_base/"; a.href = "foo"; a.search = "query"; shouldBe("a.href", "'http://old_base/foo?query'"); base.href = "http://new_base/"; shouldBe("a.href", "'http://new_base/foo?query'"); *** This bug has been marked as a duplicate of bug 98184 ***
Steve Block
Comment 9 2012-11-18 22:58:48 PST
I don't think there's a contradiction. The test case attached to the bug tests for the 'obvious' behavior, where the URL is re-based whether or not href attributes are set. It is this test case to which the results in #4 refer. The tests in Bug 47665 were added later, after Adam suggested we keep the existing behavior (where the URL is not re-based if href attributes are set) and add tests to document this.
Note You need to log in before you can comment on or make changes to this bug.