/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"domstubs.idl" #include"nsIRequest.idl"
interface mozIDOMWindow;
interface nsPIDOMWindowInner;
interface mozIDOMWindowProxy;
interface nsIArray;
interface nsIInterceptedChannel;
interface nsIPrincipal;
interface nsIPushSubscription;
interface nsIRunnable;
interface nsIURI;
%{C++
namespace mozilla {
namespace dom { class ClientInfo; class ServiceWorkerDescriptor; class IPCNotification;
} // namespace dom
} // namespace mozilla
%}
// How many times has this ServiceWorker been launched since the registration // was loaded? This value is not persistent and starts at 0 every time the // browser restarts. The value also inherently starts at 0 for a freshly // installed or updated ServiceWorker.
readonly attribute unsigned long launchCount;
readonly attribute unsignedshort state;
readonly attribute nsIWorkerDebugger debugger;
// Return whether the ServiceWorker has a "fetch" event listener. Throws if // this is unknown because the worker's main script hasn't finished executing // (when exposed as evaluatingWorker).
readonly attribute boolean handlesFetchEvents;
// Returns the lifetime deadline of the ServiceWorker as the number of // milliseconds since the (parent) process was created or 0 if there is no // current deadline. This is primarily intended to allow tests to compare // consistent values, not be useful in general. But note that // `ChromeUtils.now()` operates in the same units (milliseconds since // current process startup), and so can be used to hackily translate to wall // clock time.
readonly attribute double lifetimeDeadline;
// Total number of navigation faults experienced by this ServiceWorker since // it was loaded from disk at startup or was installed.
readonly attribute unsigned long navigationFaultCount;
// Testing mechanism to induce synthetic failure of fetch events. If set to // something other than NS_OK, all fetch events dispatched will be propagated // to the content process, but when it comes time to dispatch the fetch event, // the cancellation control flow path will be triggered.
attribute nsresult testingInjectCancellation;
void attachDebugger();
void detachDebugger();
// Forcibly terminate the ServiceWorker if it is running, returning a promise // that will be resolved when the worker is fully terminated. If the // ServiceWorker was not running, the promise will be resolved immediately. // // For the purposes of the ServiceWorkerManager, it's as if the ServiceWorker // is already dead when the call completes and returns the Promise. Any new // functional events dispatched at the ServiceWorker will result in a new // instance/global being spun up.
[implicit_jscontext]
Promise terminateWorker();
};
// Exposes the number of times we have ever checked the usage of this origin // for the purposes of mitigating ServiceWorker navigation faults that we // suspect to be due to quota limit problems. This should start out 0 and // max out at 1 for the time being. // // Note that the underlying value is tracked on our per-Principal data, but // we don't currently expose that data directly via XPCOM so we're exposing // this here as the next best thing and because most non-test consumers would // work in terms of the registration anyways. // // This will return -1 if there is no longer any per-origin data because the // last registration for the origin (principal) has been unregistered. // (Retaining a reference to this interface does not impact anything the // underlying scope-to-registration map that is implemented per spec.)
readonly attribute long quotaUsageCheckCount;
// Allows to get the related nsIServiceWorkerInfo for a given // nsIWorkerDebugger. Over time we shouldn't need this anymore, // and instead always control then nsIWorkerDebugger from // nsIServiceWorkerInfo and not the other way around. Returns // null if the service worker is no longer registered.
nsIServiceWorkerInfo getWorkerByID(in unsigned long long aID);
// Terminate all the service worker relate to this registration. // This is used by the WebExtensions framework to shutdown the extension's // background service workers as part of shutdown, which happens when: // - the extension has been disabled. // - the extension is shutting down to be updated. // - the extension is shutting down as part of the uninstall flow. // // All the service workers instances related to this registration are expected // to be terminate immediately. // // TODO - Bug 1638099: This method should also allow the WebExtension framework // to mark the registration as disabled (e.g. through an additional parameter), // to avoid it to be started again until the WebExtensions framework does explicitly // mark it back to enabled. void forceShutdown();
};
/** *UnregisteranexistingServiceWorkerregistrationfor`aScope`. *ItkeepsaCallbackaliveuntiltheoperationisconcluded.
*/ void unregister(in nsIPrincipal aPrincipal,
in nsIServiceWorkerUnregisterCallback aCallback,
in AString aScope);
nsIServiceWorkerRegistrationInfo getRegistrationByPrincipal(in nsIPrincipal aPrincipal,
in AString aScope);
[notxpcom, nostdcall] boolean StartControlling(in const_ClientInfoRef aClientInfo,
in const_ServiceWorkerDescriptorRef aServiceWorker);
// Testing
AString getScopeForUrl(in nsIPrincipal aPrincipal, in AString aPath);
// It returns an array of nsIServiceWorkerRegistrationInfos.
nsIArray getAllRegistrations();
// For clear-origin-attributes-data void removeRegistrationsByOriginAttributes(
in AString aOriginAttributes,
[optional] in nsIServiceWorkerUnregisterCallback aCallback);
// It calls unregister() in each child process. The callback is used to // inform when unregister() is completed on the current process. void propagateUnregister(in nsIPrincipal aPrincipal,
in nsIServiceWorkerUnregisterCallback aCallback,
in AString aScope);
[noscript] void sendNotificationClickEvent(in ACString aOriginSuffix,
in AString scope,
in const_IPCNotificationRef aNotification,
in AString aAction);
[noscript] void sendNotificationCloseEvent(in ACString aOriginSuffix,
in AString scope,
in const_IPCNotificationRef aNotification);
[optional_argc] void sendPushEvent(in ACString aOriginAttributes,
in ACString aScope,
[optional] in Array<uint8_t> aDataBytes); void sendPushSubscriptionChangeEvent(in ACString aOriginAttributes,
in ACString scope,
[optional] in nsIPushSubscription aOldSubscription);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.