|
11 | 11 | <script src="../../../../tools/test/htmltest.js"></script> |
12 | 12 | <script src="../../../../tools/test/chai/chai.js"></script> |
13 | 13 | <style> |
| 14 | + .polymer-veiled { |
| 15 | + background-color: white; |
| 16 | + } |
| 17 | + |
14 | 18 | .polymer-unveil { |
15 | | - background: red; |
| 19 | + background-color: red; |
| 20 | + transition: all 0.3s; |
| 21 | + -webkit-transition: all 0.3s; |
16 | 22 | } |
17 | 23 | </style> |
18 | 24 | <script> |
|
30 | 36 | <script> |
31 | 37 | Polymer('x-test', { |
32 | 38 | enteredView: function() { |
33 | | - chai.assert.isTrue(getComputedStyle(this).visibility == 'hidden', |
34 | | - 'veiled elements are visible'); |
| 39 | + chai.assert.isTrue(getComputedStyle(this).opacity == '0', |
| 40 | + 'veiled elements are not opacity 0'); |
35 | 41 | } |
36 | 42 | }); |
37 | 43 | </script> |
38 | 44 | </polymer-element> |
39 | 45 |
|
40 | 46 | <script> |
| 47 | + document.addEventListener('DOMContentLoaded', function() { |
| 48 | + chai.assert.isTrue(getComputedStyle(document.body).opacity == '0', |
| 49 | + 'veiled elements are opacity 0'); |
| 50 | + }); |
41 | 51 | document.addEventListener('WebComponentsReady', function() { |
42 | | - chai.assert.isTrue(getComputedStyle(document.body).visibility == 'hidden', |
43 | | - 'veiled elements are visible'); |
| 52 | + chai.assert.isTrue(getComputedStyle(document.body).opacity == '0', |
| 53 | + 'veiled elements are opacity 0'); |
44 | 54 | // test during transition |
45 | 55 | requestAnimationFrame(function() { |
46 | 56 | requestAnimationFrame(function() { |
|
49 | 59 | chai.assert.equal(document.querySelectorAll('.polymer-unveil').length, 3, |
50 | 60 | 'element unveil class is applied when unveiling'); |
51 | 61 | var nodes = document.querySelectorAll('.polymer-unveil') |
52 | | - for (var i=0; i<nodes.length; i++) { |
53 | | - chai.assert.equal(getComputedStyle(nodes[i]).backgroundColor, |
54 | | - 'rgb(255, 0, 0)', 'user unveil style is applied'); |
55 | | - } |
56 | | - |
57 | 62 | }); |
58 | 63 | }); |
| 64 | + var isDone; |
59 | 65 | var endEvent = (document.documentElement.style.webkitTransition !== undefined) ? |
60 | 66 | 'webkitTransitionEnd' : 'transitionend'; |
61 | 67 | document.body.addEventListener(endEvent, function(e) { |
62 | | - if (e.target != this) { |
| 68 | + if (e.target != this || isDone) { |
63 | 69 | return; |
64 | 70 | } |
| 71 | + isDone = true; |
65 | 72 | requestAnimationFrame(function() { |
66 | 73 | for (var i=0, l=Polymer.veiledElements.length, elt; i<l; i++) { |
67 | 74 | elt = document.querySelector(Polymer.veiledElements[i]); |
68 | | - chai.assert.isTrue(getComputedStyle(elt).visibility == 'visible', |
69 | | - 'unveiled elements are visible'); |
| 75 | + chai.assert.isTrue(getComputedStyle(elt).opacity == '1', |
| 76 | + 'unveiled elements are not opacity 0'); |
70 | 77 | } |
71 | 78 | chai.assert.equal(document.querySelectorAll('.polymer-veiled').length, 0, |
72 | 79 | 'element classes are cleared after unveiling'); |
|
0 commit comments