Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: bower_components/web-animations-js/test/testcases/unit-test-testharness.html

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright 2013 Google Inc. All Rights Reserved.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 -->
16 <!DOCTYPE html><meta charset="UTF-8">
17 <script src="../bootstrap.js"></script>
18 <script>
19 "use strict";
20
21 test(function() {
22 var element = document.createElement('span');
23 assert_styles(element, {},
24 'assert_styles should support an element with no parent');
25
26 document.body.appendChild(element);
27 var childCount = document.body.children.length;
28 assert_styles(element, {});
29 assert_equals(childCount, document.body.children.length,
30 'assert_styles should not leave additional elements in the dom');
31 }, 'assert_styles reference_element');
32
33 test(function() {
34 try {
35 assert_styles(null, {});
36 assert_unreached();
37 } catch (e) {
38 assert_equals(e.message, 'Expected Array, NodeList or Element but got null') ;
39 }
40 }, 'assert_styles invalid arguments');
41
42 test(function() {
43 var element = document.createElement('span');
44 document.body.appendChild(element);
45
46 try {
47 assert_styles(element, {'left': 'abc123'}, "Description 1");
48 assert_unreached();
49 } catch (e) {
50 assert_regexp_match(e.message, /^Tried to set the reference element\'s left to "abc123" but neither/);
51 }
52
53 try {
54 assert_styles(element, {'clip': 'rect(1px 2px 3px 4px)'});
55 assert_unreached();
56 } catch (e) {
57 assert_regexp_match(e.message, /Actual - /);
58 }
59 }, 'assert_styles given invalid style');
60
61 test(function() {
62 var element = document.createElement('span');
63 document.body.appendChild(element);
64 element.style.left = '-100px';
65 try {
66 assert_styles(element, {left: '100px'});
67 assert_unreached();
68 } catch(e) {
69 }
70 }, 'assert_styles should handle negative specified values');
71
72 test(function() {
73 var element = document.createElement('span');
74 document.body.appendChild(element);
75 element.style.left = '100px';
76 try {
77 assert_styles(element, {left: '-100px'});
78 assert_unreached();
79 } catch(e) {
80 }
81 }, 'assert_styles should handle negative expected values');
82
83 test(function() {
84 var element = document.createElement('span');
85 document.body.appendChild(element);
86 element.style.left = '-100px';
87 assert_styles(element, {left: '-100px'});
88 }, 'assert_styles should handle negative values');
89
90 test(function() {
91 var AssertionError = window.assert_styles_assertion_error;
92 var assert = window.assert_styles_assert_important_in_array;
93
94 assert('matrix(1%)', ['matrix(1%)']);
95 assert('matrix(1%)', ['', 'matrix(1%)']);
96 assert('matrix(1% 1px)', ['matrix(1%, 1px)']);
97 assert('rect(1px 2px 3px 4px)', ['rect(1px 2px 3px 4px)']);
98 assert('rect(1px 2px 3px 4px)', ['rect(1px, 2px, 3px, 4px)']);
99
100 try {
101 assert('', [], 'empty');
102 assert_unreached();
103 } catch(e) {
104 assert_regexp_match(e.message, /^empty/);
105 }
106
107 try {
108 assert('matrix(1%)', [], 'matrix 1% to empty');
109 assert_unreached();
110 } catch(e) {
111 assert_regexp_match(e.message, /^matrix 1% to empty/);
112 }
113
114 try {
115 assert('matrix(1%)', [''], 'matrix 1% to empty string');
116 assert_unreached();
117 } catch(e) {
118 assert_regexp_match(e.message, /^matrix 1% to empty string\n/);
119 }
120
121 try {
122 assert('matrix(1%)', ['matrix(1px)'], 'matrix 1% to matrix 1px');
123 assert_unreached();
124 } catch(e) {
125 assert_regexp_match(e.message, /^matrix 1% to matrix 1px/);
126 }
127
128 /* Check that it only needs to match to 4 significant figures */
129 assert('1', [1.0001]);
130 assert('1.0001', [1]);
131 try {
132 assert('1', [1.001]);
133 assert_unreached();
134 } catch(e) {
135 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
136 }
137
138 assert('10', [10.001]);
139 assert('10.001', [10]);
140 try {
141 assert('10', [10.01]);
142 assert_unreached();
143 } catch(e) {
144 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
145 }
146
147 assert('2.0', [2.0001]);
148 assert('2.0001', [2]);
149 try {
150 assert('2', [2.001]);
151 assert_unreached();
152 } catch(e) {
153 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
154 }
155
156 assert('20.0', [20.001]);
157 assert('20.001', [20]);
158 try {
159 assert('20.0', [20.01]);
160 assert_unreached();
161 } catch(e) {
162 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
163 }
164
165 assert('40e2', [4000.1]);
166 assert('40.001e2', [4000]);
167 try {
168 assert('40e2', [4001]);
169 assert_unreached();
170 } catch(e) {
171 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
172 }
173
174 assert('40e+3', [40001]);
175 assert('40.001e+3', [40000]);
176 try {
177 assert('40e+3', [40010]);
178 assert_unreached();
179 } catch(e) {
180 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
181 }
182
183 assert('50e-4', [0.0050001]);
184 assert('50.001e-4', [0.005]);
185 try {
186 assert('50e-4', [0.005001]);
187 assert_unreached();
188 } catch(e) {
189 assert_not_equals(e.message, "assert_unreached: Reached unreachable code");
190 }
191
192 }, 'Checking assert_important_in_array works');
193
194 test(function() {
195 var ei = window.assert_styles_extract_important;
196
197 assert_array_equals(ei('1'), [1]);
198 assert_array_equals(ei('10'), [10]);
199 assert_array_equals(ei('2.0'), [2.0]);
200 assert_array_equals(ei('20.0'), [20.0]);
201 assert_array_equals(ei('40e2'), [4000.0]);
202 assert_array_equals(ei('40e+3'), [40000.0]);
203 assert_array_equals(ei('50e-4'), [0.005]);
204 assert_array_equals(ei('60.6e-4'), [0.00606]);
205
206 assert_array_equals(ei('+1'), [1]);
207 assert_array_equals(ei('+10'), [10]);
208 assert_array_equals(ei('+2.0'), [2.0]);
209 assert_array_equals(ei('+20.0'), [20.0]);
210 assert_array_equals(ei('+40e2'), [4000.0]);
211 assert_array_equals(ei('+40e+3'), [40000.0]);
212 assert_array_equals(ei('+50e-4'), [0.005]);
213 assert_array_equals(ei('+60.6e-4'), [0.00606]);
214
215 assert_array_equals(ei('-1'), [-1]);
216 assert_array_equals(ei('-10'), [-10]);
217 assert_array_equals(ei('-2.0'), [-2.0]);
218 assert_array_equals(ei('-20.0'), [-20.0]);
219 assert_array_equals(ei('-40e2'), [-4000]);
220 assert_array_equals(ei('-50e-3'), [-0.05]);
221 assert_array_equals(ei('-60.6e-4'), [-0.00606]);
222
223 assert_array_equals(ei('matrix(1%'), ['matrix', 1, '%']);
224 assert_array_equals(ei('matrix(10px'), ['matrix', 10, 'px']);
225 assert_array_equals(ei('matrix(2.0em'), ['matrix', 2.0, 'em']);
226 assert_array_equals(ei('matrix(20.0en'), ['matrix', 20.0, 'en']);
227 assert_array_equals(ei('matrix(40e2ve'), ['matrix', 4000.0, 've']);
228 assert_array_equals(ei('matrix(40e+3vw'), ['matrix', 40000.0, 'vw']);
229 assert_array_equals(ei('matrix(50e-4%'), ['matrix', 0.005, '%']);
230
231 assert_array_equals(ei('matrix('), ['matrix']);
232 assert_array_equals(ei('blah'), ['blah']);
233 assert_array_equals(ei('+'), []);
234 assert_array_equals(ei('none'), ['none']);
235 assert_array_equals(ei('----'), []);
236 assert_array_equals(ei('-a'), ['a']);
237 assert_array_equals(ei('b.j'), ['b', 'j']);
238
239 assert_array_equals(ei('matrix(1, 0, 0, 1, 0, 0)'),
240 ['matrix', 1, 0, 0, 1, 0, 0]);
241 assert_array_equals(ei('matrix(1 0 0 1 0 0)'),
242 ['matrix', 1, 0, 0, 1, 0, 0]);
243 assert_array_equals(ei('matrix(0.9511, 0.309, -0.309, 0.9511, 0, 0)'),
244 ['matrix', 0.9511, 0.309, -0.309, 0.9511, 0, 0]);
245
246 }, 'Checking important parts are extracted successfully');
247
248 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698