1 |
|
2 // This file contains functions to be used for testing and logging. |
|
3 |
|
4 var loadStartTime = new Date().getTime(); |
|
5 var loadCount = 0; |
|
6 |
|
7 // Setup callback for loadStarted signal. |
|
8 // Called when a new page has started loading. |
|
9 // |
|
10 window.pageController.loadStarted.connect( |
|
11 function() { |
|
12 loadStartTime = new Date().getTime(); |
|
13 window.chrome.log("loadStarted:"); |
|
14 } |
|
15 ); |
|
16 |
|
17 // Setup callback for URL changed signal. |
|
18 // Called when a new page has started loading. |
|
19 // |
|
20 window.pageController.currentPageUrlChanged.connect( |
|
21 function(url) { |
|
22 window.chrome.log("currentPageUrlChanged: " + url); |
|
23 } |
|
24 ); |
|
25 |
|
26 // Setup callback for loadFinished signal. |
|
27 // Called when the current page has finished loading. |
|
28 // 'ok' parameter is false if there was an error (not very reliable). |
|
29 // |
|
30 window.pageController.loadFinished.connect( |
|
31 function(ok) { |
|
32 window.chrome.log("loadFinished: " + |
|
33 "load count: " + loadCount + " " + |
|
34 "load time: " + (new Date().getTime() - loadStartTime) + "ms " + |
|
35 "ok=" + ok + " " + window.pageController.currentDocUrl); |
|
36 //window.pageController.currentLoad("http://www.google.com/search?q=help"); |
|
37 |
|
38 loadCount++; |
|
39 |
|
40 // Load another document. This will effectively keep loading the same document forever. |
|
41 //setTimeout("window.pageController.currentLoad('http://doc.trolltech.com/4.6/classes.html')",1000); |
|
42 //setTimeout("window.pageController.currentLoad('http://www.google.com/search?q=help')",1000); |
|
43 } |
|
44 ); |
|
45 |
|
46 // Setup callback for loadProgress signal. |
|
47 // Called periodically during the load process. |
|
48 // 'percent' parameter indicates how much of the document has been loaded (0-100). |
|
49 // |
|
50 //window.pageController.loadProgress.connect( |
|
51 // function(percent) { |
|
52 // window.chrome.log("loadProgress: percent=" + percent); |
|
53 // window.chrome.alert("loadProgress: percent=" + percent); |
|
54 // } |
|
55 //); |
|
56 |
|
57 // Setup callback for the chrome's loadComplete signal. |
|
58 // Called when the chrome finishes loading. |
|
59 // |
|
60 window.chrome.loadComplete.connect( |
|
61 function() { |
|
62 window.chrome.log("chrome.loadComplete"); |
|
63 } |
|
64 ); |
|
65 |
|
66 |
|