HEX
Server: Apache
System: Linux eisbus 6.8.12-9-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-9 (2025-03-16T19:18Z) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/share/doc/libjs-scriptaculous/test/unit/position_clone_test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>script.aculo.us Unit test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../../lib/prototype.js" type="text/javascript"></script>
  <script src="../../src/scriptaculous.js" type="text/javascript"></script>
  <script src="../../src/unittest.js" type="text/javascript"></script>
  <link rel="stylesheet" href="../test.css" type="text/css" />
</head>
<body>
<h1>script.aculo.us Unit test file</h1>
<p>
  Tests for Postion.clone (to be moved to Prototype)
</p>

<!-- Log output -->
<div id="testlog"> </div>

<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[

  function prepareTarget(contained, position1, position2) {
    var target;
    if($('target_div')) Element.remove('target_div');
    if($('container_div')) Element.remove('container_div');
    if(contained) {
      target = Builder.node('div', 
        {id: 'container_div', style: 'position:' + position1},
        [Builder.node('div', {id: 'target_div', style: 'position: ' +position2})]);
    } else {
      target = Builder.node('div', 
        {id: 'target_div', style: 'position:' + position1}, '456');
    }
    document.body.appendChild(target);
    Position.clone($('source_div'),$('target_div'));
  }
  
  function prepareTargetHidden(contained, position1, position2) {
    var target;
    if($('target_div')) Element.remove('target_div');
    if($('container_div')) Element.remove('container_div');
    if(contained) {
      target = Builder.node('div', 
        {id: 'container_div', style: 'position:' + position1},
        [Builder.node('div', {id: 'target_div', style: 'display:none; position: ' +position2})]);
    } else {
      target = Builder.node('div', 
        {id: 'target_div', style: 'display:none; position:' + position1}, '456');
    }
    document.body.appendChild(target);
    Position.clone($('source_div'),$('target_div'));
    Element.show($('target_div'));
  }
  
  new Test.Unit.Runner({
    
    teardown: function() {
      Element.remove($('source_div'));
    },

    testPositionCloneFromAbsolute: function() { with(this) {
      var source = Builder.node('div', 
        {id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123');
      document.body.appendChild(source);
      var expected = Object.inspect([120, 20]);
      assertEqual(expected, Object.inspect(Position.page($('source_div'))));
      
      prepareTarget(false, 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute BODY child");
      
      prepareTarget(false, 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed BODY child");
            
      prepareTarget(true, 'absolute', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of absolute BODY child");
      
      prepareTarget(true, 'absolute', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of absolute BODY child");
      
      prepareTarget(true, 'relative', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of relative BODY child");

      prepareTarget(true, 'relative', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of relative BODY child");
      
      prepareTarget(true, 'static', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of static BODY child");

      prepareTarget(true, 'static', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of static BODY child");
    }},
    
    testPositionCloneFromRelative: function() { with(this) {
      var source = Builder.node('div', 
        {id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123');
      document.body.appendChild(source);
      var expected =  Object.inspect(Position.page($('source_div')));
      assertEqual(expected, Object.inspect(Position.page($('source_div'))));

      prepareTarget(false, 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute BODY child");

      prepareTarget(false, 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed BODY child");

      prepareTarget(true, 'absolute', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of absolute BODY child");

      prepareTarget(true, 'absolute', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of absolute BODY child");

      prepareTarget(true, 'relative', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of relative BODY child");

      prepareTarget(true, 'relative', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of relative BODY child");

      prepareTarget(true, 'static', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of static BODY child");

      prepareTarget(true, 'static', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of static BODY child");
    }},
    
    testPositionCloneFromStatic: function() { with(this) {
      var source = Builder.node('div', 
        {id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123');
      document.body.appendChild(source);
      var expected =  Object.inspect(Position.page($('source_div')));
      assertEqual(expected, Object.inspect(Position.page($('source_div'))));
    
      prepareTarget(false, 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute BODY child");

      prepareTarget(false, 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed BODY child");

      prepareTarget(true, 'absolute', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of absolute BODY child");

      prepareTarget(true, 'absolute', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of absolute BODY child");

      prepareTarget(true, 'relative', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of relative BODY child");

      prepareTarget(true, 'relative', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of relative BODY child");

      prepareTarget(true, 'static', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of static BODY child");

      prepareTarget(true, 'static', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of static BODY child");
    }},
    
    testPositionCloneFromAbsoluteWithHiddenTarget: function() { with(this) {
      var source = Builder.node('div', 
        {id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123');
      document.body.appendChild(source);
      var expected = Object.inspect([120, 20]);
      assertEqual(expected, Object.inspect(Position.page($('source_div'))));
    
      prepareTargetHidden(false, 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute BODY child");
    
      prepareTargetHidden(false, 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed BODY child");
    
      prepareTargetHidden(true, 'absolute', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of absolute BODY child");
    
      prepareTargetHidden(true, 'absolute', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of absolute BODY child");
    
      prepareTargetHidden(true, 'relative', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of relative BODY child");
    
      prepareTargetHidden(true, 'relative', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of relative BODY child");
    
      prepareTargetHidden(true, 'static', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of static BODY child");
    
      prepareTargetHidden(true, 'static', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of static BODY child");
    }},
    
    testPositionCloneFromRelativeWithHiddenTarget: function() { with(this) {
      var source = Builder.node('div', 
        {id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123');
      document.body.appendChild(source);
      var expected =  Object.inspect(Position.page($('source_div')));
      assertEqual(expected, Object.inspect(Position.page($('source_div'))));
    
      prepareTargetHidden(false, 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute BODY child");
    
      prepareTargetHidden(false, 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed BODY child");
    
      prepareTargetHidden(true, 'absolute', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of absolute BODY child");
    
      prepareTargetHidden(true, 'absolute', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of absolute BODY child");
    
      prepareTargetHidden(true, 'relative', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of relative BODY child");
    
      prepareTargetHidden(true, 'relative', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of relative BODY child");
    
      prepareTargetHidden(true, 'static', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of static BODY child");
    
      prepareTargetHidden(true, 'static', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of static BODY child");
    }},
    
    testPositionCloneFromStaticWithHiddenTarget: function() { with(this) {
      var source = Builder.node('div', 
        {id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123');
      document.body.appendChild(source);
      var expected =  Object.inspect(Position.page($('source_div')));
      assertEqual(expected, Object.inspect(Position.page($('source_div'))));
    
      prepareTargetHidden(false, 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute BODY child");
    
      prepareTargetHidden(false, 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed BODY child");
    
      prepareTargetHidden(true, 'absolute', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of absolute BODY child");
    
      prepareTargetHidden(true, 'absolute', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of absolute BODY child");
    
      prepareTargetHidden(true, 'relative', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of relative BODY child");
    
      prepareTargetHidden(true, 'relative', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of relative BODY child");
    
      prepareTargetHidden(true, 'static', 'absolute');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to absolute child of static BODY child");
    
      prepareTargetHidden(true, 'static', 'fixed');    
      assertEqual(expected, Object.inspect(Position.page($('target_div'))),
        "Clone to fixed child of static BODY child");
    }}
    
  });

// ]]>
</script>

<!-- Test elements will be inserted after this -->

</body>
</html>