commit-queue@webkit.org | e12edd5 | 2012-12-05 08:02:47 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
mark.lam@apple.com | eac91eb | 2013-09-08 01:01:30 +0000 | [diff] [blame] | 4 | <script src='../../resources/js-test-pre.js'></script> |
commit-queue@webkit.org | e12edd5 | 2012-12-05 08:02:47 +0000 | [diff] [blame] | 5 | <script> |
| 6 | description('Percentage margins on absolutely positioned elements are relative to the container\'s logical width'); |
| 7 | |
| 8 | function testMargins(outerProperties, innerProperties, expectedProperties) { |
| 9 | var outer = document.createElement('div'), |
| 10 | inner = document.createElement('div'), |
| 11 | property, style; |
| 12 | for (property in outerProperties) |
| 13 | outer.style.setProperty(property, outerProperties[property]); |
| 14 | for (property in innerProperties) |
| 15 | inner.style.setProperty(property, innerProperties[property]); |
| 16 | outer.appendChild(inner); |
| 17 | document.body.appendChild(outer); |
| 18 | style = getComputedStyle(inner); |
| 19 | for (property in expectedProperties) |
| 20 | shouldBe('"' + style.getPropertyValue(property) + '"', '"' + expectedProperties[property] + '"'); |
| 21 | document.body.removeChild(outer); |
| 22 | } |
| 23 | |
| 24 | var WritingModes = { |
| 25 | 'HORIZONTAL-TB': 'horizontal-tb', |
| 26 | 'VERTICAL-LR': 'vertical-lr', |
| 27 | 'VERTICAL-RL': 'vertical-rl' |
| 28 | } |
| 29 | |
| 30 | var outerProperties = { |
| 31 | position: 'relative', |
| 32 | width: '100px', |
| 33 | height: '200px', |
| 34 | }, innerProperties = { |
| 35 | position: 'absolute', |
| 36 | width: '40px', |
| 37 | height: '160px', |
| 38 | }, expectedProperties = { |
| 39 | margin: '10px 20px 30px 40px' |
| 40 | }; |
| 41 | |
| 42 | window.onload = function() { |
| 43 | for (var outerProperty in WritingModes) { |
| 44 | for (var innerProperty in WritingModes) { |
| 45 | outerProperties['-webkit-writing-mode'] = WritingModes[outerProperty]; |
| 46 | innerProperties['-webkit-writing-mode'] = WritingModes[innerProperty]; |
| 47 | innerProperties['margin'] = outerProperty === 'HORIZONTAL-TB' ? '10% 20% 30% 40%' : '5% 10% 15% 20%'; |
| 48 | testMargins(outerProperties, innerProperties, expectedProperties); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | </script> |
mark.lam@apple.com | eac91eb | 2013-09-08 01:01:30 +0000 | [diff] [blame] | 53 | <script src='../../resources/js-test-post.js'></script> |
commit-queue@webkit.org | e12edd5 | 2012-12-05 08:02:47 +0000 | [diff] [blame] | 54 | </body> |
| 55 | </html> |