diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js
index 35237aba..b4f1463e 100644
--- a/content/treestyletab/treestyletab.js
+++ b/content/treestyletab/treestyletab.js
@@ -2207,7 +2207,4 @@ catch(e) {
TreeStyleTabService.__proto__ = TreeStyleTabService.utils = namespace.TreeStyleTabUtils;
TreeStyleTabService.utils.init();
})();
-window.addEventListener('DOMContentLoaded', TreeStyleTabService, true);
-window.addEventListener('load', TreeStyleTabService, false);
-TreeStyleTabService.ObserverService.addObserver(TreeStyleTabService, 'sessionstore-windows-restored', false);
diff --git a/content/treestyletab/treestyletab.xul b/content/treestyletab/treestyletab.xul
index 27597e7b..ba0572e4 100644
--- a/content/treestyletab/treestyletab.xul
+++ b/content/treestyletab/treestyletab.xul
@@ -11,6 +11,11 @@
+
diff --git a/tests/unit/TreeStyleTabBrowserAutoHide.test.js b/tests/unit/TreeStyleTabBrowserAutoHide.test.js
index 7b5c66d8..1592dcd5 100644
--- a/tests/unit/TreeStyleTabBrowserAutoHide.test.js
+++ b/tests/unit/TreeStyleTabBrowserAutoHide.test.js
@@ -1,11 +1,16 @@
+var autoHideFile = baseURL+'../../content/treestyletab/treestyletabbrowser_autoHide.js';
+
utils.include(baseURL+'../../content/treestyletab/treestyletab.js');
-utils.include(baseURL+'../../content/treestyletab/treestyletabbrowser_autoHide.js');
+utils.include(autoHideFile);
+var TSTBAutoHide = TreeStyleTabBrowserAutoHide;
var autoHide;
var owner;
function setUp()
{
+ utils.include(autoHideFile);
+
owner = new Mock('owner mock');
Mock.expect(TreeStyleTabBrowserAutoHide.prototype, 'init', []);
autoHide = new TreeStyleTabBrowserAutoHide(owner);
@@ -13,24 +18,33 @@ function setUp()
function tearDown()
{
+ owner = null;
}
-
-function test_fireStateChangingEvent()
+test_fireStateChangingEvent.parameters = {
+ expanded : {
+ state : TSTBAutoHide.prototype.kSTATE_EXPANDED,
+ shown : true
+ },
+ shrunken : {
+ state : TSTBAutoHide.prototype.kSTATE_SHRUNKEN,
+ shown : false
+ },
+ hidden : {
+ state : TSTBAutoHide.prototype.kSTATE_HIDDEN,
+ shown : false
+ }
+};
+function test_fireStateChangingEvent(aParameter)
{
- var expanded = Math.random() + Date.now() + 'expanded';
- var state = Math.random() + Date.now() + 'state';
-
owner.browser = new Mock('browser');
owner.browser.expect('dispatchEvent', TypeOf(Ci.nsIDOMEvent))
.then(function(aEvent) {
- assert.equals(expanded, aEvent.shown);
- assert.equals(state, aEvent.state);
+ assert.equals('TreeStyleTabAutoHideStateChanging', aEvent.type);
+ assert.strictlyEquals(aParameter.shown, aEvent.shown);
+ assert.equals(aParameter.state, aEvent.state);
});
- Mock.expectGet(autoHide, 'expanded', expanded);
- Mock.expectGet(autoHide, 'state', state);
+ Mock.expectGet(autoHide, 'state', aParameter.state).times(2);
autoHide.fireStateChangingEvent();
}
-
-
diff --git a/tests/unit/TreeStyleTabBrowserAutoHide_withoutMock.test.js b/tests/unit/TreeStyleTabBrowserAutoHide_withoutMock.test.js
new file mode 100644
index 00000000..32b61923
--- /dev/null
+++ b/tests/unit/TreeStyleTabBrowserAutoHide_withoutMock.test.js
@@ -0,0 +1,56 @@
+var autoHideFile = baseURL+'../../content/treestyletab/treestyletabbrowser_autoHide.js';
+
+utils.include(baseURL+'../../content/treestyletab/treestyletab.js');
+utils.include(autoHideFile);
+var TSTBAutoHide = TreeStyleTabBrowserAutoHide;
+
+var autoHide;
+var owner;
+
+function setUp()
+{
+ utils.include(autoHideFile);
+
+ utils.setUpTestWindow();
+
+ var w = utils.getTestWindow();
+ owner = { browser : w.gBrowser };
+ TreeStyleTabBrowserAutoHide.prototype.init = function() {};
+ autoHide = new TreeStyleTabBrowserAutoHide(owner);
+}
+
+function tearDown()
+{
+ utils.tearDownTestWindow();
+ owner = null;
+}
+
+test_fireStateChangingEvent.parameters = {
+ expanded : {
+ state : TSTBAutoHide.prototype.kSTATE_EXPANDED,
+ shown : true
+ },
+ shrunken : {
+ state : TSTBAutoHide.prototype.kSTATE_SHRUNKEN,
+ shown : false
+ },
+ hidden : {
+ state : TSTBAutoHide.prototype.kSTATE_HIDDEN,
+ shown : false
+ }
+};
+test_fireStateChangingEvent.assertions = 2;
+function test_fireStateChangingEvent(aParamter)
+{
+ var w = utils.getTestWindow();
+
+ w.gBrowser.setAttribute(TSTBAutoHide.prototype.kSTATE, aParamter.state);
+
+ w.addEventListener('TreeStyleTabAutoHideStateChanging', function(aEvent) {
+ w.removeEventListener('TreeStyleTabAutoHideStateChanging', arguments.callee, false);
+ assert.equals(aParamter.shown, aEvent.shown);
+ assert.equals(aParamter.state, aEvent.state);
+ }, false);
+
+ autoHide.fireStateChangingEvent();
+}