-
Notifications
You must be signed in to change notification settings - Fork 263
JEP Window
At the moment add-ons imply more nodejs like approach and API rather than standard HTML. While this has some advantages, it has many disadvantages:
- People need to learn new APIs.
- HTML APIs added to Firefox don't become available to add-on authors, without additional work on platform side.
- Lot's of HTML APIs are designed around DOM window, not having one makes those API pretty weird.
Goal of this task is to expose HTML APIs like WebSockets, localStorage, etc.. available for add-on authors.
This task also contributes to a bigger goal (although it's not deliverable of this specific task) of modeling add-on environment as a more familiar web interface:
- Add-on is just a hidden tab / iframe that have more capabilities.
- Add-on document may contain buttons, checkboxes, etc.. that are to some limited degree, recognized by platform such that they'll appear in the specific areas of browser UI. (Proof of concept https://github.com/ZER0/ui-html-addon)
- Since add-on is just a hidden iframe it can use standard [cross frame communication] (https://developer.mozilla.org/en-US/docs/DOM/window.postMessage) channels to interact with panel content etc..
As a result this task add-on authors should be able to use standard HTML APIs currently
available for web developers. Add-on code should be able to import "add-on DOM window"
by calling something like require("sdk/addon/window").window
and use the all the HTML APIs
available to web content:
let { window } = require("sdk/addon/window");
let exampleSocket = new window.WebSocket("ws://www.example.com/socketserver", ["protocolOne", "protocolTwo"]);
In a future we may consider we may expose add-on DOM window as global scope in all modules. In initial version though it will be exposed via module, that way we can provide capabilities first and take more to think of all the implications of exposing window as a global scope.
Document in the window will make use of Expanded Principals to enable communication with different domains, etc... How those expanded principals will be specified by add-on authors is scope of JEP Expanded Principals.
Depending on issues with implementation details we may run into, proposed API may get adjusted to expose individual features as separate modules:
let { WebSocket } = require("sdk/web-socket");