From 8613b919088605ba74a315642a0e4b01a02f7ca0 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Thu, 3 Dec 2009 15:33:25 -0500 Subject: [PATCH] Add a .crash() method to the testplugin, and test that crashing throws exceptions in the parent. --- modules/plugin/test/mochitest/Makefile.in | 7 +++ .../test/mochitest/crashing_subpage.html | 4 ++ .../plugin/test/mochitest/test_crashing.html | 59 +++++++++++++++++++ modules/plugin/test/testplugin/README | 2 + modules/plugin/test/testplugin/nptest.cpp | 11 ++++ 5 files changed, 83 insertions(+) create mode 100644 modules/plugin/test/mochitest/crashing_subpage.html create mode 100644 modules/plugin/test/mochitest/test_crashing.html diff --git a/modules/plugin/test/mochitest/Makefile.in b/modules/plugin/test/mochitest/Makefile.in index faf0983505f..dd9e1404e10 100644 --- a/modules/plugin/test/mochitest/Makefile.in +++ b/modules/plugin/test/mochitest/Makefile.in @@ -69,6 +69,13 @@ _MOCHITEST_FILES = \ # test_npruntime_npnsetexception.html \ Disabled for e10s +ifdef MOZ_IPC +_MOCHITEST_FILES += \ + test_crashing.html \ + crashing_subpage.html \ + $(NULL) +endif + ifeq ($(OS_ARCH),WINNT) _MOCHITEST_FILES += \ test_windowed_invalidate.html \ diff --git a/modules/plugin/test/mochitest/crashing_subpage.html b/modules/plugin/test/mochitest/crashing_subpage.html new file mode 100644 index 00000000000..7c00f25c4c6 --- /dev/null +++ b/modules/plugin/test/mochitest/crashing_subpage.html @@ -0,0 +1,4 @@ + + +

Crashing subpage

+ diff --git a/modules/plugin/test/mochitest/test_crashing.html b/modules/plugin/test/mochitest/test_crashing.html new file mode 100644 index 00000000000..97b8583ded6 --- /dev/null +++ b/modules/plugin/test/mochitest/test_crashing.html @@ -0,0 +1,59 @@ + + Plugin crashing + + + + + + + diff --git a/modules/plugin/test/testplugin/README b/modules/plugin/test/testplugin/README index 4a18a162eb5..3bd1ae9c855 100644 --- a/modules/plugin/test/testplugin/README +++ b/modules/plugin/test/testplugin/README @@ -72,6 +72,8 @@ used as the exception message. Example: Returns a string consisting of the plugin name, concatenated with any arguments passed to the method. +* .crash() - Crashes the plugin + == Private browsing == The test plugin object supports the following scriptable methods: diff --git a/modules/plugin/test/testplugin/nptest.cpp b/modules/plugin/test/testplugin/nptest.cpp index 66d195b0e9b..cba738e8c00 100644 --- a/modules/plugin/test/testplugin/nptest.cpp +++ b/modules/plugin/test/testplugin/nptest.cpp @@ -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 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 crash(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result); static const NPUTF8* sPluginMethodIdentifierNames[] = { "npnEvaluateTest", @@ -123,6 +124,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = { "convertPointX", "convertPointY", "streamTest", + "crash", }; static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)]; static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMethodIdentifierNames)] = { @@ -152,6 +154,7 @@ static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMetho convertPointX, convertPointY, streamTest, + crash, }; struct URLNotifyData @@ -2015,6 +2018,14 @@ streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* 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 setColor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result) {