summaryrefslogtreecommitdiffstats
path: root/dom/xhr
diff options
context:
space:
mode:
Diffstat (limited to 'dom/xhr')
-rw-r--r--dom/xhr/XMLHttpRequest.h85
-rw-r--r--dom/xhr/XMLHttpRequestMainThread.cpp80
-rw-r--r--dom/xhr/XMLHttpRequestMainThread.h11
-rw-r--r--dom/xhr/XMLHttpRequestWorker.cpp3
-rw-r--r--dom/xhr/tests/file_XHRResponseURL.js12
-rw-r--r--dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html2
-rw-r--r--dom/xhr/tests/relativeLoad_worker.js2
-rw-r--r--dom/xhr/tests/temporaryFileBlob.sjs4
-rw-r--r--dom/xhr/tests/terminateSyncXHR_worker.js2
-rw-r--r--dom/xhr/tests/test_XHR.js3
-rw-r--r--dom/xhr/tests/test_XHRDocURI.html40
-rw-r--r--dom/xhr/tests/test_XHR_timeout.js2
-rw-r--r--dom/xhr/tests/test_bug1752863_worker.js2
-rw-r--r--dom/xhr/tests/test_worker_xhr_responseURL.html2
-rw-r--r--dom/xhr/tests/test_worker_xhr_system.js4
-rw-r--r--dom/xhr/tests/test_xhr_progressevents.html2
-rw-r--r--dom/xhr/tests/worker_temporaryFileBlob.js3
-rw-r--r--dom/xhr/tests/worker_terminateSyncXHR_frame.html2
-rw-r--r--dom/xhr/tests/xhrAbort_worker.js4
-rw-r--r--dom/xhr/tests/xhr_worker.js18
20 files changed, 162 insertions, 121 deletions
diff --git a/dom/xhr/XMLHttpRequest.h b/dom/xhr/XMLHttpRequest.h
index 0d82f8c035..a7c4c0550c 100644
--- a/dom/xhr/XMLHttpRequest.h
+++ b/dom/xhr/XMLHttpRequest.h
@@ -29,9 +29,12 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget {
const char* cStr;
const char16_t* str;
- EventType(const char* name, const char16_t* uname)
+ constexpr EventType(const char* name, const char16_t* uname)
: cStr(name), str(uname) {}
+ constexpr EventType(const EventType& other)
+ : cStr(other.cStr), str(other.str) {}
+
operator const nsDependentString() const { return nsDependentString(str); }
friend bool operator==(const EventType& a, const EventType& b) {
@@ -56,55 +59,26 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget {
};
struct ProgressEventType : public EventType {
- ProgressEventType(const char* name, const char16_t* uname)
+ constexpr ProgressEventType(const char* name, const char16_t* uname)
: EventType(name, uname) {}
};
struct ErrorProgressEventType : public ProgressEventType {
const nsresult errorCode;
-
- ErrorProgressEventType(const char* name, const char16_t* uname,
- const nsresult code)
+ constexpr ErrorProgressEventType(const char* name, const char16_t* uname,
+ const nsresult code)
: ProgressEventType(name, uname), errorCode(code) {}
};
-#define DECL_EVENT(NAME) \
- static inline const EventType NAME = EventType(#NAME, u## #NAME);
-
-#define DECL_PROGRESSEVENT(NAME) \
- static inline const ProgressEventType NAME = \
- ProgressEventType(#NAME, u## #NAME);
-
-#define DECL_ERRORPROGRESSEVENT(NAME, ERR) \
- static inline const ErrorProgressEventType NAME = \
- ErrorProgressEventType(#NAME, u## #NAME, ERR);
-
- struct Events {
- DECL_EVENT(readystatechange);
- DECL_PROGRESSEVENT(loadstart);
- DECL_PROGRESSEVENT(progress);
- DECL_ERRORPROGRESSEVENT(error, NS_ERROR_DOM_NETWORK_ERR);
- DECL_ERRORPROGRESSEVENT(abort, NS_ERROR_DOM_ABORT_ERR);
- DECL_ERRORPROGRESSEVENT(timeout, NS_ERROR_DOM_TIMEOUT_ERR);
- DECL_PROGRESSEVENT(load);
- DECL_PROGRESSEVENT(loadend);
-
- static inline const EventType* All[]{
- &readystatechange, &loadstart, &progress, &error, &abort,
- &timeout, &load, &loadend};
-
- static inline const EventType* ProgressEvents[]{
- &loadstart, &progress, &error, &abort, &timeout, &load, &loadend};
-
- static inline const EventType* Find(const nsString& name) {
- for (const EventType* type : Events::All) {
- if (*type == name) {
- return type;
- }
- }
- return nullptr;
- }
- };
+#define DECL_EVENT(NAME) static constexpr EventType NAME{#NAME, u## #NAME};
+
+#define DECL_PROGRESSEVENT(NAME) \
+ static constexpr ProgressEventType NAME { #NAME, u## #NAME }
+
+#define DECL_ERRORPROGRESSEVENT(NAME, ERR) \
+ static constexpr ErrorProgressEventType NAME{#NAME, u## #NAME, ERR};
+
+ struct Events;
static already_AddRefed<XMLHttpRequest> Constructor(
const GlobalObject& aGlobal, const MozXMLHttpRequestParameters& aParams,
@@ -216,6 +190,33 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget {
: XMLHttpRequestEventTarget(aGlobalObject) {}
};
+struct XMLHttpRequest::Events {
+ DECL_EVENT(readystatechange);
+ DECL_PROGRESSEVENT(loadstart);
+ DECL_PROGRESSEVENT(progress);
+ DECL_ERRORPROGRESSEVENT(error, NS_ERROR_DOM_NETWORK_ERR);
+ DECL_ERRORPROGRESSEVENT(abort, NS_ERROR_DOM_ABORT_ERR);
+ DECL_ERRORPROGRESSEVENT(timeout, NS_ERROR_DOM_TIMEOUT_ERR);
+ DECL_PROGRESSEVENT(load);
+ DECL_PROGRESSEVENT(loadend);
+
+ static inline const EventType* All[]{
+ &readystatechange, &loadstart, &progress, &error, &abort,
+ &timeout, &load, &loadend};
+
+ static inline const EventType* ProgressEvents[]{
+ &loadstart, &progress, &error, &abort, &timeout, &load, &loadend};
+
+ static inline const EventType* Find(const nsString& name) {
+ for (const EventType* type : Events::All) {
+ if (*type == name) {
+ return type;
+ }
+ }
+ return nullptr;
+ }
+};
+
} // namespace mozilla::dom
#endif // mozilla_dom_XMLHttpRequest_h
diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp
index dc256b10c2..ace26f296f 100644
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -40,6 +40,7 @@
#include "mozilla/LoadInfo.h"
#include "mozilla/LoadContext.h"
#include "mozilla/MemoryReporting.h"
+#include "mozilla/net/ContentRange.h"
#include "mozilla/PreloaderBase.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/SpinEventLoopUntil.h"
@@ -48,9 +49,9 @@
#include "mozilla/StaticPrefs_privacy.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsDataChannel.h"
+#include "nsIBaseChannel.h"
#include "nsIJARChannel.h"
#include "nsIJARURI.h"
-#include "nsLayoutCID.h"
#include "nsReadableUtils.h"
#include "nsSandboxFlags.h"
@@ -186,15 +187,17 @@ static void AddLoadFlags(nsIRequest* request, nsLoadFlags newFlags) {
// invoked for increased scrutability. Save the previous value on the stack.
namespace {
struct DebugWorkerRefs {
- RefPtr<ThreadSafeWorkerRef>& mTSWorkerRef;
+ Mutex& mMutex;
+ RefPtr<ThreadSafeWorkerRef> mTSWorkerRef;
nsCString mPrev;
- DebugWorkerRefs(RefPtr<ThreadSafeWorkerRef>& aTSWorkerRef,
- const std::string& aStatus)
- : mTSWorkerRef(aTSWorkerRef) {
+ DebugWorkerRefs(XMLHttpRequestMainThread& aXHR, const std::string& aStatus)
+ : mMutex(aXHR.mTSWorkerRefMutex) {
+ MutexAutoLock lock(mMutex);
+
+ mTSWorkerRef = aXHR.mTSWorkerRef;
+
if (!mTSWorkerRef) {
- MOZ_LOG(gXMLHttpRequestLog, LogLevel::Info,
- ("No WorkerRef during: %s", aStatus.c_str()));
return;
}
@@ -206,6 +209,8 @@ struct DebugWorkerRefs {
}
~DebugWorkerRefs() {
+ MutexAutoLock lock(mMutex);
+
if (!mTSWorkerRef) {
return;
}
@@ -213,6 +218,8 @@ struct DebugWorkerRefs {
MOZ_ASSERT(mTSWorkerRef->Private());
SET_WORKERREF_DEBUG_STATUS(mTSWorkerRef->Ref(), mPrev);
+
+ mTSWorkerRef = nullptr;
}
};
} // namespace
@@ -220,11 +227,13 @@ struct DebugWorkerRefs {
# define STREAM_STRING(stuff) \
(((const std::ostringstream&)(std::ostringstream() << stuff)) \
.str()) // NOLINT
+
# define DEBUG_WORKERREFS \
- DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)(mTSWorkerRef, __func__)
+ DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)(*this, __func__)
+
# define DEBUG_WORKERREFS1(x) \
DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)( \
- mTSWorkerRef, STREAM_STRING(__func__ << ": " << x)) // NOLINT
+ *this, STREAM_STRING(__func__ << ": " << x)) // NOLINT
#else
# define DEBUG_WORKERREFS void()
@@ -236,6 +245,9 @@ bool XMLHttpRequestMainThread::sDontWarnAboutSyncXHR = false;
XMLHttpRequestMainThread::XMLHttpRequestMainThread(
nsIGlobalObject* aGlobalObject)
: XMLHttpRequest(aGlobalObject),
+#ifdef DEBUG
+ mTSWorkerRefMutex("Debug WorkerRefs"),
+#endif
mResponseBodyDecodedPos(0),
mResponseType(XMLHttpRequestResponseType::_empty),
mState(XMLHttpRequest_Binding::UNSENT),
@@ -864,14 +876,28 @@ bool XMLHttpRequestMainThread::IsDeniedCrossSiteCORSRequest() {
return false;
}
-Maybe<nsBaseChannel::ContentRange>
+bool XMLHttpRequestMainThread::BadContentRangeRequested() {
+ if (!mChannel) {
+ return false;
+ }
+ // Only nsIBaseChannel supports this
+ nsCOMPtr<nsIBaseChannel> baseChan = do_QueryInterface(mChannel);
+ if (!baseChan) {
+ return false;
+ }
+ // A bad range was requested if the channel has no content range
+ // despite the request specifying a range header.
+ return !baseChan->ContentRange() && mAuthorRequestHeaders.Has("range");
+}
+
+RefPtr<mozilla::net::ContentRange>
XMLHttpRequestMainThread::GetRequestedContentRange() const {
MOZ_ASSERT(mChannel);
- nsBaseChannel* baseChan = static_cast<nsBaseChannel*>(mChannel.get());
+ nsCOMPtr<nsIBaseChannel> baseChan = do_QueryInterface(mChannel);
if (!baseChan) {
- return mozilla::Nothing();
+ return nullptr;
}
- return baseChan->GetContentRange();
+ return baseChan->ContentRange();
}
void XMLHttpRequestMainThread::GetContentRangeHeader(nsACString& out) const {
@@ -879,8 +905,8 @@ void XMLHttpRequestMainThread::GetContentRangeHeader(nsACString& out) const {
out.SetIsVoid(true);
return;
}
- Maybe<nsBaseChannel::ContentRange> range = GetRequestedContentRange();
- if (range.isSome()) {
+ RefPtr<mozilla::net::ContentRange> range = GetRequestedContentRange();
+ if (range) {
range->AsHeader(out);
} else {
out.SetIsVoid(true);
@@ -944,8 +970,7 @@ uint32_t XMLHttpRequestMainThread::GetStatus(ErrorResult& aRv) {
nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel();
if (!httpChannel) {
// Pretend like we got a 200/206 response, since our load was successful
- return IsBlobURI(mRequestURL) && GetRequestedContentRange().isSome() ? 206
- : 200;
+ return GetRequestedContentRange() ? 206 : 200;
}
uint32_t status;
@@ -1194,13 +1219,13 @@ bool XMLHttpRequestMainThread::IsSafeHeader(
bool XMLHttpRequestMainThread::GetContentType(nsACString& aValue) const {
MOZ_ASSERT(mChannel);
- nsCOMPtr<nsIURI> uri;
- if (NS_SUCCEEDED(mChannel->GetURI(getter_AddRefs(uri))) &&
- uri->SchemeIs("data")) {
- nsDataChannel* dchan = static_cast<nsDataChannel*>(mChannel.get());
- MOZ_ASSERT(dchan);
- aValue.Assign(dchan->MimeType());
- return true;
+ nsCOMPtr<nsIBaseChannel> baseChan = do_QueryInterface(mChannel);
+ if (baseChan) {
+ RefPtr<CMimeType> fullMimeType(baseChan->FullMimeType());
+ if (fullMimeType) {
+ fullMimeType->Serialize(aValue);
+ return true;
+ }
}
if (NS_SUCCEEDED(mChannel->GetContentType(aValue))) {
nsCString value;
@@ -1956,8 +1981,7 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request) {
// If we were asked for a bad range on a blob URL, but we're async,
// we should throw now in order to fire an error progress event.
- if (IsBlobURI(mRequestURL) && GetRequestedContentRange().isNothing() &&
- mAuthorRequestHeaders.Has("range")) {
+ if (BadContentRangeRequested()) {
return NS_ERROR_NET_PARTIAL_TRANSFER;
}
@@ -3128,7 +3152,7 @@ void XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
if (uploadContentType.IsVoid()) {
uploadContentType = defaultContentType;
} else if (aBodyIsDocumentOrString) {
- UniquePtr<CMimeType> contentTypeRecord =
+ RefPtr<CMimeType> contentTypeRecord =
CMimeType::Parse(uploadContentType);
nsAutoCString charset;
if (contentTypeRecord &&
@@ -3391,7 +3415,7 @@ void XMLHttpRequestMainThread::OverrideMimeType(const nsAString& aMimeType,
return;
}
- UniquePtr<MimeType> parsed = MimeType::Parse(aMimeType);
+ RefPtr<MimeType> parsed = MimeType::Parse(aMimeType);
if (parsed) {
parsed->Serialize(mOverrideMimeType);
} else {
diff --git a/dom/xhr/XMLHttpRequestMainThread.h b/dom/xhr/XMLHttpRequestMainThread.h
index 3f2d395991..b860f041fb 100644
--- a/dom/xhr/XMLHttpRequestMainThread.h
+++ b/dom/xhr/XMLHttpRequestMainThread.h
@@ -48,7 +48,6 @@
#include "mozilla/dom/XMLHttpRequestEventTarget.h"
#include "mozilla/dom/XMLHttpRequestString.h"
#include "mozilla/Encoding.h"
-#include "nsBaseChannel.h"
#ifdef Status
/* Xlib headers insist on this for some reason... Nuke it because
@@ -65,6 +64,10 @@ class nsILoadGroup;
namespace mozilla {
class ProfileChunkedBuffer;
+namespace net {
+class ContentRange;
+}
+
namespace dom {
class DOMString;
@@ -447,7 +450,8 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
#ifdef DEBUG
// For logging when there's trouble
- RefPtr<ThreadSafeWorkerRef> mTSWorkerRef = nullptr;
+ RefPtr<ThreadSafeWorkerRef> mTSWorkerRef MOZ_GUARDED_BY(mTSWorkerRefMutex);
+ Mutex mTSWorkerRefMutex;
#endif
protected:
@@ -507,7 +511,8 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
void AbortInternal(ErrorResult& aRv);
- Maybe<nsBaseChannel::ContentRange> GetRequestedContentRange() const;
+ bool BadContentRangeRequested();
+ RefPtr<mozilla::net::ContentRange> GetRequestedContentRange() const;
void GetContentRangeHeader(nsACString&) const;
struct PendingEvent {
diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp
index 371f444ee9..7fdfa8fee9 100644
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -198,11 +198,13 @@ class Proxy final : public nsIDOMEventListener {
#ifdef DEBUG
void DebugStoreWorkerRef(RefPtr<StrongWorkerRef>& aWorkerRef) {
MOZ_ASSERT(!NS_IsMainThread());
+ MutexAutoLock lock(mXHR->mTSWorkerRefMutex);
mXHR->mTSWorkerRef = new ThreadSafeWorkerRef(aWorkerRef);
}
void DebugForgetWorkerRef() {
MOZ_ASSERT(!NS_IsMainThread());
+ MutexAutoLock lock(mXHR->mTSWorkerRefMutex);
mXHR->mTSWorkerRef = nullptr;
}
#endif
@@ -325,7 +327,6 @@ class LoadStartDetectionRunnable final : public Runnable,
WorkerPrivate* mWorkerPrivate;
RefPtr<Proxy> mProxy;
RefPtr<XMLHttpRequest> mXHR;
- nsString mEventType;
uint32_t mChannelId;
bool mReceivedLoadStart;
diff --git a/dom/xhr/tests/file_XHRResponseURL.js b/dom/xhr/tests/file_XHRResponseURL.js
index 1ab1694bfa..29e6ddea69 100644
--- a/dom/xhr/tests/file_XHRResponseURL.js
+++ b/dom/xhr/tests/file_XHRResponseURL.js
@@ -51,7 +51,7 @@ function info(aMessage) {
}
function request(aURL) {
- return new Promise(function (aResolve, aReject) {
+ return new Promise(function (aResolve) {
var xhr = new XMLHttpRequest();
xhr.open("GET", aURL);
xhr.addEventListener("load", function () {
@@ -272,7 +272,7 @@ function testNotToLeakResponseURLWhileDoingRedirects() {
function testNotToLeakResponseURLWhileDoingRedirectsInWindow() {
var xhr = new XMLHttpRequest();
var requestObserver = {
- observe(aSubject, aTopic, aData) {
+ observe() {
is(xhr.readyState, XMLHttpRequest.OPENED, "assert for XHR state");
is(
xhr.responseURL,
@@ -286,7 +286,7 @@ function testNotToLeakResponseURLWhileDoingRedirectsInWindow() {
"specialpowers-http-notify-request"
);
- return new Promise(function (aResolve, aReject) {
+ return new Promise(function (aResolve) {
xhr.open(
"GET",
"http://mochi.test:8888/tests/dom/xhr/tests/file_XHRResponseURL.sjs?url=http://mochi.test:8888/tests/dom/xhr/tests/file_XHRResponseURL.text"
@@ -322,7 +322,7 @@ function testNotToLeakResponseURLWhileDoingRedirectsInWorker() {
}
};
- return new Promise(function (aResolve, aReject) {
+ return new Promise(function (aResolve) {
self.addEventListener("message", testRedirect);
message({ type: "redirect_test", status: "start" });
xhr.open(
@@ -334,7 +334,7 @@ function testNotToLeakResponseURLWhileDoingRedirectsInWorker() {
message({ type: "redirect_test", status: "end" });
aResolve();
});
- xhr.addEventListener("error", function (e) {
+ xhr.addEventListener("error", function () {
ok(false, "unexpected request falilure");
self.removeEventListener("message", testRedirect);
message({ type: "redirect_test", status: "end" });
@@ -345,7 +345,7 @@ function testNotToLeakResponseURLWhileDoingRedirectsInWorker() {
}
function waitForAllMessagesProcessed() {
- return new Promise(function (aResolve, aReject) {
+ return new Promise(function (aResolve) {
var id = setInterval(function () {
if (message.ping === message.pong) {
clearInterval(id);
diff --git a/dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html b/dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html
index 2135011d9c..895fbc4e4b 100644
--- a/dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html
+++ b/dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html
@@ -7,7 +7,7 @@ function syncXHR() {
xhr.send(null);
}
-addEventListener('load', evt => {
+addEventListener('load', () => {
syncXHR();
document.open();
document.write(
diff --git a/dom/xhr/tests/relativeLoad_worker.js b/dom/xhr/tests/relativeLoad_worker.js
index b600b592be..6d281244c2 100644
--- a/dom/xhr/tests/relativeLoad_worker.js
+++ b/dom/xhr/tests/relativeLoad_worker.js
@@ -6,7 +6,7 @@
/* global workerURL */
const importURL = "relativeLoad_import.js";
-onmessage = function (event) {
+onmessage = function () {
var xhr = new XMLHttpRequest();
xhr.open("GET", "worker_testXHR.txt", false);
xhr.send(null);
diff --git a/dom/xhr/tests/temporaryFileBlob.sjs b/dom/xhr/tests/temporaryFileBlob.sjs
index d952b325ce..151c05a231 100644
--- a/dom/xhr/tests/temporaryFileBlob.sjs
+++ b/dom/xhr/tests/temporaryFileBlob.sjs
@@ -28,7 +28,7 @@ function handleRequest(request, response) {
bos.writeByteArray(part);
response.timer1 = new Timer(
- function (timer) {
+ function () {
bos.writeByteArray(bodyBytes);
},
1000,
@@ -36,7 +36,7 @@ function handleRequest(request, response) {
);
response.timer2 = new Timer(
- function (timer) {
+ function () {
response.finish();
},
2000,
diff --git a/dom/xhr/tests/terminateSyncXHR_worker.js b/dom/xhr/tests/terminateSyncXHR_worker.js
index 7a2509af3d..29a5a8a369 100644
--- a/dom/xhr/tests/terminateSyncXHR_worker.js
+++ b/dom/xhr/tests/terminateSyncXHR_worker.js
@@ -3,7 +3,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-onmessage = function (event) {
+onmessage = function () {
throw new Error("No messages should reach me!");
};
diff --git a/dom/xhr/tests/test_XHR.js b/dom/xhr/tests/test_XHR.js
index 12eb06e4f6..0034f8a0eb 100644
--- a/dom/xhr/tests/test_XHR.js
+++ b/dom/xhr/tests/test_XHR.js
@@ -1,4 +1,7 @@
"use strict";
+
+/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */
+
SimpleTest.waitForExplicitFinish();
var gen = runTests();
diff --git a/dom/xhr/tests/test_XHRDocURI.html b/dom/xhr/tests/test_XHRDocURI.html
index 1062be13a6..61be580ddd 100644
--- a/dom/xhr/tests/test_XHRDocURI.html
+++ b/dom/xhr/tests/test_XHRDocURI.html
@@ -89,7 +89,7 @@ function* runTest() {
// use content XHR and access URI properties from content privileged script
var xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -108,7 +108,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -126,7 +126,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.text");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
is(xhr.responseXML, null, "should not have document");
if (xhr.readyState == 4) {
gen.next();
@@ -137,7 +137,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -156,7 +156,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -174,7 +174,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.sjs?url=http://example.com/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -193,7 +193,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.sjs?url=http://example.com/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -211,7 +211,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.text");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
is(xhr.responseXML, null, "should not have document");
if (xhr.readyState == 4) {
gen.next();
@@ -225,7 +225,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -246,7 +246,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -266,7 +266,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -287,7 +287,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -307,7 +307,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.sjs?url=http://example.com/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -328,7 +328,7 @@ function* runTest() {
xhr = new XMLHttpRequest;
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.sjs?url=http://example.com/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -351,7 +351,7 @@ function* runTest() {
SpecialPowers.addPermission("systemXHR", true, document);
xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -370,7 +370,7 @@ function* runTest() {
xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -388,7 +388,7 @@ function* runTest() {
xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -407,7 +407,7 @@ function* runTest() {
xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", "http://example.com/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
@@ -425,7 +425,7 @@ function* runTest() {
xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.sjs?url=http://example.com/tests/dom/xhr/tests/file_XHRDocURI.xml");
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.responseXML) {
return;
}
@@ -444,7 +444,7 @@ function* runTest() {
xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", "http://mochi.test:8888/tests/dom/xhr/tests/file_XHRDocURI.sjs?url=http://example.com/tests/dom/xhr/tests/file_XHRDocURI.html");
xhr.responseType = "document";
- xhr.onreadystatechange = function(e) {
+ xhr.onreadystatechange = function() {
if (!xhr.response) {
return;
}
diff --git a/dom/xhr/tests/test_XHR_timeout.js b/dom/xhr/tests/test_XHR_timeout.js
index 1e75c1c174..69986770e1 100644
--- a/dom/xhr/tests/test_XHR_timeout.js
+++ b/dom/xhr/tests/test_XHR_timeout.js
@@ -1,3 +1,5 @@
+/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */
+
/* Notes:
- All times are expressed in milliseconds in this test suite.
- Test harness code is at the end of this file.
diff --git a/dom/xhr/tests/test_bug1752863_worker.js b/dom/xhr/tests/test_bug1752863_worker.js
index 196b825c0c..929b005939 100644
--- a/dom/xhr/tests/test_bug1752863_worker.js
+++ b/dom/xhr/tests/test_bug1752863_worker.js
@@ -24,7 +24,7 @@ async function handleLoadstart() {
}
}
-self.onmessage = async function (ev) {
+self.onmessage = async function () {
xhr = new XMLHttpRequest({ mozAnon: false });
myself = self;
xhr.addEventListener("loadstart", handleLoadstart, true);
diff --git a/dom/xhr/tests/test_worker_xhr_responseURL.html b/dom/xhr/tests/test_worker_xhr_responseURL.html
index 89924e9815..b33cc880c6 100644
--- a/dom/xhr/tests/test_worker_xhr_responseURL.html
+++ b/dom/xhr/tests/test_worker_xhr_responseURL.html
@@ -16,7 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=998076
var worker = new Worker("../../../dom/xhr/tests/file_XHRResponseURL.js");
var requestObserver = {
- observe (aSubject, aTopic, aData) {
+ observe () {
worker.postMessage("request");
}
};
diff --git a/dom/xhr/tests/test_worker_xhr_system.js b/dom/xhr/tests/test_worker_xhr_system.js
index 23137801a0..ee5934363d 100644
--- a/dom/xhr/tests/test_worker_xhr_system.js
+++ b/dom/xhr/tests/test_worker_xhr_system.js
@@ -1,3 +1,5 @@
+/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */
+
function ok(what, msg) {
postMessage({ event: msg, test: "ok", a: what });
}
@@ -6,7 +8,7 @@ function is(a, b, msg) {
postMessage({ event: msg, test: "is", a, b });
}
-self.onmessage = function onmessage(event) {
+self.onmessage = function onmessage() {
// An XHR with system privileges will be able to do cross-site calls.
const TEST_URL =
diff --git a/dom/xhr/tests/test_xhr_progressevents.html b/dom/xhr/tests/test_xhr_progressevents.html
index ebfc06fd5b..69f549f7a8 100644
--- a/dom/xhr/tests/test_xhr_progressevents.html
+++ b/dom/xhr/tests/test_xhr_progressevents.html
@@ -12,7 +12,7 @@ SimpleTest.waitForExplicitFinish();
var gen = runTests();
-function log(s) {
+function log() {
// Uncomment these to get debugging information
/*
document.getElementById("l").textContent += s + "\n";
diff --git a/dom/xhr/tests/worker_temporaryFileBlob.js b/dom/xhr/tests/worker_temporaryFileBlob.js
index 50f071bab7..056b826e00 100644
--- a/dom/xhr/tests/worker_temporaryFileBlob.js
+++ b/dom/xhr/tests/worker_temporaryFileBlob.js
@@ -1,4 +1,7 @@
/* eslint-env worker */
+
+/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */
+
importScripts("common_temporaryFileBlob.js");
function info(msg) {
diff --git a/dom/xhr/tests/worker_terminateSyncXHR_frame.html b/dom/xhr/tests/worker_terminateSyncXHR_frame.html
index 04bd53ff1d..720cf9551d 100644
--- a/dom/xhr/tests/worker_terminateSyncXHR_frame.html
+++ b/dom/xhr/tests/worker_terminateSyncXHR_frame.html
@@ -16,7 +16,7 @@
parent.postMessage(event.data, "*");
};
- worker.onerror = function(event) {
+ worker.onerror = function() {
parent.postMessage("ERROR!", "*");
}
}
diff --git a/dom/xhr/tests/xhrAbort_worker.js b/dom/xhr/tests/xhrAbort_worker.js
index 6b82241d68..e922f8259f 100644
--- a/dom/xhr/tests/xhrAbort_worker.js
+++ b/dom/xhr/tests/xhrAbort_worker.js
@@ -57,11 +57,11 @@ function runTest() {
events.push(str);
}
- xhr.onerror = function (event) {
+ xhr.onerror = function () {
throw new Error("Error: " + xhr.statusText);
};
- xhr.onload = function (event) {
+ xhr.onload = function () {
throw new Error("Shouldn't have gotten load event!");
};
diff --git a/dom/xhr/tests/xhr_worker.js b/dom/xhr/tests/xhr_worker.js
index 46edd700db..4361b347e5 100644
--- a/dom/xhr/tests/xhr_worker.js
+++ b/dom/xhr/tests/xhr_worker.js
@@ -53,21 +53,21 @@ function onprogress(event) {
}
xhr.addEventListener("progress", onprogress);
-xhr.addEventListener("foopety", function (event) {});
-xhr.removeEventListener("doopety", function (event) {});
+xhr.addEventListener("foopety", function () {});
+xhr.removeEventListener("doopety", function () {});
-xhr.onloadend = function (event) {
+xhr.onloadend = function () {
const message = { type: "loadend" };
postMessage(message);
};
var upload = xhr.upload;
-upload.onprogress = function (event) {};
-upload.addEventListener("foo", function (event) {});
-upload.removeEventListener("foo", function (event) {});
-upload.addEventListener("load", function (event) {});
-upload.removeEventListener("foo", function (event) {});
-upload.onload = function (event) {
+upload.onprogress = function () {};
+upload.addEventListener("foo", function () {});
+upload.removeEventListener("foo", function () {});
+upload.addEventListener("load", function () {});
+upload.removeEventListener("foo", function () {});
+upload.onload = function () {
const message = { type: "upload.load" };
postMessage(message);
};