Bug 761278. Remove the non-standard uploadprogress event on XMLHttpRequest. r=sicking

This commit is contained in:
Boris Zbarsky 2012-07-21 22:28:26 -04:00
parent 8c936ae394
commit ace95218b3
13 changed files with 14 additions and 139 deletions

View File

@ -48,4 +48,3 @@ DEPRECATED_OPERATION(DOMExceptionCode)
DEPRECATED_OPERATION(NoExposedProps)
DEPRECATED_OPERATION(MutationEvent)
DEPRECATED_OPERATION(MozSlice)
DEPRECATED_OPERATION(Onuploadprogress)

View File

@ -395,22 +395,8 @@ interface nsIXHRSendable : nsISupports {
/**
* @deprecated
*/
[deprecated, scriptable, uuid(423fdd3d-41c9-4149-8fe5-b14a1d3912a0)]
[deprecated, scriptable, uuid(8ae70a39-edf1-40b4-a992-472d23421c25)]
interface nsIJSXMLHttpRequest : nsISupports {
/**
* Meant to be a script-only mechanism for setting an upload progress event
* listener.
* This attribute should not be used from native code!!
* This event listener may be called multiple times during the upload..
*
* After the initial response, all event listeners will be cleared.
* // XXXbz what does that mean, exactly?
*
* This event listener must be set BEFORE calling open().
*
* Mozilla only.
*/
attribute nsIDOMEventListener onuploadprogress;
};
%{ C++

View File

@ -90,7 +90,6 @@ using namespace mozilla::dom;
#define TIMEOUT_STR "timeout"
#define LOADSTART_STR "loadstart"
#define PROGRESS_STR "progress"
#define UPLOADPROGRESS_STR "uploadprogress"
#define READYSTATE_STR "readystatechange"
#define LOADEND_STR "loadend"
@ -619,7 +618,6 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsXMLHttpRequest)
NS_UNMARK_LISTENER_WRAPPER(LoadStart)
NS_UNMARK_LISTENER_WRAPPER(Progress)
NS_UNMARK_LISTENER_WRAPPER(Loadend)
NS_UNMARK_LISTENER_WRAPPER(UploadProgress)
NS_UNMARK_LISTENER_WRAPPER(Readystatechange)
}
if (!isBlack && tmp->PreservingWrapper()) {
@ -645,7 +643,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mResponseXML)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCORSPreflightChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnUploadProgressListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnReadystatechangeListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mXMLParserStreamListener)
@ -667,7 +664,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest,
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mResponseXML)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCORSPreflightChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnUploadProgressListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnReadystatechangeListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mXMLParserStreamListener)
@ -708,7 +704,6 @@ void
nsXMLHttpRequest::DisconnectFromOwner()
{
nsXHREventTarget::DisconnectFromOwner();
NS_DISCONNECT_EVENT_HANDLER(UploadProgress)
NS_DISCONNECT_EVENT_HANDLER(Readystatechange)
Abort();
}
@ -730,23 +725,6 @@ nsXMLHttpRequest::SetOnreadystatechange(nsIDOMEventListener * aOnreadystatechang
aOnreadystatechange);
}
NS_IMETHODIMP
nsXMLHttpRequest::GetOnuploadprogress(nsIDOMEventListener * *aOnuploadprogress)
{
return
nsXHREventTarget::GetInnerEventListener(mOnUploadProgressListener,
aOnuploadprogress);
}
NS_IMETHODIMP
nsXMLHttpRequest::SetOnuploadprogress(nsIDOMEventListener * aOnuploadprogress)
{
return
nsXHREventTarget::RemoveAddEventListener(NS_LITERAL_STRING(UPLOADPROGRESS_STR),
mOnUploadProgressListener,
aOnuploadprogress);
}
/* readonly attribute nsIChannel channel; */
NS_IMETHODIMP
nsXMLHttpRequest::GetChannel(nsIChannel **aChannel)
@ -1655,8 +1633,7 @@ nsXMLHttpRequest::DispatchProgressEvent(nsDOMEventTargetHelper* aTarget,
NS_ASSERTION(!aType.IsEmpty(), "missing event type");
if (NS_FAILED(CheckInnerWindowCorrectness()) ||
(!AllowUploadProgress() &&
(aTarget == mUpload || aType.EqualsLiteral(UPLOADPROGRESS_STR)))) {
(!AllowUploadProgress() && aTarget == mUpload)) {
return;
}
@ -1752,7 +1729,6 @@ nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
nsCAutoString method;
httpChannel->GetRequestMethod(method);
if (!mCORSUnsafeHeaders.IsEmpty() ||
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
(mUpload && mUpload->HasListeners()) ||
(!method.LowerCaseEqualsLiteral("get") &&
!method.LowerCaseEqualsLiteral("post") &&
@ -2820,7 +2796,6 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
// a progress event handler we must load with nsIRequest::LOAD_NORMAL or
// necko won't generate any progress notifications.
if (HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)) ||
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
(mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
nsLoadFlags loadFlags;
mChannel->GetLoadFlags(&loadFlags);
@ -3179,9 +3154,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
// can run script that would try to restart this request, and that could end
// up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
ChangeState(XML_HTTP_REQUEST_SENT);
if ((!mUploadComplete &&
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR))) ||
(mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
if (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR))) {
StartProgressEventTimer();
}
DispatchProgressEvent(this, NS_LITERAL_STRING(LOADSTART_STR), false,
@ -3722,10 +3695,6 @@ nsXMLHttpRequest::MaybeDispatchProgressEvents(bool aFinalProgress)
mUploadProgressMax = mUploadProgress;
mUploadLengthComputable = true;
}
DispatchProgressEvent(this, NS_LITERAL_STRING(UPLOADPROGRESS_STR),
true, mUploadLengthComputable, mUploadTransferred,
mUploadTotal, mUploadProgress,
mUploadProgressMax);
if (mUpload && !mUploadComplete) {
DispatchProgressEvent(mUpload, NS_LITERAL_STRING(PROGRESS_STR),
true, mUploadLengthComputable, mUploadTransferred,

View File

@ -217,10 +217,6 @@ public:
// nsIXMLHttpRequest
NS_DECL_NSIXMLHTTPREQUEST
// nsIJSXMLHttpRequest
NS_IMETHOD GetOnuploadprogress(nsIDOMEventListener** aOnuploadprogress);
NS_IMETHOD SetOnuploadprogress(nsIDOMEventListener* aOnuploadprogress);
NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
// nsIStreamListener
@ -253,24 +249,6 @@ public:
// event handler
IMPL_EVENT_HANDLER(readystatechange, Readystatechange)
JSObject* GetOnuploadprogress(JSContext* /* unused */)
{
nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : NULL;
if (doc) {
doc->WarnOnceAbout(nsIDocument::eOnuploadprogress);
}
return GetListenerAsJSObject(mOnUploadProgressListener);
}
void SetOnuploadprogress(JSContext* aCx, JSObject* aCallback,
ErrorResult& aRv)
{
nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : NULL;
if (doc) {
doc->WarnOnceAbout(nsIDocument::eOnuploadprogress);
}
aRv = SetJSObjectListener(aCx, NS_LITERAL_STRING("uploadprogress"),
mOnUploadProgressListener, aCallback);
}
// states
uint16_t GetReadyState();
@ -577,7 +555,6 @@ protected:
nsCOMPtr<nsIChannel> mCORSPreflightChannel;
nsTArray<nsCString> mCORSUnsafeHeaders;
nsRefPtr<nsDOMEventListenerWrapper> mOnUploadProgressListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnReadystatechangeListener;
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;

View File

@ -37,17 +37,10 @@ window.addEventListener("message", function(e) {
res.progressEvents++;
}, false);
if (req.uploadProgress) {
if (req.uploadProgress == "uploadProgress") {
xhr.addEventListener("uploadProgress", function(e) {
res.progressEvents++;
}, false);
}
else {
xhr.upload.addEventListener(req.uploadProgress, function(e) {
res.progressEvents++;
}, false);
}
}
xhr.onerror = function(e) {
res.didFail = true;
};

View File

@ -26,17 +26,10 @@ window.addEventListener("message", function(e) {\n\
res.progressEvents++;\n\
}, false);\n\
if (req.uploadProgress) {\n\
if (req.uploadProgress == "uploadProgress") {\n\
xhr.addEventListener("uploadProgress", function(e) {\n\
res.progressEvents++;\n\
}, false);\n\
}\n\
else {\n\
xhr.upload.addEventListener(req.uploadProgress, function(e) {\n\
res.progressEvents++;\n\
}, false);\n\
}\n\
}\n\
xhr.onerror = function(e) {\n\
res.didFail = true;\n\
};\n\

View File

@ -449,25 +449,12 @@ function runTest() {
},
// Progress events
{ pass: 1,
method: "POST",
body: "hi there",
headers: { "Content-Type": "text/plain" },
uploadProgress: "uploadprogress",
},
{ pass: 1,
method: "POST",
body: "hi there",
headers: { "Content-Type": "text/plain" },
uploadProgress: "progress",
},
{ pass: 0,
method: "POST",
body: "hi there",
headers: { "Content-Type": "text/plain" },
uploadProgress: "uploadprogress",
noAllowPreflight: 1,
},
{ pass: 0,
method: "POST",
body: "hi there",

View File

@ -27,12 +27,12 @@ function uploadprogress()
}
var xhr = new XMLHttpRequest();
xhr.onuploadprogress = uploadprogress;
xhr.upload.onprogress = uploadprogress;
var event = document.createEvent("ProgressEvent");
event.initProgressEvent("uploadprogress", false, false, false, false, 0);
xhr.dispatchEvent(event);
event.initProgressEvent("progress", false, false, false, false, 0);
xhr.upload.dispatchEvent(event);
ok(called,
"XMLHttpRequest.onuploadprogress sets uploadprogress event listener");
"XMLHttpRequest.upload.onprogress sets upload progress event listener");
</script>

View File

@ -105,7 +105,7 @@ function test(trusted, type, removeAddedListener, removeSetListener, allowUntrus
}
var events =
["load", "error", "progress", "uploadprogress", "readystatechange", "foo"];
["load", "error", "progress", "readystatechange", "foo"];
do {
var e = events.shift();

View File

@ -104,10 +104,6 @@ function start(obj) {
function (evt) {
logEvent(evt);
}
xhr.onuploadprogress =
function (evt) {
logEvent(evt);
}
if ("upload" in xhr) {
xhr.upload.onloadstart =
@ -277,7 +273,6 @@ var tests =
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: UPLOAD, type: "load", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
@ -294,7 +289,6 @@ var tests =
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false},
@ -303,7 +297,6 @@ var tests =
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false},
@ -313,7 +306,6 @@ var tests =
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: UPLOAD, type: "load", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
@ -330,7 +322,6 @@ var tests =
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false},
@ -339,7 +330,6 @@ var tests =
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false},
@ -349,7 +339,6 @@ var tests =
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: UPLOAD, type: "load", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
@ -366,7 +355,6 @@ var tests =
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false},
@ -375,7 +363,6 @@ var tests =
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false},

View File

@ -133,4 +133,3 @@ NoExposedPropsWarning=Exposing chrome JS objects to content without __exposedPro
MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver instead.
# LOCALIZATION NOTE: Do not translate "Blob", "mozSlice", or "slice"
MozSliceWarning=Use of mozSlice on the Blob object is deprecated. Use slice instead.
OnuploadprogressWarning=Use of XMLHttpRequest's onuploadprogress attribute is deprecated.

View File

@ -127,9 +127,6 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
void sendAsBinary(DOMString body);
any getInterface(IID iid);
[TreatNonCallableAsNull, GetterInfallible=MainThread]
attribute Function? onuploadprogress;
[Infallible]
readonly attribute boolean mozAnon;

View File

@ -97,18 +97,6 @@ public:
#undef IMPL_GETTER_AND_SETTER
JSObject*
GetOnuploadprogress(JSContext* /* unused */, ErrorResult& aRv)
{
aRv = NS_ERROR_NOT_IMPLEMENTED;
return NULL;
}
void
SetOnuploadprogress(JSContext* /* unused */, JSObject* aListener, ErrorResult& aRv)
{
aRv = NS_ERROR_NOT_IMPLEMENTED;
}
uint16_t
GetReadyState() const
{