#399: fix 'null' Blobs, add isSameNode(), fix select element non-match bug

This commit is contained in:
Cameron Kaiser 2017-08-14 18:13:41 -07:00
parent e9cc6b1d37
commit e085a5b30e
5 changed files with 32 additions and 1 deletions

View File

@ -5973,6 +5973,26 @@ nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin)
NS_ENSURE_SUCCESS(rv, rv);
if (uri && uri != aURI) {
return GetUTFOrigin(uri, aOrigin);
}
} else {
// We are probably dealing with an unknown blob.
bool isBlob = false;
nsresult rv = aURI->SchemeIs(BLOBURI_SCHEME, &isBlob);
NS_ENSURE_SUCCESS(rv, rv);
if (isBlob) {
nsAutoCString path;
rv = aURI->GetPath(path);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), path);
if (NS_FAILED(rv)) {
aOrigin.AssignLiteral("null");
return NS_OK;
}
return GetUTFOrigin(uri, aOrigin);
}
}

View File

@ -968,6 +968,12 @@ nsINode::CompareDocumentPosition(nsINode& aOtherNode) const
nsIDOMNode::DOCUMENT_POSITION_CONTAINED_BY);
}
bool
nsINode::IsSameNode(nsINode *other)
{
return other == this;
}
bool
nsINode::IsEqualNode(nsINode* aOther)
{

View File

@ -1761,6 +1761,7 @@ public:
}
nsINode* RemoveChild(nsINode& aChild, mozilla::ErrorResult& aError);
already_AddRefed<nsINode> CloneNode(bool aDeep, mozilla::ErrorResult& aError);
bool IsSameNode(nsINode* aNode);
bool IsEqualNode(nsINode* aNode);
void GetNamespaceURI(nsAString& aNamespaceURI) const
{

View File

@ -1149,9 +1149,11 @@ HTMLSelectElement::SetValue(const nsAString& aValue)
option->GetValue(optionVal);
if (optionVal.Equals(aValue)) {
SetSelectedIndexInternal(int32_t(i), true);
break;
return NS_OK;
}
}
// No matching option was found.
SetSelectedIndexInternal(-1, true);
return NS_OK;
}

View File

@ -70,6 +70,8 @@ interface Node : EventTarget {
[Throws]
Node cloneNode(optional boolean deep = false);
[Pure]
boolean isSameNode(Node? node);
[Pure]
boolean isEqualNode(Node? node);
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;