firefox addon sdk - Mozilla JetPack Invalid Filename -
i'm trying create simple mozilla add-on using external js file;
folders & files
/var/www/html/add-ons/hello /var/www/html/add-ons/hello/index.js /var/www/html/add-ons/hello/package.json /var/www/html/add-ons/hello/script/data/test.js
/var/www/html/add-ons/hello/index.js
// import page-mod api var pagemod = require("sdk/page-mod"); // create page-mod pagemod.pagemod({ include : "*", contentscriptfile : "./test.js", contentscript: 'window.alert("loaded");' });
/var/www/html/add-ons/hello/package.json
{ "title": "my jetpack addon", "name": "test", "version": "0.0.1", "description": "a basic add-on", "main": "index.js", "author": "", "engines": { "firefox": ">=38.0a1", "fennec": ">=38.0a1" }, "license": "mit", "keywords": [ "jetpack" ] }
/var/www/html/add-ons/hello/script/data/test.js
alert("hello world");
commands run test
cd /var/www/html/add-ons/hello
jpm init
(actually package.json file created command)
jpm run -b /usr/bin/firefox
(i use ubuntu run way)
i test live , loaded
alert following error;
console.error: script: error opening input stream (invalid filename?): resource://script/data/test.js
the folders , file exist within root folder.
if root; /var/www/html/add-ons/hello
shouldn't resource://script/data/test.js
referring /var/www/html/add-ons/hello/script/data/test.js
?
where doing wrong?
create folder structure below: root folder: /var/www/html/add-ons/hello
place index.js, package.json within root folder. move data packaged within add-on to: /var/www/html/add-ons/hello/data
go root folder - /var/www/html/add-ons/hello run jpm run -b
this create xpi package, launch firefox.exe temporary profile, install add-on.
ex: win 7 x64 test project: root directory: e:\training\using_angular directory of e:\training\using_angular 11/01/2015 08:26 <dir> . 11/01/2015 08:26 <dir> .. 09/29/2015 05:04 pm <dir> data 09/29/2015 05:02 pm 548 index.js 08/12/2015 08:26 pm 221 package.json directory of e:\training\using_angular\data 09/29/2015 05:04 pm <dir> . 09/29/2015 05:04 pm <dir> .. 09/29/2015 05:04 pm <dir> images 08/12/2015 08:26 pm 446 lang.json 09/29/2015 05:04 pm <dir> lib 09/29/2015 05:04 pm <dir> scripts 09/29/2015 05:04 pm <dir> styles 09/29/2015 05:04 pm <dir> html directory of e:\training\using_angular\data\html 08/12/2015 08:26 pm 446 pagescript.html
during run, 'resource://' folder refers contents packaged in add-on.
for ex: resource://caaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/data/html/pagescript.html
Comments
Post a Comment