mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibWeb: Implement the CrossOriginProperties AO
This commit is contained in:
parent
8b4e5220aa
commit
78938d933a
3 changed files with 59 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/Variant.h>
|
||||||
|
#include <AK/Vector.h>
|
||||||
|
#include <LibJS/Runtime/Object.h>
|
||||||
|
#include <LibWeb/Bindings/CrossOriginAbstractOperations.h>
|
||||||
|
#include <LibWeb/Bindings/LocationObject.h>
|
||||||
|
#include <LibWeb/Bindings/WindowObject.h>
|
||||||
|
|
||||||
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
// 7.2.3.1 CrossOriginProperties ( O ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginproperties-(-o-)
|
||||||
|
Vector<CrossOriginProperty> cross_origin_properties(Variant<LocationObject const*, WindowObject const*> const& object)
|
||||||
|
{
|
||||||
|
// 1. Assert: O is a Location or Window object.
|
||||||
|
|
||||||
|
return object.visit(
|
||||||
|
// 2. If O is a Location object, then return « { [[Property]]: "href", [[NeedsGet]]: false, [[NeedsSet]]: true }, { [[Property]]: "replace" } ».
|
||||||
|
[](LocationObject const*) -> Vector<CrossOriginProperty> {
|
||||||
|
return {
|
||||||
|
{ .property = "href"sv, .needs_get = false, .needs_set = true },
|
||||||
|
{ .property = "replace"sv },
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// 3. Return « { [[Property]]: "window", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "self", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "location", [[NeedsGet]]: true, [[NeedsSet]]: true }, { [[Property]]: "close" }, { [[Property]]: "closed", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "focus" }, { [[Property]]: "blur" }, { [[Property]]: "frames", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "length", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "top", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "opener", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "parent", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "postMessage" } ».
|
||||||
|
[](WindowObject const*) -> Vector<CrossOriginProperty> {
|
||||||
|
return {
|
||||||
|
{ .property = "window"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "self"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "location"sv, .needs_get = true, .needs_set = true },
|
||||||
|
{ .property = "close"sv },
|
||||||
|
{ .property = "closed"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "focus"sv },
|
||||||
|
{ .property = "blur"sv },
|
||||||
|
{ .property = "frames"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "length"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "top"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "opener"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "parent"sv, .needs_get = true, .needs_set = false },
|
||||||
|
{ .property = "postMessage"sv },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,9 +9,16 @@
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/Traits.h>
|
#include <AK/Traits.h>
|
||||||
#include <LibJS/Forward.h>
|
#include <LibJS/Forward.h>
|
||||||
|
#include <LibWeb/Forward.h>
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
struct CrossOriginProperty {
|
||||||
|
String property;
|
||||||
|
Optional<bool> needs_get {};
|
||||||
|
Optional<bool> needs_set {};
|
||||||
|
};
|
||||||
|
|
||||||
struct CrossOriginKey {
|
struct CrossOriginKey {
|
||||||
FlatPtr current_settings_object;
|
FlatPtr current_settings_object;
|
||||||
FlatPtr relevant_settings_object;
|
FlatPtr relevant_settings_object;
|
||||||
|
@ -20,6 +27,8 @@ struct CrossOriginKey {
|
||||||
|
|
||||||
using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
|
using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
|
||||||
|
|
||||||
|
Vector<CrossOriginProperty> cross_origin_properties(Variant<LocationObject const*, WindowObject const*> const&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
Bindings/AudioConstructor.cpp
|
Bindings/AudioConstructor.cpp
|
||||||
|
Bindings/CrossOriginAbstractOperations.cpp
|
||||||
Bindings/CSSNamespace.cpp
|
Bindings/CSSNamespace.cpp
|
||||||
Bindings/CSSRuleWrapperFactory.cpp
|
Bindings/CSSRuleWrapperFactory.cpp
|
||||||
Bindings/CSSStyleDeclarationWrapperCustom.cpp
|
Bindings/CSSStyleDeclarationWrapperCustom.cpp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue