Skip to content
Permalink
Browse files
SUMMARY element: click() for invisible SUMMARY should toggle DETAILS …
…element

SUMMARY element: click() for invisible SUMMARY should toggle DETAILS element

https://bugs.webkit.org/show_bug.cgi?id=245937

Reviewed by Tim Nguyen.

Merge - https://chromium.googlesource.com/chromium/src.git/+/c162ebcbfa71bfbdd8e3fdba2137c382f752b4b2

This is to align Webkit behavior with Gecko (Firefox) and Blink (Chrome).

We had unreasonable renderer() existence check for activate event handling. It is not defined by the standard.

* Source/WebCore/html/HTMLSummaryElement.cpp:
(HTMLSummaryElement::supportsFocus): Remove "renderer" condition
(HTMLSummaryElement::defaultEventHandler): Simplified and removed "renderer" condition
* LayoutTests/fast/html/summary-invisible-click.html: Added Test Case
* LayoutTests/fast/html/summary-invisible-click-expected.txt: Added Test Case Expectations
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-summary-element/activation-behavior-expected.txt: Updated Test Expectations

Canonical link: https://commits.webkit.org/255073@main
  • Loading branch information
Ahmad-S792 authored and nt1m committed Oct 2, 2022
1 parent b0d582e commit 19b515f0605328883ede9f5dcae2c07d571dd209
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
@@ -0,0 +1,3 @@

PASS click() on hidden SUMMARY should toggle DETAILS.

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<details style="display:none">
<summary>Click me</summary>
Blah, blah, ...
</detail>

<script>
test(() => {
const summary = document.querySelector('summary');
const details = document.querySelector('details');
assert_false(details.open);
summary.click();
assert_true(details.open);
summary.click();
assert_false(details.open);
}, 'click() on hidden SUMMARY should toggle DETAILS.');
</script>
@@ -1,18 +1,26 @@

FAIL Should open a closed details if all conditions are met assert_equals: After activation: expected open to be true expected true but got false
FAIL Should close an open details if all conditions are met assert_equals: After activation: expected open to be false expected false but got true
FAIL Should open a closed details even if the details is not being rendered assert_equals: After activation: expected open to be true expected true but got false
FAIL Should open a closed details even if the summary is not being rendered assert_equals: After activation: expected open to be true expected true but got false
FAIL Should open a closed details if a span element precedes the summary assert_equals: After activation: expected open to be true expected true but got false
PASS Should open a closed details if all conditions are met
PASS Should close an open details if all conditions are met
PASS Should open a closed details even if the details is not being rendered
PASS Should open a closed details even if the summary is not being rendered
PASS Should open a closed details if a span element precedes the summary
PASS Should stay closed if another summary element precedes the summary
FAIL Should open a closed details if another summary element *nested inside a span* precedes the summary assert_equals: After activation: expected open to be true expected true but got false
PASS Should open a closed details if another summary element *nested inside a span* precedes the summary
PASS Should stay closed if the summary element is nested inside a span element
FAIL toggle events should be coalesced even when using the activation behavior of a summary assert_equals: Expected toggle to fire exactly once expected 1 but got 0
PASS toggle events should be coalesced even when using the activation behavior of a summary
Summary
Contents

Summary
Contents

Summary
Contents

Summary 1
Summary 1
Summary 2
Contents

Summary
Contents
@@ -116,7 +116,7 @@ bool HTMLSummaryElement::supportsFocus() const

void HTMLSummaryElement::defaultEventHandler(Event& event)
{
if (isActiveSummary() && renderer()) {
if (isActiveSummary()) {
auto& eventNames = WebCore::eventNames();
if (event.type() == eventNames.DOMActivateEvent && !isClickableControl(event.target())) {
if (RefPtr<HTMLDetailsElement> details = detailsElement())
@@ -158,10 +158,7 @@ void HTMLSummaryElement::defaultEventHandler(Event& event)

bool HTMLSummaryElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
if (isActiveSummary() && renderer())
return true;

return HTMLElement::willRespondToMouseClickEventsWithEditability(editability);
return isActiveSummary() || HTMLElement::willRespondToMouseClickEventsWithEditability(editability);
}

}

0 comments on commit 19b515f

Please sign in to comment.