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.
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
5 var gTimeoutId;
6 var gTimeoutCount = 0;
7 var gIntervalCount = 0;
9 function timeoutFunc() {
10 if (++gTimeoutCount > 1) {
11 throw new Error("Timeout called more than once!");
12 }
13 postMessage("timeoutFinished");
14 }
16 function intervalFunc() {
17 if (++gIntervalCount == 2) {
18 postMessage("intervalFinished");
19 }
20 }
22 function messageListener(event) {
23 switch (event.data) {
24 case "startTimeout":
25 gTimeoutId = setTimeout(timeoutFunc, 2000);
26 clearTimeout(gTimeoutId);
27 gTimeoutId = setTimeout(timeoutFunc, 2000);
28 break;
29 case "startInterval":
30 gTimeoutId = setInterval(intervalFunc, 2000);
31 break;
32 case "cancelInterval":
33 clearInterval(gTimeoutId);
34 postMessage("intervalCanceled");
35 break;
36 case "startExpression":
37 setTimeout("this.postMessage('expressionFinished');", 2000);
38 break;
39 default:
40 throw "Bad message: " + event.data;
41 }
42 }
44 addEventListener("message", messageListener, false);