Commit graph

47821 commits

Author SHA1 Message Date
Linus Groh eb4842dfa1 LibWeb/HTML: Port Window.prompt() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh bbffda5f55 LibWeb/HTML: Port Window.confirm() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh a0b73eb5f7 LibWeb/HTML: Port Window.alert() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh a6f8b18649 LibWeb/HTML: Define Window's {Global,Window}EventHandlers via IDL 2023-03-07 23:33:34 +00:00
Linus Groh c130fd6993 LibWeb: Start generating code for the Window object from IDL :^) 2023-03-07 23:33:34 +00:00
Linus Groh e13f89c9eb LibWeb: Generate setter for [Replaceable] IDL attributes
The code is directly stolen from the REPLACEABLE_PROPERTY_SETTER() macro
which will hopefully be removed soon.
2023-03-07 23:33:34 +00:00
Linus Groh 3316d247bf LibWeb: Support interfaces with the [Global] extended attribute
These are treated differently as the interface members are placed on the
object itself, not its prototype.
As the object itself still needs to be hand-written code, and we can no
longer fully hide the gnarly generated code in the prototype object,
these now generate a 'mixin' class that is added to the actual object
through inheritance.

https://webidl.spec.whatwg.org/#Global
2023-03-07 23:33:34 +00:00
Linus Groh de83f5422d LibWeb: Generate Window{Constructor,Prototype} from IDL
The Window object is massive, so let's do the conversion to IDL step
by step. First up: getting rid of the manual constructor and prototype
definitions, which can be generated from an empty `interface Window`.
2023-03-07 23:33:34 +00:00
Luke Wilde cdc77407bf LibWeb: Make WindowOrWorkerGlobalScope#atob use forgiving base64 decode
This was forgotten to be changed when Window's atob was updated to use
forgiving base64 decode.
2023-03-07 18:45:12 +00:00
Luke Wilde b91b67f4f3 LibWeb/Fetch: Actually check if the response is null in recursive fetch
The condition for checking if there was already a response in recursive
fetch was accidentally flipped, always causing a null deref.

This made redirects crash for example.
2023-03-07 18:42:10 +00:00
Timothy Flynn 0524bc1d13 WebContent+WebDriver: Ensure Get Window Handle checks for closed BCs 2023-03-07 18:16:35 +00:00
Timothy Flynn 010be9b7c2 WebDriver: Do not throw an error when closing an inactive session
The spec states to only try to close the session *if* it exists. This
situation can occur when closing a session after a Close Window command,
as the session will be closed automatically if it was the last window.
2023-03-07 18:16:35 +00:00
Timothy Flynn 12015a4db6 WebDriver: Remove active sessions from the close-the-session AO
These steps now have more than one caller; specifically, they may be
called from the Delete Session and Close Window endpoints. The session
was only removed from the active session map for the former endpoint.

Instead, let's more accurately handle removing the session where the
spec tells us to, so that all callers properly perform this step.
2023-03-07 18:16:35 +00:00
Timothy Flynn a0992c7731 WebDriver: Reference-count WebDriver Session objects
When some WebDriver spec steps are implemented a bit more literally, we
will end up in a situation where we remove a session from its client's
active session map, but still have more steps to perform. Currently,
when we remove the session, it is immediately destroyed because it is
stored in an OwnPtr. Instead, we can store it as a RefPtr, which will
let the caller to such steps keep the session alive until the subsequent
steps are complete.

While here, this also changes the storage of active sessions to a
HashMap, as all lookups into it are currently a linear search.
2023-03-07 18:16:35 +00:00
Timothy Flynn 7be8931ca0 WebDriver: Defer removing closed window handles until no longer needed
WebDriver::Session::close_window may invoke Session::stop, which needs
the WebContent connection to still exist. Do not remove the window's
handle (thus destroying the connection) until it is no longer needed.
2023-03-07 18:16:35 +00:00
Timothy Flynn ae1611aa08 LibWeb: Mark Web::WebDriver::Response as [[nodiscard]] 2023-03-07 18:16:35 +00:00
Timothy Flynn 0ae015e266 WebDriver: Do not ignore the result of closing a session 2023-03-07 18:16:35 +00:00
Aliaksandr Kalenik 5c117cdcec WebDriver: Keep WebDriver socket listening until session end
WebDriver socket should not be closed as soon as first client
got connected becaused there might more than one WebContent
process spawned by browser.
2023-03-07 07:16:23 -05:00
Aliaksandr Kalenik 0905fd57e4 WebContent+WebDriver: Move window commands handling back to WebDriver
With current architecture every window has its own WebContent process
and there is one WebDriver process that is responsible for talking to
all opened windows. It thus make sense to manage open windows from
WebDriver process instead of WebContent process that is not supposed
to know about all other opened WebContent processes.

This mostly reverts 826d5f8f9a but also
adds `web_content_connection` to window structure and window id
generation (currently out of spec).

With these changes `get_window_handles`, `switch_to_window` and
`close_window` start to actually switch, close and returned handles
of currently opened windows.
2023-03-07 07:16:23 -05:00
Luke Wilde d036862f2b LibWeb: Refactor XHR (almost) exactly to the spec
This makes XHR now rely on Fetch, which allows it to correct send
Origin and Referer headers, CORS-preflight and filtering and many other
goodies.

The main thing that's missing is Streams, which means we can't properly
produce progress events or switch to the Loading ready state.

This also doesn't implement the Document responseType just yet.
2023-03-07 11:51:12 +00:00
Luke Wilde 90cc45b7ec LibWeb: Convert Platform::Timer to JS::SafeFunction 2023-03-07 11:51:12 +00:00
Luke Wilde 4bc0d8e4c8 LibJS: Fix compilation of operator= for JS::SafeFunction
operator= for JS::SafeFunction was missing the CallableKind parameter
in the call to init_with_callable. This was not picked up before as
nothing used operator= on JS::SafeFunction.
2023-03-07 11:51:12 +00:00
Luke Wilde 80fad65e5b LibWeb: Add function to EventTarget that says if it has any listeners
Required by XHR to determine if it should use CORS-preflight if its
upload object has any event listeners.
2023-03-07 11:51:12 +00:00
Luke Wilde acd5382924 LibWeb/Fetch: Set length synchronously in extract_body
Since we don't currently have streams, we didn't set length anywhere.
However, this is required by XHR's reliance on Fetch to get the total
number of bytes for the progress events.
2023-03-07 11:51:12 +00:00
Luke Wilde e557602d34 LibWeb: Fully read body if there is one in fetch response handover
Required by XHR's reliance on Fetch.
2023-03-07 11:51:12 +00:00
Luke Wilde cfbd0bbe0a LibWeb/Fetch: Implement Header's "extract a length" function
Required by XHR's reliance on Fetch.
2023-03-07 11:51:12 +00:00
Luke Wilde ccdb1bcc4e LibWeb/Fetch: Implement Body's "fully read" function from the spec
Required by XHR's reliance on Fetch.
2023-03-07 11:51:12 +00:00
Luke Wilde 9aca54091a LibWeb: Remove the dummy execution context 2023-03-07 11:51:12 +00:00
Luke Wilde a1f7186153 LibWeb: Make BC::set_system_visibility_state use the active doc's global
Using main_thread_vm().current_realm() will rely on the dummy execution
context if the visibility state changes when no JavaScript is running.
2023-03-07 11:51:12 +00:00
Luke Wilde 9acc542059 LibWeb: Propagate Realm instead of VM more through Fetch
This makes Fetch rely less on using main_thread_vm().current_realm(),
which relies on the dummy execution context if no JavaScript is
currently running.
2023-03-07 11:51:12 +00:00
Luke Wilde f7ff1fd985 LibWeb: Remove CSS::Parser::ParsingContext's default constructor
This relied on pulling the current realm from the main thread VM, which
requires an execution context to be on the VM's stack. This heavily
relied on the dummy execution context that is always on the stack, for
example, when parsing the UA style sheets where no JavaScript is
running.
2023-03-07 11:51:12 +00:00
Aliaksandr Kalenik 54a1ec2f10 Browser: Handle close event in WebContentView 2023-03-07 11:34:11 +00:00
Aliaksandr Kalenik 59752807c4 Ladybird: Handle close event in WebContentView 2023-03-07 11:34:11 +00:00
Aliaksandr Kalenik cc41233be4 LibWebView+WebContent: Propagate close from WebContent to LibWebView 2023-03-07 11:34:11 +00:00
Mathis Wiehl f276e70ac9 Help: Don't defer tree view selection updates
It is unsafe to defer this selection update, because ::open_url itself
is called when users make selection updates, creating a race.

This fixes and infinite selection change loop one could easily reproduce
by holding an up or down arrow key in the tree view while clicking on a
tree view item a couple of times.
2023-03-07 09:50:50 +01:00
Andreas Kling 4797fad91c Shell: Fix bogus C-style casts from NonnullOwnPtr<T>* to T*
Thanks UBSAN for spotting this!
2023-03-07 09:42:20 +01:00
Linus Groh 2258fc273c LibWeb/HighResolutionTime: Add IDL typedef for DOMHighResTimeStamp
We already have this for C++ code in DOMHighResTimeStamp.h, but let's
also avoid using plain 'double' in IDL code.
2023-03-06 23:57:25 +00:00
Sam Atkins ca30914fe9 LibWeb: Propagate errors from CSS Parser construction
This requires Parser to be movable, so we remove the `default`
destructors from Parser and TokenStream, and give them both move
constructors. Since TokenStream only holds a reference to its tokens,
(and it needs to, to avoid copying when given eg a function's contents,)
we add a manual move constructor for Parser which creates a new
TokenStream from the new Parser's tokens, and then manually copies the
old TokenStream's state.
2023-03-07 00:43:36 +01:00
Sam Atkins 235018046e LibWeb: Use free functions for parsing in @Supports 2023-03-07 00:43:36 +01:00
Sam Atkins 84af8dd9ed LibWeb: Propagate errors from CSS Tokenizer 2023-03-07 00:43:36 +01:00
Sam Atkins 17618989a3 LibWeb: Propagate errors from CSS Tokenizer construction
Instead of constructing a Tokenizer and then calling parse() on it, we
now call `Tokenizer::tokenize(...)` directly. (Renamed from `parse()`
because this is a Tokenizer, not a Parser.)
2023-03-07 00:43:36 +01:00
Mathis Wiehl 98ee2fcd1b man: Skip shellrc when invoking pager using sh
man invokes the pager command via `sh` which, since
beaae6b420 launches `Shell` in posix mode.
As the referenced commits message indicates, launching `Shell` in posix
mode while interactive, makes it choke on the default `.shellrc`. This
made `man` spew out some shell syntax errors to stderr every time it
invoked the pager.

To fix that, invoke `sh` with `--skip-shellrc` for now as suggested by
the aforementioned commit.
2023-03-07 00:42:32 +01:00
Andreas Kling d1371d66f7 Kernel: Use non-locking {Nonnull,}RefPtr for OpenFileDescription
This patch switches away from {Nonnull,}LockRefPtr to the non-locking
smart pointers throughout the kernel.

I've looked at the handful of places where these were being persisted
and I don't see any race situations.

Note that the process file descriptor table (Process::m_fds) was already
guarded via MutexProtected.
2023-03-07 00:30:12 +01:00
Andreas Kling 36b0ecfe9e Kernel: Remove two outdated FIXMEs about the file descriptor table mutex
These functions cannot be called without already holding the relevant
mutex these days, since m_fds is a MutexProtected object. :^)
2023-03-06 23:46:36 +01:00
Andreas Kling 5aa12da959 AK+Kernel: Remove all the Nonnull*PtrVector classes 2023-03-06 23:46:36 +01:00
Andreas Kling be91020d0b Settings: Remove outdated comment about NonnullPtrVector 2023-03-06 23:46:36 +01:00
Andreas Kling 2973298df1 Assistant: Remove outdated comment about NonnullPtrVector 2023-03-06 23:46:36 +01:00
Andreas Kling b4022dc844 Screensaver: Remove outdated comment about NonnullPtrVector 2023-03-06 23:46:36 +01:00
Andreas Kling f484952167 LibCpp: Remove Nonnull*PtrVector from list of known SerenityOS types 2023-03-06 23:46:36 +01:00
Andreas Kling d57b09b7cf AK: Remove specialized shuffle for NonnullPtrVector 2023-03-06 23:46:36 +01:00