mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 660066 patch 1: Null-check mPrincipal in nsFileDataURI::EqualsInternal. r=bz
This commit is contained in:
parent
c47ae25a87
commit
10cede3f4c
@ -257,15 +257,20 @@ nsFileDataURI::EqualsInternal(nsIURI* aOther,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = mPrincipal->Equals(otherFileDataUri->mPrincipal, aResult);
|
// Compare the member data that our base class knows about.
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (!nsSimpleURI::EqualsInternal(otherFileDataUri, aRefHandlingMode)) {
|
||||||
|
*aResult = PR_FALSE;
|
||||||
if (!*aResult) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nsSimpleURI::EqualsInternal(otherFileDataUri, aRefHandlingMode,
|
// Compare the piece of additional member data that we add to base class.
|
||||||
aResult);
|
if (mPrincipal && otherFileDataUri->mPrincipal) {
|
||||||
|
// Both of us have mPrincipals. Compare them.
|
||||||
|
return mPrincipal->Equals(otherFileDataUri->mPrincipal, aResult);
|
||||||
|
}
|
||||||
|
// else, at least one of us lacks a principal; only equal if *both* lack it.
|
||||||
|
*aResult = (!mPrincipal && !otherFileDataUri->mPrincipal);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIClassInfo methods:
|
// nsIClassInfo methods:
|
||||||
|
@ -125,6 +125,12 @@ var gTests = [
|
|||||||
path: "new%20Date()",
|
path: "new%20Date()",
|
||||||
ref: "",
|
ref: "",
|
||||||
nsIURL: false, nsINestedURI: false },
|
nsIURL: false, nsINestedURI: false },
|
||||||
|
{ spec: "moz-filedata:123456",
|
||||||
|
scheme: "moz-filedata",
|
||||||
|
prePath: "moz-filedata:",
|
||||||
|
path: "123456",
|
||||||
|
ref: "",
|
||||||
|
nsIURL: false, nsINestedURI: false, immutable: true },
|
||||||
{ spec: "place:redirectsMode=2&sort=8&maxResults=10",
|
{ spec: "place:redirectsMode=2&sort=8&maxResults=10",
|
||||||
scheme: "place",
|
scheme: "place",
|
||||||
prePath: "place:",
|
prePath: "place:",
|
||||||
@ -257,6 +263,20 @@ function do_test_uri_basic(aTest) {
|
|||||||
do_check_eq(URI instanceof Ci.nsINestedURI,
|
do_check_eq(URI instanceof Ci.nsINestedURI,
|
||||||
aTest.nsINestedURI);
|
aTest.nsINestedURI);
|
||||||
|
|
||||||
|
do_info("testing that " + aTest.spec + " throws or returns false " +
|
||||||
|
"from equals(null)");
|
||||||
|
// XXXdholbert At some point it'd probably be worth making this behavior
|
||||||
|
// (throwing vs. returning false) consistent across URI implementations.
|
||||||
|
var threw = false;
|
||||||
|
var isEqualToNull;
|
||||||
|
try {
|
||||||
|
isEqualToNull = URI.equals(null);
|
||||||
|
} catch(e) {
|
||||||
|
threw = true;
|
||||||
|
}
|
||||||
|
do_check_true(threw || !isEqualToNull);
|
||||||
|
|
||||||
|
|
||||||
// Check the various components
|
// Check the various components
|
||||||
do_check_property(aTest, URI, "scheme");
|
do_check_property(aTest, URI, "scheme");
|
||||||
do_check_property(aTest, URI, "prePath");
|
do_check_property(aTest, URI, "prePath");
|
||||||
|
Loading…
Reference in New Issue
Block a user