Commit graph

28 commits

Author SHA1 Message Date
Sam Atkins
e7aad5a9d3 LibWeb: Connect iframe referrerpolicy to ancestorOrigins
Corresponds to:
e161310ae7

This unfortunately isn't testable as we don't implement enough of
ancestorOrigins to be able to observe it.
2026-06-11 14:25:27 +01:00
Andreas Kling
d7f1994606 LibWeb: Keep embedded about:blank canvases on default scheme
Only give initial and empty loaded about:blank documents the implicit
light/dark supported schemes when they belong to a top-level navigable.
Embedded empty documents should not negotiate the page preferred dark
scheme while their embedding element remains light, since that forces an
opaque dark iframe canvas.

Add text coverage for both initial and navigated embedded about:blank
documents under a dark preferred scheme.
2026-05-27 20:57:38 +02:00
Andreas Kling
ab4356edea LibWeb: Let about:blank use dark color schemes
Opt empty about:blank documents into both light and dark supported
color schemes. This covers both navigation-created about:blank documents
and the initial about:blank document created with a browsing context, so
dark mode can choose the dark Canvas color before page content arrives.
2026-05-27 20:57:38 +02:00
Shannon Booth
2ae54d77e0 LibWeb: Reuse initial about:blank window for first same-origin load
Follow the spec reuse of the initial same-origin about:blank window for
a browsing context's first real navigation. This fixes a crash in
promise-job-entry-different-function-realm.html by preserving the
correct iframe realm.

However, reusing the initial about:blank Window means
create-and-initialize can associate that Window with the pending
Document before session history activation has made the Document active.
Treating a browsing context's active document as its active Window's
associated Document therefore exposes the pending Document too early.

To fix this, add an explicit active document slot to BrowsingContext and
update it when a Document is made active.

A similar fix was attempted in 7fc7263a4d,
but that version still queued navigation tasks through the reused active
Window, tagging them with the pending Document before it was active.
This caused parser-created iframe loads to hang in encoding WPTs. This
commit instead queues those navigation-internal tasks against the
navigable's currently active Document.

The newly added iframe-initial-load-chunked-body.html mimics the same
type of failure seen by the WPT regressions mentioned above.
2026-05-22 18:17:58 +02:00
Shannon Booth
3fc455ad70 LibWeb/HTML: Add some spec comments to BrowsingContext 2026-05-08 16:24:54 +02:00
Shannon Booth
04211d5a51 LibWeb: Propogate sandbox flags when creating a new browsing context 2026-04-14 23:01:36 +02:00
Shannon Booth
0086a7899d LibWeb: Remove some uneeded navigation error propogation
We should not have any errors to propogate down these paths.
2026-04-01 04:41:11 +02:00
Sam Atkins
ecbd846272 LibWeb/DOM: Implement DocumentOrShadowRoot.customElementRegistry
Step towards scoped custom element registries.
2026-03-27 19:49:55 +00:00
Niccolo Antonelli Dziri
bed56c676d LibWeb: Use enum instead of bool for CanUseCrossOriginIsolatedAPIs
Change the parameters types of the functions `coarsen_time` and
`coarsened_shared_current_time` from `bool` to
`CanUseCrossOriginIsolatedAPIs` for more coherence with the surrounding
code.
2026-02-13 16:47:42 +00:00
Psychpsyo
864018b3dc LibWeb: Don't lie about browsing context being top-level
The VERIFY() this was triggering wasn't actually to spec, and by the
time it gets encountered, the browsing context isn't technically a top-
level context yet, because it has just been created and the definition
of a top-level browsing context requires the document to be the
navigables active document, which it only becomes once a history entry
has been created for it.

Therefore we cannot just verify a top-level browsing context actually
being a top-level browsing context when inserting it into the group,
because that happens to early in its life-cycle as a top-level context.

This makes it so that JS console commands from the devtools no longer
get sent to the last created nested frame in the tab, because nested
frames no longer pretend to have a top-level browsing context.
2026-02-06 10:52:31 +00:00
Jelle Raaijmakers
a5697b4796 LibWeb: Remove unused fields from BrowsingContext
These were introduced in 83c5ff57d8, but
we stopped using them. No functional changes.
2025-10-01 07:21:54 -04:00
Luke Wilde
40bb50ac60 LibWeb: Parse and propagate the iframe sandbox attribute 2025-08-07 19:24:39 +02:00
Shannon Booth
e0d7278820 LibURL+LibWeb: Make URL::Origin default constructor private
Instead, porting over all users to use the newly created
Origin::create_opaque factory function. This also requires porting
over some users of Origin to avoid default construction.
2025-06-17 20:54:03 +02:00
Shannon Booth
937994cfaa LibWeb: Make Environment's top level origin nullable
This matches the definition in the spec, and is also a step towards
removing the default constructor of URL::Origin.
2025-05-27 14:48:43 +12:00
Shannon Booth
8a3c66d8a6 LibWeb: Make a bunch of CSP classes not realm associated
These are not associated with a javascript realm, so to avoid
confusion about which realm these need to be created in, make
all of these objects a GC::Cell, and deal with the fallout.
2025-04-28 12:41:28 +02:00
Shannon Booth
96f38dc180 LibWeb/HTML: Make environments top level creation URL nullable
This is explicitly set to null for Workers.
2025-04-22 08:44:50 -06:00
Luke Wilde
cae0ab2139 LibWeb: Make PolicyContainer GC allocated
This is required to store Content Security Policies, as their
Directives are implemented as subclasses with overridden virtual
functions. Thus, they cannot be stored as generic Directive classes, as
it'll lose the ability to call overridden functions when they are
copied.
2025-02-21 12:43:48 +00:00
Aliaksandr Kalenik
184ae687c5 LibWeb+WebContent: Remove unused code in BrowsingContext 2025-02-17 19:11:14 -05:00
Shannon Booth
9072a7caef Everywhere: Use URL::about_XXX factory functions 2025-02-15 17:05:55 +00:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Shannon Booth
0fa54c2327 LibURL+LibWeb: Make URL::serialize return a String
Simplifying a bunch of uneeded error handling around the place.
2024-12-04 16:34:13 +00:00
Sam Atkins
90e763de4c LibURL: Replace Host's Empty state with making Url's Host optional
A couple of reasons:
- Origin's Host (when in the tuple state) can't be null
- There's an "empty host" concept in the spec which is NOT the same as a
  null Host, and that was confusing me.
2024-11-30 12:07:39 +01:00
Sam Atkins
310cdc35f0 LibWeb: Fill-in some fixmes around sandboxing flag sets
...Including a couple of steps in
obtain_a_browsing_context_to_use_for_a_navigation_response() which
didn't have FIXMEs.

No apparent changes on WPT.
2024-11-26 10:59:50 +01:00
Nico Weber
ae7ee22aea LibWeb: Don't copy url when calling determine_the_origin() in Navigable
In #1537, determine_the_origin() changed to take
`Optional<URL::URL> const&` as first parameter, but it's passed
`Web::Fetch::Infrastructure::Response::url()`, which returns
`Optional<URL::URL const&>`. Ladybird does not have
SerenityOS/serenity#22870 (yet?), so this mismatch silently creates
a copy.

Change determine_the_origin() to take `Optional<URL::URL const&>`
instead. No behavior change, saves a copy, and is probably what
was originally intended.
2024-11-15 23:19:40 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Shannon Booth
1e54003cb1 LibJS+LibWeb: Rename Heap::allocate_without_realm to Heap::allocate
Now that the heap has no knowledge about a JavaScript realm and is
purely for managing the memory of the heap, it does not make sense
to name this function to say that it is a non-realm variant.
2024-11-13 16:51:44 -05:00
Shannon Booth
9b79a686eb LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>
The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.

As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.
2024-11-13 16:51:44 -05:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp (Browse further)