@@ -33,46 +33,48 @@ void testMain() {
33
33
});
34
34
35
35
test ('Attaches a stylesheet to the shadow root' , () {
36
- final DomElement ? style = hostNode.querySelector ('#flt-internals-stylesheet' );
36
+ final DomElement ? style =
37
+ hostNode.querySelector ('#flt-internals-stylesheet' );
37
38
38
39
expect (style, isNotNull);
39
40
expect (style! .tagName, equalsIgnoringCase ('style' ));
40
41
});
41
42
42
43
test ('(Self-test) hasCssRule can extract rules' , () {
43
- final DomElement ? style = hostNode.querySelector ('#flt-internals-stylesheet' );
44
+ final DomElement ? style =
45
+ hostNode.querySelector ('#flt-internals-stylesheet' );
44
46
45
47
final bool hasRule = hasCssRule (style,
46
- selector: '.flt-text-editing::placeholder' ,
47
- declaration: 'opacity: 0' );
48
+ selector: '.flt-text-editing::placeholder' ,
49
+ declaration: 'opacity: 0' );
48
50
49
51
final bool hasFakeRule = hasCssRule (style,
50
- selector: 'input::selection' ,
51
- declaration: 'color: #fabada;' );
52
+ selector: 'input::selection' , declaration: 'color: #fabada;' );
52
53
53
54
expect (hasRule, isTrue);
54
55
expect (hasFakeRule, isFalse);
55
56
});
56
57
57
58
test ('Attaches styling to remove password reveal icons on Edge' , () {
58
- final DomElement ? style = hostNode.querySelector ('#flt-internals-stylesheet' );
59
+ final DomElement ? style =
60
+ hostNode.querySelector ('#flt-internals-stylesheet' );
59
61
60
62
// Check that style.sheet! contains input::-ms-reveal rule
61
63
final bool hidesRevealIcons = hasCssRule (style,
62
- selector: 'input::-ms-reveal' ,
63
- declaration: 'display: none' );
64
+ selector: 'input::-ms-reveal' , declaration: 'display: none' );
64
65
65
- expect (hidesRevealIcons, isTrue, reason: 'In Edge, stylesheet must contain "input::-ms-reveal" rule.' );
66
+ expect (hidesRevealIcons, isTrue,
67
+ reason: 'In Edge, stylesheet must contain "input::-ms-reveal" rule.' );
66
68
}, skip: ! isEdge);
67
69
68
70
test ('Does not attach the Edge-specific style tag on non-Edge browsers' ,
69
71
() {
70
- final DomElement ? style = hostNode.querySelector ('#flt-internals-stylesheet' );
72
+ final DomElement ? style =
73
+ hostNode.querySelector ('#flt-internals-stylesheet' );
71
74
72
75
// Check that style.sheet! contains input::-ms-reveal rule
73
76
final bool hidesRevealIcons = hasCssRule (style,
74
- selector: 'input::-ms-reveal' ,
75
- declaration: 'display: none' );
77
+ selector: 'input::-ms-reveal' , declaration: 'display: none' );
76
78
77
79
expect (hidesRevealIcons, isFalse);
78
80
}, skip: isEdge);
@@ -138,18 +140,21 @@ void _runDomTests(HostNode hostNode) {
138
140
});
139
141
}
140
142
141
- /// Asserts that a given [selector] { [rule] ; } exists in a [sheet] .
142
- bool hasCssRule (DomElement ? styleSheet, {
143
+ /// Finds out whether a given CSS Rule ([selector] { [declaration] ; }) exists in a [styleSheet] .
144
+ bool hasCssRule (
145
+ DomElement ? styleSheet, {
143
146
required String selector,
144
147
required String declaration,
145
148
}) {
146
- expect (styleSheet, isNotNull );
147
- expect ((styleSheet! as DomHTMLStyleElement ).sheet, isNotNull );
149
+ assert (styleSheet != null );
150
+ assert ((styleSheet! as DomHTMLStyleElement ).sheet != null );
148
151
149
152
// regexr.com/740ff
150
- final RegExp ruleLike = RegExp ('[^{]*(?:$selector )[^{]*{[^}]*(?:$declaration )[^}]*}' );
153
+ final RegExp ruleLike =
154
+ RegExp ('[^{]*(?:$selector )[^{]*{[^}]*(?:$declaration )[^}]*}' );
151
155
152
- final DomCSSStyleSheet sheet = (styleSheet as DomHTMLStyleElement ).sheet! as DomCSSStyleSheet ;
156
+ final DomCSSStyleSheet sheet =
157
+ (styleSheet! as DomHTMLStyleElement ).sheet! as DomCSSStyleSheet ;
153
158
154
159
// Check that the cssText of any rule matches the ruleLike RegExp.
155
160
return sheet.rules
0 commit comments