layout/generic/test/test_plugin_mouse_coords.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test delivering mouse events to plugins</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 7 <script type="text/javascript" src="enableTestPlugin.js"></script>
michael@0 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 9 <style>
michael@0 10 embed { width:200px; height:200px; display:block; }
michael@0 11 iframe { border:none; }
michael@0 12 </style>
michael@0 13 </head>
michael@0 14 <body>
michael@0 15 <p id="display"></p>
michael@0 16 <div id="content" style="display: block">
michael@0 17 <embed id="p1" type="application/x-test"
michael@0 18 style="position:absolute; left:300px; top:10px;"></embed>
michael@0 19 <iframe id="f1" style="position:absolute; left:0; top:250px;"
michael@0 20 src="data:text/html,&lt;embed id='p2' type='application/x-test' style='position:absolute; left:10px; top:10px'&gt;"></iframe>
michael@0 21 <embed id="p3" type="application/x-test"
michael@0 22 style="position:absolute; left:320px; top:250px;
michael@0 23 outline:5px solid blue;
michael@0 24 border:solid black; border-width:4px 8px 4px 8px;
michael@0 25 padding:3px 1px;"></embed>
michael@0 26 </div>
michael@0 27 <pre id="test">
michael@0 28 <script class="testbody" type="text/javascript">
michael@0 29
michael@0 30 function doTest() {
michael@0 31 var p1 = document.getElementById("p1");
michael@0 32 synthesizeMouse(p1, 15, 18, { type:"mousedown" });
michael@0 33 is(p1.getLastMouseX(), 15, "p1 mouse down X");
michael@0 34 is(p1.getLastMouseY(), 18, "p1 mouse down Y");
michael@0 35 synthesizeMouse(p1, 15, 38, { type:"mousemove" });
michael@0 36 is(p1.getLastMouseX(), 15, "p1 mouse move X");
michael@0 37 is(p1.getLastMouseY(), 38, "p1 mouse move Y");
michael@0 38 synthesizeMouse(p1, 15, 28, { type:"mouseup" });
michael@0 39 is(p1.getLastMouseX(), 15, "p1 mouse up X");
michael@0 40 is(p1.getLastMouseY(), 28, "p1 mouse up Y");
michael@0 41
michael@0 42 var f1 = document.getElementById("f1");
michael@0 43 var p2 = f1.contentDocument.getElementById("p2");
michael@0 44 synthesizeMouse(p2, 15, 18, { type:"mousedown" }, f1.contentWindow);
michael@0 45 is(p2.getLastMouseX(), 15, "p2 mouse down X");
michael@0 46 is(p2.getLastMouseY(), 18, "p2 mouse down Y");
michael@0 47 synthesizeMouse(p2, 15, 38, { type:"mousemove" }, f1.contentWindow);
michael@0 48 is(p2.getLastMouseX(), 15, "p2 mouse move X");
michael@0 49 is(p2.getLastMouseY(), 38, "p2 mouse move Y");
michael@0 50 synthesizeMouse(p2, 15, 28, { type:"mouseup" }, f1.contentWindow);
michael@0 51 is(p2.getLastMouseX(), 15, "p2 mouse up X");
michael@0 52 is(p2.getLastMouseY(), 28, "p2 mouse up Y");
michael@0 53
michael@0 54 var p3 = document.getElementById("p3");
michael@0 55 // The synthesized coordinates are relative to the border-box, but the plugin
michael@0 56 // is at offset (9,7) relative to the border-box
michael@0 57 synthesizeMouse(p3, 15, 18, { type:"mousedown" });
michael@0 58 is(p3.getLastMouseX(), 6, "p3 mouse down X");
michael@0 59 is(p3.getLastMouseY(), 11, "p3 mouse down Y");
michael@0 60 synthesizeMouse(p3, 15, 38, { type:"mousemove" });
michael@0 61 is(p3.getLastMouseX(), 6, "p3 mouse move X");
michael@0 62 is(p3.getLastMouseY(), 31, "p3 mouse move Y");
michael@0 63 synthesizeMouse(p3, 15, 28, { type:"mouseup" });
michael@0 64 is(p3.getLastMouseX(), 6, "p3 mouse up X");
michael@0 65 is(p3.getLastMouseY(), 21, "p3 mouse up Y");
michael@0 66
michael@0 67 SimpleTest.finish();
michael@0 68 }
michael@0 69 // Need to run 'doTest' after painting is unsuppressed, or we'll set clip
michael@0 70 // regions to empty.
michael@0 71 addLoadEvent(function() { setTimeout(doTest, 1000); } );
michael@0 72 SimpleTest.waitForExplicitFinish();
michael@0 73
michael@0 74 </script>
michael@0 75 </pre>
michael@0 76 </body>
michael@0 77 </html>

mercurial