content/xul/document/test/test_bug199692.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 https://bugzilla.mozilla.org/show_bug.cgi?id=199692
michael@0 6 -->
michael@0 7 <window title="Test for Bug 199692"
michael@0 8 id="test_bug199692_xul"
michael@0 9 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 10 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 12
michael@0 13 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 14 <vbox hidden="true">
michael@0 15 <bindings xmlns="http://www.mozilla.org/xbl"
michael@0 16 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 17 <binding id="anon">
michael@0 18 <content>
michael@0 19 <xul:label id="anon-label" value="ANON"/>
michael@0 20 </content>
michael@0 21 </binding>
michael@0 22 </bindings>
michael@0 23 </vbox>
michael@0 24
michael@0 25 <body id="body" xmlns="http://www.w3.org/1999/xhtml">
michael@0 26 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=199692">Mozilla Bug 199692</a>
michael@0 27
michael@0 28 <vbox id="content" style="position: relative;"
michael@0 29 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 30 <xul:label id="non-anon-label" value="a textbox!:" control="textbox"/>
michael@0 31 <xul:textbox id="textbox" multiline="true" rows="4" />
michael@0 32 <xul:radiogroup style="outline: 2px solid orange;">
michael@0 33 <xul:radio id="unselected-radio" label="Orange" style="outline: 2px solid red;"/>
michael@0 34 <xul:radio id="selected-radio" label="Violet" selected="true"/>
michael@0 35 <xul:radio id="disabled-radio" label="Yellow" disabled="true"/>
michael@0 36 </xul:radiogroup>
michael@0 37 <hbox id="bound" style="-moz-binding:url('#anon'); border: 2px solid green;"></hbox>
michael@0 38 </vbox>
michael@0 39 <pre id="test">
michael@0 40 <script class="testbody" type="text/javascript">
michael@0 41 <![CDATA[
michael@0 42 SimpleTest.waitForExplicitFinish();
michael@0 43
michael@0 44 // Before onload, XUL docs have no root frame.
michael@0 45 is(document.elementFromPoint(10,10), null,
michael@0 46 "Calls to elementFromPoint before onload should return null");
michael@0 47
michael@0 48 var d = 10;
michael@0 49 function middle(e) {
michael@0 50 return { "x": e.boxObject.x + e.boxObject.width/2,
michael@0 51 "y": e.boxObject.y + e.boxObject.height/2 };
michael@0 52 }
michael@0 53 function lower_right(e) {
michael@0 54 return { "x": e.boxObject.x + e.boxObject.width - d,
michael@0 55 "y": e.boxObject.y + e.boxObject.height - d };
michael@0 56 }
michael@0 57 function upper_left(e) {
michael@0 58 return { "x": e.boxObject.x + d,
michael@0 59 "y": e.boxObject.y + d };
michael@0 60 }
michael@0 61 function scrollbar_button(e) { // a bit down from upper right
michael@0 62 return { "x": e.boxObject.x + e.boxObject.width - d,
michael@0 63 "y": e.boxObject.y + d + 15 };
michael@0 64 }
michael@0 65
michael@0 66 function test(ptFunc, id, message) {
michael@0 67 var pt = ptFunc($(id));
michael@0 68 var e = document.elementFromPoint(pt.x, pt.y);
michael@0 69 ok(e != null, message + " (returned null)");
michael@0 70 is(e.id, id, message);
michael@0 71 }
michael@0 72
michael@0 73 function do_test() {
michael@0 74 // Avoid hardcoding x,y pixel values, to better deal with differing default
michael@0 75 // font sizes or other layout defaults.
michael@0 76
michael@0 77 test(middle, 'textbox', "Point within textbox should return textbox element");
michael@0 78 test(lower_right, 'textbox', "Point on textbox's scrollbar should return textbox element");
michael@0 79 test(scrollbar_button, 'textbox', "Point on textbox's scrollbar button should return textbox element");
michael@0 80 test(middle, 'non-anon-label', "Point on label should return label");
michael@0 81 test(upper_left, 'bound', "Point on XBL content should return element with -moz-binding style");
michael@0 82
michael@0 83 SimpleTest.finish();
michael@0 84 }
michael@0 85 $("textbox").setAttribute("value",
michael@0 86 "lorem ipsum dolor sit amet " +
michael@0 87 "lorem ipsum dolor sit amet " +
michael@0 88 "lorem ipsum dolor sit amet " +
michael@0 89 "lorem ipsum dolor sit amet " +
michael@0 90 "lorem ipsum dolor sit amet " +
michael@0 91 "lorem ipsum dolor sit amet " +
michael@0 92 "lorem ipsum dolor sit amet "); // force scrollbars to appear
michael@0 93 addLoadEvent(do_test);
michael@0 94 ]]>
michael@0 95 </script>
michael@0 96 </pre>
michael@0 97 </body>
michael@0 98 </window>

mercurial