summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Loader
AgeCommit message (Collapse)Author
2022-03-21LibWeb: Ignore invalid encodings in Content-Type headersSimon Wanner
2022-03-20LibWeb: Tweak our User-Agent stringAndreas Kling
- Switch from "Mozilla/4.0" to "Mozilla/5.0" to match other browsers. - Remove references to KHTML and Gecko. - Identify ourselves as "LibWeb+LibJS/1.0 Browser/1.0" New UA: "Mozilla/5.0 (SerenityOS; x86_64) LibWeb+LibJS/1.0 Browser/1.0"
2022-03-20LibWeb: Always defer callbacks in ResourceClient::set_resource()Andreas Kling
Previously, we'd invoke the load/fail callbacks synchronously for resources that were already loaded and cached. This patch uses deferred_invoke() in the already-loaded case to ensure that we always invoke these callbacks in a consistent manner. This isn't to fix a specific issue, but rather because I kept seeing these callbacks being invoked synchronously on top of an already-tall call stack, and it was hard to reason about what was going on.
2022-03-17Libraries: Use default constructors/destructors in LibWebLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-09LibWeb: Fail resource loads on HTTP 4xx or 5xx errorAndreas Kling
This fixes an issue on ACID3 where failing image loads with body content would still get displayed.
2022-02-26LibWeb: Check for valid names in Document.createElement() & friendsAndreas Kling
We now validate that the provided tag names are valid XML tag names, and otherwise throw an "invalid character" DOM exception. 2% progression on ACID3. :^)
2022-02-21LibWeb: Make document.write() work while document is parsingAndreas Kling
This necessitated making HTMLParser ref-counted, and having it register itself with Document when created. That makes it possible for scripts to add new input at the current parser insertion point. There is now a reference cycle between Document and HTMLParser. This cycle is explicitly broken by calling Document::detach_parser() at the end of HTMLParser::run(). This is a huge progression on ACID3, from 31% to 49%! :^)
2022-02-18LibWeb: Send appropriate Accept header for FrameLoader requestsLuke Wilde
According to Fetch, we must send an Accept header with the value "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" for document, iframe and frame requests. https://fetch.spec.whatwg.org/#concept-fetch Required by uber.com.
2022-02-16LibWeb: Follow HTTP 3xx redirections when loading imagesAndreas Kling
This basically copies some logic from FrameLoader to ImageLoader. Ideally we'd share this code, but for now let's just get redirected images to show up. :^)
2022-02-12LibWeb: Set response header cookies on redirectsIdan Horowitz
Since we were previously relying on Document::set_cookie in order to set cookies received as a 'Set-Cookie' response header, we would ignore any response header cookies in redirect (status code 3xx) responses. While this behaviour is not strictly enforced in the specification, most major browsers do set cookies in redirect responses, and some sites (e.g. Cookie Clicker) rely on this behaviour. Since cookies are stored per-site and not per-document, this behaviour is achieved by simply decoupling the cookie set mechanism from it.
2022-02-12LibWeb: Ignore Location headers unless the response status code is 3xxIdan Horowitz
As per RFC7231 the Location header field has different meanings for different response status codes: For 201 (Created) responses, the Location value refers to the primary resource created by the request. For 3xx (Redirection) responses, the Location value refers to the preferred target resource for automatically redirecting the request.
2022-02-04LibWeb: Make debug logging of resource load errors red instead of greenAndreas Kling
Red is a bit more suspicious than green, after all. :^)
2022-01-31Everywhere: Update copyrights with my new serenityos.org e-mail :^)Timothy Flynn
2022-01-28Userland: Fix unnecessary heap allocation of singleton objectsDaniel Bertalan
In order to avoid having multiple instances, we were keeping a pointer to these singleton objects and only allocating them when it was null. We have `__cxa_guard_{acquire,release}` in the userland, so there's no need to do this dance, as the compiler will ensure that the constructors are only called once.
2022-01-24AK+Userland: Make AK::decode_base64 return ErrorOrSam Atkins
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2022-01-12Base+Browser: Add Browser iconselectrikmilk
Add some missing icons to the brower.
2021-12-21LibWeb: Add a workaround to assign a proper mime type to QOI imagesLinus Groh
2021-12-04LibWeb: Stop sending "load" event twice to iframesAndreas Kling
The "completely finish loading" algorithm (from the HTML spec) is responsible for sending a "load" event to nested browsing context containers (iframes). This patch removes the old mechanism for sending "load" events, which we had mistakenly kept around, causing two events to be sent instead of one. :^)
2021-11-20LibWeb: Use the sandboxed image ImageDecoder when loading faviconsAndreas Kling
2021-11-20LibWeb: Use the sandboxed ImageDecoder when creating image documentsAndreas Kling
An image document is the synthetic DOM::Document we create to wrap an image when you open the URL of an image directly in a web view. The path that creates these documents will now also call out to the separate ImageDecoder process for the actual decoding work.
2021-11-20LibWeb: Move ImageDecoder client connection singleton to its own fileAndreas Kling
This will allow us to use it in more places around LibWeb.
2021-11-19LibWeb+LibHTTP: Support multiple Set-Cookie response headersTheFightingCatfish
2021-11-18LibWeb: Move BrowsingContext into HTML/Andreas Kling
Browsing contexts are defined by the HTML specification, so let's move them into the HTML directory. :^)
2021-11-18LibWeb: Delete CSSLoaderSam Atkins
All CSS loading is now done by the relevant classes: - CSSImportRule, which loads its linked stylesheet - HTMLStyleElement, which "loads" its contents - HTMLLinkElement, which loads its linked stylesheet
2021-11-18LibWeb: Remove redundant `@import`-handling code from CSSLoaderSam Atkins
Now that `@import` rules load themselves, we don't want to also load them here.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-08LibCore: Use ErrorOr<T> for Core::File::open()Andreas Kling
2021-11-08LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()Andreas Kling
This was used in a lot of places, so this patch makes liberal use of ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-10-23AK+Everywhere: Make Base64 decoding fallibleBen Wiederhake
2021-10-06LibWeb: Resolve cyclic dependency between StyleSheet and ImportRuleBen Wiederhake
Previously: CSSImportRule::loaded_style_sheet() (and others) depend on the definition of class CSSStyleSheet. Meanwhile, CSSStyleSheet::template for_each_effective_style_rule (and others) depend on the definition of class CSSImportRule. This hasn't caused any problems so far because CSSStyleSheet.h happened to be always included after CSSImportRule.h (in part due to alphabetical ordering). However, a compilation unit that (for example) only contains #include <Userland/Libraries/LibWeb/CSSImportRule.h> would fail to compile. This patch resolves this issue by pushing the inline definition of Web::CSS::CSSStyleSheet::for_each_effective_style_rule and for_first_not_loaded_import_rule into a different file, and adding the missing headers.
2021-09-29LibWeb: Make CSSRule and CSSRuleList available to JavaScript :^)Andreas Kling
This patch makes both of these classes inherit from RefCounted and Bindings::Wrappable, plus some minimal rejigging to allow us to keep using them internally while also exposing them to web content.
2021-09-28LibWeb: Implement the dns-prefetch and preconnect link relationshipsAli Mohammad Pur
2021-09-27LibWeb: Don't try to ad-block data: urlsSam Atkins
In some cases these can be several KiB or more in size, making checking very slow, and it doesn't make sense to filter them out anyway. This change speeds up loading pages with large data: urls, which previously took up to 1ms per byte to process.
2021-09-26LibWeb: Make <link> style sheets delay the document load eventAndreas Kling
2021-09-25LibWeb: Rename HTMLDocumentParser => HTMLParserAndreas Kling
2021-09-24LibWeb: Skip decoding favicon.ico if downloaded data is emptyMandar Kulkarni
Some sites don't have favicon.ico, so we may get 404 response. In such cases, ResourceLoader still calls success_callback. For favicon loading, we are not checking response headers or payload size. This will ultimately fail in Gfx::ImageDecoder::try_create(). So avoid unnecessary work by returning early, if data is empty.
2021-09-22LibWeb: Log resource load success before invoking success callbackAndreas Kling
The success callback may trigger JavaScript execution, causing resource load times to appear much longer than they actually are. :^)
2021-09-19LibWeb: Avoid introducing a reference cycle in ResourceLoader::load()Ali Mohammad Pur
Previously we were kinda sorta resolving the reference cycle, but let's just keep the requests in a hashtable instead of relying on hard to track refcount tricks. Fixes #7314.
2021-09-16LibWeb: Don't dump full data URLs in ResourceLoader loggingAndreas Kling
Some pages use *really* large data URLs. :^)
2021-09-14AK: Make URL::m_port an Optional<u16>, Expose raw port getterIdan Horowitz
Our current way of signalling a missing port with m_port == 0 was lacking, as 0 is a valid port number in URLs.
2021-09-13LibWeb: Add the Web::URL namespace and move URLEncoder to itIdan Horowitz
This namespace will be used for all interfaces defined in the URL specification, like URL and URLSearchParams. This has the unfortunate side-effect of requiring us to use the fully qualified AK::URL name whenever we want to refer to the AK class, so this commit also fixes all such references.
2021-09-12LibWeb: Log resource loading success, failure, and durationBrian Gianforcaro
When debugging why your website isn't loading in LibWeb the resource loader is a blind spot as we don't have much logging except on certain error paths. This can lead to confusing situations where the browser just appears to hang. This changes attempts to fix that by adding common success and failure logging handlers so all resource loading outcomes can are logged.
2021-09-12LibWeb: Start tracking elapsed time when a resource is loadedBrian Gianforcaro
2021-09-12LibWeb: Include headers HashMap in the LoadRequest::hash() calculationBrian Gianforcaro
2021-09-09LibWeb: Rename BrowsingContext::document() => active_document()Andreas Kling
This better matches the spec nomenclature. Note that we don't yet *retrieve* the active document according to spec.
2021-09-09LibWeb: Add BrowsingContext::container() to align with the specAndreas Kling
We already have a base class for frame elements that we call BrowsingContextContainer. This patch makes BrowsingContext::container() actually return one of those. This makes us match the spec names, and also solves a FIXME about having a shared base for <frame> and <iframe>. (We already had the shared base, but the pointer we had there wasn't tightly typed enough.)
2021-09-08LibWeb: Scroll viewport to (0, 0) after loading a new documentAndreas Kling
This fixes a long-standing bug where the view wouldn't update when navigating to a new page after looking at the ACID2 test. This happened because ACID2 actually scrolls the viewport far down. We didn't reset the scroll position upon navigation, and so the new page thought that we were still scrolled very far down, and this broke the invalidation rect calculations.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur