From 9bc6302aead522f4a3695dbbf40a891dff2fd595 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 22 Aug 2016 19:26:07 +0900 Subject: [PATCH 1/2] spec: Add test case for fetch --- spec/chromium-spec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index feeffb041c51..f1d29a3db340 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -496,4 +496,25 @@ 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() + }) + }).catch(function (e) { + done() + }) + }) + }) + }) }) From 103fea5cdfe3a3fec62d82f91b20eda33cad820d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 22 Aug 2016 19:34:59 +0900 Subject: [PATCH 2/2] Use scoped policy for micro tasks --- atom/common/node_bindings.cc | 9 +++++---- spec/chromium-spec.js | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 2207046d8e02..d1db83b70850 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -169,10 +169,11 @@ node::Environment* NodeBindings::CreateEnvironment( context->GetIsolate(), uv_default_loop(), context, args.size(), c_argv.get(), 0, nullptr); - // Node turns off AutorunMicrotasks, but we need it in web pages to match the - // behavior of Chrome. - if (!is_browser_) - context->GetIsolate()->SetAutorunMicrotasks(true); + // Node uses the deprecated SetAutorunMicrotasks(false) mode, we should switch + // to use the scoped policy to match blink's behavior. + if (!is_browser_) { + context->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); + } mate::Dictionary process(context->GetIsolate(), env->process_object()); process.Set("type", process_type); diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index f1d29a3db340..991da316ec97 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -510,9 +510,10 @@ describe('chromium feature', function () { }).then((reader) => { reader.read().then((r) => { reader.cancel() + done() }) }).catch(function (e) { - done() + done(e) }) }) })