A place to cache linked articles (think custom and personal wayback machine)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.md 15KB

4 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. title: Extensions in Firefox 59
  2. url: https://blog.mozilla.org/addons/2018/01/26/extensions-firefox-59/
  3. hash_url: b431025fdd5261443b3a89a3f60b4ce8
  4. <img src="https://ffp4g1ylyit3jdyti1hqcvtb-wpengine.netdna-ssl.com/addons/files/2018/01/puzzle-1746563_640-160x160.png" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" title="" srcset="https://blog.mozilla.org/addons/files/2018/01/puzzle-1746563_640-160x160.png 160w, https://blog.mozilla.org/addons/files/2018/01/puzzle-1746563_640-252x252.png 252w, https://blog.mozilla.org/addons/files/2018/01/puzzle-1746563_640-600x600.png 600w, https://blog.mozilla.org/addons/files/2018/01/puzzle-1746563_640.png 640w" sizes="(max-width: 160px) 100vw, 160px"/> <p><a href="https://www.mozilla.org/firefox/">Firefox Quantum</a> continues to make <a href="https://arstechnica.com/gadgets/2018/01/firefoxs-continued-quantum-transformation-more-multithreading-tracking-protection/">news</a> as Mozilla incorporates even more <a href="https://hacks.mozilla.org/2018/01/making-webassembly-even-faster-firefoxs-new-streaming-and-tiering-compiler/">innovative technology</a> into the platform. The development team behind the WebExtensions architecture is no exception, landing a slew of new API and improvements that can now be found in Firefox 59 (just released to <a href="https://www.mozilla.org/firefox/channel/desktop/">the Beta channel</a>).</p>
  5. <p>As always, documentation for the API discussed here can be found on <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions">MDN Web Docs</a> (some of the features below are just hitting the main branch as of this post, so if you don’t find the documentation on MDN, check back in a few days).</p>
  6. <h2><a id="experimental-tab-hiding"/>Experimental Tab Hiding</h2>
  7. <p>Tab hiding is back! Since the deprecation of the legacy extension architecture, one of the most requested features has been the ability to hide tabs with the WebExtensions API. It was a key element of some very popular legacy add-ons that provided the ability to manage tab groups. Firefox 59 brings this capability back in an initial, experimental form.</p>
  8. <p>The API is very straightforward:</p>
  9. <ul>
  10. <li>Include the “tabHide” permission in your manifest file.</li>
  11. <li>Use tabs.hide() with the tab ID (or list of tab IDs) to hide tabs.</li>
  12. <li>Use tabs.show() with the tab ID (or list of tab IDs) to show hidden tabs.</li>
  13. <li>Examine the tabs.Tab.hidden field to determine if a tab is currently hidden.</li>
  14. </ul>
  15. <p>Note that the visible state of a tab is completely independent from its discarded state. While it may make sense to keep certain tabs active and loaded in memory while hidden, we encourage you to use tabs.discard() in combination with tabs.hide() to help manage memory and resource usage.</p>
  16. <p>There are certain restrictions when hiding tabs:</p>
  17. <ul>
  18. <li>Tabs that are pinned cannot be hidden</li>
  19. <li>Tabs that are sharing their screen, microphone or camera cannot be hidden</li>
  20. <li>The current active tab cannot be hidden</li>
  21. <li>Tabs that are in the process of being closed cannot be hidden</li>
  22. </ul>
  23. <p>The reintroduction of hidden tabs to Firefox does not come without some concern. A primary motivation for moving to the WebExtensions framework is to offer users a safer extension ecosystem that can be trusted to protect their security and privacy. Obviously, tab hiding opens the door for malicious extensions to hide tabs, doing things in the background without a user’s knowledge.</p>
  24. <p>To make sure we get things right, tab hiding is disabled by default. To enable the API, you must manually go to the about:config page and set extensions.webextensions.tabhide.enabled to true. This restriction will remain in place until:</p>
  25. <ul>
  26. <li>Additional user interface features are added to Firefox that allow users to see all of their hidden tabs and/or show those tabs independent of any extension. This user interface work is currently active and on-going.</li>
  27. <li>Developers (internal and external) have had some time to try the API and understand its strengths and weaknesses. In particular, we want some time to gather input on the potential for abuse.</li>
  28. </ul>
  29. <p>To be clear, this API is currently <b>experimental</b>. It could change, or even go away entirely if we can’t provide it in a secure manner.  Nevertheless, Firefox has a long, proud history of customization and the team is committed to upholding that tradition with tab hiding. So please give the API a try and see what you think. With your help, we will work to make tab hiding as fully functional as possible while still maintaining the security of the WebExtensions architecture.</p>
  30. <p>Want to jump right in a see what it’s like? Give the <a href="https://addons.mozilla.org/en-US/firefox/addon/tab-hider/">Tab Hider</a> extension a try.</p>
  31. <h2>Additional Tab Features</h2>
  32. <p>While tab hiding is the big feature to land in Firefox 59, it isn’t the only thing related to tabs.</p>
  33. <h2>Even More Theme API</h2>
  34. <p>Continuing the “theme” of previous releases, Firefox 59 includes a number of additions to the Theme API that allow you to customize even more of the browser’s appearance, including:</p>
  35. <h2>Improvements to the webRequest API</h2>
  36. <p>The webRequest API now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1377689">merges multiple headers with the same name</a> rather than using only the last one. In addition, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1149250">a couple</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1418275">of mechanisms</a> were added to the webRequest API to allow for requests to be upgraded from HTTP to HTTPS.</p>
  37. <p>Finally, to make debugging a lot easier, exceptions raised from a webRequest blocking listener now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1428094">report the original error message and filename</a>. Below is an example:</p>
  38. <div id="attachment_8371" class="wp-caption aligncenter"><img class="size-full wp-image-8371" src="https://ffp4g1ylyit3jdyti1hqcvtb-wpengine.netdna-ssl.com/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-BEFORE.png" alt="Before Firefox 59" srcset="https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-BEFORE.png 811w, https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-BEFORE-252x21.png 252w, https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-BEFORE-768x63.png 768w, https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-BEFORE-600x50.png 600w" sizes="(max-width: 811px) 100vw, 811px"/><p class="wp-caption-text">Before Firefox 59</p></div>
  39. <div id="attachment_8372" class="wp-caption aligncenter"><img class="size-full wp-image-8372" src="https://ffp4g1ylyit3jdyti1hqcvtb-wpengine.netdna-ssl.com/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-AFTER.png" alt="Starting With Firefox 59" srcset="https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-AFTER.png 817w, https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-AFTER-252x19.png 252w, https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-AFTER-768x58.png 768w, https://blog.mozilla.org/addons/files/2018/01/Screenshot-2018-1-24-1428094-Exception-raised-from-a-webRequest-blocking-listener-AFTER-600x46.png 600w" sizes="(max-width: 817px) 100vw, 817px"/><p class="wp-caption-text">Starting With Firefox 59</p></div>
  40. <h2>Register Content Scripts at Runtime</h2>
  41. <p>Another big feature landing with Firefox 59 is the ability to <a href="https://developer.mozilla.org/Add-ons/WebExtensions/API/contentScripts">register content scripts</a> at runtime. This is an important feature for extensions that want to support user scripting.</p>
  42. <p>Using the contentScripts.register() API, extensions can dynamically associate content scripts with different URLs, lifting the previous limitation that all content scripts had to be listed statically in the manifest file.</p>
  43. <h2>Support for Decentralization Protocols</h2>
  44. <p>Mozilla has always been a <a href="https://www.mozilla.org/en-US/internet-health/decentralization/">proponent of decentralization</a>, recognizing that it is a key ingredient of a healthy Internet. Starting with Firefox 59, several protocols that support decentralized architectures are approved for use by extensions.  The newly approved protocols are:</p>
  45. <p>Firefox itself does not implement these protocols, but having them on the approved list means the browser recognizes them as valid protocols and extensions are free to provide implementations.</p>
  46. <h2>browserAction and pageAction Improvements</h2>
  47. <p>Browser Actions and Page Actions are two of the most popular types of extensions that we see submitted to the Firefox <a href="https://addons.mozilla.org/">Add-Ons website</a>.  Accordingly, the team behind WebExtensions continues to expand and improve the API for those types of extensions.</p>
  48. <ul>
  49. <li>pageActions can now be <a href="https://developer.mozilla.org/Add-ons/WebExtensions/manifest.json/page_action">shown and/or hidden automatically</a> for specific pages via pattern matching using the “hide_matches” and “show_matches” manifest properties. This is a nice performance win for users.</li>
  50. <li><a href="https://developer.mozilla.org/Add-ons/WebExtensions/API/browserAction#Functions">browserAction set* methods can now accept a null value</a> which removes the property from the browserAction.</li>
  51. <li>Invalid badge background colors are <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1427107">now rejected</a> (provides more Chrome compatibility).</li>
  52. <li>An extension can now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1427431">determine </a>if its browserAction is enabled or disabled (browserAction.isEnabled), a pageAction is currently shown for a tab ( pageActions.isShown), and if its sidebarAction is currently open (sidebarAction.isOpen).</li>
  53. </ul>
  54. <h2>Enhancement to Cookies</h2>
  55. <p>The ability for extensions to control cookies in the browser expanded in Firefox 59, including:</p>
  56. <h2>Proxy Settings</h2>
  57. <p>Extensions can now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1425535">override the proxy settings</a> in the browser which has been another highly requested feature.  Using the browserSettings.proxyConfig.set() API, the following proxy settings can be controlled:</p>
  58. <ul>
  59. <li>proxyType: The type of proxy to use.</li>
  60. <li>http: The address of the http proxy, can include a port.</li>
  61. <li>httpProxyAll: Use the http proxy server for all protocols.</li>
  62. <li>ftp: The address of the ftp proxy, can include a port.</li>
  63. <li>ssl: The address of the ssl proxy, can include a port.</li>
  64. <li>socks: The address of the socks proxy, can include a port.</li>
  65. <li>socksVersion: The version of the socks proxy.</li>
  66. <li>passthrough: A list of hosts which should not be proxied.</li>
  67. <li>autoConfigUrl: A URL to use to configure the proxy.</li>
  68. <li>autoLogin: Do not prompt for authentication if password is saved.</li>
  69. <li>proxyDNS: Proxy DNS when using SOCKS v5.</li>
  70. </ul>
  71. <h2>User Notification of Extensions Overrides</h2>
  72. <p>As with previous releases, when functionality is provided via WebExtensions that allows extensions to control some aspect of the browser, Firefox will inform the user which extension controls that aspect and provide a way for them to regain control.</p>
  73. <p>The ability for an extension to control the browser’s tracking protection setting was added back in Firefox 57 via the websites.trackingProtectionMode API. Firefox 59 now shows when an extension controls tracking protection.</p>
  74. <p><img class="aligncenter size-full wp-image-8373" src="https://ffp4g1ylyit3jdyti1hqcvtb-wpengine.netdna-ssl.com/addons/files/2018/01/tracking-protection.gif" alt="Tracking Protection Notification"/></p>
  75. <p>In the above image, notice that a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1403751">message is now displayed</a> after a user disables an extension reminding them how to re-enable it, also a new feature of Firefox 59.</p>
  76. <p>One of the most popular browser defaults to override is the new tab page. Firefox already shows the user when an extension has overridden that page, but starting with Firefox 59 it also informs the user of the override on the first appearance of the new tab page itself. Plus, it is smart enough to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1414018">revert back to the previous new tab</a> if the new override is declined.</p>
  77. <p><img class="aligncenter size-full wp-image-8374" src="https://ffp4g1ylyit3jdyti1hqcvtb-wpengine.netdna-ssl.com/addons/files/2018/01/restore-settings-multiple.mov.gif" alt="Restore New Tab"/></p>
  78. <h2>Additional Browser Controls</h2>
  79. <p>To better support mouse gestures, browserSettings.contextMenuShowEvent() has been added in this version. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1419426">This new API</a> can be set to “mouseup” or “mousedown” by extensions to determine when context menus should be shown. Note that this is not supported on Android, and also calling it with a value of “mousedown” on Windows is a no-op.</p>
  80. <p>Also in Firefox 59, read-only browserSettings now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1408472">return false when calling set or clear</a> and also report an accurate levelofControl.</p>
  81. <h2>Context Menus for Bookmarks</h2>
  82. <p>Speaking of context menus, you can now set <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/menus/ContextType#Type">custom context menus for bookmarks</a>.  This will work on the bookmarks toolbar, the library menu, the bookmarks subview, and the bookmarks menu.</p>
  83. <h2>Development and Debugging</h2>
  84. <p>One of the best ways to suggest a new WebExtension API is to prototype it via an official experiment. Two major changes landed for WebExtension experiments that makes this significantly easier:</p>
  85. <p>Also in Firefox 59, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1429567">more detail has been added to sandbox names</a> to aid in debugging.</p>
  86. <h2>Miscellaneous Changes and Fixes</h2>
  87. <p>A number of smaller items were also landed in the new Firefox 59 Beta, including:</p>
  88. <h2>More to Come</h2>
  89. <p>Firefox 59 landed a total of <a href="https://mzl.la/2CJN9gE">69 items</a> for WebExtensions, the most important of which are discussed above. Thank you to everyone who had a part in getting it to Beta, especially volunteer contributors <a href="https://mozillians.org/u/andregarzia/">Andre Garzia</a>, <a href="https://mozillians.org/u/ntim/">Tim Nguyen</a>, <a href="https://mozillians.org/u/Oriol/">Oriol Brufau</a>, Javier Serrano Polo, Kevin Jones, <a href="https://mozillians.org/u/tushararora/">Tushar Arora</a>, <a href="https://mozillians.org/u/freaktechnik/">Martin Giger</a>, Peter Snyder, Lukas Jung. Additional changes and improvements to the WebExtensions API are already in progress for Firefox 60, so please continue to send us your feedback. And as always, thank you for using Firefox and helping ensure that individuals have the ability to shape the Internet and their own experiences on it.</p>