Sorry for the massive patch but I found it hard to split without
introducing a bunch of copies around...
This mostly makes necko and DOM agree on which strings to use, which
should result on less copies and conversions.
Differential Revision: https://phabricator.services.mozilla.com/D205601
For non-Window globals we pass `true` for `aInitStandardClasses` which results in
`CreateGlobal` calling `JS::InitRealmStandardClasses`.
This affects performance and memory usage and likely isn't necessary. It's also
nicer to not have this difference in behavior.
Differential Revision: https://phabricator.services.mozilla.com/D186216
This introduces two slight changes of behavior:
- Workers with a system principal are now always treated as secure context, without looking at the mIsSecureContext flag.
- We now also discard sources for all types of workers with a system principal
Differential Revision: https://phabricator.services.mozilla.com/D190282
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
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
It can fail when canceling the worker (though I couldn't reproduce the
crash locally). Some things were already accounting for it.
Rename some things for consistency.
Differential Revision: https://phabricator.services.mozilla.com/D175126
The default value for the target is Unknown, so all callsites
keep working.
We also add a Target value used for Document precomputation. This
value is enabled in RFP Lite mode, and allows us to precompute
ShouldRFP and cache it for faster computations later. (The later
computations will still check the Target, but won't need to do the
other expensive checks.)
Differential Revision: https://phabricator.services.mozilla.com/D170891
The default value for the target is Unknown, so all callsites
keep working.
We also add a Target value used for Document precomputation. This
value is enabled in RFP Lite mode, and allows us to precompute
ShouldRFP and cache it for faster computations later. (The later
computations will still check the Target, but won't need to do the
other expensive checks.)
Differential Revision: https://phabricator.services.mozilla.com/D170891
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).
Depends on D147324
Differential Revision: https://phabricator.services.mozilla.com/D147326
These methods only existed because nsIGlobalObject::PrincipalOrNull was not
available off-main-thread, so can now be removed.
Depends on D165198
Differential Revision: https://phabricator.services.mozilla.com/D165199
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).
Depends on D147324
Differential Revision: https://phabricator.services.mozilla.com/D147326
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).
Depends on D147324
Differential Revision: https://phabricator.services.mozilla.com/D147326
In some unusual cases, WorkerGlobalScope could live longer than WorkerPrivate since some other objects hold a reference on WorkerGlobalScope. We try to use CC/GC to release WorkerGlobalScope and force disconnect them from the WorkerPrivate before releasing WorkerPrivate. https://searchfox.org/mozilla-central/rev/83b86005c6913c2062419efb8aabdf2e683aa47f/dom/workers/RuntimeService.cpp#2068-2109
The previous implementation focused on nulling the WorkerGlobalScopeBase::mWorkerPrivate. However, it is not enough since WorkerGlobalScope's member could possibly hold a CheckedUnsafePtr<WorkerPrivate>, i.e. WorkerGlobalScope::mPerformance.
In this patch, we focus on breaking these connections.
Differential Revision: https://phabricator.services.mozilla.com/D162575
This centralizes the logic in one place.
In order to do this, we will need to check the principal
off-main thread. (Well, we need to know if it's System
Principal.) Worker and Worklet need special ways to do
this, so create a virtual method for it and let them
override it. This is analogous to the ShouldRFP method
on GlobalObject.
Differential Revision: https://phabricator.services.mozilla.com/D157564
This does not remove mShouldResistFingerprinting from
WorkerPrivate->mLoadInfo. This is because in between
mLoadInfo getting initialized (including where shouldRFP gets
set) and when the worker's global scope is constructed, we
need to keep track of whether we shouldRFP or not. We could
make this single bool an outparam of GetLoadInfo to later
pass to GetOrCreateGlobalScope, but that seems noisy.
Differential Revision: https://phabricator.services.mozilla.com/D157563
This centralizes the logic in one place.
In order to do this, we will need to check the principal
off-main thread. (Well, we need to know if it's System
Principal.) Worker and Worklet need special ways to do
this, so create a virtual method for it and let them
override it. This is analogous to the ShouldRFP method
on GlobalObject.
Differential Revision: https://phabricator.services.mozilla.com/D157564
This does not remove mShouldResistFingerprinting from
WorkerPrivate->mLoadInfo. This is because in between
mLoadInfo getting initialized (including where shouldRFP gets
set) and when the worker's global scope is constructed, we
need to keep track of whether we shouldRFP or not. We could
make this single bool an outparam of GetLoadInfo to later
pass to GetOrCreateGlobalScope, but that seems noisy.
Differential Revision: https://phabricator.services.mozilla.com/D157563
This centralizes the logic in one place.
In order to do this, we will need to check the principal
off-main thread. (Well, we need to know if it's System
Principal.) Worker and Worklet need special ways to do
this, so create a virtual method for it and let them
override it. This is analogous to the ShouldRFP method
on GlobalObject.
Differential Revision: https://phabricator.services.mozilla.com/D157564
This does not remove mShouldResistFingerprinting from
WorkerPrivate->mLoadInfo. This is because in between
mLoadInfo getting initialized (including where shouldRFP gets
set) and when the worker's global scope is constructed, we
need to keep track of whether we shouldRFP or not. We could
make this single bool an outparam of GetLoadInfo to later
pass to GetOrCreateGlobalScope, but that seems noisy.
Differential Revision: https://phabricator.services.mozilla.com/D157563
nsGlobalWindowInner, WorkerGlobalScopeBase, BackstagePas and SandboxPrivate now
explicitly provide GetStorageKey implementation which explicitly block null and
expanded principals. All other globals (nsGlobalWindowOuter, SimpleGlobalObject,
ShadowRealmGlobalScope and WorkletGlobalScope) inherit the default
implementation which returns NS_ERROR_NOT_AVAILABLE.
Differential Revision: https://phabricator.services.mozilla.com/D162087
It turns out that websites break with different reasons when hiding things. At this point we want to stop revising the hack further and instead gather the data about how many websites are currently affected.
Differential Revision: https://phabricator.services.mozilla.com/D154578