Compare commits

..

No commits in common. "460ffcbe1dc5d750e6ee92943b3a5b6f402d842c" and "1a640b1d9584f723a8bbc465537f03f6d7d49129" have entirely different histories.

59 changed files with 182 additions and 762 deletions

View file

@ -9,7 +9,6 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSMathNegate.h>
#include <LibWeb/CSS/CSSNumericArray.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -147,12 +146,4 @@ Optional<SumValue> CSSMathClamp::create_a_sum_value() const
};
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathClamp::create_calculation_node(CalculationContext const& context) const
{
auto lower = TRY(m_lower->create_calculation_node(context));
auto value = TRY(m_value->create_calculation_node(context));
auto upper = TRY(m_upper->create_calculation_node(context));
return ClampCalculationNode::create(move(lower), move(value), move(upper));
}
}

View file

@ -32,8 +32,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathClamp(JS::Realm&, NumericType, GC::Ref<CSSNumericValue> lower, GC::Ref<CSSNumericValue> value, GC::Ref<CSSNumericValue> upper);
GC::Ref<CSSNumericValue> m_lower;

View file

@ -7,7 +7,6 @@
#include "CSSMathInvert.h"
#include <LibWeb/Bindings/CSSMathInvertPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS {
@ -132,9 +131,4 @@ Optional<SumValue> CSSMathInvert::create_a_sum_value() const
return values;
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathInvert::create_calculation_node(CalculationContext const& context) const
{
return InvertCalculationNode::create(TRY(m_value->create_calculation_node(context)));
}
}

View file

@ -30,8 +30,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathInvert(JS::Realm&, NumericType, GC::Ref<CSSNumericValue>);
GC::Ref<CSSNumericValue> m_value;

View file

@ -9,7 +9,6 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSMathNegate.h>
#include <LibWeb/CSS/CSSNumericArray.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -158,14 +157,4 @@ Optional<SumValue> CSSMathMax::create_a_sum_value() const
return item_with_largest_value;
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathMax::create_calculation_node(CalculationContext const& context) const
{
Vector<NonnullRefPtr<CalculationNode const>> child_nodes;
for (auto const& child_value : m_values->values()) {
child_nodes.append(TRY(child_value->create_calculation_node(context)));
}
return MaxCalculationNode::create(move(child_nodes));
}
}

View file

@ -30,8 +30,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathMax(JS::Realm&, NumericType, GC::Ref<CSSNumericArray>);
GC::Ref<CSSNumericArray> m_values;

View file

@ -10,7 +10,6 @@
#include <LibWeb/CSS/CSSMathNegate.h>
#include <LibWeb/CSS/CSSNumericArray.h>
#include <LibWeb/CSS/CSSNumericValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -159,14 +158,4 @@ Optional<SumValue> CSSMathMin::create_a_sum_value() const
return item_with_smallest_value;
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathMin::create_calculation_node(CalculationContext const& context) const
{
Vector<NonnullRefPtr<CalculationNode const>> child_nodes;
for (auto const& child_value : m_values->values()) {
child_nodes.append(TRY(child_value->create_calculation_node(context)));
}
return MinCalculationNode::create(move(child_nodes));
}
}

View file

@ -30,8 +30,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathMin(JS::Realm&, NumericType, GC::Ref<CSSNumericArray>);
GC::Ref<CSSNumericArray> m_values;

View file

@ -7,7 +7,6 @@
#include "CSSMathNegate.h"
#include <LibWeb/Bindings/CSSMathNegatePrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS {
@ -122,9 +121,4 @@ Optional<SumValue> CSSMathNegate::create_a_sum_value() const
return values;
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathNegate::create_calculation_node(CalculationContext const& context) const
{
return NegateCalculationNode::create(TRY(m_value->create_calculation_node(context)));
}
}

View file

@ -30,8 +30,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathNegate(JS::Realm&, NumericType, GC::Ref<CSSNumericValue>);
GC::Ref<CSSNumericValue> m_value;

View file

@ -9,7 +9,6 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSMathInvert.h>
#include <LibWeb/CSS/CSSNumericArray.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -195,14 +194,4 @@ Optional<SumValue> CSSMathProduct::create_a_sum_value() const
return values;
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathProduct::create_calculation_node(CalculationContext const& context) const
{
Vector<NonnullRefPtr<CalculationNode const>> child_nodes;
for (auto const& child_value : m_values->values()) {
child_nodes.append(TRY(child_value->create_calculation_node(context)));
}
return ProductCalculationNode::create(move(child_nodes));
}
}

View file

@ -30,8 +30,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathProduct(JS::Realm&, NumericType, GC::Ref<CSSNumericArray>);
GC::Ref<CSSNumericArray> m_values;

View file

@ -9,7 +9,6 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSMathNegate.h>
#include <LibWeb/CSS/CSSNumericArray.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -207,14 +206,4 @@ Optional<SumValue> CSSMathSum::create_a_sum_value() const
return values;
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSMathSum::create_calculation_node(CalculationContext const& context) const
{
Vector<NonnullRefPtr<CalculationNode const>> child_nodes;
for (auto const& child_value : m_values->values()) {
child_nodes.append(TRY(child_value->create_calculation_node(context)));
}
return SumCalculationNode::create(move(child_nodes));
}
}

View file

@ -30,8 +30,6 @@ public:
virtual bool is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const override;
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
CSSMathSum(JS::Realm&, NumericType, GC::Ref<CSSNumericArray>);
GC::Ref<CSSNumericArray> m_values;

View file

@ -6,8 +6,6 @@
#include "CSSMathValue.h"
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
namespace Web::CSS {
@ -25,44 +23,4 @@ void CSSMathValue::initialize(JS::Realm& realm)
Base::initialize(realm);
}
// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation
WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSMathValue::create_an_internal_representation(PropertyNameAndID const& property) const
{
// If value is a CSSStyleValue subclass,
// If value does not match the grammar of a list-valued property iteration of property, throw a TypeError.
//
// If any component of propertys CSS grammar has a limited numeric range, and the corresponding part of value
// is a CSSUnitValue that is outside of that range, replace that value with the result of wrapping it in a
// fresh CSSMathSum whose values internal slot contains only that part of value.
//
// Return the value.
// FIXME: Check types allowed by registered custom properties.
auto context = CalculationContext::for_property(property);
auto matches = [&] {
if (type().matches_angle(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Angle);
if (type().matches_flex(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Flex);
if (type().matches_frequency(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Frequency);
if (type().matches_length(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Length);
if (type().matches_number(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Number);
if (type().matches_percentage())
return property_accepts_type(property.id(), ValueType::Percentage);
if (type().matches_resolution(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Resolution);
if (type().matches_time(context.percentages_resolve_as))
return property_accepts_type(property.id(), ValueType::Time);
return false;
}();
if (!matches)
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv };
return CalculatedStyleValue::create(TRY(create_calculation_node(context)), type(), move(context));
}
}

View file

@ -8,7 +8,6 @@
#include <LibWeb/Bindings/CSSMathValuePrototype.h>
#include <LibWeb/CSS/CSSNumericValue.h>
#include <LibWeb/Forward.h>
namespace Web::CSS {
@ -32,8 +31,6 @@ public:
};
virtual String serialize_math_value(Nested, Parens) const = 0;
virtual WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> create_an_internal_representation(PropertyNameAndID const&) const final override;
protected:
explicit CSSMathValue(JS::Realm&, Bindings::CSSMathOperator, NumericType);

View file

@ -65,8 +65,6 @@ public:
static WebIDL::ExceptionOr<GC::Ref<CSSNumericValue>> parse(JS::VM&, String const& css_text);
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const = 0;
protected:
explicit CSSNumericValue(JS::Realm&, NumericType);

View file

@ -297,34 +297,6 @@ Optional<SumValue> CSSUnitValue::create_a_sum_value() const
return SumValue { SumValueItem { value, { { unit, 1 } } } };
}
static Optional<CalculationNode::NumericValue> create_numeric_value(double value, FlyString const& unit)
{
if (unit == "number"_fly_string)
return Number { Number::Type::Number, value };
if (unit == "percent"_fly_string)
return Percentage { value };
if (auto dimension_type = dimension_for_unit(unit); dimension_type.has_value()) {
switch (*dimension_type) {
case DimensionType::Angle:
return Angle { value, string_to_angle_unit(unit).release_value() };
case DimensionType::Flex:
return Flex { value, string_to_flex_unit(unit).release_value() };
case DimensionType::Frequency:
return Frequency { value, string_to_frequency_unit(unit).release_value() };
case DimensionType::Length:
return Length { value, string_to_length_unit(unit).release_value() };
case DimensionType::Resolution:
return Resolution { value, string_to_resolution_unit(unit).release_value() };
case DimensionType::Time:
return Time { value, string_to_time_unit(unit).release_value() };
}
}
return {};
}
// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation
WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_internal_representation(PropertyNameAndID const& property) const
{
@ -350,107 +322,102 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_int
}
auto wrap_in_math_sum = [this, &property](auto&& value) -> NonnullRefPtr<StyleValue const> {
auto context = CalculationContext::for_property(property);
CalculationContext context {
.percentages_resolve_as = property_resolves_percentages_relative_to(property.id()),
.resolve_numbers_as_integers = property_accepts_type(property.id(), ValueType::Integer),
.accepted_type_ranges = property_accepted_type_ranges(property.id()),
};
auto numeric_node = NumericCalculationNode::create(value, context);
auto math_sum_node = SumCalculationNode::create({ move(numeric_node) });
return CalculatedStyleValue::create(move(math_sum_node), NumericType::create_from_unit(m_unit).release_value(), context);
};
auto value = create_numeric_value(m_value, m_unit);
if (!value.has_value()) {
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unrecognized unit '{}'.", m_unit)) };
if (m_unit == "number"_fly_string) {
// NB: Number before Integer, because a custom property accepts either and we want to avoid rounding in that case.
if (property_accepts_type(property.id(), ValueType::Number)) {
if (property_accepts_number(property.id(), m_value))
return NumberStyleValue::create(m_value);
return wrap_in_math_sum(Number { Number::Type::Number, m_value });
}
if (property_accepts_type(property.id(), ValueType::Integer)) {
// NB: Same rounding as CalculatedStyleValue::resolve_integer(). Maybe this should go somewhere central?
auto integer = llround(m_value);
if (property_accepts_integer(property.id(), integer))
return IntegerStyleValue::create(integer);
return wrap_in_math_sum(Number { Number::Type::Number, m_value });
}
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv };
}
// FIXME: Check types allowed by registered custom properties.
auto style_value = value->visit(
[&](Number const& number) -> RefPtr<StyleValue const> {
// NB: Number before Integer, because a custom property accepts either and we want to avoid rounding in that case.
if (property_accepts_type(property.id(), ValueType::Number)) {
if (property_accepts_number(property.id(), number.value()))
return NumberStyleValue::create(number.value());
return wrap_in_math_sum(number);
}
if (m_unit == "percent"_fly_string) {
if (property_accepts_type(property.id(), ValueType::Percentage)) {
Percentage percentage { m_value };
if (property_accepts_percentage(property.id(), percentage))
return PercentageStyleValue::create(percentage);
return wrap_in_math_sum(percentage);
}
if (property_accepts_type(property.id(), ValueType::Integer)) {
// NB: Same rounding as CalculatedStyleValue::resolve_integer(). Maybe this should go somewhere central?
auto integer = llround(number.value());
if (property_accepts_integer(property.id(), integer))
return IntegerStyleValue::create(integer);
return wrap_in_math_sum(number);
}
return {};
},
[&](Percentage const& percentage) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Percentage)) {
if (property_accepts_percentage(property.id(), percentage))
return PercentageStyleValue::create(percentage);
return wrap_in_math_sum(percentage);
}
return {};
},
[&](Angle const& angle) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Angle)) {
if (property_accepts_angle(property.id(), angle))
return AngleStyleValue::create(angle);
return wrap_in_math_sum(angle);
}
return {};
},
[&](Flex const& flex) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Flex)) {
if (property_accepts_flex(property.id(), flex))
return FlexStyleValue::create(flex);
return wrap_in_math_sum(flex);
}
return {};
},
[&](Frequency const& frequency) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Frequency)) {
if (property_accepts_frequency(property.id(), frequency))
return FrequencyStyleValue::create(frequency);
return wrap_in_math_sum(frequency);
}
return {};
},
[&](Length const& length) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Length)) {
if (property_accepts_length(property.id(), length))
return LengthStyleValue::create(length);
return wrap_in_math_sum(length);
}
return {};
},
[&](Resolution const& resolution) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Resolution)) {
if (property_accepts_resolution(property.id(), resolution))
return ResolutionStyleValue::create(resolution);
return wrap_in_math_sum(resolution);
}
return {};
},
[&](Time const& time) -> RefPtr<StyleValue const> {
if (property_accepts_type(property.id(), ValueType::Time)) {
if (property_accepts_time(property.id(), time))
return TimeStyleValue::create(time);
return wrap_in_math_sum(time);
}
return {};
});
if (!style_value)
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv };
return style_value.release_nonnull();
}
}
WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> CSSUnitValue::create_calculation_node(CalculationContext const& context) const
{
auto value = create_numeric_value(m_value, m_unit);
if (!value.has_value())
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to create calculation node from `{}{}`.", m_value, m_unit)) };
auto dimension_type = dimension_for_unit(m_unit);
if (!dimension_type.has_value())
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unrecognized unit '{}'.", m_unit)) };
return NumericCalculationNode::create(value.release_value(), context);
switch (*dimension_type) {
case DimensionType::Angle:
if (property_accepts_type(property.id(), ValueType::Angle)) {
Angle value { m_value, string_to_angle_unit(m_unit).release_value() };
if (property_accepts_angle(property.id(), value))
return AngleStyleValue::create(value);
return wrap_in_math_sum(value);
}
break;
case DimensionType::Flex:
if (property_accepts_type(property.id(), ValueType::Flex)) {
Flex value { m_value, string_to_flex_unit(m_unit).release_value() };
if (property_accepts_flex(property.id(), value))
return FlexStyleValue::create(value);
return wrap_in_math_sum(value);
}
break;
case DimensionType::Frequency:
if (property_accepts_type(property.id(), ValueType::Frequency)) {
Frequency value { m_value, string_to_frequency_unit(m_unit).release_value() };
if (property_accepts_frequency(property.id(), value))
return FrequencyStyleValue::create(value);
return wrap_in_math_sum(value);
}
break;
case DimensionType::Length:
if (property_accepts_type(property.id(), ValueType::Length)) {
Length value { m_value, string_to_length_unit(m_unit).release_value() };
if (property_accepts_length(property.id(), value))
return LengthStyleValue::create(value);
return wrap_in_math_sum(value);
}
break;
case DimensionType::Resolution:
if (property_accepts_type(property.id(), ValueType::Resolution)) {
Resolution value { m_value, string_to_resolution_unit(m_unit).release_value() };
if (property_accepts_resolution(property.id(), value))
return ResolutionStyleValue::create(value);
return wrap_in_math_sum(value);
}
break;
case DimensionType::Time:
if (property_accepts_type(property.id(), ValueType::Time)) {
Time value { m_value, string_to_time_unit(m_unit).release_value() };
if (property_accepts_time(property.id(), value))
return TimeStyleValue::create(value);
return wrap_in_math_sum(value);
}
break;
}
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv };
}
}

View file

@ -36,7 +36,6 @@ public:
virtual Optional<SumValue> create_a_sum_value() const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> create_an_internal_representation(PropertyNameAndID const&) const override;
virtual WebIDL::ExceptionOr<NonnullRefPtr<CalculationNode const>> create_calculation_node(CalculationContext const&) const override;
private:
explicit CSSUnitValue(JS::Realm&, double value, FlyString unit, NumericType type);

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021, the SerenityOS developers.
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
*
@ -11,7 +11,6 @@
#include "Interpolation.h"
#include <AK/IntegralMath.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
#include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
@ -601,7 +600,10 @@ ValueComparingRefPtr<StyleValue const> interpolate_property(DOM::Element& elemen
auto from = with_keyword_values_resolved(element, property_id, a_from);
auto to = with_keyword_values_resolved(element, property_id, a_to);
auto calculation_context = CalculationContext::for_property(PropertyNameAndID::from_id(property_id));
CalculationContext calculation_context {
.percentages_resolve_as = property_resolves_percentages_relative_to(property_id),
.accepted_type_ranges = property_accepted_type_ranges(property_id),
};
auto animation_type = animation_type_from_longhand_property(property_id);
switch (animation_type) {

View file

@ -566,7 +566,6 @@ private:
ShadowBlurRadius,
TranslateZArgument
};
// FIXME: Use PropertyNameAndID instead of PropertyID as the context, for registered custom properties.
using ValueParsingContext = Variant<PropertyID, FunctionContext, DescriptorContext, SpecialContext>;
Vector<ValueParsingContext> m_value_context;
auto push_temporary_value_parsing_context(ValueParsingContext&& context)

View file

@ -4106,7 +4106,11 @@ RefPtr<CalculatedStyleValue const> Parser::parse_calculated_value(ComponentValue
for (auto const& value_context : m_value_context.in_reverse()) {
auto maybe_context = value_context.visit(
[](PropertyID property_id) -> Optional<CalculationContext> {
return CalculationContext::for_property(PropertyNameAndID::from_id(property_id));
return CalculationContext {
.percentages_resolve_as = property_resolves_percentages_relative_to(property_id),
.resolve_numbers_as_integers = property_accepts_type(property_id, ValueType::Integer),
.accepted_type_ranges = property_accepted_type_ranges(property_id),
};
},
[](FunctionContext const& function) -> Optional<CalculationContext> {
// Gradients resolve percentages as lengths relative to the gradient-box.

View file

@ -3601,7 +3601,7 @@ NonnullRefPtr<StyleValue const> StyleComputer::compute_line_height(NonnullRefPtr
// NOTE: We also support calc()'d numbers
if (specified_value->is_calculated() && specified_value->as_calculated().resolves_to_number())
return NumberStyleValue::create(specified_value->as_calculated().resolve_number(CalculationResolutionContext::from_computation_context(computation_context, Length(1, LengthUnit::Em))).value());
return NumberStyleValue::create(specified_value->as_calculated().resolve_number(CalculationResolutionContext::from_computation_context(computation_context)).value());
// <percentage [0,∞]>
if (specified_value->is_percentage())

View file

@ -22,7 +22,6 @@
#include <LibWeb/CSS/CSSUnitValue.h>
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
@ -35,16 +34,6 @@
namespace Web::CSS {
CalculationContext CalculationContext::for_property(PropertyNameAndID const& property)
{
// FIXME: Handle registered custom properties, which may limit which types they accept.
return {
.percentages_resolve_as = property_resolves_percentages_relative_to(property.id()),
.resolve_numbers_as_integers = property_accepts_type(property.id(), ValueType::Integer),
.accepted_type_ranges = property_accepted_type_ranges(property.id()),
};
}
static Optional<NumericType> add_the_types(Vector<NonnullRefPtr<CalculationNode const>> const& nodes)
{
Optional<NumericType> left_type;

View file

@ -32,8 +32,6 @@ struct CalculationContext {
Optional<ValueType> percentages_resolve_as {};
bool resolve_numbers_as_integers = false;
AcceptedTypeRangeMap accepted_type_ranges {};
static CalculationContext for_property(PropertyNameAndID const&);
};
class CalculatedStyleValue : public StyleValue {

View file

@ -27,8 +27,6 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/Painting/ViewportPaintable.h>
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
namespace Web::DOM {
@ -1242,16 +1240,9 @@ GC::Ref<Geometry::DOMRect> Range::get_bounding_client_rect()
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment(TrustedTypes::TrustedHTMLOrString const& string)
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment(String const& string)
{
// 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with
// TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script".
auto const compliant_string = TRY(TrustedTypes::get_trusted_type_compliant_string(
TrustedTypes::TrustedTypeName::TrustedHTML,
HTML::relevant_global_object(*this),
string,
TrustedTypes::InjectionSink::RangecreateContextualFragment,
TrustedTypes::Script.to_string()));
// FIXME: 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script".
// 2. Let node be this's start node.
GC::Ref<Node> node = *start_container();
@ -1277,8 +1268,8 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment
element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, Namespace::HTML));
}
// 7. Let fragment node be the result of invoking the fragment parsing algorithm steps with element and compliantString.
auto fragment_node = TRY(element->parse_fragment(compliant_string.to_utf8_but_should_be_ported_to_utf16()));
// 7. Let fragment node be the result of invoking the fragment parsing algorithm steps with element and compliantString. FIXME: Use compliantString.
auto fragment_node = TRY(element->parse_fragment(string));
// 8. For each script of fragment node's script element descendants:
fragment_node->for_each_in_subtree_of_type<HTML::HTMLScriptElement>([&](HTML::HTMLScriptElement& script_element) {

View file

@ -13,7 +13,6 @@
#include <LibWeb/DOM/Node.h>
#include <LibWeb/Export.h>
#include <LibWeb/Selection/Selection.h>
#include <LibWeb/TrustedTypes/TrustedHTML.h>
#include <LibWeb/WebIDL/Types.h>
namespace Web::DOM {
@ -92,7 +91,7 @@ public:
void set_associated_selection(Badge<Selection::Selection>, GC::Ptr<Selection::Selection>);
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> create_contextual_fragment(TrustedTypes::TrustedHTMLOrString const& fragment);
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> create_contextual_fragment(String const& fragment);
template<typename Callback>
void for_each_contained(Callback callback) const

View file

@ -1,7 +1,6 @@
#import <DOM/Node.idl>
#import <DOM/AbstractRange.idl>
#import <Geometry/DOMRect.idl>
#import <TrustedTypes/TrustedHTML.idl>
// https://dom.spec.whatwg.org/#interface-range
[Exposed=Window]
@ -47,5 +46,6 @@ interface Range : AbstractRange {
stringifier;
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment
[CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or Utf16DOMString) string);
// FIXME: [CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or DOMString) string);
[CEReactions, NewObject] DocumentFragment createContextualFragment(DOMString string);
};

View file

@ -24,8 +24,6 @@
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
namespace Web::Editing {
@ -1220,14 +1218,9 @@ bool command_insert_horizontal_rule_action(DOM::Document& document, Utf16String
// https://w3c.github.io/editing/docs/execCommand/#the-inserthtml-command
bool command_insert_html_action(DOM::Document& document, Utf16String const& value)
{
// 1. Set value to the result of invoking get trusted types compliant string with TrustedHTML, this's relevant
// FIXME: 1. Set value to the result of invoking get trusted types compliant string with TrustedHTML, this's relevant
// global object, value, "Document execCommand", and "script".
auto const resulting_value = MUST(TrustedTypes::get_trusted_type_compliant_string(
TrustedTypes::TrustedTypeName::TrustedHTML,
HTML::relevant_global_object(document),
value,
TrustedTypes::InjectionSink::DocumentexecCommand,
TrustedTypes::Script.to_string()));
auto resulting_value = value;
// 2. Delete the selection.
auto& selection = *document.get_selection();
@ -1239,7 +1232,7 @@ bool command_insert_html_action(DOM::Document& document, Utf16String const& valu
return true;
// 4. Let frag be the result of calling createContextualFragment(value) on the active range.
auto frag = MUST(range->create_contextual_fragment(resulting_value));
auto frag = MUST(range->create_contextual_fragment(resulting_value.to_utf8_but_should_be_ported_to_utf16()));
// 5. Let last child be the lastChild of frag.
GC::Ptr<DOM::Node> last_child = frag->last_child();

View file

@ -217,7 +217,6 @@ class BasicShapeStyleValue;
class BorderImageSliceStyleValue;
class BorderRadiusStyleValue;
class CalculatedStyleValue;
class CalculationNode;
class CascadedProperties;
class Clip;
class ColorMixStyleValue;
@ -396,7 +395,6 @@ enum class MediaFeatureID : u8;
enum class PropertyID : u16;
struct BackgroundLayerData;
struct CalculationContext;
struct CalculationResolutionContext;
struct CSSStyleSheetInit;
struct GridRepeatParams;

View file

@ -17,24 +17,17 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/Worker.h>
#include <LibWeb/Platform/EventLoopPlugin.h>
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
namespace Web::HTML {
GC_DEFINE_ALLOCATOR(SharedWorker);
// https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworker
WebIDL::ExceptionOr<GC::Ref<SharedWorker>> SharedWorker::construct_impl(JS::Realm& realm, TrustedTypes::TrustedScriptURLOrString const& script_url, Variant<String, WorkerOptions>& options_value)
WebIDL::ExceptionOr<GC::Ref<SharedWorker>> SharedWorker::construct_impl(JS::Realm& realm, String const& script_url, Variant<String, WorkerOptions>& options_value)
{
// 1. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with
// TrustedScriptURL, this's relevant global object, scriptURL, "SharedWorker constructor", and "script".
auto const compliant_script_url = TRY(get_trusted_type_compliant_string(
TrustedTypes::TrustedTypeName::TrustedScriptURL,
realm.global_object(),
script_url,
TrustedTypes::InjectionSink::SharedWorkerconstructor,
TrustedTypes::Script.to_string()));
// FIXME: 1. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with
// TrustedScriptURL, this's relevant global object, scriptURL, "SharedWorker constructor", and "script".
auto const& compliant_script_url = script_url;
// 2. If options is a DOMString, set options to a new WorkerOptions dictionary whose name member is set to the value
// of options and whose other members are set to their default values.
@ -50,7 +43,7 @@ WebIDL::ExceptionOr<GC::Ref<SharedWorker>> SharedWorker::construct_impl(JS::Real
auto& outside_settings = current_principal_settings_object();
// 4. Let urlRecord be the result of encoding-parsing a URL given compliantScriptURL, relative to outside settings.
auto url = outside_settings.encoding_parse_url(compliant_script_url.to_utf8_but_should_be_ported_to_utf16());
auto url = outside_settings.encoding_parse_url(compliant_script_url);
// 5. If urlRecord is failure, then throw a "SyntaxError" DOMException.
if (!url.has_value())

View file

@ -10,7 +10,6 @@
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/AbstractWorker.h>
#include <LibWeb/HTML/WorkerAgentParent.h>
#include <LibWeb/TrustedTypes/TrustedScriptURL.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML {
@ -23,7 +22,7 @@ class SharedWorker final
GC_DECLARE_ALLOCATOR(SharedWorker);
public:
static WebIDL::ExceptionOr<GC::Ref<SharedWorker>> construct_impl(JS::Realm&, TrustedTypes::TrustedScriptURLOrString const& script_url, Variant<String, WorkerOptions>& options);
static WebIDL::ExceptionOr<GC::Ref<SharedWorker>> construct_impl(JS::Realm&, String const& script_url, Variant<String, WorkerOptions>& options);
virtual ~SharedWorker();

View file

@ -2,12 +2,12 @@
#import <HTML/AbstractWorker.idl>
#import <HTML/MessagePort.idl>
#import <HTML/Worker.idl>
#import <TrustedTypes/TrustedScriptURL.idl>
// https://html.spec.whatwg.org/multipage/workers.html#sharedworker
[Exposed=Window]
interface SharedWorker : EventTarget {
constructor((TrustedScriptURL or Utf16USVString) scriptURL, optional (DOMString or WorkerOptions) options = {});
// FIXME: "DOMString scriptURL" should be "(TrustedScriptURL or USVString) scriptURL".
constructor(DOMString scriptURL, optional (DOMString or WorkerOptions) options = {});
readonly attribute MessagePort port;
};

View file

@ -12,8 +12,6 @@
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
#include <LibWeb/HTML/SharedWorker.h>
#include <LibWeb/HTML/Worker.h>
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
namespace Web::HTML {
@ -44,7 +42,7 @@ void Worker::visit_edges(Cell::Visitor& visitor)
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker
// https://whatpr.org/html/9893/workers.html#dom-worker
WebIDL::ExceptionOr<GC::Ref<Worker>> Worker::create(TrustedTypes::TrustedScriptURLOrString const& script_url, WorkerOptions const& options, DOM::Document& document)
WebIDL::ExceptionOr<GC::Ref<Worker>> Worker::create(String const& script_url, WorkerOptions const& options, DOM::Document& document)
{
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url);
@ -55,31 +53,26 @@ WebIDL::ExceptionOr<GC::Ref<Worker>> Worker::create(TrustedTypes::TrustedScriptU
// JavaScript modules (specify type: "module"), and if that is specified, can also be used
// to specify how scriptURL is fetched through the credentials option.
// 1. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with
// TrustedScriptURL, this's relevant global object, scriptURL, "Worker constructor", and "script".
auto const compliant_script_url = TRY(TrustedTypes::get_trusted_type_compliant_string(
TrustedTypes::TrustedTypeName::TrustedScriptURL,
HTML::relevant_global_object(document),
script_url,
TrustedTypes::InjectionSink::Workerconstructor,
TrustedTypes::Script.to_string()));
// FIXME: 1. The user agent may throw a "SecurityError" DOMException if the request violates
// a policy decision (e.g. if the user agent is configured to not allow the page to start dedicated workers).
// Technically not a fixme if our policy is not to throw errors :^)
// 2. Let outside settings be the current principal settings object.
auto& outside_settings = current_principal_settings_object();
// 3. Parse the scriptURL argument relative to outside settings.
auto url = outside_settings.parse_url(compliant_script_url.to_utf8_but_should_be_ported_to_utf16());
auto url = outside_settings.parse_url(script_url);
// 4. If this fails, throw a "SyntaxError" DOMException.
if (!url.has_value()) {
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", compliant_script_url);
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", script_url);
return WebIDL::SyntaxError::create(document.realm(), "url is not valid"_utf16);
}
// 5. Let worker URL be the resulting URL record.
// 6. Let worker be a new Worker object.
auto worker = document.realm().create<Worker>(compliant_script_url.to_utf8_but_should_be_ported_to_utf16(), options, document);
auto worker = document.realm().create<Worker>(script_url, options, document);
// 7. Let outside port be a new MessagePort in outside settings's Realm.
auto outside_port = MessagePort::create(outside_settings.realm());

View file

@ -26,8 +26,8 @@ class Worker
GC_DECLARE_ALLOCATOR(Worker);
public:
static WebIDL::ExceptionOr<GC::Ref<Worker>> create(TrustedTypes::TrustedScriptURLOrString const& script_url, WorkerOptions const& options, DOM::Document& document);
static WebIDL::ExceptionOr<GC::Ref<Worker>> construct_impl(JS::Realm& realm, TrustedTypes::TrustedScriptURLOrString const& script_url, WorkerOptions const& options)
static WebIDL::ExceptionOr<GC::Ref<Worker>> create(String const& script_url, WorkerOptions const& options, DOM::Document& document);
static WebIDL::ExceptionOr<GC::Ref<Worker>> construct_impl(JS::Realm& realm, String const& script_url, WorkerOptions const& options)
{
auto& window = as<HTML::Window>(realm.global_object());
return Worker::create(script_url, options, window.associated_document());

View file

@ -3,12 +3,12 @@
#import <HTML/AbstractWorker.idl>
#import <HTML/MessagePort.idl>
#import <Fetch/Request.idl>
#import <TrustedTypes/TrustedScriptURL.idl>
// https://html.spec.whatwg.org/multipage/workers.html#worker
[Exposed=(Window,DedicatedWorker,SharedWorker)]
interface Worker : EventTarget {
constructor((TrustedScriptURL or Utf16USVString) scriptURL, optional WorkerOptions options = {});
// FIXME: "DOMString scriptURL" should be "(TrustedScriptURL or USVString) scriptURL".
constructor(DOMString scriptURL, optional WorkerOptions options = {});
undefined terminate();
undefined postMessage(any message, sequence<object> transfer);

View file

@ -1827,10 +1827,7 @@ CSSPixels FormattingContext::box_baseline(Box const& box) const
}
}
auto const& overflow_x = box.computed_values().overflow_x();
auto const& overflow_y = box.computed_values().overflow_y();
if (!box_state.line_boxes.is_empty() && overflow_x == CSS::Overflow::Visible && overflow_y == CSS::Overflow::Visible)
if (!box_state.line_boxes.is_empty())
return box_state.margin_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline();
if (auto const* child_box = box_child_to_derive_baseline_from(box)) {
return box_state.margin_box_top() + box_state.offset.y() + box_baseline(*child_box);

View file

@ -18,9 +18,6 @@
#include <LibWeb/ServiceWorker/ServiceWorkerContainer.h>
#include <LibWeb/ServiceWorker/ServiceWorkerRegistration.h>
#include <LibWeb/StorageAPI/StorageKey.h>
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
#include <LibWeb/TrustedTypes/TrustedScriptURL.h>
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
namespace Web::ServiceWorker {
@ -52,7 +49,7 @@ GC::Ref<ServiceWorkerContainer> ServiceWorkerContainer::create(JS::Realm& realm)
}
// https://w3c.github.io/ServiceWorker/#navigator-service-worker-register
GC::Ref<WebIDL::Promise> ServiceWorkerContainer::register_(TrustedTypes::TrustedScriptURLOrString script_url, RegistrationOptions const& options)
GC::Ref<WebIDL::Promise> ServiceWorkerContainer::register_(String script_url, RegistrationOptions const& options)
{
auto& realm = this->realm();
// Note: The register(scriptURL, options) method creates or updates a service worker registration for the given scope url.
@ -62,21 +59,15 @@ GC::Ref<WebIDL::Promise> ServiceWorkerContainer::register_(TrustedTypes::Trusted
// 1. Let p be a promise.
auto p = WebIDL::create_promise(realm);
// 2. Set scriptURL to the result of invoking Get Trusted Type compliant string with TrustedScriptURL,
// FIXME: 2. Set scriptURL to the result of invoking Get Trusted Type compliant string with TrustedScriptURL,
// this's relevant global object, scriptURL, "ServiceWorkerContainer register", and "script".
auto const compliant_script_url = MUST(TrustedTypes::get_trusted_type_compliant_string(
TrustedTypes::TrustedTypeName::TrustedScriptURL,
HTML::relevant_global_object(*this),
script_url,
TrustedTypes::InjectionSink::ServiceWorkerContainerregister,
TrustedTypes::Script.to_string()));
// 3 Let client be this's service worker client.
auto client = m_service_worker_client;
// 4. Let scriptURL be the result of parsing scriptURL with this's relevant settings objects API base URL.
auto base_url = HTML::relevant_settings_object(*this).api_base_url();
auto parsed_script_url = DOMURL::parse(compliant_script_url.to_utf8_but_should_be_ported_to_utf16(), base_url);
auto parsed_script_url = DOMURL::parse(script_url, base_url);
// 5. Let scopeURL be null.
Optional<URL::URL> scope_url;

View file

@ -10,8 +10,6 @@
#include <LibWeb/Bindings/ServiceWorkerRegistrationPrototype.h>
#include <LibWeb/Bindings/WorkerPrototype.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/TrustedTypes/TrustedScript.h>
#include <LibWeb/TrustedTypes/TrustedScriptURL.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#include <LibWeb/WebIDL/Promise.h>
@ -36,7 +34,7 @@ public:
[[nodiscard]] static GC::Ref<ServiceWorkerContainer> create(JS::Realm& realm);
virtual ~ServiceWorkerContainer() override;
GC::Ref<WebIDL::Promise> register_(TrustedTypes::TrustedScriptURLOrString script_url, RegistrationOptions const& options);
GC::Ref<WebIDL::Promise> register_(String script_url, RegistrationOptions const& options);
GC::Ref<WebIDL::Promise> get_registration(String const& client_url);

View file

@ -2,7 +2,6 @@
#import <DOM/EventHandler.idl>
#import <HTML/Worker.idl>
#import <ServiceWorker/ServiceWorkerRegistration.idl>
#import <TrustedTypes/TrustedScriptURL.idl>
// https://w3c.github.io/ServiceWorker/#serviceworkercontainer-interface
[SecureContext, Exposed=(Window,Worker)]
@ -10,7 +9,8 @@ interface ServiceWorkerContainer : EventTarget {
[FIXME] readonly attribute ServiceWorker? controller;
[FIXME] readonly attribute Promise<ServiceWorkerRegistration> ready;
[NewObject, ImplementedAs=register_] Promise<ServiceWorkerRegistration> register((TrustedScriptURL or Utf16USVString) scriptURL, optional RegistrationOptions options = {});
// FIXME: [NewObject] Promise<ServiceWorkerRegistration> register((TrustedScriptURL or USVString) scriptURL, optional RegistrationOptions options = {});
[NewObject, ImplementedAs=register_] Promise<ServiceWorkerRegistration> register(USVString scriptURL, optional RegistrationOptions options = {});
[NewObject] Promise<(ServiceWorkerRegistration or undefined)> getRegistration(optional USVString clientURL = "");
[FIXME, NewObject] Promise<FrozenArray<ServiceWorkerRegistration>> getRegistrations();

View file

@ -16,23 +16,18 @@ namespace Web::TrustedTypes {
__ENUMERATE_INJECTION_SINKS(Element##attribute_name, "Element " #attribute_name)
// https://w3c.github.io/trusted-types/dist/spec/#injection-sink
#define ENUMERATE_INJECTION_SINKS \
__ENUMERATE_INJECTION_SINKS(Documentwrite, "Document write") \
__ENUMERATE_INJECTION_SINKS(Documentwriteln, "Document writeln") \
__ENUMERATE_INJECTION_SINKS(DocumentexecCommand, "Document execCommand") \
__ENUMERATE_INJECTION_SINKS(Function, "Function") \
__ENUMERATE_INJECTION_SINKS(HTMLIFrameElementsrcdoc, "HTMLIFrameElement srcdoc") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementinnerText, "HTMLScriptElement innerText") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementsrc, "HTMLScriptElement src") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementtext, "HTMLScriptElement text") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementtextContent, "HTMLScriptElement textContent") \
__ENUMERATE_INJECTION_SINKS(Locationhref, "Location href") \
__ENUMERATE_INJECTION_SINKS(RangecreateContextualFragment, "Range createContextualFragment") \
__ENUMERATE_INJECTION_SINKS(ServiceWorkerContainerregister, "ServiceWorkerContainer register") \
__ENUMERATE_INJECTION_SINKS(SharedWorkerconstructor, "SharedWorker constructor") \
__ENUMERATE_INJECTION_SINKS(SVGScriptElementhref, "SVGScriptElement href") \
__ENUMERATE_INJECTION_SINKS(Workerconstructor, "Worker constructor") \
ENUMERATE_GLOBAL_EVENT_HANDLERS(EVENT_HANDLERS_INJECTION_SINKS) \
#define ENUMERATE_INJECTION_SINKS \
__ENUMERATE_INJECTION_SINKS(Documentwrite, "Document write") \
__ENUMERATE_INJECTION_SINKS(Documentwriteln, "Document writeln") \
__ENUMERATE_INJECTION_SINKS(Function, "Function") \
__ENUMERATE_INJECTION_SINKS(HTMLIFrameElementsrcdoc, "HTMLIFrameElement srcdoc") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementinnerText, "HTMLScriptElement innerText") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementsrc, "HTMLScriptElement src") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementtext, "HTMLScriptElement text") \
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementtextContent, "HTMLScriptElement textContent") \
__ENUMERATE_INJECTION_SINKS(Locationhref, "Location href") \
__ENUMERATE_INJECTION_SINKS(SVGScriptElementhref, "SVGScriptElement href") \
ENUMERATE_GLOBAL_EVENT_HANDLERS(EVENT_HANDLERS_INJECTION_SINKS) \
ENUMERATE_WINDOW_EVENT_HANDLERS(EVENT_HANDLERS_INJECTION_SINKS)
enum class InjectionSink {

View file

@ -12,8 +12,6 @@
namespace Web::TrustedTypes {
using TrustedHTMLOrString = Variant<GC::Root<TrustedHTML>, Utf16String>;
class TrustedHTML final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(TrustedHTML, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(TrustedHTML);

View file

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
CSS Reference Case
</title>
<link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-align/#baseline-export">
<style>
.container {
/* In this reference case, we leave 'overflow' at its initial value. */
height: 50px;
width: 100px;
border-style: solid;
border-width: 2px 3px 4px 5px;
padding: 4px 5px 7px 8px;
margin: 1px 2px 3px 4px;
}
.inline-block {
display: inline-block;
}
.inline-flex {
display: inline-flex;
}
.inline-grid {
display: inline-grid;
}
</style>
</head>
<body>
Test passes if the a/b text aligns with the bottom margin-edge of the "block"
rect and baseline-aligns with the "flex" and "grid" text.
<br><br>
<!-- Note: for this first "inline-block" case, we take the inner text out of
flow, to force the inline-block to synthesize its baseline from its
margin box. (This is how the corresponding piece of the testcase is
supposed to render). -->
a
<div class="container inline-block">
<div style="position: absolute">block</div>
</div>
b
<br>
a
<div class="container inline-flex">flex</div>
b
<br>
a
<div class="container inline-grid">grid</div>
b
</body>
</html>

View file

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
CSS Test: baseline of scrollable element should be taken from its
contents. (Except if the scrollable element is an inline-block, which gets
baseline from its margin-box.)
</title>
<link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-align/#baseline-export">
<link rel="match" href="../../../../expected/wpt-import/css/css-align/reference/baseline-of-scrollable-1-ref.html">
<style>
.container {
overflow: hidden;
height: 50px;
width: 100px;
border-style: solid;
border-width: 2px 3px 4px 5px;
padding: 4px 5px 7px 8px;
margin: 1px 2px 3px 4px;
}
.inline-block {
display: inline-block;
}
.inline-flex {
display: inline-flex;
}
.inline-grid {
display: inline-grid;
}
</style>
</head>
<body>
Test passes if the a/b text aligns with the bottom margin-edge of the "block"
rect and baseline-aligns with the "flex" and "grid" text.
<br><br>
<!-- Note: for this first "inline-block" case, the element's baseline is
synthesized from its margin box. For the other cases, the element's
baseline is taken from its contents, i.e. the text inside of it. -->
a
<div class="container inline-block">block</div>
b
<br>
a
<div class="container inline-flex">flex</div>
b
<br>
a
<div class="container inline-grid">grid</div>
b
</body>
</html>

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 69 tests
64 Pass
5 Fail
65 Pass
4 Fail
Pass Can set 'cursor' to CSS-wide keywords: initial
Pass Can set 'cursor' to CSS-wide keywords: inherit
Pass Can set 'cursor' to CSS-wide keywords: unset
@ -67,7 +67,7 @@ Pass Setting 'cursor' to a flexible length: -3.14fr throws TypeError
Fail Setting 'cursor' to a number: 0 throws TypeError
Fail Setting 'cursor' to a number: -3.14 throws TypeError
Fail Setting 'cursor' to a number: 3.14 throws TypeError
Fail Setting 'cursor' to a number: calc(2 + 3) throws TypeError
Pass Setting 'cursor' to a number: calc(2 + 3) throws TypeError
Pass Setting 'cursor' to a transform: translate(50%, 50%) throws TypeError
Pass Setting 'cursor' to a transform: perspective(10em) throws TypeError
Pass Setting 'cursor' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 32 tests
29 Pass
3 Fail
26 Pass
6 Fail
Pass Can set 'line-height' to CSS-wide keywords: initial
Pass Can set 'line-height' to CSS-wide keywords: inherit
Pass Can set 'line-height' to CSS-wide keywords: unset
@ -13,15 +13,15 @@ Pass Can set 'line-height' to the 'normal' keyword: normal
Pass Can set 'line-height' to a length: 0px
Pass Can set 'line-height' to a length: -3.14em
Pass Can set 'line-height' to a length: 3.14cm
Pass Can set 'line-height' to a length: calc(0px + 0em)
Fail Can set 'line-height' to a length: calc(0px + 0em)
Fail Can set 'line-height' to a number: 0
Fail Can set 'line-height' to a number: -3.14
Pass Can set 'line-height' to a number: 3.14
Pass Can set 'line-height' to a number: calc(2 + 3)
Fail Can set 'line-height' to a number: calc(2 + 3)
Pass Can set 'line-height' to a percent: 0%
Pass Can set 'line-height' to a percent: -3.14%
Pass Can set 'line-height' to a percent: 3.14%
Pass Can set 'line-height' to a percent: calc(0% + 0%)
Fail Can set 'line-height' to a percent: calc(0% + 0%)
Pass Setting 'line-height' to a time: 0s throws TypeError
Pass Setting 'line-height' to a time: -3.14ms throws TypeError
Pass Setting 'line-height' to a time: 3.14s throws TypeError

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 161 tests
152 Pass
9 Fail
144 Pass
17 Fail
Pass Can set 'margin-top' to CSS-wide keywords: initial
Pass Can set 'margin-top' to CSS-wide keywords: inherit
Pass Can set 'margin-top' to CSS-wide keywords: unset
@ -13,11 +13,11 @@ Pass Can set 'margin-top' to the 'auto' keyword: auto
Pass Can set 'margin-top' to a percent: 0%
Pass Can set 'margin-top' to a percent: -3.14%
Pass Can set 'margin-top' to a percent: 3.14%
Pass Can set 'margin-top' to a percent: calc(0% + 0%)
Fail Can set 'margin-top' to a percent: calc(0% + 0%)
Pass Can set 'margin-top' to a length: 0px
Pass Can set 'margin-top' to a length: -3.14em
Pass Can set 'margin-top' to a length: 3.14cm
Pass Can set 'margin-top' to a length: calc(0px + 0em)
Fail Can set 'margin-top' to a length: calc(0px + 0em)
Pass Setting 'margin-top' to a time: 0s throws TypeError
Pass Setting 'margin-top' to a time: -3.14ms throws TypeError
Pass Setting 'margin-top' to a time: 3.14s throws TypeError
@ -45,11 +45,11 @@ Pass Can set 'margin-left' to the 'auto' keyword: auto
Pass Can set 'margin-left' to a percent: 0%
Pass Can set 'margin-left' to a percent: -3.14%
Pass Can set 'margin-left' to a percent: 3.14%
Pass Can set 'margin-left' to a percent: calc(0% + 0%)
Fail Can set 'margin-left' to a percent: calc(0% + 0%)
Pass Can set 'margin-left' to a length: 0px
Pass Can set 'margin-left' to a length: -3.14em
Pass Can set 'margin-left' to a length: 3.14cm
Pass Can set 'margin-left' to a length: calc(0px + 0em)
Fail Can set 'margin-left' to a length: calc(0px + 0em)
Pass Setting 'margin-left' to a time: 0s throws TypeError
Pass Setting 'margin-left' to a time: -3.14ms throws TypeError
Pass Setting 'margin-left' to a time: 3.14s throws TypeError
@ -77,11 +77,11 @@ Pass Can set 'margin-right' to the 'auto' keyword: auto
Pass Can set 'margin-right' to a percent: 0%
Pass Can set 'margin-right' to a percent: -3.14%
Pass Can set 'margin-right' to a percent: 3.14%
Pass Can set 'margin-right' to a percent: calc(0% + 0%)
Fail Can set 'margin-right' to a percent: calc(0% + 0%)
Pass Can set 'margin-right' to a length: 0px
Pass Can set 'margin-right' to a length: -3.14em
Pass Can set 'margin-right' to a length: 3.14cm
Pass Can set 'margin-right' to a length: calc(0px + 0em)
Fail Can set 'margin-right' to a length: calc(0px + 0em)
Pass Setting 'margin-right' to a time: 0s throws TypeError
Pass Setting 'margin-right' to a time: -3.14ms throws TypeError
Pass Setting 'margin-right' to a time: 3.14s throws TypeError
@ -109,11 +109,11 @@ Pass Can set 'margin-bottom' to the 'auto' keyword: auto
Pass Can set 'margin-bottom' to a percent: 0%
Pass Can set 'margin-bottom' to a percent: -3.14%
Pass Can set 'margin-bottom' to a percent: 3.14%
Pass Can set 'margin-bottom' to a percent: calc(0% + 0%)
Fail Can set 'margin-bottom' to a percent: calc(0% + 0%)
Pass Can set 'margin-bottom' to a length: 0px
Pass Can set 'margin-bottom' to a length: -3.14em
Pass Can set 'margin-bottom' to a length: 3.14cm
Pass Can set 'margin-bottom' to a length: calc(0px + 0em)
Fail Can set 'margin-bottom' to a length: calc(0px + 0em)
Pass Setting 'margin-bottom' to a time: 0s throws TypeError
Pass Setting 'margin-bottom' to a time: -3.14ms throws TypeError
Pass Setting 'margin-bottom' to a time: 3.14s throws TypeError

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 124 tests
116 Pass
8 Fail
108 Pass
16 Fail
Pass Can set 'padding-top' to CSS-wide keywords: initial
Pass Can set 'padding-top' to CSS-wide keywords: inherit
Pass Can set 'padding-top' to CSS-wide keywords: unset
@ -12,11 +12,11 @@ Fail Can set 'padding-top' to var() references: var(--A)
Pass Can set 'padding-top' to a percent: 0%
Fail Can set 'padding-top' to a percent: -3.14%
Pass Can set 'padding-top' to a percent: 3.14%
Pass Can set 'padding-top' to a percent: calc(0% + 0%)
Fail Can set 'padding-top' to a percent: calc(0% + 0%)
Pass Can set 'padding-top' to a length: 0px
Pass Can set 'padding-top' to a length: -3.14em
Pass Can set 'padding-top' to a length: 3.14cm
Pass Can set 'padding-top' to a length: calc(0px + 0em)
Fail Can set 'padding-top' to a length: calc(0px + 0em)
Pass Setting 'padding-top' to a time: 0s throws TypeError
Pass Setting 'padding-top' to a time: -3.14ms throws TypeError
Pass Setting 'padding-top' to a time: 3.14s throws TypeError
@ -43,11 +43,11 @@ Fail Can set 'padding-left' to var() references: var(--A)
Pass Can set 'padding-left' to a percent: 0%
Fail Can set 'padding-left' to a percent: -3.14%
Pass Can set 'padding-left' to a percent: 3.14%
Pass Can set 'padding-left' to a percent: calc(0% + 0%)
Fail Can set 'padding-left' to a percent: calc(0% + 0%)
Pass Can set 'padding-left' to a length: 0px
Pass Can set 'padding-left' to a length: -3.14em
Pass Can set 'padding-left' to a length: 3.14cm
Pass Can set 'padding-left' to a length: calc(0px + 0em)
Fail Can set 'padding-left' to a length: calc(0px + 0em)
Pass Setting 'padding-left' to a time: 0s throws TypeError
Pass Setting 'padding-left' to a time: -3.14ms throws TypeError
Pass Setting 'padding-left' to a time: 3.14s throws TypeError
@ -74,11 +74,11 @@ Fail Can set 'padding-right' to var() references: var(--A)
Pass Can set 'padding-right' to a percent: 0%
Fail Can set 'padding-right' to a percent: -3.14%
Pass Can set 'padding-right' to a percent: 3.14%
Pass Can set 'padding-right' to a percent: calc(0% + 0%)
Fail Can set 'padding-right' to a percent: calc(0% + 0%)
Pass Can set 'padding-right' to a length: 0px
Pass Can set 'padding-right' to a length: -3.14em
Pass Can set 'padding-right' to a length: 3.14cm
Pass Can set 'padding-right' to a length: calc(0px + 0em)
Fail Can set 'padding-right' to a length: calc(0px + 0em)
Pass Setting 'padding-right' to a time: 0s throws TypeError
Pass Setting 'padding-right' to a time: -3.14ms throws TypeError
Pass Setting 'padding-right' to a time: 3.14s throws TypeError
@ -105,11 +105,11 @@ Fail Can set 'padding-bottom' to var() references: var(--A)
Pass Can set 'padding-bottom' to a percent: 0%
Fail Can set 'padding-bottom' to a percent: -3.14%
Pass Can set 'padding-bottom' to a percent: 3.14%
Pass Can set 'padding-bottom' to a percent: calc(0% + 0%)
Fail Can set 'padding-bottom' to a percent: calc(0% + 0%)
Pass Can set 'padding-bottom' to a length: 0px
Pass Can set 'padding-bottom' to a length: -3.14em
Pass Can set 'padding-bottom' to a length: 3.14cm
Pass Can set 'padding-bottom' to a length: calc(0px + 0em)
Fail Can set 'padding-bottom' to a length: calc(0px + 0em)
Pass Setting 'padding-bottom' to a time: 0s throws TypeError
Pass Setting 'padding-bottom' to a time: -3.14ms throws TypeError
Pass Setting 'padding-bottom' to a time: 3.14s throws TypeError

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 95 tests
89 Pass
6 Fail
83 Pass
12 Fail
Pass Can set 'width' to CSS-wide keywords: initial
Pass Can set 'width' to CSS-wide keywords: inherit
Pass Can set 'width' to CSS-wide keywords: unset
@ -13,11 +13,11 @@ Pass Can set 'width' to the 'auto' keyword: auto
Pass Can set 'width' to a percent: 0%
Fail Can set 'width' to a percent: -3.14%
Pass Can set 'width' to a percent: 3.14%
Pass Can set 'width' to a percent: calc(0% + 0%)
Fail Can set 'width' to a percent: calc(0% + 0%)
Pass Can set 'width' to a length: 0px
Pass Can set 'width' to a length: -3.14em
Pass Can set 'width' to a length: 3.14cm
Pass Can set 'width' to a length: calc(0px + 0em)
Fail Can set 'width' to a length: calc(0px + 0em)
Pass Setting 'width' to a time: 0s throws TypeError
Pass Setting 'width' to a time: -3.14ms throws TypeError
Pass Setting 'width' to a time: 3.14s throws TypeError
@ -44,11 +44,11 @@ Fail Can set 'min-width' to var() references: var(--A)
Pass Can set 'min-width' to a percent: 0%
Fail Can set 'min-width' to a percent: -3.14%
Pass Can set 'min-width' to a percent: 3.14%
Pass Can set 'min-width' to a percent: calc(0% + 0%)
Fail Can set 'min-width' to a percent: calc(0% + 0%)
Pass Can set 'min-width' to a length: 0px
Pass Can set 'min-width' to a length: -3.14em
Pass Can set 'min-width' to a length: 3.14cm
Pass Can set 'min-width' to a length: calc(0px + 0em)
Fail Can set 'min-width' to a length: calc(0px + 0em)
Pass Setting 'min-width' to a time: 0s throws TypeError
Pass Setting 'min-width' to a time: -3.14ms throws TypeError
Pass Setting 'min-width' to a time: 3.14s throws TypeError
@ -76,11 +76,11 @@ Pass Can set 'max-width' to the 'none' keyword: none
Pass Can set 'max-width' to a percent: 0%
Fail Can set 'max-width' to a percent: -3.14%
Pass Can set 'max-width' to a percent: 3.14%
Pass Can set 'max-width' to a percent: calc(0% + 0%)
Fail Can set 'max-width' to a percent: calc(0% + 0%)
Pass Can set 'max-width' to a length: 0px
Pass Can set 'max-width' to a length: -3.14em
Pass Can set 'max-width' to a length: 3.14cm
Pass Can set 'max-width' to a length: calc(0px + 0em)
Fail Can set 'max-width' to a length: calc(0px + 0em)
Pass Setting 'max-width' to a time: 0s throws TypeError
Pass Setting 'max-width' to a time: -3.14ms throws TypeError
Pass Setting 'max-width' to a time: 3.14s throws TypeError

View file

@ -1,8 +1,8 @@
Harness status: OK
Found 35 tests
Found 25 tests
29 Pass
19 Pass
6 Fail
Pass min(1em, 110px / 10px * 1px) should be used-value-equivalent to 10px
Pass max(10px, 110px / 10px * 1px) should be used-value-equivalent to 11px
@ -14,16 +14,6 @@ Pass calc(10em / 1em) should be used-value-equivalent to 10
Pass calc(10em / 1rem) should be used-value-equivalent to 10
Pass calc(10em / 1px) should be used-value-equivalent to 100
Pass calc(1px / 10em * NaN) should be used-value-equivalent to 0
Pass calc(10% / 1px) should be used-value-equivalent to 1
Pass calc(1% * 100% / 10%) should be used-value-equivalent to 10%
Pass calc(10% / 10%) should be used-value-equivalent to 1
Pass calc((10% * 1%) / 1px) should be used-value-equivalent to 10px
Pass calc(10% * 10% / 1px * 10deg / 1deg / 10px) should be used-value-equivalent to 1
Pass calc(10% * 10% / 1px * 1deg / 1deg) should be used-value-equivalent to 1px
Pass calc(1px * 2deg / 1deg) should be used-value-equivalent to 2px
Pass calc(1px * 3deg / 1deg / 1px) should be used-value-equivalent to 3
Pass e.style['width'] = "calc((1% * 1deg) / 1px)" should not set the property value
Pass e.style['width'] = "calc((1% * 1% * 1%) / 1px)" should not set the property value
Pass Property width value 'calc(1px * 10em / 0em)'
Pass Property width value 'calc(1px / 1px * 10em * infinity)'
Fail Property margin-left value 'calc(1px * 10em / -0em)'

View file

@ -1,8 +0,0 @@
Harness status: OK
Found 3 tests
3 Pass
Pass Create Worker via ScriptTestUrl
Pass Block Worker creation via string
Pass Create Worker via string with default policy.

View file

@ -1,6 +0,0 @@
Harness status: OK
Found 1 tests
1 Pass
Pass range.createContextualFragment assigned via policy (successful HTML transformation).

View file

@ -1,8 +0,0 @@
Harness status: OK
Found 3 tests
3 Pass
Pass Create SharedWorker via ScriptTestUrl
Pass Block SharedWorker creation via string
Pass Create SharedWorker via string with default policy.

View file

@ -1,10 +0,0 @@
Harness status: OK
Found 5 tests
5 Pass
Pass range.createContextualFragment assigned via policy (successful HTML transformation).
Pass `range.createContextualFragment(string)` throws.
Pass `range.createContextualFragment(null)` throws.
Pass `range.createContextualFragment(string)` assigned via default policy (successful HTML transformation).
Pass `range.createContextualFragment(null)` assigned via default policy does not throw.

View file

@ -5,7 +5,6 @@
<script src="../../resources/testharnessreport.js"></script>
<script src="../../css/support/numeric-testcommon.js"></script>
<script src="../../css/support/computed-testcommon.js"></script>
<script src="../support/parsing-testcommon.js"></script>
<style>
:root {
font-size: 10px;
@ -42,26 +41,6 @@ test_math_used("calc(10em / 1rem)", "10", {"prop": "z-index"});
test_math_used("calc(10em / 1px)", "100", {"prop": "z-index"});
test_math_used("calc(1px / 10em * NaN)", "0", {"prop": "z-index"});
// 10% -> 1px; 1px / 1px -> 1.
test_math_used("calc(10% / 1px)", "1", {"prop": "line-height"});
// 1% * 100% / 10% -> 10%.
test_math_used("calc(1% * 100% / 10%)", "10%", {"prop": "line-height"});
// 10% / 10% -> 1.
test_math_used("calc(10% / 10%)", "1", {"prop": "line-height"});
// 10% -> 1px; 1% -> 0.1px; 1px / 0.1px / 1px -> 10px.
test_math_used("calc((10% * 1%) / 1px)", "10px");
// 10% -> 1px; 1px * 1px / 1px * 10deg / 1deg / 10px -> 1.
test_math_used("calc(10% * 10% / 1px * 10deg / 1deg / 10px)", "1", {"prop": "line-height"});
// 10% -> 1px; 1px * 1px / 1px * 1deg / 1deg -> 1px.
test_math_used("calc(10% * 10% / 1px * 1deg / 1deg)", "1px", {"prop": "line-height"});
// 1px * 2deg / 1deg -> 2px.
test_math_used("calc(1px * 2deg / 1deg)", "2px", {"prop": "line-height"});
// 1px * 3deg / 1deg / 1px -> 3.
test_math_used("calc(1px * 3deg / 1deg / 1px)", "3", {"prop": "line-height"});
test_invalid_value("width", "calc((1% * 1deg) / 1px)");
test_invalid_value("width", "calc((1% * 1% * 1%) / 1px)");
testComputedValueGreaterOrLowerThan("width", "calc(1px * 10em / 0em)", REALLY_LARGE);
testComputedValueGreaterOrLowerThan("width", "calc(1px / 1px * 10em * infinity)", REALLY_LARGE);
testComputedValueGreaterOrLowerThan("margin-left", "calc(1px * 10em / -0em)", REALLY_LARGE_NEGATIVE);

View file

@ -1,52 +0,0 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<script>
const test_url = "support/WorkerGlobalScope-importScripts.https.js"
const trusted_url = trustedTypes.createPolicy("anythinggoes", {
createScriptURL: x => x}).createScriptURL(test_url);
const default_url = "support/WorkerGlobalScope-importScripts.potato.js"
test(() => {
try {
new Worker(trusted_url);
} catch (e) {
assert_unreached("Worker creation failed: " + e);
}
}, "Create Worker via ScriptTestUrl");
test(() => {
assert_throws_js(TypeError, () => new Worker(test_url));
}, "Block Worker creation via string");
// Tests with default policy.
let seenTrustedTypeName;
let seenSinkName;
function resetSeenArguments() {
seenTrustedTypeName = undefined;
seenSinkName = undefined;
}
trustedTypes.createPolicy("default", {
createScriptURL: (input, trustedTypeName, sinkName) => {
seenTrustedTypeName = trustedTypeName;
seenSinkName = sinkName;
return input.replace("potato", "https");
}
});
test(t => {
t.add_cleanup(resetSeenArguments);
new Worker(default_url);
assert_equals(seenTrustedTypeName, "TrustedScriptURL");
assert_equals(seenSinkName, "Worker constructor");
}, "Create Worker via string with default policy.");
</script>
</body>

View file

@ -1,15 +0,0 @@
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<body>
<script>
test(t => {
let p = createHTML_policy(window, 1);
let html = p.createHTML(INPUTS.HTML);
var range = document.createRange();
range.selectNodeContents(document.documentElement);
var result = range.createContextualFragment(html);
assert_equals(result.textContent, RESULTS.HTML);
}, "range.createContextualFragment assigned via policy (successful HTML transformation).");
</script>

View file

@ -1,52 +0,0 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<script>
const test_url = "support/WorkerGlobalScope-importScripts.https.js"
const trusted_url = trustedTypes.createPolicy("anythinggoes", {
createScriptURL: x => x}).createScriptURL(test_url);
const default_url = "support/WorkerGlobalScope-importScripts.potato.js"
test(() => {
try {
new SharedWorker(trusted_url);
} catch (e) {
assert_unreached("SharedWorker creation failed: " + e);
}
}, "Create SharedWorker via ScriptTestUrl");
test(() => {
assert_throws_js(TypeError, () => new SharedWorker(test_url));
}, "Block SharedWorker creation via string");
// Tests with default policy.
let seenTrustedTypeName;
let seenSinkName;
function resetSeenArguments() {
seenTrustedTypeName = undefined;
seenSinkName = undefined;
}
trustedTypes.createPolicy("default", {
createScriptURL: (input, trustedTypeName, sinkName) => {
seenTrustedTypeName = trustedTypeName;
seenSinkName = sinkName;
return input.replace("potato", "https");
}
});
test(t => {
t.add_cleanup(resetSeenArguments);
new SharedWorker(default_url);
assert_equals(seenTrustedTypeName, "TrustedScriptURL");
assert_equals(seenSinkName, "SharedWorker constructor");
}, "Create SharedWorker via string with default policy.");
</script>
</body>

View file

@ -1,59 +0,0 @@
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
<body>
<script>
// TrustedHTML assignments do not throw.
test(t => {
let p = createHTML_policy(window, 1);
let html = p.createHTML(INPUTS.HTML);
var range = document.createRange();
range.selectNodeContents(document.documentElement);
var result = range.createContextualFragment(html);
assert_equals(result.textContent, RESULTS.HTML);
}, "range.createContextualFragment assigned via policy (successful HTML transformation).");
// String assignments throw.
test(t => {
var range = document.createRange();
range.selectNodeContents(document.documentElement);
assert_throws_js(TypeError, _ => {
var result = range.createContextualFragment("A string");
});
}, "`range.createContextualFragment(string)` throws.");
// Null assignment throws.
test(t => {
var range = document.createRange();
range.selectNodeContents(document.documentElement);
assert_throws_js(TypeError, _ => {
var result = range.createContextualFragment(null);
});
}, "`range.createContextualFragment(null)` throws.");
// After default policy creation string assignment implicitly calls createHTML
test(t => {
let p = window.trustedTypes.createPolicy("default", { createHTML:
(value, _, sink) => {
assert_equals(sink, "Range createContextualFragment");
return createHTMLJS(value);
}
});
var range = document.createRange();
range.selectNodeContents(document.documentElement);
var result = range.createContextualFragment(INPUTS.HTML);
assert_equals(result.textContent, RESULTS.HTML);
}, "`range.createContextualFragment(string)` assigned via default policy (successful HTML transformation).");
// After default policy creation null assignment implicitly calls createHTML
test(t => {
var range = document.createRange();
range.selectNodeContents(document.documentElement);
var result = range.createContextualFragment(null);
assert_equals(result.textContent, "null");
}, "`range.createContextualFragment(null)` assigned via default policy does not throw.");
</script>