mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
9a431a3c46
- Bug 1054759 - Part 2: ES6 Symbol.unscopables. r=shu. (203f6a1c7a) - Bug 887016 - Part 6: Add RegExpPrototypeOptimizable. r=nbp (651d54bd7e) - Bug 887016 - Part 7: Add RegExpInstanceOptimizable. r=nbp (82701b3637) - Bug 887016 - Part 8: Add ObjectHasPrototype. r=nbp (8a9da8f9b8) - Bug 887016 - Part 9: Implement RegExp.prototype[@@match] and call it from String.prototype.match. r=till (9092676327) - Bug 887016 - Part 10: Implement RegExp.prototype[@@search] and call it from String.prototype.search. r=till (dcbd8beecb) - Bug 887016 - Part 11: Implement RegExp.prototype[@@replace] and call it from String.prototype.replace. r=h4writer,till (af2639291b) - Bug 887016 - Part 12: Implement RegExp[@@species] getter. r=evilpie,bholley (f512f802d9) - Bug 887016 - Part 13: Implement RegExp.prototype[@@split] and call it from String.prototype.split. r=h4writer,till (1fd28b046d) - Bug 887016 - Part 14: Add RegExpSearcher. r=h4writer (e5a02d6c03) - Bug 887016 - Part 15: Use RegExpSearcher in RegExp.prototype[@@replace] optimized path. r=till (4e04250fcc) - Bug 887016 - Part 16: Use RegExpSearcher in RegExp.prototype[@@searchâ] optimized path. r=till (742a1038f4) - Bug 887016 - Part 17: Mark sunspider/check-string-unpack-code.js timeout on cgc jittest. r=till (f80f8d69d5) - Bug 1251502 - Add a generic duplex resampler and a duplex WASAPI implementation. r=kinetik (5524ce1700) - Bug 1251502 - cubeb does not use cubeb-stdint.h anymore, remove it from moz.build. r=kinetik (76155cf9ee) - Bug 1259290: Part 1 - Remove unnecessary JS_ReportError calls. r=bz (1620f29a73) - Bug 1259290: Part 2 - Remove the cx from [Add|Remove]ChildWorker. r=bz (be70bd421e) - Bug 1259290: Part 3 - Remove JS_ReportError and cx handling from RegisterWorker and friends. r=bz,jandem (c646e0c7f3) - Bug 1259290: Part 4 - Remove JS_ReportError for a situation that can never happen. r=bz (ee012c8011) - Bug 1259290: Part 5 - Remove the cx from WorkerFeature::Notify. r=bz (79aff7ecb1) - Bug 1263490 - Part 1: Do not search for dollar if the length of replaceValue is 0 or 1. r=till (c88d75ff60) - Bug 1263341 - Check lastIndex in non-global replace. r=till (86d5e60a02) - Bug 1263851 - Check lastIndex after loop in RegExp.prototype[@@split]. r=till (70dc91fcf9) - Bug 1251529: In object metadata world, rename "object metadata" to "allocation metadata" and "callback" to "builder". r=fitzgen (fc8047d86d) - No bug - Add guards to tests that use TypedObject. r=me, a=bustage (87bda8c856) - Bug 1251922 - Do not create metadata objects for temporary parse globals; r=fitzgen (5b354f3cc4) - Bug 1251529: Replace allocation metadata callback with a builder class. r=fitzgen (520fb736fe) - Bug 1251529: Pass AutoEnterOOMUnsafeRegion to allocation metadata builder methods. r=fitzgen (6a2e6b05ac) - Bug 1251529: Provide default constructor for js::AllocationMetadataBuilder, js::SavedStacks::MetadataBuilder. r=shu (2300b6739c) - Bug 1251529: Provide default constructor for ShellAllocationMetadataBuilder. r=orange (24168aa011) - Bug 1259877 - Change js::DirectEval to take v/vp rather than a CallArgs to operate on directly. r=efaust (af03a24bde) - Bug 1259877 - Eliminate Invoke(JSContext*, const CallArgs&, MaybeConstruct = NO_CONSTRUCT) by 1) renaming it to a more-internal name, 2) adding an Invoke overload for existing InvokeArgs providers only, and 3) adding an InternalInvoke function to temporarily mark non-InvokeArgs places using the existing signature that will later be changed not to. r=efaust (7e4efa9129) - Bug 1259877 - Rename Invoke[GS]etter to Call[GS]etter, more in line with the spec's calling nomenclature. r=jorendorff (0b00a38913) - Bug 1259877 - Add CallFromStack for certain internal users, js::Call for general use, and mark js::Invoke as deprecated. r=efaust (56186b13fd) - Bug 1259877 - Add a bunch of Call overloads for 0/1/2 arguments with this as (HandleValue | JSObject*). r=jorendorff (ce764cca3a) - Bug 1259877 - Update Debugger code to use js::Call rather than Invoke. r=jorendorff (45f219d2f0) - Bug 1259877 - Update various miscellaneous function-calling code to js::Call. r=jandem (973c3c4171)
302 lines
6.5 KiB
C++
302 lines
6.5 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_dom_workers_xmlhttprequest_h__
|
|
#define mozilla_dom_workers_xmlhttprequest_h__
|
|
|
|
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
|
|
|
|
// Need this for XMLHttpRequestResponseType.
|
|
#include "mozilla/dom/XMLHttpRequestBinding.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "nsXMLHttpRequest.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
class Blob;
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
class Proxy;
|
|
class SendRunnable;
|
|
class XMLHttpRequestUpload;
|
|
class WorkerPrivate;
|
|
|
|
class XMLHttpRequest final: public nsXHREventTarget,
|
|
public WorkerFeature
|
|
{
|
|
public:
|
|
struct StateData
|
|
{
|
|
nsString mResponseText;
|
|
nsString mResponseURL;
|
|
uint32_t mStatus;
|
|
nsCString mStatusText;
|
|
uint16_t mReadyState;
|
|
JS::Heap<JS::Value> mResponse;
|
|
nsresult mResponseTextResult;
|
|
nsresult mStatusResult;
|
|
nsresult mResponseResult;
|
|
|
|
StateData()
|
|
: mStatus(0), mReadyState(0), mResponse(JS::UndefinedValue()),
|
|
mResponseTextResult(NS_OK), mStatusResult(NS_OK),
|
|
mResponseResult(NS_OK)
|
|
{ }
|
|
|
|
void trace(JSTracer* trc);
|
|
};
|
|
|
|
private:
|
|
RefPtr<XMLHttpRequestUpload> mUpload;
|
|
WorkerPrivate* mWorkerPrivate;
|
|
RefPtr<Proxy> mProxy;
|
|
XMLHttpRequestResponseType mResponseType;
|
|
StateData mStateData;
|
|
|
|
uint32_t mTimeout;
|
|
|
|
bool mRooted;
|
|
bool mBackgroundRequest;
|
|
bool mWithCredentials;
|
|
bool mCanceled;
|
|
|
|
bool mMozAnon;
|
|
bool mMozSystem;
|
|
|
|
public:
|
|
virtual JSObject*
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(XMLHttpRequest,
|
|
nsXHREventTarget)
|
|
|
|
nsISupports*
|
|
GetParentObject() const
|
|
{
|
|
// There's only one global on a worker, so we don't need to specify.
|
|
return nullptr;
|
|
}
|
|
|
|
static already_AddRefed<XMLHttpRequest>
|
|
Constructor(const GlobalObject& aGlobal,
|
|
const MozXMLHttpRequestParameters& aParams,
|
|
ErrorResult& aRv);
|
|
|
|
static already_AddRefed<XMLHttpRequest>
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& ignored,
|
|
ErrorResult& aRv)
|
|
{
|
|
// Pretend like someone passed null, so we can pick up the default values
|
|
MozXMLHttpRequestParameters params;
|
|
if (!params.Init(aGlobal.Context(), JS::NullHandleValue)) {
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
return nullptr;
|
|
}
|
|
|
|
return Constructor(aGlobal, params, aRv);
|
|
}
|
|
|
|
void
|
|
Unpin();
|
|
|
|
bool
|
|
Notify(Status aStatus) override;
|
|
|
|
IMPL_EVENT_HANDLER(readystatechange)
|
|
|
|
uint16_t
|
|
ReadyState() const
|
|
{
|
|
return mStateData.mReadyState;
|
|
}
|
|
|
|
void Open(const nsACString& aMethod, const nsAString& aUrl, ErrorResult& aRv)
|
|
{
|
|
Open(aMethod, aUrl, true, Optional<nsAString>(),
|
|
Optional<nsAString>(), aRv);
|
|
}
|
|
void
|
|
Open(const nsACString& aMethod, const nsAString& aUrl, bool aAsync,
|
|
const Optional<nsAString>& aUser, const Optional<nsAString>& aPassword,
|
|
ErrorResult& aRv);
|
|
|
|
void
|
|
SetRequestHeader(const nsACString& aHeader, const nsACString& aValue,
|
|
ErrorResult& aRv);
|
|
|
|
uint32_t
|
|
Timeout() const
|
|
{
|
|
return mTimeout;
|
|
}
|
|
|
|
void
|
|
SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
|
|
|
|
bool
|
|
WithCredentials() const
|
|
{
|
|
return mWithCredentials;
|
|
}
|
|
|
|
void
|
|
SetWithCredentials(bool aWithCredentials, ErrorResult& aRv);
|
|
|
|
bool
|
|
MozBackgroundRequest() const
|
|
{
|
|
return mBackgroundRequest;
|
|
}
|
|
|
|
void
|
|
SetMozBackgroundRequest(bool aBackgroundRequest, ErrorResult& aRv);
|
|
|
|
XMLHttpRequestUpload*
|
|
GetUpload(ErrorResult& aRv);
|
|
|
|
void
|
|
Send(ErrorResult& aRv);
|
|
|
|
void
|
|
Send(const nsAString& aBody, ErrorResult& aRv);
|
|
|
|
void
|
|
Send(JS::Handle<JSObject*> aBody, ErrorResult& aRv);
|
|
|
|
void
|
|
Send(Blob& aBody, ErrorResult& aRv);
|
|
|
|
void
|
|
Send(FormData& aBody, ErrorResult& aRv);
|
|
|
|
void
|
|
Send(const ArrayBuffer& aBody, ErrorResult& aRv);
|
|
|
|
void
|
|
Send(const ArrayBufferView& aBody, ErrorResult& aRv);
|
|
|
|
void
|
|
Abort(ErrorResult& aRv);
|
|
|
|
void
|
|
GetResponseURL(nsAString& aUrl) const
|
|
{
|
|
aUrl = mStateData.mResponseURL;
|
|
}
|
|
|
|
uint16_t
|
|
GetStatus(ErrorResult& aRv) const
|
|
{
|
|
aRv = mStateData.mStatusResult;
|
|
return mStateData.mStatus;
|
|
}
|
|
|
|
void
|
|
GetStatusText(nsACString& aStatusText) const
|
|
{
|
|
aStatusText = mStateData.mStatusText;
|
|
}
|
|
|
|
void
|
|
GetResponseHeader(const nsACString& aHeader, nsACString& aResponseHeader,
|
|
ErrorResult& aRv);
|
|
|
|
void
|
|
GetAllResponseHeaders(nsACString& aResponseHeaders, ErrorResult& aRv);
|
|
|
|
void
|
|
OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv);
|
|
|
|
XMLHttpRequestResponseType
|
|
ResponseType() const
|
|
{
|
|
return mResponseType;
|
|
}
|
|
|
|
void
|
|
SetResponseType(XMLHttpRequestResponseType aResponseType, ErrorResult& aRv);
|
|
|
|
void
|
|
GetResponse(JSContext* /* unused */, JS::MutableHandle<JS::Value> aResponse,
|
|
ErrorResult& aRv);
|
|
|
|
void
|
|
GetResponseText(nsAString& aResponseText, ErrorResult& aRv);
|
|
|
|
void
|
|
GetInterface(JSContext* cx, JS::Handle<JSObject*> aIID,
|
|
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv)
|
|
{
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
}
|
|
|
|
XMLHttpRequestUpload*
|
|
GetUploadObjectNoCreate() const
|
|
{
|
|
return mUpload;
|
|
}
|
|
|
|
void
|
|
UpdateState(const StateData& aStateData, bool aUseCachedArrayBufferResponse);
|
|
|
|
void
|
|
NullResponseText()
|
|
{
|
|
mStateData.mResponseText.SetIsVoid(true);
|
|
mStateData.mResponse.setNull();
|
|
}
|
|
|
|
bool MozAnon() const
|
|
{
|
|
return mMozAnon;
|
|
}
|
|
|
|
bool MozSystem() const
|
|
{
|
|
return mMozSystem;
|
|
}
|
|
|
|
bool
|
|
SendInProgress() const
|
|
{
|
|
return mRooted;
|
|
}
|
|
|
|
private:
|
|
explicit XMLHttpRequest(WorkerPrivate* aWorkerPrivate);
|
|
~XMLHttpRequest();
|
|
|
|
enum ReleaseType { Default, XHRIsGoingAway, WorkerIsGoingAway };
|
|
|
|
void
|
|
ReleaseProxy(ReleaseType aType = Default);
|
|
|
|
void
|
|
MaybePin(ErrorResult& aRv);
|
|
|
|
void
|
|
MaybeDispatchPrematureAbortEvents(ErrorResult& aRv);
|
|
|
|
void
|
|
DispatchPrematureAbortEvent(EventTarget* aTarget,
|
|
const nsAString& aEventType, bool aUploadTarget,
|
|
ErrorResult& aRv);
|
|
|
|
void
|
|
SendInternal(SendRunnable* aRunnable,
|
|
ErrorResult& aRv);
|
|
};
|
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
#endif // mozilla_dom_workers_xmlhttprequest_h__
|