michael@0: 'use strict'; michael@0: michael@0: const { setTimeout } = require('sdk/timers'); michael@0: const tabs = require('sdk/tabs'); michael@0: michael@0: let closeEvents = 0; michael@0: const closeEventDetector = _ => closeEvents++; michael@0: michael@0: exports.testNoTabCloseOnStartup = function(assert, done) { michael@0: setTimeout(_ => { michael@0: assert.equal(closeEvents, 0, 'there were no tab close events detected'); michael@0: tabs.open({ michael@0: url: 'about:mozilla', michael@0: inBackground: true, michael@0: onReady: tab => tab.close(), michael@0: onClose: _ => { michael@0: assert.equal(closeEvents, 1, 'there was one tab close event detected'); michael@0: done(); michael@0: } michael@0: }) michael@0: }); michael@0: } michael@0: michael@0: michael@0: exports.main = function() { michael@0: tabs.on('close', closeEventDetector); michael@0: michael@0: require("sdk/test/runner").runTestsFromModule(module); michael@0: }