Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 833783: followup, fix exception when calling destroy multiple times.
Browse files Browse the repository at this point in the history
  • Loading branch information
ochameau committed Feb 11, 2013
1 parent b06eb5b commit d4556ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/sdk/tabs/tab-firefox.js
Expand Up @@ -57,9 +57,11 @@ const TabTrait = Trait.compose(EventEmitter, {
},
destroy: function destroy() {
this._removeAllListeners();
this._browser.removeEventListener(EVENTS.ready.dom, this._onReady, true);
this._tab = null;
TABS.splice(TABS.indexOf(this), 1);
if (this._tab) {
this._browser.removeEventListener(EVENTS.ready.dom, this._onReady, true);
this._tab = null;
TABS.splice(TABS.indexOf(this), 1);
}
},

/**
Expand Down
4 changes: 4 additions & 0 deletions test/test-tab.js
Expand Up @@ -121,6 +121,10 @@ exports["test behavior on close"] = function(assert, done) {
"After being closed, tab attributes are undefined (url)");
assert.equal(tab.index, undefined,
"After being closed, tab attributes are undefined (index)");
// Ensure that we can call destroy multiple times without throwing
tab.destroy();
tab.destroy();

done();
});
}
Expand Down

0 comments on commit d4556ce

Please sign in to comment.