Bug 1266077. Fix <base> href getter to follow the spec; it should be using the fallback base URI to resolve against, not the document URI. r=bkelly

This commit is contained in:
Boris Zbarsky
2016-04-22 17:59:16 -04:00
parent cd5a65ec19
commit 063dcba8d2
6 changed files with 75 additions and 1 deletions

View File

@@ -61,13 +61,15 @@ NS_IMPL_STRING_ATTR(HTMLSharedElement, Target, target)
NS_IMETHODIMP
HTMLSharedElement::GetHref(nsAString& aValue)
{
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base),
"This should only get called for <base> elements");
nsAutoString href;
GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
nsCOMPtr<nsIURI> uri;
nsIDocument* doc = OwnerDoc();
nsContentUtils::NewURIWithDocumentCharset(
getter_AddRefs(uri), href, doc, doc->GetDocumentURI());
getter_AddRefs(uri), href, doc, doc->GetFallbackBaseURI());
if (!uri) {
aValue = href;