diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 741641c0bcfd..76c28a0a4189 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -152,6 +152,10 @@ public: // The XPCOM GetProduct is OK // The XPCOM GetLanguage is OK + void GetUserAgent(nsString& aUserAgent, ErrorResult& /* unused */) + { + GetUserAgent(aUserAgent); + } bool OnLine(); void RegisterProtocolHandler(const nsAString& aScheme, const nsAString& aURL, const nsAString& aTitle, ErrorResult& aRv); diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index c748c5faec10..be9185ef5194 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1612,8 +1612,6 @@ DOMInterfaces = { }, 'WorkerNavigator': { - 'headerFile': 'mozilla/dom/workers/bindings/Navigator.h', - 'workers': True, 'implicitJSContext': ['getDataStores'], }, diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index ec9b202301e5..6ffc91a9be5a 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -43,7 +43,7 @@ interface NavigatorID { readonly attribute DOMString appVersion; [Constant, Cached] readonly attribute DOMString platform; - [Pure, Cached, Throws=Workers] + [Pure, Cached, Throws] readonly attribute DOMString userAgent; [Constant, Cached] readonly attribute DOMString product; // constant "Gecko" diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index 0ca6c795212a..34c5feec697c 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -56,6 +56,47 @@ using namespace mozilla::dom; using namespace mozilla::dom::workers; +namespace { + +void +AsyncLog(nsIInterceptedChannel *aInterceptedChannel, + const nsACString& aRespondWithScriptSpec, + uint32_t aRespondWithLineNumber, uint32_t aRespondWithColumnNumber, + const nsACString& aMessageName, const nsTArray& aParams) +{ + MOZ_ASSERT(aInterceptedChannel); + nsCOMPtr reporter = + aInterceptedChannel->GetConsoleReportCollector(); + if (reporter) { + reporter->AddConsoleReport(nsIScriptError::errorFlag, + NS_LITERAL_CSTRING("Service Worker Interception"), + nsContentUtils::eDOM_PROPERTIES, + aRespondWithScriptSpec, + aRespondWithLineNumber, + aRespondWithColumnNumber, + aMessageName, aParams); + } +} + +template +void +AsyncLog(nsIInterceptedChannel* aInterceptedChannel, + const nsACString& aRespondWithScriptSpec, + uint32_t aRespondWithLineNumber, uint32_t aRespondWithColumnNumber, + // 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 paramsList(sizeof...(Params) + 1); + StringArrayAppender::Append(paramsList, sizeof...(Params) + 1, + aFirstParam, Forward(aParams)...); + AsyncLog(aInterceptedChannel, aRespondWithScriptSpec, aRespondWithLineNumber, + aRespondWithColumnNumber, aMessageName, paramsList); +} + +} // anonymous namespace + BEGIN_WORKERS_NAMESPACE CancelChannelRunnable::CancelChannelRunnable(nsMainThreadPtrHandle& aChannel, @@ -115,43 +156,6 @@ FetchEvent::Constructor(const GlobalObject& aGlobal, namespace { -void -AsyncLog(nsIInterceptedChannel *aInterceptedChannel, - const nsACString& aRespondWithScriptSpec, - uint32_t aRespondWithLineNumber, uint32_t aRespondWithColumnNumber, - const nsACString& aMessageName, const nsTArray& aParams) -{ - MOZ_ASSERT(aInterceptedChannel); - nsCOMPtr reporter = - aInterceptedChannel->GetConsoleReportCollector(); - if (reporter) { - reporter->AddConsoleReport(nsIScriptError::errorFlag, - NS_LITERAL_CSTRING("Service Worker Interception"), - nsContentUtils::eDOM_PROPERTIES, - aRespondWithScriptSpec, - aRespondWithLineNumber, - aRespondWithColumnNumber, - aMessageName, aParams); - } -} - -template -void -AsyncLog(nsIInterceptedChannel* aInterceptedChannel, - const nsACString& aRespondWithScriptSpec, - uint32_t aRespondWithLineNumber, uint32_t aRespondWithColumnNumber, - // 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 paramsList(sizeof...(Params) + 1); - StringArrayAppender::Append(paramsList, sizeof...(Params) + 1, - aFirstParam, Forward(aParams)...); - AsyncLog(aInterceptedChannel, aRespondWithScriptSpec, aRespondWithLineNumber, - aRespondWithColumnNumber, aMessageName, paramsList); -} - class FinishResponse final : public nsRunnable { nsMainThreadPtrHandle mChannel; diff --git a/dom/workers/Navigator.cpp b/dom/workers/WorkerNavigator.cpp similarity index 98% rename from dom/workers/Navigator.cpp rename to dom/workers/WorkerNavigator.cpp index 18ed152a8f00..f96cf0c14cd5 100644 --- a/dom/workers/Navigator.cpp +++ b/dom/workers/WorkerNavigator.cpp @@ -11,9 +11,9 @@ #include "mozilla/dom/DataStoreBinding.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/PromiseWorkerProxy.h" +#include "mozilla/dom/WorkerNavigator.h" #include "mozilla/dom/WorkerNavigatorBinding.h" -#include "Navigator.h" #include "nsProxyRelease.h" #include "RuntimeService.h" @@ -23,7 +23,8 @@ #include "WorkerRunnable.h" #include "WorkerScope.h" -BEGIN_WORKERS_NAMESPACE +namespace mozilla { +namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerNavigator) @@ -48,7 +49,7 @@ WorkerNavigator::Create(bool aOnLine) JSObject* WorkerNavigator::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { - return WorkerNavigatorBinding_workers::Wrap(aCx, this, aGivenProto); + return WorkerNavigatorBinding::Wrap(aCx, this, aGivenProto); } // A WorkerMainThreadRunnable to synchronously add DataStoreChangeEventProxy on @@ -300,7 +301,7 @@ WorkerNavigator::GetDataStores(JSContext* aCx, void WorkerNavigator::SetLanguages(const nsTArray& aLanguages) { - WorkerNavigatorBinding_workers::ClearCachedLanguagesValue(this); + WorkerNavigatorBinding::ClearCachedLanguagesValue(this); mProperties.mLanguages = aLanguages; } @@ -408,4 +409,5 @@ WorkerNavigator::HardwareConcurrency() const return rts->ClampedHardwareConcurrency(); } -END_WORKERS_NAMESPACE +} // namespace dom +} // namespace mozilla diff --git a/dom/workers/Navigator.h b/dom/workers/WorkerNavigator.h similarity index 91% rename from dom/workers/Navigator.h rename to dom/workers/WorkerNavigator.h index c4bdb6271d2b..b0ba07455036 100644 --- a/dom/workers/Navigator.h +++ b/dom/workers/WorkerNavigator.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozilla_dom_workers_navigator_h__ -#define mozilla_dom_workers_navigator_h__ +#ifndef mozilla_dom_workernavigator_h__ +#define mozilla_dom_workernavigator_h__ #include "Workers.h" #include "RuntimeService.h" @@ -19,14 +19,10 @@ namespace mozilla { namespace dom { class Promise; -} // namespace dom -} // namespace mozilla - -BEGIN_WORKERS_NAMESPACE class WorkerNavigator final : public nsWrapperCache { - typedef struct RuntimeService::NavigatorProperties NavigatorProperties; + typedef struct workers::RuntimeService::NavigatorProperties NavigatorProperties; NavigatorProperties mProperties; bool mOnline; @@ -116,6 +112,7 @@ public: uint64_t HardwareConcurrency() const; }; -END_WORKERS_NAMESPACE +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_workers_navigator_h__ +#endif // mozilla_dom_workernavigator_h__ diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 83b3e00d8b89..6b14cac308c2 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -22,6 +22,7 @@ #include "mozilla/dom/WorkerDebuggerGlobalScopeBinding.h" #include "mozilla/dom/WorkerGlobalScopeBinding.h" #include "mozilla/dom/WorkerLocation.h" +#include "mozilla/dom/WorkerNavigator.h" #include "mozilla/dom/cache/CacheStorage.h" #include "mozilla/Services.h" #include "nsServiceManagerUtils.h" @@ -33,7 +34,6 @@ #include #endif -#include "Navigator.h" #include "Principal.h" #include "RuntimeService.h" #include "ScriptLoader.h" diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h index ff206ebd223d..4ba8c06cc398 100644 --- a/dom/workers/WorkerScope.h +++ b/dom/workers/WorkerScope.h @@ -24,6 +24,7 @@ class Promise; class RequestOrUSVString; class ServiceWorkerRegistrationWorkerThread; class WorkerLocation; +class WorkerNavigator; namespace cache { @@ -37,7 +38,6 @@ BEGIN_WORKERS_NAMESPACE class ServiceWorkerClients; class WorkerPrivate; -class WorkerNavigator; class Performance; class WorkerGlobalScope : public DOMEventTargetHelper, diff --git a/dom/workers/moz.build b/dom/workers/moz.build index 7cff244c08b5..05d458dfb8a1 100644 --- a/dom/workers/moz.build +++ b/dom/workers/moz.build @@ -14,6 +14,7 @@ EXPORTS.mozilla.dom += [ 'ServiceWorkerRegistrar.h', 'ServiceWorkerRegistration.h', 'WorkerLocation.h', + 'WorkerNavigator.h', 'WorkerPrefs.h', 'WorkerPrivate.h', 'WorkerRunnable.h', @@ -31,7 +32,6 @@ EXPORTS.mozilla.dom.workers += [ EXPORTS.mozilla.dom.workers.bindings += [ 'DataStore.h', 'DataStoreCursor.h', - 'Navigator.h', 'Performance.h', 'ServiceWorker.h', 'ServiceWorkerClient.h', @@ -56,7 +56,6 @@ UNIFIED_SOURCES += [ 'DataStore.cpp', 'DataStoreCursor.cpp', 'FileReaderSync.cpp', - 'Navigator.cpp', 'Performance.cpp', 'Principal.cpp', 'RegisterBindings.cpp', @@ -81,6 +80,7 @@ UNIFIED_SOURCES += [ 'URL.cpp', 'WorkerDebuggerManager.cpp', 'WorkerLocation.cpp', + 'WorkerNavigator.cpp', 'WorkerPrivate.cpp', 'WorkerRunnable.cpp', 'WorkerScope.cpp',