Reviewed by Darin Adler.
- fix an ASSERT when getIntIdentifier is called with 0 or -1
* bindings/npruntime.cpp:
(_NPN_GetIntIdentifier): We cannot use the hashmap for 0 and -1 since
they are the empty value and the deleted value. Instead, keep the
identifiers for those two integers in a static array.
WebKitTools:
Reviewed by Darin Adler.
- added a testGetIntIdentifier() method to TestNetscapePlugIn
* DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
(pluginInvoke):
LayoutTests:
Reviewed by Darin Adler.
- added a test of the behavior of getIntIdentifier with the integers
0 and -1
* plugins/getintidentifier-special-values-expected.txt: Added.
* plugins/getintidentifier-special-values.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28366
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-12-03 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler.
+
+ - fix an ASSERT when getIntIdentifier is called with 0 or -1
+
+ * bindings/npruntime.cpp:
+ (_NPN_GetIntIdentifier): We cannot use the hashmap for 0 and -1 since
+ they are the empty value and the deleted value. Instead, keep the
+ identifiers for those two integers in a static array.
+
2007-12-02 Darin Adler <darin@apple.com>
Reviewed by Mitz.
NPIdentifier _NPN_GetIntIdentifier(int32_t intid)
{
- PrivateIdentifier* identifier = 0;
-
- identifier = getIntIdentifierMap()->get(intid);
- if (identifier == 0) {
- identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
- // We never release identifier names, so this dictionary will grow.
- identifier->isString = false;
- identifier->value.number = intid;
-
- getIntIdentifierMap()->set(intid, identifier);
+ PrivateIdentifier* identifier;
+
+ if (intid == 0 || intid == -1) {
+ static PrivateIdentifier* negativeOneAndZeroIdentifiers[2];
+
+ identifier = negativeOneAndZeroIdentifiers[intid + 1];
+ if (!identifier) {
+ identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+ identifier->isString = false;
+ identifier->isString = intid;
+
+ negativeOneAndZeroIdentifiers[intid + 1] = identifier;
+ }
+ } else {
+ identifier = getIntIdentifierMap()->get(intid);
+ if (!identifier) {
+ identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+ // We never release identifier names, so this dictionary will grow.
+ identifier->isString = false;
+ identifier->value.number = intid;
+
+ getIntIdentifierMap()->set(intid, identifier);
+ }
}
return (NPIdentifier)identifier;
}
+2007-12-03 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler.
+
+ - added a test of the behavior of getIntIdentifier with the integers
+ 0 and -1
+
+ * plugins/getintidentifier-special-values-expected.txt: Added.
+ * plugins/getintidentifier-special-values.html: Added.
+
2007-12-03 Rob Buis <buis@kde.org>
Reviewed by Darin.
--- /dev/null
+PASS: getIntIdentifier(n) returned consistent identifiers for n = 1, 0 and -1.
+
--- /dev/null
+<html>
+<body>
+ <pre id="console"></pre>
+ <embed id="plg" type="application/x-webkit-test-netscape"></embed>
+ <script>
+ function log(message)
+ {
+ document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+ }
+
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var plugin = document.getElementById("plg");
+
+ var pass = true;
+
+ var firstOneID = plugin.testGetIntIdentifier(1);
+ var firstZeroID = plugin.testGetIntIdentifier(0);
+ var firstMinusOneID = plugin.testGetIntIdentifier(-1);
+
+ if (firstOneID == firstZeroID) {
+ log ("FAIL: getIntIdentifier(1) and getIntIdentifier(0) returned the same identifier: " + firstOneID);
+ pass = false;
+ }
+
+ if (firstOneID == firstMinusOneID) {
+ log ("FAIL: getIntIdentifier(1) and getIntIdentifier(-1) returned the same identifier: " + firstOneID);
+ pass = false;
+ }
+
+ if (firstMinusOneID == firstZeroID) {
+ log ("FAIL: getIntIdentifier(0) and getIntIdentifier(-1) returned the same identifier: " + firstZeroID);
+ pass = false;
+ }
+
+ var secondOneID = plugin.testGetIntIdentifier(1);
+ var secondZeroID = plugin.testGetIntIdentifier(0);
+ var secondMinusOneID = plugin.testGetIntIdentifier(-1);
+
+ if (firstOneID != secondOneID) {
+ log("FAIL: getIntIdentifier(1) returned " + firstOneID + " the first time and " + secondOneID + " the second time.");
+ pass = false;
+ }
+
+ if (firstZeroID != secondZeroID) {
+ log("FAIL: getIntIdentifier(0) returned " + firstZeroID + " the first time and " + secondZeroID + " the second time.");
+ pass = false;
+ }
+
+ if (firstMinusOneID != secondMinusOneID) {
+ log("FAIL: getIntIdentifier(-1) returned " + firstMinusOneID + " the first time and " + secondMinusOneID + " the second time.");
+ pass = false;
+ }
+
+ if (pass)
+ log("PASS: getIntIdentifier(n) returned consistent identifiers for n = 1, 0 and -1.");
+
+ </script>
+</body>
+</html>
+2007-12-03 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler.
+
+ - added a testGetIntIdentifier() method to TestNetscapePlugIn
+
+ * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
+ (pluginInvoke):
+
2007-12-03 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Oliver.
#define ID_TEST_INVOKE_DEFAULT 5
#define ID_DESTROY_STREAM 6
#define ID_TEST_ENUMERATE 7
-#define NUM_METHOD_IDENTIFIERS 8
+#define ID_TEST_GETINTIDENTIFIER 8
+#define NUM_METHOD_IDENTIFIERS 9
static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
"getURLNotify",
"testInvokeDefault",
"destroyStream",
- "testEnumerate"
+ "testEnumerate",
+ "testGetIntIdentifier"
};
static NPUTF8* createCStringFromNPVariant(const NPVariant *variant)
if (browser->enumerate(obj->npp, NPVARIANT_TO_OBJECT(args[0]), &identifiers, &count)) {
NPObject* outArray = NPVARIANT_TO_OBJECT(args[1]);
NPIdentifier pushIdentifier = browser->getstringidentifier("push");
-
+
for (uint32_t i = 0; i < count; i++) {
NPUTF8* string = browser->utf8fromidentifier(identifiers[i]);
browser->releasevariantvalue(&browserResult);
browser->memfree(string);
}
-
+
browser->memfree(identifiers);
}
NPError npError = browser->destroystream(obj->npp, obj->stream, NPRES_USER_BREAK);
INT32_TO_NPVARIANT(npError, *result);
return true;
- }
+ } else if (name == pluginMethodIdentifiers[ID_TEST_GETINTIDENTIFIER]) {
+ if (argCount == 1 && NPVARIANT_IS_DOUBLE(args[0])) {
+ NPIdentifier identifier = browser->getintidentifier((int)NPVARIANT_TO_DOUBLE(args[0]));
+ INT32_TO_NPVARIANT((int32)identifier, *result);
+ return true;
+ }
+ }
return false;
}