From 2716113c633fac7657ffe6432a8c83dd31f8e427 Mon Sep 17 00:00:00 2001 From: Gregory Pappas Date: Sun, 21 Jul 2024 00:23:40 +0000 Subject: [PATCH] Bug 1898833 - Support oncontentvisibilityautostatechange event handler r=emilio,smaug Spec PR: https://github.com/whatwg/html/pull/10364 Differential Revision: https://phabricator.services.mozilla.com/D217187 --- dom/events/EventNameList.h | 2 ++ dom/tests/mochitest/general/test_interfaces.js | 2 ++ dom/webidl/EventHandler.webidl | 1 + ...ontent-visibility-auto-state-changed.html.ini | 16 ---------------- .../trusted-types-event-handlers.html.ini | 3 +++ .../content-visibility-auto-state-changed.html | 12 ++++++++++++ widget/EventMessageList.h | 3 +++ xpcom/ds/StaticAtoms.py | 1 + 8 files changed, 24 insertions(+), 16 deletions(-) delete mode 100644 testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-auto-state-changed.html.ini diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 391bf6e975113..593b6917b0358 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -167,6 +167,8 @@ EVENT(click, ePointerClick, EventNameType_All, ? ePointerEventClass : eMouseEventClass) EVENT(close, eClose, EventNameType_HTMLXUL, eBasicEventClass) +EVENT(contentvisibilityautostatechange, eContentVisibilityAutoStateChange, + EventNameType_All, eBasicEventClass) EVENT(contextmenu, eContextMenu, EventNameType_HTMLXUL | EventNameType_SVGGraphic, StaticPrefs::dom_w3c_pointer_events_dispatch_click_as_pointer_event() diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index 10b8bc2ed317d..b7d7042a00b0f 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -1679,6 +1679,8 @@ let interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "onclose", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! + { name: "oncontentvisibilityautostatechange", insecureContext: true }, + // IMPORTANT: Do not change this list without review from a DOM peer! { name: "oncontextlost", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "oncontextmenu", insecureContext: true }, diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl index c88e4f0422cea..fb949f5cf2e41 100644 --- a/dom/webidl/EventHandler.webidl +++ b/dom/webidl/EventHandler.webidl @@ -39,6 +39,7 @@ interface mixin GlobalEventHandlers { attribute EventHandler onchange; attribute EventHandler onclick; attribute EventHandler onclose; + attribute EventHandler oncontentvisibilityautostatechange; attribute EventHandler oncontextlost; attribute EventHandler oncontextmenu; attribute EventHandler oncontextrestored; diff --git a/testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-auto-state-changed.html.ini b/testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-auto-state-changed.html.ini deleted file mode 100644 index 3ae60affb1143..0000000000000 --- a/testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-auto-state-changed.html.ini +++ /dev/null @@ -1,16 +0,0 @@ -[content-visibility-auto-state-changed.html] - expected: TIMEOUT - [ContentVisibilityAutoStateChange fires when relevant element gains `content-visibility:auto` (oncontentvisibilityautostatechange syntax)] - expected: TIMEOUT - - [ContentVisibilityAutoStateChange fires when not relevant element gains `content-visibility:auto`] - expected: NOTRUN - - [ContentVisibilityAutoStateChange content attribute test] - expected: NOTRUN - - [ContentVisibilityAutoStateChange fires when skipped] - expected: NOTRUN - - [ContentVisibilityAutoStateChange fires when not skipped] - expected: NOTRUN diff --git a/testing/web-platform/meta/trusted-types/trusted-types-event-handlers.html.ini b/testing/web-platform/meta/trusted-types/trusted-types-event-handlers.html.ini index 2a861396470ee..f534e335212ce 100644 --- a/testing/web-platform/meta/trusted-types/trusted-types-event-handlers.html.ini +++ b/testing/web-platform/meta/trusted-types/trusted-types-event-handlers.html.ini @@ -50,6 +50,9 @@ [Event handler div.onclose should be blocked.] expected: FAIL + [Event handler div.oncontentvisibilityautostatechange should be blocked.] + expected: FAIL + [Event handler div.oncontextmenu should be blocked.] expected: FAIL diff --git a/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-auto-state-changed.html b/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-auto-state-changed.html index 0333c052e4a2e..6a14470c0f4b1 100644 --- a/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-auto-state-changed.html +++ b/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-auto-state-changed.html @@ -24,16 +24,22 @@
+
@@ -83,6 +89,12 @@ assert_true(contentattrfired, "contentattrfired"); }, "ContentVisibilityAutoStateChange content attribute test"); + +promise_test(async t => { + await waitForAtLeastOneFrame(); + assert_true(contentattrfiredonsvg, "contentattrfiredonsvg"); +}, "ContentVisibilityAutoStateChange content attribute test on svg"); + promise_test(t => new Promise(async (resolve, reject) => { await new Promise((waited, _) => { requestAnimationFrame(() => requestAnimationFrame(waited)); diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 857c412bc8b38..94677ecc3919e 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -214,6 +214,9 @@ NS_EVENT_MESSAGE(ePageHide) NS_EVENT_MESSAGE(eContextLost) NS_EVENT_MESSAGE(eContextRestored) +// content-visibility events +NS_EVENT_MESSAGE(eContentVisibilityAutoStateChange) + // SVG events NS_EVENT_MESSAGE(eSVGLoad) NS_EVENT_MESSAGE(eSVGScroll) diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index 82c9e3ca64bfa..51c68a4d1a368 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -787,6 +787,7 @@ Atom("onCheckKeyPressEventModel", "onCheckKeyPressEventModel"), Atom("onclick", "onclick"), Atom("onclose", "onclose"), + Atom("oncontentvisibilityautostatechange", "oncontentvisibilityautostatechange"), Atom("oncommand", "oncommand"), Atom("oncommandupdate", "oncommandupdate"), Atom("oncomplete", "oncomplete"),