Commit Graph

3048 Commits

Author SHA1 Message Date
Linus Groh
da177c6517 LibJS: Make Errors fully spec compliant
The previous handling of the name and message properties specifically
was breaking websites that created their own error types and relied on
the error prototype working correctly - not assuming an JS::Error this
object, that is.

The way it works now, and it is supposed to work, is:

- Error.prototype.name and Error.prototype.message just have initial
  string values and are no longer getters/setters
- When constructing an error with a message, we create a regular
  property on the newly created object, so a lookup of the message
  property will either get it from the object directly or go though the
  prototype chain
- Internal m_name/m_message properties are no longer needed and removed

This makes printing errors slightly more complicated, as we can no
longer rely on the (safe) internal properties, and cannot trust a
property lookup either - get_without_side_effects() is used to solve
this, it's not perfect but something we can revisit later.

I did some refactoring along the way, there was some really old stuff in
there - accessing vm.call_frame().arguments[0] is not something we (have
to) do anymore :^)

Fixes #6245.
2021-04-12 09:38:57 +02:00
Linus Groh
6e9eb0a284 LibJS: Add Object::get_without_side_effects()
Similar to Value::to_string_without_side_effects() this is mostly a
regular object property lookup, but with the guarantee that it will be
side-effect free, i.e. no accessors or native property functions will
be called. This is needed when we want to access user-controlled object
properties for debug logging, for example. The specific use case will be
error objects which will soon no longer have internal name/message
properties, so we need to guarantee that printing an error, which may
already be the result of an exception, won't blow up in our face :^)
2021-04-12 09:38:57 +02:00
Luke
9ec4defdd2 LibWeb: Add Window.parent and fix Window.top attributes
This returns the parent frame of the current frame. If it's the
main frame, it returns itself.

Also fixes the attributes of Window.top, as they were accidentally
being passed in as the setter.

Required by Web Platform Tests.
2021-04-12 09:01:08 +02:00
Timothy Flynn
e0f9ed01c7 Browser: Process Secure and HttpOnly cookie attributes 2021-04-12 08:57:44 +02:00
Timothy Flynn
db24186309 Browser: Process Path cookie attribute 2021-04-12 08:57:44 +02:00
Timothy Flynn
3d53af354e Browser: Process Domain cookie attribute 2021-04-12 08:57:44 +02:00
Timothy Flynn
a554676008 Browser: Process Max-Age cookie attribute
Note: the default expiry time should be the "the latest representable
date". However, DateTime::from_timestamp(NumericLimits<time_t>::max())
isn't feasible due to the for-loops in LibC's time_to_tm. So instead,
this just sets the date to the maxium year.
2021-04-12 08:57:44 +02:00
Timothy Flynn
d610aeb5da Browser: Parse cookie attribute name-value pairs
Implements the remainder of the parsing algorithm of RFC-6265 Section
5.2 to extract optional attributes. The attribute values are not
processed.
2021-04-12 08:57:44 +02:00
thankyouverycool
198c4fd7f2 Serendipity: Paint theme agnostic banner
And remove temporary welcome-banner.png. Fixes invisible text in
dark themes.
2021-04-12 08:56:06 +02:00
thankyouverycool
1de4ed8ca1 Serendipity: Don't modify tip frame palette
Fixes illegible tip text
2021-04-12 08:56:06 +02:00
AnotherTest
5a14f7ea2f LibRegex: Generate a 'Compare' op for empty character classes
Otherwise it would match zero-length strings.
Fixes #6256.
2021-04-12 08:54:58 +02:00
AnotherTest
7c98a6be17 LibHTTP: Handle running out of input between chunk body and ending CRLF
Fixes an issue where LibHTTP would incorrectly detect an end of stream
when it runs out of TLS application data between the chunk body and its
ending CRLF.
2021-04-12 08:36:21 +02:00
tuqqu
5438879277 LibJS: Removed a fixme in a test of BigInt.prototype.valueOf 2021-04-11 20:51:58 +02:00
Luke
83d2c3f2f5 LibWeb: Move element_child_count to ParentNode and add its IDL attribute
I initially had it in Node just because, but then saw it was part of
ParentNode in the spec.
2021-04-11 18:32:42 +02:00
Luke
fc9abee84b LibWeb: Add Event.initEvent
Used by YouTube after creating an event with Document.createEvent
2021-04-11 18:27:52 +02:00
Luke
8da14bf880 LibWeb: Add support for optional default values and optional bools in IDL
Fixed the DOMException constructor as it had the default value version
commented out.
2021-04-11 18:27:52 +02:00
Timothy Flynn
4152f807bc LibWeb: Store cookies sent via the Set-Cookie HTTP header
Note: HTTP response headers are currently stored in a hash map, so the
Set-Cookie entry will only appear once here.
2021-04-11 18:24:34 +02:00
Timothy Flynn
1ef48d50ff LibWeb+WebContent: Hook document.cookie to the backend cookie storage 2021-04-11 18:24:34 +02:00
Timothy Flynn
e54837add5 Browser+LibWeb: Add hooks for getting and setting cookies 2021-04-11 18:24:34 +02:00
Timothy Flynn
f0cdb2bf50 Browser: Initial cookie storage implementation
This adds storage for cookies that maye be set via 'document.cookie' in
JavaScript or the Set-Cookie HTTP header. For now, it parses only the
name-value pair from a set-cookie line, but does not parse optional
attributes.

Currently, storage is ephemeral and only survives for the lifetime of
the Browser instance.
2021-04-11 18:24:34 +02:00
setepenre
fe8cefa7c1 ls: ls will print directory name when listing multiple directories 2021-04-11 18:16:46 +02:00
Linus Groh
433a23cfde LibJS: Fix array hole and string object indexing prototype indirection
This fixes two cases of indexed access (array holes, out-of-bounds
string object access) where we would not follow the prototype chain and
incorrectly return undefined:

    // Should be "a", returned undefined
    Object.setPrototypeOf([,], ["a"])[0]

    // Should be "a", returned undefined
    Object.setPrototypeOf(new String(""), new String("a"))[0]

The actual fix is simple, instead of returning early if the requested
index is past the string's length or within the indexed properties size
but has no value, we just continue the prototype chain traversal and get
correct behaviour from that.
2021-04-11 18:15:47 +02:00
Andreas Kling
54cd8dfc4d LibWeb+WebContent: Support image context menus in OOPWV
You can now right-click images in web content and get a context menu.
2021-04-11 16:49:25 +02:00
Andreas Kling
e43fba0c58 SystemMonitor: Add tab with detailed state to process properties window
This is done using a wrapper model that transforms all the information
about a single process in the ProcessModel and turns it into a 2-column
table model with only that process in it.
2021-04-11 13:24:59 +02:00
Andreas Kling
a78ea2c0b2 SystemMonitor: Add a little header to the process properties window
Show a larger (32x32) version of the executable icon and the process
name + PID above the various property tabs.
2021-04-11 12:52:42 +02:00
Andreas Kling
1c52dc86ee SystemMonitor: Simplify executable icon lookup in ProcessModel 2021-04-11 12:52:42 +02:00
Andreas Kling
a2686f9bec LibGUI: Avoid unnecessary Gfx::Bitmap cloning in FileIconProvider 2021-04-11 12:52:42 +02:00
Andreas Kling
0c02dfcad5 LibGUI: Add convenient helpers for getting the sibling of a ModelIndex 2021-04-11 12:52:42 +02:00
Brian Gianforcaro
dc98c417ca LibGUI: Remove an unused AK/Debug.h include 2021-04-11 12:50:33 +02:00
Brian Gianforcaro
c4226ca646 LibWeb: Remove trailing ';' from WrapperGenerator functions. 2021-04-11 12:50:33 +02:00
Andreas Kling
251018676f Everywhere: Update references from ReadMe.md => README.md 2021-04-11 10:52:25 +02:00
Andreas Kling
698c38959d Playground: Add Alt shortcuts to menus 2021-04-11 10:38:45 +02:00
Gunnar Beutner
64740a0214 LibC: getopt() and getopt_long() shouldn't modify argv 2021-04-11 09:51:20 +02:00
Gunnar Beutner
8ca5b8c065 LibC: Move S_* defines into <fcntl.h>
According to the Single UNIX Specification, Version 2 that's where
those macros should be defined. This fixes the libiconv port.

This also fixes some (but not all) build errors for the diffutils and nano ports.
2021-04-11 09:51:20 +02:00
Gunnar Beutner
be4b20c14d LibC: Make <limits.h> compatible with GCC so that it doesn't install a fixed header
GCC installs a fixed version of the <limits.h> header as per https://gcc.gnu.org/onlinedocs/gcc/Fixed-Headers.html.
The fixed header doesn't include the target's <limits.h> which in turn means that some definitions (such as PATH_MAX)
aren't available. This change requires rebuilding the toolchain (Toolchain/BuildIt.sh).

This fixes the flatbuffers port.

The commit also removes some non-standard defines (U*_MIN) which don't appear to be used
anywhere. By definition they're always 0 though so they're not strictly necessary.
2021-04-11 09:51:20 +02:00
Brian Gianforcaro
988c23fff0 LibWeb: Add implementation of Node.compareDocumentPosition()
While looking into getting Duck Duck Go loading further in the
Browser, I noticed that it was complaining about the missing
method Node.compareDocumentPosition.

This change implements as much of the DOM spec as possible
with the current implementation of the DOM to date. The
implementation is validated by new tests in the Node.js.
2021-04-11 09:40:06 +02:00
Brian Gianforcaro
0f8932d7ab LibWeb: Connect existing implementation of Node::is_connected to JS.
I was looking at implementing something else, and saw this was low
hanging fruit, that brings the browser closer to standards conformance.

Add a basic test as well to validate it's implementation.
2021-04-11 09:40:06 +02:00
Gunnar Beutner
03ffdeb43a LibC: Provide macros for the <ctype.h> functions
These are required for the 'tr' port.
2021-04-11 01:18:02 +02:00
Gunnar Beutner
fe8b1a732e LibC: Include additional headers in <arpa/inet.h>
According to the Single UNIX Specification, Version 2 the <arpa/inet.h>
header may optionally include <netinet/in.h> and <inttypes.h>. This
helps with porting software like c-ray that expects this to be the case.
2021-04-11 01:18:02 +02:00
thankyouverycool
07627b3742 FontEditor: Add 'New Font' wizard to editor
Take a comfy guided tour through new font creation.
2021-04-11 01:16:34 +02:00
thankyouverycool
cdfa2614b9 FontEditor: Move menu bar into editor and tweak several widgets
Actions are now shared between menu bar and toolbar. Adds an edit
menu to complement toolbar actions. Glyphs are now passed as ints
instead of u8s; fixes Latin Extended+ glyphs failing to update in
real time on map. Converts weight and type to more human-readable
combo box lists. Selected glyph now scrolls into view on load.
2021-04-11 01:16:34 +02:00
thankyouverycool
c283429196 LibGfx: Add a count to FontTypes and a helper to return type names 2021-04-11 01:16:34 +02:00
thankyouverycool
25bd4b33a7 LibGUI: Move FontPickerWeightModel and helpers to their own header
Avoids maintaining multiple weight-name lists
2021-04-11 01:16:34 +02:00
Andreas Kling
d4d8d9ea0b LibGfx: Make sure draw_ui_text() paints underlines with text color
We shouldn't hard-code black here, then we won't respect the system
theme colors. :^)
2021-04-11 01:11:56 +02:00
Andreas Kling
a4992b5ece LibGUI+LibGfx: Collapse the '&' from Alt shortcuts in tooltip texts
Also resolve a FIXME about using GUI::Label auto-sizing since we're
changing this code and it simplifies what we're doing.

Fixes #6219.
2021-04-11 01:11:09 +02:00
Luke
ccd21614a3 LibJS: Replace Vector with MarkedValueList in RegExpPrototype::symbol_replace
Otherwise the GC won't be able to keep track of the stored values
and they may suddenly disappear from underneath us, thinking
they're not in use.

Fixes a crash when going to the Bootstrap website, where the first
replace call in jQuery caused a jump to a bogus address.
2021-04-11 00:32:59 +02:00
Andreas Kling
2146d22432 LibCore: Save errno before it gets clobbered in Core::IODevice::write() 2021-04-10 22:31:29 +02:00
Jelle Raaijmakers
06353077b7 LibGUI/ScrollBar: Only paint buttons as pressed when also hovered
Fixes #6185
2021-04-10 22:28:00 +02:00
Jelle Raaijmakers
f733b85957 LibTLS: Remove excessive CloseNotify logging 2021-04-10 21:05:00 +02:00
AnotherTest
a6e4482080 AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities
arguably more nice-looking by removing the need to reach into the
wrapper structs generated by them to get the value/type needed.
The C++ standard library had to invent `_v` and `_t` variants (likely
because of backwards compat), but we don't need to cater to any codebase
except our own, so might as well have good things for free. :^)
2021-04-10 21:01:31 +02:00