Skip to content

Commit c2c0743

Browse files
authored
Bump Electron to '^7.1.2' (#51)
* Bump Electron to '^7.1.2'. Inject point fix. * Fix separators * Fix injection condition, update the testcafe version * fix macOS open options * Apply suggestions from code review Co-Authored-By: Andrey Belym <belym.a.2105@gmail.com> * Add "NOTE" to comments
1 parent c711f06 commit c2c0743

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "testcafe-browser-provider-electron",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "TestCafe browser provider plugin for testing applications built with Electron.",
55
"repository": "https://github.com/DevExpress/testcafe-browser-provider-electron",
66
"homepage": "https://github.com/DevExpress/testcafe-browser-provider-electron",
@@ -51,12 +51,12 @@
5151
"babel-plugin-transform-runtime": "^6.23.0",
5252
"babel-preset-env": "^1.6.0",
5353
"del": "^2.0.0",
54-
"electron": "^6.0.0",
54+
"electron": "^7.1.2",
5555
"gulp": "^4.0.0",
5656
"gulp-babel": "^7.0.0",
5757
"gulp-eslint": "^3.0.1",
5858
"publish-please": "^5.4.3",
59-
"testcafe": "1.4.0",
59+
"testcafe": "*",
6060
"tmp": "0.0.28"
6161
},
6262
"types": "./ts-defs/index.d.ts"

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function startElectron (config, ports) {
2424

2525
if (OS.mac && statSync(config.electronPath).isDirectory()) {
2626
cmd = 'open';
27-
args = ['-naW', `"${config.electronPath}"`, '--args'].concat(debugPortsArgs, extraArgs);
27+
args = ['-nW', '-a', config.electronPath, '--args'].concat(debugPortsArgs, extraArgs);
2828
}
2929
else {
3030
cmd = config.electronPath;

src/injectable/electron-mocks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ module.exports = function install (config, testPageUrl) {
6161
var WebContents;
6262

6363
if ( process.atomBinding ) {
64-
// < electron 6
64+
// NOTE: < Electron 6
6565
WebContents = process.atomBinding('web_contents').WebContents;
6666
}
6767
else {
68-
// electron 6+
68+
// NOTE: >= Electron 6
6969
WebContents = process.electronBinding('web_contents').WebContents;
7070
}
7171

src/injectable/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
import { sep } from 'path';
2+
3+
4+
const ELECTRON_BROWSER_INIT_PATHS = [
5+
'electron/js2c/browser_init', // NOTE: >= Electron v7.0.0
6+
['electron.asar', 'browser', 'init.js'].join(sep) // NOTE: <= Electron v6.1.5
7+
];
8+
9+
function isBrowserInitModule (path) {
10+
return ELECTRON_BROWSER_INIT_PATHS.some(initPath => path.endsWith(initPath));
11+
}
12+
113
module.exports = function (config, testPageUrl) {
214
var Module = require('module');
315

416
var origModuleLoad = Module._load;
517

618
Module._load = function (...args) {
7-
if (args[2]) {
19+
const isMain = args[2];
20+
const isNotBrowserInitMainModule = isMain && !isBrowserInitModule(args[0]);
21+
22+
if (isNotBrowserInitMainModule) {
823
if (config.appPath) {
924
config.appEntryPoint = require.resolve(config.appPath);
1025

src/node-inspect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default class NodeInspect {
3131
}
3232

3333
async _setupRemoteInterface () {
34-
this.client.Debugger.enable();
34+
this.client.Debugger.enable().then(async () => {
35+
return this.client.Debugger.setBreakpointByUrl({ lineNumber: 16, url: 'internal/main/run_main_module\.js' });
36+
});
3537

3638
var pausedEvent = promisifyEvent(this.client, 'Debugger.paused');
3739

templates/hook.js.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
(function () {
2-
require({{{INJECTABLE_PATH}}})({{{CONFIG}}}, {{{TEST_PAGE_URL}}})
2+
require('module')._load({{{INJECTABLE_PATH}}})({{{CONFIG}}}, {{{TEST_PAGE_URL}}})
33
})();
4-

0 commit comments

Comments
 (0)