Bug 971279 - Add nptest java plugin. r=bsmedberg

This commit is contained in:
John Schoenick 2013-04-01 13:04:48 -07:00
parent 69263c0a97
commit bec6a56335
11 changed files with 146 additions and 4 deletions

View File

@ -1566,7 +1566,13 @@ bool nsPluginHost::IsJavaMIMEType(const char* aType)
(0 == PL_strncasecmp(aType, "application/x-java-applet",
sizeof("application/x-java-applet") - 1)) ||
(0 == PL_strncasecmp(aType, "application/x-java-bean",
sizeof("application/x-java-bean") - 1)));
sizeof("application/x-java-bean") - 1))
#ifdef DEBUG
// Emulate java handling for the npjavatest plugin
|| (0 == PL_strncasecmp(aType, "application/x-java-test",
sizeof("application/x-java-test") - 1))
#endif
);
}
// Check whether or not a tag is a live, valid tag, and that it's loaded.

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>libnptestjava.dylib</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.JavaTestPlugin</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BRPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0.0</string>
<key>CFBundleSignature</key>
<string>JAVATEST</string>
<key>CFBundleVersion</key>
<string>1.0.0.0</string>
<key>WebPluginName</key>
<string>Java Test Plug-in</string>
<key>WebPluginDescription</key>
<string>Dummy java plug-in for testing purposes.</string>
<key>WebPluginMIMETypes</key>
<dict>
<key>application/x-java-test</key>
<dict>
<key>WebPluginExtensions</key>
<array>
<string>tstjava</string>
</array>
<key>WebPluginTypeDescription</key>
<string>Dummy java type</string>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,8 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
RELATIVE_PATH=..
COCOA_NAME=JavaTest
include @srcdir@/../testplugin.mk

View File

@ -0,0 +1,10 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
LIBRARY_NAME = 'nptestjava'
relative_path = '..'
include('../testplugin.mozbuild')

View File

@ -0,0 +1,7 @@
LIBRARY NPJAVATEST
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3
NP_GetMIMEDescription @4

View File

@ -0,0 +1,42 @@
#include<winver.h>
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "mozilla.org"
VALUE "FileDescription", L"Dummy Java plug-in for testing purposes."
VALUE "FileExtents", "tstjava"
VALUE "FileOpenName", "Dummy java test type"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "nptestjava"
VALUE "MIMEType", "application/x-java-test"
VALUE "OriginalFilename", "nptestjava.dll"
VALUE "ProductName", "Java Test Plug-in"
VALUE "ProductVersion", "1.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

View File

@ -0,0 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const char *sPluginName = "Java Test Plug-in";
const char *sPluginDescription = "Dummy Java plug-in for testing purposes.";
const char *sMimeDescription = "application/x-java-test:tstjava:Dummy java type";

View File

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['secondplugin']
DIRS += ['secondplugin', 'javaplugin']
LIBRARY_NAME = 'nptest'

View File

@ -52,6 +52,7 @@
#include <float.h>
#include <windows.h>
#define getpid _getpid
#define strcasecmp _stricmp
#else
#include <unistd.h>
#include <pthread.h>
@ -139,6 +140,7 @@ static bool setPluginWantsAllStreams(NPObject* npobj, const NPVariant* args, uin
static bool crashPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool crashOnDestroy(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getJavaCodebase(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool checkObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool enableFPExceptions(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool setCookie(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
@ -202,6 +204,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
"crash",
"crashOnDestroy",
"getObjectValue",
"getJavaCodebase",
"checkObjectValue",
"enableFPExceptions",
"setCookie",
@ -266,6 +269,7 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
crashPlugin,
crashOnDestroy,
getObjectValue,
getJavaCodebase,
checkObjectValue,
enableFPExceptions,
setCookie,
@ -959,6 +963,11 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
if (strcmp(argn[i], "bugmode") == 0) {
instanceData->bugMode = atoi(argv[i]);
}
// Try to emulate java's codebase handling: Use the last seen codebase
// value, regardless of whether it is in attributes or params.
if (strcasecmp(argn[i], "codebase") == 0) {
instanceData->javaCodebase = argv[i];
}
}
if (!browserSupportsWindowless || !pluginSupportsWindowlessMode()) {
@ -2889,6 +2898,18 @@ static const NPClass kTestSharedNPClass = {
// Everything else is nullptr
};
static bool getJavaCodebase(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
if (argCount != 0) {
return false;
}
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
STRINGZ_TO_NPVARIANT(NPN_StrDup(id->javaCodebase.c_str()), *result);
return true;
}
static bool getObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
NPP npp = static_cast<TestNPObject*>(npobj)->npp;

View File

@ -152,6 +152,7 @@ typedef struct InstanceData {
NPAsyncSurface *backBuffer;
int32_t mouseUpEventCount;
int32_t bugMode;
std::string javaCodebase;
} InstanceData;
void notifyDidPaint(InstanceData* instanceData);

View File

@ -154,11 +154,13 @@ TEST_HARNESS_COMPONENTS := \
ifeq (Darwin,$(OS_TARGET))
TEST_HARNESS_PLUGINS := \
Test.plugin/ \
SecondTest.plugin/
SecondTest.plugin/ \
JavaTest.plugin/
else
TEST_HARNESS_PLUGINS := \
$(DLL_PREFIX)nptest$(DLL_SUFFIX) \
$(DLL_PREFIX)npsecondtest$(DLL_SUFFIX)
$(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) \
$(DLL_PREFIX)nptestjava$(DLL_SUFFIX)
endif
# Rules for staging the necessary harness bits for a test package