This makes the relationship between these classes and the dom ScriptLoadHandler clearer. Once we
move to ScriptLoadRequests, these three classes will share a loadhandler class which will take care
of script decoding.
Differential Revision: https://phabricator.services.mozilla.com/D145063
Similar to what was done with the prior patch, this can be described as the companion method to
loading from the network in the LoaderListener, with special requirements in terms of how it populates the loaded request
data and updates the WorkerPrivate. At some point, it may make sense to have the service worker loader as a child class of the
main worker loader, but that won't be done here (I hope anyway).
Differential Revision: https://phabricator.services.mozilla.com/D144838
We don't have a correlation to these methods in the ScriptLoadHandler on the DOM side. For now,
rename them to make the difference clear.
Differential Revision: https://phabricator.services.mozilla.com/D144837
The LoaderListener is currently used to forward events to WorkerScriptLoader. It fills a similar
role to the ScriptLoadHandler on the DOM both for OnStartRequest and OnStreamComplete. In the case
of the DOM loader, the responsibility for performing certain channel related tasks is left to the
ScriptLoadHandler, in particular the decoding of the string into UTF8 or UTF16.
While the decoding is embedded in the onStreamCompleteInternal method, it is not a 1:1 mapping.
Some of the responsibilities handled in the `OnStreamCompleteInternal` method are instead handled in
`ScriptLoader::PrepareLoadedRequest`, such as populating the SourceMaps field, managing the channel,
etc are normally handled within the ScriptLoader.
However, in the case of the WorkerScriptLoader we have two paths to reach a completed load:
* from the network
* from the cache
These have different requirements in terms of preparing the loaded request, for example the cache
does not forward a SourceMap.
In the interest of not complicating things too much, for now the method is moved wholesale into
LoaderListener. In a separate PR I will handle renaming. The next step will be to do a similar move
for the CacheScriptLoader.
Differential Revision: https://phabricator.services.mozilla.com/D144836
This just brings us a bit closer to the DOM pattern of Script Loading. One difference is that we
evaluate a source buffer instead of a JSScript, so rather than "Execute", we will still ahandle data
using "Evaluate". Maybe later we can make these two methods on the SpiderMonkey side a bit more
descriptive. For now this gets us pretty close to the goal of "if you know the DOM script loader, you know the
Worker Script loader" and vice-versa.
Differential Revision: https://phabricator.services.mozilla.com/D145065
This is mostly to bring us in line with the naming of everything else, and also make it clear that
we are crossing a thread boundary.
Differential Revision: https://phabricator.services.mozilla.com/D144990
Continuation of integrating methods from the ScriptExecutorRunnable into the WorkerScriptLoader. In this
case, the primarily function being moved here is the batch evaluation of scripts. This roughly
aligns with the ProcessPendingRequests. The function has been renamed to reflect the similarity of
responsibilities between the two classes.
As a driveby change -- the prerun function now only has one responsibility, and it is related to
loading so this has been moved and named.
Differential Revision: https://phabricator.services.mozilla.com/D144961
Part 1 of integrating the operations that the ScriptExecutorRunnable was doing on the
WorkerScriptLoader into the WorkerScriptLoader itself. This first pass moves some of the smaller,
contained functions over to the WorkerScriptLoader: The shutdown, evaluate and logging methods.
Differential Revision: https://phabricator.services.mozilla.com/D144327
This encompasses the dispatching of the loader runnable as part of the api of WorkerScriptLoader.
The same pattern will be used for the ScriptExecutorRunnable. We might be able to just use an NS
runnable method instead here, if that is preferred.
Differential Revision: https://phabricator.services.mozilla.com/D144991
We are gradually moving closer towards a ScriptLoader implementation based on the DOM ScriptLoader.
The patch is done in three parts:
* WorkerScriptLoader adjustments (WSL Parts 1-6)
* LoaderHandler class adjustments (LoadHandler Parts 1-4)
* Cleanups
The class ScriptLoaderRunnable was being passed between runnables to access information
that was shared. That role will now be done by the WorkerScriptLoader which will eventually inherit
from ScriptLoaderInterface. This is the basis for building up the Module Loader implementation for
workers. This first patch splits the responsibility of the runnable and the data holding class.
In the next few patches, methods from the ScriptExecutorRunnable will also be moved into this class,
and the runnables themselves will no longer hold execution information. Instead, they will be used
as dispatchers to have the work run in the correct place. In the next step, the same pattern will be
done with the ScriptExecutorRunnable.
Differential Revision: https://phabricator.services.mozilla.com/D144326
aLoadInfosAlreadyExecuted is used to track two pieces of state, but we are doing iteration to do
this. Instead, we can track the same state by two booleans: We know all scripts are ready to execute
if we are at the end of the mLoadInfos list. We know that we have failed if we record if any script
fails on mScriptLoader.
Depends on D143621
Differential Revision: https://phabricator.services.mozilla.com/D144276
This removes the pref `security.csp.enable` and amends various callers
in dom/, which no longer have to take this pref into consideration.
Furthermore, we can remove the test in dom/base/test/browser_bug593387.js
The test used the pref to test that external content can be embedded into
about:plugins, which is historic baggage from a previous architecture of
said page that we no longer require. It's also an anti-pattern that we
do not want to support any longer. In fact, the test had to jump through
additional hoops to make that work at all.
Differential Revision: https://phabricator.services.mozilla.com/D138661
#include "mozilla/dom/WorkerScope.h" is removed from WorkerPrivate.h, where calling WorkerPrivate::GlobalScope() without include "WorkerScope.h" makes WorkerScope as an incomplete type.
Depends on 132800
Depends on D132800
Differential Revision: https://phabricator.services.mozilla.com/D133483
#include "mozilla/dom/WorkerScope.h" is removed from WorkerPrivate.h, where calling WorkerPrivate::GlobalScope() without include "WorkerScope.h" makes WorkerScope as an incomplete type.
Depends on 132800
Depends on D132800
Differential Revision: https://phabricator.services.mozilla.com/D133483
When loading the main worker script, we will need to get the clientInfo
for the loading channel. However, the loading channel is created in
content processes and the `IsThirdPartyContextToTopWindow` won't be set
in this case. So, we will get an incorrect clientInfo with a wrong
foreign patitioned principal.
To resolve this, we have to set the flag in the content processes so
that we can get a correct clientInfo. The flag comes from the
workerPrivate which reflects the fact if the worker was created in a
third-party context. And the loading channel should have the same flag
as the document which creates the worker.
Differential Revision: https://phabricator.services.mozilla.com/D129060
When loading the main worker script, we will need to get the clientInfo
for the loading channel. However, the loading channel is created in
content processes and the `IsThirdPartyContextToTopWindow` won't be set
in this case. So, we will get an incorrect clientInfo with a wrong
foreign patitioned principal.
To resolve this, we have to set the flag in the content processes so
that we can get a correct clientInfo. The flag comes from the
workerPrivate which reflects the fact if the worker was created in a
third-party context. And the loading channel should have the same flag
as the document which creates the worker.
Differential Revision: https://phabricator.services.mozilla.com/D129060