diff --git a/Libraries/LibWeb/CSS/CSSPageRule.cpp b/Libraries/LibWeb/CSS/CSSPageRule.cpp index 059b5be1a6d..6c34d572faa 100644 --- a/Libraries/LibWeb/CSS/CSSPageRule.cpp +++ b/Libraries/LibWeb/CSS/CSSPageRule.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -45,12 +46,17 @@ String CSSPageRule::selector_text() const } // https://drafts.csswg.org/cssom/#dom-csspagerule-selectortext -void CSSPageRule::set_selector_text(StringView) +void CSSPageRule::set_selector_text(StringView text) { - // FIXME: On setting the selectorText attribute these steps must be run: - // 1. Run the parse a list of CSS page selectors algorithm on the given value. - // 2. If the algorithm returns a non-null value replace the associated selector list with the returned value. - // 3. Otherwise, if the algorithm returns a null value, do nothing. + // On setting the selectorText attribute these steps must be run: + // 1. Run the parse a list of CSS page selectors algorithm on the given value. + auto page_selector_list = parse_page_selector_list(Parser::ParsingParams {}, text); + + // 2. If the algorithm returns a non-null value replace the associated selector list with the returned value. + if (page_selector_list.has_value()) + m_selectors = page_selector_list.release_value(); + + // 3. Otherwise, if the algorithm returns a null value, do nothing. } // https://drafts.csswg.org/cssom/#ref-for-csspagerule diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-pagerule.txt b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-pagerule.txt new file mode 100644 index 00000000000..c061b9d43a8 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-pagerule.txt @@ -0,0 +1,27 @@ +Harness status: OK + +Found 22 tests + +22 Pass +Pass Sanity checks +Pass Page selector is initially the empty string +Pass Page selector 'cssText' is initially the @page { } +Pass Set selectorText to :left pseudo page +Pass Set cssText to :left pseudo page +Pass Set selectorText to named page +Pass Set cssText to named page +Pass Set selectorText to named page with :first pseudo page +Pass Set cssText to named page with :first pseudo page +Pass Set selectorText to named page with case insensitive :first pseudo page +Pass Set cssText to named page with case insensitive :first pseudo page +Pass Set selectorText to named page with two :first pseudo page +Pass Set cssText to named page with two :first pseudo page +Pass Set selectorText to named page with pseudo pages of :first, :left, :right, :first in order. +Pass Set cssText to named page with pseudo pages of :first, :left, :right, :first in order. +Pass Cannot set selectorText to named page with pseudo, whitespace between +Pass Cannot set cssText to named page with pseudo, whitespace between - return default @page { } +Pass Cannot set selectorText to two pseudos, whitespace between +Pass Cannot set cssText to two pseudos, whitespace between - return default @page { } +Pass Cannot set selectorText to invalid pseudo page +Pass Cannot set cssText to invalid pseudo page - return default @page { } +Pass Set selectorText to named page after rule was removed \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/cssom/cssom-pagerule.html b/Tests/LibWeb/Text/input/wpt-import/css/cssom/cssom-pagerule.html new file mode 100644 index 00000000000..614db53f9d7 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/cssom/cssom-pagerule.html @@ -0,0 +1,130 @@ + +CSSOM: CSSPageRule tests + + + + +