Skip to content

Commit 534545a

Browse files
Merge pull request #376 from AutomationSolutionz/recorder
Inspector and Recorder
2 parents 15408ae + 7082df3 commit 534545a

File tree

20 files changed

+495
-326
lines changed

20 files changed

+495
-326
lines changed

Apps/Web/AI_Recorder/background/back.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const metaData = {};
12
const browserAppData = chrome || browser;
23

34
import './back_zeuz.js';
@@ -32,6 +33,9 @@ function getWindowSize(callback) {
3233
}
3334

3435
function open_panel(tab) {
36+
browserAppData.storage.local.set({
37+
meta_data: metaData
38+
})
3539
let contentWindowId = tab.windowId;
3640
if (master[contentWindowId] != undefined) {
3741
browserAppData.windows.update(master[contentWindowId], {

Apps/Web/AI_Recorder/content/browserbot.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ BrowserBot.prototype.selectWindow = function(target) {
380380
else if (locatorType == "name") {
381381
this._selectWindowByName(locatorValue);
382382
} else if (locatorType == "var") {
383-
var win = this.getCurrentWindow().eval(locatorValue);
383+
// The following code is untested!! just replaced Eval()
384+
// var win = this.getCurrentWindow().eval(locatorValue);
385+
var win = "";
384386
if (win) {
385387
this._selectWindowByName(win.name);
386388
} else {
@@ -764,22 +766,26 @@ BrowserBot.prototype.modifyWindowToRecordPopUpDialogs = function(originalWindow,
764766
return openedWindow;
765767
};
766768

767-
if (browserVersion.isHTA) {
768-
originalOpenReference = 'selenium_originalOpen' + new Date().getTime();
769-
newOpenReference = 'selenium_newOpen' + new Date().getTime();
770-
var setOriginalRef = "this['" + originalOpenReference + "'] = this.open;";
771-
772-
if (windowToModify.eval) {
773-
windowToModify.eval(setOriginalRef);
774-
windowToModify.open = newOpen;
775-
} else {
776-
setOriginalRef += "this.open = this['" + newOpenReference + "'];";
777-
windowToModify[newOpenReference] = newOpen;
778-
windowToModify.setTimeout(setOriginalRef, 0);
779-
}
780-
} else {
781-
windowToModify.open = newOpen;
782-
}
769+
// if (browserVersion.isHTA) {
770+
// originalOpenReference = 'selenium_originalOpen' + new Date().getTime();
771+
// newOpenReference = 'selenium_newOpen' + new Date().getTime();
772+
// var setOriginalRef = "this['" + originalOpenReference + "'] = this.open;";
773+
774+
// if (windowToModify.eval) {
775+
// windowToModify.eval(setOriginalRef);
776+
// windowToModify.open = newOpen;
777+
// } else {
778+
// setOriginalRef += "this.open = this['" + newOpenReference + "'];";
779+
// windowToModify[newOpenReference] = newOpen;
780+
// windowToModify.setTimeout(setOriginalRef, 0);
781+
// }
782+
// } else {
783+
// windowToModify.open = newOpen;
784+
// }
785+
786+
// The following code is untested!! just replaced Eval()
787+
windowToModify.open = newOpen;
788+
783789
};
784790

785791

@@ -1826,7 +1832,9 @@ BrowserBot.prototype.close = function() {
18261832
if (browserVersion.isChrome || browserVersion.isSafari || browserVersion.isOpera) {
18271833
this.topFrame.close();
18281834
} else {
1829-
this.getCurrentWindow().eval("window.top.close();");
1835+
// this.getCurrentWindow().eval("window.top.close();");
1836+
// The following code is untested!! just replaced Eval()
1837+
window.top.close();
18301838
}
18311839
};
18321840

Apps/Web/AI_Recorder/content/injecter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// inject scripts for promot command
2-
const browser = chrome || browser;
32
var injectingScript = document.createElement("script");
43
injectingScript.src = browser.runtime.getURL("page/prompt.js");
54
(document.head || document.documentElement).appendChild(injectingScript);

Apps/Web/AI_Recorder/content/sel_api.js

Lines changed: 146 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,49 @@ Selenium.prototype.doStoreEval = function(value, varName) {
164164
};
165165

166166
Selenium.prototype.doPrePageWait = function() {
167-
window.zeuz_new_page = window.eval('(function() {return window.new_page;}())');
167+
// The following code is untested!! just replaced Eval()
168+
// window.zeuz_new_page = window.eval('(function() {return window.new_page;}())');
169+
window.zeuz_new_page = window.new_page;;
168170
};
169171
Selenium.prototype.doPageWait = function() {
170-
var expression = 'if(window.document.readyState=="complete"){return true;}else{return false;}';
171-
window.zeuz_page_done = window.eval('(function() {' + expression + '}())');
172+
// The following code is untested!! just replaced Eval()
173+
// var expression = 'if(window.document.readyState=="complete"){return true;}else{return false;}';
174+
// window.zeuz_page_done = window.eval('(function() {' + expression + '}())');
175+
window.zeuz_page_done = window.document.readyState=="complete";
172176
};
173177

174178
Selenium.prototype.doAjaxWait = function() {
175-
var expression = 'if (window.ajax_obj) { if (window.ajax_obj.length == 0) {return true;} else {\
176-
for (var index in window.ajax_obj) {\
177-
if (window.ajax_obj[index].readyState !== 4 &&\
178-
window.ajax_obj[index].readyState !== undefined &&\
179-
window.ajax_obj[index].readyState !== 0) {return false;}}return true;}}\
180-
else {if (window.origXMLHttpRequest) {window.origXMLHttpRequest = "";}return true;}';
181-
window.zeuz_ajax_done = window.eval('(function() {' + expression + '}())');
179+
// var expression = 'if (window.ajax_obj) { if (window.ajax_obj.length == 0) {return true;} else {\
180+
// for (var index in window.ajax_obj) {\
181+
// if (window.ajax_obj[index].readyState !== 4 &&\
182+
// window.ajax_obj[index].readyState !== undefined &&\
183+
// window.ajax_obj[index].readyState !== 0) {return false;}}return true;}}\
184+
// else {if (window.origXMLHttpRequest) {window.origXMLHttpRequest = "";}return true;}';
185+
// window.zeuz_ajax_done = window.eval('(function() {' + expression + '}())');
186+
187+
// The following code is untested!! just replaced Eval()
188+
if (window.ajax_obj) {
189+
if (window.ajax_obj.length == 0) {
190+
window.zeuz_ajax_done= true;
191+
}
192+
else {
193+
for (var index in window.ajax_obj) {
194+
if (window.ajax_obj[index].readyState !== 4 &&
195+
window.ajax_obj[index].readyState !== undefined &&
196+
window.ajax_obj[index].readyState !== 0) {
197+
window.zeuz_ajax_done = false;
198+
break;
199+
}
200+
}
201+
return true;
202+
}
203+
}
204+
else {
205+
if (window.origXMLHttpRequest) {
206+
window.origXMLHttpRequest = "";
207+
}
208+
window.zeuz_ajax_done = true;
209+
};
182210
};
183211

184212
Selenium.createForWindow = function(window, proxyInjectionMode) {
@@ -190,24 +218,49 @@ Selenium.createForWindow = function(window, proxyInjectionMode) {
190218

191219

192220
Selenium.prototype.doWaitPreparation = function() {
193-
window.eval('function setNewPageValue(e) {window.new_page = true;};\
194-
window.addEventListener("beforeunload", setNewPageValue, false);\
195-
if (window.XMLHttpRequest) {if (!window.origXMLHttpRequest || !window.ajax_obj) {\
196-
window.ajax_obj = []; window.origXMLHttpRequest = window.XMLHttpRequest;\
197-
window.XMLHttpRequest = function() { var xhr = new window.origXMLHttpRequest();\
198-
window.ajax_obj.push(xhr); return xhr;}}} function setDOMModifiedTime() {\
199-
window.domModifiedTime = Date.now();}var _win = window.document.body;\
200-
_win.addEventListener("DOMNodeInserted", setDOMModifiedTime, false);\
201-
_win.addEventListener("DOMNodeInsertedIntoDocument", setDOMModifiedTime, false);\
202-
_win.addEventListener("DOMNodeRemoved", setDOMModifiedTime, false);\
203-
_win.addEventListener("DOMNodeRemovedFromDocument", setDOMModifiedTime, false);\
204-
_win.addEventListener("DOMSubtreeModified", setDOMModifiedTime, false);');
221+
// window.eval('function setNewPageValue(e) {window.new_page = true;};\
222+
// window.addEventListener("beforeunload", setNewPageValue, false);\
223+
// if (window.XMLHttpRequest) {if (!window.origXMLHttpRequest || !window.ajax_obj) {\
224+
// window.ajax_obj = []; window.origXMLHttpRequest = window.XMLHttpRequest;\
225+
// window.XMLHttpRequest = function() { var xhr = new window.origXMLHttpRequest();\
226+
// window.ajax_obj.push(xhr); return xhr;}}} function setDOMModifiedTime() {\
227+
// window.domModifiedTime = Date.now();}var _win = window.document.body;\
228+
// _win.addEventListener("DOMNodeInserted", setDOMModifiedTime, false);\
229+
// _win.addEventListener("DOMNodeInsertedIntoDocument", setDOMModifiedTime, false);\
230+
// _win.addEventListener("DOMNodeRemoved", setDOMModifiedTime, false);\
231+
// _win.addEventListener("DOMNodeRemovedFromDocument", setDOMModifiedTime, false);\
232+
// _win.addEventListener("DOMSubtreeModified", setDOMModifiedTime, false);');
233+
234+
// The following code is untested!! just replaced Eval()
235+
function setNewPageValue(e) {
236+
window.new_page = true;
237+
};
238+
window.addEventListener("beforeunload", setNewPageValue, false);
239+
if (window.XMLHttpRequest) {
240+
if (!window.origXMLHttpRequest || !window.ajax_obj) {
241+
window.ajax_obj = []; window.origXMLHttpRequest = window.XMLHttpRequest;
242+
window.XMLHttpRequest = function() { var xhr = new window.origXMLHttpRequest();
243+
window.ajax_obj.push(xhr); return xhr;}
244+
}
245+
}
246+
function setDOMModifiedTime() {
247+
window.domModifiedTime = Date.now();
248+
}
249+
var _win = window.document.body;
250+
_win.addEventListener("DOMNodeInserted", setDOMModifiedTime, false);
251+
_win.addEventListener("DOMNodeInsertedIntoDocument", setDOMModifiedTime, false);
252+
_win.addEventListener("DOMNodeRemoved", setDOMModifiedTime, false);
253+
_win.addEventListener("DOMNodeRemovedFromDocument", setDOMModifiedTime, false);
254+
_win.addEventListener("DOMSubtreeModified", setDOMModifiedTime, false);
205255
};
206256

207257

208258
Selenium.prototype.doDomWait = function() {
209259
//sdx
210-
window.zeuz_dom_time = window.eval('(function() {return window.domModifiedTime;}())');
260+
// window.zeuz_dom_time = window.eval('(function() {return window.domModifiedTime;}())');
261+
// The following code is untested!! just replaced Eval()
262+
263+
window.zeuz_dom_time = window.domModifiedTime;
211264
};
212265

213266
Selenium.prototype.doClick = function(locator) {
@@ -783,16 +836,18 @@ Selenium.prototype.doHighlight = function(locator) {
783836
this.browserbot.highlight(element, true);
784837
};
785838

786-
Selenium.prototype.getEval = function(script) {
787-
try {
788-
var window = this.browserbot.getCurrentWindow();
789-
var result = eval(script);
790-
if (null == result) return "null";
791-
return result;
792-
} catch (e) {
793-
throw new SeleniumError("Threw an exception: " + extractExceptionMessage(e));
794-
}
795-
};
839+
// The following code is untested!! just replaced Eval()
840+
841+
// Selenium.prototype.getEval = function(script) {
842+
// try {
843+
// var window = this.browserbot.getCurrentWindow();
844+
// var result = eval(script);
845+
// if (null == result) return "null";
846+
// return result;
847+
// } catch (e) {
848+
// throw new SeleniumError("Threw an exception: " + extractExceptionMessage(e));
849+
// }
850+
// };
796851

797852
Selenium.prototype.isChecked = function(locator) {
798853
var element = this.browserbot.findElement(locator);
@@ -1038,47 +1093,52 @@ Selenium.prototype.getAllFields = function() {
10381093
return this.browserbot.getAllFields();
10391094
};
10401095

1041-
Selenium.prototype.getAttributeFromAllWindows = function(attributeName) {
1042-
var attributes = new Array();
1043-
1044-
var win = selenium.browserbot.topWindow;
1045-
try {
1046-
attributes.push(eval("win." + attributeName));
1047-
} catch (ignored) {
1048-
}
1049-
for (var windowName in this.browserbot.openedWindows) {
1050-
try {
1051-
win = selenium.browserbot.openedWindows[windowName];
1052-
if (!selenium.browserbot._windowClosed(win)) {
1053-
attributes.push(eval("win." + attributeName));
1054-
}
1055-
} catch (e) {}
1056-
}
1057-
return attributes;
1058-
};
1059-
1060-
Selenium.prototype.findWindow = function(soughtAfterWindowPropertyValue) {
1061-
var targetPropertyName = "name";
1062-
if (soughtAfterWindowPropertyValue.match("^title=")) {
1063-
targetPropertyName = "document.title";
1064-
soughtAfterWindowPropertyValue = soughtAfterWindowPropertyValue.replace(/^title=/, "");
1065-
} else {
1066-
if (PatternMatcher.matches(soughtAfterWindowPropertyValue, "")) {
1067-
return this.browserbot.getCurrentWindow();
1068-
}
1069-
}
1070-
1071-
if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("this.browserbot.topWindow." + targetPropertyName))) {
1072-
return this.browserbot.topWindow;
1073-
}
1074-
for (windowName in selenium.browserbot.openedWindows) {
1075-
var openedWindow = selenium.browserbot.openedWindows[windowName];
1076-
if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("openedWindow." + targetPropertyName))) {
1077-
return openedWindow;
1078-
}
1079-
}
1080-
throw new SeleniumError("could not find window with property " + targetPropertyName + " matching " + soughtAfterWindowPropertyValue);
1081-
};
1096+
// The following code is untested!! just replaced Eval()
1097+
1098+
// Selenium.prototype.getAttributeFromAllWindows = function(attributeName) {
1099+
// var attributes = new Array();
1100+
1101+
// var win = selenium.browserbot.topWindow;
1102+
// try {
1103+
// attributes.push(eval("win." + attributeName));
1104+
// } catch (ignored) {
1105+
// }
1106+
// for (var windowName in this.browserbot.openedWindows) {
1107+
// try {
1108+
// win = selenium.browserbot.openedWindows[windowName];
1109+
// if (!selenium.browserbot._windowClosed(win)) {
1110+
// attributes.push(eval("win." + attributeName));
1111+
// }
1112+
// } catch (e) {}
1113+
// }
1114+
// return attributes;
1115+
// };
1116+
1117+
1118+
// The following code is untested!! just replaced Eval()
1119+
1120+
// Selenium.prototype.findWindow = function(soughtAfterWindowPropertyValue) {
1121+
// var targetPropertyName = "name";
1122+
// if (soughtAfterWindowPropertyValue.match("^title=")) {
1123+
// targetPropertyName = "document.title";
1124+
// soughtAfterWindowPropertyValue = soughtAfterWindowPropertyValue.replace(/^title=/, "");
1125+
// } else {
1126+
// if (PatternMatcher.matches(soughtAfterWindowPropertyValue, "")) {
1127+
// return this.browserbot.getCurrentWindow();
1128+
// }
1129+
// }
1130+
1131+
// if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("this.browserbot.topWindow." + targetPropertyName))) {
1132+
// return this.browserbot.topWindow;
1133+
// }
1134+
// for (windowName in selenium.browserbot.openedWindows) {
1135+
// var openedWindow = selenium.browserbot.openedWindows[windowName];
1136+
// if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("openedWindow." + targetPropertyName))) {
1137+
// return openedWindow;
1138+
// }
1139+
// }
1140+
// throw new SeleniumError("could not find window with property " + targetPropertyName + " matching " + soughtAfterWindowPropertyValue);
1141+
// };
10821142

10831143
Selenium.prototype.doSetMouseSpeed = function(pixels) {
10841144
var intValue = new Number(pixels);
@@ -1408,7 +1468,8 @@ Selenium.prototype.doIgnoreAttributesWithoutValue = function(ignore) {
14081468
Selenium.prototype.doWaitForCondition = function(script, timeout) {
14091469
return Selenium.decorateFunctionWithTimeout(function() {
14101470
var window = selenium.browserbot.getCurrentWindow();
1411-
return eval(script);
1471+
// The following code is untested!! just replaced Eval()
1472+
// return eval(script);
14121473
}, timeout);
14131474
};
14141475

@@ -1443,14 +1504,16 @@ Selenium.prototype._abortXhrRequest = function() {
14431504

14441505
Selenium.prototype.doWaitForPageToLoad.dontCheckAlertsAndConfirms = true;
14451506

1446-
Selenium.prototype.preprocessParameter = function(value) {
1447-
var match = value.match(/^javascript\{((.|\r?\n)+)\}$/);
1448-
if (match && match[1]) {
1449-
var result = eval(match[1]);
1450-
return result == null ? null : result.toString();
1451-
}
1452-
return this.replaceVariables(value);
1453-
};
1507+
// The following code is untested!! just replaced Eval()
1508+
1509+
// Selenium.prototype.preprocessParameter = function(value) {
1510+
// var match = value.match(/^javascript\{((.|\r?\n)+)\}$/);
1511+
// if (match && match[1]) {
1512+
// var result = eval(match[1]);
1513+
// return result == null ? null : result.toString();
1514+
// }
1515+
// return this.replaceVariables(value);
1516+
// };
14541517

14551518
Selenium.prototype.replaceVariables = function(str) {
14561519
var stringResult = str;

Apps/Web/AI_Recorder/manifest.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"https://*/*"
3636
],
3737
"js": [
38+
"common_files/poly_fill.js",
3839
"content/injecter.js"
3940
],
4041
"all_frames": true,
@@ -53,6 +54,7 @@
5354
"content/commandhandlers.js",
5455
"content/browserbot.js",
5556
"common_files/escape.js",
57+
"content/sel_api.js",
5658
"content/loc_builders.js",
5759
"content/recorder.js",
5860
"content/rec_handlers.js",

Apps/Web/AI_Recorder/panel/assets/css/mystyle.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ body
587587
display: block;
588588
color: rgba(255, 255, 255, 0.6);
589589
cursor: pointer;
590-
text-align: center;
591590
}
592591
.sidebar_menu img
593592
{

Apps/Web/AI_Recorder/panel/assets/js/background/editor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* start the zeuz editor function */
2-
const browser = chrome || browser;
32
var contentWindowId;
43
var selfWindowId = -1;
54
var notificationCount = 0;

0 commit comments

Comments
 (0)