Finding and Understanding Conflicts Between JavaScript Libraries
ConflictJS is an approach that analyzes and finds conflicts between JavaScript libraries. Such conflicts may arise because libraries write to the same global memory location. If you want to include multiple libraries in a web application and are unsure whether they conflict with each other, ConflictJS can check for possible conflicts.
For details on the approach, please refer to this paper:
ConflictJS: Finding and Understanding Conflicts Between JavaScript Libraries
Jibesh Patra, Pooja N. Dixit, Michael Pradel
International Conference on Software Engineering (ICSE), 2018
The following steps are performed by ConflictJS to detect conflicts:
We have tested ConflictJS on an Ubuntu 16.04 machine using Node.js version 7 and the Chromium browser. All dependencies must be installed before running the experiments.
We provide a script init.sh that performs all the steps mentioned below. You can either use the script or manually execute the following commands to install all dependencies.
# Install the chromium-browser
sudo apt install chromium-browser
# Install the needed node modules
npm install
# jalangi in particular needs some extra modules to be installed
cd node_modules/jalangi2
npm install
# Come back to the start directory
cd ../../
# Now, create two new directory called benchmarks and results
mkdir -p benchmarks
mkdir -p results
Let's assume that you want check whether two libraries jsurl and urljs are conflicting. All experiments should be run from the current directory
cp -r benchmarks_all/jsurl/ benchmarks
cp -r benchmarks_all/urljs/ benchmarks
let resultDir = "results";
...
exports.benchmarkDir = "/benchmarks";
node src/runExperiments.js
This command needs to be run over and over until all experiments have finished. For this particular case, the command needs to run in total four times. The final results can be found in resultDir, as specified in the configuration file.
After running runExperiments.js often enough, several files and directories are created in the resultDir. The summary of all results is the content of validated-conflicts.json. For the particular example libraries the content of validated-conflicts.json is something like the following:
{"typeTestßjsurl,urljs°Url":"ERROR object,Function"}
The easiest way to check is to run the python3 script
python src/utilities/getValidatedConflicts.py results/validated-conflicts.json
The choice of such characters like ß and ° is driven by the fact that common characters like $ and _ are used by accesspaths or library names and we needed an easy way of separation. You can change the separation characters in the file src/config.js.
Copy any libraries for which you want to detect conflicts to the benchmarks directory and repeat the previous steps.
Let's assume we want to include a library not present in the benchmarks_all directory. Let's call this new library as test-lib.
Create a new folder called test-lib in the benchmarks folder.
Copy the library file test-lib.js to this newly created folder.
Create a new file called libraryInfo.json with the following content.
{
"name": "test-lib",
"urls": [
"./test-lib.js"
]
}
You may now run the experiments as mentioned in the previous steps.
./benchmarks_all
./src/config.js
./src/runExperiments.js
./src/evaluation/experiments
./src/evaluation/validation-tests
./src/htmlfragments
./src/utilities