feat: add error event for utility process (33-x-y) (#43997)
* feat: add error event for utility process (#43774)
* feat: add error event for utility process
* chore: use public report api
* chore: fix lint
* doc: mark error event as experimental
---------
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
* fixup! feat: add error event for utility process (#43774)
remove #include "electron/mas.h"
this header did not exist before c1c8fbfd9
---------
Co-authored-by: Robo <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
d8cd86c4fa
commit
5836ea1a78
16 changed files with 166 additions and 5 deletions
50
spec/fixtures/native-addon/external-ab/binding.cc
vendored
Normal file
50
spec/fixtures/native-addon/external-ab/binding.cc
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <node_api.h>
|
||||
#undef NAPI_VERSION
|
||||
#include <node_buffer.h>
|
||||
#include <v8.h>
|
||||
|
||||
namespace {
|
||||
|
||||
napi_value CreateBuffer(napi_env env, napi_callback_info info) {
|
||||
v8::Isolate* isolate = v8::Isolate::TryGetCurrent();
|
||||
if (isolate == nullptr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const size_t length = 4;
|
||||
|
||||
uint8_t* data = new uint8_t[length];
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
data[i] = static_cast<uint8_t>(length);
|
||||
}
|
||||
|
||||
auto finalizer = [](char* data, void* hint) {
|
||||
delete[] static_cast<uint8_t*>(reinterpret_cast<void*>(data));
|
||||
};
|
||||
|
||||
// NOTE: Buffer API is invoked directly rather than
|
||||
// napi version to trigger the FATAL error from V8.
|
||||
v8::MaybeLocal<v8::Object> maybe = node::Buffer::New(
|
||||
isolate, static_cast<char*>(reinterpret_cast<void*>(data)), length,
|
||||
finalizer, nullptr);
|
||||
|
||||
return reinterpret_cast<napi_value>(*maybe.ToLocalChecked());
|
||||
}
|
||||
|
||||
napi_value Init(napi_env env, napi_value exports) {
|
||||
napi_status status;
|
||||
napi_property_descriptor descriptors[] = {{"createBuffer", NULL, CreateBuffer,
|
||||
NULL, NULL, NULL, napi_default,
|
||||
NULL}};
|
||||
|
||||
status = napi_define_properties(
|
||||
env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors);
|
||||
if (status != napi_ok)
|
||||
return NULL;
|
||||
|
||||
return exports;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
|
10
spec/fixtures/native-addon/external-ab/binding.gyp
vendored
Normal file
10
spec/fixtures/native-addon/external-ab/binding.gyp
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "external_ab",
|
||||
"sources": [
|
||||
"binding.cc"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
4
spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js
vendored
Normal file
4
spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
const binding = require('../build/Release/external_ab.node');
|
||||
binding.createBuffer();
|
5
spec/fixtures/native-addon/external-ab/package.json
vendored
Normal file
5
spec/fixtures/native-addon/external-ab/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"main": "./lib/test-array-buffer.js",
|
||||
"name": "@electron-ci/external-ab",
|
||||
"version": "0.0.1"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue