зеркало из https://github.com/mozilla/pjs.git
Merge mozilla-central into mozila-inbound
This commit is contained in:
Коммит
b6f090784e
|
@ -132,7 +132,7 @@ function downloadFile(url, cb, lastModified) {
|
|||
console.info("Using binary mode to download jar file.");
|
||||
req.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
}
|
||||
req.onreadystatechange = function(aEvt) {
|
||||
req.addEventListener("readystatechange", function(aEvt) {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200) {
|
||||
// check security channel:
|
||||
|
@ -154,7 +154,7 @@ function downloadFile(url, cb, lastModified) {
|
|||
cb(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
req.send();
|
||||
}
|
||||
|
||||
|
|
|
@ -846,7 +846,7 @@ TestPilotExperiment.prototype = {
|
|||
req.setRequestHeader("Content-type", "application/json");
|
||||
req.setRequestHeader("Content-length", dataString.length);
|
||||
req.setRequestHeader("Connection", "close");
|
||||
req.onreadystatechange = function(aEvt) {
|
||||
req.addEventListener("readystatechange", function(aEvt) {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200 || req.status == 201 || req.status == 202) {
|
||||
let location = req.getResponseHeader("Location");
|
||||
|
@ -887,7 +887,7 @@ TestPilotExperiment.prototype = {
|
|||
callback(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
req.send(dataString);
|
||||
});
|
||||
},
|
||||
|
@ -919,7 +919,7 @@ TestPilotExperiment.prototype = {
|
|||
req.setRequestHeader("Content-type", "application/json");
|
||||
req.setRequestHeader("Content-length", dataString.length);
|
||||
req.setRequestHeader("Connection", "close");
|
||||
req.onreadystatechange = function(aEvt) {
|
||||
req.addEventListener("readystatechange", function(aEvt) {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200 || req.status == 201 || req.status == 202) {
|
||||
logger.info("Quit reason posted successfully " + req.responseText);
|
||||
|
@ -933,7 +933,7 @@ TestPilotExperiment.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
logger.trace("Sending quit reason.");
|
||||
req.send(dataString);
|
||||
} else {
|
||||
|
@ -1069,7 +1069,7 @@ TestPilotBuiltinSurvey.prototype = {
|
|||
req.setRequestHeader("Content-type", "application/json");
|
||||
req.setRequestHeader("Content-length", params.length);
|
||||
req.setRequestHeader("Connection", "close");
|
||||
req.onreadystatechange = function(aEvt) {
|
||||
req.addEventListener("readystatechange", function(aEvt) {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200 || req.status == 201 ||
|
||||
req.status == 202) {
|
||||
|
@ -1099,7 +1099,7 @@ TestPilotBuiltinSurvey.prototype = {
|
|||
callback(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
req.send(params);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
|||
wcscpy(slash, L"crashinjectdll.dll");
|
||||
|
||||
// now find our target process
|
||||
HANDLE targetProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD,
|
||||
HANDLE targetProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
|
||||
FALSE,
|
||||
pid);
|
||||
if (targetProc == NULL) {
|
||||
|
|
|
@ -86,9 +86,60 @@ public:
|
|||
return static_cast<nsDOMEventTargetWrapperCache*>(target);
|
||||
}
|
||||
|
||||
void Init(JSContext* aCx = nsnull);
|
||||
|
||||
protected:
|
||||
nsDOMEventTargetWrapperCache() : nsDOMEventTargetHelper(), nsWrapperCache() {}
|
||||
virtual ~nsDOMEventTargetWrapperCache();
|
||||
};
|
||||
|
||||
#define NS_DECL_EVENT_HANDLER(_event) \
|
||||
public: \
|
||||
NS_IMETHOD GetOn##_event(JSContext *cx, jsval *vp); \
|
||||
NS_IMETHOD SetOn##_event(JSContext *cx, const jsval &vp);
|
||||
|
||||
#define NS_DECL_AND_IMPL_EVENT_HANDLER(_event) \
|
||||
public: \
|
||||
NS_IMPL_EVENT_HANDLER(_class, _event)
|
||||
|
||||
#define NS_IMPL_EVENT_HANDLER(_class, _event) \
|
||||
NS_IMETHODIMP \
|
||||
_class::GetOn##_event(JSContext *cx, jsval *vp) \
|
||||
{ \
|
||||
nsEventListenerManager* elm = GetListenerManager(PR_FALSE); \
|
||||
if (elm) { \
|
||||
elm->GetJSEventListener(nsGkAtoms::on##_event, vp); \
|
||||
} else { \
|
||||
*vp = JSVAL_NULL; \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::SetOn##_event(JSContext *cx, const jsval &vp) \
|
||||
{ \
|
||||
nsEventListenerManager* elm = GetListenerManager(PR_TRUE); \
|
||||
if (!elm) { \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
} \
|
||||
\
|
||||
JSObject *obj = GetWrapper(); \
|
||||
if (!obj) { \
|
||||
/* Just silently do nothing */ \
|
||||
return NS_OK; \
|
||||
} \
|
||||
return elm->SetJSEventListenerToJsval(nsGkAtoms::on##_event, cx, obj, vp);\
|
||||
}
|
||||
|
||||
#define NS_IMPL_FORWARD_EVENT_HANDLER(_class, _event, _baseclass) \
|
||||
NS_IMETHODIMP \
|
||||
_class::GetOn##_event(JSContext *cx, jsval *vp) \
|
||||
{ \
|
||||
return _baseclass::GetOn##_event(cx, vp); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::SetOn##_event(JSContext *cx, const jsval &vp) \
|
||||
{ \
|
||||
return _baseclass::SetOn##_event(cx, vp); \
|
||||
}
|
||||
|
||||
#endif // nsDOMEventTargetWrapperCache_h__
|
||||
|
|
|
@ -41,8 +41,8 @@ interface nsIDOMEventListener;
|
|||
interface nsIDOMBlob;
|
||||
interface nsIDOMFileError;
|
||||
|
||||
[scriptable, uuid(3d77e784-1459-4206-b8a2-0855d826f569)]
|
||||
interface nsIDOMFileReader : nsISupports
|
||||
[scriptable, builtinclass, uuid(57d68e17-85fa-4509-bf71-ffac1b22a174)]
|
||||
interface nsIDOMFileReader : nsIDOMEventTarget
|
||||
{
|
||||
[implicit_jscontext]
|
||||
void readAsArrayBuffer(in nsIDOMBlob filedata);
|
||||
|
@ -60,6 +60,13 @@ interface nsIDOMFileReader : nsISupports
|
|||
[implicit_jscontext]
|
||||
readonly attribute jsval result;
|
||||
readonly attribute nsIDOMFileError error;
|
||||
|
||||
[implicit_jscontext] attribute jsval onloadstart;
|
||||
[implicit_jscontext] attribute jsval onprogress;
|
||||
[implicit_jscontext] attribute jsval onload;
|
||||
[implicit_jscontext] attribute jsval onabort;
|
||||
[implicit_jscontext] attribute jsval onerror;
|
||||
[implicit_jscontext] attribute jsval onloadend;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -527,13 +527,8 @@ public:
|
|||
/**
|
||||
* Return the root element for this document.
|
||||
*/
|
||||
Element *GetRootElement() const
|
||||
{
|
||||
return (mCachedRootElement &&
|
||||
mCachedRootElement->GetNodeParent() == this) ?
|
||||
reinterpret_cast<Element*>(mCachedRootElement.get()) :
|
||||
GetRootElementInternal();
|
||||
}
|
||||
Element *GetRootElement() const;
|
||||
|
||||
protected:
|
||||
virtual Element *GetRootElementInternal() const = 0;
|
||||
|
||||
|
@ -1644,9 +1639,7 @@ protected:
|
|||
nsIDocument* mParentDocument;
|
||||
|
||||
// A reference to the element last returned from GetRootElement().
|
||||
// This should be an Element, but that would force us to pull in
|
||||
// Element.h and therefore nsIContent.h.
|
||||
nsCOMPtr<nsINode> mCachedRootElement;
|
||||
mozilla::dom::Element* mCachedRootElement;
|
||||
|
||||
// We'd like these to be nsRefPtrs, but that'd require us to include
|
||||
// additional headers that we don't want to expose.
|
||||
|
|
|
@ -51,7 +51,7 @@ interface nsIPrincipal;
|
|||
interface nsIScriptContext;
|
||||
interface nsPIDOMWindow;
|
||||
|
||||
[scriptable, uuid(755e2d2d-a836-4539-83f4-16b51156341f)]
|
||||
[scriptable, uuid(741374e9-39ed-4712-a380-93e023b271f8)]
|
||||
interface nsIEventSource : nsISupports
|
||||
{
|
||||
readonly attribute DOMString url;
|
||||
|
@ -63,9 +63,9 @@ interface nsIEventSource : nsISupports
|
|||
readonly attribute long readyState;
|
||||
|
||||
// event handler attributes
|
||||
attribute nsIDOMEventListener onopen;
|
||||
attribute nsIDOMEventListener onmessage;
|
||||
attribute nsIDOMEventListener onerror;
|
||||
[implicit_jscontext] attribute jsval onopen;
|
||||
[implicit_jscontext] attribute jsval onmessage;
|
||||
[implicit_jscontext] attribute jsval onerror;
|
||||
|
||||
/**
|
||||
* Close the connection, if any, and set the readyState attribute to CLOSED.
|
||||
|
|
|
@ -53,18 +53,18 @@ interface nsIDOMBlob;
|
|||
#include "jsapi.h"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(dea238a1-240f-45f4-9f07-7769bc69eb76)]
|
||||
[scriptable, builtinclass, uuid(8bc1357c-fe70-4741-a170-8fa50b6d23be)]
|
||||
interface nsIXMLHttpRequestEventTarget : nsIDOMEventTarget {
|
||||
// event handler attributes
|
||||
attribute nsIDOMEventListener onabort;
|
||||
attribute nsIDOMEventListener onerror;
|
||||
attribute nsIDOMEventListener onload;
|
||||
attribute nsIDOMEventListener onloadstart;
|
||||
attribute nsIDOMEventListener onprogress;
|
||||
attribute nsIDOMEventListener onloadend;
|
||||
[implicit_jscontext] attribute jsval onabort;
|
||||
[implicit_jscontext] attribute jsval onerror;
|
||||
[implicit_jscontext] attribute jsval onload;
|
||||
[implicit_jscontext] attribute jsval onloadstart;
|
||||
[implicit_jscontext] attribute jsval onprogress;
|
||||
[implicit_jscontext] attribute jsval onloadend;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(09ff3682-7759-4441-a765-f70e1a1fabcf)]
|
||||
[scriptable, builtinclass, uuid(cfa2d9fc-1871-444c-aaf9-8fc7fc7261d8)]
|
||||
interface nsIXMLHttpRequestUpload : nsIXMLHttpRequestEventTarget {
|
||||
// for future use
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ interface nsIXMLHttpRequestUpload : nsIXMLHttpRequestEventTarget {
|
|||
* you're aware of all the security implications. And then think twice about
|
||||
* it.
|
||||
*/
|
||||
[scriptable, uuid(5cf8d518-51d0-4cd6-a69a-c3674c2de599)]
|
||||
[scriptable, uuid(10d4701f-6351-4e9b-addd-ffdba05bd425)]
|
||||
interface nsIXMLHttpRequest : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -374,7 +374,7 @@ interface nsIXMLHttpRequest : nsISupports
|
|||
*
|
||||
* Call open() before setting an onreadystatechange listener.
|
||||
*/
|
||||
attribute nsIDOMEventListener onreadystatechange;
|
||||
[implicit_jscontext] attribute jsval onreadystatechange;
|
||||
};
|
||||
|
||||
[scriptable, uuid(840d0d00-e83e-4a29-b3c7-67e96e90a499)]
|
||||
|
@ -387,7 +387,7 @@ interface nsIXHRSendable : nsISupports {
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
[deprecated, scriptable, uuid(423fdd3d-41c9-4149-8fe5-b14a1d3912a0)]
|
||||
[deprecated, scriptable, uuid(58d2c633-2efd-45be-80ed-511dcd0407cc)]
|
||||
interface nsIJSXMLHttpRequest : nsISupports {
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting an upload progress event
|
||||
|
@ -402,7 +402,7 @@ interface nsIJSXMLHttpRequest : nsISupports {
|
|||
*
|
||||
* Mozilla only.
|
||||
*/
|
||||
attribute nsIDOMEventListener onuploadprogress;
|
||||
[implicit_jscontext] attribute jsval onuploadprogress;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -0,0 +1,300 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozila.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is the Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kyle Huey <me@kylehuey.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "FileIOObject.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMProgressEvent.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "xpcprivate.h"
|
||||
|
||||
#define ERROR_STR "error"
|
||||
#define ABORT_STR "abort"
|
||||
#define PROGRESS_STR "progress"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
const PRUint64 kUnknownSize = PRUint64(-1);
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(FileIOObject, nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(FileIOObject, nsDOMEventTargetWrapperCache)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileIOObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(FileIOObject)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(FileIOObject,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProgressNotifier)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(FileIOObject,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(FileIOObject, abort)
|
||||
NS_IMPL_EVENT_HANDLER(FileIOObject, error)
|
||||
NS_IMPL_EVENT_HANDLER(FileIOObject, progress)
|
||||
|
||||
FileIOObject::FileIOObject()
|
||||
: mProgressEventWasDelayed(PR_FALSE),
|
||||
mTimerIsActive(PR_FALSE),
|
||||
mReadyState(0),
|
||||
mTotal(0), mTransferred(0)
|
||||
{}
|
||||
|
||||
FileIOObject::~FileIOObject()
|
||||
{
|
||||
if (mListenerManager)
|
||||
mListenerManager->Disconnect();
|
||||
}
|
||||
|
||||
void
|
||||
FileIOObject::StartProgressEventTimer()
|
||||
{
|
||||
if (!mProgressNotifier) {
|
||||
mProgressNotifier = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
}
|
||||
if (mProgressNotifier) {
|
||||
mProgressEventWasDelayed = PR_FALSE;
|
||||
mTimerIsActive = PR_TRUE;
|
||||
mProgressNotifier->Cancel();
|
||||
mProgressNotifier->InitWithCallback(this, NS_PROGRESS_EVENT_INTERVAL,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FileIOObject::ClearProgressEventTimer()
|
||||
{
|
||||
mProgressEventWasDelayed = PR_FALSE;
|
||||
mTimerIsActive = PR_FALSE;
|
||||
if (mProgressNotifier) {
|
||||
mProgressNotifier->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FileIOObject::DispatchError(nsresult rv, nsAString& finalEvent)
|
||||
{
|
||||
// Set the status attribute, and dispatch the error event
|
||||
switch (rv) {
|
||||
case NS_ERROR_FILE_NOT_FOUND:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::NOT_FOUND_ERR);
|
||||
break;
|
||||
case NS_ERROR_FILE_ACCESS_DENIED:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::SECURITY_ERR);
|
||||
break;
|
||||
default:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::NOT_READABLE_ERR);
|
||||
break;
|
||||
}
|
||||
|
||||
// Dispatch error event to signify load failure
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(ERROR_STR));
|
||||
DispatchProgressEvent(finalEvent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
FileIOObject::DispatchProgressEvent(const nsAString& aType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv = nsEventDispatcher::CreateEvent(nsnull, nsnull,
|
||||
NS_LITERAL_STRING("ProgressEvent"),
|
||||
getter_AddRefs(event));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privevent(do_QueryInterface(event));
|
||||
NS_ENSURE_TRUE(privevent, NS_ERROR_UNEXPECTED);
|
||||
|
||||
privevent->SetTrusted(PR_TRUE);
|
||||
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
|
||||
NS_ENSURE_TRUE(progress, NS_ERROR_UNEXPECTED);
|
||||
|
||||
bool known;
|
||||
PRUint64 size;
|
||||
if (mTotal != kUnknownSize) {
|
||||
known = PR_TRUE;
|
||||
size = mTotal;
|
||||
} else {
|
||||
known = PR_FALSE;
|
||||
size = 0;
|
||||
}
|
||||
rv = progress->InitProgressEvent(aType, PR_FALSE, PR_FALSE, known,
|
||||
mTransferred, size);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DispatchDOMEvent(nsnull, event, nsnull, nsnull);
|
||||
}
|
||||
|
||||
// nsITimerCallback
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::Notify(nsITimer* aTimer)
|
||||
{
|
||||
nsresult rv;
|
||||
mTimerIsActive = PR_FALSE;
|
||||
|
||||
if (mProgressEventWasDelayed) {
|
||||
rv = DispatchProgressEvent(NS_LITERAL_STRING("progress"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
StartProgressEventTimer();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIStreamListener
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
return DoOnStartRequest(aRequest, aContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::DoOnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::OnDataAvailable(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsIInputStream *aInputStream,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = DoOnDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mTransferred += aCount;
|
||||
|
||||
//Notify the timer is the appropriate timeframe has passed
|
||||
if (mTimerIsActive) {
|
||||
mProgressEventWasDelayed = PR_TRUE;
|
||||
} else {
|
||||
rv = DispatchProgressEvent(NS_LITERAL_STRING(PROGRESS_STR));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
StartProgressEventTimer();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
|
||||
nsresult aStatus)
|
||||
{
|
||||
// If we're here as a result of a call from Abort(),
|
||||
// simply ignore the request.
|
||||
if (aRequest != mChannel)
|
||||
return NS_OK;
|
||||
|
||||
// Cancel the progress event timer
|
||||
ClearProgressEventTimer();
|
||||
|
||||
// FileIOObject must be in DONE stage after an operation
|
||||
mReadyState = 2;
|
||||
|
||||
nsString successEvent, termEvent;
|
||||
nsresult rv = DoOnStopRequest(aRequest, aContext, aStatus,
|
||||
successEvent, termEvent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set the status field as appropriate
|
||||
if (NS_FAILED(aStatus)) {
|
||||
DispatchError(aStatus, termEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Dispatch event to signify end of a successful operation
|
||||
DispatchProgressEvent(successEvent);
|
||||
DispatchProgressEvent(termEvent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::Abort()
|
||||
{
|
||||
if (mReadyState != 1)
|
||||
return NS_ERROR_DOM_FILE_ABORT_ERR;
|
||||
|
||||
ClearProgressEventTimer();
|
||||
|
||||
mReadyState = 2; // There are DONE constants on multiple interfaces,
|
||||
// but they all have value 2.
|
||||
mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR);
|
||||
|
||||
nsString finalEvent;
|
||||
nsresult rv = DoAbort(finalEvent);
|
||||
|
||||
// Dispatch the events
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
|
||||
DispatchProgressEvent(finalEvent);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::GetReadyState(PRUint16 *aReadyState)
|
||||
{
|
||||
*aReadyState = mReadyState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::GetError(nsIDOMFileError** aError)
|
||||
{
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,124 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozila.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is the Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kyle Huey <me@kylehuey.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef FileIOObject_h__
|
||||
#define FileIOObject_h__
|
||||
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsDOMEventTargetWrapperCache.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_PROGRESS_EVENT_INTERVAL 50
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
extern const PRUint64 kUnknownSize;
|
||||
|
||||
// A common base class for FileReader and FileSaver
|
||||
|
||||
class FileIOObject : public nsDOMEventTargetWrapperCache,
|
||||
public nsIStreamListener,
|
||||
public nsITimerCallback
|
||||
{
|
||||
public:
|
||||
FileIOObject();
|
||||
~FileIOObject();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Common methods
|
||||
NS_METHOD Abort();
|
||||
NS_METHOD GetReadyState(PRUint16* aReadyState);
|
||||
NS_METHOD GetError(nsIDOMFileError** aError);
|
||||
|
||||
NS_DECL_EVENT_HANDLER(abort);
|
||||
NS_DECL_EVENT_HANDLER(error);
|
||||
NS_DECL_EVENT_HANDLER(progress);
|
||||
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileIOObject,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
|
||||
protected:
|
||||
// Implemented by the derived class to do whatever it needs to do for abort
|
||||
NS_IMETHOD DoAbort(nsAString& aEvent) = 0;
|
||||
// for onStartRequest (this has a default impl since FileReader doesn't need
|
||||
// special handling
|
||||
NS_IMETHOD DoOnStartRequest(nsIRequest *aRequest, nsISupports *aContext);
|
||||
// for onStopRequest
|
||||
NS_IMETHOD DoOnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
|
||||
nsresult aStatus, nsAString& aSuccessEvent,
|
||||
nsAString& aTerminationEvent) = 0;
|
||||
// and for onDataAvailable
|
||||
NS_IMETHOD DoOnDataAvailable(nsIRequest *aRequest, nsISupports *aContext,
|
||||
nsIInputStream *aInputStream, PRUint32 aOffset,
|
||||
PRUint32 aCount) = 0;
|
||||
|
||||
void StartProgressEventTimer();
|
||||
void ClearProgressEventTimer();
|
||||
void DispatchError(nsresult rv, nsAString& finalEvent);
|
||||
nsresult DispatchProgressEvent(const nsAString& aType);
|
||||
|
||||
nsCOMPtr<nsITimer> mProgressNotifier;
|
||||
bool mProgressEventWasDelayed;
|
||||
bool mTimerIsActive;
|
||||
|
||||
nsCOMPtr<nsIDOMFileError> mError;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
||||
PRUint16 mReadyState;
|
||||
|
||||
PRUint64 mTotal;
|
||||
PRUint64 mTransferred;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -155,6 +155,7 @@ CPPSRCS = \
|
|||
nsInProcessTabChildGlobal.cpp \
|
||||
ThirdPartyUtil.cpp \
|
||||
nsEventSource.cpp \
|
||||
FileIOObject.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Are we targeting x86-32 or x86-64? If so, we want to include SSE2 code for
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsDOMEventTargetWrapperCache.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
|
||||
nsDOMEventTargetWrapperCache::~nsDOMEventTargetWrapperCache()
|
||||
{
|
||||
|
@ -69,3 +72,29 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
|||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMEventTargetWrapperCache, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMEventTargetWrapperCache, nsDOMEventTargetHelper)
|
||||
|
||||
void
|
||||
nsDOMEventTargetWrapperCache::Init(JSContext* aCx)
|
||||
{
|
||||
// Set the original mScriptContext and mPrincipal, if available
|
||||
JSContext* cx = aCx;
|
||||
if (!cx) {
|
||||
nsIJSContextStack* stack = nsContentUtils::ThreadJSContextStack();
|
||||
|
||||
if (!stack)
|
||||
return;
|
||||
|
||||
if (NS_FAILED(stack->Peek(&cx)) || !cx)
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(cx, "Should have returned earlier ...");
|
||||
nsIScriptContext* context = GetScriptContextFromJSContext(cx);
|
||||
if (context) {
|
||||
mScriptContext = context;
|
||||
nsCOMPtr<nsPIDOMWindow> window =
|
||||
do_QueryInterface(context->GetGlobalObject());
|
||||
if (window)
|
||||
mOwner = window->GetCurrentInnerWindow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,51 +72,43 @@
|
|||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "xpcquickstubs.h"
|
||||
#include "jstypedarray.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define LOAD_STR "load"
|
||||
#define ERROR_STR "error"
|
||||
#define ABORT_STR "abort"
|
||||
#define LOADSTART_STR "loadstart"
|
||||
#define PROGRESS_STR "progress"
|
||||
#define UPLOADPROGRESS_STR "uploadprogress"
|
||||
#define LOADEND_STR "loadend"
|
||||
|
||||
#define NS_PROGRESS_EVENT_INTERVAL 50
|
||||
const PRUint64 kUnknownSize = PRUint64(-1);
|
||||
using mozilla::dom::FileIOObject;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMFileReader)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMFileReader,
|
||||
nsXHREventTarget)
|
||||
FileIOObject)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFile)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProgressNotifier)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrincipal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannel)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileReader,
|
||||
nsXHREventTarget)
|
||||
FileIOObject)
|
||||
tmp->mResultArrayBuffer = nsnull;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFile)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPrincipal)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMFileReader,
|
||||
nsXHREventTarget)
|
||||
nsDOMEventTargetWrapperCache)
|
||||
if(tmp->mResultArrayBuffer) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mResultArrayBuffer,
|
||||
"mResultArrayBuffer")
|
||||
|
@ -127,17 +119,15 @@ DOMCI_DATA(FileReader, nsDOMFileReader)
|
|||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMFileReader)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFileReader)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICharsetDetectionObserver)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(FileReader)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
|
||||
NS_INTERFACE_MAP_END_INHERITING(FileIOObject)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMFileReader, nsXHREventTarget)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget)
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMFileReader, FileIOObject)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, FileIOObject)
|
||||
|
||||
void
|
||||
nsDOMFileReader::RootResultArrayBuffer()
|
||||
|
@ -161,10 +151,6 @@ nsDOMFileReader::Notify(const char *aCharset, nsDetectionConfident aConf)
|
|||
nsDOMFileReader::nsDOMFileReader()
|
||||
: mFileData(nsnull),
|
||||
mDataLen(0), mDataFormat(FILE_AS_BINARY),
|
||||
mReadyState(nsIDOMFileReader::EMPTY),
|
||||
mProgressEventWasDelayed(PR_FALSE),
|
||||
mTimerIsActive(PR_FALSE),
|
||||
mReadTotal(0), mReadTransferred(0),
|
||||
mResultArrayBuffer(nsnull)
|
||||
{
|
||||
nsLayoutStatics::AddRef();
|
||||
|
@ -173,9 +159,6 @@ nsDOMFileReader::nsDOMFileReader()
|
|||
|
||||
nsDOMFileReader::~nsDOMFileReader()
|
||||
{
|
||||
if (mListenerManager)
|
||||
mListenerManager->Disconnect();
|
||||
|
||||
FreeFileData();
|
||||
|
||||
nsLayoutStatics::Release();
|
||||
|
@ -184,20 +167,7 @@ nsDOMFileReader::~nsDOMFileReader()
|
|||
nsresult
|
||||
nsDOMFileReader::Init()
|
||||
{
|
||||
// Set the original mScriptContext and mPrincipal, if available.
|
||||
// Get JSContext from stack.
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
|
||||
if (!stack) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSContext *cx;
|
||||
|
||||
if (NS_FAILED(stack->Peek(&cx)) || !cx) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsDOMEventTargetWrapperCache::Init();
|
||||
|
||||
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
|
||||
nsCOMPtr<nsIPrincipal> subjectPrincipal;
|
||||
|
@ -206,21 +176,18 @@ nsDOMFileReader::Init()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_STATE(subjectPrincipal);
|
||||
mPrincipal = subjectPrincipal;
|
||||
|
||||
nsIScriptContext* context = GetScriptContextFromJSContext(cx);
|
||||
if (context) {
|
||||
mScriptContext = context;
|
||||
nsCOMPtr<nsPIDOMWindow> window =
|
||||
do_QueryInterface(context->GetGlobalObject());
|
||||
if (window) {
|
||||
mOwner = window->GetCurrentInnerWindow();
|
||||
}
|
||||
}
|
||||
mPrincipal.swap(subjectPrincipal);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(nsDOMFileReader, load)
|
||||
NS_IMPL_EVENT_HANDLER(nsDOMFileReader, loadstart)
|
||||
NS_IMPL_EVENT_HANDLER(nsDOMFileReader, loadend)
|
||||
NS_IMPL_FORWARD_EVENT_HANDLER(nsDOMFileReader, abort, FileIOObject)
|
||||
NS_IMPL_FORWARD_EVENT_HANDLER(nsDOMFileReader, progress, FileIOObject)
|
||||
NS_IMPL_FORWARD_EVENT_HANDLER(nsDOMFileReader, error, FileIOObject)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileReader::Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
|
||||
PRUint32 argc, jsval *argv)
|
||||
|
@ -257,8 +224,7 @@ nsDOMFileReader::GetInterface(const nsIID & aIID, void **aResult)
|
|||
NS_IMETHODIMP
|
||||
nsDOMFileReader::GetReadyState(PRUint16 *aReadyState)
|
||||
{
|
||||
*aReadyState = mReadyState;
|
||||
return NS_OK;
|
||||
return FileIOObject::GetReadyState(aReadyState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -284,8 +250,7 @@ nsDOMFileReader::GetResult(JSContext* aCx, jsval* aResult)
|
|||
NS_IMETHODIMP
|
||||
nsDOMFileReader::GetError(nsIDOMFileError** aError)
|
||||
{
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
return NS_OK;
|
||||
return FileIOObject::GetError(aError);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -316,25 +281,19 @@ nsDOMFileReader::ReadAsDataURL(nsIDOMBlob* aFile)
|
|||
NS_IMETHODIMP
|
||||
nsDOMFileReader::Abort()
|
||||
{
|
||||
if (mReadyState != nsIDOMFileReader::LOADING)
|
||||
return NS_ERROR_DOM_FILE_ABORT_ERR;
|
||||
return FileIOObject::Abort();
|
||||
}
|
||||
|
||||
//Clear progress and file data
|
||||
mProgressEventWasDelayed = PR_FALSE;
|
||||
mTimerIsActive = PR_FALSE;
|
||||
if (mProgressNotifier) {
|
||||
mProgressNotifier->Cancel();
|
||||
}
|
||||
|
||||
//Revert status, result and readystate attributes
|
||||
nsresult
|
||||
nsDOMFileReader::DoAbort(nsAString& aEvent)
|
||||
{
|
||||
// Revert status and result attributes
|
||||
SetDOMStringToNull(mResult);
|
||||
mResultArrayBuffer = nsnull;
|
||||
mReadyState = nsIDOMFileReader::DONE;
|
||||
mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR);
|
||||
|
||||
//Non-null channel indicates a read is currently active
|
||||
// Non-null channel indicates a read is currently active
|
||||
if (mChannel) {
|
||||
//Cancel request requires an error status
|
||||
// Cancel request requires an error status
|
||||
mChannel->Cancel(NS_ERROR_FAILURE);
|
||||
mChannel = nsnull;
|
||||
}
|
||||
|
@ -343,48 +302,8 @@ nsDOMFileReader::Abort()
|
|||
//Clean up memory buffer
|
||||
FreeFileData();
|
||||
|
||||
//Dispatch the abort event
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
|
||||
|
||||
mReadyState = nsIDOMFileReader::EMPTY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsITimerCallback
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileReader::Notify(nsITimer* aTimer)
|
||||
{
|
||||
mTimerIsActive = PR_FALSE;
|
||||
if (mProgressEventWasDelayed) {
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(PROGRESS_STR));
|
||||
StartProgressEventTimer();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMFileReader::StartProgressEventTimer()
|
||||
{
|
||||
if (!mProgressNotifier) {
|
||||
mProgressNotifier = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
}
|
||||
if (mProgressNotifier) {
|
||||
mProgressEventWasDelayed = PR_FALSE;
|
||||
mTimerIsActive = PR_TRUE;
|
||||
mProgressNotifier->Cancel();
|
||||
mProgressNotifier->InitWithCallback(this, NS_PROGRESS_EVENT_INTERVAL,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
}
|
||||
|
||||
// nsIStreamListener
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileReader::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
// Tell the base class which event to dispatch
|
||||
aEvent = NS_LITERAL_STRING(LOADEND_STR);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -410,12 +329,12 @@ ReadFuncBinaryString(nsIInputStream* in,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileReader::OnDataAvailable(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsIInputStream *aInputStream,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
nsresult
|
||||
nsDOMFileReader::DoOnDataAvailable(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsIInputStream *aInputStream,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
{
|
||||
if (mDataFormat == FILE_AS_BINARY) {
|
||||
//Continuously update our binary string as data comes in
|
||||
|
@ -451,44 +370,22 @@ nsDOMFileReader::OnDataAvailable(nsIRequest *aRequest,
|
|||
mDataLen += aCount;
|
||||
}
|
||||
|
||||
mReadTransferred += aCount;
|
||||
|
||||
//Notify the timer is the appropriate timeframe has passed
|
||||
if (mTimerIsActive) {
|
||||
mProgressEventWasDelayed = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(PROGRESS_STR));
|
||||
StartProgressEventTimer();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsresult aStatus)
|
||||
nsresult
|
||||
nsDOMFileReader::DoOnStopRequest(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsresult aStatus,
|
||||
nsAString& aSuccessEvent,
|
||||
nsAString& aTerminationEvent)
|
||||
{
|
||||
//If we're here as a result of a call from Abort(),
|
||||
//simply ignore the request.
|
||||
if (aRequest != mChannel)
|
||||
return NS_OK;
|
||||
aSuccessEvent = NS_LITERAL_STRING(LOAD_STR);
|
||||
aTerminationEvent = NS_LITERAL_STRING(LOADEND_STR);
|
||||
|
||||
//Cancel the progress event timer
|
||||
mProgressEventWasDelayed = PR_FALSE;
|
||||
mTimerIsActive = PR_FALSE;
|
||||
if (mProgressNotifier) {
|
||||
mProgressNotifier->Cancel();
|
||||
}
|
||||
|
||||
//FileReader must be in DONE stage after a load
|
||||
mReadyState = nsIDOMFileReader::DONE;
|
||||
|
||||
//Set the status field as appropriate
|
||||
// Clear out the data if necessary
|
||||
if (NS_FAILED(aStatus)) {
|
||||
FreeFileData();
|
||||
DispatchError(aStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -510,16 +407,7 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
|
|||
|
||||
FreeFileData();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchError(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//Dispatch load event to signify end of a successful load
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(LOAD_STR));
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
@ -537,8 +425,8 @@ nsDOMFileReader::ReadFileContent(JSContext* aCx,
|
|||
Abort();
|
||||
mError = nsnull;
|
||||
SetDOMStringToNull(mResult);
|
||||
mReadTransferred = 0;
|
||||
mReadTotal = 0;
|
||||
mTransferred = 0;
|
||||
mTotal = 0;
|
||||
mReadyState = nsIDOMFileReader::EMPTY;
|
||||
FreeFileData();
|
||||
|
||||
|
@ -562,8 +450,8 @@ nsDOMFileReader::ReadFileContent(JSContext* aCx,
|
|||
}
|
||||
|
||||
//Obtain the total size of the file before reading
|
||||
mReadTotal = kUnknownSize;
|
||||
mFile->GetSize(&mReadTotal);
|
||||
mTotal = mozilla::dom::kUnknownSize;
|
||||
mFile->GetSize(&mTotal);
|
||||
|
||||
rv = mChannel->AsyncOpen(this, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -574,7 +462,7 @@ nsDOMFileReader::ReadFileContent(JSContext* aCx,
|
|||
|
||||
if (mDataFormat == FILE_AS_ARRAYBUFFER) {
|
||||
RootResultArrayBuffer();
|
||||
mResultArrayBuffer = js_CreateArrayBuffer(aCx, mReadTotal);
|
||||
mResultArrayBuffer = js_CreateArrayBuffer(aCx, mTotal);
|
||||
if (!mResultArrayBuffer) {
|
||||
NS_WARNING("Failed to create JS array buffer");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -584,64 +472,6 @@ nsDOMFileReader::ReadFileContent(JSContext* aCx,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMFileReader::DispatchError(nsresult rv)
|
||||
{
|
||||
//Set the status attribute, and dispatch the error event
|
||||
switch (rv) {
|
||||
case NS_ERROR_FILE_NOT_FOUND:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::NOT_FOUND_ERR);
|
||||
break;
|
||||
case NS_ERROR_FILE_ACCESS_DENIED:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::SECURITY_ERR);
|
||||
break;
|
||||
default:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::NOT_READABLE_ERR);
|
||||
break;
|
||||
}
|
||||
|
||||
//Dispatch error event to signify load failure
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(ERROR_STR));
|
||||
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMFileReader::DispatchProgressEvent(const nsAString& aType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv = nsEventDispatcher::CreateEvent(nsnull, nsnull,
|
||||
NS_LITERAL_STRING("ProgressEvent"),
|
||||
getter_AddRefs(event));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privevent(do_QueryInterface(event));
|
||||
|
||||
if (!privevent)
|
||||
return;
|
||||
|
||||
privevent->SetTrusted(PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
|
||||
|
||||
if (!progress)
|
||||
return;
|
||||
|
||||
bool known;
|
||||
PRUint64 size;
|
||||
if (mReadTotal != kUnknownSize) {
|
||||
known = PR_TRUE;
|
||||
size = mReadTotal;
|
||||
} else {
|
||||
known = PR_FALSE;
|
||||
size = 0;
|
||||
}
|
||||
progress->InitProgressEvent(aType, PR_FALSE, PR_FALSE, known,
|
||||
mReadTransferred, size);
|
||||
|
||||
this->DispatchDOMEvent(nsnull, event, nsnull, nsnull);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMFileReader::GetAsText(const nsACString &aCharset,
|
||||
const char *aFileData,
|
||||
|
|
|
@ -39,16 +39,15 @@
|
|||
#define nsDOMFileReader_h__
|
||||
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "prtime.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsICharsetDetectionObserver.h"
|
||||
|
||||
|
@ -62,15 +61,13 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsXMLHttpRequest.h"
|
||||
#include "FileIOObject.h"
|
||||
|
||||
class nsDOMFileReader : public nsXHREventTarget,
|
||||
class nsDOMFileReader : public mozilla::dom::FileIOObject,
|
||||
public nsIDOMFileReader,
|
||||
public nsIStreamListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIJSNativeInitializer,
|
||||
public nsITimerCallback,
|
||||
public nsICharsetDetectionObserver
|
||||
{
|
||||
public:
|
||||
|
@ -81,35 +78,31 @@ public:
|
|||
|
||||
NS_DECL_NSIDOMFILEREADER
|
||||
|
||||
NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::);
|
||||
|
||||
// nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
// nsIRequestObserver
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// nsITimerCallback
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
|
||||
PRUint32 argc, jsval* argv);
|
||||
|
||||
NS_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget::)
|
||||
|
||||
// nsICharsetDetectionObserver
|
||||
NS_IMETHOD Notify(const char *aCharset, nsDetectionConfident aConf);
|
||||
|
||||
void DispatchProgressEvent(const nsAString& aType);
|
||||
// FileIOObject overrides
|
||||
NS_IMETHOD DoAbort(nsAString& aEvent);
|
||||
NS_IMETHOD DoOnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
|
||||
nsresult aStatus, nsAString& aSuccessEvent,
|
||||
nsAString& aTerminationEvent);
|
||||
NS_IMETHOD DoOnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
|
||||
nsIInputStream* aInputStream, PRUint32 aOffset,
|
||||
PRUint32 aCount);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMFileReader,
|
||||
nsXHREventTarget)
|
||||
FileIOObject)
|
||||
void RootResultArrayBuffer();
|
||||
|
||||
protected:
|
||||
|
@ -126,8 +119,6 @@ protected:
|
|||
nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, PRUint32 aDataLen, nsAString &aResult);
|
||||
nsresult GuessCharset(const char *aFileData, PRUint32 aDataLen, nsACString &aCharset);
|
||||
nsresult ConvertStream(const char *aFileData, PRUint32 aDataLen, const char *aCharset, nsAString &aResult);
|
||||
void DispatchError(nsresult rv);
|
||||
void StartProgressEventTimer();
|
||||
|
||||
void FreeFileData() {
|
||||
PR_Free(mFileData);
|
||||
|
@ -143,18 +134,7 @@ protected:
|
|||
eDataFormat mDataFormat;
|
||||
|
||||
nsString mResult;
|
||||
PRUint16 mReadyState;
|
||||
|
||||
bool mProgressEventWasDelayed;
|
||||
bool mTimerIsActive;
|
||||
nsCOMPtr<nsIDOMFileError> mError;
|
||||
|
||||
nsCOMPtr<nsITimer> mProgressNotifier;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
||||
PRUint64 mReadTotal;
|
||||
PRUint64 mReadTransferred;
|
||||
|
||||
JSObject* mResultArrayBuffer;
|
||||
};
|
||||
|
|
|
@ -1825,7 +1825,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
|
|||
}
|
||||
|
||||
// Traverse all nsIDocument pointer members.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedRootElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSecurityInfo)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDisplayDocument)
|
||||
|
||||
|
@ -1906,7 +1905,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
|||
tmp->mFirstChild = nsnull;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mXPathEvaluatorTearoff)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedRootElement)
|
||||
tmp->mCachedRootElement = nsnull; // Avoid a dangling pointer
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDisplayDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBaseNodeWithHref)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDOMImplementation)
|
||||
|
@ -3396,6 +3395,13 @@ nsDocument::NodeName(nsAString& aNodeName)
|
|||
aNodeName.AssignLiteral("#document");
|
||||
}
|
||||
|
||||
Element*
|
||||
nsIDocument::GetRootElement() const
|
||||
{
|
||||
return (mCachedRootElement && mCachedRootElement->GetNodeParent() == this) ?
|
||||
mCachedRootElement : GetRootElementInternal();
|
||||
}
|
||||
|
||||
Element*
|
||||
nsDocument::GetRootElementInternal() const
|
||||
{
|
||||
|
@ -3405,7 +3411,7 @@ nsDocument::GetRootElementInternal() const
|
|||
for (i = mChildren.ChildCount(); i > 0; --i) {
|
||||
nsIContent* child = mChildren.ChildAt(i - 1);
|
||||
if (child->IsElement()) {
|
||||
const_cast<nsDocument*>(this)->mCachedRootElement = child;
|
||||
const_cast<nsDocument*>(this)->mCachedRootElement = child->AsElement();
|
||||
return child->AsElement();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -113,17 +114,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsEventSource,
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannelEventSink)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mHttpChannel)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTimer)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnOpenListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnMessageListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mUnicodeDecoder)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsEventSource, nsDOMEventTargetWrapperCache)
|
||||
tmp->Close();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnOpenListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnMessageListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
DOMCI_DATA(EventSource, nsEventSource)
|
||||
|
@ -162,23 +157,9 @@ nsEventSource::GetReadyState(PRInt32 *aReadyState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#define NS_EVENTSRC_IMPL_DOMEVENTLISTENER(_eventlistenername, _eventlistener) \
|
||||
NS_IMETHODIMP \
|
||||
nsEventSource::GetOn##_eventlistenername(nsIDOMEventListener * *aListener) \
|
||||
{ \
|
||||
return GetInnerEventListener(_eventlistener, aListener); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP \
|
||||
nsEventSource::SetOn##_eventlistenername(nsIDOMEventListener * aListener) \
|
||||
{ \
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(#_eventlistenername), \
|
||||
_eventlistener, aListener); \
|
||||
}
|
||||
|
||||
NS_EVENTSRC_IMPL_DOMEVENTLISTENER(open, mOnOpenListener)
|
||||
NS_EVENTSRC_IMPL_DOMEVENTLISTENER(error, mOnErrorListener)
|
||||
NS_EVENTSRC_IMPL_DOMEVENTLISTENER(message, mOnMessageListener)
|
||||
NS_IMPL_EVENT_HANDLER(nsEventSource, open)
|
||||
NS_IMPL_EVENT_HANDLER(nsEventSource, error)
|
||||
NS_IMPL_EVENT_HANDLER(nsEventSource, message)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventSource::Close()
|
||||
|
|
|
@ -222,10 +222,6 @@ protected:
|
|||
nsString mLastFieldName;
|
||||
nsString mLastFieldValue;
|
||||
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnOpenListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnMessageListener;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1790,7 +1790,9 @@ GK_ATOM(svgTSpanFrame, "SVGTSpanFrame")
|
|||
GK_ATOM(svgUseFrame, "SVGUseFrame")
|
||||
GK_ATOM(HTMLVideoFrame, "VideoFrame")
|
||||
GK_ATOM(onloadstart, "onloadstart")
|
||||
GK_ATOM(onloadend, "onloadend")
|
||||
GK_ATOM(onprogress, "onprogress")
|
||||
GK_ATOM(onuploadprogress, "onuploadprogress")
|
||||
GK_ATOM(onsuspend, "onsuspend")
|
||||
GK_ATOM(onemptied, "onemptied")
|
||||
GK_ATOM(onstalled, "onstalled")
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
#include "nsIRequest.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsDOMLists.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
|
|
@ -288,24 +288,15 @@ nsMultipartProxyListener::OnDataAvailable(nsIRequest *aRequest,
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXHREventTarget)
|
||||
|
||||
// nsXHREventTarget's CC participant doesn't actually do anything anymore
|
||||
// but these are left here as placeholders in case it needs to do something
|
||||
// in the future.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXHREventTarget,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadStartListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnProgressListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadendListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXHREventTarget,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadStartListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnProgressListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadendListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXHREventTarget)
|
||||
|
@ -315,83 +306,12 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
|
|||
NS_IMPL_ADDREF_INHERITED(nsXHREventTarget, nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(nsXHREventTarget, nsDOMEventTargetWrapperCache)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::GetOnload(nsIDOMEventListener** aOnLoad)
|
||||
{
|
||||
return GetInnerEventListener(mOnLoadListener, aOnLoad);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::SetOnload(nsIDOMEventListener* aOnLoad)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(LOAD_STR),
|
||||
mOnLoadListener, aOnLoad);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::GetOnerror(nsIDOMEventListener** aOnerror)
|
||||
{
|
||||
return GetInnerEventListener(mOnErrorListener, aOnerror);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::SetOnerror(nsIDOMEventListener* aOnerror)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ERROR_STR),
|
||||
mOnErrorListener, aOnerror);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::GetOnabort(nsIDOMEventListener** aOnabort)
|
||||
{
|
||||
return GetInnerEventListener(mOnAbortListener, aOnabort);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::SetOnabort(nsIDOMEventListener* aOnabort)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ABORT_STR),
|
||||
mOnAbortListener, aOnabort);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::GetOnloadstart(nsIDOMEventListener** aOnloadstart)
|
||||
{
|
||||
return GetInnerEventListener(mOnLoadStartListener, aOnloadstart);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::SetOnloadstart(nsIDOMEventListener* aOnloadstart)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(LOADSTART_STR),
|
||||
mOnLoadStartListener, aOnloadstart);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::GetOnprogress(nsIDOMEventListener** aOnprogress)
|
||||
{
|
||||
return GetInnerEventListener(mOnProgressListener, aOnprogress);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::SetOnprogress(nsIDOMEventListener* aOnprogress)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(PROGRESS_STR),
|
||||
mOnProgressListener, aOnprogress);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::GetOnloadend(nsIDOMEventListener** aOnLoadend)
|
||||
{
|
||||
return GetInnerEventListener(mOnLoadendListener, aOnLoadend);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHREventTarget::SetOnloadend(nsIDOMEventListener* aOnLoadend)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(LOADEND_STR),
|
||||
mOnLoadendListener, aOnLoadend);
|
||||
}
|
||||
NS_IMPL_EVENT_HANDLER(nsXHREventTarget, load)
|
||||
NS_IMPL_EVENT_HANDLER(nsXHREventTarget, error)
|
||||
NS_IMPL_EVENT_HANDLER(nsXHREventTarget, abort)
|
||||
NS_IMPL_EVENT_HANDLER(nsXHREventTarget, loadstart)
|
||||
NS_IMPL_EVENT_HANDLER(nsXHREventTarget, progress)
|
||||
NS_IMPL_EVENT_HANDLER(nsXHREventTarget, loadend)
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
|
@ -585,9 +505,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)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannelEventSink)
|
||||
|
@ -607,9 +524,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)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannelEventSink)
|
||||
|
@ -650,39 +564,8 @@ NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
|
|||
NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
|
||||
NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetOnreadystatechange(nsIDOMEventListener * *aOnreadystatechange)
|
||||
{
|
||||
return
|
||||
nsXHREventTarget::GetInnerEventListener(mOnReadystatechangeListener,
|
||||
aOnreadystatechange);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SetOnreadystatechange(nsIDOMEventListener * aOnreadystatechange)
|
||||
{
|
||||
return
|
||||
nsXHREventTarget::RemoveAddEventListener(NS_LITERAL_STRING(READYSTATE_STR),
|
||||
mOnReadystatechangeListener,
|
||||
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);
|
||||
}
|
||||
NS_IMPL_EVENT_HANDLER(nsXMLHttpRequest, readystatechange)
|
||||
NS_IMPL_EVENT_HANDLER(nsXMLHttpRequest, uploadprogress)
|
||||
|
||||
/* readonly attribute nsIChannel channel; */
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -80,14 +80,6 @@ public:
|
|||
nsDOMEventTargetWrapperCache)
|
||||
NS_DECL_NSIXMLHTTPREQUESTEVENTTARGET
|
||||
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnAbortListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadStartListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnProgressListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadendListener;
|
||||
};
|
||||
|
||||
class nsXMLHttpRequestUpload : public nsXHREventTarget,
|
||||
|
@ -133,8 +125,7 @@ public:
|
|||
NS_DECL_NSIXMLHTTPREQUEST
|
||||
|
||||
// nsIJSXMLHttpRequest
|
||||
NS_IMETHOD GetOnuploadprogress(nsIDOMEventListener** aOnuploadprogress);
|
||||
NS_IMETHOD SetOnuploadprogress(nsIDOMEventListener* aOnuploadprogress);
|
||||
NS_DECL_NSIJSXMLHTTPREQUEST
|
||||
|
||||
NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
|
||||
|
||||
|
@ -257,9 +248,6 @@ protected:
|
|||
nsCOMPtr<nsIChannel> mCORSPreflightChannel;
|
||||
nsTArray<nsCString> mCORSUnsafeHeaders;
|
||||
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnUploadProgressListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnReadystatechangeListener;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
|
||||
|
||||
// used to implement getAllResponseHeaders()
|
||||
|
|
|
@ -79,12 +79,12 @@ function run_test() {
|
|||
.createInstance(Components.interfaces.nsIXMLHttpRequest);
|
||||
request.open("GET", redirectURL, true);
|
||||
request.setRequestHeader("X-Custom-Header", "present");
|
||||
request.onreadystatechange = function() {
|
||||
request.addEventListener("readystatechange", function() {
|
||||
if (request.readyState == 4) {
|
||||
do_check_eq(request.status, 200);
|
||||
server.stop(do_test_finished);
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
request.send();
|
||||
try {
|
||||
request.setRequestHeader("X-Unwanted-Header", "present");
|
||||
|
|
|
@ -46,7 +46,7 @@ var asyncXHR = {
|
|||
request.open("GET", "http://localhost:4444/test_error_code.xml", true);
|
||||
|
||||
var self = this;
|
||||
request.onerror = function(event) { self.onError(event); };
|
||||
request.addEventListener("error", function(event) { self.onError(event); }, false);
|
||||
request.send(null);
|
||||
},
|
||||
onError: function doAsyncRequest_onError(event) {
|
||||
|
|
|
@ -588,17 +588,6 @@ protected:
|
|||
return target == LOCAL_GL_TEXTURE_2D ? mGLMaxTextureSize : mGLMaxCubeMapTextureSize;
|
||||
}
|
||||
|
||||
// bug 684882 comment 37. On Mac OS (confirmed on 10.7.1), Intel driver, rendering to a face of a cube map
|
||||
// copies random video memory into it.
|
||||
// In particular, since glGenerateMipmap does that, it must be avoided.
|
||||
bool WorkAroundCubeMapBug684882() const {
|
||||
#ifdef XP_MACOSX
|
||||
return gl->Vendor() == gl::GLContext::VendorIntel;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** like glBufferData but if the call may change the buffer size, checks any GL error generated
|
||||
* by this glBufferData call and returns it */
|
||||
GLenum CheckedBufferData(GLenum target,
|
||||
|
@ -1165,7 +1154,6 @@ public:
|
|||
mWrapT = aWrapT;
|
||||
SetDontKnowIfNeedFakeBlack();
|
||||
}
|
||||
|
||||
WebGLenum MinFilter() const { return mMinFilter; }
|
||||
|
||||
bool DoesMinFilterRequireMipmap() const {
|
||||
|
|
|
@ -1696,17 +1696,10 @@ WebGLContext::FramebufferTexture2D(WebGLenum target,
|
|||
nsIWebGLTexture *tobj,
|
||||
WebGLint level)
|
||||
{
|
||||
if (!mBoundFramebuffer)
|
||||
if (mBoundFramebuffer)
|
||||
return mBoundFramebuffer->FramebufferTexture2D(target, attachment, textarget, tobj, level);
|
||||
else
|
||||
return ErrorInvalidOperation("framebufferTexture2D: cannot modify framebuffer 0");
|
||||
|
||||
if (textarget != LOCAL_GL_TEXTURE_2D && WorkAroundCubeMapBug684882()) {
|
||||
return ErrorInvalidOperation("framebufferTexture2D: Attaching a face of a cube map to a framebuffer is disabled "
|
||||
"on Mac OS X on Intel GPUs to protect you from a bug causing random "
|
||||
"video memory to be copied into cube maps attached to framebuffers "
|
||||
"(Mozilla bug 684882, Apple bug 9129398)");
|
||||
}
|
||||
|
||||
return mBoundFramebuffer->FramebufferTexture2D(target, attachment, textarget, tobj, level);
|
||||
}
|
||||
|
||||
GL_SAME_METHOD_0(Flush, Flush)
|
||||
|
@ -1784,18 +1777,7 @@ WebGLContext::GenerateMipmap(WebGLenum target)
|
|||
tex->SetGeneratedMipmap();
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
if (WorkAroundCubeMapBug684882()) {
|
||||
if (target == LOCAL_GL_TEXTURE_2D) {
|
||||
gl->fGenerateMipmap(target);
|
||||
} else {
|
||||
// do nothing! Accordingly we must make sure to never actually set texture parameters to something that requires mipmaps,
|
||||
// or else we'll fail to render.
|
||||
}
|
||||
} else {
|
||||
gl->fGenerateMipmap(target);
|
||||
}
|
||||
|
||||
gl->fGenerateMipmap(target);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2527,33 +2509,12 @@ nsresult WebGLContext::TexParameter_base(WebGLenum target, WebGLenum pname,
|
|||
return ErrorInvalidEnum("texParameterf: pname %x and floating-point param %e are mutually incompatible",
|
||||
pname, floatParam);
|
||||
}
|
||||
|
||||
WebGLint intParamForGL = intParam;
|
||||
WebGLfloat floatParamForGL = floatParam;
|
||||
|
||||
if (WorkAroundCubeMapBug684882()) {
|
||||
// bug 684882 - we skip mipmap generation in this case to work around a Mac GL bug, so we have
|
||||
// to tweak the minification filter to avoid requiring a mipmap
|
||||
if (pname == LOCAL_GL_TEXTURE_MIN_FILTER) {
|
||||
if (intParam == LOCAL_GL_NEAREST_MIPMAP_NEAREST ||
|
||||
intParam == LOCAL_GL_NEAREST_MIPMAP_LINEAR)
|
||||
{
|
||||
intParamForGL = LOCAL_GL_NEAREST;
|
||||
floatParamForGL = WebGLfloat(intParamForGL);
|
||||
} else if (intParam == LOCAL_GL_LINEAR_MIPMAP_NEAREST ||
|
||||
intParam == LOCAL_GL_LINEAR_MIPMAP_LINEAR)
|
||||
{
|
||||
intParamForGL = LOCAL_GL_LINEAR;
|
||||
floatParamForGL = WebGLfloat(intParamForGL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
if (intParamPtr)
|
||||
gl->fTexParameteri(target, pname, intParamForGL);
|
||||
gl->fTexParameteri(target, pname, intParam);
|
||||
else
|
||||
gl->fTexParameterf(target, pname, floatParamForGL);
|
||||
gl->fTexParameterf(target, pname, floatParam);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2579,29 +2540,23 @@ WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname, nsIVariant **re
|
|||
|
||||
if (!ValidateTextureTargetEnum(target, "getTexParameter: target"))
|
||||
return NS_OK;
|
||||
|
||||
WebGLTexture *tex = activeBoundTextureForTarget(target);
|
||||
|
||||
if (!tex)
|
||||
if (!activeBoundTextureForTarget(target))
|
||||
return ErrorInvalidOperation("getTexParameter: no texture bound");
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
|
||||
NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
|
||||
|
||||
switch (pname) {
|
||||
// note that because of bug 684882, the minification filter for OpenGL is sometimes spoofed.
|
||||
// here we want to return our own value, not OpenGL's value
|
||||
case LOCAL_GL_TEXTURE_MIN_FILTER:
|
||||
wrval->SetAsInt32(tex->mMinFilter);
|
||||
break;
|
||||
case LOCAL_GL_TEXTURE_MAG_FILTER:
|
||||
wrval->SetAsInt32(tex->mMagFilter);
|
||||
break;
|
||||
case LOCAL_GL_TEXTURE_WRAP_S:
|
||||
wrval->SetAsInt32(tex->mWrapS);
|
||||
break;
|
||||
case LOCAL_GL_TEXTURE_WRAP_T:
|
||||
wrval->SetAsInt32(tex->mWrapT);
|
||||
{
|
||||
GLint i = 0;
|
||||
gl->fGetTexParameteriv(target, pname, &i);
|
||||
wrval->SetAsInt32(i);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -555,6 +555,14 @@ WebGLContext::InitAndValidateGL()
|
|||
|
||||
gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mGLMaxTextureSize);
|
||||
gl->fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mGLMaxCubeMapTextureSize);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->Vendor() == gl::GLContext::VendorIntel) {
|
||||
// bug 684882, corruption in large cube maps on Intel Mac driver.
|
||||
// Is reported to only affect Mac OS < 10.7.2 but don't want to rely on that yet.
|
||||
mGLMaxCubeMapTextureSize = NS_MIN(mGLMaxCubeMapTextureSize, 512);
|
||||
}
|
||||
#endif
|
||||
|
||||
gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS, &mGLMaxTextureImageUnits);
|
||||
gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &mGLMaxVertexTextureImageUnits);
|
||||
|
|
|
@ -3823,8 +3823,6 @@ nsDOMClassInfo::Init()
|
|||
|
||||
DOM_CLASSINFO_MAP_BEGIN(FileReader, nsIDOMFileReader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileReader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
|
|
|
@ -239,10 +239,10 @@ WifiGeoPositionProvider.prototype = {
|
|||
xhr.mozBackgroundRequest = true;
|
||||
xhr.open("GET", providerUrl, false);
|
||||
xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
|
||||
xhr.onerror = function(req) {
|
||||
xhr.addEventListener("error", function(req) {
|
||||
LOG("onerror: " + req);
|
||||
};
|
||||
xhr.onload = function (req) {
|
||||
}, false);
|
||||
xhr.addEventListener("load", function (req) {
|
||||
LOG("service returned: " + req.target.responseText);
|
||||
response = JSON.parse(req.target.responseText);
|
||||
/*
|
||||
|
@ -288,7 +288,7 @@ WifiGeoPositionProvider.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
|
||||
LOG("************************************* ------>>>> sending.");
|
||||
xhr.send(null);
|
||||
|
|
|
@ -390,8 +390,8 @@ protected:
|
|||
void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], PRUint32 &aLen,
|
||||
eFontPrefLang aCharLang, eFontPrefLang aPageLang);
|
||||
|
||||
bool mAllowDownloadableFonts;
|
||||
bool mDownloadableFontsSanitize;
|
||||
PRInt8 mAllowDownloadableFonts;
|
||||
PRInt8 mDownloadableFontsSanitize;
|
||||
|
||||
// which scripts should be shaped with harfbuzz
|
||||
PRInt32 mUseHarfBuzzScripts;
|
||||
|
|
|
@ -256,8 +256,8 @@ public:
|
|||
protected:
|
||||
RenderMode mRenderMode;
|
||||
|
||||
bool mUseClearTypeForDownloadableFonts;
|
||||
bool mUseClearTypeAlways;
|
||||
PRInt8 mUseClearTypeForDownloadableFonts;
|
||||
PRInt8 mUseClearTypeAlways;
|
||||
HDC mScreenDC;
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,12 +30,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
|
|||
var wrappedWin = $('ifr').contentWindow;
|
||||
var unwrapped = wrappedWin.wrappedJSObject;
|
||||
|
||||
var readystatechange = unwrapped.xhr.onreadystatechange;
|
||||
is(utils.getClassName(readystatechange), 'Proxy', 'properly wrapped');
|
||||
is(typeof readystatechange.QueryInterface, 'function', 'double wrapped');
|
||||
var filter = unwrapped.filter;
|
||||
is(utils.getClassName(filter), 'Proxy', 'properly wrapped');
|
||||
is(typeof filter.QueryInterface, 'function', 'double wrapped');
|
||||
|
||||
ok(unwrapped.testme(readystatechange),
|
||||
'content didn\'t get a proxy, but another double wrapped object');
|
||||
ok(unwrapped.testme(filter),
|
||||
"content didn't get a proxy, but another double wrapped object");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
var xhr = new XMLHttpRequest();
|
||||
var readystatechange = function() {};
|
||||
xhr.onreadystatechange = readystatechange;
|
||||
var fcn = function() {};
|
||||
var iter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, fcn, false);
|
||||
var filter = iter.filter;
|
||||
|
||||
function testme(obj) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
|
|
@ -18,10 +18,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502959
|
|||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 502959 **/
|
||||
var xhr = new XMLHttpRequest();
|
||||
// Whatever you do don't use the word "wrapped" in this function.
|
||||
function foo() {
|
||||
ok(true, "Able to call the function");
|
||||
}
|
||||
|
||||
var iter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, foo, false);
|
||||
var doublewrapped = iter.filter;
|
||||
|
||||
xhr.onreadystatechange = function() { ok(true, "Able to call the double-wrapped function"); };
|
||||
var doublewrapped = xhr.onreadystatechange;
|
||||
ok(doublewrapped.toString().indexOf("wrapped") > 0, "got a double-wrapped object back");
|
||||
|
||||
(function () {
|
||||
|
@ -29,7 +33,7 @@ ok(doublewrapped.toString().indexOf("wrapped") > 0, "got a double-wrapped object
|
|||
Components.utils.forceGC();
|
||||
})();
|
||||
|
||||
doublewrapped.handleEvent({});
|
||||
doublewrapped.acceptNode(document);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -38,16 +38,6 @@ function go() {
|
|||
"threw a security exception instead of an invalid child exception");
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
try {
|
||||
xhr.onreadystatechange = ifr.contentWindow;
|
||||
ok(false, "weird behavior");
|
||||
} catch (e) {
|
||||
ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e),
|
||||
"threw a security exception instead of an invalid child exception");
|
||||
}
|
||||
|
||||
// Location is always wrapped, so test it separately.
|
||||
|
||||
ifr.onload = null;
|
||||
|
|
|
@ -105,7 +105,7 @@ var LocaleRepository = {
|
|||
request.overrideMimeType("text/xml");
|
||||
|
||||
let self = this;
|
||||
request.onreadystatechange = function () {
|
||||
request.addEventListener("readystatechange", function () {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200) {
|
||||
self.log("---- got response")
|
||||
|
@ -122,7 +122,7 @@ var LocaleRepository = {
|
|||
Cu.reportError("Locale Repository: Error getting locale from AMO [" + request.status + "]");
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
|
||||
request.send(null);
|
||||
},
|
||||
|
|
|
@ -38,10 +38,10 @@ function run_test()
|
|||
|
||||
// Test async XHR sending
|
||||
let async = createXHR(true);
|
||||
async.onreadystatechange = function(event) {
|
||||
async.addEventListener("readystatechange", function(event) {
|
||||
if (checkResults(async))
|
||||
httpserver.stop(do_test_finished);
|
||||
};
|
||||
}, false);
|
||||
async.send(null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ install-develop: mozmill-dir
|
|||
endif
|
||||
|
||||
# Rules for staging the necessary harness bits for a test package
|
||||
stage-package: PKG_STAGE = $(DIST)/test-package-stage
|
||||
stage-package: install
|
||||
|
||||
PKG_STAGE = $(DIST)/test-package-stage
|
||||
|
||||
|
|
|
@ -320,8 +320,8 @@ TelemetryPing.prototype = {
|
|||
if (isTestPing)
|
||||
Services.obs.notifyObservers(null, "telemetry-test-xhr-complete", null);
|
||||
}
|
||||
request.onerror = function(aEvent) finishRequest(request.channel);
|
||||
request.onload = function(aEvent) finishRequest(request.channel);
|
||||
request.addEventListener("error", function(aEvent) finishRequest(request.channel), false);
|
||||
request.addEventListener("load", function(aEvent) finishRequest(request.channel), false);
|
||||
|
||||
request.send(JSON.stringify(payload));
|
||||
},
|
||||
|
|
|
@ -103,15 +103,14 @@ PROT_XMLFetcher.prototype = {
|
|||
|
||||
// Create a closure
|
||||
var self = this;
|
||||
this._request.onreadystatechange = function() {
|
||||
this._request.addEventListener("readystatechange", function() {
|
||||
self.readyStateChange(self);
|
||||
}
|
||||
}, false);
|
||||
|
||||
this._request.send(null);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
this._request.onreadystatechange = null;
|
||||
this._request.abort();
|
||||
this._request = null;
|
||||
},
|
||||
|
|
|
@ -257,7 +257,7 @@ Submitter.prototype = {
|
|||
// add the minidump
|
||||
formData.append("upload_file_minidump", File(this.dump.path));
|
||||
let self = this;
|
||||
xhr.onreadystatechange = function (aEvt) {
|
||||
xhr.addEventListener("readystatechange", function (aEvt) {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status != 200) {
|
||||
self.notifyStatus(FAILED);
|
||||
|
@ -267,7 +267,7 @@ Submitter.prototype = {
|
|||
self.submitSuccess(ret);
|
||||
}
|
||||
}
|
||||
};
|
||||
}, false);
|
||||
|
||||
xhr.send(formData);
|
||||
return true;
|
||||
|
|
|
@ -1176,8 +1176,10 @@ var AddonRepository = {
|
|||
this._request.overrideMimeType("text/xml");
|
||||
|
||||
let self = this;
|
||||
this._request.onerror = function(aEvent) { self._reportFailure(); };
|
||||
this._request.onload = function(aEvent) {
|
||||
this._request.addEventListener("error", function(aEvent) {
|
||||
self._reportFailure();
|
||||
}, false);
|
||||
this._request.addEventListener("load", function(aEvent) {
|
||||
let request = aEvent.target;
|
||||
let responseXML = request.responseXML;
|
||||
|
||||
|
@ -1196,7 +1198,7 @@ var AddonRepository = {
|
|||
totalResults = parsedTotalResults;
|
||||
|
||||
aHandleResults(elements, totalResults);
|
||||
};
|
||||
}, false);
|
||||
this._request.send(null);
|
||||
},
|
||||
|
||||
|
|
|
@ -451,8 +451,8 @@ function UpdateParser(aId, aType, aUpdateKey, aUrl, aObserver) {
|
|||
this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
this.request.overrideMimeType("text/xml");
|
||||
var self = this;
|
||||
this.request.onload = function(event) { self.onLoad() };
|
||||
this.request.onerror = function(event) { self.onError() };
|
||||
this.request.addEventListener("load", function(event) { self.onLoad() }, false);
|
||||
this.request.addEventListener("error", function(event) { self.onError() }, false);
|
||||
this.request.send(null);
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
@ -227,7 +227,7 @@ var LightweightThemeManager = {
|
|||
req.open("GET", theme.updateURL, true);
|
||||
|
||||
var self = this;
|
||||
req.onload = function () {
|
||||
req.addEventListener("load", function () {
|
||||
if (req.status != 200)
|
||||
return;
|
||||
|
||||
|
@ -240,7 +240,7 @@ var LightweightThemeManager = {
|
|||
var currentTheme = self.currentTheme;
|
||||
if (currentTheme && currentTheme.id == theme.id)
|
||||
self.currentTheme = newData;
|
||||
};
|
||||
}, false);
|
||||
|
||||
req.send(null);
|
||||
},
|
||||
|
|
|
@ -546,8 +546,8 @@ Blocklist.prototype = {
|
|||
request.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
|
||||
|
||||
var self = this;
|
||||
request.onerror = function(event) { self.onXMLError(event); };
|
||||
request.onload = function(event) { self.onXMLLoad(event); };
|
||||
request.addEventListener("error", function(event) { self.onXMLError(event); }, false);
|
||||
request.addEventListener("load", function(event) { self.onXMLLoad(event); }, false);
|
||||
request.send(null);
|
||||
|
||||
// When the blocklist loads we need to compare it to the current copy so
|
||||
|
|
|
@ -2155,9 +2155,9 @@ Checker.prototype = {
|
|||
this._request.setRequestHeader("Cache-Control", "no-cache");
|
||||
|
||||
var self = this;
|
||||
this._request.onerror = function(event) { self.onError(event); };
|
||||
this._request.onload = function(event) { self.onLoad(event); };
|
||||
this._request.onprogress = function(event) { self.onProgress(event); };
|
||||
this._request.addEventListener("error", function(event) { self.onError(event); } ,false);
|
||||
this._request.addEventListener("load", function(event) { self.onLoad(event); }, false);
|
||||
this._request.addEventListener("progress", function(event) { self.onProgress(event); }, false);
|
||||
|
||||
LOG("Checker:checkForUpdates - sending request to: " + url);
|
||||
this._request.send(null);
|
||||
|
|
|
@ -1007,6 +1007,9 @@ xhr.prototype = {
|
|||
_onload: null,
|
||||
set onload(val) { gXHR._onload = makeHandler(val); },
|
||||
get onload() { return gXHR._onload; },
|
||||
addEventListener: function(event, val, capturing) {
|
||||
eval("gXHR._on" + event + " = val");
|
||||
},
|
||||
flags: AUS_Ci.nsIClassInfo.SINGLETON,
|
||||
implementationLanguage: AUS_Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
||||
getHelperForLanguage: function(language) null,
|
||||
|
|
|
@ -87,7 +87,7 @@ function callHandleEvent() {
|
|||
gXHR.responseXML = null;
|
||||
}
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload.handleEvent(e);
|
||||
gXHR.onload(e);
|
||||
}
|
||||
|
||||
// update xml not found
|
||||
|
|
|
@ -77,7 +77,7 @@ function callHandleEvent() {
|
|||
catch(e) {
|
||||
}
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload.handleEvent(e);
|
||||
gXHR.onload(e);
|
||||
}
|
||||
|
||||
// Helper function for testing mar downloads that have the correct size
|
||||
|
|
|
@ -63,7 +63,7 @@ function end_test() {
|
|||
// call the nsIDOMEventListener's handleEvent method for onload.
|
||||
function callHandleEvent() {
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload.handleEvent(e);
|
||||
gXHR.onload(e);
|
||||
}
|
||||
|
||||
// Helper function for parsing the result from the contructed url
|
||||
|
|
|
@ -68,7 +68,7 @@ function end_test() {
|
|||
function callHandleEvent() {
|
||||
gXHR.status = gExpectedStatusCode;
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload.handleEvent(e);
|
||||
gXHR.onload(e);
|
||||
}
|
||||
|
||||
// Helper functions for testing nsIUpdateCheckListener statusText
|
||||
|
|
|
@ -166,7 +166,7 @@ OpenWebapps.prototype = {
|
|||
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||
xhr.open("GET", aURL, true);
|
||||
|
||||
xhr.onload = function() {
|
||||
xhr.addEventListener("load", function() {
|
||||
if (xhr.status == 200) {
|
||||
try {
|
||||
let manifest = JSON.parse(xhr.responseText);
|
||||
|
@ -185,12 +185,12 @@ OpenWebapps.prototype = {
|
|||
else if (aError) {
|
||||
aError.handle({ code: "networkError", message: "Unable to retrieve manifest" });
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
xhr.onerror = function() {
|
||||
xhr.addEventListener("error", function() {
|
||||
if (aError)
|
||||
aError.handle({ code: "networkError", message: "Unable to retrieve manifest" });
|
||||
}
|
||||
}, false);
|
||||
|
||||
xhr.send(null);
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче