Bug 527370: Rename some things in order to match the latest File API spec. Specifically FileRequest -> FileReader and .response -> .result. r=smaug sr=jst

--HG--
rename : content/base/public/nsIDOMFileRequest.idl => content/base/public/nsIDOMFileReader.idl
rename : content/base/src/nsDOMFileRequest.cpp => content/base/src/nsDOMFileReader.cpp
rename : content/base/src/nsDOMFileRequest.h => content/base/src/nsDOMFileReader.h
This commit is contained in:
Jonas Sicking 2009-11-09 12:05:16 -08:00
parent b35dae99b7
commit d954edae7f
9 changed files with 140 additions and 140 deletions

View File

@ -93,7 +93,7 @@ XPIDLSRCS = \
nsIContentPolicy.idl \
nsIDocumentEncoder.idl \
nsIDOMFile.idl \
nsIDOMFileRequest.idl \
nsIDOMFileReader.idl \
nsIDOMFileInternal.idl \
nsIDOMFileList.idl \
nsIDOMFileException.idl \

View File

@ -41,8 +41,8 @@ interface nsIDOMEventListener;
interface nsIDOMFile;
interface nsIDOMFileError;
[scriptable, uuid(074FEC26-7FAB-4E05-9E60-EC49E148F5EF)]
interface nsIDOMFileRequest : nsISupports
[scriptable, uuid(5db0ce80-de44-40c0-a346-e28aac4aa978)]
interface nsIDOMFileReader : nsISupports
{
void readAsBinaryString(in nsIDOMFile filedata);
void readAsText(in nsIDOMFile filedata, [optional] in DOMString encoding);
@ -55,7 +55,7 @@ interface nsIDOMFileRequest : nsISupports
const unsigned short DONE = 2;
readonly attribute unsigned short readyState;
readonly attribute DOMString response;
readonly attribute DOMString result;
readonly attribute nsIDOMFileError error;
// event handler attributes
@ -63,9 +63,9 @@ interface nsIDOMFileRequest : nsISupports
};
%{ C++
#define NS_FILEREQUEST_CID \
#define NS_FILEREADER_CID \
{0x06aa7c21, 0xfe05, 0x4cf2, \
{0xb1, 0xc4, 0x0c, 0x71, 0x26, 0xa4, 0xf7, 0x13}}
#define NS_FILEREQUEST_CONTRACTID \
"@mozilla.org/files/filerequest;1"
#define NS_FILEREADER_CONTRACTID \
"@mozilla.org/files/filereader;1"
%}

View File

@ -84,7 +84,7 @@ CPPSRCS = \
nsDOMAttributeMap.cpp \
nsDOMDocumentType.cpp \
nsDOMFile.cpp \
nsDOMFileRequest.cpp \
nsDOMFileReader.cpp \
nsDOMLists.cpp \
nsDOMParser.cpp \
nsDOMSerializer.cpp \

View File

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMFileRequest.h"
#include "nsDOMFileReader.h"
#include "nsContentCID.h"
#include "nsContentUtils.h"
@ -89,9 +89,9 @@
#define NS_PROGRESS_EVENT_INTERVAL 50
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMFileRequest)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMFileReader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMFileRequest,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMFileReader,
nsXHREventTarget)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadEndListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFile)
@ -100,7 +100,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMFileRequest,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileRequest,
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileReader,
nsXHREventTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadEndListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFile)
@ -109,32 +109,32 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileRequest,
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMFileRequest)
NS_INTERFACE_MAP_ENTRY(nsIDOMFileRequest)
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_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(FileRequest)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(FileReader)
NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
NS_IMPL_ADDREF_INHERITED(nsDOMFileRequest, nsXHREventTarget)
NS_IMPL_RELEASE_INHERITED(nsDOMFileRequest, nsXHREventTarget)
NS_IMPL_ADDREF_INHERITED(nsDOMFileReader, nsXHREventTarget)
NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget)
static const PRUint32 FILE_AS_BINARY = 1;
static const PRUint32 FILE_AS_TEXT = 2;
static const PRUint32 FILE_AS_DATAURL = 3;
NS_IMETHODIMP
nsDOMFileRequest::GetOnloadend(nsIDOMEventListener** aOnloadend)
nsDOMFileReader::GetOnloadend(nsIDOMEventListener** aOnloadend)
{
return GetInnerEventListener(mOnLoadEndListener, aOnloadend);
}
NS_IMETHODIMP
nsDOMFileRequest::SetOnloadend(nsIDOMEventListener* aOnloadend)
nsDOMFileReader::SetOnloadend(nsIDOMEventListener* aOnloadend)
{
return RemoveAddEventListener(NS_LITERAL_STRING(LOADEND_STR),
mOnLoadEndListener, aOnloadend);
@ -143,18 +143,18 @@ nsDOMFileRequest::SetOnloadend(nsIDOMEventListener* aOnloadend)
//nsICharsetDetectionObserver
NS_IMETHODIMP
nsDOMFileRequest::Notify(const char *aCharset, nsDetectionConfident aConf)
nsDOMFileReader::Notify(const char *aCharset, nsDetectionConfident aConf)
{
CopyASCIItoUTF16(aCharset, mCharset);
return NS_OK;
}
//nsDOMFileRequest constructors/initializers
//nsDOMFileReader constructors/initializers
nsDOMFileRequest::nsDOMFileRequest()
nsDOMFileReader::nsDOMFileReader()
: mFileData(nsnull), mReadCount(0),
mDataLen(0), mDataFormat(0),
mReadyState(nsIDOMFileRequest::INITIAL),
mReadyState(nsIDOMFileReader::INITIAL),
mProgressEventWasDelayed(PR_FALSE),
mTimerIsActive(PR_FALSE),
mReadTotal(0), mReadTransferred(0),
@ -163,7 +163,7 @@ nsDOMFileRequest::nsDOMFileRequest()
nsLayoutStatics::AddRef();
}
nsDOMFileRequest::~nsDOMFileRequest()
nsDOMFileReader::~nsDOMFileReader()
{
if (mListenerManager)
mListenerManager->Disconnect();
@ -172,7 +172,7 @@ nsDOMFileRequest::~nsDOMFileRequest()
}
nsresult
nsDOMFileRequest::Init()
nsDOMFileReader::Init()
{
// Set the original mScriptContext and mPrincipal, if available.
// Get JSContext from stack.
@ -211,8 +211,8 @@ nsDOMFileRequest::Init()
}
NS_IMETHODIMP
nsDOMFileRequest::Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
PRUint32 argc, jsval *argv)
nsDOMFileReader::Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
PRUint32 argc, jsval *argv)
{
mOwner = do_QueryInterface(aOwner);
if (!mOwner) {
@ -236,57 +236,57 @@ nsDOMFileRequest::Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
// nsIInterfaceRequestor
NS_IMETHODIMP
nsDOMFileRequest::GetInterface(const nsIID & aIID, void **aResult)
nsDOMFileReader::GetInterface(const nsIID & aIID, void **aResult)
{
return QueryInterface(aIID, aResult);
}
// nsIDOMFileRequest
// nsIDOMFileReader
NS_IMETHODIMP
nsDOMFileRequest::GetReadyState(PRUint16 *aReadyState)
nsDOMFileReader::GetReadyState(PRUint16 *aReadyState)
{
*aReadyState = mReadyState;
return NS_OK;
}
NS_IMETHODIMP
nsDOMFileRequest::GetResponse(nsAString& aResponse)
nsDOMFileReader::GetResult(nsAString& aResult)
{
aResponse = mResponse;
aResult = mResult;
return NS_OK;
}
NS_IMETHODIMP
nsDOMFileRequest::GetError(nsIDOMFileError** aError)
nsDOMFileReader::GetError(nsIDOMFileError** aError)
{
NS_IF_ADDREF(*aError = mError);
return NS_OK;
}
NS_IMETHODIMP
nsDOMFileRequest::ReadAsBinaryString(nsIDOMFile* aFile)
nsDOMFileReader::ReadAsBinaryString(nsIDOMFile* aFile)
{
return ReadFileContent(aFile, EmptyString(), FILE_AS_BINARY);
}
NS_IMETHODIMP
nsDOMFileRequest::ReadAsText(nsIDOMFile* aFile,
const nsAString &aCharset)
nsDOMFileReader::ReadAsText(nsIDOMFile* aFile,
const nsAString &aCharset)
{
return ReadFileContent(aFile, aCharset, FILE_AS_TEXT);
}
NS_IMETHODIMP
nsDOMFileRequest::ReadAsDataURL(nsIDOMFile* aFile)
nsDOMFileReader::ReadAsDataURL(nsIDOMFile* aFile)
{
return ReadFileContent(aFile, EmptyString(), FILE_AS_DATAURL);
}
NS_IMETHODIMP
nsDOMFileRequest::Abort()
nsDOMFileReader::Abort()
{
if (mReadyState != nsIDOMFileRequest::LOADING)
if (mReadyState != nsIDOMFileReader::LOADING)
return NS_OK;
//Clear progress and file data
@ -298,9 +298,9 @@ nsDOMFileRequest::Abort()
mReadCount = 0;
mDataLen = 0;
//Revert status, response and readystate attributes
SetDOMStringToNull(mResponse);
mReadyState = nsIDOMFileRequest::DONE;
//Revert status, result and readystate attributes
SetDOMStringToNull(mResult);
mReadyState = nsIDOMFileReader::DONE;
mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR);
//Non-null channel indicates a read is currently active
@ -319,14 +319,14 @@ nsDOMFileRequest::Abort()
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
mReadyState = nsIDOMFileRequest::INITIAL;
mReadyState = nsIDOMFileReader::INITIAL;
return NS_OK;
}
// nsITimerCallback
NS_IMETHODIMP
nsDOMFileRequest::Notify(nsITimer* aTimer)
nsDOMFileReader::Notify(nsITimer* aTimer)
{
mTimerIsActive = PR_FALSE;
if (mProgressEventWasDelayed) {
@ -338,7 +338,7 @@ nsDOMFileRequest::Notify(nsITimer* aTimer)
}
void
nsDOMFileRequest::StartProgressEventTimer()
nsDOMFileReader::StartProgressEventTimer()
{
if (!mProgressNotifier) {
mProgressNotifier = do_CreateInstance(NS_TIMER_CONTRACTID);
@ -355,17 +355,17 @@ nsDOMFileRequest::StartProgressEventTimer()
// nsIStreamListener
NS_IMETHODIMP
nsDOMFileRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsDOMFileReader::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
return NS_OK;
}
NS_IMETHODIMP
nsDOMFileRequest::OnDataAvailable(nsIRequest *aRequest,
nsISupports *aContext,
nsIInputStream *aInputStream,
PRUint32 aOffset,
PRUint32 aCount)
nsDOMFileReader::OnDataAvailable(nsIRequest *aRequest,
nsISupports *aContext,
nsIInputStream *aInputStream,
PRUint32 aOffset,
PRUint32 aCount)
{
//Update memory buffer to reflect the contents of the file
mFileData = (char *)PR_Realloc(mFileData, aOffset + aCount);
@ -377,11 +377,11 @@ nsDOMFileRequest::OnDataAvailable(nsIRequest *aRequest,
//Continuously update our binary string as data comes in
if (mDataFormat == FILE_AS_BINARY) {
PRUint32 oldLen = mResponse.Length();
PRUint32 oldLen = mResult.Length();
PRUint32 newLen = oldLen + aCount;
PRUnichar *buf;
if (mResponse.GetMutableData(&buf, newLen) != newLen) {
if (mResult.GetMutableData(&buf, newLen) != newLen) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -409,9 +409,9 @@ nsDOMFileRequest::OnDataAvailable(nsIRequest *aRequest,
}
NS_IMETHODIMP
nsDOMFileRequest::OnStopRequest(nsIRequest *aRequest,
nsISupports *aContext,
nsresult aStatus)
nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
nsISupports *aContext,
nsresult aStatus)
{
//If we're here as a result of a call from Abort(),
//simply ignore the request.
@ -425,8 +425,8 @@ nsDOMFileRequest::OnStopRequest(nsIRequest *aRequest,
mProgressNotifier->Cancel();
}
//FileRequest must be in DONE stage after a load
mReadyState = nsIDOMFileRequest::DONE;
//FileReader must be in DONE stage after a load
mReadyState = nsIDOMFileReader::DONE;
//Set the status field as appropriate
if (NS_FAILED(aStatus)) {
@ -437,12 +437,12 @@ nsDOMFileRequest::OnStopRequest(nsIRequest *aRequest,
nsresult rv;
switch (mDataFormat) {
case FILE_AS_BINARY:
break; //Already accumulated mResponse
break; //Already accumulated mResult
case FILE_AS_TEXT:
rv = GetAsText(mCharset, mFileData, mDataLen, mResponse);
rv = GetAsText(mCharset, mFileData, mDataLen, mResult);
break;
case FILE_AS_DATAURL:
rv = GetAsDataURL(mFile, mFileData, mDataLen, mResponse);
rv = GetAsDataURL(mFile, mFileData, mDataLen, mResult);
break;
default:
return NS_ERROR_FAILURE;
@ -458,9 +458,9 @@ nsDOMFileRequest::OnStopRequest(nsIRequest *aRequest,
// Helper methods
nsresult
nsDOMFileRequest::ReadFileContent(nsIDOMFile* aFile,
const nsAString &aCharset,
PRUint32 aDataFormat)
nsDOMFileReader::ReadFileContent(nsIDOMFile* aFile,
const nsAString &aCharset,
PRUint32 aDataFormat)
{
NS_ENSURE_TRUE(aFile, NS_ERROR_NULL_POINTER);
@ -490,15 +490,15 @@ nsDOMFileRequest::ReadFileContent(nsIDOMFile* aFile,
rv = mChannel->AsyncOpen(this, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
//FileRequest should be in loading state here
mReadyState = nsIDOMFileRequest::LOADING;
//FileReader should be in loading state here
mReadyState = nsIDOMFileReader::LOADING;
DispatchProgressEvent(NS_LITERAL_STRING(LOADSTART_STR));
return NS_OK;
}
void
nsDOMFileRequest::DispatchError(nsresult rv)
nsDOMFileReader::DispatchError(nsresult rv)
{
//Set the status attribute, and dispatch the error event
switch (rv) {
@ -519,7 +519,7 @@ nsDOMFileRequest::DispatchError(nsresult rv)
}
void
nsDOMFileRequest::DispatchProgressEvent(const nsAString& aType)
nsDOMFileReader::DispatchProgressEvent(const nsAString& aType)
{
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = nsEventDispatcher::CreateEvent(nsnull, nsnull,
@ -547,10 +547,10 @@ nsDOMFileRequest::DispatchProgressEvent(const nsAString& aType)
}
nsresult
nsDOMFileRequest::GetAsText(const nsAString &aCharset,
const char *aFileData,
PRUint32 aDataLen,
nsAString& aResult)
nsDOMFileReader::GetAsText(const nsAString &aCharset,
const char *aFileData,
PRUint32 aDataLen,
nsAString& aResult)
{
nsresult rv;
nsCAutoString charsetGuess;
@ -574,10 +574,10 @@ nsDOMFileRequest::GetAsText(const nsAString &aCharset,
}
nsresult
nsDOMFileRequest::GetAsDataURL(nsIFile *aFile,
const char *aFileData,
PRUint32 aDataLen,
nsAString& aResult)
nsDOMFileReader::GetAsDataURL(nsIFile *aFile,
const char *aFileData,
PRUint32 aDataLen,
nsAString& aResult)
{
aResult.AssignLiteral("data:");
@ -621,10 +621,10 @@ nsDOMFileRequest::GetAsDataURL(nsIFile *aFile,
}
nsresult
nsDOMFileRequest::ConvertStream(const char *aFileData,
PRUint32 aDataLen,
const char *aCharset,
nsAString &aResult)
nsDOMFileReader::ConvertStream(const char *aFileData,
PRUint32 aDataLen,
const char *aCharset,
nsAString &aResult)
{
nsresult rv;
nsCOMPtr<nsICharsetConverterManager> charsetConverter =
@ -650,9 +650,9 @@ nsDOMFileRequest::ConvertStream(const char *aFileData,
}
nsresult
nsDOMFileRequest::GuessCharset(const char *aFileData,
PRUint32 aDataLen,
nsACString &aCharset)
nsDOMFileReader::GuessCharset(const char *aFileData,
PRUint32 aDataLen,
nsACString &aCharset)
{
// First try the universal charset detector
nsCOMPtr<nsICharsetDetector> detector

View File

@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMFileRequest_h__
#define nsDOMFileRequest_h__
#ifndef nsDOMFileReader_h__
#define nsDOMFileReader_h__
#include "nsISupportsUtils.h"
#include "nsString.h"
@ -53,7 +53,7 @@
#include "nsICharsetDetectionObserver.h"
#include "nsIDOMFile.h"
#include "nsIDOMFileRequest.h"
#include "nsIDOMFileReader.h"
#include "nsIDOMFileList.h"
#include "nsIDOMFileError.h"
#include "nsIInputStream.h"
@ -63,23 +63,23 @@
#include "nsXMLHttpRequest.h"
class nsDOMFileRequest : public nsXHREventTarget,
public nsIDOMFileRequest,
public nsIStreamListener,
public nsIInterfaceRequestor,
public nsSupportsWeakReference,
public nsIJSNativeInitializer,
public nsITimerCallback,
public nsICharsetDetectionObserver
class nsDOMFileReader : public nsXHREventTarget,
public nsIDOMFileReader,
public nsIStreamListener,
public nsIInterfaceRequestor,
public nsSupportsWeakReference,
public nsIJSNativeInitializer,
public nsITimerCallback,
public nsICharsetDetectionObserver
{
public:
nsDOMFileRequest();
virtual ~nsDOMFileRequest();
nsDOMFileReader();
virtual ~nsDOMFileReader();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMFILEREQUEST
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMFileRequest, nsXHREventTarget)
NS_DECL_NSIDOMFILEREADER
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMFileReader, nsXHREventTarget)
NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::);
@ -126,7 +126,7 @@ protected:
PRUint32 mDataLen;
PRUint32 mDataFormat;
nsString mResponse;
nsString mResult;
PRUint16 mReadyState;
PRBool mProgressEventWasDelayed;

View File

@ -61,48 +61,48 @@ var domFileBinary = file.getAsBinary();
var domFileBinary2 = utf16File.getAsBinary();
var domFileBinary3 = utf32File.getAsBinary();
var request1 = new FileRequest();
var request1 = new FileReader();
request1.onload = handleTextISO1;
request1.readAsText(file, "iso-8859-1");
var request2 = new FileRequest();
var request2 = new FileReader();
request2.onload = handleTextUTF8;
request2.readAsText(file);
var request3 = new FileRequest();
var request3 = new FileReader();
request3.onload = handleTextUTF8;
request3.readAsText(file, "");
var request4 = new FileRequest();
var request4 = new FileReader();
request4.onload = handleTextUTF8;
request4.readAsText(file, "UTF-8");
//Test a variety of encodings, and make sure they work properly
//Also, test a variety of the same calls with different numbers of arguments
var request5 = new FileRequest();
var request5 = new FileReader();
request5.onload = handleTextUTF16;
request5.readAsText(utf16File, "UTF-16");
var request6 = new FileRequest();
var request6 = new FileReader();
request6.onload = handleTextUTF32;
request6.readAsText(utf32File, "UTF-32");
//Test binary data accessor
var request7 = new FileRequest();
var request7 = new FileReader();
request7.onload = handleDataBinary;
request7.readAsBinaryString(file);
var request71 = new FileRequest();
var request71 = new FileReader();
request71.onload = handleDataBinary16;
request71.readAsBinaryString(utf16File);
var request72 = new FileRequest();
var request72 = new FileReader();
request72.onload = handleDataBinary32;
request72.readAsBinaryString(utf32File);
//Test data URI encoding on differing file sizes
//Testing data URI when length % 3 == 0
var request8 = new FileRequest();
var request8 = new FileReader();
request8.onload = handleDataURI;
request8.readAsDataURL(file);
@ -110,7 +110,7 @@ request8.readAsDataURL(file);
var file2 = createFileWithData(testData2, "02");
var domFileData1 = file2.getAsDataURL();
var request9 = new FileRequest();
var request9 = new FileReader();
request9.onload = handleDataURI1;
request9.readAsDataURL(file2);
@ -118,13 +118,13 @@ request9.readAsDataURL(file2);
var file3 = createFileWithData(testData3, "03");
var domFileData2 = file3.getAsDataURL();
var request10 = new FileRequest();
var request10 = new FileReader();
request10.onload = handleDataURI2;
request10.readAsDataURL(file3);
//Test asynchronous property of file access
var globalVar = 0;
var request105 = new FileRequest();
var request105 = new FileReader();
request105.onload = incGlobalVar;
request105.readAsText(file, "");
is(globalVar, 0, "testing to make sure getAsText doesn't block subsequent execution");
@ -142,19 +142,19 @@ var fileList = document.getElementById('fileList');
fileList.value = testFile4.path;
var file4 = fileList.files[0];
var request11 = new FileRequest();
var request11 = new FileReader();
request11.onabort = handleCancel;
request11.readAsText(file4);
request11.abort();
//Test error handling - Note: currently throws exceptions
/*testFile4.permissions = 0;
var request12 = new FileRequest();
var request12 = new FileReader();
request12.onerror = handleSecurityError;
request12.readAsText(file4, "");
testFile4.remove(false);
var request13 = new FileRequest();
var request13 = new FileReader();
request13.onerror = handleNotFoundError;
request13.readAsText(file4, "");*/
@ -164,7 +164,7 @@ function incGlobalVar(fileAsText) {
}
function handleCancel(event) {
var fileAsText = event.target.response;
var fileAsText = event.target.result;
var error = event.target.error;
is(error.code, FileError.ABORT_ERR, "error code set to CANCELED for canceled reads");
is(fileAsText, null, "file data should be null on canceled reads");
@ -172,7 +172,7 @@ function handleCancel(event) {
}
function handleTextISO1(event) {
var fileAsText = event.target.response;
var fileAsText = event.target.result;
var error = event.target.error;
is(error, null, "error code set to null for successful data accesses");
is(testData.length, fileAsText.length, "iso-1 async length should match testdata");
@ -181,7 +181,7 @@ function handleTextISO1(event) {
}
function handleTextUTF8(event) {
var fileAsUTF8 = event.target.response;
var fileAsUTF8 = event.target.result;
var error = event.target.error;
is(error, null, "error code set to null for successful data accesses");
is(testData.length, fileAsUTF8.length, "UTF-8 async length should match testdata");
@ -190,7 +190,7 @@ function handleTextUTF8(event) {
}
function handleTextUTF16(event) {
var fileAsUTF16 = event.target.response;
var fileAsUTF16 = event.target.result;
var error = event.target.error;
is(error, null, "error code set to SUCCESS for successful data accesses");
is(testData.length, fileAsUTF16.length, "UTF-16 async length should match testdata");
@ -199,7 +199,7 @@ function handleTextUTF16(event) {
}
function handleTextUTF32(event) {
var fileAsUTF32 = event.target.response;
var fileAsUTF32 = event.target.result;
var error = event.target.error;
is(error, null, "error code set to SUCCESS for successful data accesses");
is(testData.length, fileAsUTF32.length, "UTF-32 async length should match testdata");
@ -209,7 +209,7 @@ function handleTextUTF32(event) {
//Tests dataURI.length % 3 == 0
function handleDataURI(event) {
var fileAsDataURI = event.target.response;
var fileAsDataURI = event.target.result;
is(domFileData.length, fileAsDataURI.length, "data URI async length should match dom file data");
is(domFileData, fileAsDataURI, "data URI async string result should match dom file data");
testHasRun();
@ -217,7 +217,7 @@ function handleDataURI(event) {
//Tests dataURI.length % 3 == 1
function handleDataURI1(event) {
var fileAsDataURI = event.target.response;
var fileAsDataURI = event.target.result;
is(domFileData1.length, fileAsDataURI.length, "data URI async length should match dom file data1");
is(domFileData1, fileAsDataURI, "data URI async string result should match dom file data1");
testHasRun();
@ -225,35 +225,35 @@ function handleDataURI1(event) {
//Tests dataURI.length % 3 == 2
function handleDataURI2(event) {
var fileAsDataURI = event.target.response;
var fileAsDataURI = event.target.result;
is(domFileData2.length, fileAsDataURI.length, "data URI async length should match dom file data2");
is(domFileData2, fileAsDataURI, "data URI async string result should match dom file data2");
testHasRun();
}
function handleDataBinary(event) {
var fileAsBinary = event.target.response;
var fileAsBinary = event.target.result;
is(domFileBinary.length, fileAsBinary.length, "binary data async length should match dom file binary");
is(domFileBinary, fileAsBinary, "binary data async string result should match dom file binary");
testHasRun();
}
function handleDataBinary16(event) {
var fileAsBinary = event.target.response;
var fileAsBinary = event.target.result;
is(domFileBinary2.length, fileAsBinary.length, "binary data async length should match dom file binary16");
is(domFileBinary2, fileAsBinary, "binary data async string result should match dom file binary16");
testHasRun();
}
function handleDataBinary32(event) {
var fileAsBinary = event.target.response;
var fileAsBinary = event.target.result;
is(domFileBinary3.length, fileAsBinary.length, "binary data async length should match dom file binary32");
is(domFileBinary3, fileAsBinary, "binary data async string result should match dom file binary32");
testHasRun();
}
function handleSecurityError(event) {
var fileAsText = event.target.response;
var fileAsText = event.target.result;
var error = event.target.error;
is(error.code, FileError.SECURITY_ERR, "code for file security error should have value 18");
is(fileAsText, null, "file content should be null when error is encountered");
@ -261,7 +261,7 @@ function handleSecurityError(event) {
}
function handleNotFoundError(event) {
var fileAsText = event.target.response;
var fileAsText = event.target.result;
var error = event.target.error;
is(error.code, FileError.NOT_FOUND_ERR, "code for file not found error should have value 8");
is(fileAsText, null, "file content should be null when error is encountered");

View File

@ -455,7 +455,7 @@
#include "nsDOMWorker.h"
#include "nsDOMFile.h"
#include "nsDOMFileRequest.h"
#include "nsDOMFileReader.h"
#include "nsIDOMFileException.h"
#include "nsIDOMFileError.h"
@ -1254,7 +1254,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(FileError, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(FileRequest, nsEventTargetSH,
NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
@ -1376,7 +1376,7 @@ struct nsContractIDMapData
static const nsContractIDMapData kConstructorMap[] =
{
NS_DEFINE_CONSTRUCTOR_DATA(DOMParser, NS_DOMPARSER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(FileRequest, NS_FILEREQUEST_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(FileReader, NS_FILEREADER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(XMLHttpRequest, NS_XMLHTTPREQUEST_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID)
@ -3582,8 +3582,8 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIException)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(FileRequest, nsIDOMFileRequest)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileRequest)
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)

View File

@ -416,7 +416,7 @@ enum nsDOMClassInfoID {
eDOMClassInfo_File_id,
eDOMClassInfo_FileException_id,
eDOMClassInfo_FileError_id,
eDOMClassInfo_FileRequest_id,
eDOMClassInfo_FileReader_id,
// DOM modal content window class, almost identical to Window
eDOMClassInfo_ModalContentWindow_id,

View File

@ -118,7 +118,7 @@
// DOM includes
#include "nsDOMException.h"
#include "nsDOMFileRequest.h"
#include "nsDOMFileReader.h"
#include "nsGlobalWindowCommands.h"
#include "nsIControllerCommandTable.h"
#include "nsJSProtocolHandler.h"
@ -291,7 +291,7 @@ NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsXPathEvaluator, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsXMLHttpRequest, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDOMFileRequest, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDOMFileReader, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMParser)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDOMStorageManager,
nsDOMStorageManager::GetInstance)
@ -1376,10 +1376,10 @@ static const nsModuleComponentInfo gComponents[] = {
NS_XMLSERIALIZER_CONTRACTID,
nsDOMSerializerConstructor },
{ "FileRequest",
NS_FILEREQUEST_CID,
NS_FILEREQUEST_CONTRACTID,
nsDOMFileRequestConstructor },
{ "FileReader",
NS_FILEREADER_CID,
NS_FILEREADER_CONTRACTID,
nsDOMFileReaderConstructor },
{ "XMLHttpRequest",
NS_XMLHTTPREQUEST_CID,