Commit graph

333 commits

Author SHA1 Message Date
Tim Huang
d7c54fb41e Bug 1873631 - Part 2: Set the isInThirdPartyContext bit to the loadInfo of the channel for the fetch reqeust in workers. r=bvandersloot,asuth
We propergate the isInThirdPartyContext bit from the workerPrivate to
the fetchDrvier. So, we can set the bit for the channel that loads the
fetch request for workers.

Differential Revision: https://phabricator.services.mozilla.com/D207139
2024-04-22 16:02:51 +00:00
Eden Chuang
2f65cf28ae Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth
WorkerRunnable no longer keeps a raw pointer(mWorkerPrivate) for the associated WorkerPrivate in this patch.
Removing the WorkerRunnable::mWorkerPrivate needs to fix the following problems.

1. Thread assertions in WorkerRunnable::Dispatch()

To fix this problem, the associated WorkerPrivate is as a parameter and passed to WorkerRunnable::Dispatch() for the dispatching thread assertions. This associated WorkerPrivate is also propagated to PreDispatch() and PostDispatch() for the children classes of WorkerRunnable()

2. Get the associated WorkerPrivate in WorkerRunnable::Run() for environment setup(GlobabObject, JSContext setting for the runnable)

- For WorkerThreadRunnable

Since WorkerThreadRunnable is supposed to run on the worker thread, it does not need to keep a raw pointer to WorkerPrivate as its class member. GetCurrentThreadWorkerPrivate() should always get the correct WorkerPrivate for WorkerThreadRunnable.

- For WorkerParentThreadRunnable

WorkerParentRef is introduced to keep a RefPtr<WorkerPrivate> for WorkerParentThreadRunnable instead of using a raw pointer.
Checking the associated WorkerPrivate existence by WorkerParentRef at the beginning of WorkerParentThreadRunnable::Run(). If the Worker has already shut down, WorkerParentThreadRunnable cannot do anything with the associated WorkerPrivate, so WorkerParentThreadRunnable::Run() will return NS_OK directly but with a warning.

The associated WorkerPrivate is also passed into WorkerRun(), PreRun(), and PostRun(), so the majority of implementations of child classes of WorkerRunnable do not need to be changed.

If there are any cases in which the child classes of WorkerThreadRunnable/WorkerParentThreadRunnable want to keep the associated WorkerPrivate, they should use WorkerRefs instead of raw pointers.

Depends on D205679

Differential Revision: https://phabricator.services.mozilla.com/D207039
2024-04-19 09:41:58 +00:00
Emilio Cobos Álvarez
e4ddf24147 Bug 1887719 - More consistently use UTF8String/nsCString for URLs. r=necko-reviewers,webidl,anti-tracking-reviewers,places-reviewers,jari,kershaw,janv,smaug,hsivonen
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
2024-04-04 11:49:57 +00:00
Jens Stutte
a4a855b0e3 Bug 1880233 - Add names to MainThreadWorkerRunnable derived runnables. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D201812
2024-02-14 16:13:24 +00:00
Eden Chuang
5c699915b9 Bug 1873573 - Rename PromiseWorkerProxy::WorkerPromise() to GetWorkerPromise(). r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D199323
2024-01-26 10:48:56 +00:00
Kagami Sascha Rosylight
2f3b882374 Bug 1865728 - Reverse the check order in Fetch::SetBodyUsed r=smaug
nsIInputStream can exist and then may later go away when the stream becomes unreadable (closed/errored). Since FetchStreamReader is created only when nsIInputStream initially did not exist, the current assertion may fail.

This patch now goes LockStream way if FetchStreamReader doesn't exist, regardless of whether nsIInputStream exists or not.

Differential Revision: https://phabricator.services.mozilla.com/D194413
2023-12-01 12:37:03 +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
Eden Chuang
ec09980910 Bug 1837736 - Don't execute WorkerFetchResponseRunnable::WorkerRun when Worker is shutting down r=asuth
This is a case that Worker is shutting down when WorkerFetchResponseRunnable is in queue.

When Worker is getting into "Canceling" all WorkerRefs are notified, then queued WorkerRunnable are executed.
And this causes PromiseWorkerProxy::mWorkerRef be released before the WorkerRunnable execution.
Before Fx 116, there is no this problem since the queued WorkerFetchResponseRunnable is canceled by WorkerPrivate::ClearMainEventQueue() mechanism.

However, WorkerFetchResponseRunnable needs WorkerRef to keep Worker alive for its WorkerRun execution.

Here we just check if WorkerFetchResolver::mWorkerRef is notified or not to judge if the Worker is in "Canceling." Once the Worker is in "Canceling," return true in WorkerFetchResponseRunnable::WorkerRun directly.

We might need a mechanism for PromiseWorkerProxy to notify the proxy owner worker is shutting down for proxy owner has a way to release resources.

Differential Revision: https://phabricator.services.mozilla.com/D183859
2023-07-19 08:09:11 +00:00
Kagami Sascha Rosylight
91db9f6865 Bug 1811882 - Part 4: Use NonAsyncInputToReadableStreamAlgorithms for FetchBody::GetBody() r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D179075
2023-06-06 13:07:46 +00:00
Kagami Sascha Rosylight
794038639b Bug 1811882 - Part 2: Implement ReadableStream::MaybeGetInputStreamIfUnread r=smaug
All existing GetBodyStreamHolder call is consciously done on unread streams, either to simply detect nsIInputStream-based streams or to get the internal nsIInputStream. The function can directly return nsIInputStream to fulfill the existing purposes.

Differential Revision: https://phabricator.services.mozilla.com/D178359
2023-06-06 13:07:46 +00:00
Eden Chuang
f4a08bbee6 Bug 1800659 - P2 remove nsICancelableRunnable inheriting form WorkerRunnable. r=asuth
This patch is only remove the inheriting, but keeping Cancel() implmentation.
The Cancel() is needed in some special cases, such as Worker enters Canceling when WorkerScope is not created.

Depends on D176915

Differential Revision: https://phabricator.services.mozilla.com/D173850
2023-06-06 06:36:50 +00:00
Kagami Sascha Rosylight
b758499f7e Bug 1832326 - Part 2: Remove FetchBody::mReadableStreamReader r=smaug
FetchBody does nothing with the strong reference. Both ReadableStream and FetchStreamReader have their strong references and corresponding cycle collection, so this one can go away.

Depends on D177904

Differential Revision: https://phabricator.services.mozilla.com/D178098
2023-05-16 00:08:01 +00:00
Kagami Sascha Rosylight
3803445d91 Bug 1832333 - Remove unused ErrorResult in GetBodyUsed r=smaug
It was added by bug 1385890 (D8450) to properly interact with JS ReadableStream and is not needed anymore.

Differential Revision: https://phabricator.services.mozilla.com/D177635
2023-05-10 20:11:13 +00:00
Eden Chuang
bf3fa5100a Bug 1819570 - P4 Propagte stack trace notification back to the content process for PFetch. r=asuth
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor watches channels and NetEvents, stack traces are only caught in the content process.
That means PFetch should notify the netmonitor about the stack trace of the fetch at the proper moment.

In original fetch steps, FetchDriver would notify the netmonitor the fetch stack trace at
https://searchfox.org/mozilla-central/rev/cdddec7fd690700efa4d6b48532cf70155e0386b/dom/fetch/FetchDriver.cpp#834

When PFetch is enabled, PFetch needs also to propagate this notification back to the content process.

Depends on D174442

Differential Revision: https://phabricator.services.mozilla.com/D174443
2023-05-05 15:24:10 +00:00
Eden Chuang
f6ba398065 Bug 1819570 - P1 Propagate worker's assocaited BrowsingContextID through PFetch to the parent process. r=asuth
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor also watches the channels in the parent process, the created channel still loses the BrowsingContext information for netmonitor to connect the network event and the channel.

This patch is the first part to propagte the worker's associated BrowsingContextID to the parent process through PFetch.

Differential Revision: https://phabricator.services.mozilla.com/D174249
2023-05-05 15:24:09 +00:00
Iulian Moraru
021d7987c7 Backed out 5 changesets (bug 1819570) for causing dt failures on browser_net_worker_stacks.js. CLOSED TREE
Backed out changeset e73379145f9a (bug 1819570)
Backed out changeset addc41903c2f (bug 1819570)
Backed out changeset c8534cf58f86 (bug 1819570)
Backed out changeset 81e926cf92dc (bug 1819570)
Backed out changeset 7d73ec5415a4 (bug 1819570)
2023-05-04 07:19:13 +03:00
Eden Chuang
c871ac466f Bug 1819570 - P4 Propagte stack trace notification back to the content process for PFetch. r=asuth
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor watches channels and NetEvents, stack traces are only caught in the content process.
That means PFetch should notify the netmonitor about the stack trace of the fetch at the proper moment.

In original fetch steps, FetchDriver would notify the netmonitor the fetch stack trace at
https://searchfox.org/mozilla-central/rev/cdddec7fd690700efa4d6b48532cf70155e0386b/dom/fetch/FetchDriver.cpp#834

When PFetch is enabled, PFetch needs also to propagate this notification back to the content process.

Depends on D174442

Differential Revision: https://phabricator.services.mozilla.com/D174443
2023-05-04 02:46:31 +00:00
Eden Chuang
382c6e8162 Bug 1819570 - P1 Propagate worker's assocaited BrowsingContextID through PFetch to the parent process. r=asuth
After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor also watches the channels in the parent process, the created channel still loses the BrowsingContext information for netmonitor to connect the network event and the channel.

This patch is the first part to propagte the worker's associated BrowsingContextID to the parent process through PFetch.

Differential Revision: https://phabricator.services.mozilla.com/D174249
2023-05-04 02:46:31 +00:00
Kagami Sascha Rosylight
5bcfb4442b Bug 1815431 - Remove BlobBodyStreamHolder r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D169069
2023-02-09 07:01:10 +00:00
Kagami Sascha Rosylight
a3c29544be Bug 1810759 - Replace ReadableStream internal algorithm uses in Fetch r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D167370
2023-01-24 14:52:03 +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
Kagami Sascha Rosylight
ac006ba3c4 Bug 1803386 - Part 1: Replace ReadableStream::mNativeUnderlyingSource with GetBodyStreamHolder() r=smaug
The underlying source algorithms class already has strong ref, so just use it.

Differential Revision: https://phabricator.services.mozilla.com/D166533
2023-01-12 13:43:58 +00:00
sunil mayya
05dc2710d3 Bug 1793736 - Include abort signal reason for fetch. r=necko-reviewers,valentin,tschuster
Differential Revision: https://phabricator.services.mozilla.com/D161669
2022-11-28 10:43:05 +00:00
sunil mayya
6eabd0d3de Bug 1574174 - add immutable guard for fetch response headers. r=edenchuang,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D162209
2022-11-25 12:27:15 +00:00
Butkovits Atila
bf0a7fa012 Backed out changeset 133c9084af25 (bug 1793736) for causing failures at browser_navigationPreload_read_after_respondWith.js. 2022-11-21 19:49:41 +02:00
sunil mayya
6222054cd4 Bug 1793736 - Include abort signal reason for fetch. r=necko-reviewers,valentin,tschuster
Differential Revision: https://phabricator.services.mozilla.com/D161669
2022-11-21 16:56:09 +00:00
Narcis Beleuzu
533f673e9e Backed out 4 changesets (bug 1697421) for e.g. breaking Tampermonkey userscripts (bug 1798149). CLOSED TREE
Backed out changeset 0ec0d4234b77 (bug 1697421)
Backed out changeset b1c8d75d49ef (bug 1697421)
Backed out changeset ca500b60941e (bug 1697421)
Backed out changeset 5979ac92fa24 (bug 1697421)
2022-11-03 17:15:23 +02:00
Eden Chuang
2aa93e45f4 Bug 1658869 - Propagate the InterceptedHttpChannel information to fetch's channel casued by FetchEvent.request. r=dom-worker-reviewers,dragana,jesup
When a network load needs to be intercepted by ServiceWorker, we extract the Request from the InterceptedHttpChannel, and propagate the Request through FetchEvent.request.

However, some needed information is not extracted or is modified during the Request propagation, so getting the wrong result when using the Request to fetch resources in the ServiceWorker script.

Differential Revision: https://phabricator.services.mozilla.com/D145969
2022-09-30 22:39:23 +00:00
sunil mayya
4bf93cb7b9 Bug 1697421 - improve parsing of content-type headers for fetch r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D157115
2022-09-20 11:07:45 +00:00
Iulian Moraru
d8b071ca4d Backed out 3 changesets (bug 1697421) for causing mochitest failures on test_webassembly_compile.html. CLOSED TREE
Backed out changeset 65d4f5822383 (bug 1697421)
Backed out changeset cda8626f9ccc (bug 1697421)
Backed out changeset fe6151585dec (bug 1697421)
2022-09-16 01:19:21 +03:00
sunil mayya
b522b30786 Bug 1697421 - improve parsing of content-type headers for fetch r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D157115
2022-09-15 15:19:13 +00:00
Olli Pettay
2a78f9ffc0 Bug 1775501 - multipart boundary should be handled as mixed case, r=kershaw
Since https://github.com/w3c/FileAPI/issues/43 is still open, it is unclear how body.type should work.
The current wpts expect some behavior which isn't in the specifications.
So, since the situation is very messy in the specifications, the patch is doing a
spot fix for boundary handling. It is ugly, but shouldn't change other behavior.

Differential Revision: https://phabricator.services.mozilla.com/D150018
2022-07-11 09:18:32 +00:00
Matthew Gaudet
d07e459e7b Bug 1757241 - Remove !MOZ_DOM_STREAMS code from most files r=smaug
I've also tested to verify that JS Streams remains enabled in the JS Shell package

Differential Revision: https://phabricator.services.mozilla.com/D142620
2022-04-13 18:57:48 +00:00
Yury Delendik
240524d49f Bug 1757999 - Disable fetch HTTP wasm caching if wasm debug enabled. r=necko-reviewers,lth,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140401
2022-03-09 21:49:52 +00:00
Bryan Thrall
44b065fd5a Bug 1734174 - Remove unneeded JSContext parameter from AcquireReadableStreamDefaultReader() r=mgaudet
Depends on D139871

Differential Revision: https://phabricator.services.mozilla.com/D139872
2022-02-28 22:31:41 +00:00
Kagami Sascha Rosylight
d91c23ad97 Bug 1756070 - Part 1: Add missing override keywords r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D139166
2022-02-21 13:50:12 +00:00
Eden Chuang
2266b31d41 Bug 1744025 - Replace include "mozilla/dom/WorkerPrivate.h" with include "mozilla/dom/WorkerScope.h" where WorkerPrivate->GlobalScope() is called. r=dom-worker-reviewers,smaug,jstutte
#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
2022-01-25 08:53:03 +00:00
Eden Chuang
128ff19446 Bug 1744025: Remove only assertion-relevant mWorkerPrivate from FetchBody. r=dom-worker-reviewers,edenchuang
Depends on D132711

Differential Revision: https://phabricator.services.mozilla.com/D132795
2022-01-25 08:53:01 +00:00
Kagami Sascha Rosylight
67e19158c2 Bug 1751453 - Part 2: Remove WorkerSignalFollower r=smaug
I originally intended to remove the cycle collection only, but then I found that there's zero use of this class.

Differential Revision: https://phabricator.services.mozilla.com/D136659
2022-01-24 13:18:34 +00:00
Kagami Sascha Rosylight
19504fbdf1 Bug 1751453 - Part 1: Remove AbortFollower::Unlink() r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D136658
2022-01-24 13:18:33 +00:00
Kagami Sascha Rosylight
9d024af1cc Bug 1660555 - Make AbortFollower::mFollowingSignal a WeakPtr r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D136446
2022-01-21 14:40:38 +00:00
Kagami Sascha Rosylight
cd40833835 Bug 1750543 - Don't abort by signal if consuming request body by DOM methods r=smaug
There are two cases when reading request body by DOM methods:

1. It's being read before fetch()
2. or after fetch()

The first case shouldn't be affected by abort signal per the spec, since the abort step is added only within fetch().

https://fetch.spec.whatwg.org/#ref-for-abortsignal-add

The second case should still fail but with `TypeError: Body has already been consumed`, not AbortError.

Differential Revision: https://phabricator.services.mozilla.com/D136262
2022-01-21 11:18:17 +00:00