author | Boris Zbarsky <bzbarsky@mit.edu> |
Fri, 20 Nov 2015 13:36:46 -0500 | |
changeset 273659 | c0eab88b18c27ac2fa767725f3b6268c0aeb320e |
parent 273658 | 6a353499d50d88d242e37472d894dac73e900231 |
child 273660 | 79240162428553ba63d4f918643f44ae77444adb |
push id | 29710 |
push user | cbook@mozilla.com |
push date | Mon, 23 Nov 2015 13:09:07 +0000 |
treeherder | mozilla-central@d3d286102ba7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mccr8 |
bugs | 1226479 |
milestone | 45.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/archivereader/ArchiveReader.cpp +++ b/dom/archivereader/ArchiveReader.cpp @@ -32,17 +32,17 @@ ArchiveReader::Constructor(const GlobalO if (!window) { aError.Throw(NS_ERROR_UNEXPECTED); return nullptr; } nsAutoCString encoding; if (!EncodingUtils::FindEncodingForLabelNoReplacement(aOptions.mEncoding, encoding)) { - aError.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&aOptions.mEncoding); + aError.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(aOptions.mEncoding); return nullptr; } RefPtr<ArchiveReader> reader = new ArchiveReader(aBlob, window, encoding); return reader.forget(); }
--- a/dom/base/URL.cpp +++ b/dom/base/URL.cpp @@ -73,33 +73,33 @@ URL::Constructor(const GlobalObject& aGl /* static */ already_AddRefed<URL> URL::Constructor(nsISupports* aParent, const nsAString& aUrl, const nsAString& aBase, ErrorResult& aRv) { nsCOMPtr<nsIURI> baseUri; nsresult rv = NS_NewURI(getter_AddRefs(baseUri), aBase, nullptr, nullptr, nsContentUtils::GetIOService()); if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.ThrowTypeError<MSG_INVALID_URL>(&aBase); + aRv.ThrowTypeError<MSG_INVALID_URL>(aBase); return nullptr; } return Constructor(aParent, aUrl, baseUri, aRv); } /* static */ already_AddRefed<URL> URL::Constructor(nsISupports* aParent, const nsAString& aUrl, nsIURI* aBase, ErrorResult& aRv) { nsCOMPtr<nsIURI> uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, nullptr, aBase, nsContentUtils::GetIOService()); if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.ThrowTypeError<MSG_INVALID_URL>(&aUrl); + aRv.ThrowTypeError<MSG_INVALID_URL>(aUrl); return nullptr; } RefPtr<URL> url = new URL(aParent, uri.forget()); return url.forget(); } void @@ -224,18 +224,17 @@ URL::SetHref(const nsAString& aHref, Err if (NS_FAILED(rv)) { aRv.Throw(rv); return; } nsCOMPtr<nsIURI> uri; rv = ioService->NewURI(href, nullptr, nullptr, getter_AddRefs(uri)); if (NS_FAILED(rv)) { - nsAutoString label(aHref); - aRv.ThrowTypeError<MSG_INVALID_URL>(&label); + aRv.ThrowTypeError<MSG_INVALID_URL>(aHref); return; } mURI = uri; UpdateURLSearchParams(); } void
--- a/dom/base/nsIConsoleReportCollector.h +++ b/dom/base/nsIConsoleReportCollector.h @@ -44,29 +44,29 @@ public: virtual void AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory, nsContentUtils::PropertiesFile aPropertiesFile, const nsACString& aSourceFileURI, uint32_t aLineNumber, uint32_t aColumnNumber, const nsACString& aMessageName, const nsTArray<nsString>& aStringParams) = 0; // A version of AddConsoleReport() that accepts the message parameters - // as variable nsString arguments. Note, the parameters must be exactly - // nsString and not another string class. All other args the same as - // AddConsoleReport(). + // as variable nsString arguments (or really, any sort of const nsAString). + // All other args the same as AddConsoleReport(). template<typename... Params> void AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory, nsContentUtils::PropertiesFile aPropertiesFile, const nsACString& aSourceFileURI, uint32_t aLineNumber, uint32_t aColumnNumber, const nsACString& aMessageName, - Params... aParams) + Params&&... aParams) { nsTArray<nsString> params; - mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params), aParams...); + mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params), + mozilla::Forward<Params>(aParams)...); AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, aSourceFileURI, aLineNumber, aColumnNumber, aMessageName, params); } // Flush all pending reports to the console. Main thread only. // // aDocument An optional document representing where to flush the // reports. If provided, then the corresponding window's
--- a/dom/bindings/ErrorResult.h +++ b/dom/bindings/ErrorResult.h @@ -56,24 +56,24 @@ ThrowErrorMessage(JSContext* aCx, const struct StringArrayAppender { static void Append(nsTArray<nsString>& aArgs, uint16_t aCount) { MOZ_RELEASE_ASSERT(aCount == 0, "Must give at least as many string arguments as are required by the ErrNum."); } template<typename... Ts> - static void Append(nsTArray<nsString>& aArgs, uint16_t aCount, const nsAString* aFirst, Ts... aOtherArgs) + static void Append(nsTArray<nsString>& aArgs, uint16_t aCount, const nsAString& aFirst, Ts&&... aOtherArgs) { if (aCount == 0) { MOZ_ASSERT(false, "There should not be more string arguments provided than are required by the ErrNum."); return; } - aArgs.AppendElement(*aFirst); - Append(aArgs, aCount - 1, aOtherArgs...); + aArgs.AppendElement(aFirst); + Append(aArgs, aCount - 1, Forward<Ts>(aOtherArgs)...); } }; } // namespace dom class ErrorResult { public: ErrorResult() @@ -130,25 +130,27 @@ public: // SuppressException(), since there will no longer be a way to report it. nsresult StealNSResult() { nsresult rv = ErrorCode(); SuppressException(); return rv; } template<dom::ErrNum errorNumber, typename... Ts> - void ThrowTypeError(Ts... messageArgs) + void ThrowTypeError(Ts&&... messageArgs) { - ThrowErrorWithMessage<errorNumber>(NS_ERROR_TYPE_ERR, messageArgs...); + ThrowErrorWithMessage<errorNumber>(NS_ERROR_TYPE_ERR, + Forward<Ts>(messageArgs)...); } template<dom::ErrNum errorNumber, typename... Ts> - void ThrowRangeError(Ts... messageArgs) + void ThrowRangeError(Ts&&... messageArgs) { - ThrowErrorWithMessage<errorNumber>(NS_ERROR_RANGE_ERR, messageArgs...); + ThrowErrorWithMessage<errorNumber>(NS_ERROR_RANGE_ERR, + Forward<Ts>(messageArgs)...); } void ReportErrorWithMessage(JSContext* cx); bool IsErrorWithMessage() const { return ErrorCode() == NS_ERROR_TYPE_ERR || ErrorCode() == NS_ERROR_RANGE_ERR; } // Facilities for throwing a preexisting JS exception value via this // ErrorResult. The contract is that any code which might end up calling // ThrowJSException() must call MightThrowJSException() even if no exception @@ -259,28 +261,29 @@ private: void SerializeDOMExceptionInfo(IPC::Message* aMsg) const; bool DeserializeDOMExceptionInfo(const IPC::Message* aMsg, void** aIter); // Helper method that creates a new Message for this ErrorResult, // and returns the arguments array from that Message. nsTArray<nsString>& CreateErrorMessageHelper(const dom::ErrNum errorNumber, nsresult errorType); template<dom::ErrNum errorNumber, typename... Ts> - void ThrowErrorWithMessage(nsresult errorType, Ts... messageArgs) + void ThrowErrorWithMessage(nsresult errorType, Ts&&... messageArgs) { #if defined(DEBUG) && (defined(__clang__) || defined(__GNUC__)) static_assert(dom::ErrorFormatNumArgs[errorNumber] == sizeof...(messageArgs), "Pass in the right number of arguments"); #endif ClearUnionData(); nsTArray<nsString>& messageArgsArray = CreateErrorMessageHelper(errorNumber, errorType); uint16_t argCount = dom::GetErrorArgCount(errorNumber); - dom::StringArrayAppender::Append(messageArgsArray, argCount, messageArgs...); + dom::StringArrayAppender::Append(messageArgsArray, argCount, + Forward<Ts>(messageArgs)...); #ifdef DEBUG mUnionState = HasMessage; #endif // DEBUG } void AssignErrorCode(nsresult aRv) { MOZ_ASSERT(aRv != NS_ERROR_TYPE_ERR, "Use ThrowTypeError()"); MOZ_ASSERT(aRv != NS_ERROR_RANGE_ERR, "Use ThrowRangeError()");
--- a/dom/cache/Cache.cpp +++ b/dom/cache/Cache.cpp @@ -41,32 +41,32 @@ IsValidPutRequestURL(const nsAString& aU NS_ConvertUTF16toUTF8 url(aUrl); TypeUtils::ProcessURL(url, &validScheme, nullptr, nullptr, aRv); if (aRv.Failed()) { return false; } if (!validScheme) { - NS_NAMED_LITERAL_STRING(label, "Request"); - aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(&label, &aUrl); + aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(NS_LITERAL_STRING("Request"), + aUrl); return false; } return true; } static bool IsValidPutRequestMethod(const Request& aRequest, ErrorResult& aRv) { nsAutoCString method; aRequest.GetMethod(method); if (!method.LowerCaseEqualsLiteral("get")) { NS_ConvertASCIItoUTF16 label(method); - aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label); + aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label); return false; } return true; } static bool IsValidPutRequestMethod(const RequestOrUSVString& aRequest, ErrorResult& aRv)
--- a/dom/cache/TypeUtils.cpp +++ b/dom/cache/TypeUtils.cpp @@ -157,19 +157,19 @@ TypeUtils::ToCacheRequest(CacheRequest& bool schemeValid; ProcessURL(url, &schemeValid, &aOut.urlWithoutQuery(), &aOut.urlQuery(), aRv); if (aRv.Failed()) { return; } if (!schemeValid) { if (aSchemeAction == TypeErrorOnInvalidScheme) { - NS_NAMED_LITERAL_STRING(label, "Request"); NS_ConvertUTF8toUTF16 urlUTF16(url); - aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(&label, &urlUTF16); + aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(NS_LITERAL_STRING("Request"), + urlUTF16); return; } } aIn->GetReferrer(aOut.referrer()); RefPtr<InternalHeaders> headers = aIn->Headers(); MOZ_ASSERT(headers);
--- a/dom/encoding/TextDecoder.cpp +++ b/dom/encoding/TextDecoder.cpp @@ -21,17 +21,17 @@ TextDecoder::Init(const nsAString& aLabe { nsAutoCString encoding; // Let encoding be the result of getting an encoding from label. // If encoding is failure or replacement, throw a RangeError // (https://encoding.spec.whatwg.org/#dom-textdecoder). if (!EncodingUtils::FindEncodingForLabelNoReplacement(aLabel, encoding)) { nsAutoString label(aLabel); EncodingUtils::TrimSpaceCharacters(label); - aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&label); + aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(label); return; } InitWithEncoding(encoding, aFatal); } void TextDecoder::InitWithEncoding(const nsACString& aEncoding, const bool aFatal) {
--- a/dom/encoding/TextEncoder.cpp +++ b/dom/encoding/TextEncoder.cpp @@ -16,17 +16,17 @@ TextEncoder::Init(const nsAString& aEnco { nsAutoString label(aEncoding); EncodingUtils::TrimSpaceCharacters(label); // Let encoding be the result of getting an encoding from label. // If encoding is failure, or is none of utf-8, utf-16, and utf-16be, // throw a RangeError (https://encoding.spec.whatwg.org/#dom-textencoder). if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) { - aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&label); + aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(label); return; } if (!mEncoding.EqualsLiteral("UTF-8") && !mEncoding.EqualsLiteral("UTF-16LE") && !mEncoding.EqualsLiteral("UTF-16BE")) { aRv.ThrowRangeError<MSG_DOM_ENCODING_NOT_UTF>(); return;
--- a/dom/fetch/InternalHeaders.cpp +++ b/dom/fetch/InternalHeaders.cpp @@ -175,30 +175,30 @@ InternalHeaders::IsSimpleHeader(const ns } //static bool InternalHeaders::IsInvalidName(const nsACString& aName, ErrorResult& aRv) { if (!NS_IsValidHTTPToken(aName)) { NS_ConvertUTF8toUTF16 label(aName); - aRv.ThrowTypeError<MSG_INVALID_HEADER_NAME>(&label); + aRv.ThrowTypeError<MSG_INVALID_HEADER_NAME>(label); return true; } return false; } // static bool InternalHeaders::IsInvalidValue(const nsACString& aValue, ErrorResult& aRv) { if (!NS_IsReasonableHTTPHeaderValue(aValue)) { NS_ConvertUTF8toUTF16 label(aValue); - aRv.ThrowTypeError<MSG_INVALID_HEADER_VALUE>(&label); + aRv.ThrowTypeError<MSG_INVALID_HEADER_VALUE>(label); return true; } return false; } bool InternalHeaders::IsImmutable(ErrorResult& aRv) const {
--- a/dom/fetch/Request.cpp +++ b/dom/fetch/Request.cpp @@ -97,26 +97,26 @@ GetRequestURLFromDocument(nsIDocument* a { MOZ_ASSERT(aDocument); MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIURI> baseURI = aDocument->GetBaseURI(); nsCOMPtr<nsIURI> resolvedURI; aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr, baseURI); if (NS_WARN_IF(aRv.Failed())) { - aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput); + aRv.ThrowTypeError<MSG_INVALID_URL>(aInput); return; } // This fails with URIs with weird protocols, even when they are valid, // so we ignore the failure nsAutoCString credentials; Unused << resolvedURI->GetUserPass(credentials); if (!credentials.IsEmpty()) { - aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput); + aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(aInput); return; } nsCOMPtr<nsIURI> resolvedURIClone; // We use CloneIgnoringRef to strip away the fragment even if the original URI // is immutable. aRv = resolvedURI->CloneIgnoringRef(getter_AddRefs(resolvedURIClone)); if (NS_WARN_IF(aRv.Failed())) { @@ -136,26 +136,26 @@ void GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIURI> uri; aRv = NS_NewURI(getter_AddRefs(uri), aInput, nullptr, nullptr); if (NS_WARN_IF(aRv.Failed())) { - aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput); + aRv.ThrowTypeError<MSG_INVALID_URL>(aInput); return; } // This fails with URIs with weird protocols, even when they are valid, // so we ignore the failure nsAutoCString credentials; Unused << uri->GetUserPass(credentials); if (!credentials.IsEmpty()) { - aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput); + aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(aInput); return; } nsCOMPtr<nsIURI> uriClone; // We use CloneIgnoringRef to strip away the fragment even if the original URI // is immutable. aRv = uri->CloneIgnoringRef(getter_AddRefs(uriClone)); if (NS_WARN_IF(aRv.Failed())) { @@ -178,34 +178,34 @@ GetRequestURLFromWorker(const GlobalObje workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); worker->AssertIsOnWorkerThread(); NS_ConvertUTF8toUTF16 baseURL(worker->GetLocationInfo().mHref); RefPtr<workers::URL> url = workers::URL::Constructor(aGlobal, aInput, baseURL, aRv); if (NS_WARN_IF(aRv.Failed())) { - aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput); + aRv.ThrowTypeError<MSG_INVALID_URL>(aInput); return; } nsString username; url->GetUsername(username, aRv); if (NS_WARN_IF(aRv.Failed())) { return; } nsString password; url->GetPassword(password, aRv); if (NS_WARN_IF(aRv.Failed())) { return; } if (!username.IsEmpty() || !password.IsEmpty()) { - aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput); + aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(aInput); return; } url->SetHash(EmptyString(), aRv); if (NS_WARN_IF(aRv.Failed())) { return; } @@ -311,17 +311,17 @@ Request::Constructor(const GlobalObject& // Step 14.1. Disallow forbidden methods, and anything that is not a HTTP // token, since HTTP states that Method may be any of the defined values or // a token (extension method). nsAutoCString outMethod; nsresult rv = FetchUtil::GetValidRequestMethod(method, outMethod); if (NS_FAILED(rv)) { NS_ConvertUTF8toUTF16 label(method); - aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label); + aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label); return nullptr; } // Step 14.2 request->ClearCreatedByFetchEvent(); request->SetMethod(outMethod); } @@ -345,17 +345,17 @@ Request::Constructor(const GlobalObject& requestHeaders->SetGuard(HeadersGuardEnum::Request, aRv); MOZ_ASSERT(!aRv.Failed()); if (request->Mode() == RequestMode::No_cors) { if (!request->HasSimpleMethod()) { nsAutoCString method; request->GetMethod(method); NS_ConvertUTF8toUTF16 label(method); - aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label); + aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label); return nullptr; } requestHeaders->SetGuard(HeadersGuardEnum::Request_no_cors, aRv); if (aRv.Failed()) { return nullptr; } }
--- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -985,17 +985,17 @@ MediaRecorder::Constructor(const GlobalO const MediaRecorderOptions& aInitDict, ErrorResult& aRv) { // Allow recording from audio node only when pref is on. if (!Preferences::GetBool("media.recorder.audio_node.enabled", false)) { // Pretending that this constructor is not defined. NS_NAMED_LITERAL_STRING(argStr, "Argument 1 of MediaRecorder.constructor"); NS_NAMED_LITERAL_STRING(typeStr, "MediaStream"); - aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(&argStr, &typeStr); + aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(argStr, typeStr); return nullptr; } nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.GetAsSupports()); if (!ownerWindow) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; }
--- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -2360,18 +2360,17 @@ Notification::ShowPersistentNotification new CheckLoadRunnable(worker, NS_ConvertUTF16toUTF8(aScope)); if (!loadChecker->Dispatch(worker->GetJSContext())) { aRv.Throw(NS_ERROR_DOM_ABORT_ERR); return nullptr; } if (NS_WARN_IF(NS_FAILED(loadChecker->Result()))) { if (loadChecker->Result() == NS_ERROR_NOT_AVAILABLE) { - nsAutoString scope(aScope); - aRv.ThrowTypeError<MSG_NO_ACTIVE_WORKER>(&scope); + aRv.ThrowTypeError<MSG_NO_ACTIVE_WORKER>(aScope); } else { aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); } return nullptr; } }
--- a/dom/workers/ServiceWorkerContainer.cpp +++ b/dom/workers/ServiceWorkerContainer.cpp @@ -157,17 +157,17 @@ ServiceWorkerContainer::Register(const n baseURI = window->GetDocBaseURI(); } } nsresult rv; nsCOMPtr<nsIURI> scriptURI; rv = NS_NewURI(getter_AddRefs(scriptURI), aScriptURL, nullptr, baseURI); if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.ThrowTypeError<MSG_INVALID_URL>(&aScriptURL); + aRv.ThrowTypeError<MSG_INVALID_URL>(aScriptURL); return nullptr; } aRv = CheckForSlashEscapedCharsInPath(scriptURI); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } @@ -179,28 +179,28 @@ ServiceWorkerContainer::Register(const n if (!aOptions.mScope.WasPassed()) { NS_NAMED_LITERAL_STRING(defaultScope, "./"); rv = NS_NewURI(getter_AddRefs(scopeURI), defaultScope, nullptr, scriptURI); if (NS_WARN_IF(NS_FAILED(rv))) { nsAutoCString spec; scriptURI->GetSpec(spec); NS_ConvertUTF8toUTF16 wSpec(spec); - aRv.ThrowTypeError<MSG_INVALID_SCOPE>(&defaultScope, &wSpec); + aRv.ThrowTypeError<MSG_INVALID_SCOPE>(defaultScope, wSpec); return nullptr; } } else { // Step 5. Parse against entry settings object's base URL. rv = NS_NewURI(getter_AddRefs(scopeURI), aOptions.mScope.Value(), nullptr, baseURI); if (NS_WARN_IF(NS_FAILED(rv))) { nsAutoCString spec; baseURI->GetSpec(spec); NS_ConvertUTF8toUTF16 wSpec(spec); - aRv.ThrowTypeError<MSG_INVALID_SCOPE>(&aOptions.mScope.Value(), &wSpec); + aRv.ThrowTypeError<MSG_INVALID_SCOPE>(aOptions.mScope.Value(), wSpec); return nullptr; } aRv = CheckForSlashEscapedCharsInPath(scopeURI); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } }
--- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -128,20 +128,24 @@ AsyncLog(nsIInterceptedChannel *aInterce } } template<typename... Params> void AsyncLog(nsIInterceptedChannel* aInterceptedChannel, const nsACString& aRespondWithScriptSpec, uint32_t aRespondWithLineNumber, uint32_t aRespondWithColumnNumber, - const nsACString& aMessageName, Params... aParams) + // We have to list one explicit string so that calls with an + // nsTArray of params won't end up in here. + const nsACString& aMessageName, const nsAString& aFirstParam, + Params&&... aParams) { - nsTArray<nsString> paramsList(sizeof...(Params)); - StringArrayAppender::Append(paramsList, sizeof...(Params), aParams...); + nsTArray<nsString> paramsList(sizeof...(Params) + 1); + StringArrayAppender::Append(paramsList, sizeof...(Params) + 1, + aFirstParam, Forward<Params>(aParams)...); AsyncLog(aInterceptedChannel, aRespondWithScriptSpec, aRespondWithLineNumber, aRespondWithColumnNumber, aMessageName, paramsList); } class FinishResponse final : public nsRunnable { nsMainThreadPtrHandle<nsIInterceptedChannel> mChannel; RefPtr<InternalResponse> mInternalResponse; @@ -290,17 +294,17 @@ public: } private: ~RespondWithHandler() { if (!mRequestWasHandled) { ::AsyncLog(mInterceptedChannel, mRespondWithScriptSpec, mRespondWithLineNumber, mRespondWithColumnNumber, - NS_LITERAL_CSTRING("InterceptionFailedWithURL"), &mRequestURL); + NS_LITERAL_CSTRING("InterceptionFailedWithURL"), mRequestURL); CancelRequest(NS_ERROR_INTERCEPTION_FAILED); } } }; struct RespondWithClosure { nsMainThreadPtrHandle<nsIInterceptedChannel> mInterceptedChannel; @@ -344,17 +348,17 @@ void RespondWithCopyComplete(void* aClos data->mInternalResponse, data->mWorkerChannelInfo, data->mScriptSpec, data->mResponseURLSpec); } else { AsyncLog(data->mInterceptedChannel, data->mRespondWithScriptSpec, data->mRespondWithLineNumber, data->mRespondWithColumnNumber, NS_LITERAL_CSTRING("InterceptionFailedWithURL"), - &data->mRequestURL); + data->mRequestURL); event = new CancelChannelRunnable(data->mInterceptedChannel, NS_ERROR_INTERCEPTION_FAILED); } MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(event))); } namespace { @@ -453,43 +457,45 @@ public: } else { mOwner->AsyncLog(mSourceSpec, mLine, mColumn, mMessageName, mParams); } mOwner->CancelRequest(NS_ERROR_INTERCEPTION_FAILED); } } template<typename... Params> - void SetCancelMessage(const nsACString& aMessageName, Params... aParams) + void SetCancelMessage(const nsACString& aMessageName, Params&&... aParams) { MOZ_ASSERT(mOwner); MOZ_ASSERT(mMessageName.EqualsLiteral("InterceptionFailedWithURL")); MOZ_ASSERT(mParams.Length() == 1); mMessageName = aMessageName; mParams.Clear(); - StringArrayAppender::Append(mParams, sizeof...(Params), aParams...); + StringArrayAppender::Append(mParams, sizeof...(Params), + Forward<Params>(aParams)...); } template<typename... Params> void SetCancelMessageAndLocation(const nsACString& aSourceSpec, uint32_t aLine, uint32_t aColumn, const nsACString& aMessageName, - Params... aParams) + Params&&... aParams) { MOZ_ASSERT(mOwner); MOZ_ASSERT(mMessageName.EqualsLiteral("InterceptionFailedWithURL")); MOZ_ASSERT(mParams.Length() == 1); mSourceSpec = aSourceSpec; mLine = aLine; mColumn = aColumn; mMessageName = aMessageName; mParams.Clear(); - StringArrayAppender::Append(mParams, sizeof...(Params), aParams...); + StringArrayAppender::Append(mParams, sizeof...(Params), + Forward<Params>(aParams)...); } void Reset() { mOwner = nullptr; } }; @@ -506,83 +512,83 @@ RespondWithHandler::ResolvedCallback(JSC nsCString sourceSpec; uint32_t line = 0; uint32_t column = 0; nsString valueString; ExtractErrorValues(aCx, aValue, sourceSpec, &line, &column, valueString); autoCancel.SetCancelMessageAndLocation(sourceSpec, line, column, NS_LITERAL_CSTRING("InterceptedNonResponseWithURL"), - &mRequestURL, &valueString); + mRequestURL, valueString); return; } RefPtr<Response> response; nsresult rv = UNWRAP_OBJECT(Response, &aValue.toObject(), response); if (NS_FAILED(rv)) { nsCString sourceSpec; uint32_t line = 0; uint32_t column = 0; nsString valueString; ExtractErrorValues(aCx, aValue, sourceSpec, &line, &column, valueString); autoCancel.SetCancelMessageAndLocation(sourceSpec, line, column, NS_LITERAL_CSTRING("InterceptedNonResponseWithURL"), - &mRequestURL, &valueString); + mRequestURL, valueString); return; } WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); worker->AssertIsOnWorkerThread(); // Allow opaque response interception to be disabled until we can ensure the // security implications are not a complete disaster. if (response->Type() == ResponseType::Opaque && !worker->OpaqueInterceptionEnabled()) { autoCancel.SetCancelMessage( - NS_LITERAL_CSTRING("OpaqueInterceptionDisabledWithURL"), &mRequestURL); + NS_LITERAL_CSTRING("OpaqueInterceptionDisabledWithURL"), mRequestURL); return; } // Section "HTTP Fetch", step 2.2: // If one of the following conditions is true, return a network error: // * response's type is "error". // * request's mode is not "no-cors" and response's type is "opaque". // * request is not a navigation request and response's type is // "opaqueredirect". if (response->Type() == ResponseType::Error) { autoCancel.SetCancelMessage( - NS_LITERAL_CSTRING("InterceptedErrorResponseWithURL"), &mRequestURL); + NS_LITERAL_CSTRING("InterceptedErrorResponseWithURL"), mRequestURL); return; } MOZ_ASSERT_IF(mIsClientRequest, mRequestMode == RequestMode::Same_origin); if (response->Type() == ResponseType::Opaque && mRequestMode != RequestMode::No_cors) { uint32_t mode = static_cast<uint32_t>(mRequestMode); NS_ConvertASCIItoUTF16 modeString(RequestModeValues::strings[mode].value, RequestModeValues::strings[mode].length); autoCancel.SetCancelMessage( NS_LITERAL_CSTRING("BadOpaqueInterceptionRequestModeWithURL"), - &mRequestURL, &modeString); + mRequestURL, modeString); return; } if (!mIsNavigationRequest && response->Type() == ResponseType::Opaqueredirect) { autoCancel.SetCancelMessage( - NS_LITERAL_CSTRING("BadOpaqueRedirectInterceptionWithURL"), &mRequestURL); + NS_LITERAL_CSTRING("BadOpaqueRedirectInterceptionWithURL"), mRequestURL); return; } if (NS_WARN_IF(response->BodyUsed())) { autoCancel.SetCancelMessage( - NS_LITERAL_CSTRING("InterceptedUsedResponseWithURL"), &mRequestURL); + NS_LITERAL_CSTRING("InterceptedUsedResponseWithURL"), mRequestURL); return; } RefPtr<InternalResponse> ir = response->GetInternalResponse(); if (NS_WARN_IF(!ir)) { return; } @@ -645,17 +651,17 @@ RespondWithHandler::RejectedCallback(JSC uint32_t line = mRespondWithLineNumber; uint32_t column = mRespondWithColumnNumber; nsString valueString; ExtractErrorValues(aCx, aValue, sourceSpec, &line, &column, valueString); ::AsyncLog(mInterceptedChannel, sourceSpec, line, column, NS_LITERAL_CSTRING("InterceptionRejectedResponseWithURL"), - &mRequestURL, &valueString); + mRequestURL, valueString); CancelRequest(NS_ERROR_INTERCEPTION_FAILED); } void RespondWithHandler::CancelRequest(nsresult aStatus) { nsCOMPtr<nsIRunnable> runnable = @@ -733,17 +739,17 @@ FetchEvent::ReportCanceled() // The variadic template provided by StringArrayAppender requires exactly // an nsString. NS_ConvertUTF8toUTF16 requestURL(url); //nsString requestURL; //CopyUTF8toUTF16(url, requestURL); ::AsyncLog(mChannel.get(), mPreventDefaultScriptSpec, mPreventDefaultLineNumber, mPreventDefaultColumnNumber, - NS_LITERAL_CSTRING("InterceptionCanceledWithURL"), &requestURL); + NS_LITERAL_CSTRING("InterceptionCanceledWithURL"), requestURL); } namespace { class WaitUntilHandler final : public PromiseNativeHandler { WorkerPrivate* mWorkerPrivate; const nsCString mScope;
--- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -1149,17 +1149,17 @@ public: CopyUTF8toUTF16(mRegistration->mScriptSpec, scriptSpec); CopyUTF8toUTF16(mRegistration->mScope, scope); } else { CopyUTF8toUTF16(mScriptSpec, scriptSpec); CopyUTF8toUTF16(mScope, scope); } // Throw the type error with a generic error message. - aRv.ThrowTypeError<MSG_SW_INSTALL_ERROR>(&scriptSpec, &scope); + aRv.ThrowTypeError<MSG_SW_INSTALL_ERROR>(scriptSpec, scope); } for (uint32_t i = 1; i < mCallbacks.Length(); ++i) { ErrorResult rv; aRv.CloneTo(rv); mCallbacks[i]->UpdateFailed(rv); rv.SuppressException(); } @@ -2601,17 +2601,17 @@ ServiceWorkerManager::HandleError(JSCont ServiceWorkerJob* job = queue->Peek(); if (job) { MOZ_ASSERT(job->IsRegisterJob()); RefPtr<ServiceWorkerRegisterJob> regJob = static_cast<ServiceWorkerRegisterJob*>(job); ErrorResult rv; NS_ConvertUTF8toUTF16 scope(aScope); - rv.ThrowTypeError<MSG_SW_SCRIPT_THREW>(&aWorkerURL, &scope); + rv.ThrowTypeError<MSG_SW_SCRIPT_THREW>(aWorkerURL, scope); regJob->Fail(rv); } } // Always report any uncaught exceptions or errors to the console of // each client. ReportToAllClients(aScope, aMessage, aFilename, aLine, aLineNumber, aColumnNumber, aFlags);
--- a/dom/workers/ServiceWorkerRegistration.cpp +++ b/dom/workers/ServiceWorkerRegistration.cpp @@ -696,17 +696,17 @@ ServiceWorkerRegistrationMainThread::Sho nsCOMPtr<nsIDocument> doc = window->GetExtantDoc(); if (NS_WARN_IF(!doc)) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } RefPtr<workers::ServiceWorker> worker = GetActive(); if (!worker) { - aRv.ThrowTypeError<MSG_NO_ACTIVE_WORKER>(&mScope); + aRv.ThrowTypeError<MSG_NO_ACTIVE_WORKER>(mScope); return nullptr; } nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(window); RefPtr<Promise> p = Notification::ShowPersistentNotification(global, mScope, aTitle, aOptions, aRv); if (NS_WARN_IF(aRv.Failed())) {