Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

JEP Window

Gozala edited this page Apr 17, 2013 · 2 revisions

Rationale

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.

Goals

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:

Deliverable

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");