Commit graph

23401 commits

Author SHA1 Message Date
Linus Groh
3d075e55f5 LibWeb/HTML: Port Window.scrollBy() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
2b6d9cca1a LibWeb/HTML: Port Window.scroll() to IDL
...with various changes required due to ScrollBehavior / ScrollOptions
moving from Element.idl to Window.idl.
2023-03-07 23:33:34 +00:00
Linus Groh
40b4ee88de LibWeb/HTML: Port Window.scroll{X,Y} / Window.page{X,Y}Offset to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
25f53a577d LibWeb/HTML: Port Window.inner{Width,Height} to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
0c691087ca LibWeb/HTML: Port Window.screen to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
2beb99b76e LibWeb/HTML: Port Window.matchMedia() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
198db2ebd9 LibWeb/HTML: Port Window.crypto to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
7de9179a6d LibWeb/HTML: Port Window.performance to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
95ce5735ce LibWeb/HTML: Port Window.event to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
8c0f0726d1 LibWeb/HTML: Include the WindowOrWorkerGlobalScope mixin in Window.idl 2023-03-07 23:33:34 +00:00
Linus Groh
6dd1934ed8 LibWeb/HTML: Port Window.atob() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
192f5e61f6 LibWeb/HTML: Port Window.btoa() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
94f1eff291 LibWeb/HTML: Port Window.isSecureContext to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
188aac5077 LibWeb/HTML: Port Window.origin to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
376fb9ae40 LibWeb/HTML: Hook up WindowOrWorkerGlobalScopeMixin to Window
This prepares us to use the shared implementations from this class.
2023-03-07 23:33:34 +00:00
Linus Groh
b2409517bd LibWeb/HTML: Port Window.open() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
efa48142d2 LibWeb/HTML: Port Window.frameElement to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
c6353ac8cd LibWeb/HTML: Port Window.parent to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
dba8dbe07d LibWeb/HTML: Port Window.top to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
baaf891c64 LibWeb/HTML: Port Window.length to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
c42496187b LibWeb/HTML: Port Window.history to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
eccc0d90de LibWeb/HTML: Port Window.location to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
0e40841990 LibWeb/HTML: Port Window.name to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
0e587420a8 LibWeb/HTML: Port Window.document to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
dcff775ab1 LibWeb/HTML: Port Window.frames to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
437a7c977e LibWeb/HTML: Port Window.self to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
d57876306c LibWeb/HTML: Port Window.window to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
eb2425040b LibWeb/HTML: Port Window.navigator to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
c219e6d9c1 LibWeb/HTML: Port Window.postMessage() to IDL 2023-03-07 23:33:34 +00:00
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
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