Skip to content

Commit

Permalink
Bump Electron to '^7.1.2' (#51)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Farfurix committed Dec 5, 2019
1 parent c711f06 commit c2c0743
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testcafe-browser-provider-electron",
"version": "0.0.12",
"version": "0.0.13",
"description": "TestCafe browser provider plugin for testing applications built with Electron.",
"repository": "https://github.com/DevExpress/testcafe-browser-provider-electron",
"homepage": "https://github.com/DevExpress/testcafe-browser-provider-electron",
Expand Down Expand Up @@ -51,12 +51,12 @@
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"del": "^2.0.0",
"electron": "^6.0.0",
"electron": "^7.1.2",
"gulp": "^4.0.0",
"gulp-babel": "^7.0.0",
"gulp-eslint": "^3.0.1",
"publish-please": "^5.4.3",
"testcafe": "1.4.0",
"testcafe": "*",
"tmp": "0.0.28"
},
"types": "./ts-defs/index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function startElectron (config, ports) {

if (OS.mac && statSync(config.electronPath).isDirectory()) {
cmd = 'open';
args = ['-naW', `"${config.electronPath}"`, '--args'].concat(debugPortsArgs, extraArgs);
args = ['-nW', '-a', config.electronPath, '--args'].concat(debugPortsArgs, extraArgs);
}
else {
cmd = config.electronPath;
Expand Down
4 changes: 2 additions & 2 deletions src/injectable/electron-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ module.exports = function install (config, testPageUrl) {
var WebContents;

if ( process.atomBinding ) {
// < electron 6
// NOTE: < Electron 6
WebContents = process.atomBinding('web_contents').WebContents;
}
else {
// electron 6+
// NOTE: >= Electron 6
WebContents = process.electronBinding('web_contents').WebContents;
}

Expand Down
17 changes: 16 additions & 1 deletion src/injectable/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { sep } from 'path';


const ELECTRON_BROWSER_INIT_PATHS = [
'electron/js2c/browser_init', // NOTE: >= Electron v7.0.0
['electron.asar', 'browser', 'init.js'].join(sep) // NOTE: <= Electron v6.1.5
];

function isBrowserInitModule (path) {
return ELECTRON_BROWSER_INIT_PATHS.some(initPath => path.endsWith(initPath));
}

module.exports = function (config, testPageUrl) {
var Module = require('module');

var origModuleLoad = Module._load;

Module._load = function (...args) {
if (args[2]) {
const isMain = args[2];
const isNotBrowserInitMainModule = isMain && !isBrowserInitModule(args[0]);

if (isNotBrowserInitMainModule) {
if (config.appPath) {
config.appEntryPoint = require.resolve(config.appPath);

Expand Down
4 changes: 3 additions & 1 deletion src/node-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default class NodeInspect {
}

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

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

Expand Down
3 changes: 1 addition & 2 deletions templates/hook.js.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(function () {
require({{{INJECTABLE_PATH}}})({{{CONFIG}}}, {{{TEST_PAGE_URL}}})
require('module')._load({{{INJECTABLE_PATH}}})({{{CONFIG}}}, {{{TEST_PAGE_URL}}})
})();

0 comments on commit c2c0743

Please sign in to comment.