content/xul/document/test/test_bug199692.xul

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial