Commit graph

158 commits

Author SHA1 Message Date
Sandor Molnar
09e7cbd0b7 Backed out 6 changesets (bug 1876575, bug 1876574) for causing build bustages @ toolkit/components/resistfingerprinting/nsRFPService.cpp CLOSED TREE
Backed out changeset 455ce831c73c (bug 1876575)
Backed out changeset 4fa3fbf3a3ae (bug 1876575)
Backed out changeset ac4c41cb3b67 (bug 1876575)
Backed out changeset 15e06d10788e (bug 1876575)
Backed out changeset dcd6bbea816a (bug 1876575)
Backed out changeset cc547125fda9 (bug 1876574)
2024-03-29 16:29:47 +02:00
Benjamin VanderSloot
5538e1f9d7 Bug 1876575, part 2 - Make Workers use ancestor chain for third-partiness check - r=anti-tracking-reviewers,timhuang,asuth
Differential Revision: https://phabricator.services.mozilla.com/D203289
2024-03-29 13:11:27 +00:00
Jan Varga
67a8ed7ac0 Bug 1855142 - Ensure IndexedDabaseManager::mLocale separately; r=dom-storage-reviewers,jari
mLocale is currently initialized in IndexedDatabaseManager::Init which is
called from IndexedDatabaseManager::GetOrCreate if the manager doesn't exist.
This can be a problem when IndexedDatabaseManager::GetOrCreate is called very
early,for example in nsLayoutStatics::Initialize in the parent process.

This is a preparation for moving IndexedDatabaseManager::GetOrCreate from
FactoryOp::Open to InitializeQuotaManager.

Differential Revision: https://phabricator.services.mozilla.com/D189891
2024-02-29 15:28:47 +00:00
Jens Stutte
a2709c2f0e Bug 1875800 - Add name support to WorkerRunnable. r=dom-worker-reviewers,asuth,smaug
Differential Revision: https://phabricator.services.mozilla.com/D199228
2024-01-24 16:00:26 +00:00
Cristian Tuns
741982b984 Backed out changeset f3efca74da0f (bug 1875800) for causing build bustages in WorkerPrivate.cpp CLOSED TREE 2024-01-23 11:20:38 -05:00
Jens Stutte
2594dc03cd Bug 1875800 - Add name support to WorkerRunnable. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D199228
2024-01-23 11:23:41 +00:00
Tom Schuster
34713ab490 Bug 1871063 - Forward CSP violations from creating a new SharedWorker. r=edenchuang
Differential Revision: https://phabricator.services.mozilla.com/D196968
2024-01-22 17:13:34 +00:00
Tim Huang
523b214d9a Bug 1824222 - Add OverriddenFingerprintingSettings to worker loadInfo. r=tjr,dom-worker-reviewers,smaug
To allow workers to know the OverriddenFingerprintingSettings,
we populate the value to the worker loadInfo and worker private from
the document.

For service workers, we use the partitionKey in its principal to get
the OverriddenFingerprintingSettings of the given service worker.

Differential Revision: https://phabricator.services.mozilla.com/D185014
2023-10-17 22:02:28 +00:00
Emilio Cobos Álvarez
25c0d10932 Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Benjamin VanderSloot
8acc7b239c Bug 1835907, part 5 - Refactor the window's mStorageAccessPermissionGranted variable and its Getters to a more accurate name: mUsingStorageAccess - r=anti-tracking-reviewers,pbz
This probably should have been done earlier, but became obvious with uses of Document::HasStorageAccessPermissionGrated in this stack.

Differential Revision: https://phabricator.services.mozilla.com/D184825
2023-08-15 13:04:05 +00:00
Cosmin Sabou
4f5ef3986b Backed out 6 changesets (bug 1835907) for causing multiple failures. CLOSED TREE
Backed out changeset 91ef29afec50 (bug 1835907)
Backed out changeset 989479621780 (bug 1835907)
Backed out changeset 86e3f98ceb31 (bug 1835907)
Backed out changeset 4790e44c234c (bug 1835907)
Backed out changeset bb9f48eec5bf (bug 1835907)
Backed out changeset 74f90708260a (bug 1835907)
2023-08-14 22:18:10 +03:00
Benjamin VanderSloot
d2a4578703 Bug 1835907, part 5 - Refactor the window's mStorageAccessPermissionGranted variable and its Getters to a more accurate name: mUsingStorageAccess - r=anti-tracking-reviewers,pbz
This probably should have been done earlier, but became obvious with uses of Document::HasStorageAccessPermissionGrated in this stack.

Differential Revision: https://phabricator.services.mozilla.com/D184825
2023-08-14 18:02:47 +00:00
Andrew Sutherland
dc8f6b59a7 Bug 1833312 - MPIR should not steal the caller's RefPtr. r=edenchuang
Before bug 1775784, RemoteWorkerChild's refcount was not threadsafe and
so RemoteWorkerChild-related logic went to great contortions to avoid
trying to create new refcounts off the worker launcher thread, leading
to the logic stealing the caller's RefPtr.  However, this was unsound
in the case that the RefPtr would be used after the creation of the
MessagePortIdentifierRuynnable, which was the case if dispatch of the
runnable failed.  This fix changes us to the standard XPCOM calling
convention of passing a raw pointer which the MPIR then acquires a
fresh strong refcount.  This code is not remotely performance
sensitive and the prior behavior was surprising, so there's no reason
to try and maintain the transfer of the refcount.

Differential Revision: https://phabricator.services.mozilla.com/D180063
2023-06-07 00:13:09 +00:00
Eden Chuang
ea1bf2603a Bug 1800659 - P3 Remove WorkerPrivate::ClearMainEventQueue() r=asuth,smaug
Pending->Canceling->Killing (WorkerNeverRan)

Need to clear WorkerPrivate::mPreStartRunnables

Could we call WorkerRunnable::WorkerRun() to release resource? There could be no WorkerGlobalScope...

Pending->Running->Closing->Canceling->Killing(WorkerRan)
Pending->Running->Canceling->Killing(WorkerRan)

When entering “Closing”
1. Keeping receives normal WorkerRunnables
2. Making ParentStatus as Closing
3. Cancel all timeout
4. Don’t clear the main event queue anymore. But we still wait for all SyncLoops be completed.
5. Call WorkerGlobalScope::NoteTerminating() and nsIGlobalObject::DisconnectEventTargetObjects().
6. Switching to “Canceling” by asking parent thread to call WorkerPrivate::Cancel()

When entering “Canceling”
1. Call WorkerGlobalScope::NoteTerminating()
2. Notify StrongWorkerRefs, worker is in “Canceling”, send and complete the corresponding shutdown work right now.
3. Executing all runnables until no normal WorkerRunnables in queue and no WorkerRefs, SyncLoops and children workers
4. Stop receiving normal WorkerRunnables and DisconnectEventTargetObjects of WorkerScope.
4. Entering “Killing”

When entering “Killing”
1. We would not notify WorkerRefs anymore. Logically all WorkerRefs should be released in “Canceling”
2. Executing all remaining ControlRunnables
3. Release corresponding resources of Worker on worker thread.

Depends on D173850

Differential Revision: https://phabricator.services.mozilla.com/D177511
2023-06-06 06:36:50 +00:00
Randell Jesup
1464e9c376 Bug 1824847: Maintain number of active WebTransports per document for controlling BFCache entry r=smaug,saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D173769
2023-04-15 03:32:38 +00:00
Natalia Csoregi
0bb0c6f3c7 Backed out changeset 1021dafccac0 (bug 1824847) for failures on webtransport. CLOSED TREE 2023-04-14 04:07:44 +03:00
Randell Jesup
1c16c8e248 Bug 1824847: Maintain number of active WebTransports per document for controlling BFCache entry r=smaug,saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D173769
2023-04-13 19:35:16 +00:00
Andrew Sutherland
b21cc21e8a Bug 1775784 - Improve worker shutdown ordering. r=dom-worker-reviewers,smaug
This patch simplifies and cleans up the RemoteWorker state machine by:
- (In a previous patch in the stack) making PRemoteWorker refcounted instead of
  ManualAlloc allows us to eliminate use of ThreadSafeWeakPtr and some legwork
  that was attempting to ensure we only drop references to RemoteWorkerChild on
  the "Worker Launcher" thread.
  - Although we are not allowed to call IPC methods on a different thread, we
    can absolutely add and remove refcounts on other threads as needed.
  - This allowed removal of the `SelfHolder` class as well as a number of calls
    to NS_ProxyRelease.
  - This allowed removal of the `{get,m}RemoteWorkerControllerWeakRef` hack.
- Adding 2 optional lambda callbacks to the WorkerPrivate constructor that will
  be notified on the parent thread in order to simplify tracking the state of
  the worker:
  - CancellationCallback: Invoked when the parent thread tells the worker to
    cancel itself.  This can be the automatic result of a script load error,
    a call to `self.close()`, or an explicit call to Cancel() by the parent.
    - Note that cancellation was always being initiated by the parent thread,
      even in the case of `self.close()`!
  - TerminationCallback: Invoked when the worker thread has finished and the
    WorkerPrivate's self-ref is about to be dropped.  This indicates that the
    worker transitioned to Killing and fully completed that process.
- Changing the RemoteWorkerChild to always perform state transitions on the
  owning parent thread (although the state may be checked from other threads,
  more in the code comments).
  - The CancellationCallback mechanism replaces a complicated use of
    WorkerRefs.  This allowed removal of ReleaseWorkerRunnable.
  - In general this reduces the number of permutations of thread interactions
    we have to worry about.
- Changing the RemoteWorkerChild to only report that the worker has finished
  shutting down as a result of the TerminationCallback rather than when the
  worker has transitioned to Cancelling.
- Changing the states to better represent the worker's state in terms of
  WorkerStatus terminology.

Some related cleanups:
- Use of mechanisms provided by IPC:
  - RemoteWorkerChild had an mOwningEventTarget with a GetOwningEventTarget
    getter that we were able to replace with the IPC-maintained
    GetActorEventTarget().
  - We replaced the `mIPCActive` with use of IPC's CanSend().
- MOZ_LOG logging was added under "RemoteWorkerChild".

Differential Revision: https://phabricator.services.mozilla.com/D164644
2023-03-14 23:57:57 +00:00
Yulia Startsev
e6d68fc585 Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-14 09:04:59 +00:00
Marian-Vasile Laza
2b10b4cf84 Backed out 4 changesets (bug 1805676) for wpt failures on shared-worker-import-csp.html. CLOSED TREE
Backed out changeset 95d1e02df42c (bug 1805676)
Backed out changeset 79f32abb379d (bug 1805676)
Backed out changeset 2d35363f5937 (bug 1805676)
Backed out changeset b173c8e2beba (bug 1805676)
2023-02-13 21:14:00 +02:00
Yulia Startsev
a3e98a92c7 Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-13 16:09:46 +00:00
Stanca Serban
35c5dff6e9 Backed out 4 changesets (bug 1805676) for causing wpt failures in /workers/modules/shared-worker-import-csp.html. CLOSED TREE
Backed out changeset 3d943ee00682 (bug 1805676)
Backed out changeset 34da8cbd7db2 (bug 1805676)
Backed out changeset 1573d31341db (bug 1805676)
Backed out changeset 212f36c3a9e0 (bug 1805676)
2023-02-13 10:41:28 +02:00
Yulia Startsev
fad5626a3b Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-13 07:35:59 +00:00
Eden Chuang
14ff5b1650 Bug 1351231 - Integrate FetchChild into Fetch.cpp r=dom-worker-reviewers,jesup
Depends on D142437

Differential Revision: https://phabricator.services.mozilla.com/D142704
2023-01-20 09:09:18 +00:00
Noemi Erli
2a016fbd8d Backed out 5 changesets (bug 1351231) for causing multiple wpt failures CLOSED TREE
Backed out changeset 257553919696 (bug 1351231)
Backed out changeset 4fd92351d64b (bug 1351231)
Backed out changeset 7a4e3f5f674a (bug 1351231)
Backed out changeset 9da00c1364a5 (bug 1351231)
Backed out changeset 19b78046ffef (bug 1351231)
2023-01-18 18:16:01 +02:00
Eden Chuang
473cb0ffa2 Bug 1351231 - Integrate FetchChild into Fetch.cpp r=dom-worker-reviewers,jesup
Depends on D142437

Differential Revision: https://phabricator.services.mozilla.com/D142704
2023-01-18 00:50:20 +00:00
Marian-Vasile Laza
1037940f5b Backed out 5 changesets (bug 1351231) for causing multiple wpt failures. CLOSED TREE
Backed out changeset a41252141399 (bug 1351231)
Backed out changeset 6cbb442f4772 (bug 1351231)
Backed out changeset dbdca4661a35 (bug 1351231)
Backed out changeset ea27cd66fefd (bug 1351231)
Backed out changeset 8c21c9468949 (bug 1351231)
2023-01-17 19:53:09 +02:00
Eden Chuang
81c1e9c406 Bug 1351231 - Integrate FetchChild into Fetch.cpp r=dom-worker-reviewers,jesup
Depends on D142437

Differential Revision: https://phabricator.services.mozilla.com/D142704
2023-01-17 15:13:46 +00:00
Butkovits Atila
7855df7caf Backed out 5 changesets (bug 1351231) for causing fetch related failures. CLOSED TREE
Backed out changeset da5c4a821428 (bug 1351231)
Backed out changeset 66b279e5a513 (bug 1351231)
Backed out changeset 3eb8fdd0ba6d (bug 1351231)
Backed out changeset a1fcf22a2a0e (bug 1351231)
Backed out changeset fd2a843599d1 (bug 1351231)
2023-01-12 20:20:14 +02:00
Eden Chuang
181d5d396e Bug 1351231 - Integrate FetchChild into Fetch.cpp r=dom-worker-reviewers,jesup
Depends on D142437

Differential Revision: https://phabricator.services.mozilla.com/D142704
2023-01-12 17:24:29 +00:00
Stanca Serban
0d5b1d231b Backed out 5 changesets (bug 1351231) for Fetch related failures. CLOSED TREE
Backed out changeset cc26eeeaf3dd (bug 1351231)
Backed out changeset c0cb3c17f246 (bug 1351231)
Backed out changeset 84162d09eef8 (bug 1351231)
Backed out changeset 5c3b5a384f2f (bug 1351231)
Backed out changeset d8fa8a006948 (bug 1351231)
2023-01-12 18:56:25 +02:00
Eden Chuang
4993cf02ca Bug 1351231 - Integrate FetchChild into Fetch.cpp r=dom-worker-reviewers,jesup
Depends on D142437

Differential Revision: https://phabricator.services.mozilla.com/D142704
2023-01-12 15:09:45 +00:00
Jan Varga
3120da2b93 Bug 1803062 - Add a helper class for automatic proxy releasing of objects; r=dom-storage-reviewers,jesup
The helper makes it easier and simper to hold self references in lamnda
functions.

Differential Revision: https://phabricator.services.mozilla.com/D163938
2022-12-16 06:38:08 +00:00
Tom Ritter
61152c85e9 Bug 1770498: Add shouldResistFingerprinting to RemoteWorkerData r=asuth
Previously, we initialized WorkerLoadInfo's shouldRFP member
using the Worker's principal at time of construction. It is
better to populate it from the RemoteWorkerData structure.

The RemoteWorkerData's shouldRFP member can be initialized
with the correct context.

In ServiceWorkerPrivateImpl.cpp it has the same effect, before
and after we use ServiceWorkerInfo.mPrincipal

But for SharedWorker.cpp we previously used
RemoteWorkerData.principalInfo (the second of three principal
members).  This was initialized from the WorkerLoadInfo.mPrincipal
member, which in turn came from loadInfo.mChannel which in turn
came from loadInfo.mLoadingPrincipal.

Now we use the WorkerLoadInfo.mShouldResistFingerprinting member
which is initialized from
nsContentUtils::ShouldResistFingerprinting(document) in
WorkerPrivate::GetLoadInfo which can take into account greater
context which will be important in the next few patches.

Differential Revision: https://phabricator.services.mozilla.com/D150590
2022-07-15 20:39:19 +00:00
Tom Ritter
a53968736e Bug 1770498: Simplify Principal-based ShouldRFP check r=ckerschb,freddyb
- Reorder ShouldRFP(char* justification) to put it first
 - Add a log line about a null dochsell to be consistent
 - Significantly alter the ShouldRFP(nsIPrincipal) check:

   Before, it was a coarse function, if you weren't system
   principal, it just checked the pref.

   Now, it has been combined with the ShouldRFP(nsIPrincipal, OriginAttributes)
   function, which was fine-grained. That function didn't
   need to exist, because we can _get_ the OriginAttributes
   _from_ the principal.

   Because before we were retrieving the OA from the loadInfo
   (and not the principal) we add an assert to ensure they're
   the same.

   We eliminate the ShouldRFP(nsIPrincipal, OriginAttributes)
   function entirely and convert its one caller into just
   passing the principal.

   One result of all of this is that the ShouldRFP(nsIPrincipal)
   check has been turned into a fine-grained check.

Differential Revision: https://phabricator.services.mozilla.com/D146945
2022-07-15 20:39:17 +00:00
criss
cf82fc590a Backed out changeset 9bf6a5eb2ed5 (bug 1770498) for causing mochitest failures on browser_navigator.js . CLOSED TREE 2022-06-02 19:53:39 +03:00
Tom Ritter
0319228cb0 Bug 1770498: Simplify Principal-based ShouldRFP check r=ckerschb,freddyb
Differential Revision: https://phabricator.services.mozilla.com/D146945
2022-06-02 15:31:24 +00:00
Tom Schuster
4525afaf9f Bug 1740263 - Implement the CSP checking callback for WASM. r=dom-worker-reviewers,smaug,freddyb
Differential Revision: https://phabricator.services.mozilla.com/D141979
2022-05-19 14:13:50 +00:00
Iulian Moraru
4d59317ca4 Backed out 6 changesets (bug 1740263) for causing bp-hybrid bustages on nsScriptSecurityManager. CLOSED TREE
Backed out changeset 2f5ec6ad0f81 (bug 1740263)
Backed out changeset a1e7766cdb94 (bug 1740263)
Backed out changeset 3978ccb95455 (bug 1740263)
Backed out changeset e34ba774b3f8 (bug 1740263)
Backed out changeset 8365b10be28e (bug 1740263)
Backed out changeset d923462c9cd0 (bug 1740263)
2022-05-19 03:28:08 +03:00
Tom Schuster
5c808859fa Bug 1740263 - Implement the CSP checking callback for WASM. r=dom-worker-reviewers,smaug,freddyb
Differential Revision: https://phabricator.services.mozilla.com/D141979
2022-05-18 21:39:29 +00:00
Jens Stutte
e8e1c6bb2e Bug 1731298: Further audit accesses through mState variants. r=dom-worker-reviewers,asuth
Depends on D140302

Differential Revision: https://phabricator.services.mozilla.com/D140314
2022-04-29 06:09:24 +00:00
Tom Ritter
9664c43d70 Bug 1752907: Correctly populate the RFP member on Workers r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D141753
2022-03-23 19:01:50 +00:00
Eden Chuang
b1c9671000 Bug 1545733 - Don't call WorkerPrivate::Cancel() in RemoteWorkerChild::CloseWorkerOnMainThread() if RemoteWorkerChild::mState(Pending).mWorkerPrivate is nullptr. r=dom-worker-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D141721
2022-03-23 09:19:29 +00:00
Emilio Cobos Álvarez
8e81f196b9 Bug 1758705 - Make origin trials in workers work. r=asuth,dom-worker-reviewers
(pun intended)

Snapshot the trials at worker creation time, which should be enough for
our purposes.

Differential Revision: https://phabricator.services.mozilla.com/D140660
2022-03-11 11:05:09 +00:00
Jens Stutte
db8e331c53 Bug 1731298: Explicitly check if the worker is running in Exec. r=dom-worker-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D140302
2022-03-04 14:47:02 +00:00
Jens Stutte
a3884ad516 Bug 1741182: Harmonize WorkerRunnable derived classes' overrides of Cancel. r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D135679
2022-01-12 14:43:09 +00:00
Tim Huang
e9fcc1c87e Bug 1731982 - Part 10: Populate IsThirdPartyContextToTopWindow to WorkerPrivate. r=asuth
To know if a worker is created under a third-party context, we need to
populate the `IsThirdPartyContextToTopWindow` to WorkerPrivate. This is
needed to get the correct foreign partitioned prinipal when loading
worker script in the content processes.

Differential Revision: https://phabricator.services.mozilla.com/D129059
2021-11-25 13:11:33 +00:00
Yaron Tausky
83bb5d45cd Bug 1741493 - Split IPCInternalResponse r=nika
This commit replaces IPCInternalResponse with three different structs:
ParentToParentInternalResponse, ParentToChildInternalResponse, and
ChildToParentInternalResponse. Doing this lets us convert runtime
checks into compile-time type checks and simplifies relevant code.

Differential Revision: https://phabricator.services.mozilla.com/D131275
2021-11-19 16:45:19 +00:00
Alexandru Michis
490a04115c Backed out 12 changesets (bug 1731982, bug 1736401) for causing crashes. a=backout
DONTBUILD

Backed out changeset ab85eef8a4fd (bug 1736401)
Backed out changeset 347ce2439936 (bug 1731982)
Backed out changeset fa0ff1505daa (bug 1731982)
Backed out changeset 5b1f2b0a5673 (bug 1731982)
Backed out changeset 4adc65d2f1a3 (bug 1731982)
Backed out changeset a8700204af07 (bug 1731982)
Backed out changeset 88bd00ed8d94 (bug 1731982)
Backed out changeset 80bd8c79b931 (bug 1731982)
Backed out changeset 58ca3a94fec0 (bug 1731982)
Backed out changeset 0b28570dea43 (bug 1731982)
Backed out changeset 23524ce67bb9 (bug 1731982)
Backed out changeset d29cc06a65db (bug 1731982)
2021-11-09 09:23:38 +02:00
Tim Huang
de5e12c1b3 Bug 1731982 - Part 10: Populate IsThirdPartyContextToTopWindow to WorkerPrivate. r=asuth
To know if a worker is created under a third-party context, we need to
populate the `IsThirdPartyContextToTopWindow` to WorkerPrivate. This is
needed to get the correct foreign partitioned prinipal when loading
worker script in the content processes.

Differential Revision: https://phabricator.services.mozilla.com/D129059
2021-11-08 14:30:56 +00:00