Skip to content

Commit

Permalink
Merge pull request #778 from AviVahl/electron-11
Browse files Browse the repository at this point in the history
chore(deps): electron@11, latest others
  • Loading branch information
VerteDinde authored Nov 25, 2020
2 parents 2bfc7dd + d763b84 commit 1510a9b
Show file tree
Hide file tree
Showing 13 changed files with 1,706 additions and 3,239 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
{
"files": "*.d.ts",
"rules": {
"no-useless-constructor": "off"
}
"no-useless-constructor": "off",
"no-undef": "off"
}
}
]
}
47 changes: 24 additions & 23 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,23 +440,23 @@ Api.prototype.addExecuteJavaScriptSupport = function () {
const app = this.app;
const self = this;

app.client.addCommand('webContents.executeJavaScript', function (
code,
useGesture
) {
return this.executeAsync(
async function (code, useGesture, requireName, done) {
const webContents = window[requireName](
'electron'
).remote.getCurrentWebContents();
const result = await webContents.executeJavaScript(code, useGesture);
done(result);
},
code,
useGesture,
self.requireName
);
});
app.client.addCommand(
'webContents.executeJavaScript',
function (code, useGesture) {
return this.executeAsync(
async function (code, useGesture, requireName, done) {
const webContents = window[requireName](
'electron'
).remote.getCurrentWebContents();
const result = await webContents.executeJavaScript(code, useGesture);
done(result);
},
code,
useGesture,
self.requireName
);
}
);

app.webContents.executeJavaScript = function () {
return app.client['webContents.executeJavaScript'].apply(
Expand Down Expand Up @@ -492,12 +492,13 @@ Api.prototype.transferPromiseness = function (target, promise) {
const addProperties = function (source, target, moduleName) {
const sourceModule = source[moduleName];
if (!sourceModule) return;
target[moduleName] = transformObject(sourceModule, {}, function (
value,
parent
) {
return value.bind(parent);
});
target[moduleName] = transformObject(
sourceModule,
{},
function (value, parent) {
return value.bind(parent);
}
);
};

addProperties(promise, target, 'webContents');
Expand Down
53 changes: 26 additions & 27 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,33 +227,32 @@ Application.prototype.createClient = function () {
};

Application.prototype.addCommands = function () {
this.client.addCommand('waitUntilTextExists', function (
selector,
text,
timeout
) {
const self = this;
return self
.waitUntil(async function () {
const elem = await self.$(selector);
const exists = await elem.isExisting();
if (!exists) {
return false;
}

const selectorText = await elem.getText();
return Array.isArray(selectorText)
? selectorText.some((s) => s.includes(text))
: selectorText.includes(text);
}, timeout)
.then(
function () {},
function (error) {
error.message = 'waitUntilTextExists ' + error.message;
throw error;
}
);
});
this.client.addCommand(
'waitUntilTextExists',
function (selector, text, timeout) {
const self = this;
return self
.waitUntil(async function () {
const elem = await self.$(selector);
const exists = await elem.isExisting();
if (!exists) {
return false;
}

const selectorText = await elem.getText();
return Array.isArray(selectorText)
? selectorText.some((s) => s.includes(text))
: selectorText.includes(text);
}, timeout)
.then(
function () {},
function (error) {
error.message = 'waitUntilTextExists ' + error.message;
throw error;
}
);
}
);

this.client.addCommand('waitUntilWindowLoaded', function (timeout) {
const self = this;
Expand Down
Loading

0 comments on commit 1510a9b

Please sign in to comment.