diff options
author | Nik Nyby <nnyby@columbia.edu> | 2015-10-24 11:50:56 -0400 |
---|---|---|
committer | Nik Nyby <nnyby@columbia.edu> | 2015-10-24 11:50:56 -0400 |
commit | af0fdf2afd5b42a041d97f33170d17d6f18253af (patch) | |
tree | b31f8c59c4ed9d05fa5eaa2f95a204a1f46787f6 | |
parent | da101e8eb9da3808b3bd75d571e40d5c2f139d9d (diff) | |
parent | 59597067c21e52ae94340801d4bf6e3a9825c7a3 (diff) | |
download | librejsxul-af0fdf2afd5b42a041d97f33170d17d6f18253af.tar.lz librejsxul-af0fdf2afd5b42a041d97f33170d17d6f18253af.tar.xz librejsxul-af0fdf2afd5b42a041d97f33170d17d6f18253af.zip |
Merge pull request #5 from nikolas/jpm
jpm
120 files changed, 405 insertions, 2141 deletions
diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a3c316f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "addon-sdk"] - path = addon-sdk - url = https://github.com/mozilla/addon-sdk.git diff --git a/.jpmignore b/.jpmignore new file mode 100644 index 0000000..dec47f7 --- /dev/null +++ b/.jpmignore @@ -0,0 +1,12 @@ +.* +* +!/data/** +!/lib/** +!/locale/** +!/node_modules/** +!/package.json +!/icon.png +!/icon64.png +!/COPYING +!/bootstrap.js +!/install.rdf diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000..ad8214e --- /dev/null +++ b/.jshintignore @@ -0,0 +1,3 @@ +data/settings/third-party/ +data/chrome_worker/parser/ +lib/url_handler/node_* diff --git a/.travis.yml b/.travis.yml index 62ba557..8c58f56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ -language: python -python: - - "2.7" +language: node_js +node_js: + - "4.1.2" addons: - firefox: "41.0.1" + firefox: "41.0.2" before_script: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" -script: ./test.sh +script: + - npm i jpm + - npm i + - jpm test @@ -1,3 +1,8 @@ +2015-10-23 Nik Nyby <nikolas@gnu.org> + * Converted LibreJS to use jpm instead of the old add-on + system: cfx. Thanks to Adrian Aichner for helping out + with this. + 2015-10-22 Nik Nyby <nikolas@gnu.org> * Add some notes on working with the LibreJS codebase to the manual. diff --git a/Makefile.in b/Makefile.in index 7b3c878..35e9692 100644 --- a/Makefile.in +++ b/Makefile.in @@ -21,7 +21,6 @@ SHELL := /bin/bash DESTDIR = -ADDON_SDK = /opt/addon-sdk srcdir = @srcdir@ VPATH = @srcdir@ prefix = @prefix@ @@ -51,7 +50,7 @@ enabled already, you may, inside your Mozilla-browser, need to go in \ the menu in Tools > Add-ons and click enable where you see LibreJS. \ " -CFX_ARGS = +JPM_ARGS = all: xpi @@ -103,10 +102,14 @@ dist: info: doc/librejs.info cd doc && gendocs.sh --email bug-librejs@gnu.org librejs "GNU LibreJS Manual" +jpm: + npm i jpm + xpi: librejs.xpi -librejs.xpi: - cd $(ADDON_SDK) && source bin/activate && cd - && cfx $(CFX_ARGS) xpi +librejs.xpi: jpm + npm i + jpm xpi .PHONY: all install install-pdf install-dvi install-html uninstall clean \ distclean info pdf dvi html xpi txt diff --git a/addon-sdk b/addon-sdk deleted file mode 160000 -Subproject 12f7d53e8b5fc015a15fa4a30fa588e81e9e9b2 diff --git a/configure.ac b/configure.ac index 54f8fcf..2952cd5 100644 --- a/configure.ac +++ b/configure.ac @@ -5,8 +5,7 @@ AC_PATH_PROG([MAKEINFO], makeinfo) AC_PATH_PROG([TEXI2ANY], texi2any) AC_PATH_PROG([TEXI2DVI], texi2dvi) AC_PATH_PROG([TEXI2PDF], texi2pdf) -AC_ARG_VAR([ADDON_SDK], [location of the Mozilla addon-sdk (default=/opt/addon-sdk)]) -AC_ARG_VAR([CFX_ARGS], [build arguments to pass to cfx]) +AC_ARG_VAR([JPM_ARGS], [build arguments to pass to jpm]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/doc/librejs.info b/doc/librejs.info index f3ee4f9..ae23807 100644 --- a/doc/librejs.info +++ b/doc/librejs.info @@ -90,8 +90,8 @@ or by building it from source. 3.1 Building the Package ======================== -After enabling the Add-on SDK, you should be able to use the 'make' -command to build LibreJS from source. +After installing 'jpm', you should be able to use the 'make' command to +build LibreJS from source. After running 'make', a new file, 'librejs.xpi' should be generated. This is the file that can be installed in a Mozilla browser. @@ -647,40 +647,26 @@ LibreJS has been tested extensively on multiple GNU/Linux distributions, but it is compatible any operating system as long as you're using a compatible Mozilla browser. -A.2 Mozilla's Add-on SDK -======================== - -LibreJS uses the Mozilla Add-on SDK (Software Development Kit), a set of -APIs and tools to create add-ons for Mozilla browsers. - - You do not need the Add-on SDK to use LibreJS xpi file or to install -it using the packaged version, but it is required in order to package -the LibreJS source code into an xpi file using 'make'. If you would -like to run the tests for LibreJS or make changes to the source files, -you will need the Add-on SDK as well. For the "make" command to work -properly, you must have the 'cfx' command available on your system from -the command line. - - The latest tarball for the Add-on SDK is available at: - - <https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz> - - Instructions on how to get it working are available here: +A.2 Mozilla's Jetpack Manager for Node.js +========================================= - <https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html> +LibreJS uses the Mozilla 'jpm' tool, a set of utilities for creating, +testing, running and packaging Mozilla Jetpack Addons. - In order to use 'make' with LibreJS source, however, it is ideal to -have 'cfx' available at all times and for all users. + You do not need 'jpm' to use the LibreJS xpi file or to install it +using the packaged version, but it is required in order to package the +LibreJS source code into an xpi file. If you would like to run the +tests for LibreJS or make changes to the source files, you will need +'jpm' as well. For the "make" command to work properly, you must have +the 'jpm' command available on your system from the command line. - An easy way to do this is to extract the contents of the tarball and -to place the files inside '/usr/lib/addon-sdk' and then creating a -symbolic link in '/usr/bin', as follows: + You can find information on getting 'jpm' at these links: - sudo ln -s /usr/lib/addon-sdk/bin/cfx /usr/bin/cfx + <https://www.npmjs.com/package/jpm> - The 'cfx' command will then be available to all users. + <https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29> - The Add-on SDK is released under the Mozilla Public License 2.0. + JPM is released under the Mozilla Public License 2.0. File: librejs.info, Node: LibreJS Internals, Next: Tests, Prev: Installation Requirements, Up: Top @@ -1285,14 +1271,14 @@ Node: Top841 Node: Overview2000 Node: Disclaimer2847 Node: Installation3343 -Node: How to Use4196 -Node: JavaScript Detection7438 -Node: Free Licenses Detection10846 -Node: Setting Your JavaScript Free17264 -Node: LibreJS Development Notes24098 -Node: Installation Requirements25470 -Node: LibreJS Internals27624 -Node: Tests28787 -Node: GNU Free Documentation License33294 +Node: How to Use4189 +Node: JavaScript Detection7431 +Node: Free Licenses Detection10839 +Node: Setting Your JavaScript Free17257 +Node: LibreJS Development Notes24091 +Node: Installation Requirements25463 +Node: LibreJS Internals27070 +Node: Tests28233 +Node: GNU Free Documentation License32740 End Tag Table diff --git a/doc/librejs.texi b/doc/librejs.texi index a19047e..98c2d62 100644 --- a/doc/librejs.texi +++ b/doc/librejs.texi @@ -106,7 +106,7 @@ file, or by building it from source. @section Building the Package -After enabling the Add-on SDK, you should be able to use the @code{make} +After installing @code{jpm}, you should be able to use the @code{make} command to build LibreJS from source. After running @code{make}, a new file, @file{librejs.xpi} should be @@ -784,40 +784,25 @@ LibreJS has been tested extensively on multiple GNU/Linux distributions, but it is compatible any operating system as long as you're using a compatible Mozilla browser. -@appendixsec Mozilla's Add-on SDK -LibreJS uses the Mozilla Add-on SDK (Software Development Kit), a -set of APIs and tools to create add-ons for Mozilla browsers. +@appendixsec Mozilla's Jetpack Manager for Node.js +LibreJS uses the Mozilla @code{jpm} tool, a set of utilities for +creating, testing, running and packaging Mozilla Jetpack Addons. -You do not need the Add-on SDK to use LibreJS xpi file or to install it +You do not need @code{jpm} to use the LibreJS xpi file or to install it using the packaged version, but it is required in order to package the -LibreJS source code into an xpi file using @code{make}. If you would like -to run the tests for LibreJS or make changes to the source files, you -will need the Add-on SDK as well. For the ``make'' command to work -properly, you must have the @code{cfx} command available on your system +LibreJS source code into an xpi file. If you would like to run the +tests for LibreJS or make changes to the source files, you +will need @code{jpm} as well. For the ``make'' command to work +properly, you must have the @code{jpm} command available on your system from the command line. -The latest tarball for the Add-on SDK is available at: +You can find information on getting @code{jpm} at these links: -@url{https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz} +@url{https://www.npmjs.com/package/jpm} -Instructions on how to get it working are available here: +@url{https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29} -@url{https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html} - -In order to use @code{make} with LibreJS source, however, it is ideal to -have @code{cfx} available at all times and for all users. - -An easy way to do this is to extract the contents of the tarball and to -place the files inside @file{/usr/lib/addon-sdk} and then creating a -symbolic link in @file{/usr/bin}, as follows: - -@example -sudo ln -s /usr/lib/addon-sdk/bin/cfx /usr/bin/cfx -@end example - -The @code{cfx} command will then be available to all users. - -The Add-on SDK is released under the Mozilla Public License 2.0. +JPM is released under the Mozilla Public License 2.0. @node LibreJS Internals @appendix LibreJS Internals diff --git a/doc/manual/html_node/Installation-Requirements.html b/doc/manual/html_node/Installation-Requirements.html index 720d26b..61db3c3 100644 --- a/doc/manual/html_node/Installation-Requirements.html +++ b/doc/manual/html_node/Installation-Requirements.html @@ -84,47 +84,27 @@ LibreJS has been tested extensively on multiple GNU/Linux distributions, but it is compatible any operating system as long as you’re using a compatible Mozilla browser. </p> -<a name="Mozilla_0027s-Add_002don-SDK"></a> -<h3 class="appendixsec">A.2 Mozilla’s Add-on SDK</h3> -<p>LibreJS uses the Mozilla Add-on SDK (Software Development Kit), a -set of APIs and tools to create add-ons for Mozilla browsers. +<a name="Mozilla_0027s-Jetpack-Manager-for-Node_002ejs"></a> +<h3 class="appendixsec">A.2 Mozilla’s Jetpack Manager for Node.js</h3> +<p>LibreJS uses the Mozilla <code>jpm</code> tool, a set of utilities for +creating, testing, running and packaging Mozilla Jetpack Addons. </p> -<p>You do not need the Add-on SDK to use LibreJS xpi file or to install it +<p>You do not need <code>jpm</code> to use the LibreJS xpi file or to install it using the packaged version, but it is required in order to package the -LibreJS source code into an xpi file using <code>make</code>. If you would like -to run the tests for LibreJS or make changes to the source files, you -will need the Add-on SDK as well. For the “make” command to work -properly, you must have the <code>cfx</code> command available on your system +LibreJS source code into an xpi file. If you would like to run the +tests for LibreJS or make changes to the source files, you +will need <code>jpm</code> as well. For the “make” command to work +properly, you must have the <code>jpm</code> command available on your system from the command line. </p> -<p>The latest tarball for the Add-on SDK is available at: +<p>You can find information on getting <code>jpm</code> at these links: </p> -<p><a href="https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz">https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz</a> +<p><a href="https://www.npmjs.com/package/jpm">https://www.npmjs.com/package/jpm</a> </p> -<p>Instructions on how to get it working are available here: +<p><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29">https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29</a> </p> -<p><a href="https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html">https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html</a> +<p>JPM is released under the Mozilla Public License 2.0. </p> -<p>In order to use <code>make</code> with LibreJS source, however, it is ideal to -have <code>cfx</code> available at all times and for all users. -</p> -<p>An easy way to do this is to extract the contents of the tarball and to -place the files inside <samp>/usr/lib/addon-sdk</samp> and then creating a -symbolic link in <samp>/usr/bin</samp>, as follows: -</p> -<div class="example"> -<pre class="example">sudo ln -s /usr/lib/addon-sdk/bin/cfx /usr/bin/cfx -</pre></div> - -<p>The <code>cfx</code> command will then be available to all users. -</p> -<p>The Add-on SDK is released under the Mozilla Public License 2.0. -</p> -<hr> -<div class="header"> -<p> -Next: <a href="LibreJS-Internals.html#LibreJS-Internals" accesskey="n" rel="next">LibreJS Internals</a>, Previous: <a href="LibreJS-Development-Notes.html#LibreJS-Development-Notes" accesskey="p" rel="prev">LibreJS Development Notes</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> -</div> diff --git a/doc/manual/html_node/Installation.html b/doc/manual/html_node/Installation.html index cc65d82..de5dac5 100644 --- a/doc/manual/html_node/Installation.html +++ b/doc/manual/html_node/Installation.html @@ -76,7 +76,7 @@ file, or by building it from source. <a name="Building-the-Package"></a> <h3 class="section">3.1 Building the Package</h3> -<p>After enabling the Add-on SDK, you should be able to use the <code>make</code> +<p>After installing <code>jpm</code>, you should be able to use the <code>make</code> command to build LibreJS from source. </p> <p>After running <code>make</code>, a new file, <samp>librejs.xpi</samp> should be diff --git a/doc/manual/html_node/index.html b/doc/manual/html_node/index.html index b7e668d..41b9b4b 100644 --- a/doc/manual/html_node/index.html +++ b/doc/manual/html_node/index.html @@ -109,7 +109,7 @@ ul.no-bullet {list-style: none} <li><a name="toc-Installation-Requirements-1" href="Installation-Requirements.html#Installation-Requirements">Appendix A Installation Requirements</a> <ul class="no-bullet"> <li><a name="toc-Mozilla-Browser" href="Installation-Requirements.html#Mozilla-Browser">A.1 Mozilla Browser</a></li> - <li><a name="toc-Mozilla_0027s-Add_002don-SDK" href="Installation-Requirements.html#Mozilla_0027s-Add_002don-SDK">A.2 Mozilla’s Add-on SDK</a></li> + <li><a name="toc-Mozilla_0027s-Jetpack-Manager-for-Node_002ejs" href="Installation-Requirements.html#Mozilla_0027s-Jetpack-Manager-for-Node_002ejs">A.2 Mozilla’s Jetpack Manager for Node.js</a></li> </ul></li> <li><a name="toc-LibreJS-Internals-1" href="LibreJS-Internals.html#LibreJS-Internals">Appendix B LibreJS Internals</a></li> <li><a name="toc-Tests-1" href="Tests.html#Tests">Appendix C Tests</a></li> diff --git a/doc/manual/index.html b/doc/manual/index.html index 5f3b6f6..2e989e9 100644 --- a/doc/manual/index.html +++ b/doc/manual/index.html @@ -5,7 +5,7 @@ <h2>GNU LibreJS Manual</h2> <address>Free Software Foundation</address> -<address>last updated October 22, 2015</address> +<address>last updated October 23, 2015</address> <p>This manual (librejs) is available in the following formats:</p> diff --git a/doc/manual/librejs.dvi.gz b/doc/manual/librejs.dvi.gz Binary files differindex 74a1b40..cf1dba2 100644 --- a/doc/manual/librejs.dvi.gz +++ b/doc/manual/librejs.dvi.gz diff --git a/doc/manual/librejs.html b/doc/manual/librejs.html index 8569cd8..14c0847 100644 --- a/doc/manual/librejs.html +++ b/doc/manual/librejs.html @@ -108,7 +108,7 @@ ul.no-bullet {list-style: none} <li><a name="toc-Installation-Requirements-1" href="#Installation-Requirements">Appendix A Installation Requirements</a> <ul class="no-bullet"> <li><a name="toc-Mozilla-Browser" href="#Mozilla-Browser">A.1 Mozilla Browser</a></li> - <li><a name="toc-Mozilla_0027s-Add_002don-SDK" href="#Mozilla_0027s-Add_002don-SDK">A.2 Mozilla’s Add-on SDK</a></li> + <li><a name="toc-Mozilla_0027s-Jetpack-Manager-for-Node_002ejs" href="#Mozilla_0027s-Jetpack-Manager-for-Node_002ejs">A.2 Mozilla’s Jetpack Manager for Node.js</a></li> </ul></li> <li><a name="toc-LibreJS-Internals-1" href="#LibreJS-Internals">Appendix B LibreJS Internals</a></li> <li><a name="toc-Tests-1" href="#Tests">Appendix C Tests</a></li> @@ -219,7 +219,7 @@ file, or by building it from source. <a name="Building-the-Package"></a> <h3 class="section">3.1 Building the Package</h3> -<p>After enabling the Add-on SDK, you should be able to use the <code>make</code> +<p>After installing <code>jpm</code>, you should be able to use the <code>make</code> command to build LibreJS from source. </p> <p>After running <code>make</code>, a new file, <samp>librejs.xpi</samp> should be @@ -848,41 +848,26 @@ LibreJS has been tested extensively on multiple GNU/Linux distributions, but it is compatible any operating system as long as you’re using a compatible Mozilla browser. </p> -<a name="Mozilla_0027s-Add_002don-SDK"></a> -<h3 class="appendixsec">A.2 Mozilla’s Add-on SDK</h3> -<p>LibreJS uses the Mozilla Add-on SDK (Software Development Kit), a -set of APIs and tools to create add-ons for Mozilla browsers. +<a name="Mozilla_0027s-Jetpack-Manager-for-Node_002ejs"></a> +<h3 class="appendixsec">A.2 Mozilla’s Jetpack Manager for Node.js</h3> +<p>LibreJS uses the Mozilla <code>jpm</code> tool, a set of utilities for +creating, testing, running and packaging Mozilla Jetpack Addons. </p> -<p>You do not need the Add-on SDK to use LibreJS xpi file or to install it +<p>You do not need <code>jpm</code> to use the LibreJS xpi file or to install it using the packaged version, but it is required in order to package the -LibreJS source code into an xpi file using <code>make</code>. If you would like -to run the tests for LibreJS or make changes to the source files, you -will need the Add-on SDK as well. For the “make” command to work -properly, you must have the <code>cfx</code> command available on your system +LibreJS source code into an xpi file. If you would like to run the +tests for LibreJS or make changes to the source files, you +will need <code>jpm</code> as well. For the “make” command to work +properly, you must have the <code>jpm</code> command available on your system from the command line. </p> -<p>The latest tarball for the Add-on SDK is available at: +<p>You can find information on getting <code>jpm</code> at these links: </p> -<p><a href="https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz">https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz</a> +<p><a href="https://www.npmjs.com/package/jpm">https://www.npmjs.com/package/jpm</a> </p> -<p>Instructions on how to get it working are available here: +<p><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29">https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29</a> </p> -<p><a href="https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html">https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html</a> -</p> -<p>In order to use <code>make</code> with LibreJS source, however, it is ideal to -have <code>cfx</code> available at all times and for all users. -</p> -<p>An easy way to do this is to extract the contents of the tarball and to -place the files inside <samp>/usr/lib/addon-sdk</samp> and then creating a -symbolic link in <samp>/usr/bin</samp>, as follows: -</p> -<div class="example"> -<pre class="example">sudo ln -s /usr/lib/addon-sdk/bin/cfx /usr/bin/cfx -</pre></div> - -<p>The <code>cfx</code> command will then be available to all users. -</p> -<p>The Add-on SDK is released under the Mozilla Public License 2.0. +<p>JPM is released under the Mozilla Public License 2.0. </p> <hr> <a name="LibreJS-Internals"></a> diff --git a/doc/manual/librejs.html.gz b/doc/manual/librejs.html.gz Binary files differindex f1c2743..6a7177f 100644 --- a/doc/manual/librejs.html.gz +++ b/doc/manual/librejs.html.gz diff --git a/doc/manual/librejs.html_node.tar.gz b/doc/manual/librejs.html_node.tar.gz Binary files differindex d5a9c88..d2eea99 100644 --- a/doc/manual/librejs.html_node.tar.gz +++ b/doc/manual/librejs.html_node.tar.gz diff --git a/doc/manual/librejs.info.tar.gz b/doc/manual/librejs.info.tar.gz Binary files differindex 72a1a41..cc42d53 100644 --- a/doc/manual/librejs.info.tar.gz +++ b/doc/manual/librejs.info.tar.gz diff --git a/doc/manual/librejs.pdf b/doc/manual/librejs.pdf Binary files differindex c464ae2..250acb7 100644 --- a/doc/manual/librejs.pdf +++ b/doc/manual/librejs.pdf diff --git a/doc/manual/librejs.texi.tar.gz b/doc/manual/librejs.texi.tar.gz Binary files differindex 640a41d..a091cc4 100644 --- a/doc/manual/librejs.texi.tar.gz +++ b/doc/manual/librejs.texi.tar.gz diff --git a/doc/manual/librejs.txt b/doc/manual/librejs.txt index 5ae723b..dcbe22a 100644 --- a/doc/manual/librejs.txt +++ b/doc/manual/librejs.txt @@ -24,7 +24,7 @@ LibreJS 8.4 Releasing a new version Appendix A Installation Requirements A.1 Mozilla Browser - A.2 Mozilla's Add-on SDK + A.2 Mozilla's Jetpack Manager for Node.js Appendix B LibreJS Internals Appendix C Tests Appendix D GNU Free Documentation License @@ -72,8 +72,8 @@ or by building it from source. 3.1 Building the Package ======================== -After enabling the Add-on SDK, you should be able to use the 'make' -command to build LibreJS from source. +After installing 'jpm', you should be able to use the 'make' command to +build LibreJS from source. After running 'make', a new file, 'librejs.xpi' should be generated. This is the file that can be installed in a Mozilla browser. @@ -611,40 +611,26 @@ LibreJS has been tested extensively on multiple GNU/Linux distributions, but it is compatible any operating system as long as you're using a compatible Mozilla browser. -A.2 Mozilla's Add-on SDK -======================== - -LibreJS uses the Mozilla Add-on SDK (Software Development Kit), a set of -APIs and tools to create add-ons for Mozilla browsers. - - You do not need the Add-on SDK to use LibreJS xpi file or to install -it using the packaged version, but it is required in order to package -the LibreJS source code into an xpi file using 'make'. If you would -like to run the tests for LibreJS or make changes to the source files, -you will need the Add-on SDK as well. For the "make" command to work -properly, you must have the 'cfx' command available on your system from -the command line. - - The latest tarball for the Add-on SDK is available at: - - <https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz> - - Instructions on how to get it working are available here: +A.2 Mozilla's Jetpack Manager for Node.js +========================================= - <https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/installation.html> +LibreJS uses the Mozilla 'jpm' tool, a set of utilities for creating, +testing, running and packaging Mozilla Jetpack Addons. - In order to use 'make' with LibreJS source, however, it is ideal to -have 'cfx' available at all times and for all users. + You do not need 'jpm' to use the LibreJS xpi file or to install it +using the packaged version, but it is required in order to package the +LibreJS source code into an xpi file. If you would like to run the +tests for LibreJS or make changes to the source files, you will need +'jpm' as well. For the "make" command to work properly, you must have +the 'jpm' command available on your system from the command line. - An easy way to do this is to extract the contents of the tarball and -to place the files inside '/usr/lib/addon-sdk' and then creating a -symbolic link in '/usr/bin', as follows: + You can find information on getting 'jpm' at these links: - sudo ln -s /usr/lib/addon-sdk/bin/cfx /usr/bin/cfx + <https://www.npmjs.com/package/jpm> - The 'cfx' command will then be available to all users. + <https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29> - The Add-on SDK is released under the Mozilla Public License 2.0. + JPM is released under the Mozilla Public License 2.0. Appendix B LibreJS Internals **************************** diff --git a/doc/manual/librejs.txt.gz b/doc/manual/librejs.txt.gz Binary files differindex 4c3514b..8141d68 100644 --- a/doc/manual/librejs.txt.gz +++ b/doc/manual/librejs.txt.gz diff --git a/lib/addon_management/install_uninstall.js b/lib/addon_management/install_uninstall.js index c5c150f..084b448 100644 --- a/lib/addon_management/install_uninstall.js +++ b/lib/addon_management/install_uninstall.js @@ -27,10 +27,10 @@ const {Cc, Ci, Cu, Cm, Cr} = require("chrome"); -const httpObserver = require("http_observer/http_request_observer"); -var narcissusWorker = require("parser/narcissus_worker") +const httpObserver = require("../http_observer/http_request_observer"); +var narcissusWorker = require("../parser/narcissus_worker") .narcissusWorker; -const caching = require("http_observer/caching"); +const caching = require("../http_observer/caching"); const prompt = Cc["@mozilla.org/embedcomp/prompt-service;1"]. getService(Ci.nsIPromptService); @@ -46,7 +46,7 @@ exports.onUnload = function(reason) { reason == "shutdown" || reason == "upgrade" || reason == "downgrade") { - require("settings/storage").librejsStorage.writeCacheToDB(); + require("../settings/storage").librejsStorage.writeCacheToDB(); // remove all http notifications httpObserver.removeHttpObserver(); // remove worker. diff --git a/lib/addon_management/prefchange.js b/lib/addon_management/prefchange.js index 910a103..48a8765 100644 --- a/lib/addon_management/prefchange.js +++ b/lib/addon_management/prefchange.js @@ -27,7 +27,7 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); var prompt = Cc['@mozilla.org/embedcomp/prompt-service;1']. getService(Ci.nsIPromptService); -var scriptsCached = require("script_entries/scripts_cache").scriptsCached; +var scriptsCached = require("../script_entries/scripts_cache").scriptsCached; var setWhitelist = function () { whitelist = []; diff --git a/lib/html_script_finder/dom_handler.js b/lib/html_script_finder/dom_handler.js index c57c945..e16f673 100644 --- a/lib/html_script_finder/dom_handler.js +++ b/lib/html_script_finder/dom_handler.js @@ -32,33 +32,32 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); -var scriptProperties = - require("html_script_finder/dom_handler/script_properties"); +var scriptProperties = require("./dom_handler/script_properties"); const scriptTypes = scriptProperties.scriptTypes; const statusTypes = scriptProperties.statusTypes; const reasons = scriptProperties.reasons; -var urlHandler = require("url_handler/url_handler"); +var urlHandler = require("../url_handler/url_handler"); -var WebLabelFinder = - require("html_script_finder/web_labels/js_web_labels").WebLabelFinder; +var WebLabelFinder = require("./web_labels/js_web_labels").WebLabelFinder; // object model for script entries. -var scriptObject = require("html_script_finder/dom_handler/script_object"); +var scriptObject = require("./dom_handler/script_object"); -var privacyChecker = require("js_checker/privacy_checker").privacyCheck; -var jsChecker = require("js_checker/js_checker"); -const types = require("js_checker/constant_types"); +var privacyChecker = require("../js_checker/privacy_checker").privacyCheck; +var jsChecker = require("../js_checker/js_checker"); +const types = require("../js_checker/constant_types"); var checkTypes = types.checkTypes; var stripCDATAOpen = /<\!\[CDATA\[/gi; var stripCDATAClose = /]]>/g; -var isDryRun = require("addon_management/prefchange").isDryRun; -var allowedRef = require('http_observer/allowed_referrers').allowedReferrers; -var attributeHelpers = require("html_script_finder/dom_handler/attributes"); +var isDryRun = require("../addon_management/prefchange").isDryRun; +var allowedRef = require('../http_observer/allowed_referrers') + .allowedReferrers; +var attributeHelpers = require("./dom_handler/attributes"); // javascript:* var jsInAttrRe = attributeHelpers.jsInAttrRe; @@ -66,10 +65,8 @@ var jsInAttrRe = attributeHelpers.jsInAttrRe; // the list of all available event attributes var intrinsicEvents = attributeHelpers.intrinsicEvents; -var domGatherer = - require("html_script_finder/dom_handler/dom_gatherer").domGatherer; -var domChecker = - require("html_script_finder/dom_handler/dom_checker").domChecker; +var domGatherer = require("./dom_handler/dom_gatherer").domGatherer; +var domChecker = require("./dom_handler/dom_checker").domChecker; /** * The DomHandler object takes a whole document, diff --git a/lib/html_script_finder/dom_handler/attributes.js b/lib/html_script_finder/dom_handler/attributes.js index 796e718..ac603fe 100644 --- a/lib/html_script_finder/dom_handler/attributes.js +++ b/lib/html_script_finder/dom_handler/attributes.js @@ -21,9 +21,8 @@ */ // object model for script entries. -var scriptObject = require("html_script_finder/dom_handler/script_object"); - -var scriptProperties = require("html_script_finder/dom_handler/script_properties"); +var scriptObject = require("./script_object"); +var scriptProperties = require("./script_properties"); const scriptTypes = scriptProperties.scriptTypes; diff --git a/lib/html_script_finder/dom_handler/dom_checker.js b/lib/html_script_finder/dom_handler/dom_checker.js index 6a98d61..b4d27b2 100644 --- a/lib/html_script_finder/dom_handler/dom_checker.js +++ b/lib/html_script_finder/dom_handler/dom_checker.js @@ -30,25 +30,26 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); var timer = require("sdk/timers"); -var scriptProperties = require("html_script_finder/dom_handler/script_properties"); +var scriptProperties = require("./script_properties"); const scriptTypes = scriptProperties.scriptTypes; const statusTypes = scriptProperties.statusTypes; const reasons = scriptProperties.reasons; // ensure xhr won't create an infinite loop // with html content. -var urlTester = require("html_script_finder/url_seen_tester").urlSeenTester; -var urlHandler = require("url_handler/url_handler"); +var urlTester = require("../url_seen_tester").urlSeenTester; +var urlHandler = require("../../url_handler/url_handler"); -var privacyChecker = require("js_checker/privacy_checker").privacyCheck; -var jsChecker = require("js_checker/js_checker"); +var privacyChecker = require("../../js_checker/privacy_checker").privacyCheck; +var jsChecker = require("../../js_checker/js_checker"); -const types = require("js_checker/constant_types"); +const types = require("../../js_checker/constant_types"); var checkTypes = types.checkTypes; var stripCDATAOpen = /<\!\[CDATA\[/gi; var stripCDATAClose = /]]>/g; -const getHash = require("script_entries/scripts_cache").scriptsCached.getHash; +const getHash = require("../../script_entries/scripts_cache") + .scriptsCached.getHash; var DomChecker = function() { // reference to domHandler instance @@ -452,8 +453,7 @@ DomChecker.prototype.xhr = function(script, responseCallback) { urlTester.addUrl(url); // request module. Compatible with Https-Everywhere. - require('html_script_finder/dom_handler/request') - .request(script, responseCallback).request(); + require('./request').request(script, responseCallback).request(); } catch (x) { console.debug('error', x, x.lineNumber, x.fileName); responseCallback(script, false); diff --git a/lib/html_script_finder/dom_handler/dom_gatherer.js b/lib/html_script_finder/dom_handler/dom_gatherer.js index 7bb2569..ce29cf6 100644 --- a/lib/html_script_finder/dom_handler/dom_gatherer.js +++ b/lib/html_script_finder/dom_handler/dom_gatherer.js @@ -20,18 +20,19 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var scriptProperties = require("html_script_finder/dom_handler/script_properties"); +var scriptProperties = require("./script_properties"); const scriptTypes = scriptProperties.scriptTypes; -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; +const scriptsCached = require("../../script_entries/scripts_cache") + .scriptsCached; const statusTypes = scriptProperties.statusTypes; // object model for script entries. -var scriptObject = require("html_script_finder/dom_handler/script_object"); +var scriptObject = require("./script_object"); -var urlHandler = require("url_handler/url_handler"); +var urlHandler = require("../../url_handler/url_handler"); -var attributeHelpers = require("html_script_finder/dom_handler/attributes"); +var attributeHelpers = require("./attributes"); // javascript:* var jsInAttrRe = attributeHelpers.jsInAttrRe; @@ -39,9 +40,9 @@ var jsInAttrRe = attributeHelpers.jsInAttrRe; // the list of all available event attributes var intrinsicEvents = attributeHelpers.intrinsicEvents; -var privacyChecker = require("js_checker/privacy_checker").privacyCheck; +var privacyChecker = require("../../js_checker/privacy_checker").privacyCheck; -const types = require("js_checker/constant_types"); +const types = require("../../js_checker/constant_types"); var checkTypes = types.checkTypes; @@ -246,8 +247,10 @@ DomGatherer.prototype.gatherScriptsContent = function() { // using else if since script text is // ignored if src attribute is set. // adding this.narcissusBugFixLibreJS to fix comment bug. - var bugfix = require('html_script_finder/bug_fix').narcissusBugFixLibreJS; - currentScript = stripHtmlCommentsInScript(this.d.domScripts[i].text + bugfix); + var bugfix = require('../../html_script_finder/bug_fix') + .narcissusBugFixLibreJS; + currentScript = stripHtmlCommentsInScript( + this.d.domScripts[i].text + bugfix); scriptEntry = scriptObject.Script( {'type': scriptTypes.INLINE, diff --git a/lib/html_script_finder/dom_handler/request.js b/lib/html_script_finder/dom_handler/request.js index a008295..f25ba8f 100644 --- a/lib/html_script_finder/dom_handler/request.js +++ b/lib/html_script_finder/dom_handler/request.js @@ -28,9 +28,10 @@ var {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm"); // ensure xhr won't create an infinite loop // with html content. -var urlTester = require("html_script_finder/url_seen_tester").urlSeenTester; -var urlHandler = require("url_handler/url_handler"); -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; +var urlTester = require("../url_seen_tester").urlSeenTester; +var urlHandler = require("../../url_handler/url_handler"); +const scriptsCached = require("../../script_entries/scripts_cache") + .scriptsCached; var Request = function() { this.url = null; diff --git a/lib/html_script_finder/dom_handler/script_object.js b/lib/html_script_finder/dom_handler/script_object.js index 83ae073..64468b4 100644 --- a/lib/html_script_finder/dom_handler/script_object.js +++ b/lib/html_script_finder/dom_handler/script_object.js @@ -20,11 +20,13 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var removedScripts = require("script_entries/removed_scripts").removedScripts; +var removedScripts = require("../../script_entries/removed_scripts") + .removedScripts; -var acceptedScripts = require("script_entries/accepted_scripts") +var acceptedScripts = require("../../script_entries/accepted_scripts") .acceptedScripts; -var dryRunScripts = require("script_entries/dryrun_scripts").dryRunScripts; +var dryRunScripts = require("../../script_entries/dryrun_scripts") + .dryRunScripts; var Script = function(props) { // can be an attribute, an inline script, diff --git a/lib/html_script_finder/html_parser.js b/lib/html_script_finder/html_parser.js index a2bae80..ab36eaf 100644 --- a/lib/html_script_finder/html_parser.js +++ b/lib/html_script_finder/html_parser.js @@ -80,7 +80,7 @@ var {Cc, Ci, Cu} = require("chrome"); -var domHandlerModule = require("html_script_finder/dom_handler"); +var domHandlerModule = require("./dom_handler"); const PR_UINT32_MAX = 2147483647; diff --git a/lib/html_script_finder/web_labels/js_web_labels.js b/lib/html_script_finder/web_labels/js_web_labels.js index 510852b..0cb64bf 100644 --- a/lib/html_script_finder/web_labels/js_web_labels.js +++ b/lib/html_script_finder/web_labels/js_web_labels.js @@ -22,19 +22,18 @@ // node.js url module. Makes it easier to resolve // urls in that datauri loaded dom -var urlHandler = require("url_handler/url_handler"); +var urlHandler = require("../../url_handler/url_handler"); var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); var data = require("sdk/self").data; // license definitions, we are using canonical urls and license // identifiers. -var licenses = require('js_checker/license_definitions').licenses; +var licenses = require('../../js_checker/license_definitions').licenses; -var getLicenseList = require('html_script_finder/web_labels/find_js_labels') - .getLicenseList; -const types = require("js_checker/constant_types"); +var getLicenseList = require('./find_js_labels').getLicenseList; +const types = require("../../js_checker/constant_types"); -const addToCache = require("html_script_finder/web_labels/script_hash_worker") +const addToCache = require("./script_hash_worker") .addToCache; // keep web labels in memory so that they can be checked even when they @@ -175,7 +174,7 @@ WebLabelFinder.prototype.isLicenseFree = function( var found = false; // Check if we can look up this license by its identifier. - var identifier = lic.licenses[i]['licenseName']; + var identifier = lic.licenses[i].licenseName; if (typeof identifier !== 'undefined' && typeof licenses[identifier] !== 'undefined' ) { diff --git a/lib/html_script_finder/web_labels/script_hash_worker.js b/lib/html_script_finder/web_labels/script_hash_worker.js index 92ffb82..4ed9d21 100644 --- a/lib/html_script_finder/web_labels/script_hash_worker.js +++ b/lib/html_script_finder/web_labels/script_hash_worker.js @@ -20,9 +20,10 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const types = require("js_checker/constant_types"); -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; -const xhr = require('html_script_finder/dom_handler/dom_checker').xhr; +const types = require("../../js_checker/constant_types"); +const scriptsCached = require("../../script_entries/scripts_cache") + .scriptsCached; +const xhr = require('../dom_handler/dom_checker').xhr; const timers = require("sdk/timers"); exports.addToCache = function (lic, delay, jsWebLabelsURL, callback) { diff --git a/lib/http_observer/allowed_referrers.js b/lib/http_observer/allowed_referrers.js index 39374c9..06d860b 100644 --- a/lib/http_observer/allowed_referrers.js +++ b/lib/http_observer/allowed_referrers.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var prefChange = require("addon_management/prefchange"); +var prefChange = require("../addon_management/prefchange"); var allowed = {}; diff --git a/lib/http_observer/http_request_observer.js b/lib/http_observer/http_request_observer.js index e8c9635..0b6e14d 100644 --- a/lib/http_observer/http_request_observer.js +++ b/lib/http_observer/http_request_observer.js @@ -31,8 +31,9 @@ var targetMimeTypes = /.*(javascript|ecmascript|html).*/i; // ensure xhr won't create an infinite loop // with html content. -var urlTester = require("html_script_finder/url_seen_tester").urlSeenTester; -var streamLoader = require("http_observer/stream_loader").streamLoader; +var urlTester = require("../html_script_finder/url_seen_tester") + .urlSeenTester; +var streamLoader = require("../http_observer/stream_loader").streamLoader; var httpRequestObserver = { observe: function(request, aTopic, aData) { diff --git a/lib/http_observer/process_response.js b/lib/http_observer/process_response.js index 924636b..72f236c 100644 --- a/lib/http_observer/process_response.js +++ b/lib/http_observer/process_response.js @@ -27,28 +27,32 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); -var jsChecker = require("js_checker/js_checker"); +var jsChecker = require("../js_checker/js_checker"); -const types = require("js_checker/constant_types"); +const types = require("../js_checker/constant_types"); var checkTypes = types.checkTypes; // check if scripts embedded dynamically have a jsWebLabel entry indexed by referrer. -var jsWebLabelEntries = require("html_script_finder/web_labels/js_web_labels").jsWebLabelEntries; +var jsWebLabelEntries = require("../html_script_finder/web_labels/js_web_labels") + .jsWebLabelEntries; -var htmlParser = require("html_script_finder/html_parser"); +var htmlParser = require("../html_script_finder/html_parser"); -var removedScripts = require("script_entries/removed_scripts").removedScripts; -var allowedRef = require('http_observer/allowed_referrers').allowedReferrers; +var removedScripts = require("../script_entries/removed_scripts") + .removedScripts; +var allowedRef = require('../http_observer/allowed_referrers') + .allowedReferrers; -var acceptedScripts = require("script_entries/accepted_scripts").acceptedScripts; +var acceptedScripts = require("../script_entries/accepted_scripts") + .acceptedScripts; // used to display info when a url is whitelisted. -var dryRunScripts = require("script_entries/dryrun_scripts").dryRunScripts; +var dryRunScripts = require("../script_entries/dryrun_scripts").dryRunScripts; // node.js url module. Makes it easier to resolve // urls in that datauri loaded dom -var urlHandler = require("url_handler/url_handler"); -var isDryRun = require("addon_management/prefchange").isDryRun; +var urlHandler = require("../url_handler/url_handler"); +var isDryRun = require("../addon_management/prefchange").isDryRun; var jsMimeTypeRe = /.*(javascript|ecmascript).*/i; var htmlMimeTypeRe = /.*(xhtml\+xml|html|multipart\/x-mixed-replace).*/i; diff --git a/lib/http_observer/stream_loader.js b/lib/http_observer/stream_loader.js index ec21cb7..c790fe2 100644 --- a/lib/http_observer/stream_loader.js +++ b/lib/http_observer/stream_loader.js @@ -21,7 +21,7 @@ */ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); -const processResponse = require('http_observer/process_response'); +const processResponse = require('./process_response'); const CHARSETS = [ '866', 'ansi_x3.4-1968', 'arabic', 'ascii', 'asmo-708', 'big5', 'big5-hkscs', 'chinese', 'cn-big5', 'cp1250', 'cp1251', 'cp1252', diff --git a/lib/js_checker/free_checker.js b/lib/js_checker/free_checker.js index 71a262e..be190e2 100644 --- a/lib/js_checker/free_checker.js +++ b/lib/js_checker/free_checker.js @@ -20,16 +20,16 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var licenses = require('js_checker/license_definitions'); +var licenses = require('./license_definitions'); var simpleStorage = require("sdk/simple-storage"); const LAZY = licenses.types.LAZY; var licenseRegex = []; -const END_OF_SCRIPT = require('html_script_finder/bug_fix').END_OF_SCRIPT; -const types = require("js_checker/constant_types"); +const END_OF_SCRIPT = require('../html_script_finder/bug_fix').END_OF_SCRIPT; +const types = require("./constant_types"); const token = types.token; -var patternUtils = require('js_checker/pattern_utils').patternUtils; +var patternUtils = require('./pattern_utils').patternUtils; var licStartLicEndRe = /@licstartThefollowingistheentirelicensenoticefortheJavaScriptcodeinthis(?:page|file)(.*)?@licendTheaboveistheentirelicensenoticefortheJavaScriptcodeinthis(?:page|file)/mi; var licenseMagnet = /.*@license ?(magnet\:\?xt=urn\:btih\:[0-9A-Za-z]+).*/; diff --git a/lib/js_checker/js_checker.js b/lib/js_checker/js_checker.js index 21bfeaf..ecf0826 100644 --- a/lib/js_checker/js_checker.js +++ b/lib/js_checker/js_checker.js @@ -23,16 +23,17 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); -var narcissusWorker = require("parser/narcissus_worker") +var narcissusWorker = require("../parser/narcissus_worker") .narcissusWorker; -const nonTrivialModule = require("js_checker/nontrivial_checker"); -const freeChecker = require("js_checker/free_checker"); -const relationChecker = require("js_checker/relation_checker"); -const types = require("js_checker/constant_types"); +const nonTrivialModule = require("./nontrivial_checker"); +const freeChecker = require("./free_checker"); +const relationChecker = require("./relation_checker"); +const types = require("./constant_types"); -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; -var isDryRun = require("addon_management/prefchange").isDryRun; +const scriptsCached = require("../script_entries/scripts_cache") + .scriptsCached; +var isDryRun = require("../addon_management/prefchange").isDryRun; var checkTypes = types.checkTypes; @@ -165,13 +166,14 @@ JsChecker.prototype.isFreeLicensed = function(script) { */ JsChecker.prototype.searchJs = function(jsCode, resultReady, url) { var that = this; - var bugfix = require('html_script_finder/bug_fix').narcissusBugFixLibreJS; + var bugfix = require('../html_script_finder/bug_fix') + .narcissusBugFixLibreJS; console.debug('JsChecker.searchJs for script url:', url); this.url = url; this.resultReady = resultReady; this.jsCode = jsCode; this.shortText = jsCode.replace(bugfix, '').substring(0,100); - this.notification = require("ui/notification") + this.notification = require("../ui/notification") .createNotification(this.shortText).notification; var verbatimCode = this.jsCode.replace(bugfix, ''); diff --git a/lib/js_checker/nontrivial_checker.js b/lib/js_checker/nontrivial_checker.js index 6a22992..1c79a2a 100644 --- a/lib/js_checker/nontrivial_checker.js +++ b/lib/js_checker/nontrivial_checker.js @@ -19,7 +19,7 @@ * You should have received a copy of the GNU General Public License * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const types = require("js_checker/constant_types"); +const types = require("./constant_types"); // constants from Narcissus for function types. const DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2; diff --git a/lib/js_checker/privacy_checker.js b/lib/js_checker/privacy_checker.js index f39e0b7..fe0fa8a 100644 --- a/lib/js_checker/privacy_checker.js +++ b/lib/js_checker/privacy_checker.js @@ -20,8 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const privacyThreatJs = require('js_checker/privacy_threat_definitions.js'); -const patternUtils = require('js_checker/pattern_utils').patternUtils; +const privacyThreatJs = require('./privacy_threat_definitions.js'); +const patternUtils = require('./pattern_utils').patternUtils; exports.privacyCheck = { checkScriptPrivacyThreat: function (currentScript) { diff --git a/lib/js_checker/relation_checker.js b/lib/js_checker/relation_checker.js index c504444..21580a9 100644 --- a/lib/js_checker/relation_checker.js +++ b/lib/js_checker/relation_checker.js @@ -25,7 +25,7 @@ * Finds out if two scripts are related to each other. * */ -const types = require("js_checker/constant_types"); +const types = require("./constant_types"); const token = types.token; diff --git a/lib/js_load_observer/js_load_observer.js b/lib/js_load_observer/js_load_observer.js index 7b73ec6..525f58f 100644 --- a/lib/js_load_observer/js_load_observer.js +++ b/lib/js_load_observer/js_load_observer.js @@ -25,10 +25,12 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); var observerService = Cc["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService); -var acceptedScripts = require("script_entries/accepted_scripts").acceptedScripts; -var allowedRef = require('http_observer/allowed_referrers').allowedReferrers; +var acceptedScripts = require("../script_entries/accepted_scripts") + .acceptedScripts; +var allowedRef = require('../http_observer/allowed_referrers') + .allowedReferrers; -var urlHandler = require("url_handler/url_handler"); +var urlHandler = require("../url_handler/url_handler"); var ScriptAnalyzer = function() { // the URL of the current page. @@ -51,7 +53,7 @@ ScriptAnalyzer.prototype.analyzeScriptBeforeExec = function (e) { var script = e.target, isAccepted; var text = script.src ? script.src : script.textContent.substring(0,100); - var notif = require("ui/notification") + var notif = require("../ui/notification") .createNotification(text).notification; this.pageURL = urlHandler.removeFragment(script.ownerDocument.URL); if (!allowedRef.urlInAllowedReferrers(this.pageURL)) { diff --git a/lib/main.js b/lib/main.js index ac280a4..b704aad 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,15 +26,15 @@ const { Cc, Ci } = require("chrome"); -const librejsStorage = require("settings/storage").librejsStorage; -let addonManage = require("addon_management/install_uninstall"); -let httpObserver = require("http_observer/http_request_observer"); -let prefObserver = require("pref_observer/pref_observer"); -let prefChange = require("addon_management/prefchange"); -let uiInfo = require("ui/ui_info"); -let scriptPanel = require("ui/script_panel.js"); +const librejsStorage = require("./settings/storage").librejsStorage; +let addonManage = require("./addon_management/install_uninstall"); +let httpObserver = require("./http_observer/http_request_observer"); +let prefObserver = require("./pref_observer/pref_observer"); +let prefChange = require("./addon_management/prefchange"); +let uiInfo = require("./ui/ui_info"); +let scriptPanel = require("./ui/script_panel.js"); -require('ui'); +require('./ui'); // set whitelist at startup. prefChange.init(); diff --git a/lib/parser/narcissus_worker.js b/lib/parser/narcissus_worker.js index a25e279..e9829b4 100644 --- a/lib/parser/narcissus_worker.js +++ b/lib/parser/narcissus_worker.js @@ -31,7 +31,7 @@ var NarcissusWorker = function() { var that = this; this.worker.onmessage = function(e) { - var jsChecker = require("js_checker/js_checker"); + var jsChecker = require("../js_checker/js_checker"); console.debug('onmessage', e.data.hash); try { diff --git a/lib/pref_observer/pref_observer.js b/lib/pref_observer/pref_observer.js index d066c2f..2c5e360 100644 --- a/lib/pref_observer/pref_observer.js +++ b/lib/pref_observer/pref_observer.js @@ -20,7 +20,7 @@ */ var {Cc, Ci} = require("chrome"); -const httpObserver = require("http_observer/http_request_observer"); +const httpObserver = require("../http_observer/http_request_observer"); // https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Preferences#Using_preference_observers var prefObserver = { diff --git a/lib/script_entries/accepted_scripts.js b/lib/script_entries/accepted_scripts.js index c732f31..bac11f0 100644 --- a/lib/script_entries/accepted_scripts.js +++ b/lib/script_entries/accepted_scripts.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var allScripts = require('script_entries/all_scripts').allScripts; +var allScripts = require('./all_scripts').allScripts; var AcceptedScripts = function() { this.scripts = {}; diff --git a/lib/script_entries/all_scripts.js b/lib/script_entries/all_scripts.js index 2028864..c27a410 100644 --- a/lib/script_entries/all_scripts.js +++ b/lib/script_entries/all_scripts.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var crypto = require('script_entries/crypto'); +var crypto = require('./crypto'); var AllScripts = function() { this.scripts = {}; diff --git a/lib/script_entries/dryrun_scripts.js b/lib/script_entries/dryrun_scripts.js index 87ec482..a15b0b2 100644 --- a/lib/script_entries/dryrun_scripts.js +++ b/lib/script_entries/dryrun_scripts.js @@ -20,8 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var allScripts = require('script_entries/all_scripts').allScripts; -const urlHandler = require('url_handler/url_handler'); +var allScripts = require('./all_scripts').allScripts; +const urlHandler = require('../url_handler/url_handler'); exports.dryRunScripts = { scripts: {}, diff --git a/lib/script_entries/free_libraries.js b/lib/script_entries/free_libraries.js index 8821d04..291b982 100644 --- a/lib/script_entries/free_libraries.js +++ b/lib/script_entries/free_libraries.js @@ -22,13 +22,15 @@ // THIS MODULE IS DEPRECATED IN FAVOR OF THE NEW WHITELISTING MODULE (LibreJS 6.0) -var relationChecker = require("js_checker/relation_checker").relationChecker; -var checkTypes = require("js_checker/constant_types").checkTypes; -var scriptsCached = require("script_entries/scripts_cache").scriptsCached; +var relationChecker = require("../js_checker/relation_checker") + .relationChecker; +var checkTypes = require("../js_checker/constant_types").checkTypes; +var scriptsCached = require("./scripts_cache").scriptsCached; // find the json database path. -var dbContents = require("sdk/self").data.load("script_libraries/script-libraries.json"); +var dbContents = require("sdk/self").data.load( + "script_libraries/script-libraries.json"); const AUTHOR_REASON = "This script has been tagged as free software by LibreJS authors."; diff --git a/lib/script_entries/removed_scripts.js b/lib/script_entries/removed_scripts.js index b7544e9..2a3b1d3 100644 --- a/lib/script_entries/removed_scripts.js +++ b/lib/script_entries/removed_scripts.js @@ -20,8 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var allScripts = require('script_entries/all_scripts').allScripts; -const urlHandler = require('url_handler/url_handler'); +var allScripts = require('./all_scripts').allScripts; +const urlHandler = require('../url_handler/url_handler'); var RemovedScripts = function() { this.scripts = {}; diff --git a/lib/script_entries/scripts_cache.js b/lib/script_entries/scripts_cache.js index 47ab069..52ae33f 100644 --- a/lib/script_entries/scripts_cache.js +++ b/lib/script_entries/scripts_cache.js @@ -19,14 +19,14 @@ * You should have received a copy of the GNU General Public License * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var relationCheckerObj = require("js_checker/relation_checker") +var relationCheckerObj = require("../js_checker/relation_checker") .relationChecker; // import free_libraries to populate the cache hash map. -var free_libraries = require("script_entries/free_libraries"); +var free_libraries = require("../script_entries/free_libraries"); -var crypto = require('script_entries/crypto'); -const checkTypes = require("js_checker/constant_types").checkTypes; +var crypto = require('./crypto'); +const checkTypes = require("../js_checker/constant_types").checkTypes; // cachedResults contains objects with result/relationChecker for // scripts entries indexed by SHA1sum @@ -40,7 +40,8 @@ var ScriptsCached = function() { }; ScriptsCached.prototype.getHash = function(scriptText) { - require('ui/notification').createNotification(scriptText.substring(0,100)); + require('../ui/notification').createNotification( + scriptText.substring(0,100)); return crypto.sha1Encrypt(scriptText); }; diff --git a/lib/settings/settings_tab.js b/lib/settings/settings_tab.js index 976714a..6e28ef6 100644 --- a/lib/settings/settings_tab.js +++ b/lib/settings/settings_tab.js @@ -21,10 +21,9 @@ */ const tabs = require("sdk/tabs"); const data = require("sdk/self").data; -const storage = require("settings/storage").librejsStorage; -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; - -exports.settingsManager = settingsManager; +const storage = require("./storage").librejsStorage; +const scriptsCached = require("../script_entries/scripts_cache") + .scriptsCached; let settingsManager = { settingsTab: { diff --git a/lib/settings/storage.js b/lib/settings/storage.js index bc9fe77..abd42e6 100644 --- a/lib/settings/storage.js +++ b/lib/settings/storage.js @@ -23,14 +23,18 @@ const { Cc, Ci, Cu, components } = require("chrome"); -var { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm"); -var { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm"); -var relationChecker = require("js_checker/relation_checker").relationChecker; +const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm"); +const { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm"); +var relationChecker = require("../js_checker/relation_checker") + .relationChecker; var rc = relationChecker(); // a dummy object for legacy module. -const AUTHOR_REASON = require("script_entries/free_libraries").AUTHOR_REASON; -var relationChecker = require("js_checker/relation_checker").relationChecker; +const AUTHOR_REASON = require("../script_entries/free_libraries") + .AUTHOR_REASON; +var relationChecker = require("../js_checker/relation_checker") + .relationChecker; -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; +const scriptsCached = require("../script_entries/scripts_cache") + .scriptsCached; let librejsStorage = { @@ -59,7 +63,7 @@ let librejsStorage = { NetUtil.asyncFetch(channel, function(inputStream, status) { if (!components.isSuccessCode(status)) { - require("script_entries/free_libraries").init(); + require("../script_entries/free_libraries").init(); that.initialWrite(); } @@ -88,7 +92,7 @@ let librejsStorage = { console.debug("About to write free libraries"); // our file is not populated with default contents. // use free_libraries.js to populate. - require("script_entries/free_libraries").init(); + require("../script_entries/free_libraries").init(); this.writeCacheToDB(callback); }, @@ -25,20 +25,22 @@ let tabs = require("sdk/tabs"); let {getMostRecentBrowserWindow} = require('sdk/window/utils'); let {ToggleButton} = require('sdk/ui/button/toggle'); -let settings_tab = require('settings/settings_tab'); -let allowedRef = require("http_observer/allowed_referrers").allowedReferrers; -let urlHandler = require("url_handler/url_handler"); -let removedScripts = require("script_entries/removed_scripts").removedScripts; -let acceptedScripts = require("script_entries/accepted_scripts") +let settings_tab = require('./settings/settings_tab'); +let allowedRef = require("./http_observer/allowed_referrers") + .allowedReferrers; +let urlHandler = require("./url_handler/url_handler"); +let removedScripts = require("./script_entries/removed_scripts") + .removedScripts; +let acceptedScripts = require("./script_entries/accepted_scripts") .acceptedScripts; -let jsLabelsPagesVisited = require('html_script_finder/web_labels/js_web_labels') +let jsLabelsPagesVisited = require('./html_script_finder/web_labels/js_web_labels') .jsLabelsPagesVisited; -let dryRunScripts = require("script_entries/dryrun_scripts").dryRunScripts; -let types = require("js_checker/constant_types"); -const removeHashCallback = require("js_checker/js_checker").removeHashCallback; +let dryRunScripts = require("./script_entries/dryrun_scripts").dryRunScripts; +let types = require("./js_checker/constant_types"); +const removeHashCallback = require("./js_checker/js_checker").removeHashCallback; // move to sub-module later -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; +const scriptsCached = require("./script_entries/scripts_cache").scriptsCached; function generateDataURI (encodedText) { return "data:text/html;charset=UTF-8;base64," + encodedText; @@ -135,7 +137,7 @@ let UI = exports.UI = { } }); - var menuitem = require("menuitems").Menuitem({ + var menuitem = require("menuitem").Menuitem({ id: 'librejs_settings', menuid: 'menu_ToolsPopup', label: 'LibreJS Whitelist', diff --git a/lib/ui/notification.js b/lib/ui/notification.js index da4b7d5..c49b083 100644 --- a/lib/ui/notification.js +++ b/lib/ui/notification.js @@ -24,7 +24,7 @@ // is running to inform the user it is indeed busy working. const timer = require("sdk/timers"); const self = require("sdk/self"); -const isDisplayNotifications = require("addon_management/prefchange") +const isDisplayNotifications = require("../addon_management/prefchange") .isDisplayNotifications; exports.createCriticalNotification = function (text) { diff --git a/lib/ui/script_panel.js b/lib/ui/script_panel.js index 35b601c..12c25ae 100644 --- a/lib/ui/script_panel.js +++ b/lib/ui/script_panel.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var urlHandler = require("url_handler/url_handler"); +var urlHandler = require("../url_handler/url_handler"); /** * addScriptsToPanelList diff --git a/lib/ui/ui_info.js b/lib/ui/ui_info.js index 6df8a09..8b5ad81 100644 --- a/lib/ui/ui_info.js +++ b/lib/ui/ui_info.js @@ -24,10 +24,10 @@ var data = require("sdk/self").data; var pageMod = require("sdk/page-mod"); -var urlHandler = require("url_handler/url_handler"); +var urlHandler = require("../url_handler/url_handler"); var pageWorker = require("sdk/page-worker"); var tabs = require("sdk/tabs"); -var prefs = require("addon_management/prefchange"); +var prefs = require("../addon_management/prefchange"); // contain list of recently found contact links or email addresses. var contactList = {}; @@ -162,7 +162,7 @@ var tabProcess = function (worker) { var searchSecondLevelPage = function( worker, urlToSearch, originalUrl) { - return; +/* var originalWorker = worker; console.debug('searchSecondLevelPage'); @@ -195,6 +195,7 @@ var searchSecondLevelPage = function( } }); } +*/ }; exports.testModule = { diff --git a/lib/url_handler/node_url.js b/lib/url_handler/node_url.js index 71d31a6..47779f1 100644 --- a/lib/url_handler/node_url.js +++ b/lib/url_handler/node_url.js @@ -19,7 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var punycode = require('url_handler/node_punycode'); +var punycode = require('./node_punycode'); exports.parse = urlParse; exports.resolve = urlResolve; @@ -92,7 +92,7 @@ var protocolPattern = /^([a-z0-9.+-]+:)/i, 'gopher:': true, 'file:': true }, - querystring = require('url_handler/node_querystring'); + querystring = require('./node_querystring'); function urlParse(url, parseQueryString, slashesDenoteHost) { if (url && typeof(url) === 'object' && url instanceof Url) return url; diff --git a/lib/url_handler/url_handler.js b/lib/url_handler/url_handler.js index 5117190..234dff5 100644 --- a/lib/url_handler/url_handler.js +++ b/lib/url_handler/url_handler.js @@ -29,7 +29,7 @@ // node.js url module. Makes it easier to resolve // urls in that datauri loaded dom -var nodeJsUrl = require("url_handler/node_url"); +var nodeJsUrl = require("./node_url"); var urlUtils = { getFragment: function (url) { diff --git a/package.json b/package.json index b3313cb..d8379cb 100644 --- a/package.json +++ b/package.json @@ -1,68 +1,66 @@ { - "name": "librejs", - "license": "GPL-3.0+", - "author": "Loic J. Duros", - "homepage": "gnu.org/software/librejs/", - "version": "6.0.10.20151023", - "title": "GNU LibreJS", - "id": "jid1-KtlZuoiikVfFew@jetpack", - "description": "GNU LibreJS is an add-on for Mozilla-based browsers (IceCat, Firefox, Abrowser, Iceweasel)\n that prevents the execution of nonfree nontrivial JavaScript as described in \"The Javascript Trap\": http://www.gnu.org/philosophy/javascript-trap.html", - "main": "lib/main", - "icon": "data/widget/images/librejs-32.png", - "icon64": "data/widget/images/librejs-64.png", - "dependencies": [ - "notification-box", - "addon-sdk", - "menuitems", - "vold-utils" - ], - "permissions": { - "private-browsing": true, - "unsafe-content-script": true + "name": "librejs", + "license": "GPL-3.0+", + "author": "Loic J. Duros", + "homepage": "https://gnu.org/software/librejs/", + "repository": "http://git.savannah.gnu.org/cgit/librejs.git/", + "version": "6.0.10rc20151023", + "title": "GNU LibreJS", + "id": "jid1-KtlZuoiikVfFew@jetpack", + "description": "GNU LibreJS is an add-on for Mozilla-based browsers (IceCat, Firefox, Abrowser, Iceweasel)\n that prevents the execution of nonfree nontrivial JavaScript as described in \"The Javascript Trap\": http://www.gnu.org/philosophy/javascript-trap.html", + "main": "lib/main.js", + "icon": "data/widget/images/librejs-64.png", + "dependencies": { + "menuitem": "0.0.5", + "notification-box": "0.1.1" + }, + "permissions": { + "private-browsing": true, + "unsafe-content-script": true + }, + "preferences": [ + { + "name": "whitelist", + "title": "Whitelist domain, separated by comma, omit protocol, e.g.: gnu.org, wildcard is *", + "type": "string", + "value": "" }, - "preferences": [ - { - "name": "whitelist", - "title": "Whitelist domain, separated by comma, omit protocol, e.g.: gnu.org, wildcard is *", - "type": "string", - "value": "" - }, - { - "name": "complaint_tab", - "title": "Display complaint tab on sites where nonfree nontrivial JavaScript is detected", - "type": "bool", - "value": true - }, - { - "name": "display_notifications", - "title": "Display notifications of the JavaScript code being analyzed by LibreJS.", - "type": "bool", - "value": false - }, - { - "name": "complaint_email_subject", - "title": "Complaint email subject", - "description": "Initial subject line used in complaint emails", - "type": "string", - "value": "Please make your JavaScript free" - }, - { - "name": "complaint_email_body", - "title": "Complaint email body", - "description": "Initial body text used in complaint emails", - "type": "string", - "value": "I could not use your site because it requires running JavaScript code which is not free software. Since a nonfree program disrespects the user's freedom, I decided not to run it. \\n\\nSee http://gnu.org/philosophy/javascript-trap.html for more information, and please make your JavaScript code free." - } - ], - "scripts": { - "pretest": "jshint ./lib/ ./data/ --exclude ./data/settings/third-party/", - "test": "cfx test -v" + { + "name": "complaint_tab", + "title": "Display complaint tab on sites where nonfree nontrivial JavaScript is detected", + "type": "bool", + "value": true }, - "jscsConfig": { - "preset": "google", - "validateIndentation": 4 + { + "name": "display_notifications", + "title": "Display notifications of the JavaScript code being analyzed by LibreJS.", + "type": "bool", + "value": false }, - "jshintConfig": { - "moz": true + { + "name": "complaint_email_subject", + "title": "Complaint email subject", + "description": "Initial subject line used in complaint emails", + "type": "string", + "value": "Please make your JavaScript free" + }, + { + "name": "complaint_email_body", + "title": "Complaint email body", + "description": "Initial body text used in complaint emails", + "type": "string", + "value": "I could not use your site because it requires running JavaScript code which is not free software. Since a nonfree program disrespects the user's freedom, I decided not to run it. \\n\\nSee http://gnu.org/philosophy/javascript-trap.html for more information, and please make your JavaScript code free." } + ], + "scripts": { + "pretest": "jshint lib data", + "test": "jpm test -v" + }, + "jscsConfig": { + "preset": "google", + "validateIndentation": 4 + }, + "jshintConfig": { + "moz": true + } } diff --git a/packages/menuitems/README.md b/packages/menuitems/README.md deleted file mode 100644 index 12a6954..0000000 --- a/packages/menuitems/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Menuitems Package for Jetpack Add-ons - - diff --git a/packages/menuitems/docs/menuitems.md b/packages/menuitems/docs/menuitems.md deleted file mode 100644 index 2017c9c..0000000 --- a/packages/menuitems/docs/menuitems.md +++ /dev/null @@ -1,66 +0,0 @@ -<!-- contributed by Erik Vold [erikvvold@gmail.com] --> - - -The `menuitems` API is a simple way to create -[Menuitems](https://developer.mozilla.org/en/XUL/PopupGuide/MenuItems), which -can perform an action when clicked, and display state. - -## Example ## - - exports.main = function(options) { - // create menuitem for the File menu, - // and insert it before the 'Quit' menuitem - require("menuitems").Menuitem({ - id: "myextprefix-some-mi-id", - menuid: "menu_FilePopup", - insertbefore: "menu_FileQuitItem", - "label": _("label"), - "accesskey": _("label.ak"), - image: self.data.url("icon.png"), - className: 'pizazz', - disabled: false, - checked: false, - onCommand: function() { - // do something - } - }); - }; - -<api name="Menuitem"> -@class - -Module exports `Menuitem` constructor allowing users to create a -[`menuitem`](https://developer.mozilla.org/en/XUL/menuitem). - -<api name="Menuitem"> -@constructor -Creates a `menuitem`. - -@param options {Object} - Options for the `menuitem`, with the following parameters: - -@prop id {String} -A id for the `menuitem`, this should be namespaced. - -@prop menuid {String} -The id of the parent `<menu>` node. - -@prop label {String} -A label for the `menuitem`. - -@prop image {String} -A image url for the `menuitem`. - -@prop className {String} -A default space delimited list of class names for the menuitem. - -@prop disabled {Boolean} -When a menuitem is disabled it cannot be used, but is still displayed. - -@prop checked {Boolean} -Displays a check beside the menuitem. - -@prop [onCommand] {Function} - A option function that is invoked when the `menuitem` is executed. -</api> -</api> diff --git a/packages/menuitems/lib/menuitems.js b/packages/menuitems/lib/menuitems.js deleted file mode 100644 index 075d690..0000000 --- a/packages/menuitems/lib/menuitems.js +++ /dev/null @@ -1,195 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -const windowUtils = require("sdk/deprecated/window-utils"); -const { Class } = require("sdk/core/heritage"); -const { validateOptions } = require("sdk/deprecated/api-utils"); -const { on, emit, once, off } = require("sdk/event/core"); -const { isBrowser } = require("sdk/window/utils"); -const { EventTarget } = require('sdk/event/target'); -const { unload } = require("unload+"); - -const menuitemNS = require("sdk/core/namespace").ns(); -const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - -function MenuitemOptions(options) { - return validateOptions(options, { - id: { is: ['string'] }, - menuid: { is: ['undefined', 'string'] }, - insertbefore: { is: ['undefined', 'string', 'object'] }, - label: { is: ["string"] }, - disabled: { is: ["undefined", "boolean"], map: function(v) !!v}, - accesskey: { is: ["undefined", "string"] }, - key: { is: ["undefined", "string"] }, - checked: { is: ['undefined', 'boolean'] }, - className: { is: ["undefined", "string"] }, - onCommand: { is: ['undefined', 'function'] } - }); -} - -let Menuitem = Class({ - extends: EventTarget, - initialize: function(options) { - options = menuitemNS(this).options = MenuitemOptions(options); - EventTarget.prototype.initialize.call(this, options); - - menuitemNS(this).destroyed = false; - menuitemNS(this).unloaders = []; - menuitemNS(this).menuitems = addMenuitems(this, options).menuitems; - }, - get id() menuitemNS(this).options.id, - get label() menuitemNS(this).options.label, - set label(val) updateProperty(this, 'label', val), - get checked() menuitemNS(this).options.checked, - set checked(val) updateProperty(this, 'checked', !!val), - get disabled() menuitemNS(this).options.disabled, - set disabled(val) updateProperty(this, 'disabled', !!val), - get key() menuitemNS(this).options.key, - set key(val) updateProperty(this, 'key', val), - clone: function (overwrites) { - let opts = Object.clone(menuitemNS(this).options); - for (let key in overwrites) { - opts[key] = ovrewrites[key]; - } - return Menuitem(opts); - }, - get menuid() menuitemNS(this).options.menuid, - set menuid(val) { - let options = menuitemNS(this).options; - options.menuid = val; - - forEachMI(function(menuitem, i, $) { - updateMenuitemParent(menuitem, options, $); - }); - }, - destroy: function() { - if (!menuitemNS(this).destroyed) { - menuitemNS(this).destroyed = true; - menuitemNS(this).unloaders.forEach(function(u) u()); - menuitemNS(this).unloaders = null; - menuitemNS(this).menuitems = null; - } - return true; - } -}); - -function addMenuitems(self, options) { - let menuitems = []; - - // setup window tracker - windowUtils.WindowTracker({ - onTrack: function (window) { - if (!isBrowser(window) || menuitemNS(self).destroyed) return; - - // add the new menuitem to a menu - var menuitem = updateMenuitemAttributes( - window.document.createElementNS(NS_XUL, "menuitem"), options); - var menuitems_i = menuitems.push(menuitem) - 1; - - // add the menutiem to the ui - updateMenuitemParent(menuitem, options, function(id) window.document.getElementById(id)); - - menuitem.addEventListener("command", function() { - if (!self.disabled) - emit(self, 'command'); - }, true); - - // add unloader - let unloader = function unloader() { - menuitem.parentNode && menuitem.parentNode.removeChild(menuitem); - menuitems[menuitems_i] = null; - }; - menuitemNS(self).unloaders.push(function() { - remover(); - unloader(); - }); - let remover = unload(unloader, window); - } - }); - return {menuitems: menuitems}; -} - -function updateMenuitemParent(menuitem, options, $) { - // add the menutiem to the ui - if (Array.isArray(options.menuid)) { - let ids = options.menuid; - for (var len = ids.length, i = 0; i < len; i++) { - if (tryParent($(ids[i]), menuitem, options.insertbefore)) - return true; - } - } - else { - return tryParent($(options.menuid), menuitem, options.insertbefore); - } - return false; -} - -function updateMenuitemAttributes(menuitem, options) { - menuitem.setAttribute("id", options.id); - menuitem.setAttribute("label", options.label); - - if (options.accesskey) - menuitem.setAttribute("accesskey", options.accesskey); - - if (options.key) - menuitem.setAttribute("key", options.key); - - menuitem.setAttribute("disabled", !!options.disabled); - - if (options.image) { - menuitem.classList.add("menuitem-iconic"); - menuitem.style.listStyleImage = "url('" + options.image + "')"; - } - - if (options.checked) - menuitem.setAttribute('checked', options.checked); - - if (options.className) - options.className.split(/\s+/).forEach(function(name) menuitem.classList.add(name)); - - return menuitem; -} - -function updateProperty(menuitem, key, val) { - menuitemNS(menuitem).options[key] = val; - - forEachMI(function(menuitem) { - menuitem.setAttribute(key, val); - }, menuitem); - return val; -} - -function forEachMI(callback, menuitem) { - menuitemNS(menuitem).menuitems.forEach(function(mi, i) { - if (!mi) return; - callback(mi, i, function(id) mi.ownerDocument.getElementById(id)); - }); -} - -function tryParent(parent, menuitem, before) { - if (parent) parent.insertBefore(menuitem, insertBefore(parent, before)); - return !!parent; -} - -function insertBefore(parent, insertBefore) { - if (typeof insertBefore == "number") { - switch (insertBefore) { - case MenuitemExport.FIRST_CHILD: - return parent.firstChild; - } - return null; - } - else if (typeof insertBefore == "string") { - return parent.querySelector("#" + insertBefore); - } - return insertBefore; -} - -function MenuitemExport(options) { - return Menuitem(options); -} -MenuitemExport.FIRST_CHILD = 1; - -exports.Menuitem = MenuitemExport; diff --git a/packages/menuitems/package.json b/packages/menuitems/package.json deleted file mode 100644 index 95b1ede..0000000 --- a/packages/menuitems/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "menuitems", - "description": "Menuitems for Jetpacks", - "keywords": ["menu", "menuitems", "button", "ui"], - "author": "Erik Vold (http://erikvold.com/) <erikvvold@gmail.com>", - "version": "1.1.1", - "license": "MPL 2.0", - "dependencies": ["api-utils", "vold-utils"] -} diff --git a/packages/menuitems/tests/test-menuitems.js b/packages/menuitems/tests/test-menuitems.js deleted file mode 100644 index 191bb44..0000000 --- a/packages/menuitems/tests/test-menuitems.js +++ /dev/null @@ -1,171 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -'use strict' - -const windowUtils = require("window-utils"); -const menuitems = require("menuitems"); - -let window = windowUtils.activeBrowserWindow; -let document = window.document; -function $(id) document.getElementById(id); - -function createMI(options, test) { - test.assertEqual(!$(options.id), true); - var mi = new menuitems.Menuitem(options); - return mi; -} - -exports.testMIDoesNotExist = function(test) { - var options = { - id: "test-mi-dne", - label: "test" - }; - createMI(options, test); - test.assertEqual(!!$(options.id), false, 'menuitem does not exists'); -}; - -exports.testMIDoesExist = function(test) { - var options = { - id: "test-mi-exists", - label: "test", - menuid: 'menu_FilePopup' - }; - let mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - test.assertEqual(menuitem.id, options.id, 'menuitem id is ok'); - test.assertEqual(menuitem.getAttribute('label'), options.label, 'menuitem label is ok'); - test.assertEqual(menuitem.parentNode.id, options.menuid, 'in the file menu'); - test.assertEqual(menuitem.getAttribute('disabled'), 'false', 'menuitem not disabled'); - test.assertEqual(menuitem.getAttribute('accesskey'), '', 'menuitem accesskey is ok'); - test.assertEqual(menuitem.getAttribute('class'), '', 'menuitem class is ok'); - test.assertEqual(menuitem.nextSibling, undefined, 'menuitem is last'); - test.assertEqual(menuitem.hasAttribute("checked"), false, 'menuitem not checked'); - mi.destroy(); - test.assert(!$(options.id), 'menuitem is gone'); - test.assertEqual(menuitem.parentNode, null, 'menuitem has no parent'); -}; - -exports.testMIOnClick = function(test) { - test.waitUntilDone(); - - let options = { - id: "test-mi-onclick", - label: "test", - menuid: 'menu_FilePopup', - onCommand: function() { - mi.destroy(); - test.pass('onCommand worked!'); - test.done(); - } - }; - - let e = document.createEvent("UIEvents"); - e.initUIEvent("command", true, true, window, 1); - - var mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - menuitem.dispatchEvent(e); -}; - -exports.testMIDisabled = function(test) { - test.waitUntilDone(); - - let commandIsOK = false; - let count = 0; - let options = { - id: "test-mi-disabled", - label: "test", - disabled: true, - menuid: 'menu_FilePopup', - onCommand: function() { - count++; - if (!commandIsOK) { - test.fail('onCommand was called, that is not ok'); - return; - } - - mi.destroy(); - test.assertEqual(count, 1, 'onCommand was called the correct number of times!'); - test.done(); - } - }; - - let e = document.createEvent("UIEvents"); - e.initUIEvent("command", true, true, window, 1); - - var mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - test.assertEqual(menuitem.getAttribute('disabled'), 'true', 'menuitem not disabled'); - menuitem.dispatchEvent(e); - mi.disabled = false; - test.assertEqual(menuitem.getAttribute('disabled'), 'false', 'menuitem not disabled'); - commandIsOK = true; - menuitem.dispatchEvent(e); -}; - -exports.testMIChecked = function(test) { - let options = { - id: "test-mi-checked", - label: "test", - disabled: true, - menuid: 'menu_FilePopup', - checked: true - }; - - let mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - test.assertEqual(menuitem.getAttribute("checked"), "true", 'menuitem checked'); - mi.checked = false; - test.assertEqual(menuitem.getAttribute("checked"), "false", 'menuitem checked'); - mi.destroy(); -}; - -exports.testMIClass = function(test) { - let options = { - id: "test-mi-class", - label: "pizazz", - className: "pizazz", - menuid: 'menu_FilePopup', - }; - - var mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - test.assertEqual(menuitem.getAttribute('class'), 'pizazz', 'menuitem not disabled'); - mi.destroy(); -}; - -exports.testInsertBeforeExists = function(test) { - let options = { - id: 'test-mi-insertbefore', - label: 'insertbefore', - insertbefore:'menu_FileQuitItem', - menuid: 'menu_FilePopup', - }; - - var mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - test.assertEqual(menuitem.nextSibling, $('menu_FileQuitItem'), 'menuitem not disabled'); - mi.destroy(); -}; - -exports.testInsertBeforeDoesNotExist = function(test) { - let options = { - id: 'test-mi-insertbefore', - label: 'insertbefore', - insertbefore:'menu_ZZZDNE', - menuid: 'menu_FilePopup', - }; - - var mi = createMI(options, test); - let menuitem = $(options.id); - test.assertEqual(!!menuitem, true, 'menuitem exists'); - test.assertEqual(menuitem.nextSibling, null, 'menuitem not disabled'); - mi.destroy(); -}; diff --git a/packages/notificationbox/LICENSE b/packages/notificationbox/LICENSE deleted file mode 100644 index 14e2f77..0000000 --- a/packages/notificationbox/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/packages/notificationbox/README.md b/packages/notificationbox/README.md deleted file mode 100644 index df41739..0000000 --- a/packages/notificationbox/README.md +++ /dev/null @@ -1,5 +0,0 @@ -NotificationBox implements some of the notificationbox element functionality in Firefox and Mozilla-based browsers using the Addon SDK. For any question or feedback please email lduros--at--member.fsf.org - -It is released under the MPL 2.0. - -See [doc/main.md](https://github.com/lduros/notificationbox/blob/master/doc/main.md)for more information. diff --git a/packages/notificationbox/data/gnu-icon.png b/packages/notificationbox/data/gnu-icon.png Binary files differdeleted file mode 100644 index 2005027..0000000 --- a/packages/notificationbox/data/gnu-icon.png +++ /dev/null diff --git a/packages/notificationbox/doc/images/critical-notification.png b/packages/notificationbox/doc/images/critical-notification.png Binary files differdeleted file mode 100644 index 6e69b22..0000000 --- a/packages/notificationbox/doc/images/critical-notification.png +++ /dev/null diff --git a/packages/notificationbox/doc/images/info-low-priority.png b/packages/notificationbox/doc/images/info-low-priority.png Binary files differdeleted file mode 100644 index 6fff9f6..0000000 --- a/packages/notificationbox/doc/images/info-low-priority.png +++ /dev/null diff --git a/packages/notificationbox/doc/main.md b/packages/notificationbox/doc/main.md deleted file mode 100644 index 2c28c3a..0000000 --- a/packages/notificationbox/doc/main.md +++ /dev/null @@ -1,46 +0,0 @@ -NotificationBox implements some of the notificationbox element functionality in Firefox and Mozilla-based browsers using the Addon SDK. For any question or feedback please email lduros--at--member.fsf.org - -You can create a notification as follows: -```javascript -var self = require("self"); -var notification = require("notification-box").NotificationBox({ - 'value': 'important-message', - 'label': 'This is a very important message!', - 'priority': 'CRITICAL_BLOCK', - 'image': self.data.url("gnu-icon.png"), - 'buttons': [{'label': "Do something about it!", - 'onClick': function () { console.log("You clicked the important button!"); }}] -}); -``` - -It implements the following options: - - - value: value used to identify the notification - - label: label to appear on the notification - - image: URL of image to appear on the notification. You can also - load a local image from the data folder, like in the example - - priority: notification priority. Use one of the following: - - INFO_LOW - - INFO_MEDIUM - - INFO_HIGH - - WARNING_LOW - - WARNING_MEDIUM - - WARNING_HIGH - - CRITICAL_LOW - - CRITICAL_MEDIUM - - CRITICAL_HIGH - - CRITICAL_BLOCK - - buttons: array of buttons to appear on the notification. - You can use the following options: - - accessKey: the accesskey to appear on the button - - onClick: the callback function to trigger when button is activated. - - label: the text to display on the button - - -Here is an overview of what the example above with the critical notification looks like: - - -When using 'INFO_LOW' for the priority instead, you would see: - - -For more information on notificationbox: https://developer.mozilla.org/en-US/docs/XUL/notificationbox diff --git a/packages/notificationbox/lib/main.js b/packages/notificationbox/lib/main.js deleted file mode 100644 index 0d17404..0000000 --- a/packages/notificationbox/lib/main.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyrights Loic J. Duros 2012 - * lduros@member.fsf.org - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var self = require("sdk/self"); -var notification = require("notification-box").NotificationBox({ - 'value': 'important-message', - 'label': 'You have been warned...', - 'priority': 'WARNING_HIGH', - 'image': self.data.url("gnu-icon.png"), - 'buttons': [{'label': "Gotcha", - 'onClick': function () { console.log("You clicked the important button!"); }}] -}); diff --git a/packages/notificationbox/lib/notification-box.js b/packages/notificationbox/lib/notification-box.js deleted file mode 100644 index 94b26cd..0000000 --- a/packages/notificationbox/lib/notification-box.js +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyrights Loic J. Duros 2012 - * lduros@member.fsf.org - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const { Cc, Ci } = require("chrome"); -const { getMostRecentBrowserWindow } = require('sdk/window/utils'); -/* I haven't found this sort of validation functions in the SDK, -except for the deprecated api-utils module. */ -let isString = function (str) { - return typeof(str) == 'string' || str instanceof String; -}; - -let isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; -}; - -exports.NotificationBox = function (options) { - options = options || {}; - let mainWindow = getWindow(); - let nb = mainWindow.gBrowser.getNotificationBox(); - let notification, priority, label, image, value, buttons = []; - - if (options.value && isString(options.value)) { - notification = nb.getNotificationWithValue(options.value); - value = options.value; - } - else { - notification = nb.getNotificationWithValue(''); - value = ''; - } - - // Add label or create empty notification. - if (options.label && isString(options.label)) - label = options.label; - else - label = ""; - - // Set priority of the notification (from info low, to critical - // block. - if (options.priority && options.priority in PRIORITY) - priority = nb[PRIORITY[options.priority]]; - else - priority = nb[PRIORITY.INFO_LOW]; - - // Set a custom icon for the notification or use the regular info - // icon. - if (options.image && isString(options.image)) - image = options.image; - else - image = 'chrome://browser/skin/Info.png'; - - // Add buttons. - if (isArray(options.buttons)) { - for (let i = 0, length = options.buttons.length; i < length; i++) { - buttons.push(NotificationButton(options.buttons[i])); - } - } - else if (typeof(options.buttons) === 'object') { - // If it's not an array of buttons, then it should be a single button. - buttons.push(NotificationButton(options.buttons)); - } - else { - buttons = null; - } - - // add new notification to notificationbox. - nb.appendNotification(label, value, - image, - priority, buttons); - - return {'notificationbox': nb, 'notification': notification}; -}; - - - -var NotificationButton = function (options) { - - options = options || {}; - let accessKey, onClick, label, popup; - - if (options.accessKey) - accessKey = options.accessKey; - else - accessKey = ''; - - if (options.onClick) - onClick = options.onClick; - else - onClick = function () {}; - - if (options.label) - label = options.label; - else - label = ""; - - // no popup for now... maybe we can use a panel later. - popup = null; - - return {label: label, - accessKey: accessKey, - callback: onClick, - popup: popup}; - -}; - -const PRIORITY = { - 'INFO_LOW': 'PRIORITY_INFO_LOW', - 'INFO_MEDIUM': 'PRIORITY_INFO_MEDIUM', - 'INFO_HIGH': 'PRIORITY_INFO_HIGH', - 'WARNING_LOW': 'PRIORITY_WARNING_LOW', - 'WARNING_MEDIUM': 'PRIORITY_WARNING_MEDIUM', - 'WARNING_HIGH': 'PRIORITY_WARNING_HIGH', - 'CRITICAL_LOW': 'PRIORITY_CRITICAL_LOW', - 'CRITICAL_MEDIUM': 'PRIORITY_CRITICAL_MEDIUM', - 'CRITICAL_HIGH': 'PRIORITY_CRITICAL_HIGH', - 'CRITICAL_BLOCK': 'PRIORITY_CRITICAL_BLOCK' -}; - -let getWindow = function () { - return getMostRecentBrowserWindow(); -}; - -exports.PRIORITY = PRIORITY; - diff --git a/packages/notificationbox/package.json b/packages/notificationbox/package.json deleted file mode 100644 index 57ce0bb..0000000 --- a/packages/notificationbox/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "notification-box", - "license": "MPL 2.0", - "author": "", - "version": "0.1", - "fullName": "notification-box", - "id": "jid1-dyFGGJB0CjoDMA", - "description": "a basic add-on" -} diff --git a/packages/notificationbox/test/test-main.js b/packages/notificationbox/test/test-main.js deleted file mode 100644 index 9e7031a..0000000 --- a/packages/notificationbox/test/test-main.js +++ /dev/null @@ -1,12 +0,0 @@ -var main = require("main"); - -exports["test main"] = function(assert) { - assert.pass("Unit test running!"); -}; - -exports["test main async"] = function(assert, done) { - assert.pass("async Unit test running!"); - done(); -}; - -require("test").run(exports); diff --git a/packages/vold-utils/README.md b/packages/vold-utils/README.md deleted file mode 100644 index 41773e3..0000000 --- a/packages/vold-utils/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Vold Utils for Mozilla's Add-on SDK - -A collection of various modules which help build other apis. - - diff --git a/packages/vold-utils/docs/listen.md b/packages/vold-utils/docs/listen.md deleted file mode 100644 index d19c6c6..0000000 --- a/packages/vold-utils/docs/listen.md +++ /dev/null @@ -1,23 +0,0 @@ -<!-- contributed by Erik Vold [erikvvold@gmail.com] --> - -The `listen` module allows modules to register listeners to elements that are -automatically removed when the module unloads. - -<api name="listen"> -@function - Add listeners to run when unloading in a unload queue. Optionally scope the - callback to a container, e.g., window. Provide a way to run all the callbacks. - -@param container {object} - A container for the node, which a "unload" event will be attached to, this is - used to cancel the unload magic that would occur, to avoid memory leaks. -@param node {object} - The node to listen to. -@param event {string} - The event type, for example: "load", "click", ... -@param callback {function} - A function to be called when the event occurs on the node. -@param [capture] {boolean} - Indicates if the event should be captured. [See the `useCapture` - documentation here](https://developer.mozilla.org/en/DOM/element.addEventListener). -</api> diff --git a/packages/vold-utils/docs/unload+.md b/packages/vold-utils/docs/unload+.md deleted file mode 100644 index 78693ef..0000000 --- a/packages/vold-utils/docs/unload+.md +++ /dev/null @@ -1,20 +0,0 @@ -<!-- contributed by Erik Vold [erikvvold@gmail.com] --> - -The `unload+` module allows modules to register callbacks that are called -when they are unloaded, and associate unload functions to containers to have the -unloader automatically deleted when the container unloads. - -<api name="unload"> -@function - Save callbacks to run when unloading in a unload queue. Optionally scope the - callback to a container, e.g., window. Provide a way to run all the callbacks. - -@param callback {function} - A function to be called when the module unloads. -@param [container] {object} - Optional container object; if the container "unloads" before the module - unloads, then the associated callback is removed from the unload queue. -@returns {function} - Returns a function which will allow one to remove the callback from the unload - queue. -</api> diff --git a/packages/vold-utils/lib/array.js b/packages/vold-utils/lib/array.js deleted file mode 100644 index 5ac0577..0000000 --- a/packages/vold-utils/lib/array.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -function run(array) array.forEach(function(f) f()); -exports.run = run; - - diff --git a/packages/vold-utils/lib/instances.js b/packages/vold-utils/lib/instances.js deleted file mode 100644 index a33ca40..0000000 --- a/packages/vold-utils/lib/instances.js +++ /dev/null @@ -1,57 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MIT/X11 License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * Contributor(s): - * Erik Vold <erikvvold@gmail.com> (Original Author) - * - * ***** END LICENSE BLOCK ***** */ - -const {Cc, Ci, Cu} = require("chrome"); - -var Instances = exports.Instances = { - get bis() Cc["@mozilla.org/binaryinputstream;1"] - .createInstance(Ci.nsIBinaryInputStream), - get ch() Cc["@mozilla.org/security/hash;1"] - .createInstance(Ci.nsICryptoHash), - get dp() Cc["@mozilla.org/xmlextras/domparser;1"] - .createInstance(Ci.nsIDOMParser), - get ds() Cc["@mozilla.org/xmlextras/xmlserializer;1"] - .createInstance(Ci.nsIDOMSerializer), - get fos() Cc["@mozilla.org/network/file-output-stream;1"] - .createInstance(Ci.nsIFileOutputStream), - get sfos() Cc["@mozilla.org/network/safe-file-output-stream;1"] - .createInstance(Ci.nsIFileOutputStream) - .QueryInterface(Ci.nsISafeOutputStream), - get fp() Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker), - get lf() Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile), - get process() Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess), - get se() Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError) - .QueryInterface(Ci.nsIScriptError2), - get ss() Cc["@mozilla.org/supports-string;1"] - .createInstance(Ci.nsISupportsString), - get suc() Cc["@mozilla.org/intl/scriptableunicodeconverter"] - .createInstance(Ci.nsIScriptableUnicodeConverter), - get timer() Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer), - get wbp() Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] - .createInstance(Ci.nsIWebBrowserPersist), - get xhr() Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] - .createInstance(Ci.nsIXMLHttpRequest) -}; diff --git a/packages/vold-utils/lib/listen.js b/packages/vold-utils/lib/listen.js deleted file mode 100644 index 0b947d1..0000000 --- a/packages/vold-utils/lib/listen.js +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -const { unload, Unload } = require("unload+"); - -/** - * Helper that adds event listeners and remembers to remove on unload - */ -function listen(window, node, event, func, capture) { - // Default to use capture - if (capture == null) - capture = true; - - node.addEventListener(event, func, capture); - function undoListen() { - node.removeEventListener(event, func, capture); - } - - // Undo the listener on unload and provide a way to undo everything - let undoUnload = unload(undoListen, window); - return function() { - undoListen(); - undoUnload(); - }; -} -exports.listen = listen; - diff --git a/packages/vold-utils/lib/memoize.js b/packages/vold-utils/lib/memoize.js deleted file mode 100644 index 73bb4fc..0000000 --- a/packages/vold-utils/lib/memoize.js +++ /dev/null @@ -1,131 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MIT/X11 License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * Contributor(s): - * Nils Maier <MaierMan@web.de> - * Erik Vold <erikvvold@gmail.com> - * - * ***** END LICENSE BLOCK ***** */ - -"use strict"; - -/** - * Decorate a function with a memoization wrapper, with a limited-size cache - * to reduce peak memory utilization. - * - * The memoized function may have any number of arguments, but they must be - * be serializable. It's safest to use this only on functions that accept - * primitives. - * - * A memoized function is not thread-safe, but so is JS, nor re-entrant-safe! - * - * @usage var foo = Scriptish_memoize(function foo(arg1, arg2) { ... complex operation ... }); - * @param {Function} func The function to be memoized - * @param {Number} limit Optional. Cache size (default: 100) - * @param {Number} num_args Options. Number of arguments the function expects (default: func.length) - * @return {Function} Memoized function - */ -exports.memoize = function memoize(func, limit, num_args) { - limit = limit || 100; - num_args = num_args || func.length; - - var cache = Object.create(null); - var keylist = []; - var args = []; - var key, result; - - switch (num_args) { - case 0: - throw new Error("memoize does not support functions without arguments"); - case 1: - return function memoize_one_arg(a) { - key = a.toString(); - - if (key in cache) - return cache[key]; - - result = func.call(null, a); - cache[key] = result; - if (keylist.push(key) > limit) - delete cache[keylist.shift()]; - return result; - }; - case 2: - return function memoize_two_args(a, b) { - args[0] = a; args[1] = b; - key = JSON.stringify(args); - args.length = 0; - - if (key in cache) - return cache[key]; - - var result = func.call(null, a, b); - cache[key] = result; - if (keylist.push(key) > limit) - delete cache[keylist.shift()]; - return result; - }; - case 3: - return function memoize_three_args(a, b, c) { - args[0] = a; args[1] = b; args[2] = c; - key = JSON.stringify(args); - args.length = 0; - - if (key in cache) - return cache[key]; - - var result = func.call(null, a, b, c); - cache[key] = result; - if (keylist.push(key) > limit) - delete cache[keylist.shift()]; - return result; - }; - - case 4: - return function memoize_four_args(a, b, c, d) { - args[0] = a; args[1] = b; args[2] = c; args[3] = d; - key = JSON.stringify(args); - args.length = 0; - - if (key in cache) - return cache[key]; - - var result = func.call(null, a, b, c, d); - cache[key] = result; - if (keylist.push(key) > limit) - delete cache[keylist.shift()]; - return result; - }; - - default: - return function() { - var key = JSON.stringify(arguments); - if (key in cache) - return cache[key]; - - var result = func.apply(null, arguments); - cache[key] = result; - if (keylist.push(key) > limit) - delete cache[keylist.shift()]; - return result; - }; - } -} diff --git a/packages/vold-utils/lib/net-utils.js b/packages/vold-utils/lib/net-utils.js deleted file mode 100644 index df7f300..0000000 --- a/packages/vold-utils/lib/net-utils.js +++ /dev/null @@ -1,3 +0,0 @@ - -require("chrome").Cu.import("resource://gre/modules/NetUtil.jsm", this); -exports.NetUtil = NetUtil; diff --git a/packages/vold-utils/lib/services.js b/packages/vold-utils/lib/services.js deleted file mode 100644 index 4854dfa..0000000 --- a/packages/vold-utils/lib/services.js +++ /dev/null @@ -1,84 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MIT/X11 License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * Contributor(s): - * Erik Vold <erikvvold@gmail.com> (Original Author) - * - * ***** END LICENSE BLOCK ***** */ - -const {Cc, Ci, Cu} = require("chrome"); -Cu.import("resource://gre/modules/Services.jsm", this); - -const global = this; -var Services = exports.Services = {}; -(function(inc, tools){ - inc("resource://gre/modules/XPCOMUtils.jsm", global); - inc("resource://gre/modules/Services.jsm", tools); - Services.__proto__ = tools.Services; -})(Cu.import, {}); - -/* -XPCOMUtils.defineLazyGetter(Services, "scriptish", function() ( - Cc["@scriptish.erikvold.com/scriptish-service;1"] - .getService().wrappedJSObject)); -*/ - -XPCOMUtils.defineLazyServiceGetter( - Services, "as", "@mozilla.org/alerts-service;1", "nsIAlertsService"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "ass", "@mozilla.org/appshell/appShellService;1", - "nsIAppShellService"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "cb", "@mozilla.org/widget/clipboardhelper;1", - "nsIClipboardHelper"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "cs", "@mozilla.org/consoleservice;1", "nsIConsoleService"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "eps", "@mozilla.org/uriloader/external-protocol-service;1", - "nsIExternalProtocolService"); - -if (Cc["@mozilla.org/privatebrowsing;1"]) { - XPCOMUtils.defineLazyServiceGetter( - Services, "pbs", "@mozilla.org/privatebrowsing;1", - "nsIPrivateBrowsingService"); -} else { - Services.pbs = {privateBrowsingEnabled: false}; -} - -XPCOMUtils.defineLazyServiceGetter( - Services, "sis", "@mozilla.org/scriptableinputstream;1", - "nsIScriptableInputStream"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "suhtml", "@mozilla.org/feed-unescapehtml;1", - "nsIScriptableUnescapeHTML"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "tld", "@mozilla.org/network/effective-tld-service;1", - "nsIEffectiveTLDService"); - -XPCOMUtils.defineLazyServiceGetter( - Services, "uuid", "@mozilla.org/uuid-generator;1", - "nsIUUIDGenerator"); diff --git a/packages/vold-utils/lib/unload+.js b/packages/vold-utils/lib/unload+.js deleted file mode 100644 index 285fd46..0000000 --- a/packages/vold-utils/lib/unload+.js +++ /dev/null @@ -1,80 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -const { Class } = require("sdk/core/heritage"); -const unloadNS = require("sdk/core/namespace").ns(); - -var Unloader = exports.Unloader = Class({ - initialize: function Unloader() { - let unloaders = unloadNS(this).unloaders = []; - - let unloadersUnlaod = unloadNS(this).unloadersUnlaod = function() { - unloaders.slice().forEach(function(u) u()); - unloaders.length = 0; - } - - require("sdk/system/unload").when(unloadersUnlaod); - }, - unload: function unload(callback, container) { - // Calling with no arguments runs all the unloader callbacks - if (callback == null) { - unloadNS(this).unloadersUnlaod(); - return null; - } - - var remover = removeUnloader.bind(null, unloader, unloadNS(this).unloaders); - - // The callback is bound to the lifetime of the container if we have one - if (container != null) { - // Remove the unloader when the container unloads - container.addEventListener("unload", remover, false); - - // Wrap the callback to additionally remove the unload listener - let origCallback = callback; - callback = function() { - container.removeEventListener("unload", remover, false); - origCallback(); - } - } - - // Wrap the callback in a function that ignores failures - function unloader() { - try { - callback(); - } - catch(e) { - console.error(e); - } - } - unloadNS(this).unloaders.push(unloader); - - // Provide a way to remove the unloader - return remover; - } -}); - -function removeUnloader(unloader, unloaders) { - let index = unloaders.indexOf(unloader); - if (index != -1) - unloaders.splice(index, 1); -} - -/** - * Save callbacks to run when unloading. Optionally scope the callback to a - * container, e.g., window. Provide a way to run all the callbacks. - * - * @usage unload(): Run all callbacks and release them. - * - * @usage unload(callback): Add a callback to run on unload. - * @param [function] callback: 0-parameter function to call on unload. - * @return [function]: A 0-parameter function that undoes adding the callback. - * - * @usage unload(callback, container) Add a scoped callback to run on unload. - * @param [function] callback: 0-parameter function to call on unload. - * @param [node] container: Remove the callback when this container unloads. - * @return [function]: A 0-parameter function that undoes adding the callback. - */ -const gUnload = Unloader(); -exports.unload = gUnload.unload.bind(gUnload); diff --git a/packages/vold-utils/lib/window-watcher.js b/packages/vold-utils/lib/window-watcher.js deleted file mode 100644 index ab4f449..0000000 --- a/packages/vold-utils/lib/window-watcher.js +++ /dev/null @@ -1,91 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Twitter Address Bar Search. - * - * The Initial Developer of the Original Code is The Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Edward Lee <edilee@mozilla.com> - * Erik Vold <erikvvold@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -const {Cu} = require("chrome"); -Cu.import("resource://gre/modules/Services.jsm", this); - -var {unload} = require("unload+"); - -/** - * Apply a callback to each open and new browser windows. - * - * @usage watchWindows(callback): Apply a callback to each browser window. - * @param [function] callback: 1-parameter function that gets a browser window. - */ -exports.watchWindows = function watchWindows(callback) { - // Wrap the callback in a function that ignores failures - function watcher(window) { - try { - // Now that the window has loaded, only handle browser windows - let {documentElement} = window.document; - if (documentElement.getAttribute("windowtype") == "navigator:browser") - callback(window); - } - catch(ex) {} - } - - // Wait for the window to finish loading before running the callback - function runOnLoad(window) { - // Listen for one load event before checking the window type - window.addEventListener("load", function runOnce() { - window.removeEventListener("load", runOnce, false); - watcher(window); - }, false); - } - - // Add functionality to existing windows - let windows = Services.wm.getEnumerator(null); - while (windows.hasMoreElements()) { - // Only run the watcher immediately if the window is completely loaded - let window = windows.getNext(); - if (window.document.readyState == "complete") - watcher(window); - // Wait for the window to load before continuing - else - runOnLoad(window); - } - - // Watch for new browser windows opening then wait for it to load - function windowWatcher(subject, topic) { - if (topic == "domwindowopened") - runOnLoad(subject); - } - Services.ww.registerNotification(windowWatcher); - - // Make sure to stop watching for windows if we're unloading - unload(function() Services.ww.unregisterNotification(windowWatcher)); -}; diff --git a/packages/vold-utils/lib/xpcom-utils.js b/packages/vold-utils/lib/xpcom-utils.js deleted file mode 100644 index f453b34..0000000 --- a/packages/vold-utils/lib/xpcom-utils.js +++ /dev/null @@ -1,3 +0,0 @@ - -require("chrome").Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); -exports.XPCOMUtils = XPCOMUtils; diff --git a/packages/vold-utils/package.json b/packages/vold-utils/package.json deleted file mode 100644 index ad549b7..0000000 --- a/packages/vold-utils/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "vold-utils", - "description": "Utilitys for Jetpacks", - "author": "Erik Vold (http://erikvold.com/) <erikvvold@gmail.com>", - "version": "1.1", - "dependencies": ["api-utils"] -} diff --git a/packages/vold-utils/tests/test-unload+.js b/packages/vold-utils/tests/test-unload+.js deleted file mode 100644 index 92f3e0c..0000000 --- a/packages/vold-utils/tests/test-unload+.js +++ /dev/null @@ -1,119 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -var timer = require("timer"); -var {Cc,Ci} = require("chrome"); -const windowUtils = require("window-utils"); -const { Loader } = require('test-harness/loader'); - -function makeEmptyWindow() { - var xulNs = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - var blankXul = ('<?xml version="1.0"?>' + - '<?xml-stylesheet href="chrome://global/skin/" ' + - ' type="text/css"?>' + - '<window xmlns="' + xulNs + '">' + - '</window>'); - var url = "data:application/vnd.mozilla.xul+xml," + escape(blankXul); - var features = ["chrome", "width=10", "height=10"]; - - var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"] - .getService(Ci.nsIWindowWatcher); - return ww.openWindow(null, url, null, features.join(","), null); -} - -exports.testUnloading = function(test) { - var loader = Loader(module); - var {unload} = loader.require("unload+"); - var unloadCalled = 0; - - function unloader() { - unloadCalled++; - throw "error"; - } - unload(unloader); - - function unloader2() unloadCalled++; - var removeUnloader2 = unload(unloader2); - - function unloader3() unloadCalled++; - unload(unloader3); - - // remove unloader2 - removeUnloader2(); - - loader.unload(); - test.assertEqual( - unloadCalled, 2, "Unloader functions are called on unload."); -}; - -exports.testUnloadingWindow = function(test) { - test.waitUntilDone(); - - var loader = Loader(module); - var {unload} = loader.require("unload+"); - var unloadCalled = 0; - var finished = false; - var myWindow; - - var delegate = { - onTrack: function(window) { - if (window == myWindow) { - test.pass("onTrack() called with our test window"); - - let unloader = function unloader() { - unloadCalled++; - } - unload(unloader, window); - unload(unloader); - - timer.setTimeout(function() { - window.close(); - - test.assertEqual( - unloadCalled, 0, "no unloaders called."); - - if (window.closed) { - test.pass("window closed"); - } else { - test.fail("window is not closed!"); - } - - timer.setTimeout(function() { - test.assertEqual( - unloadCalled, 0, "zero unloaders called."); - - loader.unload(); - - test.assertEqual( - unloadCalled, 1, "one unloaders called."); - - if (finished) { - test.pass("finished"); - test.done(); - } else { - test.fail("not finished!"); - } - }, 1); - }, 1); - } - }, - onUntrack: function(window) { - if (window == myWindow) { - test.pass("onUntrack() called with our test window"); - - if (!finished) { - finished = true; - myWindow = null; - wt.unload(); - } else { - test.fail("finishTest() called multiple times."); - } - } - } - }; - - var wt = new windowUtils.WindowTracker(delegate); - myWindow = makeEmptyWindow(); -}; diff --git a/test.sh b/test.sh deleted file mode 100755 index 2886c95..0000000 --- a/test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -if [ ! -f "addon-sdk/bin/activate" ]; then - die "Addon SDK not available. Run git submodule update." -fi - -pushd addon-sdk -source bin/activate -popd - -echo "Running tests" -cfx test --verbose diff --git a/test/mock/mock_nodes.js b/test/mock/mock_nodes.js index 3ef1fbc..abd29a4 100644 --- a/test/mock/mock_nodes.js +++ b/test/mock/mock_nodes.js @@ -19,7 +19,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const types = require("js_checker/constant_types").token; +const types = require("../../lib/js_checker/constant_types").token; exports.mockNodes = { diff --git a/test/test-accepted_scripts.js b/test/test-accepted_scripts.js index 4e5ee16..812f538 100644 --- a/test/test-accepted_scripts.js +++ b/test/test-accepted_scripts.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var acceptedScripts = require('script_entries/accepted_scripts') +var acceptedScripts = require('../lib/script_entries/accepted_scripts') .acceptedScripts; exports.testAddAScript = function (assert) { diff --git a/test/test-all_scripts.js b/test/test-all_scripts.js index d26963d..56759a6 100644 --- a/test/test-all_scripts.js +++ b/test/test-all_scripts.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var allScripts = require('script_entries/all_scripts').allScripts; +var allScripts = require('../lib/script_entries/all_scripts').allScripts; exports.truncateDataTest = function(test) { var str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ultricies molestie tellus, eu ullamcorper dui luctus sit amet. Morbi sed urna eu justo malesuada bibendum nec non est. Sed sagittis sodales ullamcorper. Mauris dolor arcu, dignissim ac sollicitudin ac, tempus at orci. Curabitur pretium risus id urna congue cursus. Nulla ullamcorper faucibus nibh, eget ultrices ante vestibulum id. Vestibulum elementum ullamcorper mi, id ultrices lacus faucibus et. Nullam lectus augue, suscipit a elementum at, malesuada eget nulla. Aenean tempus ultrices elit ut vulputate. Ut congue magna ultricies felis rutrum eget ultricies nibh vehicula. In id pellentesque risus. Pellentesque aliquam quam eros, quis placerat eros. Cras molestie, turpis et consectetur sollicitudin, magna enim mattis lectus, et adipiscing erat urna in risus. Vestibulum sed arcu vitae mauris ornare ultricies a sit amet leo. Praesent pharetra, urna in varius fermentum, neque nibh tempor justo, id ullamcorper magna amet.…"; diff --git a/test/test-allowed_referrers.js b/test/test-allowed_referrers.js index 6be8d27..47256b9 100644 --- a/test/test-allowed_referrers.js +++ b/test/test-allowed_referrers.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const allowedRef = require('http_observer/allowed_referrers').allowedReferrers; +const allowedRef = require('../lib/http_observer/allowed_referrers').allowedReferrers; var addUrls = function () { allowedRef.addPage('http://www.example.org'); diff --git a/test/test-bug-frozen.js b/test/test-bug-frozen.js index f02f6cf..215182b 100644 --- a/test/test-bug-frozen.js +++ b/test/test-bug-frozen.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var main = require('main'); +var main = require('../lib/main'); var tabs = require('sdk/tabs'); /*exports.testBug = function (assert, done) { diff --git a/test/test-crypto-a.js b/test/test-crypto-a.js index caa12f8..4a2dd6e 100644 --- a/test/test-crypto-a.js +++ b/test/test-crypto-a.js @@ -19,7 +19,7 @@ * You should have received a copy of the GNU General Public License * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var crypto = require("script_entries/crypto"); +var crypto = require("../lib/script_entries/crypto"); exports.testSha1EncryptTest = function(assert) { var str = "This is my test string"; diff --git a/test/test-crypto-b.js b/test/test-crypto-b.js index 3326724..65a9699 100644 --- a/test/test-crypto-b.js +++ b/test/test-crypto-b.js @@ -323,7 +323,8 @@ var list = [ ]; list = ["http://code.jquery.com/jquery-1.8.2.min.js"]; -const scriptsCached = require("script_entries/scripts_cache").scriptsCached; +const scriptsCached = require("../lib/script_entries/scripts_cache") + .scriptsCached; var counter = 0; @@ -333,16 +334,13 @@ var popAndEncryptRemoteScript = function (test) { try { var currentUrl = list.pop(); var script = {url: currentUrl}; - require('html_script_finder/dom_handler/request').request(script, - function (script, data) { - //console.log('"',scriptsCached.getHash(data), '": - //{"filename": "', currentUrl, '", "result": 6}'); - counter++; - popAndEncryptRemoteScript(test); - - - }).request(); - + require('../lib/html_script_finder/dom_handler/request').request( + script, function (script, data) { + //console.log('"',scriptsCached.getHash(data), '": + //{"filename": "', currentUrl, '", "result": 6}'); + counter++; + popAndEncryptRemoteScript(test); + }).request(); } catch (e) { test.assertEqual(counter, totalScripts); test.done(); diff --git a/test/test-domHandler.js b/test/test-domHandler.js index c5eaa50..5095d97 100644 --- a/test/test-domHandler.js +++ b/test/test-domHandler.js @@ -24,7 +24,7 @@ // using following command to run after placing nightly is /usr/local/: // cfx --binary=/usr/local/bin/firefox-nightly test -f domHandler -var domHandler = require("html_script_finder/dom_handler"); +var domHandler = require("../lib/html_script_finder/dom_handler"); var mockDom = require("./mock/mock_dom"); //var loader = test.makeSandboxedLoader(); diff --git a/test/test-free_libraries.js b/test/test-free_libraries.js index 523deb1..11f8f7a 100644 --- a/test/test-free_libraries.js +++ b/test/test-free_libraries.js @@ -23,7 +23,7 @@ forget this test for now. -var main = require("main"); +var main = require("../lib/main"); var pageMod = require("sdk/page-mod"); var tabs = require("sdk/tabs"); diff --git a/test/test-html_parser.js b/test/test-html_parser.js index 30c08bc..1c3e0ef 100644 --- a/test/test-html_parser.js +++ b/test/test-html_parser.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var htmlParser = require("html_script_finder/html_parser"); +var htmlParser = require("../lib/html_script_finder/html_parser"); var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); diff --git a/test/test-js_checker.js b/test/test-js_checker.js index 61a3a15..e786d62 100644 --- a/test/test-js_checker.js +++ b/test/test-js_checker.js @@ -20,8 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const jsChecker = require("js_checker/js_checker"); -const constants = require("js_checker/constant_types"); +const jsChecker = require("../lib/js_checker/js_checker"); +const constants = require("../lib/js_checker/constant_types"); var checkTypes = constants.checkTypes; var init = function() { diff --git a/test/test-js_load_observer_1.js b/test/test-js_load_observer_1.js index 54b4674..b0d66f3 100644 --- a/test/test-js_load_observer_1.js +++ b/test/test-js_load_observer_1.js @@ -20,12 +20,14 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var jsLoadObserver = require("js_load_observer/js_load_observer"); +var jsLoadObserver = require("../lib/js_load_observer/js_load_observer"); var tabs = require("sdk/tabs"); // use the two buckets. -var removedScripts = require("script_entries/removed_scripts").removedScripts; -var acceptedScripts = require("script_entries/accepted_scripts").acceptedScripts; +var removedScripts = require("../lib/script_entries/removed_scripts") + .removedScripts; +var acceptedScripts = require("../lib/script_entries/accepted_scripts") + .acceptedScripts; var mockDom = require("./mock/mock_dom"); // FIXME diff --git a/test/test-js_load_observer_3.js b/test/test-js_load_observer_3.js index a6f1840..1448a56 100644 --- a/test/test-js_load_observer_3.js +++ b/test/test-js_load_observer_3.js @@ -24,10 +24,12 @@ var tabs = require("sdk/tabs"); var pageMod = require("sdk/page-mod"); // use the two buckets. -var removedScripts = require("script_entries/removed_scripts").removedScripts; -var acceptedScripts = require("script_entries/accepted_scripts").acceptedScripts; +var removedScripts = require("../lib/script_entries/removed_scripts") + .removedScripts; +var acceptedScripts = require("../lib/script_entries/accepted_scripts") + .acceptedScripts; -var jsLoadObserver = require("js_load_observer/js_load_observer"); +var jsLoadObserver = require("../lib/js_load_observer/js_load_observer"); var reset = function(url) { acceptedScripts.clearScripts(url); diff --git a/test/test-license_definitions.js b/test/test-license_definitions.js index f20299c..8f6cc93 100644 --- a/test/test-license_definitions.js +++ b/test/test-license_definitions.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const licenses = require('js_checker/license_definitions'); +const licenses = require('../lib/js_checker/license_definitions'); exports.testGetLicenseName = function (test) { diff --git a/test/test-nonfree_checker.js b/test/test-nonfree_checker.js index 0c4d85d..a2d2818 100644 --- a/test/test-nonfree_checker.js +++ b/test/test-nonfree_checker.js @@ -20,8 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const check = require("js_checker/free_checker"); -const licenses = require("js_checker/license_definitions"); +const check = require("../lib/js_checker/free_checker"); +const licenses = require("../lib/js_checker/license_definitions"); const mockNodes = require("./mock/mock_nodes_with_comments"); var mockLicense = function () { @@ -95,7 +95,7 @@ exports.testCheckNodeFreeLicenseNotFree = function (test) { /* exports.testLicenseToRegexp = function (test) { var loader = test.makeSandboxedLoader(); - var module = loader.require('js_checker/free_checker'); + var module = loader.require('../lib/js_checker/free_checker'); var privateScope = loader.findSandboxForModule('js_checker/free_checker'.toString()).globalScope; // ensure the regex values are truthy. test.assert(privateScope.licenses.licenses.gplv2.licenseFragments[0].regex); diff --git a/test/test-nontrivial_checker.js b/test/test-nontrivial_checker.js index c93166f..3998fc3 100644 --- a/test/test-nontrivial_checker.js +++ b/test/test-nontrivial_checker.js @@ -20,12 +20,12 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const nonTrivialCheckModule = require("js_checker/nontrivial_checker"); +const nonTrivialCheckModule = require("../lib/js_checker/nontrivial_checker"); const check = nonTrivialCheckModule.nonTrivialChecker(false, false); const mn = require("./mock/mock_nodes"); var testRunner; -const constants = require("js_checker/constant_types"); +const constants = require("../lib/js_checker/constant_types"); var checkTypes = constants.checkTypes; var testCheckNontrivial = function (assert, n) { diff --git a/test/test-privacy_checker.js b/test/test-privacy_checker.js index 974b379..9062f58 100644 --- a/test/test-privacy_checker.js +++ b/test/test-privacy_checker.js @@ -20,7 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const privacyCheck = require("js_checker/privacy_checker").privacyCheck; +const privacyCheck = require("../lib/js_checker/privacy_checker") + .privacyCheck; exports.testPrivacyCheckerGoogleAnalyticsRegex = function(assert) { // original analytics code this was designed for diff --git a/test/test-relation_checker.js b/test/test-relation_checker.js index 97d6f4e..a8a07ed 100644 --- a/test/test-relation_checker.js +++ b/test/test-relation_checker.js @@ -20,7 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var relationChecker = require('js_checker/relation_checker').relationChecker('b'); +var relationChecker = require('../lib/js_checker/relation_checker') + .relationChecker('b'); const mn = require("./mock/mock_nodes"); // the fake node. @@ -62,7 +63,8 @@ exports.testCheckMethodNotAdded = function (test) { exports.testStoreNodeGlobalDeclarations = function (test) { - var check = require('js_checker/relation_checker').relationChecker('b'); + var check = require('../lib/js_checker/relation_checker') + .relationChecker('b'); check.storeNodeGlobalDeclarations(nVar); test.assertEqual('def' in check.variableDeclarations, true); check.storeNodeGlobalDeclarations(nFunc); diff --git a/test/test-removed_scripts.js b/test/test-removed_scripts.js index 78dd8c4..fbe2780 100644 --- a/test/test-removed_scripts.js +++ b/test/test-removed_scripts.js @@ -20,7 +20,8 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var removedScripts = require('script_entries/removed_scripts').removedScripts; +var removedScripts = require('../lib/script_entries/removed_scripts') + .removedScripts; exports.truncateDataTest = function(test) { var str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ultricies molestie tellus, eu ullamcorper dui luctus sit amet. Morbi sed urna eu justo malesuada bibendum nec non est. Sed sagittis sodales ullamcorper. Mauris dolor arcu, dignissim ac sollicitudin ac, tempus at orci. Curabitur pretium risus id urna congue cursus. Nulla ullamcorper faucibus nibh, eget ultrices ante vestibulum id. Vestibulum elementum ullamcorper mi, id ultrices lacus faucibus et. Nullam lectus augue, suscipit a elementum at, malesuada eget nulla. Aenean tempus ultrices elit ut vulputate. Ut congue magna ultricies felis rutrum eget ultricies nibh vehicula. In id pellentesque risus. Pellentesque aliquam quam eros, quis placerat eros. Cras molestie, turpis et consectetur sollicitudin, magna enim mattis lectus, et adipiscing erat urna in risus. Vestibulum sed arcu vitae mauris ornare ultricies a sit amet leo. Praesent pharetra, urna in varius fermentum, neque nibh tempor justo, id ullamcorper magna amet.…"; diff --git a/test/test-request.js b/test/test-request.js index ba66bbf..040ea8c 100644 --- a/test/test-request.js +++ b/test/test-request.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var xhr2 = require("html_script_finder/dom_handler/request"); +var xhr2 = require("../lib/html_script_finder/dom_handler/request"); var Request = require("sdk/request").Request; exports.testHttpsEverywhere = function (test) { diff --git a/test/test-script_object.js b/test/test-script_object.js index aceaa89..ce7802a 100644 --- a/test/test-script_object.js +++ b/test/test-script_object.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var scriptObject = require("html_script_finder/dom_handler/script_object"); +var scriptObject = require("../lib/html_script_finder/dom_handler/script_object"); exports.testCreateNewScript = function(assert) { var script1, script2; diff --git a/test/test-script_properties.js b/test/test-script_properties.js index 1a58ca0..c65275c 100644 --- a/test/test-script_properties.js +++ b/test/test-script_properties.js @@ -19,7 +19,7 @@ * You should have received a copy of the GNU General Public License * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var scriptProperties = require("html_script_finder/dom_handler/script_properties"); +var scriptProperties = require("../lib/html_script_finder/dom_handler/script_properties"); const scriptTypes = scriptProperties.scriptTypes; const statusTypes = scriptProperties.statusTypes; diff --git a/test/test-stream_loader.js b/test/test-stream_loader.js index a75683e..cb549c7 100644 --- a/test/test-stream_loader.js +++ b/test/test-stream_loader.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var streamLoader = require("http_observer/stream_loader.js"); +var streamLoader = require("../lib/http_observer/stream_loader.js"); var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); exports.testListener = function (assert) { diff --git a/test/test-ui_info.js b/test/test-ui_info.js index f17ca98..eac14ee 100644 --- a/test/test-ui_info.js +++ b/test/test-ui_info.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var uiInfo = require("ui/ui_info").testModule; +var uiInfo = require("../lib/ui/ui_info").testModule; exports.testFoundInContactList = function (test) { diff --git a/test/test-url_handler.js b/test/test-url_handler.js index 54f4171..457c6c7 100644 --- a/test/test-url_handler.js +++ b/test/test-url_handler.js @@ -19,7 +19,7 @@ * You should have received a copy of the GNU General Public License * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -const urlHandler = require('url_handler/url_handler'); +const urlHandler = require('../lib/url_handler/url_handler'); exports.testRemoveFragment1 = function (test) { var url = 'http://example.org/blah.html#section'; diff --git a/test/test-web-label-finder.js b/test/test-web-label-finder.js index 30cff01..1733f5a 100644 --- a/test/test-web-label-finder.js +++ b/test/test-web-label-finder.js @@ -24,7 +24,7 @@ const {Cc,Ci} = require('chrome'); var parser = Cc["@mozilla.org/xmlextras/domparser;1"] .createInstance(Ci.nsIDOMParser); -var WebLabelFinder = require('html_script_finder/web_labels/js_web_labels') +var WebLabelFinder = require('../lib/html_script_finder/web_labels/js_web_labels') .WebLabelFinder; exports.testSearchForJsLinkEmpty = function (assert) { diff --git a/test/test-web-labels.js b/test/test-web-labels.js index 1fc39b0..0cc3919 100644 --- a/test/test-web-labels.js +++ b/test/test-web-labels.js @@ -29,7 +29,7 @@ var mockLicenseList = [{ 'free': true }]; -var dom_handler = require('html_script_finder/dom_handler'); +var dom_handler = require('../lib/html_script_finder/dom_handler'); exports.testScriptHasJsWebLabel = function (assert) { var dm = new dom_handler.DomHandler(); diff --git a/test/test-windowProperty.js b/test/test-windowProperty.js index 64f944e..dd653f9 100644 --- a/test/test-windowProperty.js +++ b/test/test-windowProperty.js @@ -20,7 +20,7 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -var relationChecker = require('js_checker/relation_checker'); +var relationChecker = require('../lib/js_checker/relation_checker'); const mn = require("./mock/mock_nodes"); exports.testCheckIdentifierIsWindowProperty = function (assert) { |