tbb-tests/test_tor_bug4755.html

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 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 Tor bug
     5 https://trac.torproject.org/projects/tor/ticket/4755
     6 -->
     7 <head>
     8   <meta charset="utf-8">
     9   <title>Test for Tor Bug #4755: Return client window coordinates for mouse event screenX/Y.</title>
    10   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    11   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    12   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    13 </head>
    14 <body>
    15 <a target="_blank" href="https://trac.torproject.org/projects/tor/ticket/4755">Tor Bug 4755</a>
    16 <p id="display"></p>
    17 <pre id="test"></pre>
    18 <script type="application/javascript">
    19   // This test produces fake mouse events and checks that the screenX and screenY
    20   // properties of the received event objects provide client window coordinates.
    21   function test_go () { 
    22     // Listening for asynchronous events, so we need to use the following call.
    23     SimpleTest.waitForExplicitFinish();
    24     // A full list of possible mouse and touch events.
    25     var eventTypes = ["mousedown", "mouseup"],
    26                      // TODO: get the following events working. No success so far.
    27                  /*  ["click", "contextmenu", "DOMMouseScroll", "dblclick", "wheel",
    28                       "mouseenter", "mouseleave", "mousemove", "mouseout", "mouseover",
    29                       "MozEdgeUIGesture", "MozMagnifyGesture", "MozMagnifyGestureStart",
    30                       "MozMagnifyGestureUpdate", "MozPressTapGesture", "MozRotateGesture",
    31                       "MozRotateGestureStart", "MozRotateGestureUpdate", "MozSwipeGesture",
    32                       "MozTapGesture", "MozTouchDown", "MozTouchMove", "MozTouchUp",
    33                       "touchcancel", "touchend", "touchenter", "touchleave", "touchmove",
    34                       "touchstart"], */
    35         n = eventTypes.length,
    36         examineEvent = function examineEvent (event) {
    37           console.log(n, event.type, event.screenX, event.clientX, event.screenY, event.clientY);
    38           is(event.screenX, event.clientX, "event.screenX and event.clientX should be the same");
    39           is(event.screenY, event.clientY, "event.screenY and event.clientY should be the same");
    40           --n;
    41           if (n === 0) {
    42             // We have now received all posted events.
    43             SimpleTest.finish();
    44           }
    45         },
    46         pretest = document.querySelector("pre#test");
    47     // The following loop creates a new div for each event in eventTypes,
    48     // attaches a listener to listen for the event, and then generates
    49     // a fake event at the center of the div.
    50     for (var i = 0; i < eventTypes.length; ++i) {
    51       var div = document.createElement("div");
    52       div.style = "width:10px;height:10px;background-color:red;";
    53       // Name the div after the event we're listening for.
    54       div.id = eventTypes[i];
    55       document.body.appendChild(div);
    56       div.addEventListener(eventTypes[i], examineEvent, false);
    57       // For some reason, the following synthesizeMouseAtCenter call only seems to run if we
    58       // wrap it in a window.setTimeout(..., 0).
    59       window.setTimeout(() => synthesizeMouseAtCenter(div, {type : eventTypes[i]}), 0);
    60     }
    61   }
    62   // Run the test once the window has loaded.
    63   window.onload = test_go;
    64 </script>
    65 </body>
    66 </html>

mercurial