mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 677260: Add specIgnoringRef and hasRef for URIs. r=bz, sr=biesi
This commit is contained in:
parent
e54f0564c3
commit
c1d7fc5bac
@ -202,6 +202,20 @@ nsNullPrincipalURI::GetSpec(nsACString &_spec)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// result may contain unescaped UTF-8 characters
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::GetSpecIgnoringRef(nsACString &result)
|
||||
{
|
||||
return GetSpec(result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::GetHasRef(PRBool *result)
|
||||
{
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::SetSpec(const nsACString &aSpec)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@
|
||||
*
|
||||
* The nsIURL methods operate on the <jar-entry> part of the spec.
|
||||
*/
|
||||
[scriptable, uuid(c95d481a-c0ec-43cc-8320-43842b1df597)]
|
||||
[scriptable, uuid(0d31634e-2fc9-4597-9d53-11fb3f05516a)]
|
||||
interface nsIJARURI : nsIURL {
|
||||
|
||||
/**
|
||||
|
@ -247,6 +247,20 @@ nsJARURI::GetSpec(nsACString &aSpec)
|
||||
return FormatSpec(entrySpec, aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetSpecIgnoringRef(nsACString &aSpec)
|
||||
{
|
||||
nsCAutoString entrySpec;
|
||||
mJAREntry->GetSpecIgnoringRef(entrySpec);
|
||||
return FormatSpec(entrySpec, aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetHasRef(PRBool *result)
|
||||
{
|
||||
return mJAREntry->GetHasRef(result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetSpec(const nsACString& aSpec)
|
||||
{
|
||||
|
@ -73,7 +73,7 @@
|
||||
* Description: The mime type we want an icon for. This is ignored by stock images.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b6a47fa0-2f1e-4084-ae5f-bdebab4d1cc3)]
|
||||
[scriptable, uuid(da53adda-cbe3-41bc-a57d-fdd7a0ff448b)]
|
||||
interface nsIMozIconURI : nsIURI
|
||||
{
|
||||
/**
|
||||
|
@ -145,6 +145,19 @@ nsMozIconURI::GetSpec(nsACString &aSpec)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMozIconURI::GetSpecIgnoringRef(nsACString &result)
|
||||
{
|
||||
return GetSpec(result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMozIconURI::GetHasRef(PRBool *result)
|
||||
{
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// takes a string like ?size=32&contentType=text/html and returns a new string
|
||||
// containing just the attribute value. i.e you could pass in this string with
|
||||
// an attribute name of 'size=', this will return 32
|
||||
|
@ -45,7 +45,7 @@ interface nsIFile;
|
||||
* an URL. The URL scheme need not be file:, since other local protocols may
|
||||
* map URLs to files (e.g., resource:).
|
||||
*/
|
||||
[scriptable, uuid(44c14c16-07b4-48fb-b44b-0c8986697a17)]
|
||||
[scriptable, uuid(93a4f94e-1dae-4056-ac4e-08e13691ee8e)]
|
||||
interface nsIFileURL : nsIURL
|
||||
{
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@
|
||||
* we will need to add additional checks there for all intermediate IIDs, until
|
||||
* nsPrincipal is fixed to serialize its URIs as nsISupports (bug 662693).
|
||||
*/
|
||||
[scriptable, uuid(12120b20-0929-40e9-88cf-6e08766e8b23)]
|
||||
[scriptable, uuid(395fe045-7d18-4adb-a3fd-af98c8a1af11)]
|
||||
interface nsIURI : nsISupports
|
||||
{
|
||||
/************************************************************************
|
||||
@ -272,4 +272,13 @@ interface nsIURI : nsISupports
|
||||
*/
|
||||
nsIURI cloneIgnoringRef();
|
||||
|
||||
/**
|
||||
* returns a string for the current URI with the ref element cleared.
|
||||
*/
|
||||
readonly attribute AUTF8String specIgnoringRef;
|
||||
|
||||
/**
|
||||
* Returns if there is a reference portion (the part after the "#") of the URI.
|
||||
*/
|
||||
readonly attribute boolean hasRef;
|
||||
};
|
||||
|
@ -54,7 +54,7 @@
|
||||
* |
|
||||
* filePath
|
||||
*/
|
||||
[scriptable, uuid(eab18ad5-e3be-4eb3-9c78-7d4e750200d6)]
|
||||
[scriptable, uuid(067d697a-c725-4293-9656-e658a75e6bcf)]
|
||||
interface nsIURL : nsIURI
|
||||
{
|
||||
/*************************************************************************
|
||||
|
@ -201,6 +201,21 @@ nsSimpleURI::GetSpec(nsACString &result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// result may contain unescaped UTF-8 characters
|
||||
NS_IMETHODIMP
|
||||
nsSimpleURI::GetSpecIgnoringRef(nsACString &result)
|
||||
{
|
||||
result = mScheme + NS_LITERAL_CSTRING(":") + mPath;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSimpleURI::GetHasRef(PRBool *result)
|
||||
{
|
||||
*result = mIsRefValid;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSimpleURI::SetSpec(const nsACString &aSpec)
|
||||
{
|
||||
|
@ -999,6 +999,21 @@ nsStandardURL::GetSpec(nsACString &result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// result may contain unescaped UTF-8 characters
|
||||
NS_IMETHODIMP
|
||||
nsStandardURL::GetSpecIgnoringRef(nsACString &result)
|
||||
{
|
||||
// URI without ref is 0 to one char before ref
|
||||
if (mRef.mLen >= 0) {
|
||||
URLSegment noRef(0, mRef.mPos - 1);
|
||||
|
||||
result = Segment(noRef);
|
||||
} else {
|
||||
result = mSpec;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// result may contain unescaped UTF-8 characters
|
||||
NS_IMETHODIMP
|
||||
nsStandardURL::GetPrePath(nsACString &result)
|
||||
@ -2144,6 +2159,13 @@ nsStandardURL::GetRef(nsACString &result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStandardURL::GetHasRef(PRBool *result)
|
||||
{
|
||||
*result = (mRef.mLen >= 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// result may contain unescaped UTF-8 characters
|
||||
NS_IMETHODIMP
|
||||
nsStandardURL::GetDirectory(nsACString &result)
|
||||
|
@ -306,6 +306,8 @@ var gTests = [
|
||||
prePath: "http://a",
|
||||
path: "/b/c/g?y",
|
||||
ref: "",// fix
|
||||
specIgnoringRef: "http://a/b/c/g?y",
|
||||
hasRef: false,
|
||||
nsIURL: true, nsINestedURI: false },
|
||||
{ spec: "http://a/b/c/d;p?q",
|
||||
relativeURI: "#s",
|
||||
@ -313,6 +315,8 @@ var gTests = [
|
||||
prePath: "http://a",
|
||||
path: "/b/c/d;p?q#s",
|
||||
ref: "s",// fix
|
||||
specIgnoringRef: "http://a/b/c/d;p?q",
|
||||
hasRef: true,
|
||||
nsIURL: true, nsINestedURI: false },
|
||||
{ spec: "http://a/b/c/d;p?q",
|
||||
relativeURI: "g#s",
|
||||
@ -688,6 +692,11 @@ function do_test_uri_basic(aTest) {
|
||||
do_check_property(aTest, URI, "username");
|
||||
do_check_property(aTest, URI, "password");
|
||||
do_check_property(aTest, URI, "host");
|
||||
do_check_property(aTest, URI, "specIgnoringRef");
|
||||
if ("hasRef" in aTest) {
|
||||
do_info("testing hasref: " + aTest.hasRef + " vs " + URI.hasRef);
|
||||
do_check_eq(aTest.hasRef, URI.hasRef);
|
||||
}
|
||||
}
|
||||
|
||||
// Test that a given URI parses correctly when we add a given ref to the end
|
||||
@ -728,6 +737,8 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
|
||||
" is equalExceptRef to self with '" + aSuffix + "' appended");
|
||||
do_check_uri_eqExceptRef(origURI, testURI);
|
||||
|
||||
do_check_eq(testURI.hasRef, true);
|
||||
|
||||
if (!origURI.ref) {
|
||||
// These tests fail if origURI has a ref
|
||||
do_info("testing cloneIgnoringRef on " + testURI.spec +
|
||||
|
Loading…
Reference in New Issue
Block a user