We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

window.NativeWindow Redirect 1

The NativeWindow object is only available to privileged code running on Firefox for Android, and is intended for use by Firefox for Android add-ons.

The NativeWindow object enables Firefox for Android add-ons to create user interface components.

NativeWindow is available as a property of the chrome window object. For example, if you use this template for initializing your extension, you can access it from the window argument passed into loadIntoWindow():

function loadIntoWindow(window) {
  window.NativeWindow.toast.show("I'm starting!", "short");

You can also access the chrome window using nsIWindowMediator:

let window = Services.wm.getMostRecentWindow("navigator:browser");
window.NativeWindow.toast.show("Here's another toast message!", "short");

Obtain NativeWindow object with add-on SDK:

// Obtain component object : Chrome Authority
// https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Chrome_Authority
var { Cu } = require("chrome");

// Obtain commonly used services : Services.jsm
// https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm

function getNativeWindow() {

	let window = Services.wm.getMostRecentWindow("navigator:browser");
	return window.NativeWindow;


The NativeWindow object enables developers of Firefox for Android add-ons to create UI components.

It supports the following components:

Add items to the main menu in Firefox for Android. See the menu API documentation.

label: menu label
icon: file:// or data: URI for an icon
callback: JS function called when menu is tapped
returns a menu ID that can be used to remove the menu
let id = NativeWindow.menu.add(label, icon, callback);


Show and hide doorhanger notifications. See the doorhanger API documentation.

message: displayed text
value: string based tag
buttons: array of JS objects used to create buttons in the notification
tabId: tab associated with this notification
options: JS object that has 'persistence' and 'timeout' options
NativeWindow.doorhanger.show(message, value, buttons, tabId, options);
NativeWindow.doorhanger.hide(value, tabId);


Add and remove context menu items. See the contextmenus API documentation.

label: menu label
selector: JS object that has a 'matches(element)' function. Used to show the menu.
callback: JS function called when menu is tapped
returns a menu ID that can be used to remove the menu
let id = NativeWindow.contextmenu.add(label, selector, callback);


Show Android toast notifications. See the toast API documentation.

message: displayed text
duration: "short" or "long"; Used for alert timeout
NativeWindow.toast.show(message, duration);



Add and remove pageactions, i.e. clickable indicators in the URL bar. See the pageactions API documentation.

NativeWindow.pageactions was deprecated in Firefox 34. Use the new PageActions.jsm instead.

title: Pageaction title
icon: Icon image for the pageaction
clickCallback: Callback called when pageaction is clicked
longClickCallback: Callback called when pageaction is long pressed
let options = {
  title: "title",
  icon: "chrome://myaddon/skin/image.png",
  clickCallback: function() { },
  longClickCallback: function() { } (optional)

//Adding pageaction
let id = NativeWindow.pageactions.add(options);

//Remove pageaction

Document Tags and Contributors

Last updated by: Sheppy,