brief introduction to the mozilla add-on sdk

Download Brief Introduction to the Mozilla Add-on SDK

If you can't read please download the document

Upload: martin-giger

Post on 16-Apr-2017

1.029 views

Category:

Technology


0 download

TRANSCRIPT

Mozilla Add-on SDK

AMOQuestions/Understanding (bad at explaining) ask them directly

I'm Martin aka freaktechnik

Information Technology and Electrical Engineering student

Euphonium player

Nightingale Media Player developer

Firefox Add-on developer

Goals

Basic Firefox Extension Knowledge

Tools for Development

Add-on SDK Extension Structure and API

Firefox Extensions

3 Different Types

Just ZIP filesAlso Themes (no scripts anymore), langpacks and searchengines (sometimes recognized as normal extension)

Traditional Overlay Add-ons

The old style

Restart to apply

Add content by overlaying documents

XPCOM

Components can be in nearly any language

Bootstrapped Extensions

Since Firefox 4

Restartless

Everything is done with XPCOM

Manually load components need to use JS to load binaries

Add-on SDK Extensions

Compile to bootstrapped extensions

CommonJS environement

XPCOM API wrappers to commonjs stable API (for example e10s doesn't affect you in most cases)SDK isn't bundled anymore with jpm...

Base Knowledge

JavaScript

Maybe HTML and CSS

XPCOM

-> CommonJS and chrome JS, also everything is mozJS, no DOM etc.

Tools

Firefox

CFX or JPM

An editor

JPM

The 'compiler' apart from others

Node based

npm install jpm --global

InitRunXpiTesthelp(testall, -b etc.)

Basic Extension Structure

jpm init

Basic Extension Structure

lib main modules

data misc files

test unit test modules

package.json add-on metadata

Modules

Where functionality is

Prebuilt SDK modules

3rd party libraries

Custom modules for Add-on logic

SDK Modules

Split into high-level and low-level API modules

High-level modules provide simple APIs for things likePage content modification (sdk/page-mod)

Tabs (sdk/tabs)

Requests (sdk/request)

Buttons and toolbars (sdk/ui)

Panels (sdk/panel)

Clipboard (sdk/clipboard)

Passwords (sdk/passwords)

Custom Modules

Main loading point module (usually main.js)

require() to import other modules

exports object for public symbols

Content Scripts

Scripts that run in a browser context

Still run in a separated sandbox

They have access to the document's DOM

port for communication

Debugging

Firefox 31

Always enabled via run command

Content-scripts can't be reached

Console output in console when run, else browser console (important, not web console)

XPCOM with Jetpack

const { Cu, Ci, Cr, Cc } = require('chrome')

Be nice to the global scope:
const { jsm } = require('resource://some.jsm');

You can define components

Quick, buuut, extreaction brackets

Future

JPM release

Integrated extension toolkit

Help!

MDN: https://developer.mozilla.org/en-US/Add-ons/SDK/

Sourcecode: https://github.com/mozilla/addon-sdk

IRC: irc://irc.mozilla.org/jetpack

Follow @MozillaCH on Twitter