Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 923539 of Porting a Google Chrome extension

  • Revision slug: Mozilla/Add-ons/WebExtensions/Porting_from_Google_Chrome
  • Revision title: Porting from Google Chrome
  • Revision id: 923539
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment

Revision Content

Work in progress

This article describes the changes you'll need to be aware of if you are porting an extension from Chrome or Opera to run on Firefox.

Briefly, the process of porting an extension from Chrome or Opera is like this:

  1. Review your use of manifest.json features and WebExtension APIs. If you're using features or APIs that are not yet supported in Firefox, you may not be able to port your extension yet.
  2. Add the applications key to the extension's manifest.json file.
  3. Check you have done the basic setup for installing WebExtensions in Firefox.
  4. Package the extension as an XPI, install the extension in Firefox, and test it.
  5. Submit it to AMO for signing and distribution.

The biggest issue right now is the first in the above list. Firefox currently has support for only a limited set of WebExtension features. We're working on adding more support, but many features are not yet supported, and we may never support some.

In the rest of this article we'll list the features and APIs that are fully or partially supported in Firefox. It's safe to assume that features and APIs not listed here are not yet supported.

manifest.json features

Fully supported keys

Partially supported keys

background

Firefox does not support the "persistent" property. Background scripts stay loaded all the time.

content_scripts

Firefox does not currently support:

  • include_globs
  • exclude_globs
  • match_about_blank

permissions

Firefox does not yet support the following permissions:

  • activeTab
  • background
  • clipboardRead
  • clipboardWrite
  • geolocation
  • nativeMessaging
  • unlimitedStorage

Obviously, it also don't yet support permissions for APIs that are themselves not supported.

JavaScript APIs

Fully supported APIs

Partially supported APIs

browserAction

Firefox does not support:

  • the imageData attribute on setIcon().
  • enable() or disable().

extension

Firefox only supports getBackgroundPage() and getURL().

i18n

  • In the JavaScript API, Firefox only supports getMessage().
  • Firefox only supports the @@extension_id and @@ui_locale predefined messages.
  • Firefox does not localize CSS files.
  • Strings to be localized must consist entirely of __MSG_foo__ in order for a substitution to be made.

notifications

  • The only supported notification options are iconUrl, title, and message.
  • The only supported methods we support are create(), clear(), and getAll().
  • The only supported event is onClosed. Firefox doesn't provide byUser data.

runtime

Firefox only supports onStartup, getManifest(), id, and the message passing interfaces (sendMessage(), onMessage, onConnect).

storage

  • The only storage area Firefox supports support is local.
  • Firefox does not support getBytesInUse() or clear().

tabs

Firefox does not support:

  • getCurrent()
  • sendRequest()
  • getSelected()
  • duplicate()
  • highlight()
  • move()
  • detectLanguage()
  • captureVisibleTab()
  • getZoom()
  • setZoom()
  • getZoomSettings()
  • setZoomSettings()

Firefox treats highlighted and active as the same since Firefox cannot select multiple tabs.

webNavigation

Firefox does not support:

  • getFrame()
  • getAllFrames()
  • onCreatedNavigationTarget
  • onHistoryStateUpdated
  • transition types and qualifiers
  • Filtering

onReferenceFragmentUpdated also triggers for pushState.

webRequest

Firefox does not support:

  • handlerBehaviorChanged()
  • onAuthRequired
  • onBeforeRedirect
  • onErrorOccurred

Requests can be:

  • canceled only in onBeforeRequest
  • modified/redirected only in onBeforeSendHeaders

Responses can be modified only in onHeadersReceived.

windows

  • onFocusChanged will trigger multiple times for a given focus change.
  • create() does not support the focused, type, or state options.
  • update() only supports the focused option.

Planned APIs

We don't yet support the following APIs, but plan to, soon:

 

Revision Source

<div class="warning">
<p>Work in progress</p>
</div>

<p>This article describes the changes you'll need to be aware of if you are porting an extension from Chrome or Opera to run on Firefox.</p>

<p>Briefly, the process of porting an extension from Chrome or Opera is like this:</p>

<ol>
 <li>Review your use of manifest.json features and WebExtension APIs. If you're using features or APIs that are not yet supported in Firefox, you may not be able to port your extension yet.</li>
 <li>Add the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a></code> key to the extension's manifest.json file.</li>
 <li><a href="/en-US/Add-ons/WebExtensions/Prerequisites">Check you have done the basic setup for installing WebExtensions in Firefox.</a></li>
 <li><a href="/en-US/Add-ons/WebExtensions/Packaging_and_installation">Package the extension as an XPI, install the extension in Firefox, and test it</a>.</li>
 <li><a href="/en-US/Add-ons/Distribution">Submit it to AMO for signing and distribution</a>.</li>
</ol>

<p>The biggest issue right now is the first in the above list. Firefox currently has support for only a limited set of WebExtension features. We're working on adding more support, but many features are not yet supported, and we may never support some.</p>

<p>In the rest of this article we'll list the features and APIs that are fully or partially supported in Firefox. It's safe to assume that features and APIs not listed here are not yet supported.</p>

<h2 id="manifest.json_features">manifest.json features</h2>

<h3 id="Fully_supported_keys">Fully supported keys</h3>

<ul>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/applications">applications</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/default_locale">default_locale</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/description">description</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/manifest_version">manifest_version</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/name">name</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/version">version</a></code></li>
 <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/web_accessible_resources">web_accessible_resources</a></code></li>
</ul>

<h3 id="Partially_supported_keys">Partially supported keys</h3>

<h4 id="background">background</h4>

<p>Firefox does not support the <code>"persistent"</code> property. Background scripts stay loaded all the time.</p>

<h4 id="content_scripts">content_scripts</h4>

<p>Firefox does not currently support:</p>

<ul>
 <li><code>include_globs</code></li>
 <li><code>exclude_globs</code></li>
 <li><code>match_about_blank</code></li>
</ul>

<h4 id="permissions">permissions</h4>

<p>Firefox does not yet support the following permissions:</p>

<ul>
 <li><code>activeTab</code></li>
 <li><code>background</code></li>
 <li><code>clipboardRead</code></li>
 <li><code>clipboardWrite</code></li>
 <li><code>geolocation</code></li>
 <li><code>nativeMessaging</code></li>
 <li><code>unlimitedStorage</code></li>
</ul>

<p>Obviously, it also don't yet support permissions for <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API#Chrome_incompatibilities">APIs that are themselves not supported</a>.</p>

<h2 id="JavaScript_APIs">JavaScript APIs</h2>

<h3 id="Fully_supported_APIs">Fully supported APIs</h3>

<ul>
 <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/alarms">alarms</a></code></li>
</ul>

<h3 id="Partially_supported_APIs">Partially supported APIs</h3>

<h4 id="browserAction"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">browserAction</a></h4>

<p>Firefox does not support:</p>

<ul>
 <li>the <code>imageData</code> attribute on <code>setIcon()</code>.</li>
 <li><code>enable()</code> or <code>disable()</code>.</li>
</ul>

<h4 id="extension"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/extension">extension</a></h4>

<p>Firefox <em>only supports</em> <code>getBackgroundPage()</code> and <code>getURL()</code>.</p>

<h4 id="i18n"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n">i18n</a></h4>

<ul>
 <li>In the JavaScript API, Firefox only supports <code>getMessage()</code>.</li>
 <li>Firefox only supports the <code>@@extension_id</code> and <code>@@ui_locale</code> predefined messages.</li>
 <li>Firefox does not localize CSS files.</li>
 <li>Strings to be localized must consist entirely of <code>__MSG_foo__</code> in order for a substitution to be made.</li>
</ul>

<h4 id="notifications"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications">notifications</a></h4>

<ul>
 <li>The only supported notification options are <code>iconUrl</code>, <code>title</code>, and <code>message</code>.</li>
 <li>The only supported methods we support are <code>create()</code>, <code>clear()</code>, and <code>getAll()</code>.</li>
 <li>The only supported event is <code>onClosed</code>. Firefox doesn't provide <code>byUser</code> data.</li>
</ul>

<h4 id="runtime"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime">runtime</a></h4>

<p>Firefox only supports <code>onStartup</code>, <code>getManifest()</code>, <code>id</code>, and the message passing interfaces (<code>sendMessage()</code>, <code>onMessage</code>, <code>onConnect</code>).</p>

<h4 id="storage"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage</a></h4>

<ul>
 <li>The only storage area Firefox supports support is <code>local</code>.</li>
 <li>Firefox does not support <code>getBytesInUse()</code> or <code>clear()</code>.</li>
</ul>

<h4 id="tabs"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs">tabs</a></h4>

<p>Firefox does not support:</p>

<ul>
 <li><code>getCurrent()</code></li>
 <li><code>sendRequest()</code></li>
 <li><code>getSelected()</code></li>
 <li><code>duplicate()</code></li>
 <li><code>highlight()</code></li>
 <li><code>move()</code></li>
 <li><code>detectLanguage()</code></li>
 <li><code>captureVisibleTab()</code></li>
 <li><code>getZoom()</code></li>
 <li><code>setZoom()</code></li>
 <li><code>getZoomSettings()</code></li>
 <li><code>setZoomSettings()</code></li>
</ul>

<p>Firefox treats <code>highlighted</code> and <code>active</code> as the same since Firefox cannot select multiple tabs.</p>

<h4 id="webNavigation"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation">webNavigation</a></h4>

<p>Firefox does not support:</p>

<ul>
 <li><code>getFrame()</code></li>
 <li><code>getAllFrames()</code></li>
 <li><code>onCreatedNavigationTarget</code></li>
 <li><code>onHistoryStateUpdated</code></li>
 <li>transition types and qualifiers</li>
 <li>Filtering</li>
</ul>

<p><code>onReferenceFragmentUpdated</code> also triggers for <code>pushState</code>.</p>

<h4 id="webRequest"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest">webRequest</a></h4>

<p>Firefox does not support:</p>

<ul>
 <li><code>handlerBehaviorChanged()</code></li>
 <li><code>onAuthRequired</code></li>
 <li><code>onBeforeRedirect</code></li>
 <li><code>onErrorOccurred</code></li>
</ul>

<p>Requests can be:</p>

<ul>
 <li>canceled only in <code>onBeforeRequest</code></li>
 <li>modified/redirected only in <code>onBeforeSendHeaders</code></li>
</ul>

<p>Responses can be modified only in <code>onHeadersReceived</code>.</p>

<h4 id="windows"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows">windows</a></h4>

<ul>
 <li><code>onFocusChanged</code> will trigger multiple times for a given focus change.</li>
 <li><code>create()</code> does not support the <code>focused</code>, <code>type</code>, or <code>state</code> options.</li>
 <li><code>update()</code> only supports the <code>focused</code> option.</li>
</ul>

<h3 id="Planned_APIs">Planned APIs</h3>

<p>We don't yet support the following APIs, but plan to, soon:</p>

<ul>
 <li><a class="external text" href="https://developer.chrome.com/extensions/bookmarks" rel="nofollow">bookmarks</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/commands" rel="nofollow">commands</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/contextMenus" rel="nofollow">contextMenus</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/cookies" rel="nofollow">cookies</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/devtools" rel="nofollow">Devtools (mostly panels)</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/downloads" rel="nofollow">downloads</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/history" rel="nofollow">history</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/idle" rel="nofollow">idle</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/omnibox" rel="nofollow">omnibox</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/pageAction" rel="nofollow">pageAction</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/permissions" rel="nofollow">permissions</a></li>
 <li><a class="external text" href="https://developer.chrome.com/extensions/runtime#method-connectNative" rel="nofollow">Native messaging (runtime.connectNative)</a></li>
</ul>

<p>&nbsp;</p>
Revert to this revision