| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| "http://www.w3.org/TR/html4/strict.dtd"> |
| <html> |
| <head> |
| <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| <title>Test of webkitConvertPointFromNodeToPage function</title> |
| <link rel="stylesheet" href="../../js/resources/js-test-style.css"/> |
| <script src="../../js/resources/js-test-pre.js"></script> |
| <style type="text/css" media="screen"> |
| body { |
| height: 1000px; |
| } |
| |
| h1 { |
| font-size: 14pt; |
| } |
| .layer { |
| position: relative; |
| width: 600px; |
| height: 500px; |
| -webkit-transform: translate(0px); |
| } |
| .dot { |
| position: absolute; |
| background-color: #0f0; |
| width: 10px; |
| height: 10px; |
| left: 0px; |
| top: 0px; |
| visibility: hidden; |
| } |
| b.border { |
| border: 5px solid blue; |
| } |
| |
| .a { |
| position: relative; |
| left: 10px; |
| background: #cbc; |
| width: 800px; |
| -webkit-transform-origin: top left; |
| -webkit-transform: translate(130px, 20px) rotate(-35deg) scale(0.6); |
| padding: 5px; |
| margin-bottom: 20px; |
| } |
| .b { |
| position: relative; |
| background: #bcc; |
| -webkit-transform: translate(20px); |
| } |
| .c { |
| position: relative; |
| -webkit-transform: translate(20px); |
| background: #99c; |
| } |
| .d { |
| position: relative; |
| background: #cc9; |
| } |
| |
| </style> |
| <script> |
| function runTest(name, id, x1, y1, x2, y2) |
| { |
| debug(""); |
| debug(name); |
| var node = document.getElementById(id); |
| p = webkitConvertPointFromNodeToPage(node, new WebKitPoint(0, 0)); |
| x = Math.round(p.x); |
| y = Math.round(p.y); |
| shouldBe('x', x1+""); |
| shouldBe('y', y1+""); |
| |
| debug("Round Trip of (0,0)"); |
| p2 = webkitConvertPointFromPageToNode(node, p); |
| x = Math.round(p2.x); |
| y = Math.round(p2.y); |
| if (x == -0) |
| x = 0; |
| if (y == -0) |
| y = 0; |
| shouldBe('x', '0'); |
| shouldBe('y', '0'); |
| |
| p = webkitConvertPointFromNodeToPage(node, new WebKitPoint(5, 40)); |
| x = Math.round(p.x); |
| y = Math.round(p.y); |
| if (x == -0) |
| x = 0; |
| if (y == -0) |
| y = 0; |
| shouldBe('x', x2+""); |
| shouldBe('y', y2+""); |
| |
| debug("Round Trip of (5,40)"); |
| p2 = webkitConvertPointFromPageToNode(node, p); |
| x = Math.round(p2.x); |
| y = Math.round(p2.y); |
| if (x == -0) |
| x = 0; |
| if (y == -0) |
| y = 0; |
| shouldBe('x', '5'); |
| shouldBe('y', '40'); |
| } |
| |
| function run() { |
| description("This test exercises the webkitConvertPointFromNodeToPage() function"); |
| |
| debug("Test parameter passing - should not crash"); |
| var point = webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0)); |
| if (point == null) |
| testPassed("Missing parameter test"); |
| else |
| testFailed("Missing parameter test"); |
| debug("Test did not crash and therefore was successful"); |
| debug(""); |
| point = webkitConvertPointFromNodeToPage(null, new WebKitPoint(0, 0)); |
| if (point == null) |
| testPassed("null parameter test a"); |
| else |
| testFailed("null parameter test a"); |
| debug("Test did not crash and therefore was successful"); |
| debug(""); |
| point = webkitConvertPointFromNodeToPage(null, null); |
| if (point == null) |
| testPassed("null parameter test b"); |
| else |
| testFailed("null parameter test b"); |
| debug("Test did not crash and therefore was successful"); |
| |
| runTest("Test 1", "test1", 8, 12, 13, 52); |
| runTest("Test 2", "test2", 8, 50, 13, 90); |
| runTest("Test 3", "test3", 8, 84, 13, 124); |
| runTest("Test 4", "test4", 8, 118, 13, 158); |
| runTest("Test 5", "test5", 28, 152, 33, 192); |
| runTest("Test 6", "test6", 28, 186, 33, 226); |
| runTest("Test 7", "test7", 8, 238, 13, 278); |
| runTest("Test 8", "test8", 8, 272, 13, 312); |
| runTest("Test 9", "test9", 28, 290, 33, 330); |
| runTest("Test 10", "test10", 28, 308, 33, 348); |
| runTest("Test 11", "test11", 158, 355, 174, 373); |
| runTest("Test 12", "test12", 168, 428, 184, 446); |
| runTest("Test 13", "test13", 28, 486, 33, 526); |
| |
| debug('<br /><span class="pass">TEST COMPLETE</span>'); |
| |
| if (window.layoutTestController) |
| window.layoutTestController.notifyDone(); |
| } |
| |
| function pageLoaded() |
| { |
| if (window.layoutTestController) |
| window.layoutTestController.waitUntilDone(); |
| setTimeout(run, 0); |
| } |
| successfullyParsed = true; |
| |
| </script> |
| </head> |
| <body onload="pageLoaded()"> |
| <h1 id="test1">Test 1 - This is a H1 heading.</h1> |
| <p id="test2">Test 2 - This is a simple paragraph.</p> |
| <p id="test3">Test 3 - This is a paragraph with a <b>nested</b> element.</p> |
| <p id="test4">Test 4 - This is a paragraph with a <b class="border">nested</b> element that has a border.</p> |
| <p id="test5" class="c">Test 5 - This is a transformed paragraph with a <b class="border">nested</b> element that has a border.</p> |
| <p id="test6" class="c">Test 6 - This is a transformed paragraph with a <b class="border">nested</b> element that has a border.<br>And then a second line.</p> |
| <div class="d"> |
| <p id="test7">Test 7 - This is a paragraph inside something that does not have a compositing layer.</p> |
| </div> |
| <div id="test8" class="d"> |
| Test 8 - This is raw text inside something that does not have a compositing layer. |
| </div> |
| |
| <div id="test9" class="b"> |
| Test 9 - This is raw text inside something that has a compositing layer. |
| <div id="test10" class="d"> |
| Test 10 - This is raw text inside something that does not have a compositing layer. |
| </div> |
| </div> |
| |
| <div class="a"> |
| <p id="test11">Test 11 - This is a rotated and scaled paragraph</p> |
| </div> |
| <div class="a"> |
| <div class="b"> |
| <p id="test12">Test 12 - This is a rotated and scaled paragraph with a <b class="border">nested</b> element that has a border.</p> |
| </div> |
| </div> |
| <div class="b"> |
| <p id="test13">Test 13 - This is a paragraph with a <b class="border">nested</b> element that has a border.</p> |
| </div> |
| <div id="description"></div> |
| <div id="console"></div> |
| </body> |
| <script src="../../js/resources/js-test-post.js"></script> |
| </html> |