зеркало из https://github.com/mozilla/pjs.git
Test for error condition when trying to set an unknown variable in NPAPI. b=479979 r=roc
This commit is contained in:
Родитель
bc70ba2da9
Коммит
a5d1b9a7eb
|
@ -44,8 +44,8 @@ relativesrcdir = modules/plugin/test
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = test_npruntime.xul
|
||||
_TEST_FILES = \
|
||||
test_bug479979.xul \
|
||||
test_npruntime.xul \
|
||||
test_privatemode.xul \
|
||||
test_wmode.xul \
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<window title="NPAPI Private Mode Tests"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<title>NPAPI Private Mode 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" />
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
|
||||
<embed id="plugin1" type="application/x-test" width="300" height="300"></embed>
|
||||
</body>
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests() {
|
||||
var pluginElement1 = document.getElementById("plugin1");
|
||||
|
||||
var rv = true; // we want !true from the test plugin
|
||||
var exceptionThrown = false;
|
||||
try {
|
||||
rv = pluginElement1.setUndefinedValueTest();
|
||||
} catch (e) {
|
||||
exceptionThrown = true;
|
||||
}
|
||||
is(exceptionThrown, false, "Exception thrown setting undefined variable.");
|
||||
is(rv, false, "Setting undefined variable succeeded.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
|
@ -19,6 +19,12 @@ above. The default solid color is completely transparent black (i.e., nothing).
|
|||
This specifies the color to use for drawmode="solid". The value should be 8 hex
|
||||
digits, 2 per channel in AARRGGBB format.
|
||||
|
||||
== Generic API Tests ==
|
||||
|
||||
* setUndefinedValueTest
|
||||
Attempts to set the value of an undefined variable (0x0) via NPN_SetValue,
|
||||
returns true if it succeeds and false if it doesn't. It should never succeed.
|
||||
|
||||
== NPRuntime testing ==
|
||||
|
||||
The test plugin object supports the following scriptable method:
|
||||
|
|
|
@ -60,6 +60,7 @@ static NPClass sNPClass;
|
|||
typedef bool (* ScriptableFunction)
|
||||
(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
||||
static bool setUndefinedValueTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool identifierToStringTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool queryPrivateModeState(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool lastReportedPrivateModeState(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
@ -69,6 +70,7 @@ static bool getClipRegionRectCount(NPObject* npobj, const NPVariant* args, uint3
|
|||
static bool getClipRegionRectEdge(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
||||
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||
"setUndefinedValueTest",
|
||||
"identifierToStringTest",
|
||||
"queryPrivateModeState",
|
||||
"lastReportedPrivateModeState",
|
||||
|
@ -79,6 +81,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
|||
};
|
||||
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
||||
static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMethodIdentifierNames)] = {
|
||||
setUndefinedValueTest,
|
||||
identifierToStringTest,
|
||||
queryPrivateModeState,
|
||||
lastReportedPrivateModeState,
|
||||
|
@ -601,6 +604,15 @@ scriptableConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, N
|
|||
// test functions
|
||||
//
|
||||
|
||||
static bool
|
||||
setUndefinedValueTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
NPError err = NPN_SetValue(npp, (NPPVariable)0x0, 0x0);
|
||||
BOOLEAN_TO_NPVARIANT((err == NPERR_NO_ERROR), *result);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
identifierToStringTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче