#29 Add test cases for code ported from Chrome Zero
Closed 2 years ago by xbedna60. Opened 2 years ago by xbedna60.

Rename the fakePluginArray function.
martinbednar • 2 years ago  
file modified
+425 -368
@@ -26,7 +26,7 @@ 

  /**

   * Wrapping groups

   *

-  * Used to control the built-in levels and GUI (e.g. level tweaks).

+  * Used to control the built-in levels and options GUI.

   */

  var wrapping_groups = {

  	empty_level: { /// Automatically populated
@@ -34,14 +34,17 @@ 

  		level_id: "",

  		level_description: "",

  	},

- 	group_map: {}, ///Automatically populated

- 	wrapper_map: {}, ///Automatically populated

- 	group_names: [], ///Automatically populated

+ 	option_map: {}, ///Automatically populated

+ 	associated_params: {}, ///Automatically populated

  	get_wrappers: function(level) {

  		wrappers = [];

  		for (group of wrapping_groups.groups) {

- 			if ((level[group.id] !== undefined) && level[group.id] !== 0) {

- 				let arg_values = group.params[level[group.id] - 1].config;

+ 			if (level[group.id] === true) {

+ 				let arg_names = wrapping_groups.associated_params[group.id];

+ 				let arg_values = arg_names.reduce(function(prev, name) {

+ 					prev.push(level[name]);

+ 					return prev;

+ 				}, []);

  				group.wrappers.forEach((w) => wrappers.push([w, ...arg_values]));

  			}

  		}
@@ -51,23 +54,36 @@ 

  		{

  			name: "time_precision",

  			label: "Time precision",

- 			description: "Prevent attacks and fingerprinting techniques relying on precise time measurement (or make them harder).",

- 			description2: ["Limit the precision of high resolution time stamps (Date, Performance, events, Gamepad API, Web VR API). Timestamps provided by the Geolocation API are wrapped as well if you enable Geolocation API wrapping"],

- 			params: [

- 				{

- 					short: "Poor",

- 					description: "Round time to hundredths of a second (1.230)",

- 					config: [2, false],

- 				},

- 				{

- 					short: "Low",

- 					description: "Round time to tenths of a second (1.200)",

- 					config: [1, false],

- 				},

- 				{

- 					short: "High",

- 					description: "Randomize decimal digits with noise (1.451)",

- 					config: [0, true],

+ 			description: "Limit the precision of high resolution time stamps (Date, Performance, events, Gamepad API, Web VR API)",

+ 			description2: ["Timestamps provided by the Geolocation API are wrapped as well if you enable Geolocation API wrapping"],

+ 			options: [

+ 				{

+ 					description: "Manipulate time to",

+ 					ui_elem: "select",

+ 					name: "precision",

+ 					default: 1,

+ 					data_type: "Number",

+ 					options: [

+ 						{

+ 							value: 2,

+ 							description: "Hundredths of a second (1.230)",

+ 						},

+ 						{

+ 							value: 1,

+ 							description: "Tenths of a second (1.200)",

+ 						},

+ 						{

+ 							value: 0,

+ 							description: "Full seconds (1.000)",

+ 						},

+ 					],

+ 				},

+ 				{

+ 					ui_elem: "input-checkbox",

+ 					name: "randomize",

+ 					description: "Apply additional randomization after rounding (note that the random noise is influenced by the selected precision and consequently is more effective with lower time precision)",

+ 					data_type: "Boolean",

+ 					default: false,

  				},

  			],

  			wrappers: [
@@ -89,24 +105,30 @@ 

  		},

  		{

  			name: "htmlcanvaselement",

- 			label: "Localy rendered images",

- 			description: "Protect against canvas fingerprinting.",

+ 			description: "Protect against canvas fingerprinting",

  			description2: [

  				"Functions canvas.toDataURL(), canvas.toBlob(), CanvasRenderingContext2D.getImageData(), OffscreenCanvas.convertToBlob() return modified image data to prevent fingerprinting",

  				"CanvasRenderingContext2D.isPointInStroke() and CanvasRenderingContext2D.isPointInPath() are modified to lie with probability"

  			],

- 			params: [

- 				{

- 					short: "Little lies",

- 					description: "Alter image data based on domain hash",

- 					config: [0],

- 				},

- 				{

- 					short: "Strict",

- 					description: "Replace by white image",

- 					config: [1],

- 				},

- 			],

+ 			options: [

+ 				{

+ 				description: "farbling type",

+ 				ui_elem: "select",

+ 				name: "method",

+ 				default: 0,

+ 				data_type: "Number",

+ 				options: [

+ 					{

+ 						value: 0,

+ 						description: "Alter image data based on domain and session hashes",

+ 					},

+ 					{

+ 						value: 1,

+ 						description: "Replace by white image",

+ 					}

+ 				],

+ 			}

+ 		],

  			wrappers: [

  				// H-C

  				"CanvasRenderingContext2D.prototype.getImageData",
@@ -119,22 +141,28 @@ 

  		},

  		{

  			name: "audiobuffer",

- 			label: "Locally generated audio and audio card information",

- 			description: "Protect against audio fingerprinting, spoof details of your audio card.",

+ 			description: "Protect against audio fingerprinting",

  			description2: [

  				"Functions AudioBuffer.getChannelData(), AudioBuffer.copyFromChannel(), AnalyserNode.getByteTimeDomainData(), AnalyserNode.getFloatTimeDomainData(), AnalyserNode.getByteFrequencyData() and AnalyserNode.getFloatFrequencyData() are modified to alter audio data based on domain key"

  			],

- 			params: [

- 				{

- 					short: "Little lies",

- 					description: "Add amplitude noise based on domain hash",

- 					config: [0],

- 				},

- 				{

- 					short: "Strict",

- 					description: "Replace by white noise based on domain hash",

- 					config: [1],

- 				},

+ 			options: [

+ 				{

+ 					description: "farbling type",

+ 					ui_elem: "select",

+ 					name: "method",

+ 					default: 0,

+ 					data_type: "Number",

+ 					options: [

+ 						{

+ 							value: 0,

+ 							description: "Add amplitude noise based on domain hash",

+ 						},

+ 						{

+ 							value: 1,

+ 							description: "Replace by white noise based on domain hash",

+ 						}

+ 					],

+ 				}

  			],

  			wrappers: [

  				// AUDIO
@@ -148,25 +176,29 @@ 

  		},

  		{

  			name: "webgl",

- 			label: "Localy rendered images and graphic card information",

- 			description: "Protect against WEBGL fingerprinting, spoof details of your graphic card.",

+ 			description: "Protect against WEBGL fingerprinting",

  			description2: [

  				"Function WebGLRenderingContext.getParameter() returns modified/bottom values for certain parameters",

  				"WebGLRenderingContext functions .getFramebufferAttachmentParameter(), .getActiveAttrib(), .getActiveUniform(), .getAttribLocation(), .getBufferParameter(), .getProgramParameter(), .getRenderbufferParameter(), .getShaderParameter(), .getShaderPrecisionFormat(), .getTexParameter(), .getUniformLocation(), .getVertexAttribOffset(), .getSupportedExtensions() and .getExtension() return modified values",

  				"Function WebGLRenderingContext.readPixels() returns modified image data to prevent fingerprinting"

  		],

- 			params: [

- 				{

- 					short: "Little lies",

- 					description: "Generate random numbers/strings and modify canvas using domain hash",

- 					config: [0],

- 				},

- 				{

- 					short: "Strict",

- 					description: "Return bottom values (null, empty string), empty canvas",

- 					config: [1],

- 				},

- 			],

+ 			options: [{

+ 				description: "farbling type",

+ 				ui_elem: "select",

+ 				name: "method",

+ 				default: 0,

+ 				data_type: "Number",

+ 				options: [

+ 					{

+ 						value: 0,

+ 						description: "Generate random numbers/strings based on domain hash, modified canvas",

+ 					},

+ 					{

+ 						value: 1,

+ 						description: "Return bottom values (null, empty string), empty canvas",

+ 					}

+ 				],

+ 			}],

  			wrappers: [

  				// WEBGL

  				"WebGLRenderingContext.prototype.getParameter",
@@ -205,26 +237,29 @@ 

  		},

  		{

  			name: "plugins",

- 			label: "Installed browser plugins",

  			description: "Protect against plugin fingerprinting",

  			description2: [],

- 			params: [

- 				{

- 					short: "Little lies",

- 					description: "Edit current and add two fake plugins",

- 					config: [0],

- 				},

- 				{

- 					short: "Fake",

- 					description: "Return two fake plugins",

- 					config: [1],

- 				},

- 				{

- 					short: "Empty",

- 					description: "Return empty",

- 					config: [2],

- 				},

- 			],

+ 			options: [{

+ 				description: "farbling type",

+ 				ui_elem: "select",

+ 				name: "method",

+ 				default: 0,

+ 				data_type: "Number",

+ 				options: [

+ 					{

+ 						value: 0,

+ 						description: "Edit current and add two fake plugins",

+ 					},

+ 					{

+ 						value: 1,

+ 						description: "Return two fake plugins",

+ 					},

+ 					{

+ 						value: 2,

+ 						description: "Return empty"

+ 					}

+ 				],

+ 			}],

  			wrappers: [

  				// NP

  				"Navigator.prototype.plugins", // also modifies "Navigator.prototype.mimeTypes",
@@ -232,28 +267,31 @@ 

  		},

  		{

  			name: "enumerateDevices",

- 			label: "Connected cameras and microphones",

  			description: "Prevent fingerprinting based on the multimedia devices connected to the computer",

  			description2: [

  				"Function MediaDevices.enumerateDevices() is modified to return empty or modified result"

  		],

- 			params: [

- 				{

- 					short: "Little lies",

- 					description: "Randomize order",

- 					config: [0],

- 				},

- 				{

- 					short: "Add fake",

- 					description: "Add 0-4 fake devices and randomize order",

- 					config: [1],

- 				},

- 				{

- 					short: "Empty",

- 					description: "Return empty",

- 					config: [2],

- 				},

- 			],

+ 			options: [{

+ 				description: "farbling type",

+ 				ui_elem: "select",

+ 				name: "method",

+ 				default: 0,

+ 				data_type: "Number",

+ 				options: [

+ 					{

+ 						value: 0,

+ 						description: "Randomize order",

+ 					},

+ 					{

+ 						value: 1,

+ 						description: "Add 0-4 fake devices and randomize order",

+ 					},

+ 					{

+ 						value: 2,

+ 						description: "Return empty promise"

+ 					}

+ 				],

+ 			}],

  			wrappers: [

  				// MCS

  				"MediaDevices.prototype.enumerateDevices",
@@ -261,28 +299,31 @@ 

  		},

  		{

  			name: "hardware",

- 			label: "Device memory and CPU",

- 			description: "Spoof hardware information on the amount of RAM and CPU count.",

+ 			description: "Spoof hardware information to the most popular HW",

  			description2: [

  				"Getters navigator.deviceMemory and navigator.hardwareConcurrency return modified values",

  			],

- 			params: [

- 				{

- 					short: "Low",

- 					description: "Return random valid value between minimum and real value",

- 					config: [0],

- 				},

- 				{

- 					short: "Medium",

- 					description: "Return random valid value between minimum and 8",

- 					config: [1],

- 				},

- 				{

- 					short: "High",

- 					description: "Return 4 for navigator.deviceMemory and 2 for navigator.hardwareConcurrency",

- 					config: [2],

- 				},

- 			],

+ 			options: [{

+ 				description: "farbling type",

+ 				ui_elem: "select",

+ 				name: "method",

+ 				default: 0,

+ 				data_type: "Number",

+ 				options: [

+ 					{

+ 						value: 0,

+ 						description: "Return random valid value between minimum and real value",

+ 					},

+ 					{

+ 						value: 1,

+ 						description: "Return random valid value between minimum and 8.0",

+ 					},

+ 					{

+ 						value: 2,

+ 						description: "Return 4 for navigator.deviceMemory and 2 for navigator.hardwareConcurrency"

+ 					}

+ 				],

+ 			}],

  			wrappers: [

  				// HTML-LS

  				"Navigator.prototype.hardwareConcurrency",
@@ -292,19 +333,25 @@ 

  		},

  		{

  			name: "xhr",

- 			label: "XMLHttpRequest requests (XHR)",

- 			description: "Filter reliable XHR requests to server.",

- 			description2: ["Note that these requests are broadly employed for benign purposes and also note that Fetch, SSE, WebRTC, and WebSockets APIs are not blocked. All provide similar and some even better means of communication with server. For practical usage, we recommend activating Fingerprint Detector instead of XHR wrappers. JShelter keeps the wrapper as it is useful for some users mainly for experimental reasons."],

- 			params: [

- 				{

- 					short: "Ask",

- 					description: "Ask before executing an XHR request",

- 					config: [false, true],

- 				},

- 				{

- 					short: "Block",

- 					description: "Block all XMLHttpRequests",

- 					config: [true, false],

+ 			description: "Filter XMLHttpRequest requests",

+ 			description2: [],

+ 			options: [

+ 				{

+ 					ui_elem: "input-radio",

+ 					name: "behaviour",

+ 					data_type: "Boolean",

+ 					options: [

+ 						{

+ 							value: "block",

+ 							description: "Block all XMLHttpRequest.",

+ 							default: false,

+ 						},

+ 						{

+ 							value: "ask",

+ 							description: "Ask before executing an XHR request.",

+ 							default: true,

+ 						},

+ 					],

  				},

  			],

  			wrappers: [
@@ -315,19 +362,15 @@ 

  		},

  		{

  			name: "arrays",

- 			label: "ArrayBuffer",

- 			description: "Protect against ArrayBuffer exploitation, for example, to prevent side channel attacks on memory layout (or make them harder).",

+ 			description: "Protect against ArrayBuffer exploitation",

  			description2: [],

- 			params: [

+ 			options: [

  				{

- 					short: "Shift",

- 					description: "Shift indexes to make memory page boundaries detection harder",

- 					config: [false],

- 				},

- 				{

- 					short: "Randomize",

- 					description: "Use random mapping of array indexing to memory",

- 					config: [true],

+ 					ui_elem: "input-checkbox",

+ 					name: "mapping",

+ 					description: "Use random mapping of array indexing to memory.",

+ 					data_type: "Boolean",

+ 					default: false,

  				},

  			],

  			wrappers: [
@@ -345,19 +388,25 @@ 

  		},

  		{

  			name: "shared_array",

- 			label: "SharedArrayBuffer",

- 			description: "Protect against SharedArrayBuffer exploitation, for example, to prevent side channel attacks on memory layout (or make them harder).",

+ 			description: "Protect against SharedArrayBuffer exploitation:",

  			description2: [],

- 			params: [

- 				{

- 					short: "Medium",

- 					description: "Randomly slow messages to prevent high resolution timers",

- 					config: [false],

- 				},

- 				{

- 					short: "Strict",

- 					description: "Block SharedArrayBuffer",

- 					config: [true],

+ 			options: [

+ 				{

+ 					ui_elem: "input-radio",

+ 					name: "approach",

+ 					data_type: "Boolean",

+ 					options: [

+ 						{

+ 							value: "block",

+ 							description: "Block SharedArrayBuffer.",

+ 							default: true,

+ 						},

+ 						{

+ 							value: "polyfill",

+ 							description: "Randomly slow messages to prevent high resolution timers.",

+ 							default: false,

+ 						},

+ 					],

  				},

  			],

  			wrappers: [
@@ -367,19 +416,25 @@ 

  		},

  		{

  			name: "webworker",

- 			label: "WebWorker",

- 			description: "Protect against WebWorker exploitation, for example, to provide high resolution timers",

+ 			description: "Protect against WebWorker exploitation",

  			description2: [],

- 			params: [

- 				{

- 					short: "Medium",

- 					description: "Randomly slow messages to prevent high resolution timers",

- 					config: [false],

- 				},

- 				{

- 					short: "Strict",

- 					description: "Remove real parallelism, use WebWorker polyfill",

- 					config: [true],

+ 			options: [

+ 				{

+ 					ui_elem: "input-radio",

+ 					name: "approach",

+ 					data_type: "Boolean",

+ 					options: [

+ 						{

+ 							value: "polyfill",

+ 							description: "Remove real parallelism, use WebWorker polyfill.",

+ 							default: true,

+ 						},

+ 						{

+ 							value: "slow",

+ 							description: "Randomly slow messages to prevent high resolution timers.",

+ 							default: false,

+ 						},

+ 					],

  				},

  			],

  			wrappers: [
@@ -388,39 +443,45 @@ 

  		},

  		{

  			name: "geolocation",

- 			label: "Physical location (geolocation)",

- 			description: "Limit the information on real-world position provided by Geolocation API.",

+ 			description: "Geolocation API wrapping",

  			description2: [],

- 			params: [

- 				{

- 					short: "Timestamp-only",

- 					description: "Provide accurate data (use when you really need to provide exact location and you want to protect geolocation timestamps)",

- 					config: [-1],

- 				},

- 				{

- 					short: "Village",

- 					description: "Use accuracy of hundreds of meters",

- 					config: [2],

- 				},

- 				{

- 					short: "Town",

- 					description: "Use accuracy of kilometers",

- 					config: [3],

- 				},

- 				{

- 					short: "Region",

- 					description: "Use accuracy of tens of kilometers",

- 					config: [4],

- 				},

- 				{

- 					short: "Long distance",

- 					description: "Use accuracy of hundreds of kilometers",

- 					config: [5],

- 				},

- 				{

- 					short: "Strict",

- 					description: "Turn location services off",

- 					config: [0],

+ 			options: [

+ 				{

+ 					description: "Location obfuscation",

+ 					ui_elem: "select",

+ 					name: "locationObfuscationType",

+ 					default: 0,

+ 					data_type: "Number",

+ 					options: [

+ 						{

+ 							value: 0,

+ 							description: "Turn location services off",

+ 						},

+ 						//{

+ 						//	value: 1,

+ 						//	description: "Use the position below",

+ 						//},

+ 						{

+ 							value: 2,

+ 							description: "Use accuracy of hundreds of meters",

+ 						},

+ 						{

+ 							value: 3,

+ 							description: "Use accuracy of kilometers",

+ 						},

+ 						{

+ 							value: 4,

+ 							description: "Use accuracy of tens of kilometers",

+ 						},

+ 						{

+ 							value: 5,

+ 							description: "Use accuracy of hundreds of kilometers",

+ 						},

+ 						{

+ 							value: -1,

+ 							description: "Provide accurate data (use when you really need to provide exact location)",

+ 						},

+ 					],

  				},

  			],

  			wrappers: [
@@ -437,14 +498,15 @@ 

  		},

      {

  			name: "physical_environment",

- 			label: "Physical environement sensors",

- 			description: "Limit the information provided by physical environment sensors like Magnetometer or Accelerometer.",

+ 			description: "Wrapping APIs for scanning properties of the physical environment",

  			description2: [],

- 			params: [

+ 			options: [

  				{

- 					short: "High",

- 					description: "Emulate stationary device based on domain hash",

- 					config: [true],

+           name: "emulateStationaryDevice",

+           description: "Emulate stationary device",

+           data_type: "Boolean",

+           ui_elem: "input-checkbox",

+           default: true,

  				},

  			],

  			wrappers: [
@@ -460,30 +522,18 @@ 

          "Accelerometer.prototype.y",

          "Accelerometer.prototype.z",

  

-         // Gyroscope

-         "Gyroscope.prototype.x",

-         "Gyroscope.prototype.y",

-         "Gyroscope.prototype.z",

- 

-         // AbsoluteOrientationSensor and RelativeOrientationSensor

-         "OrientationSensor.prototype.quaternion",

- 

-         // AmbientLightSensor

-         "AmbientLightSensor.prototype.illuminance"

+         // Here, we will add references to other GenericSensorAPI

+         // sensor wrappers (DeviceOrientationSensor, AmbientLightSensor,

+         // ProximitySensor, ...)

+         // We should also decide whether Bluetooth / NFC belongs here

  			],

  		},

  		{

  			name: "gamepads",

- 			label: "Gamepads",

- 			description: "Prevent websites from accessing and learning information on local gamepads.",

+ 			description: "Prevent websites from learning information on local gamepads",

  			description2: [],

- 			params: [

- 				{

- 					short: "Strict",

- 					description: "Hide all gamepads",

- 					config: [true],

- 				},

- 			],

+ 			default: true,

+ 			options: [],

  			wrappers: [

  				// GAMEPAD

  				"Navigator.prototype.getGamepads",
@@ -491,16 +541,10 @@ 

  		},

  		{

  			name: "vr",

- 			label: "Virtual and augmented reality devices",

- 			description: "Prevent websites from accessing and learning information on local virtual and augmented reality displays.",

+ 			description: "Prevent websites from learning information on local Virtual Reality displays",

  			description2: [],

- 			params: [

- 				{

- 					short: "Strict",

- 					description: "Hide all devices",

- 					config: [],

- 				},

- 			],

+ 			default: true,

+ 			options: [],

  			wrappers: [

  				// VR

  				"Navigator.prototype.activeVRDisplays",
@@ -510,16 +554,10 @@ 

  		},

  		{

  			name: "analytics",

- 			label: "Unreliable transfers to server (beacons)",

- 			description: "Prevent unreliable transfers to server (beacons).",

- 			description2: ["Such transfers are typically misused for analytics but occassionally may be used by e-shops or other pages.", "Prevent sending information through Beacon API."],

- 			params: [

- 				{

- 					short: "Disabled",

- 					description: "The wrapper performs no action",

- 					config: [],

- 				},

- 			],

+ 			description: "Prevent sending analytics through Beacon API",

+ 			description2: [],

+ 			default: true,

+ 			options: [],

  			wrappers: [

  				// BEACON

  				"Navigator.prototype.sendBeacon",
@@ -527,16 +565,10 @@ 

  		},

  		{

  			name: "battery",

- 			label: "Hardware battery",

  			description: "Disable Battery status API",

  			description2: [],

- 			params: [

- 				{

- 					short: "Disabled",

- 					description: "Disable the API",

- 					config: [],

- 				},

- 			],

+ 			default: true,

+ 			options: [],

  			wrappers: [

  				// BATTERY

  				"Navigator.prototype.getBattery",
@@ -545,16 +577,10 @@ 

  		},

  		{

  			name: "windowname",

- 			label: "Persistent identifier of the browser tab",

- 			description: "Clear window.name value on the webpage loading.",

- 			description2: ["This API might be occasionally used for benign purposes.", "This API provides a possibility to detect cross-site browsing in one tab and broser session."],

- 			params: [

- 				{

- 					short: "Strict",

- 					description: "Clear during page reload",

- 					config: [],

- 				},

- 			],

+ 			description: "Clear window.name value on the webpage loading",

+ 			description2: [],

+ 			default: true,

+ 			options: [],

  			wrappers: [

  				// WINDOW-NAME

  				"window.name",
@@ -601,14 +627,32 @@ 

  /// Automatically populate infered metadata in wrapping_groups.

  wrapping_groups.groups.forEach(function (group) {

  	group.id = group.name;

- 	if (!are_all_api_unsupported(group.wrappers)) {

- 		wrapping_groups.group_names.push(group.name);

- 		wrapping_groups.empty_level[group.id] = 0;

- 	}

- 	wrapping_groups.group_map[group.id] = group

- 	for (wrapper_name of group.wrappers) {

- 		wrapping_groups.wrapper_map[wrapper_name] = group.name;

- 	}

+ 	group.data_type = "Boolean";

+ 	group.ui_elem = "input-checkbox";

+ 	wrapping_groups.empty_level[group.id] = are_all_api_unsupported(group.wrappers) ? true : Boolean(group.default);

+ 	wrapping_groups.option_map[group.id] = group

+ 	wrapping_groups.associated_params[group.id] = [];

+ 	group.options.forEach((function (gid, option) {

+ 		option.id = `${gid}_${option.name}`;

+ 		if (option.default !== undefined) {

+ 			wrapping_groups.empty_level[option.id] = option.default;

+ 			wrapping_groups.associated_params[group.id].push(option.id);

+ 		}

+ 		wrapping_groups.option_map[option.id] = option;

+ 		if (option.options !== undefined) {

+ 			option.options.forEach((function (oid, choice) {

+ 				choice.id = `${oid}_${choice.value}`;

+ 				if (choice.default !== undefined) {

+ 					wrapping_groups.empty_level[choice.id] = choice.default;

+ 					wrapping_groups.associated_params[group.id].push(choice.id);

+ 				}

+ 				if (choice.ui_elem === undefined && option.ui_elem !== undefined) {

+ 					choice.ui_elem = option.ui_elem;

+ 				}

+ 				wrapping_groups.option_map[choice.id] = choice;

+ 			}).bind(null, option.id));

+ 		}

+ 	}).bind(null, group.id));

  });

  

  // *****************************************************************************
@@ -619,83 +663,110 @@ 

  const L1 = "1";

  const L2 = "2";

  const L3 = "3";

- const L_EXPERIMENTAL = "Experiment"; // Use a long ID so that it is not in conflict with pre0.7 user-defined levels

  

  /// Built-in levels

  var level_0 = {

  	"builtin": true,

  	"level_id": L0,

- 	"level_text": "Turn JavaScript Shield off",

- 	"level_description": "JavaScript APIs are not wrapped. Use this level if you trust the oprator of the visited page(s) or if you do not like JavaScript Shield but apply other protection mechanisms.",

+ 	"level_text": "Turn wrappers off",

+ 	"level_description": "No protection at all",

+ };

+ 

+ var level_1 = {

+ 	"builtin": true,

+ 	"level_id": L1,

+ 	"level_text": "Minimal",

+ 	"level_description": "Minimal level of protection",

+ 	"time_precision": true,

+ 	"time_precision_precision": 2,

+ 	"time_precision_randomize": false,

+ 	"hardware": true,

+ 	"hardware_method": 0,

+ 	"battery": true,

+ 	"plugins": true,

+ 	"plugins_method": 0,

+ 	"geolocation": true,

+ 	"geolocation_locationObfuscationType": 2,

+ 	"analytics": true,

+ 	"windowname": true,

+   "physical_environment": true,

+   "physical_environment_emulateStationaryDevice": true,

  };

  

  var level_2 = {

  	"builtin": true,

  	"level_id": L2,

  	"level_text": "Recommended",

- 	"level_description": "Make the browser appear differently to distinct fingerprinters. Apply security counter-measures that are likely not to break web pages. Slightly modify the results of API calls in different way on different domains so that the cross-site fingerprint is not stable. The generated fingerprint values also differ with each browser restart. If you need a different fingerprint for the same website without restart, use incognito mode. Keep in mind that even if you log out from a site, clear your cookies, change your IP address, the modified APIs will provide a way to compute the same fingerprint. Restart your browser if you want to change your fingerprint. If in doubt, use this level.",

- 	"time_precision": 3,

- 	"htmlcanvaselement": 1,

- 	"audiobuffer": 1,

- 	"webgl": 1,

- 	"plugins": 2,

- 	"enumerateDevices": 2,

- 	"hardware": 1,

- 	"geolocation": 3,

-   "physical_environment": 1,

- 	"gamepads": 1,

- 	"vr": 1,

- 	"analytics": 1,

- 	"battery": 1,

- 	"windowname": 1,

+ 	"level_description": "Recommended level of protection for most sites",

+ 	"time_precision": true,

+ 	"time_precision_precision": 1,

+ 	"time_precision_randomize": false,

+ 	"hardware": true,

+ 	"hardware_method": 0,

+ 	"battery": true,

+ 	"htmlcanvaselement": true,

+ 	"htmlcanvaselement_method": 0,

+ 	"audiobuffer": true,

+ 	"audiobuffer_method": 0,

+ 	"webgl": true,

+ 	"webgl_method": 0,

+ 	"plugins": true,

+ 	"plugins_method": 1,

+ 	"enumerateDevices": true,

+ 	"enumerateDevices_method": 1,

+ 	"geolocation": true,

+ 	"geolocation_locationObfuscationType": 3,

+ 	"gamepads": true,

+ 	"vr": true,

+ 	"analytics": true,

+ 	"windowname": true,

+   "physical_environment": true,

+   "physical_environment_emulateStationaryDevice": true,

  };

  

  var level_3 = {

  	"builtin": true,

  	"level_id": L3,

- 	"level_text": "Strict",

- 	"level_description": "Enable all non-experimental protection. The wrapped APIs return fake values. Some APIs are blocked completely, others provide meaningful but rare values. Some return values are meaningless. This level will make you fingerprintable because the results of API calls are generally modified in the same way on all webistes and in each session. Use this level if you want to limit the information provided by your browser. If you are worried about fingerprinters, make sure the Fingerprint Detector is activated.",

- 	"time_precision": 3,

- 	"htmlcanvaselement": 2,

- 	"audiobuffer": 2,

- 	"webgl": 2,

- 	"plugins": 3,

- 	"enumerateDevices": 3,

- 	"hardware": 3,

- 	"webworker": 2,

- 	"geolocation": 6,

-   "physical_environment": 1,

- 	"gamepads": 1,

- 	"vr": 1,

- 	"analytics": 1,

- 	"battery": 1,

- 	"windowname": 1,

+ 	"level_text": "High",

+ 	"level_description": "High level of protection",

+ 	"time_precision": true,

+ 	"time_precision_precision": 0,

+ 	"time_precision_randomize": true,

+ 	"hardware": true,

+ 	"hardware_method": 2,

+ 	"battery": true,

+ 	"htmlcanvaselement": true,

+ 	"htmlcanvaselement_method": 1,

+ 	"audiobuffer": true,

+ 	"audiobuffer_method": 1,

+ 	"webgl": true,

+ 	"webgl_method": 1,

+ 	"plugins": true,

+ 	"plugins_method": 2,

+ 	"enumerateDevices": true,

+ 	"enumerateDevices_method": 2,

+ 	"xhr": true,

+ 	"xhr_behaviour_block": false,

+ 	"xhr_behaviour_ask": true,

+ 	"arrays": true,

+ 	"arrays_mapping": true,

+ 	"shared_array": true,

+ 	"shared_array_approach_block": true,

+ 	"shared_array_approach_polyfill": false,

+ 	"webworker": true,

+ 	"webworker_approach_polyfill": true,

+ 	"webworker_approach_slow": false,

+ 	"geolocation": true,

+ 	"geolocation_locationObfuscationType": 0,

+ 	"gamepads": true,

+ 	"vr": true,

+ 	"analytics": true,

+ 	"windowname": true,

+   "physical_environment": true,

+   "physical_environment_emulateStationaryDevice": true,

  };

  

- var level_experimental = {

- 	"builtin": true,

- 	"level_id": L_EXPERIMENTAL,

- 	"level_text": "Experimental",

- 	"level_description": "Strict level protections with additional wrappers enabled (including APIs known to regularly break webpages and APIs that do not work perfectly). Use this level if you want to experiment with JShelter. Use Recommended or Strict level with active Fingerprint Detector for your regular activities.",

- 	"time_precision": 3,

- 	"htmlcanvaselement": 2,

- 	"audiobuffer": 2,

- 	"webgl": 2,

- 	"plugins": 3,

- 	"enumerateDevices": 3,

- 	"hardware": 3,

- 	"xhr": 1,

- 	"arrays": 2,

- 	"shared_array": 2,

- 	"webworker": 2,

- 	"geolocation": 6,

-   "physical_environment": 1,

- 	"gamepads": 1,

- 	"vr": 1,

- 	"analytics": 1,

- 	"battery": 1,

- 	"windowname": 1,

- };

+ const BUILTIN_LEVEL_NAMES = [L0, L1, L2, L3];

  

  var levels = {};

  var default_level = {};
@@ -704,9 +775,9 @@ 

  function init_levels() {

  	levels = {

  		[level_0.level_id]: level_0,

+ 		[level_1.level_id]: level_1,

  		[level_2.level_id]: level_2,

- 		[level_3.level_id]: level_3,

- 		[level_experimental.level_id]: level_experimental

+ 		[level_3.level_id]: level_3

  	};

  	default_level = Object.create(levels[L2]);

  	default_level.level_text = "Default";
@@ -741,24 +812,31 @@ 

  	}

  	default_level.is_default = true;

  	var new_domains = res["domains"] || {};

- 	for (let [d, {level_id, tweaks, restore, restore_tweaks}] of Object.entries(new_domains)) {

+ 	for (let [d, {level_id, tweaks}] of Object.entries(new_domains)) {

  		let level = levels[level_id];

  		if (level === undefined) {

  			domains[d] = default_level;

- 		}

- 		else {

- 			if (tweaks) {

- 				// this domain has "tweaked" wrapper groups from other levels, let's merge them

- 				level = Object.assign({}, level, tweaks);

- 				level.tweaks = tweaks;

- 				delete level.wrappers; // we will lazy instantiate them on demand in getCurrentLevelJSON()

- 			}

- 			if (restore) {

- 				level.restore = restore;

- 				if (restore_tweaks) {

- 					level.restore_tweaks = restore_tweaks;

+ 		} else if (tweaks) {

+ 			// this domain has "tweaked" wrapper groups from other levels, let's merge them

+ 			level = Object.assign({tweaks}, level);

+ 			for ([group, tlev_id] of Object.entries(tweaks)) {

+ 				if (tlev_id === level_id) {

+ 					// redundant tweak: same level

+ 					delete tweaks[group];

+ 					continue;

+ 				}

+ 				// cleanup original group settings for this level

+ 				delete level[group];

+ 				let prefix = `${group}_`;

+ 				for (let key of Object.keys(level).filter(k => k.startsWith(prefix))) delete[key];

+ 				// now copy the group settings from the tweak level

+ 				let tweakLevel = levels[tlev_id];

+ 				if (tweakLevel[group]) {

+ 					level[group] = tweakLevel[group];

+ 					for (let key of Object.keys(tweakLevel).filter(k => k.startsWith(prefix))) level[key] = tweakLevel[key];

  				}

  			}

+ 			delete level.wrappers; // we will lazy instantiate them on demand in getCurrentLevelJSON()

  		}

  		domains[d] = level;

  	}
@@ -781,27 +859,17 @@ 

  function saveDomainLevels() {

  	tobesaved = {};

  	for (k in domains) {

- 		let {level_id, tweaks, restore, restore_tweaks} = domains[k];

+ 		let {level_id, tweaks} = domains[k];

  		if (k[k.length - 1] === ".") {

  			k = k.substring(0, k.length-1);

  		}

  		if (tweaks) {

- 			for (let [group, param] of Object.entries(tweaks)) {

- 				if (param === (levels[level_id][group] || 0)) {

- 					delete tweaks[group]; // remove redundant entries

- 				}

- 			}

- 			if (Object.keys(tweaks).length === 0) {

- 				tweaks = undefined;

+ 			for (let [group, tlev_id] of Object.entries(tweaks)) {

+ 				if (tlev_id === level_id) delete tweaks[group]; // remove redundant entries

  			}

+ 			if (Object.keys(tweaks).length === 0) delete tweaks;

  		}

  		tobesaved[k] = tweaks ? {level_id, tweaks} : {level_id};

- 		if (restore) {

- 			tobesaved[k].restore = restore;

- 			if (restore_tweaks) {

- 				tobesaved[k].restore_tweaks = restore_tweaks;

- 			}

- 		}

  	}

  	browser.storage.sync.set({domains: tobesaved});

  }
@@ -820,14 +888,3 @@ 

  	}

  	return [default_level, wrapped_codes[default_level.level_id]];

  }

- 

- function getTweaksForLevel(level_id, tweaks_obj) {

- 	tweaks_obj = tweaks_obj || {}; // Make sure that tweaks_obj is an object

- 	let working = Object.assign({}, wrapping_groups.empty_level, levels[level_id], tweaks_obj);

- 	Object.keys(working).forEach(function(key) {

- 		if (!wrapping_groups.group_names.includes(key)) {

- 			delete working[key];

- 		}

- 	});

- 	return working;

- }

file modified
+5 -4
@@ -31,9 +31,10 @@ 

  //  \copyright Copyright (c) 2020 The Brave Authors.

  

  /** \file

-  * This file contains wrappers for NavigatorPlugins. See the MDN docs on the [plugins](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins/plugins)

-  * and [MIME types](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins/mimeTypes).

+  * This file contains wrappers for NavigatorPlugins

   *

+  *   * https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins/plugins

+  *   * https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins/mimeTypes

   * \ingroup wrappers

   *

   * The goal is to prevent fingerprinting by modifying value returned by getters navigator.plugins and navigator.mimeTypes
@@ -44,8 +45,8 @@ 

   *	 * (1) - replace by shuffled PluginArray with two fake plugins, empty MimeTypeArray

   *	 * (2) - replace by empty PluginArray and MimeTypeArray

   *

-  * These approaches are inspired by the algorithms created by [Brave Software](https://brave.com)

-  * available [here](https://github.com/brave/brave-core/blob/master/chromium_src/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc).

+  * These approaches are inspired by the algorithms created by Brave Software <https://brave.com>

+  * available at https://github.com/brave/brave-core/blob/master/chromium_src/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc

   *

   */

  

@@ -35,7 +35,7 @@ 

      # Browsers in which tests will be run.

      tested_browsers = [BrowserType.CHROME, BrowserType.FIREFOX]

      # Default levels of JShelter which will be tested.

-     tested_jsr_levels = [0, 1, 2, 3]

+     tested_jsr_levels = [0, 2, 3, "Experiment"]

  

  

  

@@ -54,3 +54,7 @@ 

          return values_expected.level3

      elif get_shared_browser().jsr_level == 4:

          return values_expected.level4

+     elif get_shared_browser().jsr_level == "Experiment":

+         return values_expected.level3

+     else:

+         return values_expected.level3

tests/integration_tests/testing/tests_definition/test_01_hw.py tests/integration_tests/testing/tests_definition/test_hw.py
file renamed
file was moved with no change to the file
tests/integration_tests/testing/tests_definition/test_04_NBS_setting.py tests/integration_tests/testing/tests_definition/test_NBS_setting.py
file renamed
+63 -56
@@ -1,56 +1,63 @@ 

- #

- #  JShelter is a browser extension which increases level

- #  of security, anonymity and privacy of the user while browsing the

- #  internet.

- #

- #  Copyright (C) 2021  Martin Bednar

- #

- # SPDX-License-Identifier: GPL-3.0-or-later

- #

- #  This program is free software: you can redistribute it and/or modify

- #  it under the terms of the GNU General Public License as published by

- #  the Free Software Foundation, either version 3 of the License, or

- #  (at your option) any later version.

- #

- #  This program is distributed in the hope that it will be useful,

- #  but WITHOUT ANY WARRANTY; without even the implied warranty of

- #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- #  GNU General Public License for more details.

- #

- #  You should have received a copy of the GNU General Public License

- #  along with this program.  If not, see <https://www.gnu.org/licenses/>.

- #

- 

- import pytest

- from selenium.webdriver.common.by import By

- from time import sleep

- 

- 

- def switch_NBS_setting(browser):

-     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/popup.html"))

-     browser.driver.find_elements(By.CLASS_NAME, 'switch')[0].click()

-     sleep(1)

- 

- 

- def get_NBS_setting(browser):

-     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/popup.html"))

-     sleep(1)

-     return(browser.driver.execute_script("return window.getComputedStyle(document.querySelector('#shield-switch + .slider'),':before').getPropertyValue('content')"))

- 

- 

- ## Test turnning NBS off in popup.

- ## Sleep 0.5 second to changes take effect.

- def test_switching_NBS(browser):

-     NBS_setting_values = ['"ON"', '"OFF"']

-     

-     original_setting = get_NBS_setting(browser)

-     original_setting_index = NBS_setting_values.index(original_setting)

-     

-     # Range is saing how many times should NBS be switched.

-     for i in range(4):

-         switch_NBS_setting(browser)

-         assert get_NBS_setting(browser) == NBS_setting_values[(i + 1 + original_setting_index) % 2]

-     

-     # Return original value

-     if get_NBS_setting(browser) != original_setting:

-         switch_NBS_setting(browser)

+ #

+ #  JShelter is a browser extension which increases level

+ #  of security, anonymity and privacy of the user while browsing the

+ #  internet.

+ #

+ #  Copyright (C) 2021  Martin Bednar

+ #

+ # SPDX-License-Identifier: GPL-3.0-or-later

+ #

+ #  This program is free software: you can redistribute it and/or modify

+ #  it under the terms of the GNU General Public License as published by

+ #  the Free Software Foundation, either version 3 of the License, or

+ #  (at your option) any later version.

+ #

+ #  This program is distributed in the hope that it will be useful,

+ #  but WITHOUT ANY WARRANTY; without even the implied warranty of

+ #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ #  GNU General Public License for more details.

+ #

+ #  You should have received a copy of the GNU General Public License

+ #  along with this program.  If not, see <https://www.gnu.org/licenses/>.

+ #

+ 

+ import pytest

+ from selenium.webdriver.common.by import By

+ from time import sleep

+ from web_browser_type import BrowserType

+ 

+ 

+ def switch_NBS_setting(browser):

+     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/popup.html"))

+     sleep(1)

+     browser.driver.find_elements(By.CLASS_NAME, 'slider')[1].click()

+     sleep(1)

+ 

+ 

+ def get_NBS_setting(browser):

+     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/popup.html"))

+     sleep(2)

+     return(browser.driver.execute_script("return window.getComputedStyle(document.querySelector('#nbs_whitelist .switch_wrapper .switch .slider'),':before').getPropertyValue('content')"))

+ 

+ 

+ ## Test turnning NBS off in popup.

+ ## Sleep 0.5 second to changes take effect.

+ def test_switching_NBS(browser):

+     if browser.type == BrowserType.CHROME:

+         # Not able to test NBS switch in Google Chrome.

+         # Can not show popup.html in Chrome. Popup.html is not accesible and testable.

+         assert True

+         return()

+     NBS_setting_values = ['"ON"', '"OFF"']

+     

+     original_setting = get_NBS_setting(browser)

+     original_setting_index = NBS_setting_values.index(original_setting)

+     

+     # Range is saing how many times should NBS be switched.

+     for i in range(4):

+         switch_NBS_setting(browser)

+         assert get_NBS_setting(browser) == NBS_setting_values[(i + 1 + original_setting_index) % 2]

+     

+     # Return original value

+     if get_NBS_setting(browser) != original_setting:

+         switch_NBS_setting(browser)

tests/integration_tests/testing/tests_definition/test_05_domain_level_setting.py tests/integration_tests/testing/tests_definition/test_domain_level_setting.py
file renamed
+79 -79
@@ -1,79 +1,79 @@ 

- #

- #  JShelter is a browser extension which increases level

- #  of security, anonymity and privacy of the user while browsing the

- #  internet.

- #

- #  Copyright (C) 2021  Martin Bednar

- #

- # SPDX-License-Identifier: GPL-3.0-or-later

- #

- #  This program is free software: you can redistribute it and/or modify

- #  it under the terms of the GNU General Public License as published by

- #  the Free Software Foundation, either version 3 of the License, or

- #  (at your option) any later version.

- #

- #  This program is distributed in the hope that it will be useful,

- #  but WITHOUT ANY WARRANTY; without even the implied warranty of

- #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- #  GNU General Public License for more details.

- #

- #  You should have received a copy of the GNU General Public License

- #  along with this program.  If not, see <https://www.gnu.org/licenses/>.

- #

- 

- import pytest

- from selenium.webdriver.common.by import By

- from selenium.webdriver.support.select import Select

- import random

- 

- 

- domains = ["messenger.com", "email.seznam.cz", "facebook.com", "www.fit.vutbr.cz"]

- levels = ['0', '1', '2', '3']

- 

- 

- def set_domain_level(browser, domain, level):

-     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

-     browser.driver.find_elements(By.ID, 'domain-text')[0].send_keys(domain)

-     select = Select(browser.driver.find_elements(By.ID, 'domain-level')[0])

-     select.select_by_value(level)

-     browser.driver.find_elements(By.ID, 'add_domain')[0].click()

- 

- 

- def unset_domain_level(browser, domain):

-     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

-     browser.driver.find_elements(By.ID, 'delete-dl-' + domain)[0].click()

- 

- def change_domain_level(browser, domain, level):

-     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

-     select = Select(browser.driver.find_elements(By.ID, 'dl-change-' + domain)[0])

-     select.select_by_value(level)

-     browser.driver.find_elements(By.ID, 'overwrite-dl-' + domain)[0].click()

- 

- 

- def get_domain_level(browser, domain):

-     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

-     select = Select(browser.driver.find_elements(By.ID, 'dl-change-' + domain)[0])

-     selected_option = select.first_selected_option

-     return selected_option.get_attribute("value")

-     

- 

- 

- ## Test setting a level for the selected domains.

- def test_setting_domain_level(browser):

-     for i in range(len(domains)):

-         domain = domains[i]

-         level = random.choice(levels)

-         set_domain_level(browser, domain, level)

-         assert get_domain_level(browser, domain) == level

- 

- 

- ## Test changing a level for the selected domains.

- def test_change_domain_level(browser):

-     for i in range(len(domains)):

-         domain = domains[i]

-         level = random.choice(levels)

-         change_domain_level(browser, domain, level)

-         assert get_domain_level(browser, domain) == level

-         

-         # Tear down.

-         unset_domain_level(browser, domain)

+ #

+ #  JShelter is a browser extension which increases level

+ #  of security, anonymity and privacy of the user while browsing the

+ #  internet.

+ #

+ #  Copyright (C) 2021  Martin Bednar

+ #

+ # SPDX-License-Identifier: GPL-3.0-or-later

+ #

+ #  This program is free software: you can redistribute it and/or modify

+ #  it under the terms of the GNU General Public License as published by

+ #  the Free Software Foundation, either version 3 of the License, or

+ #  (at your option) any later version.

+ #

+ #  This program is distributed in the hope that it will be useful,

+ #  but WITHOUT ANY WARRANTY; without even the implied warranty of

+ #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ #  GNU General Public License for more details.

+ #

+ #  You should have received a copy of the GNU General Public License

+ #  along with this program.  If not, see <https://www.gnu.org/licenses/>.

+ #

+ 

+ import pytest

+ from selenium.webdriver.common.by import By

+ from selenium.webdriver.support.select import Select

+ import random

+ 

+ 

+ domains = ["messenger.com", "email.seznam.cz", "facebook.com", "www.fit.vutbr.cz"]

+ levels = ['0', '2', '3', 'Experiment']

+ 

+ 

+ def set_domain_level(browser, domain, level):

+     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

+     browser.driver.find_elements(By.ID, 'domain-text')[0].send_keys(domain)

+     select = Select(browser.driver.find_elements(By.ID, 'domain-level')[0])

+     select.select_by_value(level)

+     browser.driver.find_elements(By.ID, 'add_domain')[0].click()

+ 

+ 

+ def unset_domain_level(browser, domain):

+     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

+     browser.driver.find_elements(By.ID, 'delete-dl-' + domain)[0].click()

+ 

+ def change_domain_level(browser, domain, level):

+     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

+     select = Select(browser.driver.find_elements(By.ID, 'dl-change-' + domain)[0])

+     select.select_by_value(level)

+     browser.driver.find_elements(By.ID, 'overwrite-dl-' + domain)[0].click()

+ 

+ 

+ def get_domain_level(browser, domain):

+     browser.driver.get(browser._jsr_options_page.replace("/options.html", "/options_domains.html"))

+     select = Select(browser.driver.find_elements(By.ID, 'dl-change-' + domain)[0])

+     selected_option = select.first_selected_option

+     return selected_option.get_attribute("value")

+     

+ 

+ 

+ ## Test setting a level for the selected domains.

+ def test_setting_domain_level(browser):

+     for i in range(len(domains)):

+         domain = domains[i]

+         level = random.choice(levels)

+         set_domain_level(browser, domain, level)

+         assert get_domain_level(browser, domain) == level

+ 

+ 

+ ## Test changing a level for the selected domains.

+ def test_change_domain_level(browser):

+     for i in range(len(domains)):

+         domain = domains[i]

+         level = random.choice(levels)

+         change_domain_level(browser, domain, level)

+         assert get_domain_level(browser, domain) == level

+         

+         # Tear down.

+         unset_domain_level(browser, domain)

tests/integration_tests/testing/tests_definition/test_06_canvas.py tests/integration_tests/testing/tests_definition/test_canvas.py
file renamed
file was moved with no change to the file
tests/integration_tests/testing/tests_definition/test_07_navigator.py tests/integration_tests/testing/tests_definition/test_navigator.py
file renamed
+11 -5
@@ -1,10 +1,10 @@ 

  #

- #  JShelter is a browser extension which increases level

+ #  JavaScript Restrictor is a browser extension which increases level

  #  of security, anonymity and privacy of the user while browsing the

  #  internet.

  #

- #  Copyright (C) 2020  Martin Bednar

  #  Copyright (C) 2021  Matus Svancar

+ #  Copyright (C) 2022  Martin Bednar

  #

  # SPDX-License-Identifier: GPL-3.0-or-later

  #
@@ -109,7 +109,9 @@ 

  

  ## Test plugins count

  def test_plugins_count(browser, navigator, expected):

-     if expected.navigator.plugins['count'][browser.type] == 'REAL VALUE':

+     if expected.navigator.plugins['count'][browser.type] == 'IGNORE':

+         return

+     elif expected.navigator.plugins['count'][browser.type] == 'REAL VALUE':

          assert len(navigator['plugins']) == len(browser.real.navigator.plugins)

      elif expected.navigator.plugins['count'][browser.type] == 'PLUS_2':

          assert len(navigator['plugins']) == len(browser.real.navigator.plugins) + 2
@@ -118,7 +120,9 @@ 

  

  ## Test plugins array value

  def test_plugins(browser, navigator, expected):

-     if expected.navigator.plugins['value'][browser.type] == 'REAL VALUE':

+     if expected.navigator.plugins['count'][browser.type] == 'IGNORE':

+         return

+     elif expected.navigator.plugins['value'][browser.type] == 'REAL VALUE':

          assert navigator['plugins'] == browser.real.navigator.plugins

      elif expected.navigator.plugins['value'][browser.type] == 'EMPTY':

          assert not navigator['plugins']
@@ -127,7 +131,9 @@ 

  

  ## Test mimeTypes

  def test_mime_types(browser, navigator, expected):

-     if expected.navigator.mimeTypes == 'EMPTY':

+     if expected.navigator.mimeTypes == 'IGNORE':

+         return

+     elif expected.navigator.mimeTypes == 'EMPTY':

          assert navigator['mimeTypes'] == []

      elif expected.navigator.mimeTypes == 'SPOOF VALUE':

          if browser.real.navigator.mimeTypes == []:

tests/integration_tests/testing/tests_definition/test_08_performance.py tests/integration_tests/testing/tests_definition/test_performance.py
file renamed
file was moved with no change to the file
tests/integration_tests/testing/tests_definition/test_09_ECMA_arrays.py tests/integration_tests/testing/tests_definition/test_referrer.py
file renamed
+18 -13
@@ -3,7 +3,7 @@ 

  #  of security, anonymity and privacy of the user while browsing the

  #  internet.

  #

- #  Copyright (C) 2020  Martin Bednar

+ #  Copyright (C) 2022  Martin Bednar

  #

  # SPDX-License-Identifier: GPL-3.0-or-later

  #
@@ -22,22 +22,27 @@ 

  #

  

  import pytest

+ from selenium.webdriver.common.by import By

  

- from values_getters import get_referrer

+ from configuration import get_config

  

- 

- ## Setup method - it is run before referrer test execution starts.

+ ## Setup method - it is run before time tests execution starts.

  #

- #  This setup method initialize variable referrer that contains current data about referrer and

- #  this variable is provided to referrer test and value in referrer variable is compared with expected values.

+ #  This setup method open testing page.

  @pytest.fixture(scope='module', autouse=True)

- def referrer(browser):

-     return get_referrer(browser.driver)

+ def load_test_page(browser):

+     browser.driver.get(get_config("testing_page"))

  

  

- ## Test referrer - where the page was navigated from.

- def test_referrer(browser, referrer, expected):

-     if expected.referrer == 'REAL VALUE':

-         assert referrer == browser.real.referrer

+ ## Test crypto.getRandomValues.

+ #  Random values should be generated. No error in Javascript runtime should appear.

+ # \bug Known bug: JShelter, Firefox, level 3: Uncaught TypeError: Crypto.getRandomValues: Argument 1 does not implement interface ArrayBufferView.

+ # Bug is caused by passing a proxy object to the function, but the actual object is expected (not the proxy).

+ @pytest.mark.xfail

+ def test_crypto_getRandomValues(browser):

+     ul = browser.driver.find_element(By.ID,"getRandomValues")

+     if len(ul.text) > 0:

+         items = ul.find_elements(By.TAG_NAME,"li")

+         assert len(items) > 0

      else:

-         assert referrer == expected.referrer

+         pytest.fail("No random value generated. Probable JavaScript error: Crypto.getRandomValues: Argument 1 does not implement interface ArrayBufferView.")

tests/integration_tests/testing/tests_definition/test_10_time.py tests/integration_tests/testing/tests_definition/test_time.py
file renamed
+27 -4
@@ -1,9 +1,9 @@ 

  #

- #  JShelter is a browser extension which increases level

+ #  JavaScript Restrictor is a browser extension which increases level

  #  of security, anonymity and privacy of the user while browsing the

  #  internet.

  #

- #  Copyright (C) 2020  Martin Bednar

+ #  Copyright (C) 2022  Martin Bednar

  #

  # SPDX-License-Identifier: GPL-3.0-or-later

  #
@@ -47,5 +47,28 @@ 

      p_now = datetime.now()

      p_time = p_now.hour * 60 * 60 + p_now.minute * 60 + p_now.second

      # Values do not have to be strictly equal.

-     # A deviation of less than 4 is tolerated.

-     assert abs(js_time - p_time) < 4

+     # A deviation of less than 1 is tolerated.

+     assert abs(js_time - p_time) <= 1

+ 

+ 

+ ## Test time accuracy.

+ def test_accuracy(browser, expected):

+     #Suppose time is rounded.

+     is_time_rounded = True

+     # Make 3 measurement.

+     for _ in range(3):

+         # Wait a while to value of time will be changed.

+         time.sleep(random.randint(1, 3))

+         miliseconds = browser.driver.execute_script("let d = new Date();"

+                                                     "return d.getMilliseconds()")

+         if expected.time['accuracy'] == 'EXACTLY':

+             if int(miliseconds / 10) * 10 != miliseconds:

+                 # miliseconds was not rounded. At least one of three measurement has to say value was not rounded.

+                 is_time_rounded = False

+         else:

+             assert is_in_accuracy(miliseconds, expected.time['accuracy'])

+  

+     if expected.time['accuracy'] == 'EXACTLY':

+         # At least one of three measurement has to say value was not rounded.

+         # is_time_rounded should be false if EXACTLY value is required.

+         assert not is_time_rounded

tests/integration_tests/testing/tests_definition/test_11_toString.py tests/integration_tests/testing/tests_definition/test_toString.py
file renamed
file was moved with no change to the file
tests/integration_tests/testing/tests_definition/test_12_webaudio.py tests/integration_tests/testing/tests_definition/test_webaudio.py
file renamed
file was moved with no change to the file
tests/integration_tests/testing/tests_definition/test_13_webgl.py tests/integration_tests/testing/tests_definition/test_webgl.py
file renamed
file was moved with no change to the file
tests/integration_tests/testing/tests_definition/test_14_gps.py tests/integration_tests/testing/tests_definition/test_gps.py
file renamed
file was moved with no change to the file
@@ -1,5 +1,5 @@ 

  #

- #  JShelter is a browser extension which increases level

+ #  JavaScript Restrictor is a browser extension which increases level

  #  of security, anonymity and privacy of the user while browsing the

  #  internet.

  #
@@ -26,7 +26,7 @@ 

  from web_browser_type import BrowserType

  

  

- ## Module contains definitions for expected values of default levels od JShelter.

+ ## Module contains definitions for expected values of default levels od JSR.

  #

  #  Expected values are comparing during testing with current values of variables.

  #  'REAL VALUE' means that current value should not be spoofed.
@@ -35,13 +35,11 @@ 

  #  This module can be edited when definition of default levels will be changed.

  

  

- #  Ignore Plugins and mimeTypes tests - explanation:

+ ## Expected values for default level 0 of JSR.

+ #  Ignore Plugins and mimeTypes test - explanation:

  #  The apparent modification of the plugins is caused by the Selenium environment in which the testing takes place.

  #  This difference only appears in a browser controlled by Selenium.

  #  This issue is not caused by JShield, but by Selenium.

- 

- 

- ## Expected values for default level 0 of JShelter.

  level0 = TestedValues(

      user_agent={BrowserType.FIREFOX: 'REAL VALUE',

                  BrowserType.CHROME: 'REAL VALUE'},
@@ -77,11 +75,11 @@ 

      referrer='REAL VALUE',

      time={'value': 'REAL VALUE',

            'accuracy': 'EXACTLY'},

-     plugins={'count': {BrowserType.FIREFOX: 'REAL VALUE',

+     plugins={'count': {BrowserType.FIREFOX: 0,

                         BrowserType.CHROME: 'IGNORE'},

-              'value': {BrowserType.FIREFOX: 'REAL VALUE',

+              'value': {BrowserType.FIREFOX: 'EMPTY',

                         BrowserType.CHROME: 'IGNORE'}},

-     mimeTypes='REAL VALUE',

+     mimeTypes='IGNORE',

      get_channel= 'REAL VALUE',

      copy_channel= 'REAL VALUE',

      byte_time_domain= 'REAL VALUE',
@@ -103,7 +101,7 @@ 

      methods_toString='REAL VALUE'

  )

  

- ## Expected values for default level 1 of JShelter.

+ ## Expected values for default level 1 of JSR.

  level1 = TestedValues(

      user_agent={BrowserType.FIREFOX: 'REAL VALUE',

                  BrowserType.CHROME: 'REAL VALUE'},
@@ -144,10 +142,10 @@ 

      time={'value': 'REAL VALUE',

            'accuracy': 0.01},

      plugins={'count': {BrowserType.FIREFOX: 0,

-                        BrowserType.CHROME: 'IGNORE'},

+                        BrowserType.CHROME: 'REAL VALUE'},

               'value': {BrowserType.FIREFOX: 'EMPTY',

-                        BrowserType.CHROME: 'IGNORE'}},

-     mimeTypes='SPOOF VALUE',

+                        BrowserType.CHROME: 'REAL VALUE'}},

+     mimeTypes='REAL VALUE',

      get_channel= 'REAL VALUE',

      copy_channel= 'REAL VALUE',

      byte_time_domain= 'REAL VALUE',
@@ -169,7 +167,7 @@ 

      methods_toString='REAL VALUE'

  )

  

- ## Expected values for default level 2 of JShelter.

+ ## Expected values for default level 2 of JSR.

  level2 = TestedValues(

      user_agent={BrowserType.FIREFOX: 'REAL VALUE',

                  BrowserType.CHROME: 'REAL VALUE'},
@@ -183,7 +181,7 @@ 

      cookie_enabled='REAL VALUE',

      oscpu='REAL VALUE',

      gps_accuracy={'value': 'REAL VALUE',

-                   'accuracy': 100},

+                   'accuracy': 1},

      altitude={'value': 'REAL VALUE',

                'accuracy': 100},

      altitude_accurac={'value': 'REAL VALUE',
@@ -199,7 +197,7 @@ 

      speed={'value': 'REAL VALUE',

             'accuracy': 100},

      timestamp={'value': 'REAL VALUE',

-                'accuracy': 0.1},

+                'accuracy': 0.001},

      device_memory={BrowserType.FIREFOX: None,

                     BrowserType.CHROME: 'SPOOF VALUE',

                     'valid_values': {0.25,0.5,1,2,4,8}},
@@ -208,12 +206,12 @@ 

      IOdevices= {0,1,2,3,4,5,6,7,8,9},

      referrer='REAL VALUE',

      time={'value': 'REAL VALUE',

-           'accuracy': 0.1},

+           'accuracy': 1},

      plugins={'count': {BrowserType.FIREFOX: 0,

                         BrowserType.CHROME: 'IGNORE'},

               'value': {BrowserType.FIREFOX: 'EMPTY',

                         BrowserType.CHROME: 'IGNORE'}},

-     mimeTypes='EMPTY',

+     mimeTypes='SPOOF VALUE',

      get_channel= 'SPOOF VALUE',

      copy_channel= 'SPOOF VALUE',

      byte_time_domain= 'SPOOF VALUE',
@@ -221,7 +219,7 @@ 

      byte_frequency= 'SPOOF VALUE',

      float_frequency= 'SPOOF VALUE',

      performance={'value': 'REAL VALUE',

-                  'accuracy': 100},

+                  'accuracy': 1},

      protect_canvas=False,

      canvas_imageData = 'SPOOF VALUE',

      canvas_dataURL = 'SPOOF VALUE',
@@ -235,7 +233,7 @@ 

      methods_toString='REAL VALUE'

  )

  

- ## Expected values for default level 3 of JShelter.

+ ## Expected values for default level 3 of JSR.

  level3 = TestedValues(

      user_agent={BrowserType.FIREFOX: 'REAL VALUE',

                  BrowserType.CHROME: 'REAL VALUE'},
@@ -291,7 +289,7 @@ 

      methods_toString='REAL VALUE'

  )

  

- ## Expected values for custom level 4 of JShelter.

+ ## Expected values for custom level 4 of JSR.

  ## The hard-coded configuration of the level 4 is defined in the file web_browser.py in function define_test_level.

  level4 = TestedValues(

      user_agent={BrowserType.FIREFOX: 'REAL VALUE',

@@ -3,8 +3,8 @@ 

  #  of security, anonymity and privacy of the user while browsing the

  #  internet.

  #

- #  Copyright (C) 2020  Martin Bednar

  #  Copyright (C) 2021  Matus Svancar

+ #  Copyright (C) 2022  Martin Bednar

  #

  # SPDX-License-Identifier: GPL-3.0-or-later

  #
@@ -44,11 +44,11 @@ 

  #  Function waits maximally 10 seconds for loading geolocation data.

  def get_position(driver):

      driver.get(get_config("testing_page"))

-     driver.find_element_by_xpath("//button[text()='Show GPS data']").click()

+     driver.find_element(By.XPATH, "//button[text()='Show GPS data']").click()

      WebDriverWait(driver, 10).until(

          ec.presence_of_element_located((By.ID, 'mapnavi'))

      )

-     location = driver.find_element_by_id('placeToWriteGPSDetails').text

+     location = driver.find_element(By.ID, 'placeToWriteGPSDetails').text

      location = location.replace(" ", "").split()

      position = {}

      for property in location:
@@ -130,10 +130,10 @@ 

  def is_canvas_spoofed(driver):

      try:

          driver.get(get_config("testing_page"))

-         driver.find_element_by_xpath("//button[text()='Add line to canvas']").click()

-         driver.find_element_by_xpath("//button[text()='Add circle to canvas']").click()

-         driver.find_element_by_xpath("//button[text()='Add text to canvas']").click()

-         driver.find_element_by_xpath("//button[text()='Get data and show image in canvas frame']").click()

+         driver.find_element(By.XPATH, "//button[text()='Add line to canvas']").click()

+         driver.find_element(By.XPATH, "//button[text()='Add circle to canvas']").click()

+         driver.find_element(By.XPATH, "//button[text()='Add text to canvas']").click()

+         driver.find_element(By.XPATH, "//button[text()='Get data and show image in canvas frame']").click()

          is_spoofed = driver.execute_script("var canvas = document.getElementById('canvas1'); return !canvas.getContext('2d')"

                                       ".getImageData(0, 0, canvas.width, canvas.height).data.some(channel => channel !== 255)")

      except:
@@ -269,7 +269,7 @@ 

  ## returns object with attributes output by AudioContext.getChannelData, AudioContext.copyFromChannel, AnalyserNode.getFloatFrequencyData, AnalyserNode.getByteFrequencyData, AnalyserNode.getFloatTimeDomainData, AnalyserNode.getByteTimeDomainData which are saved in testing page

  def get_audio(driver):

      driver.get(get_config("testing_page"))

-     driver.find_element_by_xpath("//button[text()='Test audio']").click()

+     driver.find_element(By.XPATH, "//button[text()='Test audio']").click()

      sleep(3)

      audio = {'get_channel': driver.execute_script("return document.getElementById('channel_data_result').innerHTML;"),

               'copy_channel': driver.execute_script("return document.getElementById('copy_result').innerHTML;"),

@@ -95,10 +95,11 @@ 

          if self.type == BrowserType.CHROME:

              self.driver.get('chrome://system/')

              WebDriverWait(self.driver, 10).until(

-                 ec.presence_of_element_located((By.ID, 'extensions-value-btn'))

+                 ec.presence_of_element_located((By.ID, 'expandAll'))

              )

-             for elem in self.driver.find_element_by_id('extensions-value').text.splitlines():

-                 if 'JavaScript Restrictor' in elem:

+             self.driver.find_element(By.ID, 'expandAll').click()

+             for elem in self.driver.find_element(By.ID, 'extensions-value').text.splitlines():

+                 if 'JShelter' in elem:

                      self._jsr_options_page = "chrome-extension://" + elem.split(':')[0][:-1] + "/options.html"

  

      ## Create new browser of given type (Chrome, Firefox).

@@ -310,6 +310,112 @@ 

  			{

  				"begin": "var browser = JSON.parse(JSON.stringify(sinon_browser)); browser.storage.sync.get = function(param) { return Promise.resolve(param); }; browser.runtime.onMessage.addListener = function(){return;}; browser.runtime.getURL = function(){return;};"

  			}

+ 		},

+ 		{

+ 			"name": "wrappingS-ECMA-SHARED",

+ 			"remove_custom_namespace": true,

+ 			"let_to_var": false,

+ 			"src_script_requirements": [

+ 				{

+ 					"type": "const",

+ 					"requirements": [

+ 						{

+ 							"from": "./wrapping.js",

+ 							"objects": [

+ 								"add_wrappers"

+ 							]

+ 						}

+ 					]

+ 				}

+ 			],

+ 			"extra_exports": [

+ 				"proxyHandler",

+ 				"wrappingFunctionBody",

+ 				"wrappers"

+ 			],

+ 			"test_script_requirements": [

+ 				{

+ 					"type": "const",

+ 					"requirements": [

+ 						{

+ 							"from": "./wrappingS-ECMA-SHARED.js",

+ 							"objects": [

+ 								"proxyHandler",

+ 								"wrappingFunctionBody",

+ 								"wrappers"

+ 							]

+ 						}

+ 					]

+ 				}

+ 			]

+ 		},

+ 		{

+ 			"name": "wrappingS-ECMA-ARRAY",

+ 			"remove_custom_namespace": true,

+ 			"let_to_var": false,

+ 			"src_script_requirements": [

+ 				{

+ 					"type": "const",

+ 					"requirements": [

+ 						{

+ 							"from": "./wrapping.js",

+ 							"objects": [

+ 								"add_wrappers"

+ 							]

+ 						}

+ 					]

+ 				}

+ 			],

+ 			"extra_exports": [

+ 				"packIEEE754",

+ 				"unpackIEEE754",

+ 				"unpackF64",

+ 				"packF64",

+ 				"unpackF32",

+ 				"packF32",

+ 				"constructDecorator",

+ 				"offsetDecorator",

+ 				"redefineNewArrayFunctions",

+ 				"redefineNewArrayConstructors",

+ 				"proxyHandler",

+ 				"getByteDecorator",

+ 				"setByteDecorator",

+ 				"getFloatDecorator",

+ 				"setFloatDecorator",

+ 				"getBigIntDecorator",

+ 				"setBigIntDecorator",

+ 				"redefineDataViewFunctions"

+ 			],

+ 			"test_script_requirements": [

+ 				{

+ 					"type": "const",

+ 					"requirements": [

+ 						{

+ 							"from": "./wrappingS-ECMA-ARRAY.js",

+ 							"objects": [

+ 								"packIEEE754",

+ 								"unpackIEEE754",

+ 								"unpackF64",

+ 								"packF64",

+ 								"unpackF32",

+ 								"packF32",

+ 								"constructDecorator",

+ 								"offsetDecorator",

+ 								"redefineNewArrayFunctions",

+ 								"redefineNewArrayConstructors",

+ 								"proxyHandler",

+ 								"getByteDecorator",

+ 								"setByteDecorator",

+ 								"getFloatDecorator",

+ 								"setFloatDecorator",

+ 								"getBigIntDecorator",

+ 								"setBigIntDecorator",

+ 								"redefineDataViewFunctions"

+ 							]

+ 						}

+ 					]

+ 				}

+ 			]

  		}

  	]

  }

@@ -122,7 +122,7 @@ 

  	remove_custom_namespace=$(jq -r '.remove_custom_namespace' <<< "$script")

  	if [ $remove_custom_namespace == "true" ]

  	then

- 		sed -i -e "s/(function() {//" -e "s/})();//" -e "s/successCallback(/return(/" ./tmp/$source_script_name

+ 		sed -i -e "s/(function() {//" -e "s/(function () {//" -e "s/})();//" -e "s/successCallback(/return(/" ./tmp/$source_script_name

  	fi

  	

  	# Modify source script - convert "let" variables to "var" variables if necessary.
@@ -244,6 +244,6 @@ 

  echo Cleanup STARTED.

  

  # Remove ./tmp directory (temporary working directory) after tests finished.

- rm -rf ./tmp

+ # rm -rf ./tmp

  

  echo Cleanup FINISHED.

@@ -0,0 +1,120 @@ 

+ //

+ //  JavaScript Restrictor is a browser extension which increases level

+ //  of security, anonymity and privacy of the user while browsing the

+ //  internet.

+ //

+ //  Copyright (C) 2022 Martin Bednar

+ //

+ // SPDX-License-Identifier: GPL-3.0-or-later

+ //

+ //  This program is free software: you can redistribute it and/or modify

+ //  it under the terms of the GNU General Public License as published by

+ //  the Free Software Foundation, either version 3 of the License, or

+ //  (at your option) any later version.

+ //

+ //  This program is distributed in the hope that it will be useful,

+ //  but WITHOUT ANY WARRANTY; without ev1267027en the implied warranty of

+ //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ //  GNU General Public License for more details.

+ //

+ //  You should have received a copy of the GNU General Public License

+ //  along with this program.  If not, see <https://www.gnu.org/licenses/>.

+ //

+ 

+ /// <reference path="../../common/wrappingS-ECMA-ARRAY.js">

+ 

+ describe("ECMA-ARRAY", function() {

+ 	describe("packIEEE754", function() {

+ 		it("should be defined.",function() {

+ 			expect(packIEEE754).toBeDefined();

+ 		});

+ 		it("should return array.",function() {

+ 			expect(packIEEE754(14156,2,5)).toEqual(jasmine.any(Array));

+ 		});

+ 	});

+ 	describe("unpackIEEE754", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackIEEE754).toBeDefined();

+ 		});

+ 	});

+ 	describe("unpackF64", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("packF64", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("unpackF32", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("packF32", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("constructDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("offsetDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("redefineNewArrayFunctions", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("redefineNewArrayConstructors", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("proxyHandler", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("getByteDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("setByteDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("getFloatDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("setFloatDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("getBigIntDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("setBigIntDecorator", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ 	describe("redefineDataViewFunctions", function() {

+ 		it("should be defined.",function() {

+ 			expect(unpackF64).toBeDefined();

+ 		});

+ 	});

+ });

@@ -0,0 +1,42 @@ 

+ //

+ //  JavaScript Restrictor is a browser extension which increases level

+ //  of security, anonymity and privacy of the user while browsing the

+ //  internet.

+ //

+ //  Copyright (C) 2022 Martin Bednar

+ //

+ // SPDX-License-Identifier: GPL-3.0-or-later

+ //

+ //  This program is free software: you can redistribute it and/or modify

+ //  it under the terms of the GNU General Public License as published by

+ //  the Free Software Foundation, either version 3 of the License, or

+ //  (at your option) any later version.

+ //

+ //  This program is distributed in the hope that it will be useful,

+ //  but WITHOUT ANY WARRANTY; without ev1267027en the implied warranty of

+ //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ //  GNU General Public License for more details.

+ //

+ //  You should have received a copy of the GNU General Public License

+ //  along with this program.  If not, see <https://www.gnu.org/licenses/>.

+ //

+ 

+ /// <reference path="../../common/wrappingS-ECMA-SHARED.js">

+ 

+ describe("ECMA-SHARED", function() {

+ 	describe("proxyHandler", function() {

+ 		it("should be defined.",function() {

+ 			expect(proxyHandler).toBeDefined();

+ 		});

+ 	});

+ 	describe("wrappingFunctionBody", function() {

+ 		it("should be defined.",function() {

+ 			expect(wrappingFunctionBody).toBeDefined();

+ 		});

+ 	});

+ 	describe("wrappers", function() {

+ 		it("should be defined.",function() {

+ 			expect(wrappers).toBeDefined();

+ 		});

+ 	});

+ });

no initial comment

Already at least partially merged

| * | | | | | commit d2f5695
| |\ \ \ \ \ \ Merge: 433d877 3d887db
| | | | | | | | Author: Libor Polčák ipolcak@fit.vutbr.cz
| | | | | | | | Date: Tue Feb 15 13:32:37 2022 +0100
| | | | | | | |
| | | | | | | | Merge fixes of Plugins and MimeTypes wrappers and levels
| | | | | | | |
| | | | | | | | Including sync between docs and applied levels

Pull-Request has been closed by xbedna60

2 years ago
Metadata
Changes Summary 23
+425 -368
file changed
common/levels.js
+5 -4
file changed
common/wrappingS-NP.js
+1 -1
file changed
tests/integration_tests/testing/configuration.py
+4 -0
file changed
tests/integration_tests/testing/conftest.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_hw.py
tests/integration_tests/testing/tests_definition/test_01_hw.py
+63 -56
file renamed
tests/integration_tests/testing/tests_definition/test_NBS_setting.py
tests/integration_tests/testing/tests_definition/test_04_NBS_setting.py
+79 -79
file renamed
tests/integration_tests/testing/tests_definition/test_domain_level_setting.py
tests/integration_tests/testing/tests_definition/test_05_domain_level_setting.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_canvas.py
tests/integration_tests/testing/tests_definition/test_06_canvas.py
+11 -5
file renamed
tests/integration_tests/testing/tests_definition/test_navigator.py
tests/integration_tests/testing/tests_definition/test_07_navigator.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_performance.py
tests/integration_tests/testing/tests_definition/test_08_performance.py
+18 -13
file renamed
tests/integration_tests/testing/tests_definition/test_referrer.py
tests/integration_tests/testing/tests_definition/test_09_ECMA_arrays.py
+27 -4
file renamed
tests/integration_tests/testing/tests_definition/test_time.py
tests/integration_tests/testing/tests_definition/test_10_time.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_toString.py
tests/integration_tests/testing/tests_definition/test_11_toString.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_webaudio.py
tests/integration_tests/testing/tests_definition/test_12_webaudio.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_webgl.py
tests/integration_tests/testing/tests_definition/test_13_webgl.py
+0 -0
file renamed
tests/integration_tests/testing/tests_definition/test_gps.py
tests/integration_tests/testing/tests_definition/test_14_gps.py
+19 -21
file changed
tests/integration_tests/testing/values_expected.py
+8 -8
file changed
tests/integration_tests/testing/values_getters.py
+4 -3
file changed
tests/integration_tests/testing/web_browser.py
+106 -0
file changed
tests/unit_tests/config/global.json
+2 -2
file changed
tests/unit_tests/start_unit_tests.sh
+120
file added
tests/unit_tests/tests/wrappingS-ECMA-ARRAY_tests.js
+42
file added
tests/unit_tests/tests/wrappingS-ECMA-SHARED_tests.js