-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibWeb: Update "create and initialize a document" to currrent spec #2971
base: master
Are you sure you want to change the base?
Conversation
gjf7
commented
Dec 19, 2024
- Update "create and initialize a document" to currrent spec
- Add noopener-allow-popups value to OpenerPolicyValue
This is failing some tests but it's hard to tell which. Can you rebase on master? #2950 should make the output a bit more readable. |
Hi there, could u approve the ci again? Thanks |
Libraries/LibWeb/DOM/Document.cpp
Outdated
// 1. If either of sourceOrigin or destinationOrigin have a scheme that is not an HTTP(S) scheme | ||
// and the user agent considers it necessary for sourceOrigin and destinationOrigin to be isolated | ||
// from each other (for implementation-defined reasons), optionally set swapGroup to true. | ||
if (!source_origin.scheme()->starts_with_bytes("http"sv) || !destination_origin.scheme()->starts_with_bytes("http"sv)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. The return value of scheme() is Optional.
I tried using Optional's value_or() with an empty String as follows:
if (!source_origin.scheme().value_or(String {}).starts_with_bytes("http"sv) ||
!destination_origin.scheme().value_or(String {}).starts_with_bytes("http"sv)) {
swap_group = true;
}
However, I'm getting a verification error at runtime:
CopyVERIFICATION FAILED: m_has_value at /Users/haochen/Project/ladybird/AK/Optional.h:317
As I'm new to C++, I'm not sure about the best way to handle this. @AtkinsSJ, could you suggest the proper way to check Optional in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably do this:
if (source_origin.scheme.has_value() &&
(!source_origin.scheme()->starts_with_bytes("http"sv) || !destination_origin.scheme()->starts_with_bytes("http"sv))) {
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh scratch that, I missed that it's two different variables. 😅
But anyway foo.has_value() && !foo->starts_with_bytes("http"sv)
is the check for each one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've updated the code. Please let me know if any other changes are needed to merge this PR.
710ae61
to
4fe0e8a
Compare
Corresponds to whatwg/html#10394. Since we haven't implemented browsing context group switch logic due to opener policy, just add noopener-allow-popups to OpenerPolicyValue for now.