Commit Graph

2030 Commits

Author SHA1 Message Date
Sandor Molnar
a8db14100e Backed out changeset b858a0740582 (bug 1848694) for causing build bustages on dom/base/Element.cpp CLOSED TREE 2023-09-21 16:45:57 +03:00
Valentin Gosu
e058782d44 Bug 1848694 - Remove/avoid global references to nsIIOService r=mccr8,necko-reviewers,kershaw
This patch removes the static pointer to nsIIOService in nsContentUtils,
replacing it to calls to mozilla::components::IO::Service.

It also makes nsScriptSecurityManager::sIOService a StaticRefPtr.

Differential Revision: https://phabricator.services.mozilla.com/D188714
2023-09-21 12:39:20 +00:00
Olli Pettay
8349e16ebd Bug 1851526 - Don't create the event in nsContentUtils::DispatchChromeEvent if it will not be dispatched, r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D187407
2023-09-05 08:37:33 +00:00
Markus Stange
755a0de1c3 Bug 1851263 - Rename nsIGlobalObject::AsInnerWindow to GetAsInnerWindow because it can return null. r=smaug
This is also the name that was originally suggested in https://bugzilla.mozilla.org/show_bug.cgi?id=218415#c53 .

Differential Revision: https://phabricator.services.mozilla.com/D187340
2023-09-04 04:06:30 +00:00
Markus Stange
325df32372 Bug 1850458 - Pass along aErrorResult to CreateEvent. r=emk
Differential Revision: https://phabricator.services.mozilla.com/D187017
2023-08-29 15:30:15 +00:00
Markus Stange
538be2c237 Bug 1843484 - Don't hold an extra strong reference to the event target. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D186979
2023-08-28 23:38:43 +00:00
Markus Stange
70bd936589 Bug 1843484 - Use EventTarget* instead of nsISupports* for the event target parameter of the nsContentUtils::Dispatch methods. r=smaug
This saves a few queryInterface calls on the hot path.

Differential Revision: https://phabricator.services.mozilla.com/D186976
2023-08-28 23:38:42 +00:00
Emilio Cobos Álvarez
b3eacea949 Bug 1849204 - Add generic atom hash keys that use the better distributed atom hash, and use it across the tree. r=mstange,xpcom-reviewers,credential-management-reviewers,sgalich,nika
Differential Revision: https://phabricator.services.mozilla.com/D186496
2023-08-18 18:43:27 +00:00
Markus Stange
d48eceba22 Bug 1843946 - Make the MiscContainer for eAtomArray refcounted. r=emilio
This makes it cheaper to copy the nsAttrValue, which improves innerHTML times on Speedometer
because it reduces the time spent creating and destroying valueForAfterSetAttr.

It will also make it possible to reuse eAtomArray values across elements.

This patch adds a copying operation in AllocClassMatchingInfo which is needed
now that the MiscContainer's mValue.mAtomArray is immutable. This is a bit
unfortunate: In the past, this was doing one atom array allocation, and now
it's doing two; one during parsing and one during the copy. However, I would
expect that most calls to getElementsByClassName only supply a single class
name and not a set of space-separated class names, but I haven't measured it.
If this copy turns out to make things slower, we can probably avoid it by
adding a way to parse a string into an AtomArray directly without going
through nsAttrValue.

Before: https://share.firefox.dev/3DAhLzm
After: https://share.firefox.dev/456TMTM

Differential Revision: https://phabricator.services.mozilla.com/D183810
2023-08-17 19:02:39 +00:00
Markus Stange
7b93a1e994 Bug 1834370 - Keep listeners for each event type in a separate array, and use binary search on the outer list. r=smaug
This considerably improves the testcase in bug 1834003, because it
reduces the amount of memory we need to look at when checking the
listeners at the nsWindowRoot. At the moment, nsWindowRoot has 156
listeners for 94 different event types, all from JSWindowActor event
listeners.

Having a separate array per event type also matches what Blink and Webkit do.

Differential Revision: https://phabricator.services.mozilla.com/D183431
2023-08-16 16:16:37 +00:00
Olli Pettay
6172d98d49 Bug 1848714 - Use unsafe methods in hot code paths to access and remove elements from nsTArray when it is guaranteed to be safe, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D186191
2023-08-15 14:24:19 +00:00
Masayuki Nakano
33c777c972 Bug 1266437 - Drop "OS" modifier r=smaug,m_kato,karlt,Gijs
On Windows, Windows logo key was mapped to "OS" modifier, and on Linux,
it's same and the key is called "Super" and "Hyper".  That conformed to the
older UI Events spec.

However, UI Events declares that they should be mapped to "Meta" now and Chrome
handles it as the spec in Windows and Linux.  Therefore, we should align the
behavior to them.

Note that we've treated the legacy "Meta" modifier on Linux as DOM "Meta"
modifier state, and we'll keep this as-is because in Sun/Solaris keyboard
layout, they keys are mapped to the legacy "Meta".

Finally, the following check only `IsMeta()` but not `IsOS()`.  I think that
they should've checked `IsOS()` too.  Therefore, they will behave differently
in Windows and Linux.
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/base/Element.cpp#3287-3288
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3762-3764
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3796-3806
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLLabelElement.cpp#127-128
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/widget/gtk/nsGtkKeyUtils.cpp#1461-1462

Note that `KEY_NAME_INDEX_OS` will be removed in the patch for bug 1232918.

Differential Revision: https://phabricator.services.mozilla.com/D183480
2023-08-07 01:03:58 +00:00
Cristian Tuns
02ef83ec78 Backed out 2 changesets (bug 1266437, bug 1232918) for causing mochitest failures in test_autoplay_policy_key_blacklist.html CLOSED TREE
Backed out changeset 33e3c6593d4b (bug 1232918)
Backed out changeset 1b56e99dd221 (bug 1266437)
2023-08-03 23:29:52 -04:00
Masayuki Nakano
861dcd8b88 Bug 1266437 - Drop "OS" modifier r=smaug,m_kato,karlt,Gijs
On Windows, Windows logo key was mapped to "OS" modifier, and on Linux,
it's same and the key is called "Super" and "Hyper".  That conformed to the
older UI Events spec.

However, UI Events declares that they should be mapped to "Meta" now and Chrome
handles it as the spec in Windows and Linux.  Therefore, we should align the
behavior to them.

Note that we've treated the legacy "Meta" modifier on Linux as DOM "Meta"
modifier state, and we'll keep this as-is because in Sun/Solaris keyboard
layout, they keys are mapped to the legacy "Meta".

Finally, the following check only `IsMeta()` but not `IsOS()`.  I think that
they should've checked `IsOS()` too.  Therefore, they will behave differently
in Windows and Linux.
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/base/Element.cpp#3287-3288
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3762-3764
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3796-3806
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLLabelElement.cpp#127-128
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/widget/gtk/nsGtkKeyUtils.cpp#1461-1462

Note that `KEY_NAME_INDEX_OS` will be removed in the patch for bug 1232918.

Differential Revision: https://phabricator.services.mozilla.com/D183480
2023-08-04 00:10:11 +00:00
avandolder
8898fd2eec Bug 1837540 - Make radio button group navigation follow tree-order. r=sefeng,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183426
2023-08-03 01:52:19 +00:00
Narcis Beleuzu
ed85f561c2 Backed out changeset 013278adabc7 (bug 1837540) for build bustages on mochitest.ini . CLOSED TREE 2023-08-03 02:25:53 +03:00
avandolder
9d805ab56a Bug 1837540 - Make radio button group navigation follow tree-order. r=sefeng,smaug
Differential Revision: https://phabricator.services.mozilla.com/D183426
2023-08-02 23:04:07 +00:00
Thomas Wisniewski
1ffb72e885 Bug 1784880 - Support range requests on blob URLs in fetch/XMLHttpRequest; r=dlrobertson,necko-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D184281
2023-08-01 18:50:37 +00:00
Natalia Csoregi
d68a6831c5 Backed out 4 changesets (bug 1834370) for causing failures on pointerevent_mouse-on-object.html and hazard failures on EventListenerManager.cpp. CLOSED TREE
Backed out changeset 0f6ca90bab38 (bug 1834370)
Backed out changeset ad2415f36294 (bug 1834370)
Backed out changeset 2cb41429ffea (bug 1834370)
Backed out changeset 70fea1f92e87 (bug 1834370)
2023-08-01 20:43:07 +03:00
Markus Stange
4e7ef64fea Bug 1834370 - Keep listeners for each event type in a separate array, and use binary search on the outer list. r=smaug
This considerably improves the testcase in bug 1834003, because it
reduces the amount of memory we need to look at when checking the
listeners at the nsWindowRoot. At the moment, nsWindowRoot has 156
listeners for 94 different event types, all from JSWindowActor event
listeners.

Having a separate array per event type also matches what Blink and Webkit do.

Differential Revision: https://phabricator.services.mozilla.com/D183431
2023-08-01 14:53:10 +00:00
Cristian Tuns
8acd1060a3 Backed out changeset 384e4f88f047 (bug 1784880) for causing wpt failures in parsedepth.html CLOSED TREE 2023-08-01 05:41:04 -04:00
Thomas Wisniewski
21f4de34c5 Bug 1784880 - Support range requests on blob URLs in fetch/XMLHttpRequest; r=dlrobertson,necko-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D184281
2023-08-01 02:48:47 +00:00
Iulian Moraru
d6c744aa21 Backed out 4 changesets (bug 1834370) for causing assertion failures on EventListenerManager.cpp. CLOSED TREE
Backed out changeset d279ac4c2c01 (bug 1834370)
Backed out changeset 00077ebdbfe6 (bug 1834370)
Backed out changeset 6a8a7bccbfef (bug 1834370)
Backed out changeset fa5f05b1f6a1 (bug 1834370)
2023-08-01 06:52:42 +03:00
Markus Stange
3d4cd30495 Bug 1834370 - Keep listeners for each event type in a separate array, and use binary search on the outer list. r=smaug
This considerably improves the testcase in bug 1834003, because it
reduces the amount of memory we need to look at when checking the
listeners at the nsWindowRoot. At the moment, nsWindowRoot has 156
listeners for 94 different event types, all from JSWindowActor event
listeners.

Having a separate array per event type also matches what Blink and Webkit do.

Differential Revision: https://phabricator.services.mozilla.com/D183431
2023-07-31 23:43:24 +00:00
Markus Stange
b256017c83 Bug 1845381 - For begin/repeat/end SMIL animation events, only support "beginEvent"/"repeatEvent"/"endEvent" in addEventListener. r=webcompat-reviewers,dholbert,smaug,twisniewski
Before this patch, we would have called listeners added with both
addEventListener("end", ...) and addEventListener("endEvent", ...).
Now we will just call listeners added with the latter and ignore the
former.

This change only affects listeners added with addEventListener.
For attribute handlers and IDL property listeners, we still use
onbegin/onrepeat/onend as before.

The new behavior matches Blink, simplifies the code, and will let us
improve performance by storing event listeners in a map keyed by event
type atom (bug 1834370).

Differential Revision: https://phabricator.services.mozilla.com/D184532
2023-07-31 20:43:47 +00:00
Noemi Erli
4fb434f11a Backed out changeset e104c452e06d (bug 1845381) for causing failures in href-animate-element.html CLOSED TREE 2023-07-27 16:04:18 +03:00
Markus Stange
2bc06fb4ae Bug 1845381 - For begin/repeat/end SMIL animation events, only support "beginEvent"/"repeatEvent"/"endEvent" in addEventListener. r=dholbert,smaug
Before this patch, we would have called listeners added with both
addEventListener("end", ...) and addEventListener("endEvent", ...).
Now we will just call listeners added with the latter and ignore the
former.

This change only affects listeners added with addEventListener.
For attribute handlers and IDL property listeners, we still use
onbegin/onrepeat/onend as before.

The new behavior matches Blink, simplifies the code, and will let us
improve performance by storing event listeners in a map keyed by event
type atom (bug 1834370).

Differential Revision: https://phabricator.services.mozilla.com/D184532
2023-07-27 01:43:21 +00:00
Emilio Cobos Álvarez
7e86fb16c4 Bug 1844872 - Optimize nsContentUtils::IsPDFJS. r=smaug
In the blocked bug, this function shows up. Avoid copying the full URI
spec most cases by doing a faster scheme check first.

Differential Revision: https://phabricator.services.mozilla.com/D184269
2023-07-21 22:19:15 +00:00
Gregory Pappas
7e7f870b3d Bug 1843742 - Remove dom.allow_XUL_XBL_for_file pref r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D183644
2023-07-16 21:35:00 +00:00
Emilio Cobos Álvarez
c05407a221 Bug 1843277 - Remove nsContentUtils::HasPluginWithUncontrolledEventDispatch. r=peterv
Always false.

Differential Revision: https://phabricator.services.mozilla.com/D183495
2023-07-13 14:35:12 +00:00
Tom Ritter
d620a46d9d Bug 1842678: Add a bunch of RFP logging for debugging purposes r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D183202
2023-07-12 13:57:49 +00:00
Tom Ritter
00e525ae7a Bug 1842678: Exempt non-content about: urls r=timhuang
This code path is in the uncommon case, mostly
applicable to service workers I think. Test Coverage
shows it's not hit in our current suite.

Differential Revision: https://phabricator.services.mozilla.com/D183195
2023-07-12 13:57:49 +00:00
Norisz Fay
bf676656ce Backed out 2 changesets (bug 1842678) for causing failures on browser_navigator_iframes.js CLOSED TREE
Backed out changeset 179417d82498 (bug 1842678)
Backed out changeset 29825d05469c (bug 1842678)
2023-07-11 20:54:14 +03:00
Tom Ritter
c272ed508f Bug 1842678: Add a bunch of RFP logging for debugging purposes r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D183202
2023-07-11 15:43:54 +00:00
Tom Ritter
760642cac2 Bug 1842678: Exempt non-content about: urls r=timhuang
This code path is in the uncommon case, mostly
applicable to service workers I think. Test Coverage
shows it's not hit in our current suite.

Differential Revision: https://phabricator.services.mozilla.com/D183195
2023-07-11 15:43:53 +00:00
Tom Ritter
466cf1fa65 Bug 1835099: Check the Partition Key in both flows r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D179107
2023-07-10 15:16:20 +00:00
Dan Robertson
9366764be0 Bug 1733981: Allow single range header values without preflight. r=twisniewski,necko-reviewers,kershaw
The Range header was added as a safe-listed header as long as the value
is in a particular format. Update IsCORSSafelistedRequestHeader
implementations to account for this.

Differential Revision: https://phabricator.services.mozilla.com/D182861
2023-07-10 12:03:29 +00:00
Norisz Fay
9ac3ab923d Backed out changeset 87f35bfe2247 (bug 1733981) for causing failures on general.any.serviceworker.html CLOSED TREE 2023-07-09 16:14:45 +03:00
Dan Robertson
e2f05941e1 Bug 1733981: Allow single range header values without preflight. r=twisniewski,necko-reviewers,kershaw
The Range header was added as a safe-listed header as long as the value
is in a particular format. Update IsCORSSafelistedRequestHeader
implementations to account for this.

Differential Revision: https://phabricator.services.mozilla.com/D182861
2023-07-09 03:00:27 +00:00
Cosmin Sabou
e95c3a2ccb Backed out changeset ee68eebc7bfd (bug 1733981) for causing range related wpt unexpected passes. CLOSED TREE 2023-07-08 17:43:27 +03:00
Dan Robertson
a366c27aa0 Bug 1733981: Allow single range header values without preflight. r=twisniewski,necko-reviewers,kershaw
The Range header was added as a safe-listed header as long as the value
is in a particular format. Update IsCORSSafelistedRequestHeader
implementations to account for this.

Differential Revision: https://phabricator.services.mozilla.com/D182861
2023-07-08 13:07:02 +00:00
Sean Feng
16ad52a74f Bug 1792110 - Update the common ancestor finding logic for mouseup with mousedown r=edgar
The existing function doesn't not work for cases like when mousedown
and mouseup were happened in the same hierarchy but the mousedown target
was a different interactive element than the mouseup target. This
could be easily accomplished by setting `pointer-events: none` or
`display: none` to the `active` pseudo-class of the mousedown target.

This patch fixes this by when the logic tries to find the event target
tree of the mousedown target, it continues building up (by recursively looking
up the parents) the tree instead of stopping at the first interactive element.

Differential Revision: https://phabricator.services.mozilla.com/D178844
2023-07-07 19:08:40 +00:00
Nika Layzell
b783e25bea Bug 1840647 - Part 1: Fix callers of GetWebExposedOriginSerialization in AntiTracking, r=smaug,anti-tracking-reviewers,timhuang
I have done my best to figure out what these specific call-sites
actually want to be using, however I do not understand the AntiTracking
implementation. Please look over these callers somewhat carefully to
make sure this is actually the desired behaviour.

It seems like the majority of these cases are in places where
`OriginNoSuffix` has been mixed up with
`GetWebExposedOriginSerialization`. This makes sense, as these will be
identical strings for the majority of web-exposed URLs. The big
differences between the two are with other URL types, like null
principals.

The logic seems somewhat inconsistent about its handling of origin
attributes, which was also confusing when reading through it. I've tried
to align with the existing code when possible.

Differential Revision: https://phabricator.services.mozilla.com/D182226
2023-07-07 17:08:35 +00:00
Norisz Fay
b6b72da567 Backed out 5 changesets (bug 1792110) for causing ThreadSanitizer related failures CLOSED TREE
Backed out changeset 66ee3cdf67e0 (bug 1792110)
Backed out changeset 510ddee05cfc (bug 1792110)
Backed out changeset c29961741ee1 (bug 1792110)
Backed out changeset 9cfe7f3b3e3e (bug 1792110)
Backed out changeset d492bd7d93d7 (bug 1792110)
2023-07-06 23:02:57 +03:00
Sean Feng
76e3357bf9 Bug 1792110 - Update the common ancestor finding logic for mouseup with mousedown r=edgar
The existing function doesn't not work for cases like when mousedown
and mouseup were happened in the same hierarchy but the mousedown target
was a different interactive element than the mouseup target. This
could be easily accomplished by setting `pointer-events: none` or
`display: none` to the `active` pseudo-class of the mousedown target.

This patch fixes this by when the logic tries to find the event target
tree of the mousedown target, it continues building up (by recursively looking
up the parents) the tree instead of stopping at the first interactive element.

Differential Revision: https://phabricator.services.mozilla.com/D178844
2023-07-06 17:04:51 +00:00
Adam Vandolder
ef3648dda8 Bug 1556358 - Part 3: Restore FACE state in SessionStore. r=edgar,farre
Depends on D174115

Differential Revision: https://phabricator.services.mozilla.com/D179278
2023-06-28 16:28:27 +00:00
avandolder
f102e83b63 Bug 1556358 - Part 2: Save and restore custom element form data. r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D174115
2023-06-28 04:31:22 +00:00
Tom Ritter
c85ef80084 Bug 1825561: Add in the ETP Toggle check to the ShouldRFP callgraph r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D174166
2023-06-28 04:05:59 +00:00
Nika Layzell
30c48eac49 Bug 1839920 - Rename Get{ASCII,UTF}Origin to GetWebExposedOriginSerialization, r=smaug,necko-reviewers,anti-tracking-reviewers,bvandersloot,jesup
This should make uses of the type more clearly indicating where the
origin came from, and should help avoid potential confusion between this
origin and nsIPrincipal::origin in new code.

This new name is long, but explicit. The string returned from this
function corresponds to the "serialization of an origin" from the WHATWG
html spec:
https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin

Differential Revision: https://phabricator.services.mozilla.com/D181794
2023-06-27 19:59:15 +00:00
Tom Ritter
15951df9ce Bug 1830070: Correctly apply RFP Checks to about: documents and deal with pop-ups r=smaug,necko-reviewers,emilio
This patch has three parts to it:

1) Use NS_IsContentAccessibleAboutURI to ensure that only safe
   about: documents get exempted.

   With this change, we will no longer allow about:blank or
   about:srcdoc to be exempted base on URI.  If they are to be
   exempted, it will need to be base on other information.

2) In Document::RecomputeResistFingerprinting we previously
   deferred to a Parent Document if we had one, and either the
   principals matched or we were a null principal.

   We will do the same thing, except we will also defer to our
   opener as well as the parent document.  Now about:blank
   documents can be exempted.

   However, this deferral only works if the opener is
   same-process. For cross-process openers, we make the decision
   ourselves.

We can make the wrong decision though. CookieJarSettings is
inherited through iframes but it is _not_ inherited through popups.
(Yet. There's some discussion there, but it's not implemented.)

Conceptually; however, we do want CJS to inherit, and we do want
RFP to inherit as well.  Because a popup can collude with its
opener to bypass RFP and Storage restrictions, we should propagate
the CJS information.

This does lead to an unusual situation: if you have exempted
b.com, and a.com (which is not exempted) creates a popup for b.com
then that popup will not be exempted.  But an open tab for b.com
would be.  And it might be hard to tell those two apart, or why
they behave differently.

The third part of the patch:

3) In LoadInfo we want to populate information down from the
   opener to the popup.  This is needed because otherwise a
   cross-origin popup will not defer to its opener (because in
   Fission they're in different processes) and will decide if
   it should be exempted itself. It's the CookieJarSettings
   object that prevents the cross-origin document from thinking
   it should be exempted - CJS tells it 'No, you're a child
   (either a subdocument or a popup) and if I say you don't get
   an exemption, you don't.'


Finally, there is one more caveat: we can only defer to a parent
document or opener if it still exists.  A popup may outlive its
opener. If that happens, and something induces a call to
RecomputeResistFingerprinting, then (e.g.) an about:blank popup
may lose an RFP exemption that it had received from its parent.
This isn't expected to happen in practice -
RecomputeResistFingerprinting is only called on document creation
and pref changes I believe.

It is not possible for a popup to _gain_ an exemption though,
because even if the parent document is gone, the CJS lives on and
restricts it.

Differential Revision: https://phabricator.services.mozilla.com/D178866
2023-06-27 03:31:02 +00:00