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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests the Filter Editor Widget's add button
const {
CSSFilterEditorWidget,
} = require("resource://devtools/client/shared/widgets/FilterWidget.js");
const STRINGS_URI = "devtools/client/locales/filterwidget.properties";
const L10N = new LocalizationHelper(STRINGS_URI);
const TEST_URI = CHROME_URL_ROOT + "doc_filter-editor-01.html";
add_task(async function () {
const { doc } = await createHost("bottom", TEST_URI);
const container = doc.querySelector("#filter-container");
const widget = new CSSFilterEditorWidget(container, "none");
const select = widget.el.querySelector("select"),
add = widget.el.querySelector("#add-filter");
const TEST_DATA = [
{
name: "blur",
unit: "px",
type: "length",
},
{
name: "contrast",
unit: "%",
type: "percentage",
},
{
name: "hue-rotate",
unit: "deg",
type: "angle",
},
{
name: "drop-shadow",
placeholder: L10N.getStr("dropShadowPlaceholder"),
type: "string",
},
{
name: "url",
placeholder: "example.svg#c1",
type: "string",
},
];
info("Test adding new filters with different units");
for (const [index, filter] of TEST_DATA.entries()) {
select.value = filter.name;
add.click();
if (filter.unit) {
is(
widget.getValueAt(index),
`0${filter.unit}`,
`Should add ${filter.unit} to ${filter.type} filters`
);
} else if (filter.placeholder) {
const i = index + 1;
const input = widget.el.querySelector(`.filter:nth-child(${i}) input`);
is(
input.placeholder,
filter.placeholder,
"Should set the appropriate placeholder for string-type filters"
);
}
}
widget.destroy();
});
|