|
| 1 | +/* |
| 2 | + * Copyright 2013 The Polymer Authors. All rights reserved. |
| 3 | + * Use of this source code is goverened by a BSD-style |
| 4 | + * license that can be found in the LICENSE file. |
| 5 | + */ |
| 6 | + |
| 7 | +suite('HTMLElement', function() { |
| 8 | + |
| 9 | + var div; |
| 10 | + |
| 11 | + setup(function() { |
| 12 | + div = document.body.appendChild(document.createElement('div')); |
| 13 | + div.style.cssText = |
| 14 | + 'width: 100px; height: 100px; overflow: scroll;' + |
| 15 | + 'position: absolute; top: 100px; left: 100px;' + |
| 16 | + 'border: 10px solid red'; |
| 17 | + var sr = div.createShadowRoot(); |
| 18 | + var div2 = sr.appendChild(document.createElement('div')); |
| 19 | + div2.style.cssText = 'width: 1000px; height: 1000px'; |
| 20 | + }); |
| 21 | + |
| 22 | + teardown(function() { |
| 23 | + if (div && div.parentNode) |
| 24 | + div.parentNode.removeChild(div); |
| 25 | + div = undefined; |
| 26 | + }); |
| 27 | + |
| 28 | + test('scrollTop', function() { |
| 29 | + assert.equal(div.scrollTop, 0); |
| 30 | + div.scrollTop = 100; |
| 31 | + assert.equal(div.scrollTop, 100); |
| 32 | + }); |
| 33 | + |
| 34 | + test('scrollLeft', function() { |
| 35 | + assert.equal(div.scrollLeft, 0); |
| 36 | + div.scrollLeft = 100; |
| 37 | + assert.equal(div.scrollLeft, 100); |
| 38 | + }); |
| 39 | + |
| 40 | + test('scrollHeight', function() { |
| 41 | + assert.equal(div.scrollHeight, 1000); |
| 42 | + }); |
| 43 | + |
| 44 | + test('scrollWidth', function() { |
| 45 | + assert.equal(div.scrollHeight, 1000); |
| 46 | + }); |
| 47 | + |
| 48 | + test('clientHeight', function() { |
| 49 | + div.style.overflow = 'hidden'; |
| 50 | + assert.equal(div.clientHeight, 100); |
| 51 | + }); |
| 52 | + |
| 53 | + test('clientLeft', function() { |
| 54 | + div.style.overflow = 'hidden'; |
| 55 | + assert.equal(div.clientLeft, 10); |
| 56 | + }); |
| 57 | + |
| 58 | + test('clientTop', function() { |
| 59 | + assert.equal(div.clientTop, 10); |
| 60 | + }); |
| 61 | + |
| 62 | + test('clientWidth', function() { |
| 63 | + div.style.overflow = 'hidden'; |
| 64 | + assert.equal(div.clientWidth, 100); |
| 65 | + }); |
| 66 | + |
| 67 | + test('offsetHeight', function() { |
| 68 | + assert.equal(div.offsetHeight, 120); |
| 69 | + }); |
| 70 | + |
| 71 | + test('offsetLeft', function() { |
| 72 | + assert.equal(div.offsetLeft, 100); |
| 73 | + }); |
| 74 | + |
| 75 | + test('offsetTop', function() { |
| 76 | + assert.equal(div.offsetTop, 100); |
| 77 | + }); |
| 78 | + |
| 79 | + test('offsetWidth', function() { |
| 80 | + assert.equal(div.offsetWidth, 120); |
| 81 | + }); |
| 82 | + |
| 83 | +}); |
0 commit comments