| | 413 | |
|---|
| | 414 | // Based on properties check from http://www.quirksmode.org/viewport/compatibility.html |
|---|
| | 415 | var documentViewportProperties = { |
|---|
| | 416 | properties : [ |
|---|
| | 417 | 'self.pageXOffset', 'self.pageYOffset', |
|---|
| | 418 | 'self.screenX', 'self.screenY', |
|---|
| | 419 | 'self.innerHeight', 'self.innerWidth', |
|---|
| | 420 | 'self.outerHeight', 'self.outerWidth', |
|---|
| | 421 | 'self.screen.height', 'self.screen.width', |
|---|
| | 422 | 'self.screen.availHeight', 'self.screen.availWidth', |
|---|
| | 423 | 'self.screen.availTop', 'self.screen.availLeft', |
|---|
| | 424 | 'self.screen.Top', 'self.screen.Left', |
|---|
| | 425 | 'self.screenTop', 'self.screenLeft', |
|---|
| | 426 | 'document.body.clientHeight', 'document.body.clientWidth', |
|---|
| | 427 | 'document.body.scrollHeight', 'document.body.scrollWidth', |
|---|
| | 428 | 'document.body.scrollLeft', 'document.body.scrollTop', |
|---|
| | 429 | 'document.body.offsetHeight', 'document.body.offsetWidth', |
|---|
| | 430 | 'document.body.offsetTop', 'document.body.offsetLeft' |
|---|
| | 431 | ].inject([], function(properties, prop) { |
|---|
| | 432 | if(!self.screen && prop.include('self.screen')) return; |
|---|
| | 433 | if (!document.body && prop.include('document.body')) return; |
|---|
| | 434 | properties.push(prop); |
|---|
| | 435 | if (prop.include('.body') && document.documentElement) |
|---|
| | 436 | properties.push(prop.sub('.body', '.documentElement')); |
|---|
| | 437 | return properties; |
|---|
| | 438 | }), |
|---|
| | 439 | |
|---|
| | 440 | inspect : function() { |
|---|
| | 441 | var props = []; |
|---|
| | 442 | this.properties.each(function(prop) { |
|---|
| | 443 | if (eval(prop)) props[prop] = eval(prop); |
|---|
| | 444 | }); |
|---|
| | 445 | return props; |
|---|
| | 446 | } |
|---|
| | 447 | }; |
|---|
| | 1617 | testElementToViewportDimensionsDoesNotAffectDocumentProperties: function() {with(this) { |
|---|
| | 1618 | // No properties on the document should be affected when resizing |
|---|
| | 1619 | // an absolute positioned(0,0) element to viewport dimensions |
|---|
| | 1620 | var vd = document.viewport.getDimensions(); |
|---|
| | 1621 | |
|---|
| | 1622 | var before = documentViewportProperties.inspect(); |
|---|
| | 1623 | $('elementToViewportDimensions').setStyle({ height: vd.height + 'px', width: vd.width + 'px' }).show(); |
|---|
| | 1624 | var after = documentViewportProperties.inspect(); |
|---|
| | 1625 | $('elementToViewportDimensions').hide(); |
|---|
| | 1626 | |
|---|
| | 1627 | documentViewportProperties.properties.each(function(prop) { |
|---|
| | 1628 | assertEqual(before[prop], after[prop], prop + ' was affected'); |
|---|
| | 1629 | }); |
|---|
| | 1630 | }}, |
|---|
| | 1631 | |
|---|