1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/document/test/test_bug199692.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=199692 1.9 +--> 1.10 +<window title="Test for Bug 199692" 1.11 + id="test_bug199692_xul" 1.12 + xmlns:html="http://www.w3.org/1999/xhtml" 1.13 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.14 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.15 + 1.16 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.17 + <vbox hidden="true"> 1.18 + <bindings xmlns="http://www.mozilla.org/xbl" 1.19 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.20 + <binding id="anon"> 1.21 + <content> 1.22 + <xul:label id="anon-label" value="ANON"/> 1.23 + </content> 1.24 + </binding> 1.25 + </bindings> 1.26 + </vbox> 1.27 + 1.28 +<body id="body" xmlns="http://www.w3.org/1999/xhtml"> 1.29 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=199692">Mozilla Bug 199692</a> 1.30 + 1.31 +<vbox id="content" style="position: relative;" 1.32 +xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.33 + <xul:label id="non-anon-label" value="a textbox!:" control="textbox"/> 1.34 + <xul:textbox id="textbox" multiline="true" rows="4" /> 1.35 + <xul:radiogroup style="outline: 2px solid orange;"> 1.36 + <xul:radio id="unselected-radio" label="Orange" style="outline: 2px solid red;"/> 1.37 + <xul:radio id="selected-radio" label="Violet" selected="true"/> 1.38 + <xul:radio id="disabled-radio" label="Yellow" disabled="true"/> 1.39 + </xul:radiogroup> 1.40 + <hbox id="bound" style="-moz-binding:url('#anon'); border: 2px solid green;"></hbox> 1.41 +</vbox> 1.42 +<pre id="test"> 1.43 + <script class="testbody" type="text/javascript"> 1.44 +<![CDATA[ 1.45 + SimpleTest.waitForExplicitFinish(); 1.46 + 1.47 + // Before onload, XUL docs have no root frame. 1.48 + is(document.elementFromPoint(10,10), null, 1.49 + "Calls to elementFromPoint before onload should return null"); 1.50 + 1.51 + var d = 10; 1.52 + function middle(e) { 1.53 + return { "x": e.boxObject.x + e.boxObject.width/2, 1.54 + "y": e.boxObject.y + e.boxObject.height/2 }; 1.55 + } 1.56 + function lower_right(e) { 1.57 + return { "x": e.boxObject.x + e.boxObject.width - d, 1.58 + "y": e.boxObject.y + e.boxObject.height - d }; 1.59 + } 1.60 + function upper_left(e) { 1.61 + return { "x": e.boxObject.x + d, 1.62 + "y": e.boxObject.y + d }; 1.63 + } 1.64 + function scrollbar_button(e) { // a bit down from upper right 1.65 + return { "x": e.boxObject.x + e.boxObject.width - d, 1.66 + "y": e.boxObject.y + d + 15 }; 1.67 + } 1.68 + 1.69 + function test(ptFunc, id, message) { 1.70 + var pt = ptFunc($(id)); 1.71 + var e = document.elementFromPoint(pt.x, pt.y); 1.72 + ok(e != null, message + " (returned null)"); 1.73 + is(e.id, id, message); 1.74 + } 1.75 + 1.76 + function do_test() { 1.77 + // Avoid hardcoding x,y pixel values, to better deal with differing default 1.78 + // font sizes or other layout defaults. 1.79 + 1.80 + test(middle, 'textbox', "Point within textbox should return textbox element"); 1.81 + test(lower_right, 'textbox', "Point on textbox's scrollbar should return textbox element"); 1.82 + test(scrollbar_button, 'textbox', "Point on textbox's scrollbar button should return textbox element"); 1.83 + test(middle, 'non-anon-label', "Point on label should return label"); 1.84 + test(upper_left, 'bound', "Point on XBL content should return element with -moz-binding style"); 1.85 + 1.86 + SimpleTest.finish(); 1.87 + } 1.88 + $("textbox").setAttribute("value", 1.89 + "lorem ipsum dolor sit amet " + 1.90 + "lorem ipsum dolor sit amet " + 1.91 + "lorem ipsum dolor sit amet " + 1.92 + "lorem ipsum dolor sit amet " + 1.93 + "lorem ipsum dolor sit amet " + 1.94 + "lorem ipsum dolor sit amet " + 1.95 + "lorem ipsum dolor sit amet "); // force scrollbars to appear 1.96 + addLoadEvent(do_test); 1.97 +]]> 1.98 + </script> 1.99 +</pre> 1.100 +</body> 1.101 +</window>