Explorar el Código

LibWeb: Add methods to Window that must do nothing

This change adds the `captureEvents()` and `releaseEvents()` methods to
the window object. These methods are obsolete, but are still included
in the HTML specification, which says they must do nothing.
Tim Ledbetter hace 1 año
padre
commit
88f3145f8a

+ 2 - 0
Tests/LibWeb/Text/expected/DOM/Window-methods-that-must-do-nothing.txt

@@ -0,0 +1,2 @@
+window.captureEvents() returns undefined: true
+window.releaseEvents() returns undefined: true

+ 8 - 0
Tests/LibWeb/Text/input/DOM/Window-methods-that-must-do-nothing.html

@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script>
+    test(() => {
+        println(`window.captureEvents() returns undefined: ${window.captureEvents() === undefined}`);
+        println(`window.releaseEvents() returns undefined: ${window.releaseEvents() === undefined}`);
+    });
+</script>

+ 12 - 0
Userland/Libraries/LibWeb/HTML/Window.cpp

@@ -1600,6 +1600,18 @@ JS::NonnullGCPtr<Crypto::Crypto> Window::crypto()
     return JS::NonnullGCPtr { *m_crypto };
 }
 
+// https://html.spec.whatwg.org/multipage/obsolete.html#dom-window-captureevents
+void Window::capture_events()
+{
+    // Do nothing.
+}
+
+// https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-releaseevents
+void Window::release_events()
+{
+    // Do nothing.
+}
+
 // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation
 JS::NonnullGCPtr<Navigation> Window::navigation()
 {

+ 3 - 0
Userland/Libraries/LibWeb/HTML/Window.h

@@ -202,6 +202,9 @@ public:
 
     [[nodiscard]] JS::NonnullGCPtr<Crypto::Crypto> crypto();
 
+    void capture_events();
+    void release_events();
+
     [[nodiscard]] JS::NonnullGCPtr<CustomElementRegistry> custom_elements();
 
     HighResolutionTime::DOMHighResTimeStamp get_last_activation_timestamp() const { return m_last_activation_timestamp; }

+ 3 - 0
Userland/Libraries/LibWeb/HTML/Window.idl

@@ -110,6 +110,9 @@ interface Window : EventTarget {
 
     // https://w3c.github.io/webcrypto/#crypto-interface
     [SameObject] readonly attribute Crypto crypto;
+
+    undefined captureEvents();
+    undefined releaseEvents();
 };
 Window includes AnimationFrameProvider;
 Window includes GlobalEventHandlers;