B2G/gecko/browser/base/content/test/browser_addon_bar_aomlistener.js
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
This Source Code Form is subject to the terms of the Mozilla Public
License, v.
This Source Code Form is subject to the terms of the Mozilla Public License v .
function test() {
  let addonbar = document.getElementById("addon-bar");
  ok(addonbar.collapsed, "addon bar is collapsed by default");
  function addItem(id) {
    let button = document.createElement("toolbarbutton");
    button.id = id;
    let palette = document.getElementById("navigator-toolbox").palette;
    palette.appendChild(button);
    addonbar.insertItem(id, null, null, false);
  }
  AddonsMgrListener.onInstalling();
  let id = "testbutton";
  addItem(id);
  AddonsMgrListener.onInstalled();
  ok(!addonbar.collapsed, "addon bar is not collapsed after toggle");
  AddonsMgrListener.onUninstalling();
  addonbar.currentSet = addonbar.currentSet.replace("," + id, "");
  AddonsMgrListener.onUninstalled();
  ok(addonbar.collapsed, "addon bar is collapsed after toggle");
  AddonsMgrListener.onEnabling();
  let id = "testbutton";
  addItem(id);
  AddonsMgrListener.onEnabled();
  ok(!addonbar.collapsed, "addon bar is not collapsed after toggle");
  AddonsMgrListener.onDisabling();
  addonbar.currentSet = addonbar.currentSet.replace("," + id, "");
  AddonsMgrListener.onDisabled();
  ok(addonbar.collapsed, "addon bar is collapsed after toggle");
}
function test ( ) { let addonbar = document . getElementById ( "addon-bar" ) ; ok ( addonbar . collapsed , "addon bar is collapsed by default" ) ; function addItem ( id ) { let button = document . createElement ( "toolbarbutton" ) ; button . id = id ; let palette = document . getElementById ( "navigator-toolbox" ) . palette ; palette . appendChild ( button ) ; addonbar . insertItem ( id , null , null , false ) ; } AddonsMgrListener . onInstalling ( ) ; let id = "testbutton" ; addItem ( id ) ; AddonsMgrListener . onInstalled ( ) ; ok ( ! addonbar . collapsed , "addon bar is not collapsed after toggle" ) ; AddonsMgrListener . onUninstalling ( ) ; addonbar . currentSet = addonbar . currentSet . replace ( "," + id , "" ) ; AddonsMgrListener . onUninstalled ( ) ; ok ( addonbar . collapsed , "addon bar is collapsed after toggle" ) ; AddonsMgrListener . onEnabling ( ) ; let id = "testbutton" ; addItem ( id ) ; AddonsMgrListener . onEnabled ( ) ; ok ( ! addonbar . collapsed , "addon bar is not collapsed after toggle" ) ; AddonsMgrListener . onDisabling ( ) ; addonbar . currentSet = addonbar . currentSet . replace ( "," + id , "" ) ; AddonsMgrListener . onDisabled ( ) ; ok ( addonbar . collapsed , "addon bar is collapsed after toggle" ) ; }
This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0.
This Source Code Form is subject to the terms of the Mozilla Public License v . 2 . 0 .
// call onInstalling // add item to the bar // call onInstalled // confirm bar is visible // call onUninstalling // remove item from the bar // call onUninstalled // confirm bar is not visible // call onEnabling // add item to the bar // call onEnabled // confirm bar is visible // call onDisabling // remove item from the bar // call onDisabled // confirm bar is not visible