Skip to content

ZER0/dialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dialog

A small module to open a window dialog with features in Add-on SDK. It's also possible attach content scripts to dialog with the document loaded.

usage

const dialog = require('./dialog');

dialog.open({
  // both `foo.html` and `index.js` are supposed to
  // be in add-on's `data` folder
  url: './foo.html',
  contentScriptFile: './index.js',
  features: {
    width: 320,
    height: 200
  }
}).then(worker => {
  // do something with worker, e.g.
  worker.port.on('title', console.log);
});

access to the window

open function returns a promise resolved once the document is ready, passing the worker attached, if any contentScript* was declared, or null.

It's possible modify the window object from the document's script itself, like any regular web page, or if a worker is returned, is possible access to worker.tab and worker.tab.window.

For example, this code will close the window opened, after two seconds.

const dialog = require('./dialog');
const { setTimeout } = require('sdk/timers');

dialog.open({
  url: './foo.html',
  contentScriptFile: './index.js',
  features: {
    width: 320,
    height: 200
  }
}).then(worker => {
  setTimeout(() => worker.tab.close(), 2000);
});

About

A small module to open a window dialog in Add-on SDK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published