Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add e2e test for abort in renderer loaded native module #617

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
ELECTRON_CACHE_DIR: ${{ github.workspace }}
FAILURE_LOG: true
ELECTRON_ENABLE_LOGGING: true

jobs:
build:
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/test-apps/native-electron/renderer-abort/addon.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <node_api.h>
#include <stdlib.h>

namespace demo
{
napi_value Method(napi_env env, napi_callback_info args)
{
abort();
return nullptr;
}

napi_value init(napi_env env, napi_value exports)
{
napi_status status;
napi_value fn;
status = napi_create_function(env, nullptr, 0, Method, nullptr, &fn);
if (status != napi_ok)
return nullptr;
status = napi_set_named_property(env, exports, "abort", fn);
if (status != napi_ok)
return nullptr;
return exports;
}

NAPI_MODULE(NODE_GYP_MODULE_NAME, init)
}
8 changes: 8 additions & 0 deletions test/e2e/test-apps/native-electron/renderer-abort/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cc" ]
}
]
}
18 changes: 18 additions & 0 deletions test/e2e/test-apps/native-electron/renderer-abort/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"method": "minidump",
"namespacedData": {
"initialScope": {
"release":"native-electron-renderer-abort@1.0.0",
"user": {
"username": "some_user"
}
}
},
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"appId": "277345",
"data": {
"event_id": "{{id}}",
"timestamp": 0
},
"attachments": [ { "attachment_type": "event.minidump" } ]
}
15 changes: 15 additions & 0 deletions test/e2e/test-apps/native-electron/renderer-abort/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "native-electron-renderer-abort",
"version": "1.0.0",
"main": "src/main.js",
"scripts": {
"build": "node-gyp configure build"
},
"dependencies": {
"@sentry/electron": "3.0.0",
"sadness-generator": "0.0.2"
},
"devDependencies": {
"node-gyp": "9.3.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
description: Native Renderer Abort
category: Native (Electron Uploader)
condition: usesCrashpad && version.major >= 20
command: yarn && yarn build
20 changes: 20 additions & 0 deletions test/e2e/test-apps/native-electron/renderer-abort/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron');
const { abort } = require('../build/Release/addon.node');

init({
debug: true,
});

setTimeout(() => {
abort();
}, 500);
</script>
</body>
</html>
27 changes: 27 additions & 0 deletions test/e2e/test-apps/native-electron/renderer-abort/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const path = require('path');

const { app, BrowserWindow } = require('electron');
const { init, Integrations } = require('@sentry/electron');

app.commandLine.appendSwitch('enable-crashpad');

init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
integrations: [new Integrations.ElectronMinidump()],
initialScope: { user: { username: 'some_user' } },
onFatalError: () => {},
});

app.on('ready', () => {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

mainWindow.loadFile(path.join(__dirname, 'index.html'));
});
26 changes: 26 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-abort/addon.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <node_api.h>
#include <stdlib.h>

namespace demo
{
napi_value Method(napi_env env, napi_callback_info args)
{
abort();
return nullptr;
}

napi_value init(napi_env env, napi_value exports)
{
napi_status status;
napi_value fn;
status = napi_create_function(env, nullptr, 0, Method, nullptr, &fn);
if (status != napi_ok)
return nullptr;
status = napi_set_named_property(env, exports, "abort", fn);
if (status != napi_ok)
return nullptr;
return exports;
}

NAPI_MODULE(NODE_GYP_MODULE_NAME, init)
}
8 changes: 8 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-abort/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cc" ]
}
]
}
75 changes: 75 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-abort/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"method": "envelope",
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4",
"appId": "277345",
"data": {
"sdk": {
"name": "sentry.javascript.electron",
"packages": [
{
"name": "npm:@sentry/electron",
"version": "{{version}}"
}
],
"version": "{{version}}"
},
"contexts": {
"app": {
"app_name": "native-sentry-renderer-abort",
"app_version": "1.0.0",
"app_start_time": "{{time}}"
},
"browser": {
"name": "Chrome"
},
"chrome": {
"name": "Chrome",
"type": "runtime",
"version": "{{version}}"
},
"device": {
"arch": "{{arch}}",
"family": "Desktop",
"memory_size": 0,
"free_memory": 0,
"processor_count": 0,
"processor_frequency": 0,
"cpu_description": "{{cpu}}",
"screen_resolution":"{{screen}}",
"screen_density": 1,
"language": "{{language}}"
},
"node": {
"name": "Node",
"type": "runtime",
"version": "{{version}}"
},
"os": {
"name": "{{platform}}",
"version": "{{version}}"
},
"runtime": {
"name": "Electron",
"version": "{{version}}"
},
"electron": {
"crashed_url": "app:///src/index.html"
}
},
"release": "native-sentry-renderer-abort@1.0.0",
"environment": "development",
"user": {
"ip_address": "{{auto}}"
},
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "renderer",
"event_type": "native"
}
},
"attachments": [ { "attachment_type": "event.minidump" } ]
}
15 changes: 15 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-abort/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "native-sentry-renderer-abort",
"version": "1.0.0",
"main": "src/main.js",
"scripts": {
"build": "node-gyp configure build"
},
"dependencies": {
"@sentry/electron": "3.0.0",
"sadness-generator": "0.0.2"
},
"devDependencies": {
"node-gyp": "9.3.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
description: Native Renderer Abort
category: Native (Sentry Uploader)
condition: usesCrashpad && version.major >= 20
command: yarn && yarn build
20 changes: 20 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-abort/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron');
const { abort } = require('../build/Release/addon.node');

init({
debug: true,
});

setTimeout(() => {
abort();
}, 500);
</script>
</body>
</html>
25 changes: 25 additions & 0 deletions test/e2e/test-apps/native-sentry/renderer-abort/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const path = require('path');

const { app, BrowserWindow } = require('electron');
const { init } = require('@sentry/electron');

app.commandLine.appendSwitch('enable-crashpad');

init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
onFatalError: () => {},
});

app.on('ready', () => {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

mainWindow.loadFile(path.join(__dirname, 'index.html'));
});
Loading