From 29d7b0825b2f18b68c996abe9430cfbacae731e7 Mon Sep 17 00:00:00 2001 From: Butkovits Atila Date: Tue, 9 Jun 2020 17:06:04 +0300 Subject: [PATCH] Backed out changeset d10fb80f7aa0 (bug 1502403) for build bustages at rules.mk. CLOSED TREE --- dom/file/FileReader.cpp | 66 +------------------ dom/file/FileReader.h | 6 -- dom/file/tests/common_fileReader.js | 6 +- .../filereader_abort.html.ini | 4 ++ .../filereader_events.any.js.ini | 15 +++++ .../filereader_result.html.ini | 16 +++++ 6 files changed, 41 insertions(+), 72 deletions(-) create mode 100644 testing/web-platform/meta/FileAPI/reading-data-section/filereader_abort.html.ini create mode 100644 testing/web-platform/meta/FileAPI/reading-data-section/filereader_events.any.js.ini create mode 100644 testing/web-platform/meta/FileAPI/reading-data-section/filereader_result.html.ini diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp index f806dacfedb6..3d2d3a092ea6 100644 --- a/dom/file/FileReader.cpp +++ b/dom/file/FileReader.cpp @@ -84,29 +84,6 @@ class MOZ_RAII FileReaderDecreaseBusyCounter { ~FileReaderDecreaseBusyCounter() { mFileReader->DecreaseBusyCounter(); } }; -class FileReader::AsyncWaitRunnable final : public CancelableRunnable { - public: - explicit AsyncWaitRunnable(FileReader* aReader) - : CancelableRunnable("FileReader::AsyncWaitRunnable"), mReader(aReader) {} - - NS_IMETHOD - Run() override { - if (mReader) { - mReader->InitialAsyncWait(); - } - return NS_OK; - } - - NS_IMETHOD - Cancel() override { - mReader = nullptr; - return NS_OK; - } - - public: - RefPtr mReader; -}; - void FileReader::RootResultArrayBuffer() { mozilla::HoldJSObjects(this); } // FileReader constructors/initializers @@ -179,7 +156,7 @@ void FileReader::GetResult(JSContext* aCx, return; } - if (mReadyState != DONE || mResult.IsVoid()) { + if (mResult.IsVoid()) { aResult.SetNull(); return; } @@ -423,8 +400,7 @@ void FileReader::ReadFileContent(Blob& aBlob, const nsAString& aCharset, } } - mAsyncWaitRunnable = new AsyncWaitRunnable(this); - aRv = NS_DispatchToCurrentThread(mAsyncWaitRunnable); + aRv = DoAsyncWait(); if (NS_WARN_IF(aRv.Failed())) { FreeFileData(); return; @@ -432,18 +408,6 @@ void FileReader::ReadFileContent(Blob& aBlob, const nsAString& aCharset, // FileReader should be in loading state here mReadyState = LOADING; -} - -void FileReader::InitialAsyncWait() { - mAsyncWaitRunnable = nullptr; - - nsresult rv = DoAsyncWait(); - if (NS_WARN_IF(NS_FAILED(rv))) { - mReadyState = EMPTY; - FreeFileData(); - return; - } - DispatchProgressEvent(NS_LITERAL_STRING(LOADSTART_STR)); } @@ -730,11 +694,6 @@ void FileReader::Abort() { ClearProgressEventTimer(); - if (mAsyncWaitRunnable) { - mAsyncWaitRunnable->Cancel(); - mAsyncWaitRunnable = nullptr; - } - mReadyState = DONE; // XXX The spec doesn't say this @@ -744,20 +703,6 @@ void FileReader::Abort() { SetDOMStringToNull(mResult); mResultArrayBuffer = nullptr; - // If we have the stream and the busy-count is not 0, it means that we are - // waiting for an OnInputStreamReady() call. Let's abort the current - // AsyncWait() calling it again with a nullptr callback. See - // nsIAsyncInputStream.idl. - if (mAsyncStream && mBusyCount) { - mAsyncStream->AsyncWait(/* callback */ nullptr, - /* aFlags*/ 0, - /* aRequestedCount */ 0, mTarget); - DecreaseBusyCounter(); - MOZ_ASSERT(mBusyCount == 0); - - mAsyncStream->Close(); - } - mAsyncStream = nullptr; mBlob = nullptr; @@ -767,7 +712,7 @@ void FileReader::Abort() { // Dispatch the events DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR)); DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR)); -} // namespace dom +} nsresult FileReader::IncreaseBusyCounter() { if (mWeakWorkerRef && mBusyCount++ == 0) { @@ -800,11 +745,6 @@ void FileReader::DecreaseBusyCounter() { void FileReader::Shutdown() { mReadyState = DONE; - if (mAsyncWaitRunnable) { - mAsyncWaitRunnable->Cancel(); - mAsyncWaitRunnable = nullptr; - } - if (mAsyncStream) { mAsyncStream->Close(); mAsyncStream = nullptr; diff --git a/dom/file/FileReader.h b/dom/file/FileReader.h index fa0042815d0f..2487f366e41a 100644 --- a/dom/file/FileReader.h +++ b/dom/file/FileReader.h @@ -117,8 +117,6 @@ class FileReader final : public DOMEventTargetHelper, eDataFormat DataFormat() const { return mDataFormat; } const nsString& Result() const { return mResult; } - void InitialAsyncWait(); - private: virtual ~FileReader(); @@ -193,10 +191,6 @@ class FileReader final : public DOMEventTargetHelper, // This value is set when the reading starts in order to keep the worker alive // during the process. RefPtr mStrongWorkerRef; - - // Runnable to start the reading asynchronous. - class AsyncWaitRunnable; - RefPtr mAsyncWaitRunnable; }; NS_DEFINE_STATIC_IID_ACCESSOR(FileReader, FILEREADER_ID) diff --git a/dom/file/tests/common_fileReader.js b/dom/file/tests/common_fileReader.js index 3df3a361149b..affcee3cf183 100644 --- a/dom/file/tests/common_fileReader.js +++ b/dom/file/tests/common_fileReader.js @@ -344,7 +344,7 @@ function test_readAsText(blob, text) { is(r.readyState, FileReader.LOADING, "correct loading text readyState"); is(onloadHasRun, false, "text loading must be async"); - is(onloadStartHasRun, false, "text loadstart should fire async"); + is(onloadStartHasRun, true, "text loadstart should fire sync"); }); } @@ -378,7 +378,7 @@ function test_readAsBinaryString(blob, text) { is(r.readyState, FileReader.LOADING, "correct loading binary readyState"); is(onloadHasRun, false, "binary loading must be async"); - is(onloadStartHasRun, false, "binary loadstart should fire async"); + is(onloadStartHasRun, true, "binary loadstart should fire sync"); }); } @@ -419,7 +419,7 @@ function test_readAsArrayBuffer(blob, text) { "correct loading arrayBuffer readyState" ); is(onloadHasRun, false, "arrayBuffer loading must be async"); - is(onloadStartHasRun, false, "arrayBuffer loadstart should fire sync"); + is(onloadStartHasRun, true, "arrayBuffer loadstart should fire sync"); }); } diff --git a/testing/web-platform/meta/FileAPI/reading-data-section/filereader_abort.html.ini b/testing/web-platform/meta/FileAPI/reading-data-section/filereader_abort.html.ini new file mode 100644 index 000000000000..d25bc2191b0b --- /dev/null +++ b/testing/web-platform/meta/FileAPI/reading-data-section/filereader_abort.html.ini @@ -0,0 +1,4 @@ +[filereader_abort.html] + [Aborting after read] + expected: FAIL + diff --git a/testing/web-platform/meta/FileAPI/reading-data-section/filereader_events.any.js.ini b/testing/web-platform/meta/FileAPI/reading-data-section/filereader_events.any.js.ini new file mode 100644 index 000000000000..fe19471261dc --- /dev/null +++ b/testing/web-platform/meta/FileAPI/reading-data-section/filereader_events.any.js.ini @@ -0,0 +1,15 @@ +[filereader_events.any.html] + [events are dispatched in the correct order for a non-empty blob] + expected: FAIL + + [events are dispatched in the correct order for an empty blob] + expected: FAIL + + +[filereader_events.any.worker.html] + [events are dispatched in the correct order for a non-empty blob] + expected: FAIL + + [events are dispatched in the correct order for an empty blob] + expected: FAIL + diff --git a/testing/web-platform/meta/FileAPI/reading-data-section/filereader_result.html.ini b/testing/web-platform/meta/FileAPI/reading-data-section/filereader_result.html.ini new file mode 100644 index 000000000000..cda42af42c0f --- /dev/null +++ b/testing/web-platform/meta/FileAPI/reading-data-section/filereader_result.html.ini @@ -0,0 +1,16 @@ +[filereader_result.html] + [result is null during "loadstart" event for readAsBinaryString] + expected: FAIL + + [result is null during "loadstart" event for readAsDataURL] + expected: FAIL + + [result is null during "progress" event for readAsBinaryString] + expected: FAIL + + [result is null during "loadstart" event for readAsArrayBuffer] + expected: FAIL + + [result is null during "loadstart" event for readAsText] + expected: FAIL +