Update chrome.js

This commit is contained in:
Namhyeon Go 2022-01-27 14:18:29 +09:00 committed by GitHub
parent 4f6a3a1e50
commit e4adea873a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,9 +14,10 @@ var AutoItX = require("lib/autoitx");
// for remote debugging // for remote debugging
var pageEventId = 0; var pageEventId = 0;
var ChromeObject = function() { var ChromeObject = function(interfaces) {
STD.EventableObject.apply(this, arguments); // set this object to `eventable` STD.EventableObject.apply(this, arguments); // set this object to `eventable`
this.interfaces = (typeof interfaces !== "undefined" ? interfaces : []);
this.vendor = "Chrome"; 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";
@ -54,9 +55,13 @@ var ChromeObject = function() {
this.create = function() { this.create = function() {
try { try {
if (this.interfaces.indexOf("autoitx") > -1) {
this.oAutoIt = AutoItX.create().getInterface(); this.oAutoIt = AutoItX.create().getInterface();
} else {
console.log("AutoItX is disabled");
}
} catch (e) { } catch (e) {
console.warn("AutoItX is disabled"); console.log("AutoItX is disabled");
} }
return this; return this;
}; };
@ -65,7 +70,7 @@ var ChromeObject = function() {
if (this.oAutoIt != null) { if (this.oAutoIt != null) {
this.oAutoIt[FN].apply(args); this.oAutoIt[FN].apply(args);
} else { } else {
console.warn("AutoItX is disabled"); console.log("AutoItX is disabled");
} }
}; };
@ -362,7 +367,7 @@ var ChromeObject = function() {
if (this.debuggingPort > 0) { if (this.debuggingPort > 0) {
try { try {
var responseText = HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json"); var responseText = HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json");
//console.info(responseText); //console.log(responseText);
pageList = JSON.parse(responseText); pageList = JSON.parse(responseText);
this.pageList = pageList; this.pageList = pageList;
return pageList; return pageList;
@ -442,7 +447,7 @@ var ChromeObject = function() {
"params": params "params": params
})); }));
pageEventId++; pageEventId++;
console.info("ChromeObject().sendPageRPC() -> Sent"); console.log("ChromeObject().sendPageRPC() -> Sent");
} else { } else {
this.setPageId(null); this.setPageId(null);
if (this.pageId != "") { if (this.pageId != "") {
@ -491,7 +496,7 @@ var ChromeObject = function() {
this.getEvaluatedValue = function(expression) { this.getEvaluatedValue = function(expression) {
try { try {
var responseText = this.evaluate(expression); var responseText = this.evaluate(expression);
console.info(responseText); console.log(responseText);
var result = JSON.parse(responseText).result.result.value; var result = JSON.parse(responseText).result.result.value;
if (typeof(result) !== "undefined" && result != null) { if (typeof(result) !== "undefined" && result != null) {