Setting mFirstResponseSource in nsHttpChannel::OnStartRequest when cache wins is too late, because the channel might already started redirecting in nsHttpChannel::ReadFromCache. In this case nsHttpChannel::OnStartRequest is not call at all for the cache pump and we would proceed the network response which should be ignored.
Since the uri classifier needs topWindowURI to decide whether or not to enable channel annotation, we have to allow to change this attribute in js for passing the test.
--HG--
extra : rebase_source : c5effa05fecef0d32600e4c9c926dbfa77c2ca6f
This patch includes two changes:
1. The current channel annotation is happened at nsChannelClassifier::OnClassifyComplete and this is too late because this channel might be already hit the network.
This patch adds a new API CheckIsTrackerWithLocalTable in nsChannelClassifier to check if the URI is in local blacklist and whitelist before calling BeginConnectActual.
Please note that whitelist will be checked only when TP is disabled.
2. Skip channel annotation for first-party and top-level load http channels
--HG--
extra : rebase_source : 78f98f8200d3dbb1cb96cd0a33901b2a82227974
This is a preexisting issue that makes nsMultiplexInputStream multiple-inherit
from nsIInputStream: once via nsIMultipartInputStream and once via
nsIAsyncInputStream. This causes problems once we end up with more multiplex
streams that are async streams, because then some assingments to
nsCOMPtr<nsIInputStream> start asserting. This patch just removes the footgun
by getting rid of the multiple inheritance.
The original code creates nsChannelClassifier and calls ShouldEnableTrackingProtection twice when TP is enabled. To avoid redundancy, this patch makes channel classifier as a data member in nsHttpChannel. Note that the data member is a weak ptr to prevent ref count cycle.
--HG--
extra : rebase_source : 11d2e17c2b45b70e3cd407d882ddf0c57ad51755
This patch contains two parts below:
1. mNeckoTarget
Since almost all child channels in necko need mNeckoTarget to dispatch runnables to main thread, it seems worth to have a holder class of mNeckoTarget and ask child channels to inherit it.
2. ChannelEvent
A lot of classes in FTPChannelChild and HttpChannelChild inheriting ChannelEvent and override GetEventTarget. It should be worth to extract the same code and put it in the same space.
Collect telemetry for all requests to get an exact percentage of
requests that are subject to HSTS priming, and how many result in an
HSTS Priming request being sent. Clean up telemetry to remove instances
of double counting requests if a priming request was sent.
HSTSPrimingListener::ReportTiming was using mCallback to calculate
timing telemetry, but we were calling swap() on the nsCOMPtr. Give it an
explicit argument for the callback.
Add tests for telemetry values to all of the HSTS priming tests. This
tests for the minimum as telemetry may be gathered on background or
other requests.
MozReview-Commit-ID: 5V2Nf0Ugc3r
--HG--
extra : rebase_source : daa357219a77d912a78b95a703430f39d884c6ab
The current channel annotation is happened at nsChannelClassifier::OnClassifyComplete and this is too late because this channel might be already hit the network.
This patch adds a new API CheckIsTrackerWithLocalTable in nsChannelClassifier to check if the URI is in local blacklist and whitelist before calling BeginConnectActual.
Please note that whitelist will be checked only when TP is disabled.
--HG--
extra : rebase_source : 0761f6c7631bc934691c8d018be88514568a3aa1
The original code creates nsChannelClassifier and calls ShouldEnableTrackingProtection twice when TP is enabled. To avoid redundancy, this patch makes channel classifier as a data member in nsHttpChannel. Note that the data member is a weak ptr to prevent ref count cycle.
--HG--
extra : rebase_source : 4a77f1e51b38e27a065162cc702091aca2db51de
Also removes some dead code.
A lot of the code in ExtensionUtils.jsm is not needed in all processes, and a
lot of the rest isn't needed until extension code runs. Most of it winds up
being loaded into all processes way earlier than necessary.
MozReview-Commit-ID: CMRjCPOjRF2
--HG--
extra : rebase_source : 37718eaf05a22b8ccb95f633cf7454bd7975cdce
This removes unnecessary COM overhead from the extension protocol service,
particularly from the flag lookup code, which is called often, and from hot
paths. The devirtualized lookups should have virtually no overhead for
extensions without web-accessible resources, and very little overhead except
when resources are specified as non-prefix globs.
MozReview-Commit-ID: 4hQ7GuQSjvW
--HG--
extra : rebase_source : 61897a204abd915ad61852fa475cde2de51753f3
NotifyTrackingProtectionDisabled/NotifyTrackingResource/SetClassifierMatchedInfo updates tracking protection and safe browsing states from parent to child.
They should at least handled by child process before OnStopRequest. Move them to PHttpBackgroundChannel can ensure that.
MozReview-Commit-ID: 8T6k9z9FgrI
--HG--
extra : rebase_source : fd26e2b4309a31e0a9bb16c9236eb4a1875518dc
OnStartRequestSent is used to ensure the execution order between OnStartRequest and all other messsages sent over PBackground.
IPC messages sent before OnStartRequestSent can be processed immediately while received by content process.
IPC messages sent after OnSartRequestSent need to be pending until OnStartRequestReceived is called.
MozReview-Commit-ID: 5Vbb8SBQmW8
--HG--
extra : rebase_source : 81ddce949d2a658e227e1e67d7d4313f7c66513f
PHttpBackgroundChannel is created by content process because PBackground IPDL
can only be initiated from content process. The background channel deletion is
controlled by chrome process while PHttpChannel is going to be closed or canceled.
BackgroundChannelRegistrar is introduced for pairing HttpChannelParent and
HttpBackgroundChannelParent since they are created over different IPDL
asynchronously.
nsIParentRedirectingChannel.continueVerification is introduced to asynchronously
wait for background channel to be established on the new channel during the
Redirect2Verify phase.
MozReview-Commit-ID: 41l8ivan8iA
--HG--
extra : rebase_source : b8b6d7e7c037efaa9fc13df14191205c603e833a
AsyncOpen procedure can failed and trigger FailedAsyncOpen IPC to do the clean up.
However FailedAsyncOpen might not complete if content process is destroyed at the meantime.
We can delay the timing of holding the strong reference to parent listener and channel object
to make sure no reference cycle is created by HttpChannelParent. In addition, clean up the
strong reference as soon as FailedAsyncOpen IPC is triggered.
MozReview-Commit-ID: LDOt0BpBgFe
--HG--
extra : rebase_source : 38e1128e8c361a2422ec4d8292b591ab3b3ef41f
PHttpBackgroundChannel is introduced to deliver OnStopRequest/OnTransportAndData/OnProgress/OnStatus on background thread.
FlushedForDiversion/DivertMessages is moved to PHttpBackgroundChannel to ensure no more channel event are delivered after these two messages on the background channel.
OnStartRequestSent is introduced to synchronize the execution order between OnStartRequest (main thread IPC) and all other messages on PHttpBackgroundChannel.
MozReview-Commit-ID: HfqvPML6EKw
--HG--
extra : rebase_source : 423709763e1abf1362347bc2d3141e2d33aed46a
Avoids a thread-safety race condition on shutdown where we could try to finalize a statement twice.
Allows the async thread to be referenced until ShutdownAsyncThread, so async finalizers can make use of it.
Removes the no more useful mAsyncExecutionThreadIsAlive.
Nullifies the sqlite3_mutex pointer when the connection is closed, since it would be a dangling pointer.
Use a ScopeExit to ensure the connection and the mutex pointers are always nullified on failure.
Makes asyncClose bailout early if a Close method was already invoked before.
Makes AsyncInitDatabase not use AsyncClose to just shutdown the async thread.
Fixes various unfinalized statements in consumers code.
Makes mConnectionClosed better follow mDBConn status.
Replaces some mutex locking isClosed() calls with lockless isConnectionReadyOnThisThread.
MozReview-Commit-ID: 6sftFehsQTt
--HG--
extra : rebase_source : 2bf3088b500376e58e62e8f078d9950588adc649
This patch makes navigator object to return spoofed value for fields have fingerprintable
concerns. This changes the worker navigator as well.
MozReview-Commit-ID: E2SLNZRfuVP
--HG--
extra : rebase_source : 960bafbe41382eba891ad807c37a822ba6a758c8
This patch makes nsHttpHandler to use a spoofed userAgent in the User-Agent header
when 'privacy.resistFingerprinting' is true, the spoofed userAgent string has a
fixed appName, platform and buildID. The only variant in it is the version number,
it will be rounded to the nearest 10(e.g. 40, 50, 60) for reducing fingerprinting
across release versions.
MozReview-Commit-ID: BTGuIJp94U1
--HG--
extra : rebase_source : ab0b6379630c0e962636e624f2caccca6cc9f934
When the last request is removed from the load group, we report telemetry for the default load request. This was done without checking if the request was successful, which may cause us to report telemetry for failed requests as well.
Also, the NullHttpChannel had its timingEnabled attribute set to true, which could lead us to report invalid telemetry
MozReview-Commit-ID: 5w7rd2V17Xd
--HG--
extra : rebase_source : 60785ebc38da8880aa6ded668fed8af81c3d60e9
We write a lot of 4-bytes prefixes to file which call many system calls.
We should use a buffer and only write to file if the buffer is full or
finish writing. nsIBufferedOutputStream is a good candidate to do that
MozReview-Commit-ID: CzGOd7iXVTv
--HG--
extra : rebase_source : 25f1ce804b9a53e0a0a4023a1aa91f1a0ed98547
In order to provide more details context of how client arrived at the unsafe
page, particularly in redirect case, we may have to add more information to
redirect chains including:
- referrer (if any)
- remote address.
- URL
We may want to use an idl interface instead of nsIPrincipal to store these
information
MozReview-Commit-ID: 3Uh4r06w60C
For a long time, opening a resource:// url that leads to a file list has
used a title of the form "Index of jar:file://..." where the
jar:file://... url is the actual location the resource:// url has been
resolved to in the omni.ja.
That same url is used to derive a link to the parent directory. Because
of security context restrictions, the resource://... page can't open a
link to jar:file://... .
So we use the original resource:// url to derive the parent directory
link, and while here, also fix the title.
--HG--
extra : rebase_source : f12ff784c1671f15b83ff082eb7418fcb71f1e10
1. Use ScopeExit to ensure mListener->OnStartRequest() is invoked before exit CallOnStartRequest.
2. Add assertion to ensure OnStartRequest called before OnStopRequest.
MozReview-Commit-ID: FgONlk5HPNz
--HG--
extra : rebase_source : ffe386bc8bea6defb216ecf149a29deacdb3737a
See bug 1365483 for the rationale.
MozReview-Commit-ID: 4sWodnP5MYZ
--HG--
extra : rebase_source : 6a32073e50695ac8f4a540c83f9d2b5542b53585
extra : intermediate-source : 5d7189453d82844d55e3d90c79792b2edd7bdd0d
extra : source : 8b029c32f3512c9d8e92582312459a501594a6e8
This function is arguably nicer than calling NS_ProcessNextEvent
manually, is slightly more efficient, and will enable better auditing
for NS_ProcessNextEvent when we do Quantum DOM scheduling changes.
If HttpChannelChild::Cancel is triggered off main thread while flushing channel event queue,
CompleteResume might be executed while the flush is about to be finished. In this case, queue resumption
will not be able to trigger the second queue flush because the previous one is not finished yet.
Therefore, the HttpChannelChild::Cancel will be sitted in the queue without executing.
MozReview-Commit-ID: GxnkiDUmEnw
--HG--
extra : rebase_source : d04268a04ab24c38bf6fa436526a04f77cd64805
nsAHttpTransaction::Available() obtained a bytecount from the abstract
transaction's input stream. If that stream was derived from a file://
it would create janky IO - so remove the interface.
Http2Push maintains a non-inherited interface which is used to check
the number of bytes it has internally buffered in memory.
MozReview-Commit-ID: IQHt8yGsqDE
--HG--
extra : rebase_source : 64449c6bd743119ea7626a3b2b2b91a376280021
UAOverridesBootstrapper.js is introduced to delay the initialization of
UserAgentOverrides.jsm until the creation of nsHttpHandler in chrome process.
Uninit will be triggered at profile-change-net-teardown because no network
traffice after this point.
MozReview-Commit-ID: F8Lpn6RyZEm
--HG--
extra : rebase_source : b516209f96ec81deb54aab3c038803beb3cea441
system-info might need to be construct while creating nsHttpHandler and it might take up to 30ms.
Lazy loading the DEFAULT_UA can delay the creation of nsHttpHandler after start-up.
MozReview-Commit-ID: FtIpKjcY38r
--HG--
extra : rebase_source : 8061ed3ce6c42955e52f494166958f5b63ab940b
This is also the non-broken way to fix bug 1346392. Instead of waiting
until the auth handler gets its hands on things, we break layering a bit
and inspect the response headers as soon as we decompress them to see if
there's any connection-oriented auth being requested. If there is, we
treat the situation as if we got a RST_STREAM or GOAWAY with
HTTP_1_1_REQUIRED.
We were able to re-purpose the NS_ERROR_ABORT code path that was
previously used with an inappropriate HTTP status code when talking to
an HTTPS proxy over http/2, as that usage was removed a while back from
the stream, though we still had the (dead) code in the session to handle
the stream giving us that return value. The error code was changed to
NS_ERROR_NET_RESET, however, to give a better description of what's
going on.
MozReview-Commit-ID: DLjOIIiXGrV
--HG--
extra : rebase_source : 703fde39432808cabd05b48aa40165e53ebc5ed1
UAOverridesBootstrapper.js is introduced to delay the initialization of
UserAgentOverrides.jsm until the creation of the first nsHttpChannel.
Uninit will be triggered at profile-change-net-teardown because no network
traffice after this point.
MozReview-Commit-ID: F8Lpn6RyZEm
--HG--
extra : rebase_source : 7c3649b50ad8594dc0968961fbbd2766d0d98b0a
system-info might need to be construct while creating nsHttpHandler and it might take up to 30ms.
Lazy loading the DEFAULT_UA can delay the creation of nsHttpHandler after start-up.
MozReview-Commit-ID: FtIpKjcY38r
--HG--
extra : rebase_source : 8061ed3ce6c42955e52f494166958f5b63ab940b
nsAHttpTransaction::Available() obtained a bytecount from the abstract
transaction's input stream. If that stream was derived from a file://
it would create janky IO - so remove the interface.
Http2Push maintains a non-inherited interface which is used to check
the number of bytes it has internally buffered in memory.
MozReview-Commit-ID: IQHt8yGsqDE
--HG--
extra : rebase_source : 78dbd5cae35bc6cb1ce2f03192226cb85564298e
nsAHttpTransaction::Available() obtained a bytecount from the abstract
transaction's input stream. If that stream was derived from a file://
it would create janky IO - so remove the interface.
Http2Push maintains a non-inherited interface which is used to check
the number of bytes it has internally buffered in memory.
MozReview-Commit-ID: IQHt8yGsqDE
--HG--
extra : rebase_source : 6b3b210a8f6736887b5076c90621d678b038bcad
This patch prevents the following error:
AltDataOutputStreamChild::Close -> SendClose()
AltDataOutputStreamChild::Release -> Send__delete__()
AltDataOutputStreamParent::RecvClose() -> SendError()
AltDataOutputStreamParent::ActorDestroy -> mIPCOpen = false
AltDataOutputStreamChild::RecvError -> === Crash - object was deleted ===
We introduce the DeleteSelf message.
AltDataOutputStreamChild::Release -> SendDeleteSelf()
AltDataOutputStreamParent::RecvDeleteSelf -> mIPCOpen = false; SendDeleteSelf()
AltDataOutputStreamChild::RecvDeleteSelf -> Send__delete__()
The parent will not send any more messages after receiving the DeleteSelf message.
MozReview-Commit-ID: I9RQ5I7eSt9
--HG--
extra : rebase_source : 8f918d24595248149ebd3857e05e38dc5237059b
We now have code that unconditionally requires the rust
compiler and are committed to adding more. Remove this
last vestige of conditional support.
MozReview-Commit-ID: EK6FBnAbR
--HG--
extra : rebase_source : 6efda10a74f9ca0482304c2b1ffe6941e42138f8
The channel objects cannot be handed off to other threads before the creation
process has been finished, so there is no point in trying to hold these locks
while the initialization code is running. These lockings have shown up in
profiles as being expensive.
Since the mTargetThread in nsInputStreamPump is directly acquired from current or main thread, we need to pass another labeled main thread target to dispatch runnables to the correct tab/doc group.
Removes references to now unused pref that was added in bug 868441 and removed in bugs 913807 and 1054572. It also removes some leftovers from http channel which have not been removed in those 2 bugs.
There's one redudant NS_ShouldCheckAppCache(nsIURI*, bool) is not used
anymore. Also we remove the extra usePrivateBrowsing argument, since we
can get this information from nsIPrincipal.
The blocking transactions should be dispatched before other transactions. So, this patch aims to put those transactions in front of the pending queue.
Moreover, also give the rest available connections to background tab when processing pendingQ for all entries.
Currently nsBufferedInputStream is able to Fill() data only from sync
inputStream. When a page uses XHR to upload something, it creates a
nsBufferedInputStream around the source inputStream. This stream can be a
IPCBlobInputStream, and in that case, the reading is only supported using
nsIAsyncInputStream interface. nsBufferedInputStream must support it.
// When non empty all non-localhost DNS queries (including IP addresses)
// resolve to this value. The value can be a name or an IP address.
// domains mapped to localhost with localDomains stay localhost.
pref("network.dns.forceResolve", "");
Testing is the primary use case here - replay captive data on a 'fake
server' by directing all traffic to it at the DNS level. Chrome has
something similar.
MozReview-Commit-ID: 7AOgQZpZKec
--HG--
extra : rebase_source : ad2648a701fffecaae47cbfae17e7aa6badd50ee
Some protocol handlers don't handle speculative connections too well
(they crash). So, we limit to the most useful protocols. This patch
brought to you by
https://bugzilla.mozilla.org/show_bug.cgi?id=1348278#c21
MozReview-Commit-ID: 8dWGdVtalIS
--HG--
extra : rebase_source : 9ba674282e40d8313fdb8fbd2f1b9ae7567d299d
mRacingNetAndCache used to be set in TriggerNetwork, when the network was triggered before the cache callbacks had been called, but this could also happen when we bypassed the cache.
MozReview-Commit-ID: 4CklwPVRGar
--HG--
extra : rebase_source : 47a604e25ce879b929dbb2eba7bca36e371845ae
This change makes the code a little cleaner and reduces the number of
places we call PR_GetCurrentThread, which is important for Quantum DOM
scheduling work.
The conversion was largely automatic, via:
find netwerk/ -name \*.cpp | \
xargs sed -i -e 's/MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread[^;]*/MOZ_ASSERT(OnSocketThread(), "not on socket thread")/'
and related invocations, with a few manual tweaks at the end.
Change mozilla::Smprintf and friends to return a UniquePtr, rather than
relying on manual memory management. (Though after this patch there are
still a handful of spots needing SmprintfFree.)
MozReview-Commit-ID: COa4nzIX5qa
--HG--
extra : rebase_source : ab4a11b4d2e758099bd0794d5c25d799a7e42680
nsInputStreamPump should use the stream as nsIAsyncInputStream if available.
In order to do so, we need to wrap a BufferedStream around it.
MediaResource cannot use a simple sync nsIInputStream when BlobURL are involved
in the content process.
Serializing and sending IPC messages takes a lot of time, and it gets in the way of image loading. Making this functionality async gets out of the way of image loading (among other things).
The test has been changed to pump the main thread after calling predictor.learn so the multiprocess version can actually run to completion. This isn't strictly necessary in the single process version, but it makes the code changes (which are already pretty invasive) simpler.
MozReview-Commit-ID: 7jvhomlygbf
--HG--
extra : rebase_source : a779a498f83a2b02d2d634eff63d15f483793046