summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/interactive-elements/contextmenu-historical.html
blob: f723d3a92aab226fd82295a81209c3e25882bcb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<meta charset="utf-8">
<title>menu element removed properties</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-menu-element">
<link rel="help" href="https://github.com/whatwg/html/pull/2742">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<menu type="context" label="label">
  <menuitem>Text</menuitem>
  <menuitem type="checkbox" checked>Checked</menuitem>
  <menuitem disabled>Disabled</menuitem>
  <menuitem default>Default</menuitem>
</menu>

<script>
"use strict";

const menu = document.querySelector("menu");
const menuitem = document.querySelector("menuitem");

test(() => {
  assert_false("HTMLMenuItemElement" in window, "the HTMLMenuItemElement interface must not exist");
  assert_equals(menuitem.constructor, HTMLUnknownElement, "A <menuitem> must be HTMLUnknownElement");

  for (const prop of ["type", "label", "icon", "disabled", "checked", "radiogroup", "default"]) {
    assert_false(prop in menuitem, `menuitem.${prop} must not be present`);
  }
}, "HTMLMenuItemElement must not be not present");

test(() => {
  const potentialBadLocations = [
    window,
    document,
    HTMLElement.prototype,
    SVGElement.prototype,
    Document.prototype,
    HTMLDocument.prototype,
    Element.prototype
  ];
  for (const location of potentialBadLocations) {
    assert_false("onshow" in location,
      `${location.constructor.name} must not have a property "onshow"`);
  }
}, `onshow must not be present on the GlobalEventHandlers locations`);

test(() => {
  assert_false("RelatedEvent" in window);
}, "RelatedEvent must not be present");

test(() => {
  assert_false("contextMenu" in HTMLElement.prototype,
    "HTMLElement's prototype must not have a property \"contextMenu\"");
  assert_false("contextMenu" in document.createElement("div"),
    "A div must not have a property \"contextMenu\"");
}, "el.contextMenu must not be present");

test(() => {
  assert_false("type" in menu);

  menu.type = "toolbar";
  assert_equals(menu.getAttribute("type"), "context");
}, "menu.type must not exist or reflect the content attribute");

test(() => {
  assert_false("label" in menu);

  menu.label = "new label";
  assert_equals(menu.getAttribute("label"), "label");
}, "menu.label must not exist or reflect the content attribute");

test(() => {
  assert_array_equals(document.querySelectorAll("menuitem:enabled"), []);
}, ":enabled must not match menuitems");

test(() => {
  assert_array_equals(document.querySelectorAll("menuitem:disabled"), []);
}, ":disabled must not match menuitems");

test(() => {
  assert_array_equals(document.querySelectorAll("menuitem:checked"), []);
}, ":checked must not match menuitems");

test(() => {
  try {
    assert_array_equals(document.querySelectorAll("menuitem:default"), []);
  } catch (e) {
    // Not everyone has implemented :default as of the time of this writing.
    if (e.name !== "SyntaxError") {
      throw e;
    }
  }
}, ":default must not match menuitems");

test(() => {
  assert_equals(getComputedStyle(menu).display, "block");
}, "The user-agent stylesheet must leave type=\"context\" menus as block display like other menus");

</script>