diff --git a/test/unit/dynamic-import.html b/test/unit/dynamic-import.html index 9dbaf7fa0b..d5fa6a4b2f 100644 --- a/test/unit/dynamic-import.html +++ b/test/unit/dynamic-import.html @@ -65,6 +65,40 @@ }, null, true); }); + test('importHref does not leak event listeners on load', function(done) { + var errorSpy = sinon.spy(); + var loadSpy = sinon.spy(function(e) { + var target = e.target; + target.dispatchEvent(new Event('error')); + assert.isFalse(errorSpy.called, 'doesn\'t trigger the error event listener'); + setTimeout(function() { + loadSpy.reset(); + target.dispatchEvent(new Event('load')); + assert.isFalse(loadSpy.called, 'doesn\'t trigger the load event listener'); + done(); + }); + }); + + Polymer.Base.importHref('dynamic-imports/async-import.html', loadSpy, errorSpy, true); + }); + + test('importHref does not leak event listeners on error', function(done) { + var loadSpy = sinon.spy(); + var errorSpy = sinon.spy(function(e) { + var target = e.target; + target.dispatchEvent(new Event('load')); + assert.isFalse(loadSpy.called, 'doesn\'t trigger the load event listener'); + setTimeout(function() { + errorSpy.reset(); + target.dispatchEvent(new Event('error')); + assert.isFalse(errorSpy.called, 'doesn\'t trigger the error event listener'); + done(); + }); + }); + + Polymer.Base.importHref('dynamic-imports/async-import-invalid.html', loadSpy, errorSpy, true); + }); + }); });