From 148154779aedcb8fcd48e77c5189610f01d7fa05 Mon Sep 17 00:00:00 2001 From: Lukas Lihotzki Date: Tue, 23 May 2023 18:18:39 +0200 Subject: [PATCH] Deprecate HtmlMenuItemElement and parts of HtmlMenuElement --- .../src/features/gen_HtmlMenuItemElement.rs | 15 +++++++ crates/web-sys/tests/wasm/html_element.rs | 8 ---- crates/web-sys/tests/wasm/main.rs | 8 ++-- crates/web-sys/tests/wasm/menu_element.rs | 20 +++++---- .../web-sys/tests/wasm/menu_item_element.rs | 43 ------------------- .../webidls/enabled/HTMLMenuElement.webidl | 18 +++++--- .../enabled/HTMLMenuItemElement.webidl | 6 ++- 7 files changed, 46 insertions(+), 72 deletions(-) delete mode 100644 crates/web-sys/tests/wasm/menu_item_element.rs diff --git a/crates/web-sys/src/features/gen_HtmlMenuItemElement.rs b/crates/web-sys/src/features/gen_HtmlMenuItemElement.rs index f0beb92644d..dd1f4d83267 100644 --- a/crates/web-sys/src/features/gen_HtmlMenuItemElement.rs +++ b/crates/web-sys/src/features/gen_HtmlMenuItemElement.rs @@ -11,7 +11,9 @@ extern "C" { #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] + #[deprecated(note = "Absent in all major browsers")] pub type HtmlMenuItemElement; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = type)] #[doc = "Getter for the `type` field of this object."] #[doc = ""] @@ -19,6 +21,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn type_(this: &HtmlMenuItemElement) -> String; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = type)] #[doc = "Setter for the `type` field of this object."] #[doc = ""] @@ -26,6 +29,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn set_type(this: &HtmlMenuItemElement, value: &str); + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = label)] #[doc = "Getter for the `label` field of this object."] #[doc = ""] @@ -33,6 +37,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn label(this: &HtmlMenuItemElement) -> String; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = label)] #[doc = "Setter for the `label` field of this object."] #[doc = ""] @@ -40,6 +45,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn set_label(this: &HtmlMenuItemElement, value: &str); + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = icon)] #[doc = "Getter for the `icon` field of this object."] #[doc = ""] @@ -47,6 +53,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn icon(this: &HtmlMenuItemElement) -> String; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = icon)] #[doc = "Setter for the `icon` field of this object."] #[doc = ""] @@ -54,6 +61,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn set_icon(this: &HtmlMenuItemElement, value: &str); + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = disabled)] #[doc = "Getter for the `disabled` field of this object."] #[doc = ""] @@ -61,6 +69,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn disabled(this: &HtmlMenuItemElement) -> bool; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = disabled)] #[doc = "Setter for the `disabled` field of this object."] #[doc = ""] @@ -68,6 +77,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn set_disabled(this: &HtmlMenuItemElement, value: bool); + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = checked)] #[doc = "Getter for the `checked` field of this object."] #[doc = ""] @@ -75,6 +85,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn checked(this: &HtmlMenuItemElement) -> bool; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = checked)] #[doc = "Setter for the `checked` field of this object."] #[doc = ""] @@ -82,6 +93,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn set_checked(this: &HtmlMenuItemElement, value: bool); + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = radiogroup)] #[doc = "Getter for the `radiogroup` field of this object."] #[doc = ""] @@ -89,6 +101,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn radiogroup(this: &HtmlMenuItemElement) -> String; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = radiogroup)] #[doc = "Setter for the `radiogroup` field of this object."] #[doc = ""] @@ -96,6 +109,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn set_radiogroup(this: &HtmlMenuItemElement, value: &str); + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = defaultChecked)] #[doc = "Getter for the `defaultChecked` field of this object."] #[doc = ""] @@ -103,6 +117,7 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"] pub fn default_checked(this: &HtmlMenuItemElement) -> bool; + #[deprecated(note = "Absent in all major browsers")] # [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = defaultChecked)] #[doc = "Setter for the `defaultChecked` field of this object."] #[doc = ""] diff --git a/crates/web-sys/tests/wasm/html_element.rs b/crates/web-sys/tests/wasm/html_element.rs index 73157ceeee1..9f15918c012 100644 --- a/crates/web-sys/tests/wasm/html_element.rs +++ b/crates/web-sys/tests/wasm/html_element.rs @@ -121,14 +121,6 @@ fn test_html_element() { ); assert!(element.is_content_editable(), "Should be content_editable"); - /*TODO doesn't work in Chrome - // TODO verify case where menu is passed - match element.context_menu() { - None => assert!(true, "Shouldn't have a custom menu set"), - _ => assert!(false, "Shouldn't have a custom menu set") - }; - */ - // TODO: This test is also broken in Chrome (but not Firefox). // assert!(!element.spellcheck(), "Shouldn't be spellchecked"); element.set_spellcheck(true); diff --git a/crates/web-sys/tests/wasm/main.rs b/crates/web-sys/tests/wasm/main.rs index f78f773a9f6..a587b9f6921 100644 --- a/crates/web-sys/tests/wasm/main.rs +++ b/crates/web-sys/tests/wasm/main.rs @@ -11,6 +11,7 @@ pub mod br_element; pub mod button_element; pub mod console; pub mod div_element; +pub mod dom_point; pub mod element; pub mod event; pub mod head_element; @@ -21,13 +22,10 @@ pub mod hr_element; pub mod html_element; pub mod html_html_element; pub mod image_data; -pub mod input_element; -//TODO: Both menu-related tests completely break in Chrome, but run fine in Firefox. -//pub mod menu_element; -//pub mod menu_item_element; -pub mod dom_point; pub mod indexeddb; +pub mod input_element; pub mod location; +pub mod menu_element; pub mod meta_element; pub mod meter_element; pub mod mod_elements; diff --git a/crates/web-sys/tests/wasm/menu_element.rs b/crates/web-sys/tests/wasm/menu_element.rs index 92456133ffd..85df4159997 100644 --- a/crates/web-sys/tests/wasm/menu_element.rs +++ b/crates/web-sys/tests/wasm/menu_element.rs @@ -1,5 +1,5 @@ -use wasm_bindgen_test::*; use wasm_bindgen::prelude::*; +use wasm_bindgen_test::*; use web_sys::HtmlMenuElement; #[wasm_bindgen(module = "/tests/wasm/element.js")] @@ -11,15 +11,17 @@ extern "C" { fn test_menu_element() { let menu = new_menu(); - menu.set_type("toolbar"); - assert_eq!(menu.type_(), "toolbar", "Menu should have the type value we gave it."); - - menu.set_label("Menu label here"); - assert_eq!(menu.label(), "Menu label here", "Menu should have the label value we gave it."); - menu.set_compact(true); - assert_eq!(menu.compact(), true, "Menu should be compact after we set it to be compact."); + assert_eq!( + menu.compact(), + true, + "Menu should be compact after we set it to be compact." + ); menu.set_compact(false); - assert_eq!(menu.compact(), false, "Menu should not be compact after we set it to be not-compact."); + assert_eq!( + menu.compact(), + false, + "Menu should not be compact after we set it to be not-compact." + ); } diff --git a/crates/web-sys/tests/wasm/menu_item_element.rs b/crates/web-sys/tests/wasm/menu_item_element.rs deleted file mode 100644 index 6b6eaaffb22..00000000000 --- a/crates/web-sys/tests/wasm/menu_item_element.rs +++ /dev/null @@ -1,43 +0,0 @@ -use wasm_bindgen_test::*; -use wasm_bindgen::prelude::*; -use web_sys::HtmlMenuItemElement; - -#[wasm_bindgen(module = "/tests/wasm/element.js")] -extern "C" { - fn new_menuitem() -> HtmlMenuItemElement; -} - -#[wasm_bindgen_test] -fn test_menuitem_element() { - let menuitem = new_menuitem(); - - menuitem.set_type("radio"); - assert_eq!(menuitem.type_(), "radio", "Menu item should have the type value we gave it."); - - menuitem.set_label("Menu item label here"); - assert_eq!(menuitem.label(), "Menu item label here", "Menu item should have the label value we gave it."); - - menuitem.set_icon("https://en.wikipedia.org/wiki/Rust_(programming_language)#/media/File:Rust_programming_language_black_logo.svg"); - assert_eq!(menuitem.icon(), "https://en.wikipedia.org/wiki/Rust_(programming_language)#/media/File:Rust_programming_language_black_logo.svg", "Menu item should have the icon value we gave it."); - - menuitem.set_disabled(true); - assert_eq!(menuitem.disabled(), true, "Menu item should be disabled after we set it to be disabled."); - - menuitem.set_disabled(false); - assert_eq!(menuitem.disabled(), false, "Menu item should not be disabled after we set it to be not-disabled."); - - menuitem.set_checked(true); - assert_eq!(menuitem.checked(), true, "Menu item should be checked after we set it to be checked."); - - menuitem.set_checked(false); - assert_eq!(menuitem.checked(), false, "Menu item should not be checked after we set it to be not-checked."); - - menuitem.set_radiogroup("Radio group name"); - assert_eq!(menuitem.radiogroup(), "Radio group name", "Menu item should have the radiogroup value we gave it."); - - menuitem.set_default_checked(true); - assert_eq!(menuitem.default_checked(), true, "Menu item should be default_checked after we set it to be default_checked."); - - menuitem.set_default_checked(false); - assert_eq!(menuitem.default_checked(), false, "Menu item should not be default_checked after we set it to be not default_checked."); -} diff --git a/crates/web-sys/webidls/enabled/HTMLMenuElement.webidl b/crates/web-sys/webidls/enabled/HTMLMenuElement.webidl index 5f1f130814f..32b9a1f6a0f 100644 --- a/crates/web-sys/webidls/enabled/HTMLMenuElement.webidl +++ b/crates/web-sys/webidls/enabled/HTMLMenuElement.webidl @@ -12,13 +12,21 @@ * and create derivative works of this document. */ -/* TODO -interface MenuBuilder; -*/ - -// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element +// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menu +// > The and