gecko-dev/dom/workers
Andrea Marchesini 8ae9152b88 Bug 1193373 - Support Permissions API in Worker Context, r=manuel,webidl,asuth,smaug
This commit exposes the Permissions API to DOM Workers. It achieves this goal
by introducing a thread-safe bridge between `PermissionStatus` and the
`PermissionObserver`: the `PermissionStatusSink` object.

Actors:
- The `PermissionObserver` is a main-thread-only singleton that monitors
  permission change events and propagates the notification to the right sink
  objects.
- The `PermissionStatus` is the DOM object exposed to the global. It's not
  thread-safe.
- The `PermissionStatusSink` is the new bridge introduced by this commit.

The `PermissionStatusSink` lifetime:
- This object is kept alive on the current thread by the `PermissionStatus` and
  on the main thread by the `PermissionObserver`.
- The `PermissionStatus` creates the object on its creation thread. When
  `PermissionStatus` object is released (or disconnected from the owner, it
  disentangles itself from the `PermissionStatusSink`. The disentangle
  operation triggers the un-registration procedure from the
  `PermissionObserver` on the main thread.
- A weak `WorkerRef` is used to monitor the worker's lifetime.

Permission change notification:
- When the  `PermissionObserver` is notified for a permission-change event, it
  notifies all the `PermissionStatusSink`. This happens on the main thread (see
  `MaybeUpdatedByOnMainThread` and `MaybeUpdatedByNotifyOnlyOnMainThread`).
- Using `MozPromise`, the `PermissionStatusSink` computes the permission action
  (`PermissionChangedOnMainThread`) on the main thread, then informs the
  parent `PermissionStatus` object on its creation thread.
- The `PermissionStatus` object converts the action to the DOM
  `PermissionState` and dispatches an event.

Differential Revision: https://phabricator.services.mozilla.com/D224594
2024-10-11 06:53:48 +00:00
..
loader Bug 1918449 - Part 1: Handle unknown module type earlier r=jonco,dom-worker-reviewers,dom-core,asuth,mccr8 2024-09-24 08:50:36 +00:00
remoteworkers Bug 1923501 - Fix WPT workers/shared-worker-options-mismatch.html, r=asuth 2024-10-08 23:05:04 +00:00
sharedworkers Bug 1923501 - Fix WPT workers/shared-worker-options-mismatch.html, r=asuth 2024-10-08 23:05:04 +00:00
test Bug 1193373 - Support Permissions API in Worker Context, r=manuel,webidl,asuth,smaug 2024-10-11 06:53:48 +00:00
ChromeWorker.cpp
ChromeWorker.h
ChromeWorkerScope.cpp
ChromeWorkerScope.h
EventWithOptionsRunnable.cpp
EventWithOptionsRunnable.h
JSExecutionManager.cpp
JSExecutionManager.h
JSSettings.h
MessageEventRunnable.cpp
MessageEventRunnable.h
moz.build
nsIWorkerChannelInfo.idl
nsIWorkerDebugger.idl Bug 1910698 - Remove nsIScriptError.sourceLine. r=smaug,devtools-reviewers,webdriver-reviewers,necko-reviewers,nchevobbe,kershaw,jdescottes,credential-management-reviewers,dimi 2024-08-01 17:12:48 +00:00
nsIWorkerDebuggerManager.idl
Queue.h
RegisterBindings.cpp Bug 1906744 - Check if constructor is enabled before installing named property. r=mccr8,dom-storage-reviewers,janv,asuth,eemeli 2024-08-08 16:35:19 +00:00
RuntimeService.cpp Backed out 9 changesets (bug 1911021) for causing multiple failures. CLOSED TREE 2024-10-11 02:59:43 +03:00
RuntimeService.h Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth 2024-06-27 12:39:47 +00:00
ScriptLoader.cpp Bug 1880789 - Remove dom.workers.modules.enabled pref. r=gregp,webidl,dom-worker-reviewers,saschanaz,dom-storage-reviewers,janv,yulia,asuth 2024-09-24 10:48:13 +00:00
ScriptLoader.h
Worker.cpp
Worker.h
WorkerChannelInfo.cpp
WorkerChannelInfo.h
WorkerCommon.h Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth 2024-06-27 12:39:47 +00:00
WorkerCSPEventListener.cpp
WorkerCSPEventListener.h
WorkerDebugger.cpp Bug 1910698 - Remove nsIScriptError.sourceLine. r=smaug,devtools-reviewers,webdriver-reviewers,necko-reviewers,nchevobbe,kershaw,jdescottes,credential-management-reviewers,dimi 2024-08-01 17:12:48 +00:00
WorkerDebugger.h Bug 1910698 - Remove nsIScriptError.sourceLine. r=smaug,devtools-reviewers,webdriver-reviewers,necko-reviewers,nchevobbe,kershaw,jdescottes,credential-management-reviewers,dimi 2024-08-01 17:12:48 +00:00
WorkerDebuggerManager.cpp
WorkerDebuggerManager.h
WorkerDocumentListener.cpp
WorkerDocumentListener.h
WorkerError.cpp Bug 1923501 - Fix WPT workers/shared-worker-options-mismatch.html, r=asuth 2024-10-08 23:05:04 +00:00
WorkerError.h Bug 1923501 - Fix WPT workers/shared-worker-options-mismatch.html, r=asuth 2024-10-08 23:05:04 +00:00
WorkerEventTarget.cpp Bug 1914034 - Expose wrapped runnable name in ExternalRunnableWrapper::GetName and WrappedControlRunnable::GetName r=nika 2024-08-22 19:29:22 +00:00
WorkerEventTarget.h
WorkerIPCUtils.h Bug 1923501 - Fix WPT workers/shared-worker-options-mismatch.html, r=asuth 2024-10-08 23:05:04 +00:00
WorkerLoadInfo.cpp Bug 1914286 - Remove NS_RelaxStrictFileOriginPolicy. r=smaug,necko-reviewers,kershaw 2024-08-23 10:13:35 +00:00
WorkerLoadInfo.h
WorkerLocation.cpp
WorkerLocation.h
WorkerNavigator.cpp Bug 1193373 - Support Permissions API in Worker Context, r=manuel,webidl,asuth,smaug 2024-10-11 06:53:48 +00:00
WorkerNavigator.h Bug 1193373 - Support Permissions API in Worker Context, r=manuel,webidl,asuth,smaug 2024-10-11 06:53:48 +00:00
WorkerPrivate.cpp Bug 1917822 - Add mozilla::dom::TimeoutManager to WorkerGlobalScope, r=smaug 2024-10-08 13:26:00 +00:00
WorkerPrivate.h Bug 1916465 - Allow SharedArrayBuffer for Inference Remote Type r=nika,dom-worker-reviewers,asuth 2024-09-27 14:47:40 +00:00
WorkerRef.cpp
WorkerRef.h
WorkerRunnable.cpp Bug 1894231 - P11 Remove WorkerThreadRunnable::mWorkerPrivateForPreStartCleaning. r=dom-worker-reviewers,asuth 2024-06-24 22:20:54 +00:00
WorkerRunnable.h Bug 1894231 - P11 Remove WorkerThreadRunnable::mWorkerPrivateForPreStartCleaning. r=dom-worker-reviewers,asuth 2024-06-24 22:20:54 +00:00
WorkerScope.cpp Bug 1917822 - Add mozilla::dom::TimeoutManager to WorkerGlobalScope, r=smaug 2024-10-08 13:26:00 +00:00
WorkerScope.h Bug 1917822 - Add mozilla::dom::TimeoutManager to WorkerGlobalScope, r=smaug 2024-10-08 13:26:00 +00:00
WorkerStatus.h
WorkerTestUtils.cpp Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth 2024-06-27 12:39:47 +00:00
WorkerTestUtils.h Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth 2024-06-27 12:39:47 +00:00
WorkerThread.cpp Bug 1905337 - Keep dispatched RefPtr<WorkerThreadRunnable> of WorkerPrivate::mPreStartRunnables. r=dom-worker-reviewers,jstutte,smaug 2024-07-03 09:59:16 +00:00
WorkerThread.h Bug 1905337 - Keep dispatched RefPtr<WorkerThreadRunnable> of WorkerPrivate::mPreStartRunnables. r=dom-worker-reviewers,jstutte,smaug 2024-07-03 09:59:16 +00:00