michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: function testState(aPinned) { michael@0: function elemAttr(id, attr) document.getElementById(id).getAttribute(attr); michael@0: michael@0: if (aPinned) { michael@0: is(elemAttr("key_close", "disabled"), "true", michael@0: "key_close should be disabled when a pinned-tab is selected"); michael@0: is(elemAttr("menu_close", "key"), "", michael@0: "menu_close shouldn't have a key set when a pinned is selected"); michael@0: } michael@0: else { michael@0: is(elemAttr("key_close", "disabled"), "", michael@0: "key_closed shouldn't have disabled state set when a non-pinned tab is selected"); michael@0: is(elemAttr("menu_close", "key"), "key_close", michael@0: "menu_close should have key_close set as its key when a non-pinned tab is selected"); michael@0: } michael@0: } michael@0: michael@0: let lastSelectedTab = gBrowser.selectedTab; michael@0: ok(!lastSelectedTab.pinned, "We should have started with a regular tab selected"); michael@0: michael@0: testState(false); michael@0: michael@0: let pinnedTab = gBrowser.addTab("about:blank"); michael@0: gBrowser.pinTab(pinnedTab); michael@0: michael@0: // Just pinning the tab shouldn't change the key state. michael@0: testState(false); michael@0: michael@0: // Test updating key state after selecting a tab. michael@0: gBrowser.selectedTab = pinnedTab; michael@0: testState(true); michael@0: michael@0: gBrowser.selectedTab = lastSelectedTab; michael@0: testState(false); michael@0: michael@0: gBrowser.selectedTab = pinnedTab; michael@0: testState(true); michael@0: michael@0: // Test updating the key state after un/pinning the tab. michael@0: gBrowser.unpinTab(pinnedTab); michael@0: testState(false); michael@0: michael@0: gBrowser.pinTab(pinnedTab); michael@0: testState(true); michael@0: michael@0: // Test updating the key state after removing the tab. michael@0: gBrowser.removeTab(pinnedTab); michael@0: testState(false); michael@0: michael@0: finish(); michael@0: }