Closed Bug 600809 Opened 14 years ago Closed 14 years ago

Base href is repeated when reading JS ".href" attribute of the base tag

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- final+

People

(Reporter: BYK, Assigned: sicking)

References

Details

(Keywords: regression, testcase, Whiteboard: [ready to land])

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3
Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b6) Gecko/20100101 Firefox/4.0b6

When a <base href="somepath/somepath2/"> is defined on the page and when you access that base element with JavaScript and read its "href" property like document.getElementsByTagName('base')[0].href, it doubles the href. The expected value is "somepath/somepath2/" or "http://mydomain.com/somepath/somepath2" though the read value is "http://mydomain.com/somepath/somepath2/somepath/somepath2/".

Reading via the getAttribute method temporarily solves my problem since it reports the exact value defined in the href attribute.

Reproducible: Always

Steps to Reproduce:
1. Create a <base href="somepath/"> element in the head of your document
2. Access and read the href JavaScript property of this base element
Actual Results:  
See that the base href is repeated.

Expected Results:  
Expected result is the normal path to the base href.

This might be the case only with relative base href's though I have not tested it.

Also it seems that this problem also exists on the previous versions of Firefox like 3.6.
Can a base href actually be relative according to the spec?
"Note: The base URL must be an absolute URL!"

My bad. Sorry for disturbing everybody.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
(In reply to comment #1)
> Can a base href actually be relative according to the spec?

Yes in HTML5, although not in HTML4. See bug 553074
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Attached file testcase (obsolete) —
Blocks: 515401
Severity: minor → normal
Status: UNCONFIRMED → NEW
Component: General → DOM: Core & HTML
Ever confirmed: true
Keywords: testcase
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
blocking2.0: --- → ?
Keywords: regression
Assignee: nobody → jonas
blocking2.0: ? → final+
Attached patch Patch to fixSplinter Review
Trivial patch, just resolve against the document uri.
Attachment #479788 - Attachment is obsolete: true
Attachment #481157 - Flags: review?
Attachment #481157 - Flags: review? → review?(Olli.Pettay)
OS: Windows 7 → All
Hardware: x86 → All
Comment on attachment 481157 [details] [diff] [review]
Patch to fix

Could you add still some tests to verify that
::GetHref works properly after calling ::SetHref.
Attachment #481157 - Flags: review?(Olli.Pettay) → review+
Doesn't the included test-change do that?
Whiteboard: [ready to land]
Well, yes one variation. But perhaps you could add a check that it works
also with absolute urls... just to prevent regressions in the future.
Ah, yes, will add absolute urls as a test too.
Checked in, with additional test, thanks for the quick review

http://hg.mozilla.org/mozilla-central/rev/94f44cf059a6
Status: NEW → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: