1 define([ 'util/report' ], function (report
) {
3 return el
.className
.split(/\s+/g);
6 function addClass(el
, className
) {
7 el
.className
+= ' ' + className
;
10 function removeClass(el
, className
) {
11 // wtb classList (damnit Safari!)
12 el
.className
= classes(el
).filter(function (c
) {
13 return c
!== className
;
17 function testResultNameAccept(name
) {
18 return name
!== 'pass';
22 endTest: function (domId
, err
, results
) {
23 var el
= document
.getElementById(domId
);
25 throw new Error('Could not find element #' + domId
);
28 function findSlot(name
) {
29 var elements
= el
.querySelectorAll('[data-property]');
31 for (i
= 0; i
< elements
.length
; ++i
) {
32 var element
= elements
[i
];
33 if (element
.getAttribute('data-property') === name
) {
41 function fillSlots(name
, value
) {
42 if (!testResultNameAccept(name
)) {
46 if (value
=== null || typeof value
=== 'undefined') {
50 if (typeof value
=== 'object') {
51 Object
.keys(value
).forEach(function (subName
) {
52 fillSlots(subName
, value
[subName
]);
55 var slot
= findSlot(name
);
57 slot
.textContent
= value
;
59 //console.warn('Could not find slot ' + name + ' for ' + domId, value);
64 fillSlots('', results
);
66 removeClass(el
, 'pass');
67 removeClass(el
, 'fail');
68 removeClass(el
, 'error');
71 addClass(el
, 'error');
73 var errorMessageEl
= el
.querySelector('.error-message');
75 errorMessageEl
.textContent
= err
;
77 } else if (results
&& results
.passed
) {