Test for bug 564607 - Firefox crashes when an OOPP plugin implements NPClass.enumerate

This commit is contained in:
Benjamin Smedberg 2010-05-10 17:11:14 -04:00
parent d5b8a23321
commit 11fa580385
3 changed files with 43 additions and 1 deletions

View File

@ -91,6 +91,7 @@ _MOCHITEST_FILES = \
test_propertyAndMethod.html \
test_bug539565-1.html \
test_bug539565-2.html \
test_enumerate.html \
$(NULL)
# test_npruntime_npnsetexception.html \ Disabled for e10s

View File

@ -0,0 +1,33 @@
<html>
<head>
<title>NPAPI Cookie Tests</title>
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
function runTests() {
var pluginElement = document.getElementById("plugin1");
var c = 0;
var foundSetColor = false;
for (var n in pluginElement) {
++c;
ok(n in pluginElement, "Enumerated property which doesn't exist?");
if (n == 'setColor')
foundSetColor = true;
}
ok(c > 0, "Should have enumerated some properties");
ok(foundSetColor, "Should have enumerated .setColor");
SimpleTest.finish();
}
</script>
</body>
</html>

View File

@ -1676,7 +1676,15 @@ scriptableRemoveProperty(NPObject* npobj, NPIdentifier name)
bool
scriptableEnumerate(NPObject* npobj, NPIdentifier** identifier, uint32_t* count)
{
return false;
const int bufsize = sizeof(NPIdentifier) * ARRAY_LENGTH(sPluginMethodIdentifierNames);
NPIdentifier* ids = (NPIdentifier*) NPN_MemAlloc(bufsize);
if (!ids)
return false;
memcpy(ids, sPluginMethodIdentifiers, bufsize);
*identifier = ids;
*count = ARRAY_LENGTH(sPluginMethodIdentifierNames);
return true;
}
bool