browser_bug422590.js
Go to the documentation of this file.
1 function test() {
3 
4  // test the main (normal) browser window
6 }
7 
8 function testChromeless() {
9  // test a chromeless window
10  var newWin = openDialog("chrome://browser/content/", "_blank",
11  "chrome,dialog=no,toolbar=no", "about:blank");
12  ok(newWin, "got new window");
13 
14  function runWindowTest() {
15  // Check that the search bar is hidden
16  var searchBar = newWin.BrowserSearch.searchBar;
17  ok(searchBar, "got search bar");
18 
19  var searchBarBO = searchBar.boxObject;
20  is(searchBarBO.width, 0, "search bar hidden");
21  is(searchBarBO.height, 0, "search bar hidden");
22 
23  function finalize() {
24  newWin.removeEventListener("load", runWindowTest, false);
25  newWin.close();
26  finish();
27  }
28  testCustomize(newWin, finalize);
29  }
30 
31  newWin.addEventListener("load", runWindowTest, false);
32 }
33 
34 function testCustomize(aWindow, aCallback) {
35  var fileMenu = aWindow.document.getElementById("file-menu");
36  ok(fileMenu, "got file menu");
37  is(fileMenu.disabled, false, "file menu initially enabled");
38 
39  // Launch toolbar customization
40  // ctEl is either iframe that contains the customize sheet, or the dialog
41  var ctEl = aWindow.BrowserCustomizeToolbar();
42 
43  is(fileMenu.disabled, true,
44  "file menu is disabled during toolbar customization");
45 
46  // Set a callback on the window's toolbox
47  var nt = aWindow.getNavToolbox();
48  var oldHandler = nt.customizeInitialized;
49  nt.customizeInitialized = ctInit;
50  function ctInit() {
51  // Restore customizeInitialized handler
52  nt.customizeInitialized = oldHandler;
53 
54  // Close toolbar customization
55  closeToolbarCustomization(aWindow, ctEl);
56 
57  // Can't use the property, since the binding may have since been removed
58  // if the element is hidden (see bug 422590)
59  is(fileMenu.getAttribute("disabled"), "false",
60  "file menu is enabled after toolbar customization");
61 
62  if (aCallback)
63  aCallback();
64  }
65 }
66 
67 function closeToolbarCustomization(aWindow, aCTWindow) {
68  var osString = Components.classes["@mozilla.org/xre/app-info;1"].
69  getService(Components.interfaces.nsIXULRuntime).OS;
70 
71  // Force the cleanup code to be run now instead of onunload
72  // This also hides the sheet on Mac
73  aCTWindow.finishToolbarCustomization();
74 
75  // On windows and linux, need to explicitly close the window
76  if (osString != "Darwin")
77  aCTWindow.close();
78 }
function closeToolbarCustomization(aWindow, aCTWindow)
function testCustomize(aWindow, aCallback)
getService(Ci.sbIFaceplateManager)
let window
waitForExplicitFinish()
function testChromeless()
function test()