From 7c0980bbbdc9848303d16c0807e8b43fd9f6b92a Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Fri, 27 Oct 2017 09:27:39 -0700 Subject: [PATCH 1/2] tests(web-inspector): add test for setImmediate polyfill --- lighthouse-core/test/lib/web-inspector-test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lighthouse-core/test/lib/web-inspector-test.js b/lighthouse-core/test/lib/web-inspector-test.js index 01cc059180fd..e0a81bb2dafd 100644 --- a/lighthouse-core/test/lib/web-inspector-test.js +++ b/lighthouse-core/test/lib/web-inspector-test.js @@ -21,6 +21,21 @@ describe('Web Inspector lib', function() { assert.ok(WebInspector.Color); }); + it('does not destroy setImmediate', done => { + const fakeArg = { + foo() {}, + }; + + setImmediate(function(arg) { + try { + arg.foo(); + done(); + } catch (err) { + done(err); + } + }, fakeArg); + }); + // Our implementation of using DevTools doesn't sandbox natives // In the future, it'd be valuable to handle that so lighthouse can safely // be consumed as a lib, without dirtying the shared natives From c33fc94923020429eb856876f71759042529edf1 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Fri, 27 Oct 2017 15:09:09 -0700 Subject: [PATCH 2/2] change name, add comment --- lighthouse-core/test/lib/web-inspector-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/test/lib/web-inspector-test.js b/lighthouse-core/test/lib/web-inspector-test.js index e0a81bb2dafd..5b0581a84c33 100644 --- a/lighthouse-core/test/lib/web-inspector-test.js +++ b/lighthouse-core/test/lib/web-inspector-test.js @@ -21,14 +21,14 @@ describe('Web Inspector lib', function() { assert.ok(WebInspector.Color); }); - it('does not destroy setImmediate', done => { + it('does not polyfill setImmediate incorrectly', done => { const fakeArg = { foo() {}, }; setImmediate(function(arg) { try { - arg.foo(); + arg.foo(); // make sure setImmediate passed the fakeArg done(); } catch (err) { done(err);