Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=390488 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 390488</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=390488">Mozilla Bug 390488</a> |
michael@0 | 13 | <p id="display"> |
michael@0 | 14 | <div id="testdiv" onclick="checkForStacks();" style="visibility:hidden"> |
michael@0 | 15 | </div> |
michael@0 | 16 | </p> |
michael@0 | 17 | <div id="content" style="display: none"> |
michael@0 | 18 | |
michael@0 | 19 | </div> |
michael@0 | 20 | <pre id="test"> |
michael@0 | 21 | <script class="testbody" type="text/javascript"> |
michael@0 | 22 | |
michael@0 | 23 | /** Test for Bug 390488 **/ |
michael@0 | 24 | function getStack1() { |
michael@0 | 25 | var func = arguments.callee.caller; |
michael@0 | 26 | var stack = ""; |
michael@0 | 27 | for (var i = 1; func && i < 8; i++) { |
michael@0 | 28 | stack += " " + i + ". " + func.name; |
michael@0 | 29 | func = func.caller; |
michael@0 | 30 | } |
michael@0 | 31 | return stack; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function getStack2() { |
michael@0 | 35 | var stack = new Error().stack; |
michael@0 | 36 | // Remove the two lines due to calling this |
michael@0 | 37 | return stack.substring(stack.indexOf("\n", stack.indexOf("\n")+1)+1); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function simulateClick() { |
michael@0 | 41 | var evt = document.createEvent("MouseEvents"); |
michael@0 | 42 | evt.initMouseEvent("click", true, true, window, |
michael@0 | 43 | 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
michael@0 | 44 | $("testdiv").dispatchEvent(evt); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function matches(s, p, name) { |
michael@0 | 48 | ok(s.match(p) != null, name, |
michael@0 | 49 | "got " + uneval(s) + ", expected a string matching " + uneval(p)); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function checkForStacks() { |
michael@0 | 53 | matches(getStack1(), /checkForStacks .* onclick .* simulateClick/, |
michael@0 | 54 | "Stack from walking caller chain should be correct"); |
michael@0 | 55 | isnot(getStack2().indexOf("simulateClick@"), -1, |
michael@0 | 56 | "Stack from |new Error().stack| should include simulateClick"); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | simulateClick(); |
michael@0 | 60 | </script> |
michael@0 | 61 | </pre> |
michael@0 | 62 | </body> |
michael@0 | 63 | </html> |
michael@0 | 64 |