author | Wes Kocher <wkocher@mozilla.com> |
Fri, 23 Jan 2015 19:49:51 -0800 | |
changeset 225504 | 961c75198f9d996a4952a3b0b776331b49d6acb0 |
parent 225503 | bb9a4a4133af86645d7bc1758e9eddf04c3cf3cc |
child 225505 | e9d37cd95335336532e6e5d1b32207e31ccc7a51 |
push id | 28163 |
push user | philringnalda@gmail.com |
push date | Sat, 24 Jan 2015 16:27:39 +0000 |
treeherder | mozilla-central@1cf171c1a177 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1113621 |
milestone | 38.0a1 |
backs out | 5ed6d1902cc7bafbf9ffeaf35815c56cdd8f8c0d |
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/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -404,21 +404,16 @@ DOMInterfaces = { 'Exception': { 'headerFile': 'mozilla/dom/DOMException.h', 'binaryNames': { 'message': 'messageMoz', }, }, -'ExtendableEvent': { - 'headerFile': 'mozilla/dom/ServiceWorkerEvents.h', - 'nativeType': 'mozilla::dom::workers::ExtendableEvent', -}, - 'FileList': { 'headerFile': 'mozilla/dom/File.h', }, 'FileReader': { 'nativeType': 'nsDOMFileReader', 'implicitJSContext': [ 'readAsArrayBuffer' ], }, @@ -605,16 +600,21 @@ DOMInterfaces = { { 'nativeType': 'nsIInputStream', 'notflattened': True }, { 'workers': True, }], +'InstallPhaseEvent': { + 'headerFile': 'ServiceWorkerEvents.h', + 'nativeType': 'mozilla::dom::workers::InstallPhaseEvent', +}, + 'InstallEvent': { 'headerFile': 'ServiceWorkerEvents.h', 'nativeType': 'mozilla::dom::workers::InstallEvent', }, 'KeyEvent': { 'concrete': False },
--- a/dom/webidl/InstallEvent.webidl +++ b/dom/webidl/InstallEvent.webidl @@ -2,19 +2,30 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. * * For more information on this interface, please see * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html */ +// While not explicitly restricted to ServiceWorkerGlobalScope, it probably +// should be. https://github.com/slightlyoff/ServiceWorker/issues/254 [Constructor(DOMString type, optional InstallEventInit eventInitDict), - Exposed=ServiceWorker] -interface InstallEvent : ExtendableEvent { + Func="mozilla::dom::workers::ServiceWorkerEventsVisible", + // XXXbz I have no idea where this should be exposed. The spec makes + // no sense. But since it returns a ServiceWorker and that's only + // exposed in Window, let's say Window. + Exposed=Window] +interface InstallEvent : InstallPhaseEvent { + // The currently active worker for this scope when this worker is asked to + // install itself. + // This may be null when a ServiceWorker is being installed for a previously + // uncontrolled scope. + // https://github.com/slightlyoff/ServiceWorker/issues/260 readonly attribute ServiceWorker? activeWorker; void replace(); }; // Should be in the spec soon to satisfy conventions about events. // https://github.com/slightlyoff/ServiceWorker/issues/216. dictionary InstallEventInit : EventInit { ServiceWorker? activeWorker = null;
rename from dom/webidl/ExtendableEvent.webidl rename to dom/webidl/InstallPhaseEvent.webidl --- a/dom/webidl/ExtendableEvent.webidl +++ b/dom/webidl/InstallPhaseEvent.webidl @@ -2,18 +2,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. * * For more information on this interface, please see * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html */ -[Constructor(DOMString type, optional ExtendableEventInit eventInitDict), - Exposed=ServiceWorker] -interface ExtendableEvent : Event { +// While not explicitly restricted to ServiceWorkerGlobalScope, it probably +// should be. https://github.com/slightlyoff/ServiceWorker/issues/254 +[Constructor(DOMString type, optional EventInit eventInitDict), + Func="mozilla::dom::workers::ServiceWorkerEventsVisible", + Exposed=(ServiceWorker,Window)] +interface InstallPhaseEvent : Event { // https://github.com/slightlyoff/ServiceWorker/issues/261 void waitUntil(Promise<any> p); }; - -dictionary ExtendableEventInit : EventInit { - // Defined for the forward compatibility across the derived events -};
--- a/dom/webidl/ServiceWorker.webidl +++ b/dom/webidl/ServiceWorker.webidl @@ -5,19 +5,19 @@ * * The origin of this IDL file is * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-obj * */ // Still unclear what should be subclassed. // https://github.com/slightlyoff/ServiceWorker/issues/189 -[Func="mozilla::dom::workers::ServiceWorkerVisible", - // FIXME(nsm): Bug 1113522. This is exposed to satisfy webidl constraints, but it won't actually work. - Exposed=(ServiceWorker,Window)] +[Pref="dom.serviceWorkers.enabled", + // FIXME(nsm): Bug 1113522. Should also be exposed on Workers too. + Exposed=Window] interface ServiceWorker : EventTarget { readonly attribute USVString scriptURL; readonly attribute ServiceWorkerState state; attribute EventHandler onstatechange; }; ServiceWorker implements AbstractWorker;
--- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -125,17 +125,16 @@ WEBIDL_FILES = [ 'DynamicsCompressorNode.webidl', 'Element.webidl', 'EngineeringMode.webidl', 'Event.webidl', 'EventHandler.webidl', 'EventListener.webidl', 'EventSource.webidl', 'EventTarget.webidl', - 'ExtendableEvent.webidl', 'Fetch.webidl', 'File.webidl', 'FileList.webidl', 'FileMode.webidl', 'FileReader.webidl', 'FileReaderSync.webidl', 'FocusEvent.webidl', 'FontFace.webidl', @@ -241,16 +240,17 @@ WEBIDL_FILES = [ 'Identity.webidl', 'ImageCapture.webidl', 'ImageData.webidl', 'ImageDocument.webidl', 'InputEvent.webidl', 'InputMethod.webidl', 'InspectorUtils.webidl', 'InstallEvent.webidl', + 'InstallPhaseEvent.webidl', 'InterAppConnection.webidl', 'InterAppConnectionRequest.webidl', 'InterAppMessagePort.webidl', 'KeyAlgorithm.webidl', 'KeyboardEvent.webidl', 'KeyEvent.webidl', 'LegacyQueryInterface.webidl', 'LinkStyle.webidl',
--- a/dom/workers/ServiceWorker.cpp +++ b/dom/workers/ServiceWorker.cpp @@ -4,38 +4,20 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ServiceWorker.h" #include "nsPIDOMWindow.h" #include "SharedWorker.h" #include "WorkerPrivate.h" -#include "mozilla/Preferences.h" #include "mozilla/dom/Promise.h" -#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h" using namespace mozilla::dom; - -namespace mozilla { -namespace dom { -namespace workers { - -bool -ServiceWorkerVisible(JSContext* aCx, JSObject* aObj) -{ - if (NS_IsMainThread()) { - return Preferences::GetBool("dom.serviceWorkers.enabled", false); - } - - ServiceWorkerGlobalScope* scope = nullptr; - nsresult rv = UnwrapObject<prototypes::id::ServiceWorkerGlobalScope_workers, - mozilla::dom::ServiceWorkerGlobalScopeBinding_workers::NativeType>(aObj, scope); - return NS_SUCCEEDED(rv); -} +USING_WORKERS_NAMESPACE ServiceWorker::ServiceWorker(nsPIDOMWindow* aWindow, SharedWorker* aSharedWorker) : DOMEventTargetHelper(aWindow), mState(ServiceWorkerState::Installing), mSharedWorker(aSharedWorker) { AssertIsOnMainThread(); @@ -68,12 +50,8 @@ WorkerPrivate* ServiceWorker::GetWorkerPrivate() const { // At some point in the future, this may be optimized to terminate a worker // that hasn't been used in a certain amount of time or when there is memory // pressure or similar. MOZ_ASSERT(mSharedWorker); return mSharedWorker->GetWorkerPrivate(); } - -} // namespace workers -} // namespace dom -} // namespace mozilla
--- a/dom/workers/ServiceWorker.h +++ b/dom/workers/ServiceWorker.h @@ -16,19 +16,16 @@ namespace mozilla { namespace dom { class Promise; namespace workers { class SharedWorker; -bool -ServiceWorkerVisible(JSContext* aCx, JSObject* aObj); - class ServiceWorker MOZ_FINAL : public DOMEventTargetHelper { friend class RuntimeService; public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorker, DOMEventTargetHelper) IMPL_EVENT_HANDLER(statechange)
--- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -6,52 +6,62 @@ #include "ServiceWorkerEvents.h" #include "nsContentUtils.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/workers/bindings/ServiceWorker.h" +#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h" using namespace mozilla::dom; BEGIN_WORKERS_NAMESPACE -ExtendableEvent::ExtendableEvent(EventTarget* aOwner) +bool +ServiceWorkerEventsVisible(JSContext* aCx, JSObject* aObj) +{ + ServiceWorkerGlobalScope* scope = nullptr; + nsresult rv = UnwrapObject<prototypes::id::ServiceWorkerGlobalScope_workers, + mozilla::dom::ServiceWorkerGlobalScopeBinding_workers::NativeType>(aObj, scope); + return NS_SUCCEEDED(rv) && scope; +} + +InstallPhaseEvent::InstallPhaseEvent(EventTarget* aOwner) : Event(aOwner, nullptr, nullptr) { } void -ExtendableEvent::WaitUntil(Promise& aPromise) +InstallPhaseEvent::WaitUntil(Promise& aPromise) { MOZ_ASSERT(!NS_IsMainThread()); // Only first caller counts. if (EventPhase() == AT_TARGET && !mPromise) { mPromise = &aPromise; } } -NS_IMPL_ADDREF_INHERITED(ExtendableEvent, Event) -NS_IMPL_RELEASE_INHERITED(ExtendableEvent, Event) +NS_IMPL_ADDREF_INHERITED(InstallPhaseEvent, Event) +NS_IMPL_RELEASE_INHERITED(InstallPhaseEvent, Event) -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ExtendableEvent) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(InstallPhaseEvent) NS_INTERFACE_MAP_END_INHERITING(Event) -NS_IMPL_CYCLE_COLLECTION_INHERITED(ExtendableEvent, Event, mPromise) +NS_IMPL_CYCLE_COLLECTION_INHERITED(InstallPhaseEvent, Event, mPromise) InstallEvent::InstallEvent(EventTarget* aOwner) - : ExtendableEvent(aOwner) + : InstallPhaseEvent(aOwner) , mActivateImmediately(false) { } -NS_IMPL_ADDREF_INHERITED(InstallEvent, ExtendableEvent) -NS_IMPL_RELEASE_INHERITED(InstallEvent, ExtendableEvent) +NS_IMPL_ADDREF_INHERITED(InstallEvent, InstallPhaseEvent) +NS_IMPL_RELEASE_INHERITED(InstallEvent, InstallPhaseEvent) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(InstallEvent) -NS_INTERFACE_MAP_END_INHERITING(ExtendableEvent) +NS_INTERFACE_MAP_END_INHERITING(InstallPhaseEvent) -NS_IMPL_CYCLE_COLLECTION_INHERITED(InstallEvent, ExtendableEvent, mActiveWorker) +NS_IMPL_CYCLE_COLLECTION_INHERITED(InstallEvent, InstallPhaseEvent, mActiveWorker) END_WORKERS_NAMESPACE
--- a/dom/workers/ServiceWorkerEvents.h +++ b/dom/workers/ServiceWorkerEvents.h @@ -2,60 +2,63 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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_serviceworkerevents_h__ #define mozilla_dom_workers_serviceworkerevents_h__ #include "mozilla/dom/Event.h" -#include "mozilla/dom/ExtendableEventBinding.h" +#include "mozilla/dom/InstallPhaseEventBinding.h" #include "mozilla/dom/InstallEventBinding.h" namespace mozilla { namespace dom { class Promise; } // namespace dom } // namespace mozilla BEGIN_WORKERS_NAMESPACE class ServiceWorker; -class ExtendableEvent : public Event +bool +ServiceWorkerEventsVisible(JSContext* aCx, JSObject* aObj); + +class InstallPhaseEvent : public Event { nsRefPtr<Promise> mPromise; protected: - explicit ExtendableEvent(mozilla::dom::EventTarget* aOwner); - ~ExtendableEvent() {} + explicit InstallPhaseEvent(mozilla::dom::EventTarget* aOwner); + ~InstallPhaseEvent() {} public: NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ExtendableEvent, Event) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallPhaseEvent, Event) NS_FORWARD_TO_EVENT virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE { - return mozilla::dom::ExtendableEventBinding::Wrap(aCx, this); + return mozilla::dom::InstallPhaseEventBinding::Wrap(aCx, this); } - static already_AddRefed<ExtendableEvent> + static already_AddRefed<InstallPhaseEvent> Constructor(mozilla::dom::EventTarget* aOwner, const nsAString& aType, const EventInit& aOptions) { - nsRefPtr<ExtendableEvent> e = new ExtendableEvent(aOwner); + nsRefPtr<InstallPhaseEvent> e = new InstallPhaseEvent(aOwner); bool trusted = e->Init(aOwner); e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable); e->SetTrusted(trusted); return e.forget(); } - static already_AddRefed<ExtendableEvent> + static already_AddRefed<InstallPhaseEvent> Constructor(const GlobalObject& aGlobal, const nsAString& aType, const EventInit& aOptions, ErrorResult& aRv) { nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports()); return Constructor(target, aType, aOptions); } @@ -66,29 +69,29 @@ public: already_AddRefed<Promise> GetPromise() const { nsRefPtr<Promise> p = mPromise; return p.forget(); } }; -class InstallEvent MOZ_FINAL : public ExtendableEvent +class InstallEvent MOZ_FINAL : public InstallPhaseEvent { // FIXME(nsm): Bug 982787 will allow actually populating this. nsRefPtr<ServiceWorker> mActiveWorker; bool mActivateImmediately; protected: explicit InstallEvent(mozilla::dom::EventTarget* aOwner); ~InstallEvent() {} public: NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallEvent, ExtendableEvent) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallEvent, InstallPhaseEvent) NS_FORWARD_TO_EVENT virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE { return mozilla::dom::InstallEventBinding::Wrap(aCx, this); } static already_AddRefed<InstallEvent>
--- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -1061,18 +1061,18 @@ private: { MOZ_ASSERT(aWorkerPrivate->IsServiceWorker()); nsRefPtr<EventTarget> target = do_QueryObject(aWorkerPrivate->GlobalScope()); // FIXME(nsm): Set activeWorker to the correct thing. EventInit init; init.mBubbles = false; init.mCancelable = true; - nsRefPtr<ExtendableEvent> event = - ExtendableEvent::Constructor(target, NS_LITERAL_STRING("activate"), init); + nsRefPtr<InstallPhaseEvent> event = + InstallPhaseEvent::Constructor(target, NS_LITERAL_STRING("activate"), init); event->SetTrusted(true); nsRefPtr<Promise> waitUntilPromise; // FIXME(nsm): Install error handler for any listener errors. ErrorResult result; result = target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
--- a/dom/workers/moz.build +++ b/dom/workers/moz.build @@ -3,17 +3,16 @@ # This Source Code Form is subject to the terms of the Mozilla Public # 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/. # Public stuff. EXPORTS.mozilla.dom += [ 'ServiceWorkerCommon.h', 'ServiceWorkerContainer.h', - 'ServiceWorkerEvents.h', 'ServiceWorkerRegistration.h', 'WorkerPrivate.h', 'WorkerRunnable.h', 'WorkerScope.h', ] EXPORTS.mozilla.dom.workers += [ 'ServiceWorkerManager.h',