Commit Graph
113 Commits
Author SHA1 Message Date
agoloman c75e2e420f Revert "Bug 2020707, Bug 2020704 - Part 6: Update test expectations now that speculationrules scripts are supported. r=dom-core-reviewers,jjaschke" for causing bc failures @browser_misused_characters_in_strings.js.
This reverts commit 524a1fc191.

Revert "Bug 2020707 - Part 5: Gate speculation rules script support behind a pref. r=dom-core-reviewers,jjaschke"

This reverts commit 11741d18ad.

Revert "Bug 2020707 - Part 4: Unregister speculation rules when their script element is removed. r=dom-core-reviewers,hsivonen"

This reverts commit 5202943dc9.

Revert "Bug 2020707 - Part 3: Report an exception if speculation rules parsing fails. r=dom-core-reviewers,jjaschke"

This reverts commit 70c5aa5425.

Revert "Bug 2020707 - Part 2: Add support for speculationrules script type. r=dom-core-reviewers,jjaschke"

This reverts commit 65b30a350b.

Revert "Bug 2020707 - Part 1: Allow speculation rules to be registered to the document from scripts. r=hsivonen,jjaschke"

This reverts commit 28c7050de9.

Revert "Bug 2020704 - Part 2: Add parser for speculation rule sets. r=hsivonen,jjaschke"

This reverts commit eabb8c6eb3.

Revert "Bug 2020704 - Part 1: Add speculation rules crate. r=dom-core-reviewers,jjaschke"

This reverts commit cd65bed005.
2026-06-12 06:28:05 +00:00
Adam Vandolder 11741d18ad Bug 2020707 - Part 5: Gate speculation rules script support behind a pref. r=dom-core-reviewers,jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D305775
2026-06-12 04:48:34 +00:00
Adam Vandolder 5202943dc9 Bug 2020707 - Part 4: Unregister speculation rules when their script element is removed. r=dom-core-reviewers,hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D303212
2026-06-12 04:48:32 +00:00
Adam Vandolder 65b30a350b Bug 2020707 - Part 2: Add support for speculationrules script type. r=dom-core-reviewers,jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D286178
2026-06-12 04:48:27 +00:00
Daniel Holbert 648f3a95c5 Bug 2044510: Pass already_AddRefed types by-value instead of by rvalue reference, in dom/html. r=dom-core-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D304360
2026-06-05 21:06:40 +00:00
Sylvestre Ledru d2ee2c8fb9 Bug 2036402 - Apply std::move in dom/html where values can be moved instead of copied r=dom-core,firefox-svg-reviewers,smaug,longsonr
Differential Revision: https://phabricator.services.mozilla.com/D298099
2026-05-04 15:16:20 +00:00
Emilio Cobos Álvarez fe182cca64 Bug 2025271 - Simplify DOMString. r=smaug,nika,extension-reviewers,core-sessionstore-reviewers,dom-worker-reviewers,robwu,asuth
Make DOMString a regular nsAutoTString with some special methods for
performance in some hot getters. For that, we need to change a bit
nsTString:

 * Support for unowned buffers: Owned buffers now are represented by
   STRINGBUFFER|OWNED flags, rather than REFCOUNTED.

 * Inlining of the destructor: It showed up in profiles, it's also just
   a few instructions, so probably worth it. We could OOL the owned path
   I guess, if we wanted to.

 * Inlinling and reordering of NonVoidStringToJsval. Old code had
   special DOMString path inline with [buffer, literal, copy] paths,
   then out of line code with [literal, buffer, copy]. Instead,
   consolidate everything in a [buffer, literal, copy] inline path.
   Do the same for UTF8/Latin1 strings too for consistency.

Differential Revision: https://phabricator.services.mozilla.com/D288148
2026-04-13 09:33:54 +00:00
Emilio Cobos Álvarez 5016086e1a Bug 2025089 - Remove some includes from nsINode.h and Element.h. r=dom-core,dom-storage-reviewers,firefox-svg-reviewers,janv,smaug
Differential Revision: https://phabricator.services.mozilla.com/D289049
2026-03-22 23:45:55 +00:00
Sylvestre Ledru 9eb1a31a98 Bug 2023419 - Remove Emacs/Vim modelines from dom/ r=emilio,media-playback-reviewers,webidl,padenot
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287843
2026-03-16 21:02:32 +00:00
Frédéric Wang d2478ad5f9 Bug 1997818 - Improve parser blocking for ScriptElement::MaybeProcessScript(). r=smaug
When processing a non-trusted inline script, we must run a TrustedTypes
default policy callback on the source text, which in particular may:
- Generally be executed asynchronously in a script runner (thus
  requiring to block the parser in the meantime).
- Modify the script type, for example between classic and module (thus
  changing the expected blocking behavior for the parser).

Currently, ScriptElement::MaybeProcessScript() returns a boolean
telling callers whether they need to block the parser. Most callers
ignore it but for those that don't, the behavior described above make it
impossible to know the correct desired returned value in advance for
non-trusted inline scripts. Current code always always tell callers not
to block the parser, which is incorrect and causing assertion failures.

This patch adds an optional nsIParser argument to MaybeProcessScript(),
which becomes responsible of blocking the parser when needed. For
external and trusted inline scripts we can continue to try and process
the script immediately and use the result to determine whether to block
the parser. Similarly, for non-trusted inline scripts in context where
it is safe to run script, we can run the default policy callback before
the processing attempt and blocking decision.

For non-trusted inline scripts with a default policy callback that need
to be executed in a script runner, we always block the parser while
waiting that script runner to be executed and only decide to unblock it
after the attempt to process the script.

Differential Revision: https://phabricator.services.mozilla.com/D272372
2025-12-08 14:08:33 +00:00
Denis Palmeiro 66b973dc4f Bug 1995614: Use atoms for attributes if available instead of expecting a StringBuffer. r=hsivonen,media-playback-reviewers,firefox-svg-reviewers,karlt,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D271244
2025-11-13 04:18:51 +00:00
serge-sans-paille f61f1d17c2 Bug 1996566 - Remove unused mfbt inclusion in dom/** r=emilio,media-playback-reviewers,dom-storage-reviewers,dom-worker-reviewers,jari,alwu,asuth
Differential Revision: https://phabricator.services.mozilla.com/D270172
2025-10-28 07:24:25 +00:00
Frédéric Wang 1f81a41d25 Bug 1928932 - Part 3 - Transmit proper MutationEffectOnScript to mutation observers. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D253633
2025-09-02 20:04:43 +00:00
Emilio Cobos Álvarez 791917d8af Bug 1976665 - Sort headers in dom/. r=dom-core,media-playback-reviewers,webrtc-reviewers,dom-storage-reviewers,padenot,janv,smaug,jesup,jib
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.

Differential Revision: https://phabricator.services.mozilla.com/D256800
2025-08-05 11:47:34 +00:00
Frédéric Wang 5b2f8ce346 Bug 1972280 - Test whether script's text is non-empty in ScriptElement::MaybeProcessScript. r=smaug
Currently logic is duplicated in HTMLScriptElement and SVGScriptElement's
HasScriptContent() implementations. Rename these methods to only check
hether we have external script content, and move the check for inline
script content directly in ScriptElement::MaybeProcessScript.

Differential Revision: https://phabricator.services.mozilla.com/D253789
2025-06-17 09:36:12 +00:00
Nazım Can Altınova be9cba47b7 Bug 1905855 - Use USVString instead of DOMString for HTMLScriptElement's src attribute r=smaug
Type of src attribute is USVString in the spec:
https://html.spec.whatwg.org/multipage/scripting.html#the-script-element:dom-script-src
And USVString is usually the required type for src and url attributes.

Differential Revision: https://phabricator.services.mozilla.com/D251774
2025-05-30 20:45:44 +00:00
Tom Schuster edaa914b45 Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantString. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D246424
2025-04-30 11:09:07 +00:00
longsonr e69829766c Bug 1847712 - support fetchpriority for SVG image, feImage and script elements r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D246863
2025-04-29 03:35:00 +00:00
Goloman Adrian 8262016029 Backed out changeset 63b702867240 (bug 1847712) for causing wpt failures @ttr-image-fetchpriority.html. CLOSED TREE 2025-04-28 12:41:32 +03:00
longsonr ef3debc812 Bug 1847712 - support fetchpriority for SVG image, feImage and script elements r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D246863
2025-04-28 08:19:38 +00:00
Frédéric Wang fd4d501294 Bug 1944511 Implement remaining Trusted Type support for attribute changes. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D236107
2025-02-14 06:49:12 +00:00
Frédéric Wang 3638510837 Bug 1905706 - Trusted Types support for the src/innerText/textContent/text IDL attributes of HTMLScriptElement. r=smaug
This only does the minimal change to handle trusted types as arguments
of attribute setter/getter. See bug 1928932 for follow-up checks.

Differential Revision: https://phabricator.services.mozilla.com/D227513
2024-11-27 05:06:17 +00:00
Mirko Brodesser 86af414bcd Bug 1914372: part 2) Add TrustedHTML to the interface of Element.innerHTML. r=smaug,peterv,farre
Differential Revision: https://phabricator.services.mozilla.com/D219876
2024-10-16 10:32:37 +00:00
Emilio Cobos Álvarez a44b49af0b Bug 1910698 - Add a struct to represent JS caller location and more general warning source location. r=smaug,necko-reviewers,anti-tracking-reviewers,dom-storage-reviewers,pbz,kershaw,janv
Use it liberally across the tree. This could be cleaned up even more in the future.

Differential Revision: https://phabricator.services.mozilla.com/D218114
2024-08-01 17:12:48 +00:00
Cathie Chen 7859d6112f Bug 1879340 - Add potentially render blocking, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D201095
2024-02-24 18:12:35 +00:00
Cathie Chen d8224880f1 Bug 1878888 - Add the runtime flag and parsing for the blocking attribute, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D200810
2024-02-07 17:06:56 +00:00
Gregory Pappas eb2242368d Bug 1853547 - Remove dom.importMaps.enabled pref r=allstarschh
Differential Revision: https://phabricator.services.mozilla.com/D197751
2024-01-06 01:53:19 +00:00
Mirko Brodesser 2a72b3ab97 Bug 1865610: part 1) Add partial support for the "fetchpriority" attribute for loading style sheets from <link> elements or Link header fields. r=smaug,emilio,valentin
Includes only support for dynamically loading style sheets from `<link>`
elements and `Link` header fields.
The remaining support, including preloading, is completed in part 3.

Differential Revision: https://phabricator.services.mozilla.com/D191745
2023-11-23 14:36:11 +00:00
Tooru Fujisawa 3805c12503 Bug 1864168 - Part 6: Use 1-origin column number in ScriptLoader and nsIScriptElement. r=smaug,devtools-reviewers,hsivonen,ochameau
Also fix opSetScriptLineAndColumnNumberAndFreeze::mColumnNumber to point the
first character of the script source, instead of '>' of the start tag.

Differential Revision: https://phabricator.services.mozilla.com/D193374
2023-11-22 12:31:32 +00:00
Natalia Csoregi e0d56104a6 Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug 1862693) for causing bustage on nsRFPService.cpp. CLOSED TREE
Backed out changeset a4f3e7625abf (bug 1865005)
Backed out changeset ab38141e470b (bug 1862814)
Backed out changeset a679b50dc4a9 (bug 1862814)
Backed out changeset e340886ce62a (bug 1862814)
Backed out changeset 1378502e64b0 (bug 1862814)
Backed out changeset 8ee94e5e79c2 (bug 1862814)
Backed out changeset 6d4ef1cdfabb (bug 1864168)
Backed out changeset 2c30c4d757fc (bug 1864168)
Backed out changeset d4db9576559b (bug 1864168)
Backed out changeset 8ffec0d83028 (bug 1864168)
Backed out changeset fa77d852b494 (bug 1864168)
Backed out changeset f6646771a26a (bug 1864168)
Backed out changeset 7bd0ff6986df (bug 1864155)
Backed out changeset 39867b503289 (bug 1862693)
2023-11-22 14:01:55 +02:00
Tooru Fujisawa 57838ec3d2 Bug 1864168 - Part 6: Use 1-origin column number in ScriptLoader and nsIScriptElement. r=smaug,devtools-reviewers,hsivonen,ochameau
Also fix opSetScriptLineAndColumnNumberAndFreeze::mColumnNumber to point the
first character of the script source, instead of '>' of the start tag.

Differential Revision: https://phabricator.services.mozilla.com/D193374
2023-11-22 11:13:56 +00:00
Mirko Brodesser c9f82f9c46 Bug 1839315: part 6) Lift code for fetchpriority attribute from nsGenericHTMLElementWithFetchPriorityAttribute to nsGenericHTMLElement. r=smaug
As requested in the review of part 1.

Differential Revision: https://phabricator.services.mozilla.com/D191274
2023-10-23 08:14:51 +00:00
Mirko Brodesser 510fb3abb6 Bug 1839315: part 1) Lift code for fetchpriority attribute from HTMLScriptElement to nsGenericHTMLElementWithFetchPriorityAttribute. r=smaug
Since the HTMLLinkElement requires it too, see part 2.

Differential Revision: https://phabricator.services.mozilla.com/D189935
2023-10-23 08:14:49 +00:00
Mirko Brodesser 3de23172d3 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-28 11:56:34 +00:00
Mirko Brodesser ff739cbbd7 Bug 1839316: part 2) Implement getting and setting "fetchpriority" content attribute of <script> element. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D181752
2023-08-28 11:56:33 +00:00
Cosmin Sabou 70b514ed8e Backed out 5 changesets (bug 1839316) for causing bustages on ScriptLoader.cpp. CLOSED TREE
Backed out changeset 85f107e082ee (bug 1839316)
Backed out changeset 8c1e22518c3a (bug 1839316)
Backed out changeset a4c3dec0f34c (bug 1839316)
Backed out changeset 313ff15742dd (bug 1839316)
Backed out changeset fa200e26bbb1 (bug 1839316)
2023-08-09 20:16:06 +03:00
Mirko Brodesser fcb70e3246 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-09 13:50:28 +00:00
Mirko Brodesser 27bbf8ed44 Bug 1839316: part 2) Implement getting and setting "fetchpriority" content attribute of <script> element. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D181752
2023-08-09 13:50:28 +00:00
Cosmin Sabou 1ea8eb8868 Backed out 5 changesets (bug 1839316) for causing leaks. CLOSED TREE
Backed out changeset 75edff380fee (bug 1839316)
Backed out changeset 6a622fd5cd91 (bug 1839316)
Backed out changeset 60908cc7c586 (bug 1839316)
Backed out changeset 7b9dd8875a9e (bug 1839316)
Backed out changeset b586915187c2 (bug 1839316)
2023-08-07 16:43:03 +03:00
Mirko Brodesser e0b84f81a4 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-07 11:46:19 +00:00
Mirko Brodesser 82184f5a89 Bug 1839316: part 2) Implement getting and setting "fetchpriority" content attribute of <script> element. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D181752
2023-08-07 11:46:18 +00:00
Robert Longson 75934e48ba Bug 1839954 - support async defer and module scripts r=emilio
https://www.w3.org/2012/01/05-svg-irc#T21-07-03 says that async and defer should be supported as does the specification https://www.w3.org/TR/SVG2/interact.html#ScriptElement

https://github.com/w3c/svgwg/issues/918 tracks getting the SVGScriptElement webidl updated.

Differential Revision: https://phabricator.services.mozilla.com/D181936
2023-07-06 18:51:54 +00:00
Emilio Cobos Álvarez 529c9ee321 Bug 1839922 - Remove usage of {Has,Get}Attr(kNameSpaceID_None, ..). r=edgar
We have more readable and faster versions (that just omit the namespace
arg).

Mostly done via sed, with a couple helpers to use the faster lookups
where possible.

Differential Revision: https://phabricator.services.mozilla.com/D181795
2023-06-23 10:01:32 +00:00
CanadaHonk 23e171e2af Bug 1834134 - Create base ScriptElement GetScriptType method r=peterv
SVG and HTML ScriptElements now use a new base GetScriptType common
method instead of an individual duplicate implementation.

Make a big (unimportant) meta bug to do more of this later?
(avoids code duplication between SVG and HTML, updates old SVG code).

160 WPT subtests newly pass (100% in this test file) 🎉

Differential Revision: https://phabricator.services.mozilla.com/D180200
2023-06-22 19:42:30 +00:00
CanadaHonk b3b8dd000a Bug 1834110 - Do not run script elements with whitespace type attribute values r=peterv
Fixed running script elements with a type attribute value with whitespace
(like " ").

Fixed by comparing value emptiness before and after trim, if not empty
before and empty after, undo the trim.

2 WPT subtests now newly pass.

WPT tests: https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html

Differential Revision: https://phabricator.services.mozilla.com/D178573
2023-06-02 15:24:14 +00:00
Emilio Cobos Álvarez ded1458b5b Bug 1829189 - Make OnAttrSetButNotChanged and AfterSetAttr infallible. r=smaug
Same rg + sed shenanigans as the first patch.

There were two that could fail, both due to OOM:

 * HTMLInputElement::AfterSetAttr: If we fail (only in the type=range
   case) we end up with an old value without it being clamped by
   min/max/step.

 * HTMLBodyElement::AfterSetAttr: If we fail we won't peek up the
   DocShell's frame margins and styling could be incorrect.

That seems better than having to deal with broken states after we've
already set the attribute.

Depends on D176069

Differential Revision: https://phabricator.services.mozilla.com/D176070
2023-04-21 08:56:27 +00:00
Masayuki Nakano 5dfd7f8719 Bug 1800553 - part 2: Change HTMLAnchorElement::GetText to a const method r=smaug
This needs to change `nsContentUtils` methods because of used by the method.
Then, we can make some there callers are also `const` methods.

Depends on D162065

Differential Revision: https://phabricator.services.mozilla.com/D162066
2022-11-16 00:21:30 +00:00
Yoshi Cheng-Hao Huang 6d98cdb61b Bug 1778289 - Part 12: Update spec links as the PR is merged. r=jonco,yulia
The PR has been merged.
See https://html.spec.whatwg.org/multipage/webappapis.html#import-maps

Differential Revision: https://phabricator.services.mozilla.com/D158828
2022-10-07 13:56:27 +00:00
Yoshi Cheng-Hao Huang 13ecf3a08f Bug 1778289 : Part 8: Update spec for prepare-script when type="importmap". r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D152875
2022-10-07 13:56:25 +00:00
Yoshi Cheng-Hao Huang 31656e9e1f Bug 1688879 - Part 2: Add support for import maps in ScriptElement/ScriptLoader/ScriptKind. r=jonco,yulia,smaug
Differential Revision: https://phabricator.services.mozilla.com/D142070
2022-05-05 21:19:01 +00:00