1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug580638.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + waitForExplicitFinish(); 1.10 + 1.11 + function testState(aPinned) { 1.12 + function elemAttr(id, attr) document.getElementById(id).getAttribute(attr); 1.13 + 1.14 + if (aPinned) { 1.15 + is(elemAttr("key_close", "disabled"), "true", 1.16 + "key_close should be disabled when a pinned-tab is selected"); 1.17 + is(elemAttr("menu_close", "key"), "", 1.18 + "menu_close shouldn't have a key set when a pinned is selected"); 1.19 + } 1.20 + else { 1.21 + is(elemAttr("key_close", "disabled"), "", 1.22 + "key_closed shouldn't have disabled state set when a non-pinned tab is selected"); 1.23 + is(elemAttr("menu_close", "key"), "key_close", 1.24 + "menu_close should have key_close set as its key when a non-pinned tab is selected"); 1.25 + } 1.26 + } 1.27 + 1.28 + let lastSelectedTab = gBrowser.selectedTab; 1.29 + ok(!lastSelectedTab.pinned, "We should have started with a regular tab selected"); 1.30 + 1.31 + testState(false); 1.32 + 1.33 + let pinnedTab = gBrowser.addTab("about:blank"); 1.34 + gBrowser.pinTab(pinnedTab); 1.35 + 1.36 + // Just pinning the tab shouldn't change the key state. 1.37 + testState(false); 1.38 + 1.39 + // Test updating key state after selecting a tab. 1.40 + gBrowser.selectedTab = pinnedTab; 1.41 + testState(true); 1.42 + 1.43 + gBrowser.selectedTab = lastSelectedTab; 1.44 + testState(false); 1.45 + 1.46 + gBrowser.selectedTab = pinnedTab; 1.47 + testState(true); 1.48 + 1.49 + // Test updating the key state after un/pinning the tab. 1.50 + gBrowser.unpinTab(pinnedTab); 1.51 + testState(false); 1.52 + 1.53 + gBrowser.pinTab(pinnedTab); 1.54 + testState(true); 1.55 + 1.56 + // Test updating the key state after removing the tab. 1.57 + gBrowser.removeTab(pinnedTab); 1.58 + testState(false); 1.59 + 1.60 + finish(); 1.61 +}