c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt SweeneyYUI.add('dom-xy-test', function(Y) {
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney Y.DOM._testXY = function() {
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney var Assert = Y.Assert,
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney ArrayAssert = Y.ArrayAssert,
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney tests = {name: 'Y.DOM.xy'},
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney sel = 'h1, .node, table th, table td, table tr, table',
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney play2 = Y.DOM.byId('play2'),
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney nodes = Y.Selector.query(sel);
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney window.scrollTo(100, 100);
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney play2.scrollTop = 50;
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney Y.each(nodes, function(n) {
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney var el = document.createElement('div'),
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney xy = Y.DOM.getXY(n),
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney box,
1dac070d5991af1a83315be5c43374921abe4aeaMatt Sweeney actual,
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney id = n.id;
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney el.className = 'nodeOver nodeOver-' + n.tagName.toLowerCase();
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney el.style.height = n.offsetHeight + 'px';
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney el.style.width = n.offsetWidth + 'px';
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney document.body.appendChild(el);
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney Y.DOM.setXY(el, xy, true);
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney box = el.getBoundingClientRect();
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
1a86e336ee9746646cf1c0c426cef659a14d3b57Matt Sweeney //actual = [box.left + Y.DOM.docScrollX(), box.top + Y.DOM.docScrollY()];
1a86e336ee9746646cf1c0c426cef659a14d3b57Matt Sweeney actual = [el.offsetLeft, el.offsetTop];
1dac070d5991af1a83315be5c43374921abe4aeaMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney tests['should set ' + id + ' in page coords'] = function() {
1a86e336ee9746646cf1c0c426cef659a14d3b57Matt Sweeney ArrayAssert.itemsAreEqual(actual, [Math.round(xy[0]), Math.round(xy[1])]);
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney };
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney });
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney Y.Test.Runner.add(new Y.Test.Case(tests));
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney };
c7a0918bf9dc49db2a98ee5ec43a5e139e938f1cMatt Sweeney}, '@VERSION@' ,{requires:['dom-screen', 'test']});