Bug 510963 - NPN_GetValue(NPNVPluginElementNPObject) is broken, r=josh

--HG--
extra : rebase_source : e1242620d2adfee22a5c8ede076e4d43916e72d9
This commit is contained in:
Benjamin Smedberg 2009-09-10 14:11:30 -04:00
parent fdb442917d
commit d31bf1898b
4 changed files with 57 additions and 8 deletions

View File

@ -1168,16 +1168,16 @@ _getpluginelement(NPP npp)
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getpluginelement called from the wrong thread\n"));
return nsnull;
}
nsIDOMElement *elementp = nsnull;
NPError nperr = _getvalue(npp, NPNVDOMElement, &elementp);
if (nperr != NPERR_NO_ERROR) {
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(npp->ndata);
if (!inst)
return nsnull;
}
// Pass ownership of elementp to element
nsCOMPtr<nsIDOMElement> element;
element.swap(elementp);
inst->GetDOMElement(getter_AddRefs(element));
if (!element)
return nsnull;
JSContext *cx = GetJSContextFromNPP(npp);
NS_ENSURE_TRUE(cx, nsnull);

View File

@ -44,7 +44,11 @@ relativesrcdir = modules/plugin/test
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
_MOCHITEST_FILES = \
test_npobject_getters.html \
$(NULL)
_MOCHICHROME_FILES = \
test_bug479979.xul \
test_npruntime.xul \
test_privatemode.xul \
@ -52,5 +56,8 @@ _TEST_FILES = \
test_npapi_timers.xul \
$(NULL)
libs:: $(_TEST_FILES)
libs:: $(_MOCHICHROME_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
libs:: $(_MOCHITEST_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1,20 @@
<head>
<title>NPNV*NPObject accessibility 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>
<body onload="runTests()">
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
<script class="testbody" type="application/javascript">
dump('lastScript');
SimpleTest.waitForExplicitFinish();
function runTests() {
ok(document.getElementById('plugin1').pluginFoundElement, "plugin1.pluginFoundElement (NPNVPluginElementNPObject)", document.getElementById('plugin1').pluginFoundElement);
ok(window.pluginFoundWindow, "window.pluginFoundWindow (NPNVWindowNPObject)", window.pluginFoundWindow);
SimpleTest.finish();
}
</script>

View File

@ -356,6 +356,28 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
return err;
}
NPVariant variantTrue;
BOOLEAN_TO_NPVARIANT(true, variantTrue);
// Set a property on NPNVPluginElementNPObject
NPObject* o = NULL;
err = NPN_GetValue(instance, NPNVPluginElementNPObject, &o);
if (err == NPERR_NO_ERROR) {
NPN_SetProperty(instance, o,
NPN_GetStringIdentifier("pluginFoundElement"), &variantTrue);
NPN_ReleaseObject(o);
o = NULL;
}
// Set a property on NPNVWindowNPObject
err = NPN_GetValue(instance, NPNVWindowNPObject, &o);
if (err == NPERR_NO_ERROR) {
NPN_SetProperty(instance, o,
NPN_GetStringIdentifier("pluginFoundWindow"), &variantTrue);
NPN_ReleaseObject(o);
o = NULL;
}
++sInstanceCount;
return NPERR_NO_ERROR;
}