2013-11-20 03:15:02 +04:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#include "domstubs.idl"
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
interface mozIDOMWindow;
|
|
|
|
interface nsPIDOMWindowInner;
|
|
|
|
interface mozIDOMWindowProxy;
|
2015-04-10 11:50:06 +03:00
|
|
|
interface nsIArray;
|
2014-07-21 10:25:44 +04:00
|
|
|
interface nsIDocument;
|
2015-02-19 04:34:29 +03:00
|
|
|
interface nsIInterceptedChannel;
|
2015-02-11 14:53:00 +03:00
|
|
|
interface nsIPrincipal;
|
2015-07-15 22:21:40 +03:00
|
|
|
interface nsIRunnable;
|
2014-07-15 01:15:23 +04:00
|
|
|
interface nsIURI;
|
|
|
|
|
2015-04-15 20:11:17 +03:00
|
|
|
[scriptable, uuid(52ee2c9d-ee87-4caf-9588-23ae77ff8798)]
|
2014-09-10 19:21:32 +04:00
|
|
|
interface nsIServiceWorkerUnregisterCallback : nsISupports
|
|
|
|
{
|
|
|
|
// aState is true if the unregistration succeded.
|
|
|
|
// It's false if this ServiceWorkerRegistration doesn't exist.
|
2015-04-15 20:11:17 +03:00
|
|
|
void unregisterSucceeded(in bool aState);
|
|
|
|
void unregisterFailed();
|
2014-09-10 19:21:32 +04:00
|
|
|
};
|
|
|
|
|
2015-11-26 14:18:56 +03:00
|
|
|
interface nsIWorkerDebugger;
|
|
|
|
|
|
|
|
[scriptable, builtinclass, uuid(76e357ed-208d-4e4c-9165-1c4059707879)]
|
2015-11-05 09:15:49 +03:00
|
|
|
interface nsIServiceWorkerInfo : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute DOMString scriptSpec;
|
|
|
|
readonly attribute DOMString cacheName;
|
2015-11-26 14:18:56 +03:00
|
|
|
|
|
|
|
readonly attribute nsIWorkerDebugger debugger;
|
|
|
|
|
|
|
|
void attachDebugger();
|
|
|
|
|
|
|
|
void detachDebugger();
|
2015-11-05 09:15:49 +03:00
|
|
|
};
|
|
|
|
|
2015-11-13 23:54:45 +03:00
|
|
|
[scriptable, uuid(87e63548-d440-4b8a-b158-65ad1de0211E)]
|
|
|
|
interface nsIServiceWorkerRegistrationInfoListener : nsISupports
|
|
|
|
{
|
|
|
|
void onChange();
|
|
|
|
};
|
|
|
|
|
2015-12-15 14:10:53 +03:00
|
|
|
[scriptable, builtinclass, uuid(ddbc1fd4-2f2e-4fca-a395-6e010bbedfe3)]
|
2015-11-02 17:04:41 +03:00
|
|
|
interface nsIServiceWorkerRegistrationInfo : nsISupports
|
2015-04-10 11:50:06 +03:00
|
|
|
{
|
|
|
|
readonly attribute nsIPrincipal principal;
|
|
|
|
|
|
|
|
readonly attribute DOMString scope;
|
|
|
|
readonly attribute DOMString scriptSpec;
|
|
|
|
|
2015-11-05 09:15:49 +03:00
|
|
|
readonly attribute nsIServiceWorkerInfo installingWorker;
|
|
|
|
readonly attribute nsIServiceWorkerInfo waitingWorker;
|
|
|
|
readonly attribute nsIServiceWorkerInfo activeWorker;
|
2015-11-13 23:54:45 +03:00
|
|
|
|
2015-12-15 14:10:53 +03:00
|
|
|
// 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
|
2016-01-15 20:37:34 +03:00
|
|
|
// nsIServiceWorkerInfo and not the other way around. Returns
|
|
|
|
// null if the service worker is no longer registered.
|
2015-12-15 14:10:53 +03:00
|
|
|
nsIServiceWorkerInfo getWorkerByID(in unsigned long long aID);
|
|
|
|
|
2015-11-13 23:54:45 +03:00
|
|
|
void addListener(in nsIServiceWorkerRegistrationInfoListener listener);
|
|
|
|
|
|
|
|
void removeListener(in nsIServiceWorkerRegistrationInfoListener listener);
|
2015-04-10 11:50:06 +03:00
|
|
|
};
|
|
|
|
|
2015-11-04 17:17:02 +03:00
|
|
|
[scriptable, uuid(9e523e7c-ad6f-4df0-8077-c74aebbc679d)]
|
|
|
|
interface nsIServiceWorkerManagerListener : nsISupports
|
|
|
|
{
|
|
|
|
void onRegister(in nsIServiceWorkerRegistrationInfo aInfo);
|
|
|
|
|
|
|
|
void onUnregister(in nsIServiceWorkerRegistrationInfo aInfo);
|
|
|
|
};
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
[scriptable, builtinclass, uuid(7404c8e8-4d47-4449-8ed1-47d1261d4e33)]
|
2013-11-20 03:15:02 +04:00
|
|
|
interface nsIServiceWorkerManager : nsISupports
|
|
|
|
{
|
2014-08-22 03:31:12 +04:00
|
|
|
/**
|
|
|
|
* Registers a ServiceWorker with script loaded from `aScriptURI` to act as
|
|
|
|
* the ServiceWorker for aScope. Requires a valid entry settings object on
|
|
|
|
* the stack. This means you must call this from content code 'within'
|
|
|
|
* a window.
|
|
|
|
*
|
|
|
|
* Returns a Promise.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
nsISupports register(in mozIDOMWindow aWindow, in nsIURI aScope, in nsIURI aScriptURI);
|
2013-11-20 03:15:02 +04:00
|
|
|
|
2014-08-22 03:31:12 +04:00
|
|
|
/**
|
2014-09-10 19:21:32 +04:00
|
|
|
* Unregister an existing ServiceWorker registration for `aScope`.
|
|
|
|
* It keeps aCallback alive until the operation is concluded.
|
2014-08-22 03:31:12 +04:00
|
|
|
*/
|
2015-02-11 14:53:00 +03:00
|
|
|
void unregister(in nsIPrincipal aPrincipal,
|
|
|
|
in nsIServiceWorkerUnregisterCallback aCallback,
|
2014-09-10 19:21:32 +04:00
|
|
|
in DOMString aScope);
|
2013-11-20 03:15:02 +04:00
|
|
|
|
2014-08-20 19:40:00 +04:00
|
|
|
// Returns a Promise
|
2016-01-30 20:05:36 +03:00
|
|
|
nsISupports getRegistrations(in mozIDOMWindow aWindow);
|
2014-08-20 19:40:00 +04:00
|
|
|
|
|
|
|
// Returns a Promise
|
2016-01-30 20:05:36 +03:00
|
|
|
nsISupports getRegistration(in mozIDOMWindow aWindow, in DOMString aScope);
|
2014-08-20 19:40:00 +04:00
|
|
|
|
2014-08-26 12:16:03 +04:00
|
|
|
// Returns a Promise
|
2016-01-30 20:05:36 +03:00
|
|
|
nsISupports getReadyPromise(in mozIDOMWindow aWindow);
|
2014-08-26 12:16:03 +04:00
|
|
|
|
|
|
|
// Remove ready pending Promise
|
2016-01-30 20:05:36 +03:00
|
|
|
void removeReadyPromise(in mozIDOMWindow aWindow);
|
2014-08-26 12:16:03 +04:00
|
|
|
|
2015-12-15 14:10:53 +03:00
|
|
|
nsIServiceWorkerRegistrationInfo getRegistrationByPrincipal(in nsIPrincipal aPrincipal,
|
|
|
|
in DOMString aScope);
|
|
|
|
|
2014-07-21 10:25:44 +04:00
|
|
|
/**
|
|
|
|
* Call this to request that document `aDoc` be controlled by a ServiceWorker
|
|
|
|
* if a registration exists for it's scope.
|
|
|
|
*
|
|
|
|
* This MUST only be called once per document!
|
|
|
|
*/
|
2015-11-26 02:03:59 +03:00
|
|
|
[notxpcom,nostdcall] void MaybeStartControlling(in nsIDocument aDoc, in DOMString aDocumentId);
|
2014-07-21 10:25:44 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Documents that have called MaybeStartControlling() should call this when
|
|
|
|
* they are destroyed. This function may be called multiple times, and is
|
|
|
|
* idempotent.
|
|
|
|
*/
|
|
|
|
[notxpcom,nostdcall] void MaybeStopControlling(in nsIDocument aDoc);
|
|
|
|
|
2014-08-25 09:35:03 +04:00
|
|
|
/*
|
|
|
|
* Returns a ServiceWorker.
|
|
|
|
* window is the window of the caller. scope is the registration's scope and must be
|
|
|
|
* a valid entry that window is allowed to load, otherwise this will return nullptr.
|
|
|
|
* These are only meant to be called from ServiceWorkerRegistration instances.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
[noscript] nsISupports GetInstalling(in nsPIDOMWindowInner aWindow, in DOMString aScope);
|
|
|
|
[noscript] nsISupports GetWaiting(in nsPIDOMWindowInner aWindow, in DOMString aScope);
|
|
|
|
[noscript] nsISupports GetActive(in nsPIDOMWindowInner aWindow, in DOMString aScope);
|
2014-08-25 09:35:03 +04:00
|
|
|
|
|
|
|
/*
|
2015-10-01 02:11:03 +03:00
|
|
|
* Returns a ServiceWorker object representing the active worker controlling this
|
|
|
|
* window.
|
2014-08-25 09:35:03 +04:00
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
[noscript] nsISupports GetDocumentController(in nsPIDOMWindowInner aWindow);
|
2014-07-24 01:05:08 +04:00
|
|
|
|
2015-03-06 04:37:49 +03:00
|
|
|
/*
|
|
|
|
* Clears ServiceWorker registrations from memory and disk for the specified
|
|
|
|
* host.
|
|
|
|
* - All ServiceWorker instances change their state to redundant.
|
|
|
|
* - Existing ServiceWorker instances handling fetches will keep running.
|
|
|
|
* - All documents will immediately stop being controlled.
|
|
|
|
* - Unregister jobs will be queued for all registrations.
|
|
|
|
* This eventually results in the registration being deleted from disk too.
|
|
|
|
*/
|
2015-06-21 14:19:07 +03:00
|
|
|
void removeAndPropagate(in AUTF8String aHost);
|
2015-03-06 04:37:49 +03:00
|
|
|
|
2014-07-11 22:52:19 +04:00
|
|
|
// Testing
|
2015-06-03 11:43:43 +03:00
|
|
|
DOMString getScopeForUrl(in nsIPrincipal aPrincipal, in DOMString aPath);
|
2015-04-10 11:50:06 +03:00
|
|
|
|
2015-06-04 21:51:57 +03:00
|
|
|
// Note: This is meant to be used only by about:serviceworkers.
|
2015-11-02 17:04:41 +03:00
|
|
|
// It returns an array of nsIServiceWorkerRegistrationInfos.
|
2015-04-10 11:50:06 +03:00
|
|
|
nsIArray getAllRegistrations();
|
2015-04-11 06:19:28 +03:00
|
|
|
|
2015-06-04 21:51:57 +03:00
|
|
|
// Note: This is meant to be used only by about:serviceworkers.
|
|
|
|
// It calls softUpdate() for each child process.
|
|
|
|
[implicit_jscontext] void propagateSoftUpdate(in jsval aOriginAttributes,
|
|
|
|
in DOMString aScope);
|
|
|
|
|
|
|
|
// Note: This is meant to be used only by about:serviceworkers.
|
|
|
|
// 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 DOMString aScope);
|
|
|
|
|
2015-06-26 04:50:25 +03:00
|
|
|
void sendNotificationClickEvent(in ACString aOriginSuffix,
|
|
|
|
in ACString scope,
|
|
|
|
in AString aID,
|
|
|
|
in AString aTitle,
|
|
|
|
in AString aDir,
|
|
|
|
in AString aLang,
|
|
|
|
in AString aBody,
|
|
|
|
in AString aTag,
|
|
|
|
in AString aIcon,
|
|
|
|
in AString aData,
|
|
|
|
in AString aBehavior);
|
2016-04-20 08:04:09 +03:00
|
|
|
|
|
|
|
void sendNotificationCloseEvent(in ACString aOriginSuffix,
|
|
|
|
in ACString scope,
|
|
|
|
in AString aID,
|
|
|
|
in AString aTitle,
|
|
|
|
in AString aDir,
|
|
|
|
in AString aLang,
|
|
|
|
in AString aBody,
|
|
|
|
in AString aTag,
|
|
|
|
in AString aIcon,
|
|
|
|
in AString aData,
|
|
|
|
in AString aBehavior);
|
|
|
|
|
2015-09-17 15:13:04 +03:00
|
|
|
[optional_argc] void sendPushEvent(in ACString aOriginAttributes,
|
|
|
|
in ACString aScope,
|
|
|
|
[optional] in uint32_t aDataLength,
|
|
|
|
[optional, array, size_is(aDataLength)] in uint8_t aDataBytes);
|
2015-06-24 23:34:54 +03:00
|
|
|
void sendPushSubscriptionChangeEvent(in ACString aOriginAttributes,
|
|
|
|
in ACString scope);
|
2015-11-04 17:17:02 +03:00
|
|
|
|
|
|
|
void addListener(in nsIServiceWorkerManagerListener aListener);
|
|
|
|
|
|
|
|
void removeListener(in nsIServiceWorkerManagerListener aListener);
|
2015-11-16 19:04:11 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
bool shouldReportToWindow(in mozIDOMWindowProxy aWindow, in ACString aScope);
|
2013-11-20 03:15:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
%{ C++
|
|
|
|
#define SERVICEWORKERMANAGER_CONTRACTID "@mozilla.org/serviceworkers/manager;1"
|
|
|
|
%}
|