From bb96bbc7669dd04165f5c45265c864770665184d Mon Sep 17 00:00:00 2001 From: Libor Polčák Date: Nov 04 2021 09:50:37 +0000 Subject: Wrap Navigator.prototype and Geolocation.prototype Previously, we wrapped navigator and navigator.geolocation and let the prototypes accessible --- diff --git a/common/levels.js b/common/levels.js index bc8c418..5c6849a 100644 --- a/common/levels.js +++ b/common/levels.js @@ -257,7 +257,7 @@ var wrapping_groups = { }], wrappers: [ // NP - "navigator.plugins", // also modifies "navigator.mimeTypes", + "Navigator.prototype.plugins", // also modifies "Navigator.prototype.mimeTypes", ], }, { @@ -321,9 +321,9 @@ var wrapping_groups = { }], wrappers: [ // HTML-LS - "navigator.hardwareConcurrency", + "Navigator.prototype.hardwareConcurrency", // DM - "navigator.deviceMemory", + "Navigator.prototype.deviceMemory", ], }, { @@ -481,10 +481,10 @@ var wrapping_groups = { ], wrappers: [ // GPS - "navigator.geolocation", - "navigator.geolocation.getCurrentPosition", - "navigator.geolocation.watchPosition", - "navigator.geolocation.clearWatch" + "Navigator.prototype.geolocation", + "Geolocation.prototype.getCurrentPosition", + "Geolocation.prototype.watchPosition", + "Geolocation.prototype.clearWatch" ], }, { @@ -495,7 +495,7 @@ var wrapping_groups = { options: [], wrappers: [ // GAMEPAD - "navigator.getGamepads", + "Navigator.prototype.getGamepads", ], }, { @@ -506,9 +506,9 @@ var wrapping_groups = { options: [], wrappers: [ // VR - "navigator.activeVRDisplays", + "Navigator.prototype.activeVRDisplays", // XR - "navigator.xr", + "Navigator.prototype.xr", ], }, { @@ -519,7 +519,7 @@ var wrapping_groups = { options: [], wrappers: [ // BEACON - "navigator.sendBeacon", + "Navigator.prototype.sendBeacon", ], }, { @@ -530,7 +530,7 @@ var wrapping_groups = { options: [], wrappers: [ // BATTERY - "navigator.getBattery", + "Navigator.prototype.getBattery", "window.BatteryManager", ], }, diff --git a/common/wrappingS-BATTERY-CR.js b/common/wrappingS-BATTERY-CR.js index 72ccf2f..0bef7bb 100644 --- a/common/wrappingS-BATTERY-CR.js +++ b/common/wrappingS-BATTERY-CR.js @@ -46,13 +46,13 @@ (function() { var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "getBattery", wrapped_objects: [], post_wrapping_code: [ { code_type: "delete_properties", - parent_object: "navigator", + parent_object: "Navigator.prototype", delete_properties: ["getBattery"], } ], diff --git a/common/wrappingS-BE.js b/common/wrappingS-BE.js index 9d3cdd4..93bf47f 100644 --- a/common/wrappingS-BE.js +++ b/common/wrappingS-BE.js @@ -41,7 +41,7 @@ (function() { var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "sendBeacon", wrapped_objects: [], helping_code: "", diff --git a/common/wrappingS-DM.js b/common/wrappingS-DM.js index 0298ee5..3ef37cd 100644 --- a/common/wrappingS-DM.js +++ b/common/wrappingS-DM.js @@ -54,7 +54,7 @@ (function() { var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "deviceMemory", wrapped_objects: [], helping_code: ` @@ -78,7 +78,7 @@ post_wrapping_code: [ { code_type: "object_properties", - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "deviceMemory", wrapped_objects: [], /** \brief replaces navigator.deviceMemory getter diff --git a/common/wrappingS-GEO.js b/common/wrappingS-GEO.js index 0d8e943..b6f56ca 100644 --- a/common/wrappingS-GEO.js +++ b/common/wrappingS-GEO.js @@ -219,32 +219,32 @@ var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "geolocation", wrapped_objects: [], helping_code: setArgs, post_wrapping_code: [ { code_type: "delete_properties", - parent_object: "navigator", + parent_object: "Navigator.prototype", apply_if: "!enableGeolocation", delete_properties: ["geolocation"], } ], }, { - parent_object: "navigator.geolocation", + parent_object: "Geolocation.prototype", parent_object_property: "getCurrentPosition", wrapped_objects: [ { - original_name: "navigator.geolocation.getCurrentPosition", + original_name: "Geolocation.prototype.getCurrentPosition", callable_name: "originalGetCurrentPosition", }, ], helping_code: setArgs + processOriginalGPSDataObject_globals, wrapping_function_args: "successCallback, errorCallback, origOptions", - /** \fn fake navigator.geolocation.getCurrentPosition + /** \fn fake Geolocation.prototype.getCurrentPosition * \brief Provide a fake geolocation position */ wrapping_function_body: ` @@ -266,18 +266,18 @@ `, }, { - parent_object: "navigator.geolocation", + parent_object: "Geolocation.prototype", parent_object_property: "watchPosition", wrapped_objects: [ { - original_name: "navigator.geolocation.watchPosition", + original_name: "Geolocation.prototype.watchPosition", wrapped_name: "originalWatchPosition", }, ], helping_code: setArgs + processOriginalGPSDataObject_globals + "let watchPositionCounter = 0;", wrapping_function_args: "successCallback, errorCallback, origOptions", - /** \fn fake navigator.geolocation.watchPosition - * navigator.geolocation.watchPosition intended use concerns tracking user position changes. + /** \fn fake Geolocation.prototype.watchPosition + * Geolocation.prototype.watchPosition intended use concerns tracking user position changes. * JSR provides four modes of operaion: * * current position approximation: Always return the same data, the same as getCurrentPosition() * * accurate data: Return exact position but fake timestamp @@ -292,30 +292,30 @@ } else { // Re-use the wrapping of n.g.getCurrentPosition() - navigator.geolocation.getCurrentPosition(successCallback, errorCallback, origOptions); + Geolocation.prototype.getCurrentPosition(successCallback, errorCallback, origOptions); watchPositionCounter++; return watchPositionCounter; } `, }, { - parent_object: "navigator.geolocation", + parent_object: "Geolocation.prototype", parent_object_property: "clearWatch", wrapped_objects: [ { - original_name: "navigator.geolocation.clearWatch", + original_name: "Geolocation.prototype.clearWatch", wrapped_name: "originalClearWatch", }, ], helping_code: setArgs, wrapping_function_args: "id", - /** \fn fake_or_original navigator.geolocation.clearWatch + /** \fn fake_or_original Geolocation.prototype.clearWatch * If the Geolocation API provides correct data, call the original implementation, * otherwise do nothing as the watchPosition object was not created. */ wrapping_function_body: ` if (provideAccurateGeolocationData) { - originalClearWatch.call(navigator.geolocation, id); + originalClearWatch.call(Geolocation.prototype, id); } `, } diff --git a/common/wrappingS-GP.js b/common/wrappingS-GP.js index abc09cc..d3174d9 100644 --- a/common/wrappingS-GP.js +++ b/common/wrappingS-GP.js @@ -75,10 +75,10 @@ `; var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "getGamepads", wrapped_objects: [{ - original_name: "navigator.getGamepads()", + original_name: "Navigator.prototype.getGamepads()", wrapped_name: "origGamepads", }], helping_code: "", diff --git a/common/wrappingS-HTML-LS.js b/common/wrappingS-HTML-LS.js index 813500e..5b72b6b 100644 --- a/common/wrappingS-HTML-LS.js +++ b/common/wrappingS-HTML-LS.js @@ -241,7 +241,7 @@ ISBN 978-3-319-66398-2. var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "hardwareConcurrency", wrapped_objects: [], helping_code: ` diff --git a/common/wrappingS-NP.js b/common/wrappingS-NP.js index 22e15cb..649158d 100644 --- a/common/wrappingS-NP.js +++ b/common/wrappingS-NP.js @@ -266,7 +266,7 @@ var fakes = fakeMime + fakePlugin + fakePluginArray + fakeMimeTypeArrayF; var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "plugins", apply_if: "navigator.plugins.length > 0", wrapped_objects: [], @@ -291,7 +291,7 @@ post_wrapping_code: [ { code_type: "object_properties", - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "plugins", wrapped_objects: [], /** \brief replaces navigator.plugins getter @@ -313,7 +313,7 @@ }, { code_type: "object_properties", - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "mimeTypes", wrapped_objects: [], /** \brief replaces navigator.mimeTypes getter diff --git a/common/wrappingS-VR.js b/common/wrappingS-VR.js index e85eb34..82b076f 100644 --- a/common/wrappingS-VR.js +++ b/common/wrappingS-VR.js @@ -74,7 +74,7 @@ `; var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "activeVRDisplays", wrapped_objects: [], helping_code: "", diff --git a/common/wrappingS-XR.js b/common/wrappingS-XR.js index 2c65eb1..94f2a83 100644 --- a/common/wrappingS-XR.js +++ b/common/wrappingS-XR.js @@ -47,14 +47,14 @@ (function() { var wrappers = [ { - parent_object: "navigator", + parent_object: "Navigator.prototype", parent_object_property: "xr", wrapped_objects: [], helping_code: "", post_wrapping_code: [ { code_type: "delete_properties", - parent_object: "navigator", + parent_object: "Navigator.prototype", delete_properties: ["xr"], } ],