Update chrome.js

This commit is contained in:
Namhyeon Go 2022-04-29 16:12:22 +09:00 committed by GitHub
parent ef7f6fb0e1
commit 512f0b4cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1180,6 +1180,10 @@ var ChromeObject = function(interfaces) {
this.prompt = function(s) {
return this.getEvaluatedValue('prompt("' + s + '")');
};
this.confirm = function(s) {
return this.getEvaluatedValue('(confirm("' + s + '") ? "true" : "false")');
};
this.setVendor = function(vendor) {
var vendor = vendor.toLowerCase();
@ -1225,6 +1229,18 @@ var ChromeObject = function(interfaces) {
return this.getEvaluatedValue("document.cookie");
};
this.getNumberOfSelectorAll = function(selector) {
return parseInt(this.getEvaluatedValue('document.querySelectorAll("' + selector + '").length'));
};
this.setValueOfInputs = function(type, s) {
this.evaluate('document.querySelectorAll("[type=' + type + ']").forEach(function(x){x.value = "' + s + '";})');
};
this.sendEnterKey = function() {
this.evaluate('var ev=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,keyCode:13});document.body.dispatchEvent(ev);');
};
this.create();
};
ChromeObject.prototype = new STD.EventableObject();