Do process.emit('exit') in WillReleaseScriptContext
This commit is contained in:
parent
ffcf609de1
commit
bc196c016b
2 changed files with 3 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "atom/common/api/atom_bindings.h"
|
#include "atom/common/api/atom_bindings.h"
|
||||||
|
#include "atom/common/api/event_emitter_caller.h"
|
||||||
#include "atom/common/node_bindings.h"
|
#include "atom/common/node_bindings.h"
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
|
@ -174,6 +175,8 @@ void AtomRendererClient::DidCreateScriptContext(
|
||||||
|
|
||||||
void AtomRendererClient::WillReleaseScriptContext(
|
void AtomRendererClient::WillReleaseScriptContext(
|
||||||
v8::Handle<v8::Context> context) {
|
v8::Handle<v8::Context> context) {
|
||||||
|
node::Environment* env = node::Environment::GetCurrent(context);
|
||||||
|
mate::EmitEvent(env->isolate(), env->process_object(), "exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
||||||
|
|
|
@ -106,11 +106,6 @@ if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration =
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Emit the 'exit' event when page is unloading.
|
|
||||||
window.addEventListener('unload', function() {
|
|
||||||
return process.emit('exit');
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// Delete Node's symbols after the Environment has been loaded.
|
// Delete Node's symbols after the Environment has been loaded.
|
||||||
process.once('loaded', function() {
|
process.once('loaded', function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue