mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Update chrome.js
This commit is contained in:
parent
331578452f
commit
5572edb03d
|
@ -7,6 +7,9 @@ var FILE = require("lib/file");
|
|||
var HTTP = require("lib/http");
|
||||
var Websocket = require("lib/websocket");
|
||||
|
||||
// for remote debugging
|
||||
var pageEventId = 0;
|
||||
|
||||
var ChromeObject = function() {
|
||||
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application";
|
||||
this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:installedDir\\Application\\chrome.exe";
|
||||
|
@ -23,7 +26,6 @@ var ChromeObject = function() {
|
|||
|
||||
// for remote debugging
|
||||
this.debuggingPort = 0;
|
||||
this.pageEventId = 1;
|
||||
this.pageId = "";
|
||||
this.ws = Websocket.create();
|
||||
|
||||
|
@ -196,7 +198,7 @@ var ChromeObject = function() {
|
|||
|
||||
this.getPageList = function() {
|
||||
if (this.debuggingPort > 0) {
|
||||
return HTTP.get("http://localhost:" + this.debuggingPort + "/json");
|
||||
return HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json");
|
||||
} else {
|
||||
console.error("Remote debugging unavailable");
|
||||
return [];
|
||||
|
@ -224,12 +226,12 @@ var ChromeObject = function() {
|
|||
|
||||
this.sendPageRPC = function(method, params) {
|
||||
if (this.pageId != "") {
|
||||
this.ws.send("ws://localhost:" + this.debuggingPort + "/devtools/page/" + this.pageId, JSON.stringify({
|
||||
"id": this.pageEventId,
|
||||
this.ws.send("ws://127.0.0.1:" + this.debuggingPort + "/devtools/page/" + this.pageId, JSON.stringify({
|
||||
"id": pageEventId,
|
||||
"method": method,
|
||||
"params": params
|
||||
}));
|
||||
this.pageEventId++;
|
||||
pageEventId++;
|
||||
console.info("ChromeObject().sendPageRPC() -> Sent");
|
||||
} else {
|
||||
console.error("pageId not specified");
|
||||
|
@ -249,6 +251,10 @@ var ChromeObject = function() {
|
|||
"expression": expression
|
||||
});
|
||||
};
|
||||
|
||||
this.focus = function() {
|
||||
return this.evaluate("window.focus()");
|
||||
};
|
||||
};
|
||||
|
||||
exports.create = function() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user