summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-ui/appearance-cssom-001.html
blob: 49b4e1c68d02d5df8831bedc7945bb7463915652 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!doctype html>
<title>CSS Basic User Interface Test: appearance CSSOM</title>
<link rel="help" href="https://drafts.csswg.org/css-ui-4/#appearance-switching">
<meta name="assert" content="CSSOM for the appearance/-webkit-appearance property is correct.">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<button id=button>Test</button>
<script>
  const button = document.getElementById('button');
  const values = ["none",
                  "auto",
                  "button",
                  "checkbox",
                  "listbox",
                  "menulist",
                  "menulist-button",
                  "meter",
                  "progress-bar",
                  "push-button",
                  "radio",
                  "searchfield",
                  "slider-horizontal",
                  "square-button",
                  "textarea",
                  "textfield",
                 ];
  const initial_appearance = getComputedStyle(button).appearance;
  function assert_style_for_prop(style, prop, value) {
    if (prop === '-webkit-appearance') {
      assert_equals(style.WebkitAppearance, value, 'style.WebkitAppearance (uppercase W)');
      assert_equals(style.webkitAppearance, value, 'style.webkitAppearance (lowercase w)');
    } else {
      assert_equals(style.appearance, value, 'style.appearance');
    }
    assert_equals(style.getPropertyValue(prop), value, `getPropertyValue(${prop})`);
  }
  for (const prop of ["-webkit-appearance", "appearance"]) {
    for (const value of values) {
      test(() => {
        button.removeAttribute('style');
        button.style.setProperty(prop, value);
        assert_style_for_prop(button.style, prop, value);
        const style = getComputedStyle(button);
        assert_style_for_prop(style, prop, value);
        button.style.setProperty('background-color', 'black');
        assert_style_for_prop(style, prop, value,
                              'Computed value should be the specified value');
      }, `${prop}: ${value}`);
    }

    const invalidValues = ["bogus-button",
                           "attachment",
                           "button-bevel",
                           "borderless-attachment",
                           "button-arrow-down",
                           "button-arrow-next",
                           "button-arrow-previous",
                           "button-arrow-up",
                           "button-focus",
                           "caps-lock-indicator",
                           "caret",
                           "checkbox-container",
                           "checkbox-label",
                           "checkmenuitem",
                           "color-well",
                           "continuous-capacity-level-indicator",
                           "default-button",
                           "discrete-capacity-level-indicator",
                           "dualbutton",
                           "groupbox",
                           "image-controls-button",
                           "inner-spin-button",
                           "list-button",
                           "listitem",
                           "media-controls-background",
                           "media-controls-dark-bar-background",
                           "media-controls-fullscreen-background",
                           "media-controls-light-bar-background",
                           "media-current-time-display",
                           "media-enter-fullscreen-button",
                           "media-exit-fullscreen-button",
                           "media-fullscreen-volume-slider",
                           "media-fullscreen-volume-slider-thumb",
                           "media-mute-button",
                           "media-overlay-play-button",
                           "media-play-button",
                           "media-return-to-realtime-button",
                           "media-rewind-button",
                           "media-seek-back-button",
                           "media-seek-forward-button",
                           "media-slider",
                           "media-sliderthumb",
                           "media-time-remaining-display",
                           "media-toggle-closed-captions-button",
                           "media-volume-slider",
                           "media-volume-slider-container",
                           "media-volume-slider-mute-button",
                           "media-volume-sliderthumb",
                           "menuarrow",
                           "menubar",
                           "menucheckbox",
                           "menuimage",
                           "menuitem",
                           "menuitemtext",
                           "menulist-text",
                           "menulist-textfield",
                           "menupopup",
                           "menuradio",
                           "menuseparator",
                           "meterbar",
                           "meterchunk",
                           "number-input",
                           "progress-bar-value",
                           "progressbar",
                           "progressbar-vertical",
                           "progresschunk",
                           "progresschunk-vertical",
                           "radio-container",
                           "radio-label",
                           "radiomenuitem",
                           "range",
                           "range-thumb",
                           "rating-level-indicator",
                           "relevancy-level-indicator",
                           "resizer",
                           "resizerpanel",
                           "scale-horizontal",
                           "scale-vertical",
                           "scalethumb-horizontal",
                           "scalethumb-vertical",
                           "scalethumbend",
                           "scalethumbstart",
                           "scalethumbtick",
                           "scrollbarbutton-down",
                           "scrollbarbutton-left",
                           "scrollbarbutton-right",
                           "scrollbarbutton-up",
                           "scrollbarthumb-horizontal",
                           "scrollbarthumb-vertical",
                           "scrollbartrack-horizontal",
                           "scrollbartrack-vertical",
                           "searchfield-cancel-button",
                           "searchfield-decoration",
                           "searchfield-results-button",
                           "searchfield-results-decoration",
                           "separator",
                           "sheet",
                           "slider-vertical",
                           "sliderthumb-horizontal",
                           "sliderthumb-vertical",
                           "snapshotted-plugin-overlay",
                           "spinner",
                           "spinner-downbutton",
                           "spinner-textfield",
                           "spinner-upbutton",
                           "splitter",
                           "statusbar",
                           "statusbarpanel",
                           "tab",
                           "tab-scroll-arrow-back",
                           "tab-scroll-arrow-forward",
                           "tabpanel",
                           "tabpanels",
                           "textfield-multiline",
                           "toolbar",
                           "toolbarbutton",
                           "toolbarbutton-dropdown",
                           "toolbargripper",
                           "toolbox",
                           "tooltip",
                           "treeheader",
                           "treeheadercell",
                           "treeheadersortarrow",
                           "treeitem",
                           "treeline",
                           "treetwisty",
                           "treetwistyopen",
                           "treeview",
                           "-apple-pay-button",
                           "-moz-win-borderless-glass",
                           "-moz-win-browsertabbar-toolbox",
                           "-moz-win-communications-toolbox",
                           "-moz-win-communicationstext",
                           "-moz-win-exclude-glass",
                           "-moz-win-glass",
                           "-moz-win-media-toolbox",
                           "-moz-window-button-box",
                           "-moz-window-button-box-maximized",
                           "-moz-window-button-close",
                           "-moz-window-button-maximize",
                           "-moz-window-button-minimize",
                           "-moz-window-button-restore",
                           "-moz-window-frame-bottom",
                           "-moz-window-frame-left",
                           "-moz-window-frame-right",
                           "-moz-window-titlebar",
                           "-moz-window-titlebar-maximized",
                           ];
    for (const invalidValue of invalidValues) {
      test(() => {
        button.removeAttribute('style');
        button.style.setProperty(prop, invalidValue);
        assert_style_for_prop(button.style, prop, "");
        const style = getComputedStyle(button);
        assert_style_for_prop(style, prop, initial_appearance);
      }, `${prop}: ${invalidValue} (invalid)`);
    }
  }

  for (const prefix of ["-ms-",
                        "mso-",
                        "-moz-",
                        "-o-",
                        "-xv-",
                        "-atsc-",
                        "-wap-",
                        "-khtml-",
                        "-konq-",
                        "-apple-",
                        "prince-",
                        "-ah-",
                        "-hp-",
                        "-ro-",
                        "-rim-",
                        "-tc-",
                        ]) {
    const prop = `${prefix}appearance`;
    test(() => {
      button.removeAttribute('style');
      button.style.setProperty(prop, 'none');
      assert_equals(button.style.getPropertyValue(prop), '');
      const style = getComputedStyle(button);
      assert_equals(style.getPropertyValue(prop), '');
    }, `${prop} (should not be supported)`);
  }
</script>