Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Apps/Web/AI_Recorder/background/back.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const metaData = {};
const browserAppData = chrome || browser;

import './back_zeuz.js';
Expand Down Expand Up @@ -32,6 +33,9 @@ function getWindowSize(callback) {
}

function open_panel(tab) {
browserAppData.storage.local.set({
meta_data: metaData
})
let contentWindowId = tab.windowId;
if (master[contentWindowId] != undefined) {
browserAppData.windows.update(master[contentWindowId], {
Expand Down
44 changes: 26 additions & 18 deletions Apps/Web/AI_Recorder/content/browserbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ BrowserBot.prototype.selectWindow = function(target) {
else if (locatorType == "name") {
this._selectWindowByName(locatorValue);
} else if (locatorType == "var") {
var win = this.getCurrentWindow().eval(locatorValue);
// The following code is untested!! just replaced Eval()
// var win = this.getCurrentWindow().eval(locatorValue);
var win = "";
if (win) {
this._selectWindowByName(win.name);
} else {
Expand Down Expand Up @@ -764,22 +766,26 @@ BrowserBot.prototype.modifyWindowToRecordPopUpDialogs = function(originalWindow,
return openedWindow;
};

if (browserVersion.isHTA) {
originalOpenReference = 'selenium_originalOpen' + new Date().getTime();
newOpenReference = 'selenium_newOpen' + new Date().getTime();
var setOriginalRef = "this['" + originalOpenReference + "'] = this.open;";

if (windowToModify.eval) {
windowToModify.eval(setOriginalRef);
windowToModify.open = newOpen;
} else {
setOriginalRef += "this.open = this['" + newOpenReference + "'];";
windowToModify[newOpenReference] = newOpen;
windowToModify.setTimeout(setOriginalRef, 0);
}
} else {
windowToModify.open = newOpen;
}
// if (browserVersion.isHTA) {
// originalOpenReference = 'selenium_originalOpen' + new Date().getTime();
// newOpenReference = 'selenium_newOpen' + new Date().getTime();
// var setOriginalRef = "this['" + originalOpenReference + "'] = this.open;";

// if (windowToModify.eval) {
// windowToModify.eval(setOriginalRef);
// windowToModify.open = newOpen;
// } else {
// setOriginalRef += "this.open = this['" + newOpenReference + "'];";
// windowToModify[newOpenReference] = newOpen;
// windowToModify.setTimeout(setOriginalRef, 0);
// }
// } else {
// windowToModify.open = newOpen;
// }

// The following code is untested!! just replaced Eval()
windowToModify.open = newOpen;

};


Expand Down Expand Up @@ -1826,7 +1832,9 @@ BrowserBot.prototype.close = function() {
if (browserVersion.isChrome || browserVersion.isSafari || browserVersion.isOpera) {
this.topFrame.close();
} else {
this.getCurrentWindow().eval("window.top.close();");
// this.getCurrentWindow().eval("window.top.close();");
// The following code is untested!! just replaced Eval()
window.top.close();
}
};

Expand Down
1 change: 0 additions & 1 deletion Apps/Web/AI_Recorder/content/injecter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// inject scripts for promot command
const browser = chrome || browser;
var injectingScript = document.createElement("script");
injectingScript.src = browser.runtime.getURL("page/prompt.js");
(document.head || document.documentElement).appendChild(injectingScript);
Expand Down
229 changes: 146 additions & 83 deletions Apps/Web/AI_Recorder/content/sel_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,49 @@ Selenium.prototype.doStoreEval = function(value, varName) {
};

Selenium.prototype.doPrePageWait = function() {
window.zeuz_new_page = window.eval('(function() {return window.new_page;}())');
// The following code is untested!! just replaced Eval()
// window.zeuz_new_page = window.eval('(function() {return window.new_page;}())');
window.zeuz_new_page = window.new_page;;
};
Selenium.prototype.doPageWait = function() {
var expression = 'if(window.document.readyState=="complete"){return true;}else{return false;}';
window.zeuz_page_done = window.eval('(function() {' + expression + '}())');
// The following code is untested!! just replaced Eval()
// var expression = 'if(window.document.readyState=="complete"){return true;}else{return false;}';
// window.zeuz_page_done = window.eval('(function() {' + expression + '}())');
window.zeuz_page_done = window.document.readyState=="complete";
};

Selenium.prototype.doAjaxWait = function() {
var expression = 'if (window.ajax_obj) { if (window.ajax_obj.length == 0) {return true;} else {\
for (var index in window.ajax_obj) {\
if (window.ajax_obj[index].readyState !== 4 &&\
window.ajax_obj[index].readyState !== undefined &&\
window.ajax_obj[index].readyState !== 0) {return false;}}return true;}}\
else {if (window.origXMLHttpRequest) {window.origXMLHttpRequest = "";}return true;}';
window.zeuz_ajax_done = window.eval('(function() {' + expression + '}())');
// var expression = 'if (window.ajax_obj) { if (window.ajax_obj.length == 0) {return true;} else {\
// for (var index in window.ajax_obj) {\
// if (window.ajax_obj[index].readyState !== 4 &&\
// window.ajax_obj[index].readyState !== undefined &&\
// window.ajax_obj[index].readyState !== 0) {return false;}}return true;}}\
// else {if (window.origXMLHttpRequest) {window.origXMLHttpRequest = "";}return true;}';
// window.zeuz_ajax_done = window.eval('(function() {' + expression + '}())');

// The following code is untested!! just replaced Eval()
if (window.ajax_obj) {
if (window.ajax_obj.length == 0) {
window.zeuz_ajax_done= true;
}
else {
for (var index in window.ajax_obj) {
if (window.ajax_obj[index].readyState !== 4 &&
window.ajax_obj[index].readyState !== undefined &&
window.ajax_obj[index].readyState !== 0) {
window.zeuz_ajax_done = false;
break;
}
}
return true;
}
}
else {
if (window.origXMLHttpRequest) {
window.origXMLHttpRequest = "";
}
window.zeuz_ajax_done = true;
};
};

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


Selenium.prototype.doWaitPreparation = function() {
window.eval('function setNewPageValue(e) {window.new_page = true;};\
window.addEventListener("beforeunload", setNewPageValue, false);\
if (window.XMLHttpRequest) {if (!window.origXMLHttpRequest || !window.ajax_obj) {\
window.ajax_obj = []; window.origXMLHttpRequest = window.XMLHttpRequest;\
window.XMLHttpRequest = function() { var xhr = new window.origXMLHttpRequest();\
window.ajax_obj.push(xhr); return xhr;}}} function setDOMModifiedTime() {\
window.domModifiedTime = Date.now();}var _win = window.document.body;\
_win.addEventListener("DOMNodeInserted", setDOMModifiedTime, false);\
_win.addEventListener("DOMNodeInsertedIntoDocument", setDOMModifiedTime, false);\
_win.addEventListener("DOMNodeRemoved", setDOMModifiedTime, false);\
_win.addEventListener("DOMNodeRemovedFromDocument", setDOMModifiedTime, false);\
_win.addEventListener("DOMSubtreeModified", setDOMModifiedTime, false);');
// window.eval('function setNewPageValue(e) {window.new_page = true;};\
// window.addEventListener("beforeunload", setNewPageValue, false);\
// if (window.XMLHttpRequest) {if (!window.origXMLHttpRequest || !window.ajax_obj) {\
// window.ajax_obj = []; window.origXMLHttpRequest = window.XMLHttpRequest;\
// window.XMLHttpRequest = function() { var xhr = new window.origXMLHttpRequest();\
// window.ajax_obj.push(xhr); return xhr;}}} function setDOMModifiedTime() {\
// window.domModifiedTime = Date.now();}var _win = window.document.body;\
// _win.addEventListener("DOMNodeInserted", setDOMModifiedTime, false);\
// _win.addEventListener("DOMNodeInsertedIntoDocument", setDOMModifiedTime, false);\
// _win.addEventListener("DOMNodeRemoved", setDOMModifiedTime, false);\
// _win.addEventListener("DOMNodeRemovedFromDocument", setDOMModifiedTime, false);\
// _win.addEventListener("DOMSubtreeModified", setDOMModifiedTime, false);');

// The following code is untested!! just replaced Eval()
function setNewPageValue(e) {
window.new_page = true;
};
window.addEventListener("beforeunload", setNewPageValue, false);
if (window.XMLHttpRequest) {
if (!window.origXMLHttpRequest || !window.ajax_obj) {
window.ajax_obj = []; window.origXMLHttpRequest = window.XMLHttpRequest;
window.XMLHttpRequest = function() { var xhr = new window.origXMLHttpRequest();
window.ajax_obj.push(xhr); return xhr;}
}
}
function setDOMModifiedTime() {
window.domModifiedTime = Date.now();
}
var _win = window.document.body;
_win.addEventListener("DOMNodeInserted", setDOMModifiedTime, false);
_win.addEventListener("DOMNodeInsertedIntoDocument", setDOMModifiedTime, false);
_win.addEventListener("DOMNodeRemoved", setDOMModifiedTime, false);
_win.addEventListener("DOMNodeRemovedFromDocument", setDOMModifiedTime, false);
_win.addEventListener("DOMSubtreeModified", setDOMModifiedTime, false);
};


Selenium.prototype.doDomWait = function() {
//sdx
window.zeuz_dom_time = window.eval('(function() {return window.domModifiedTime;}())');
// window.zeuz_dom_time = window.eval('(function() {return window.domModifiedTime;}())');
// The following code is untested!! just replaced Eval()

window.zeuz_dom_time = window.domModifiedTime;
};

Selenium.prototype.doClick = function(locator) {
Expand Down Expand Up @@ -783,16 +836,18 @@ Selenium.prototype.doHighlight = function(locator) {
this.browserbot.highlight(element, true);
};

Selenium.prototype.getEval = function(script) {
try {
var window = this.browserbot.getCurrentWindow();
var result = eval(script);
if (null == result) return "null";
return result;
} catch (e) {
throw new SeleniumError("Threw an exception: " + extractExceptionMessage(e));
}
};
// The following code is untested!! just replaced Eval()

// Selenium.prototype.getEval = function(script) {
// try {
// var window = this.browserbot.getCurrentWindow();
// var result = eval(script);
// if (null == result) return "null";
// return result;
// } catch (e) {
// throw new SeleniumError("Threw an exception: " + extractExceptionMessage(e));
// }
// };

Selenium.prototype.isChecked = function(locator) {
var element = this.browserbot.findElement(locator);
Expand Down Expand Up @@ -1038,47 +1093,52 @@ Selenium.prototype.getAllFields = function() {
return this.browserbot.getAllFields();
};

Selenium.prototype.getAttributeFromAllWindows = function(attributeName) {
var attributes = new Array();

var win = selenium.browserbot.topWindow;
try {
attributes.push(eval("win." + attributeName));
} catch (ignored) {
}
for (var windowName in this.browserbot.openedWindows) {
try {
win = selenium.browserbot.openedWindows[windowName];
if (!selenium.browserbot._windowClosed(win)) {
attributes.push(eval("win." + attributeName));
}
} catch (e) {}
}
return attributes;
};

Selenium.prototype.findWindow = function(soughtAfterWindowPropertyValue) {
var targetPropertyName = "name";
if (soughtAfterWindowPropertyValue.match("^title=")) {
targetPropertyName = "document.title";
soughtAfterWindowPropertyValue = soughtAfterWindowPropertyValue.replace(/^title=/, "");
} else {
if (PatternMatcher.matches(soughtAfterWindowPropertyValue, "")) {
return this.browserbot.getCurrentWindow();
}
}

if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("this.browserbot.topWindow." + targetPropertyName))) {
return this.browserbot.topWindow;
}
for (windowName in selenium.browserbot.openedWindows) {
var openedWindow = selenium.browserbot.openedWindows[windowName];
if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("openedWindow." + targetPropertyName))) {
return openedWindow;
}
}
throw new SeleniumError("could not find window with property " + targetPropertyName + " matching " + soughtAfterWindowPropertyValue);
};
// The following code is untested!! just replaced Eval()

// Selenium.prototype.getAttributeFromAllWindows = function(attributeName) {
// var attributes = new Array();

// var win = selenium.browserbot.topWindow;
// try {
// attributes.push(eval("win." + attributeName));
// } catch (ignored) {
// }
// for (var windowName in this.browserbot.openedWindows) {
// try {
// win = selenium.browserbot.openedWindows[windowName];
// if (!selenium.browserbot._windowClosed(win)) {
// attributes.push(eval("win." + attributeName));
// }
// } catch (e) {}
// }
// return attributes;
// };


// The following code is untested!! just replaced Eval()

// Selenium.prototype.findWindow = function(soughtAfterWindowPropertyValue) {
// var targetPropertyName = "name";
// if (soughtAfterWindowPropertyValue.match("^title=")) {
// targetPropertyName = "document.title";
// soughtAfterWindowPropertyValue = soughtAfterWindowPropertyValue.replace(/^title=/, "");
// } else {
// if (PatternMatcher.matches(soughtAfterWindowPropertyValue, "")) {
// return this.browserbot.getCurrentWindow();
// }
// }

// if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("this.browserbot.topWindow." + targetPropertyName))) {
// return this.browserbot.topWindow;
// }
// for (windowName in selenium.browserbot.openedWindows) {
// var openedWindow = selenium.browserbot.openedWindows[windowName];
// if (PatternMatcher.matches(soughtAfterWindowPropertyValue, eval("openedWindow." + targetPropertyName))) {
// return openedWindow;
// }
// }
// throw new SeleniumError("could not find window with property " + targetPropertyName + " matching " + soughtAfterWindowPropertyValue);
// };

Selenium.prototype.doSetMouseSpeed = function(pixels) {
var intValue = new Number(pixels);
Expand Down Expand Up @@ -1408,7 +1468,8 @@ Selenium.prototype.doIgnoreAttributesWithoutValue = function(ignore) {
Selenium.prototype.doWaitForCondition = function(script, timeout) {
return Selenium.decorateFunctionWithTimeout(function() {
var window = selenium.browserbot.getCurrentWindow();
return eval(script);
// The following code is untested!! just replaced Eval()
// return eval(script);
}, timeout);
};

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

Selenium.prototype.doWaitForPageToLoad.dontCheckAlertsAndConfirms = true;

Selenium.prototype.preprocessParameter = function(value) {
var match = value.match(/^javascript\{((.|\r?\n)+)\}$/);
if (match && match[1]) {
var result = eval(match[1]);
return result == null ? null : result.toString();
}
return this.replaceVariables(value);
};
// The following code is untested!! just replaced Eval()

// Selenium.prototype.preprocessParameter = function(value) {
// var match = value.match(/^javascript\{((.|\r?\n)+)\}$/);
// if (match && match[1]) {
// var result = eval(match[1]);
// return result == null ? null : result.toString();
// }
// return this.replaceVariables(value);
// };

Selenium.prototype.replaceVariables = function(str) {
var stringResult = str;
Expand Down
2 changes: 2 additions & 0 deletions Apps/Web/AI_Recorder/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"https://*/*"
],
"js": [
"common_files/poly_fill.js",
"content/injecter.js"
],
"all_frames": true,
Expand All @@ -53,6 +54,7 @@
"content/commandhandlers.js",
"content/browserbot.js",
"common_files/escape.js",
"content/sel_api.js",
"content/loc_builders.js",
"content/recorder.js",
"content/rec_handlers.js",
Expand Down
1 change: 0 additions & 1 deletion Apps/Web/AI_Recorder/panel/assets/css/mystyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ body
display: block;
color: rgba(255, 255, 255, 0.6);
cursor: pointer;
text-align: center;
}
.sidebar_menu img
{
Expand Down
1 change: 0 additions & 1 deletion Apps/Web/AI_Recorder/panel/assets/js/background/editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* start the zeuz editor function */
const browser = chrome || browser;
var contentWindowId;
var selfWindowId = -1;
var notificationCount = 0;
Expand Down
Loading