toolkit/content/tests/chrome/test_position.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 XUL Widget Test for positioning
michael@0 6 -->
michael@0 7 <window title="position" width="500" height="600"
michael@0 8 onload="setTimeout(runTest, 0);"
michael@0 9 style="margin: 0; border: 0; padding; 0;"
michael@0 10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 12 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 13
michael@0 14
michael@0 15 <hbox id="box1">
michael@0 16 <button label="0" width="100" height="40" style="margin: 3px;"/>
michael@0 17 </hbox>
michael@0 18 <scrollbox id="box2" orient="vertical" align="start" width="200" height="50"
michael@0 19 style="overflow: hidden; margin-left: 2px; padding: 1px;">
michael@0 20 <deck>
michael@0 21 <scrollbox id="box3" orient="vertical" align="start" height="100"
michael@0 22 style="overflow: scroll; margin: 1px; padding: 0;">
michael@0 23 <vbox id="innerscroll" width="200" align="start">
michael@0 24 <button id="button1" label="1" width="90" maxwidth="100"
michael@0 25 minheight="25" height="35" maxheight="50"
michael@0 26 style="min-width: 80px; margin: 5px; border: 4px; padding: 7px;
michael@0 27 -moz-appearance: none;"/>
michael@0 28 <menu id="menu">
michael@0 29 <menupopup id="popup" style="-moz-appearance: none; margin:0; border: 0; padding: 0;"
michael@0 30 onpopupshown="menuOpened()"
michael@0 31 onpopuphidden="if (event.target == this) SimpleTest.finish()">
michael@0 32 <menuitem label="One"/>
michael@0 33 <menu id="submenu" label="Three">
michael@0 34 <menupopup id="subpopup" style="-moz-appearance: none; margin:0; border: 0; padding: 0;"
michael@0 35 onpopupshown="submenuOpened()">
michael@0 36 <menuitem label="Four"/>
michael@0 37 </menupopup>
michael@0 38 </menu>
michael@0 39 </menupopup>
michael@0 40 </menu>
michael@0 41 <button label="2" maxwidth="100" maxheight="20" style="margin: 5px;"/>
michael@0 42 <button label="3" maxwidth="100" maxheight="20" style="margin: 5px;"/>
michael@0 43 <button label="4" maxwidth="100" maxheight="20" style="margin: 5px;"/>
michael@0 44 </vbox>
michael@0 45 <box height="200"/>
michael@0 46 </scrollbox>
michael@0 47 </deck>
michael@0 48 </scrollbox>
michael@0 49
michael@0 50 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 51 <p id="display"></p>
michael@0 52 <div id="content" style="display: none">
michael@0 53 </div>
michael@0 54 <pre id="test">
michael@0 55 </pre>
michael@0 56 </body>
michael@0 57
michael@0 58 <script>
michael@0 59 <![CDATA[
michael@0 60
michael@0 61 SimpleTest.waitForExplicitFinish();
michael@0 62
michael@0 63 function runTest()
michael@0 64 {
michael@0 65 var winwidth = document.documentElement.boxObject.width;
michael@0 66 var innerscroll = $("innerscroll").boxObject.width;
michael@0 67
michael@0 68 var box1 = $("box1");
michael@0 69 checkPosition("box1", box1, 0, 0, winwidth, 46);
michael@0 70
michael@0 71 var box2 = $("box2");
michael@0 72 checkPosition("box2", box2, 2, 46, winwidth, 96);
michael@0 73
michael@0 74 // height is height(box1) = 46 + margin-top(box3) = 1 + margin-top(button1) = 5
michael@0 75 var button1 = $("button1");
michael@0 76 checkPosition("button1", button1, 9, 53, 99, 88);
michael@0 77
michael@0 78 var sbo = box2.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
michael@0 79 sbo.scrollTo(7, 16);
michael@0 80
michael@0 81 // clientRect height is offset from root so is 16 pixels vertically less
michael@0 82 checkPosition("button1 scrolled", button1, 9, 37, 99, 72);
michael@0 83
michael@0 84 var box3 = $("box3");
michael@0 85 sbo = box3.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
michael@0 86 sbo.scrollTo(1, 2);
michael@0 87
michael@0 88 checkPosition("button1 scrolled", button1, 9, 35, 99, 70);
michael@0 89
michael@0 90 $("menu").open = true;
michael@0 91 }
michael@0 92
michael@0 93 function menuOpened()
michael@0 94 {
michael@0 95 $("submenu").open = true;
michael@0 96 }
michael@0 97
michael@0 98 function submenuOpened()
michael@0 99 {
michael@0 100 var menu = $("menu");
michael@0 101 var menuleft = Math.round(menu.getBoundingClientRect().left);
michael@0 102 var menubottom = Math.round(menu.getBoundingClientRect().bottom);
michael@0 103
michael@0 104 var submenu = $("submenu");
michael@0 105 var submenutop = Math.round(submenu.getBoundingClientRect().top);
michael@0 106 var submenuright = Math.round(submenu.getBoundingClientRect().right);
michael@0 107
michael@0 108 checkPosition("popup", $("popup"), menuleft, menubottom, -1, -1);
michael@0 109 checkPosition("subpopup", $("subpopup"), submenuright, submenutop, -1, -1);
michael@0 110
michael@0 111 menu.open = false;
michael@0 112 }
michael@0 113
michael@0 114 function checkPosition(testid, elem, cleft, ctop, cright, cbottom)
michael@0 115 {
michael@0 116 // -1 for right or bottom means that the exact size should not be
michael@0 117 // checked, just ensure it is larger then the left or top position
michael@0 118 var rect = elem.getBoundingClientRect();
michael@0 119 is(Math.round(rect.left), cleft, testid + " client rect left");
michael@0 120 if (testid != "popup")
michael@0 121 is(Math.round(rect.top), ctop, testid + " client rect top");
michael@0 122 if (cright >= 0)
michael@0 123 is(Math.round(rect.right), cright, testid + " client rect right");
michael@0 124 else
michael@0 125 ok(rect.right - rect.left > 20, testid + " client rect right");
michael@0 126 if (cbottom >= 0)
michael@0 127 is(Math.round(rect.bottom), cbottom, testid + " client rect bottom");
michael@0 128 else
michael@0 129 ok(rect.bottom - rect.top > 15, testid + " client rect bottom");
michael@0 130 }
michael@0 131
michael@0 132 ]]>
michael@0 133
michael@0 134 </script>
michael@0 135
michael@0 136 </window>

mercurial