mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Add a .crash() method to the testplugin, and test that crashing throws exceptions in the parent.
This commit is contained in:
parent
3e06063b78
commit
8613b91908
@ -69,6 +69,13 @@ _MOCHITEST_FILES = \
|
|||||||
|
|
||||||
# test_npruntime_npnsetexception.html \ Disabled for e10s
|
# test_npruntime_npnsetexception.html \ Disabled for e10s
|
||||||
|
|
||||||
|
ifdef MOZ_IPC
|
||||||
|
_MOCHITEST_FILES += \
|
||||||
|
test_crashing.html \
|
||||||
|
crashing_subpage.html \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(OS_ARCH),WINNT)
|
ifeq ($(OS_ARCH),WINNT)
|
||||||
_MOCHITEST_FILES += \
|
_MOCHITEST_FILES += \
|
||||||
test_windowed_invalidate.html \
|
test_windowed_invalidate.html \
|
||||||
|
4
modules/plugin/test/mochitest/crashing_subpage.html
Normal file
4
modules/plugin/test/mochitest/crashing_subpage.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<html>
|
||||||
|
<body onload="window.parent.frameLoaded()">
|
||||||
|
<h1>Crashing subpage</h1>
|
||||||
|
<embed id="plugin1" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
|
59
modules/plugin/test/mochitest/test_crashing.html
Normal file
59
modules/plugin/test/mochitest/test_crashing.html
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<head>
|
||||||
|
<title>Plugin crashing</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>
|
||||||
|
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
|
||||||
|
|
||||||
|
<script class="testbody" type="application/javascript">
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
var iframe = document.getElementById('iframe1');
|
||||||
|
|
||||||
|
window.frameLoaded = function frameLoaded_toCrash() {
|
||||||
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||||
|
var prefs = Components.classes['@mozilla.org/preferences-service;1']
|
||||||
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
|
if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
|
||||||
|
ok(true, "Skipping this test when IPC plugins are not enabled.");
|
||||||
|
SimpleTest.finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = iframe.contentDocument.getElementById('plugin1');
|
||||||
|
|
||||||
|
p.setColor("FFFF00FF");
|
||||||
|
|
||||||
|
try {
|
||||||
|
p.crash();
|
||||||
|
ok(false, "p.crash() should throw an exception");
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
ok(true, "p.crash() should throw an exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
p.setColor("FFFF0000");
|
||||||
|
ok(false, "p.setColor should throw after the plugin crashes");
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
ok(true, "p.setColor should throw after the plugin crashes");
|
||||||
|
}
|
||||||
|
|
||||||
|
window.frameLoaded = function reloaded() {
|
||||||
|
var p = iframe.contentDocument.getElementById('plugin1');
|
||||||
|
try {
|
||||||
|
p.setColor('FF00FF00');
|
||||||
|
ok(true, "Reloading worked");
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
ok(false, "Reloading didn't give us a usable plugin");
|
||||||
|
}
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.contentWindow.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
@ -72,6 +72,8 @@ used as the exception message. Example:
|
|||||||
Returns a string consisting of the plugin name, concatenated with any
|
Returns a string consisting of the plugin name, concatenated with any
|
||||||
arguments passed to the method.
|
arguments passed to the method.
|
||||||
|
|
||||||
|
* .crash() - Crashes the plugin
|
||||||
|
|
||||||
== Private browsing ==
|
== Private browsing ==
|
||||||
|
|
||||||
The test plugin object supports the following scriptable methods:
|
The test plugin object supports the following scriptable methods:
|
||||||
|
@ -95,6 +95,7 @@ static bool throwExceptionNextInvoke(NPObject* npobj, const NPVariant* args, uin
|
|||||||
static bool convertPointX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
static bool convertPointX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||||
static bool convertPointY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
static bool convertPointY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||||
static bool streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
static bool streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||||
|
static bool crash(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||||
|
|
||||||
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||||
"npnEvaluateTest",
|
"npnEvaluateTest",
|
||||||
@ -123,6 +124,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
|||||||
"convertPointX",
|
"convertPointX",
|
||||||
"convertPointY",
|
"convertPointY",
|
||||||
"streamTest",
|
"streamTest",
|
||||||
|
"crash",
|
||||||
};
|
};
|
||||||
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
||||||
static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMethodIdentifierNames)] = {
|
static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMethodIdentifierNames)] = {
|
||||||
@ -152,6 +154,7 @@ static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMetho
|
|||||||
convertPointX,
|
convertPointX,
|
||||||
convertPointY,
|
convertPointY,
|
||||||
streamTest,
|
streamTest,
|
||||||
|
crash,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct URLNotifyData
|
struct URLNotifyData
|
||||||
@ -2015,6 +2018,14 @@ streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant*
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
crash(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||||
|
{
|
||||||
|
void (*funcptr)() = NULL;
|
||||||
|
funcptr(); // Crash calling null function pointer
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
setColor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
setColor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user