JavaScript Restrictor
Browser extension that improves privacy and security
Instruction how to run integration tests

Integration tests for web browser extension Javascript Restrictor automatically verify that required JavaScript API is wrapped and conversely, that non-wrapped JavaScript API provides real values.

It is necessary to partially set up manually a test environment before the first test run!

SET UP TEST ENVIRONMENT

Install required programs and tools

These programs and tools are required to be installed:

No other versions of Google Chrome and especially Mozilla Firefox may be installed on the same machine. If you already have installed Mozilla Firefox Standard Edition, uninstall it before instalation of Mozilla Firefox ESR starts. Web browser driver automatically selects the installed version of the web browser so it is better to have installed only one correct version of each web browser. Web browsers may not have installed JSR extension. Python script will install it itself before running tests. If you already have installed JSR in web browser, delete JSR setting from Options page and then remove JSR extension from browser.

How to install Mozilla Firefox ESR on Linux

If you have problems with installing Mozzila Firefox ESR on Linux, try this way:

sudo add-apt-repository ppa:jonathonf/firefox-esr
sudo apt-get update
sudo apt-get install firefox-esr

Or download archiv with Firefox ESR from official page, extract archiv to /opt/firefox and create a symbolic link firefox in /usr/bin pointing to the /opt/firefox/firefox. In case of problems with installing Firefox ESR, follow this tutorial.

Setup web browsers

Open Mozilla Firefox ESR and change preference xpinstall.signatures.required to false in the Firefox Configuration Editor (about:config page). You can follow official Mozilla support.

Open testing page and click on button Show GPS data. Firefox will ask you if you want to enable the page to access location. Check option Remember this decision and then click Allow.

Google Chrome is already prepared in default state for testing JSR, the Chrome settings do not need to be changed.

Download web browser drivers

Download web browser drivers needed for controlling web browsers by tests. Download drivers for both web browsers - Google Chrome and Mozilla Firefox - and for both platform - Windows and Linux.

For Google Chrome download the ChromeDriver from download page. Select the version coresponding to the version of your Google Chrome web browser. If you download an incompatible version, you will see an error during starting tests. Download the correct ChromeDriver to folder ../common_files/webbrowser_drivers with name chromedriver.exe (for Windows) or chromedriver (for Linux).

For Mozilla Firefox download the GeckoDriver from download page. Select the version coresponding to the version of your Mozilla Firefox web browser (typically the newest version). If you download an incompatible version, you will see an error during starting tests. Download the correct GeckoDriver to folder ../common_files/webbrowser_drivers with name geckodriver.exe (for Windows) or geckodriver (for Linux).

RUN TESTS

on Windows OS

  1. Install Windows Subsystem for Linux (WSL): https://docs.microsoft.com/en-us/windows/wsl/install-win10.
  2. Convert EOL in the scripts fix_manifest.sh (in the root directory of JSR project) and nscl/include.sh from Windows (CR LF) to Unix (LF) - you can use the tool dos2unix in WSL to convert CR LF to LF.
  3. Open root directory of JSR project in WSL and run command make.
  4. Open PowerShell in folder integration_tests and run command: .\start_integration_tests.ps1

Script may ask you for the path into directory, where the file chrome.exe is stored and where the files of Firefox ESR default profile are stored.

Default location of directory, where chrome.exe is stored, is: C:\Program Files (x86)\Google\Chrome\Application Default location of directory, where the files of Firefox ESR default profile are stored, is: C:\Users\<username>\AppData\Roaming\Mozilla\Firefox\Profiles\<profilename>.default-esr

If script does not find needed files into default locations, it will prompts you to input path, where the file(s) is/are saved.

When script execution starts for the first time, OS Windows may ask you to allow Firewall Exception for this script (for Python). Click Allow.

on Linux OS

Open Terminal in folder integration_tests and run command: ./start_integration_tests.sh

Script may ask you for the path into directory, where the files of Firefox ESR default profile are stored.

Default location of directory, where the files of Firefox ESR default profile are stored, is: /home/<username>/.mozilla/firefox/<profilename>.default-esr

If script does not find needed files into default location, it will prompts you to input path into directory, where the files are saved.

Integration tests configuration

You can change selected browsers, which integration tests run in, and you can change JSR levels, which are tested, by modifing the file ./testing/configuration.py.