contextmenu-historical.html (3213B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>menu element removed properties</title> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-menu-element"> 5 <link rel="help" href="https://github.com/whatwg/html/pull/2742"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <menu type="context" label="label"> 10 <menuitem>Text</menuitem> 11 <menuitem type="checkbox" checked>Checked</menuitem> 12 <menuitem disabled>Disabled</menuitem> 13 <menuitem default>Default</menuitem> 14 </menu> 15 16 <script> 17 "use strict"; 18 19 const menu = document.querySelector("menu"); 20 const menuitem = document.querySelector("menuitem"); 21 22 test(() => { 23 assert_false("HTMLMenuItemElement" in window, "the HTMLMenuItemElement interface must not exist"); 24 assert_equals(menuitem.constructor, HTMLUnknownElement, "A <menuitem> must be HTMLUnknownElement"); 25 26 for (const prop of ["type", "label", "icon", "disabled", "checked", "radiogroup", "default"]) { 27 assert_false(prop in menuitem, `menuitem.${prop} must not be present`); 28 } 29 }, "HTMLMenuItemElement must not be not present"); 30 31 test(() => { 32 const potentialBadLocations = [ 33 window, 34 document, 35 HTMLElement.prototype, 36 SVGElement.prototype, 37 Document.prototype, 38 HTMLDocument.prototype, 39 Element.prototype 40 ]; 41 for (const location of potentialBadLocations) { 42 assert_false("onshow" in location, 43 `${location.constructor.name} must not have a property "onshow"`); 44 } 45 }, `onshow must not be present on the GlobalEventHandlers locations`); 46 47 test(() => { 48 assert_false("RelatedEvent" in window); 49 }, "RelatedEvent must not be present"); 50 51 test(() => { 52 assert_false("contextMenu" in HTMLElement.prototype, 53 "HTMLElement's prototype must not have a property \"contextMenu\""); 54 assert_false("contextMenu" in document.createElement("div"), 55 "A div must not have a property \"contextMenu\""); 56 }, "el.contextMenu must not be present"); 57 58 test(() => { 59 assert_false("type" in menu); 60 61 menu.type = "toolbar"; 62 assert_equals(menu.getAttribute("type"), "context"); 63 }, "menu.type must not exist or reflect the content attribute"); 64 65 test(() => { 66 assert_false("label" in menu); 67 68 menu.label = "new label"; 69 assert_equals(menu.getAttribute("label"), "label"); 70 }, "menu.label must not exist or reflect the content attribute"); 71 72 test(() => { 73 assert_array_equals(document.querySelectorAll("menuitem:enabled"), []); 74 }, ":enabled must not match menuitems"); 75 76 test(() => { 77 assert_array_equals(document.querySelectorAll("menuitem:disabled"), []); 78 }, ":disabled must not match menuitems"); 79 80 test(() => { 81 assert_array_equals(document.querySelectorAll("menuitem:checked"), []); 82 }, ":checked must not match menuitems"); 83 84 test(() => { 85 try { 86 assert_array_equals(document.querySelectorAll("menuitem:default"), []); 87 } catch (e) { 88 // Not everyone has implemented :default as of the time of this writing. 89 if (e.name !== "SyntaxError") { 90 throw e; 91 } 92 } 93 }, ":default must not match menuitems"); 94 95 test(() => { 96 assert_equals(getComputedStyle(menu).display, "block"); 97 }, "The user-agent stylesheet must leave type=\"context\" menus as block display like other menus"); 98 99 </script>