mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 765468 - Use a dictionary for the argument to the XMLHttpRequest constructor; r=bz
This commit is contained in:
parent
7199ac064a
commit
56a3842ca1
@ -553,28 +553,36 @@ nsXMLHttpRequest::InitParameters(JSContext* aCx, const jsval* aParams)
|
|||||||
nsresult rv = params.Init(aCx, aParams);
|
nsresult rv = params.Init(aCx, aParams);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
InitParameters(params.mozAnon, params.mozSystem);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsXMLHttpRequest::InitParameters(bool aAnon, bool aSystem)
|
||||||
|
{
|
||||||
// Check for permissions.
|
// Check for permissions.
|
||||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(GetOwner());
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(GetOwner());
|
||||||
NS_ENSURE_TRUE(window && window->GetDocShell(), NS_OK);
|
if (!window || !window->GetDocShell()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Chrome is always allowed access, so do the permission check only
|
// Chrome is always allowed access, so do the permission check only
|
||||||
// for non-chrome pages.
|
// for non-chrome pages.
|
||||||
if (!nsContentUtils::IsCallerChrome()) {
|
if (!nsContentUtils::IsCallerChrome()) {
|
||||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
|
||||||
NS_ENSURE_TRUE(doc, NS_OK);
|
if (!doc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
doc->NodePrincipal()->GetURI(getter_AddRefs(uri));
|
doc->NodePrincipal()->GetURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
if (!nsContentUtils::URIIsChromeOrInPref(uri, "dom.systemXHR.whitelist")) {
|
if (!nsContentUtils::URIIsChromeOrInPref(uri, "dom.systemXHR.whitelist")) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsAnon = params.mozAnon;
|
mIsAnon = aAnon;
|
||||||
mIsSystem = params.mozSystem;
|
mIsSystem = aSystem;
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -182,7 +182,7 @@ public:
|
|||||||
static already_AddRefed<nsXMLHttpRequest>
|
static already_AddRefed<nsXMLHttpRequest>
|
||||||
Constructor(JSContext* aCx,
|
Constructor(JSContext* aCx,
|
||||||
nsISupports* aGlobal,
|
nsISupports* aGlobal,
|
||||||
const mozilla::dom::Optional<jsval>& aParams,
|
const mozilla::dom::Nullable<mozilla::dom::MozXMLHttpRequestParameters>& aParams,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
|
||||||
@ -194,12 +194,9 @@ public:
|
|||||||
|
|
||||||
nsRefPtr<nsXMLHttpRequest> req = new nsXMLHttpRequest();
|
nsRefPtr<nsXMLHttpRequest> req = new nsXMLHttpRequest();
|
||||||
req->Construct(principal->GetPrincipal(), window);
|
req->Construct(principal->GetPrincipal(), window);
|
||||||
if (aParams.WasPassed()) {
|
if (!aParams.IsNull()) {
|
||||||
nsresult rv = req->InitParameters(aCx, &aParams.Value());
|
const mozilla::dom::MozXMLHttpRequestParameters& params = aParams.Value();
|
||||||
if (NS_FAILED(rv)) {
|
req->InitParameters(params.mozAnon, params.mozSystem);
|
||||||
aRv.Throw(rv);
|
|
||||||
return req.forget();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return req.forget();
|
return req.forget();
|
||||||
}
|
}
|
||||||
@ -217,6 +214,7 @@ public:
|
|||||||
|
|
||||||
// Initialize XMLHttpRequestParameter object.
|
// Initialize XMLHttpRequestParameter object.
|
||||||
nsresult InitParameters(JSContext* aCx, const jsval* aParams);
|
nsresult InitParameters(JSContext* aCx, const jsval* aParams);
|
||||||
|
void InitParameters(bool aAnon, bool aSystem);
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ function runTests() {
|
|||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
let validParameters = [
|
let validParameters = [
|
||||||
|
undefined,
|
||||||
|
null,
|
||||||
{},
|
{},
|
||||||
{mozSystem: ""},
|
{mozSystem: ""},
|
||||||
{mozSystem: 0},
|
{mozSystem: 0},
|
||||||
@ -30,8 +32,12 @@ function runTests() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let invalidParameters = [
|
let invalidParameters = [
|
||||||
undefined,
|
0,
|
||||||
null,
|
7,
|
||||||
|
Math.PI,
|
||||||
|
"string",
|
||||||
|
true,
|
||||||
|
false,
|
||||||
{get mozSystem() { throw "Bla"; } },
|
{get mozSystem() { throw "Bla"; } },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -31,7 +31,27 @@ enum XMLHttpRequestResponseType {
|
|||||||
"moz-blob"
|
"moz-blob"
|
||||||
};
|
};
|
||||||
|
|
||||||
[Constructor(optional any params)]
|
/**
|
||||||
|
* Parameters for instantiating an XMLHttpRequest. They are passed as an
|
||||||
|
* optional argument to the constructor:
|
||||||
|
*
|
||||||
|
* new XMLHttpRequest({anon: true, system: true});
|
||||||
|
*/
|
||||||
|
dictionary MozXMLHttpRequestParameters
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* If true, the request will be sent without cookie and authentication
|
||||||
|
* headers.
|
||||||
|
*/
|
||||||
|
boolean mozAnon = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, the same origin policy will not be enforced on the request.
|
||||||
|
*/
|
||||||
|
boolean mozSystem = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
[Constructor(optional MozXMLHttpRequestParameters? params = null)]
|
||||||
interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||||
// event handler
|
// event handler
|
||||||
[TreatNonCallableAsNull] attribute Function? onreadystatechange;
|
[TreatNonCallableAsNull] attribute Function? onreadystatechange;
|
||||||
|
@ -1466,7 +1466,7 @@ XMLHttpRequest::_finalize(JSFreeOp* aFop)
|
|||||||
XMLHttpRequest*
|
XMLHttpRequest*
|
||||||
XMLHttpRequest::Constructor(JSContext* aCx,
|
XMLHttpRequest::Constructor(JSContext* aCx,
|
||||||
JSObject* aGlobal,
|
JSObject* aGlobal,
|
||||||
const Optional<jsval>& aParams,
|
const Nullable<MozXMLHttpRequestParametersWorkers>& aParams,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||||
|
@ -72,7 +72,8 @@ public:
|
|||||||
|
|
||||||
static XMLHttpRequest*
|
static XMLHttpRequest*
|
||||||
Constructor(JSContext* aCx, JSObject* aGlobal,
|
Constructor(JSContext* aCx, JSObject* aGlobal,
|
||||||
const Optional<jsval>& aParams, ErrorResult& aRv);
|
const Nullable<MozXMLHttpRequestParametersWorkers>& aParams,
|
||||||
|
ErrorResult& aRv);
|
||||||
void
|
void
|
||||||
Unpin();
|
Unpin();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user