Update chrome.js

This commit is contained in:
Namhyeon Go 2022-01-26 02:40:19 +09:00 committed by GitHub
parent cc42490106
commit 730de840bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ var pageEventId = 0;
var ChromeObject = function() { var ChromeObject = function() {
STD.EventableObject.apply(this, arguments); // set this object to `eventable` STD.EventableObject.apply(this, arguments); // set this object to `eventable`
this.vendor = "Chrome";
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application"; this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application";
this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:installedDir\\Application\\chrome.exe"; this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:installedDir\\Application\\chrome.exe";
//this.processID = 0; //this.processID = 0;
@ -520,6 +521,28 @@ var ChromeObject = function() {
this.setPageId(null); this.setPageId(null);
} }
// calling _focus()
title = this._focus();
// find window by title
var pageList = this.getPageList();
if (pageList.length > 0) {
this.oAutoIt.WinActivate(title);
}
} catch (e) {
console.error("ChromeObject._focus() ->", e.message);
}
}
// calling `onfocus` event
this.dispatchEvent(new STD.Event("focus"));
return title;
};
this._focus = function() {
var title = "";
// get current title // get current title
var _title = this.getTitle(); var _title = this.getTitle();
@ -537,19 +560,6 @@ var ChromeObject = function() {
title = _title; /// when it is already catch title = _title; /// when it is already catch
} }
// find window by title
var pageList = this.getPageList();
if (pageList.length > 0) {
this.oAutoIt.WinActivate(title);
}
} catch (e) {
console.error("ChromeObject._focus() ->", e.message);
}
}
// calling `onfocus` event
this.dispatchEvent(new STD.Event("focus"));
return title; return title;
}; };
@ -1124,6 +1134,24 @@ var ChromeObject = function() {
return 'decodeURIComponent("' + encodeURIComponent(value) + '")'; return 'decodeURIComponent("' + encodeURIComponent(value) + '")';
}; };
this.setVendor = function(vendor) {
var vendor = vendor.toLowerCase();
switch (vendor) {
case "msedge":
this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Microsoft\\Edge\\Application";
this.binPath = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Microsoft\\Edge\\Application\\chrome.exe";
break;
case "chrome":
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application";
this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:installedDir\\Application\\chrome.exe";
break;
}
return this;
};
this.create(); this.create();
}; };
ChromeObject.prototype = new STD.EventableObject(); ChromeObject.prototype = new STD.EventableObject();