dom/tests/html/jshandlers.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.

michael@0 1 <html>
michael@0 2 <body>
michael@0 3 The link below has an onmousedown, an onmouseup, and an onmousemove handler.
michael@0 4 Mouseover or click for event info in debug console.
michael@0 5 <a href="jshandlers.html">Link back to this page</a>
michael@0 6
michael@0 7 <p>The link below has an event that should open www.mozilla.org when
michael@0 8 clicked
michael@0 9 </p>
michael@0 10 <!-- The link does 'return 0' - as per bug 345521 this should *not* be
michael@0 11 interpreted as false
michael@0 12 -->
michael@0 13 <a href="http://www.mozilla.org" onclick="return 0">Click me</a>
michael@0 14
michael@0 15 <p>The link below has an event that is cancelled - nothing should happen when
michael@0 16 clicked
michael@0 17 </p>
michael@0 18 <a href="http://www.mozilla.org" onclick="return false">Click me<a/>
michael@0 19
michael@0 20 </body>
michael@0 21 <script>
michael@0 22 function findElementByTagName(start, tag)
michael@0 23 {
michael@0 24 var type = start.nodeType;
michael@0 25
michael@0 26 if (type == Node.ELEMENT) {
michael@0 27
michael@0 28 if (tag == start.tagName) {
michael@0 29 //dump ("found one\n");
michael@0 30 return start;
michael@0 31 }
michael@0 32
michael@0 33 if (start.hasChildNodes) {
michael@0 34 var children = start.childNodes;
michael@0 35 var length = children.length;
michael@0 36 var count = 0;
michael@0 37 while(count < length) {
michael@0 38 var ret = findElementByTagName(children[count], tag)
michael@0 39 if (null != ret) {
michael@0 40 return ret;
michael@0 41 }
michael@0 42 count++;
michael@0 43 }
michael@0 44 }
michael@0 45 }
michael@0 46 return null;
michael@0 47 }
michael@0 48
michael@0 49 function getFirstLink()
michael@0 50 {
michael@0 51 var node = document.documentElement;
michael@0 52 var ret = findElementByTagName(node, "A");
michael@0 53 return ret;
michael@0 54 }
michael@0 55
michael@0 56 function ondown()
michael@0 57 {
michael@0 58 dump("got mousedown in script\n");
michael@0 59 }
michael@0 60
michael@0 61 function onup()
michael@0 62 {
michael@0 63 dump("got mouseup in script\n");
michael@0 64 }
michael@0 65
michael@0 66 function onmove(event)
michael@0 67 {
michael@0 68 dump("got mousemove in script at "+event.clientX+", "+event.clientY+"\n");
michael@0 69 }
michael@0 70
michael@0 71 var l = getFirstLink();
michael@0 72 l.onmousedown = ondown;
michael@0 73 l.onmouseup = onup;
michael@0 74 l.onmousemove = onmove;
michael@0 75 </script>
michael@0 76 </html>

mercurial