Skip to content

Instantly share code, notes, and snippets.

@Gozala
Forked from jeffgca/sdk_strawman.js
Created October 10, 2012 11:01
Show Gist options
  • Select an option

  • Save Gozala/3864791 to your computer and use it in GitHub Desktop.

Select an option

Save Gozala/3864791 to your computer and use it in GitHub Desktop.
content script apis ideas
// Content scripts will be able to require modules, only
// high level ones that are E10S friendly and can do
// everything via data that is serialize.
$(function() {
// what we have now
self.on('event-name', function(data) {
// ... something
});
self.port.emit('something');
// instead, (re)implementing APIs or providing new globals
// we just expose modules to a content scripts.
var notify = require('sdk/notifications')
addon.notify({
title: 'foo',
text: 'bar',
data: 'baz baz',
onClick: function() {
// called if notification is clicked
}
});
var Panel = require('sdk/panel').Panel;
var panel = Panel({
// ....
});
panel.show();
var request = require('sdk/request').request;
request({
url: 'http://something.ca',
// ...
onComplete: function(response) {
// response data is brought back serialized.
}
})
/*
* the 'require' case, perhaps we have an abstract 'bridge'
* protocol that a module can implement, which handles communication?
*/
self.require('notifications').notify({
title: 'foo',
text: 'bar',
data: 'baz baz',
onClick: function() {}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment