Merge pull request #6926 from electron/fix-fetch
Use scoped policy for micro tasks
This commit is contained in:
commit
d6a63855c4
2 changed files with 27 additions and 4 deletions
|
@ -169,10 +169,11 @@ node::Environment* NodeBindings::CreateEnvironment(
|
||||||
context->GetIsolate(), uv_default_loop(), context,
|
context->GetIsolate(), uv_default_loop(), context,
|
||||||
args.size(), c_argv.get(), 0, nullptr);
|
args.size(), c_argv.get(), 0, nullptr);
|
||||||
|
|
||||||
// Node turns off AutorunMicrotasks, but we need it in web pages to match the
|
// Node uses the deprecated SetAutorunMicrotasks(false) mode, we should switch
|
||||||
// behavior of Chrome.
|
// to use the scoped policy to match blink's behavior.
|
||||||
if (!is_browser_)
|
if (!is_browser_) {
|
||||||
context->GetIsolate()->SetAutorunMicrotasks(true);
|
context->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
|
||||||
|
}
|
||||||
|
|
||||||
mate::Dictionary process(context->GetIsolate(), env->process_object());
|
mate::Dictionary process(context->GetIsolate(), env->process_object());
|
||||||
process.Set("type", process_type);
|
process.Set("type", process_type);
|
||||||
|
|
|
@ -496,4 +496,26 @@ describe('chromium feature', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('fetch', function () {
|
||||||
|
it('does not crash', function (done) {
|
||||||
|
const server = http.createServer(function (req, res) {
|
||||||
|
res.end('test')
|
||||||
|
server.close()
|
||||||
|
})
|
||||||
|
server.listen(0, '127.0.0.1', function () {
|
||||||
|
const port = server.address().port
|
||||||
|
fetch(`http://127.0.0.1:${port}`).then((res) => {
|
||||||
|
return res.body.getReader()
|
||||||
|
}).then((reader) => {
|
||||||
|
reader.read().then((r) => {
|
||||||
|
reader.cancel()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
}).catch(function (e) {
|
||||||
|
done(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue