diff options
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/icedteanp/IcedTeaPluginUtils.cc | 20 | ||||
-rw-r--r-- | plugin/icedteanp/IcedTeaPluginUtils.h | 10 |
2 files changed, 28 insertions, 2 deletions
diff --git a/plugin/icedteanp/IcedTeaPluginUtils.cc b/plugin/icedteanp/IcedTeaPluginUtils.cc index 6ed17bb..8e690bd 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.cc +++ b/plugin/icedteanp/IcedTeaPluginUtils.cc @@ -498,6 +498,14 @@ IcedTeaPluginUtilities::removeInstanceID(void* member_ptr) instance_map->erase(member_ptr); } +/* Clear instance_map. Useful for tests. */ +void +IcedTeaPluginUtilities::clearInstanceIDs() +{ + delete instance_map; + instance_map = new std::map<void*, NPP>(); +} + /** * Removes all mappings to a given instance, and all associated objects */ @@ -603,6 +611,18 @@ IcedTeaPluginUtilities::removeObjectMapping(std::string key) object_map->erase(key); } +/* Clear object_map. Useful for tests. */ +void +IcedTeaPluginUtilities::clearObjectMapping() +{ + std::map<std::string, NPObject*>::iterator iter = object_map->begin(); + for (; iter != object_map->end(); ++iter) { + browser_functions.releaseobject(iter->second); + } + delete object_map; + object_map = new std::map<std::string, NPObject*>(); +} + /* * Similar to printStringVector, but takes a vector of string pointers instead * diff --git a/plugin/icedteanp/IcedTeaPluginUtils.h b/plugin/icedteanp/IcedTeaPluginUtils.h index b55355b..634b675 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.h +++ b/plugin/icedteanp/IcedTeaPluginUtils.h @@ -252,9 +252,12 @@ class IcedTeaPluginUtilities static void storeInstanceID(void* member_ptr, NPP instance); - static void removeInstanceID(void* member_ptr); + static void removeInstanceID(void* member_ptr); - static NPP getInstanceFromMemberPtr(void* member_ptr); + /* Clear object_map. Useful for tests. */ + static void clearInstanceIDs(); + + static NPP getInstanceFromMemberPtr(void* member_ptr); static NPObject* getNPObjectFromJavaKey(std::string key); @@ -262,6 +265,9 @@ class IcedTeaPluginUtilities static void removeObjectMapping(std::string key); + /* Clear object_map. Useful for tests. */ + static void clearObjectMapping(); + static void invalidateInstance(NPP instance); static bool isObjectJSArray(NPP instance, NPObject* object); |