1 |
4307
|
leinfelder
|
<script language="JavaScript">
|
2 |
|
|
if (window["selenium_has_been_loaded_into_this_window"]==null)
|
3 |
|
|
{
|
4 |
|
|
|
5 |
|
|
__SELENIUM_JS__
|
6 |
|
|
|
7 |
|
|
// Some background on the code below: broadly speaking, where we are relative to other windows
|
8 |
|
|
// when running in proxy injection mode depends on whether we are in a frame set file or not.
|
9 |
|
|
//
|
10 |
|
|
// In regular HTML files, the selenium JavaScript is injected into an iframe called "selenium"
|
11 |
|
|
// in order to reduce its impact on the JavaScript environment (through namespace pollution,
|
12 |
|
|
// etc.). So in regular HTML files, we need to look at the parent of the current window when we want
|
13 |
|
|
// a handle to, e.g., the application window.
|
14 |
|
|
//
|
15 |
|
|
// In frame set files, we can't use an iframe, so we put the JavaScript in the head element and share
|
16 |
|
|
// the window with the frame set. So in this case, we need to look at the current window, not the
|
17 |
|
|
// parent when looking for, e.g., the application window. (TODO: Perhaps I should have just
|
18 |
|
|
// assigned a regular frame for selenium?)
|
19 |
|
|
//
|
20 |
|
|
BrowserBot.prototype.getContentWindow = function() {
|
21 |
|
|
if (window["seleniumInSameWindow"] != null) return window;
|
22 |
|
|
return window.parent;
|
23 |
|
|
};
|
24 |
|
|
|
25 |
|
|
BrowserBot.prototype.getTargetWindow = function(windowName) {
|
26 |
|
|
if (window["seleniumInSameWindow"] != null) return window;
|
27 |
|
|
return window.parent;
|
28 |
|
|
};
|
29 |
|
|
|
30 |
|
|
BrowserBot.prototype.getCurrentWindow = function() {
|
31 |
|
|
if (window["seleniumInSameWindow"] != null) return window;
|
32 |
|
|
return window.parent;
|
33 |
|
|
};
|
34 |
|
|
|
35 |
|
|
LOG.openLogWindow = function(message, className) {
|
36 |
|
|
// disable for now
|
37 |
|
|
};
|
38 |
|
|
|
39 |
|
|
BrowserBot.prototype.relayToRC = function(name) {
|
40 |
|
|
var object = eval(name);
|
41 |
|
|
var s = 'state:' + serializeObject(name, object) + "\n";
|
42 |
|
|
sendToRC(s,"state=true");
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
BrowserBot.prototype.relayBotToRC = function(s) {
|
46 |
|
|
this.relayToRC("selenium." + s);
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
function selenium_frameRunTest(oldOnLoadRoutine) {
|
50 |
|
|
if (oldOnLoadRoutine) {
|
51 |
|
|
eval(oldOnLoadRoutine);
|
52 |
|
|
}
|
53 |
|
|
runSeleniumTest();
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
function seleniumOnLoad() {
|
57 |
|
|
injectedSessionId = @SESSION_ID@;
|
58 |
|
|
window["selenium_has_been_loaded_into_this_window"] = true;
|
59 |
|
|
runSeleniumTest();
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
function seleniumOnUnload() {
|
63 |
|
|
sendToRC("OK"); // just in case some poor PI server thread is waiting for a response
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
if (window.addEventListener) {
|
67 |
|
|
window.addEventListener("load", seleniumOnLoad, false); // firefox
|
68 |
|
|
window.addEventListener("unload", seleniumOnUnload, false); // firefox
|
69 |
|
|
} else if (window.attachEvent){
|
70 |
|
|
window.attachEvent("onload", seleniumOnLoad); // IE
|
71 |
|
|
window.attachEvent("onunload", seleniumOnUnload); // IE
|
72 |
|
|
}
|
73 |
|
|
else {
|
74 |
|
|
throw "causing a JavaScript error to tell the world that I did not arrange to be run on load";
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
injectedSessionId = @SESSION_ID@;
|
78 |
|
|
}
|
79 |
|
|
</script>
|