Bug 749257 - Improve test plugin. r=josh, r=bsmedberg

This commit is contained in:
David Keeler 2012-08-13 10:40:15 -07:00
parent f4e9f8985a
commit d0d3c04507
12 changed files with 255 additions and 94 deletions

View File

@ -80,6 +80,7 @@ MOCHITEST_FILES = \
test_pluginstream_src_referer.html \
plugin-stream-referer.sjs \
test_src_url_change.html \
test_secondPlugin.html \
$(NULL)
# test_plugin_scroll_painting.html \ bug 596491

View File

@ -0,0 +1,33 @@
<html>
<head>
<title>Second Test Plug-in Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="run()">
<object id="plugin" type="application/x-second-test" width=200 height=200></object>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
function run() {
var foundFirstPlugin = false;
var foundSecondPlugin = false;
for (var index in navigator.plugins) {
var plugin = navigator.plugins[index];
if (plugin.name == "Test Plug-in") foundFirstPlugin = true;
if (plugin.name == "Second Test Plug-in") foundSecondPlugin = true;
}
ok(foundFirstPlugin, "Should have a plugin named 'Test Plug-in'");
ok(foundSecondPlugin, "Should have a plugin named 'Second Test Plug-in'");
var pluginElement = document.getElementById("plugin");
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
SimpleTest.finish();
}
</script>
</body>
</html>

View File

@ -13,85 +13,9 @@ include $(DEPTH)/config/autoconf.mk
MODULE = nptest
LIBRARY_NAME = nptest
MODULE_NAME = TestPlugin
FORCE_SHARED_LIB = 1
# Don't use STL wrappers; nptest isn't Gecko code
STL_FLAGS =
DIRS = secondplugin
# must link statically with the CRT; nptest isn't Gecko code
USE_STATIC_LIBS = 1
# Need to custom install plugins
NO_DIST_INSTALL = 1
NO_INSTALL = 1
VPATH += $(topsrcdir)/build
CPPSRCS = \
nptest.cpp \
nptest_utils.cpp \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CMMSRCS = nptest_macosx.mm
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CPPSRCS += nptest_gtk2.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CPPSRCS += nptest_droid.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS += nptest_os2.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += nptest_qt.cpp
include $(topsrcdir)/config/config.mk
CXXFLAGS += $(MOZ_QT_CFLAGS)
CFLAGS += $(MOZ_QT_CFLAGS)
EXTRA_DSO_LDOPTS = \
$(MOZ_QT_LIBS) \
$(XLDFLAGS) \
$(XLIBS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS += nptest_windows.cpp
RCFILE = nptest.rc
RESFILE = nptest.res
DEFFILE = $(win_srcdir)/nptest.def
OS_LIBS += $(call EXPAND_LIBNAME,msimg32)
# Windows opt builds without PGO break nptest.dll
MOZ_OPTIMIZE=
endif
include $(topsrcdir)/config/rules.mk
ifndef __LP64__
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
EXTRA_DSO_LDOPTS += -framework Carbon
endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CXXFLAGS += $(MOZ_GTK2_CFLAGS)
CFLAGS += $(MOZ_GTK2_CFLAGS)
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS)
endif
install-plugin: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
$(INSTALL) $(srcdir)/Info.plist $(DIST)/bin/plugins/Test.plugin/Contents
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins/Test.plugin/Contents/MacOS
else
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
endif
endif
libs:: install-plugin
RELATIVE_PATH=.
COCOA_NAME=Test
include @srcdir@/testplugin.mk

View File

@ -59,19 +59,13 @@
using namespace std;
#define PLUGIN_NAME "Test Plug-in"
#define PLUGIN_DESCRIPTION "Plug-in for testing purposes.\xE2\x84\xA2 " \
"(\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80 " \
"\xe4\xb8\xad\xe6\x96\x87 " \
"\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a\xd8\xa9)"
#define PLUGIN_VERSION "1.0.0.0"
#define ARRAY_LENGTH(a) (sizeof(a)/sizeof(a[0]))
#define STATIC_ASSERT(condition) \
extern void np_static_assert(int arg[(condition) ? 1 : -1])
static char sPluginName[] = PLUGIN_NAME;
static char sPluginDescription[] = PLUGIN_DESCRIPTION;
extern const char *sPluginName;
extern const char *sPluginDescription;
static char sPluginVersion[] = PLUGIN_VERSION;
//
@ -603,7 +597,7 @@ NP_GetPluginVersion()
}
#endif
static char sMimeDescription[] = "application/x-test:tst:Test mimetype";
extern const char *sMimeDescription;
#if defined(XP_UNIX)
NP_EXPORT(const char*) NP_GetMIMEDescription()
@ -619,10 +613,10 @@ NP_EXPORT(NPError)
NP_GetValue(void* future, NPPVariable aVariable, void* aValue) {
switch (aVariable) {
case NPPVpluginNameString:
*((char**)aValue) = sPluginName;
*((const char**)aValue) = sPluginName;
break;
case NPPVpluginDescriptionString:
*((char**)aValue) = sPluginDescription;
*((const char**)aValue) = sPluginDescription;
break;
default:
return NPERR_INVALID_PARAM;
@ -1960,7 +1954,7 @@ scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCoun
}
ostringstream value;
value << PLUGIN_NAME;
value << sPluginName;
for (uint32_t i = 0; i < argCount; i++) {
switch(args[i].type) {
case NPVariantType_Int32:

View File

@ -0,0 +1,6 @@
const char *sPluginName = "Test Plug-in";
const char *sPluginDescription = "Plug-in for testing purposes.\xE2\x84\xA2 " \
"(\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80 " \
"\xe4\xb8\xad\xe6\x96\x87 " \
"\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a\xd8\xa9)";
const char *sMimeDescription = "application/x-test:tst:Test mimetype";

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>libnpsecondtest.dylib</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.SecondTestPlugin</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>SECONDTEST</string>
<key>CFBundleVersion</key>
<string>1.0.0.0</string>
<key>WebPluginName</key>
<string>Second Test Plug-in</string>
<key>WebPluginDescription</key>
<string>Second plug-in for testing purposes.</string>
<key>WebPluginMIMETypes</key>
<dict>
<key>application/x-second-test</key>
<dict>
<key>WebPluginExtensions</key>
<array>
<string>ts2</string>
</array>
<key>WebPluginTypeDescription</key>
<string>Second test type</string>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,19 @@
#
# 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/.
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = npsecondtest
LIBRARY_NAME = npsecondtest
MODULE_NAME = SecondTestPlugin
RELATIVE_PATH=..
COCOA_NAME=SecondTest
include @srcdir@/../testplugin.mk

View File

@ -0,0 +1,7 @@
LIBRARY NPSECONDTEST
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"Second plug-in for testing purposes."
VALUE "FileExtents", "ts2"
VALUE "FileOpenName", "Second test type"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "npsecondtest"
VALUE "MIMEType", "application/x-second-test"
VALUE "OriginalFilename", "npsecondtest.dll"
VALUE "ProductName", "Second 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 = "Second Test Plug-in";
const char *sPluginDescription = "Second plug-in for testing purposes.";
const char *sMimeDescription = "application/x-second-test:ts2:Second test type";

View File

@ -0,0 +1,88 @@
#
# 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/.
FORCE_SHARED_LIB = 1
# Don't use STL wrappers; nptest isn't Gecko code
STL_FLAGS =
# must link statically with the CRT; nptest isn't Gecko code
USE_STATIC_LIBS = 1
# Need to custom install plugins
NO_DIST_INSTALL = 1
NO_INSTALL = 1
VPATH += $(topsrcdir)/build
CPPSRCS = \
$(RELATIVE_PATH)/nptest.cpp \
$(RELATIVE_PATH)/nptest_utils.cpp \
nptest_name.cpp \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CMMSRCS = $(RELATIVE_PATH)/nptest_macosx.mm
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CPPSRCS += $(RELATIVE_PATH)/nptest_gtk2.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CPPSRCS += $(RELATIVE_PATH)/nptest_droid.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS += $(RELATIVE_PATH)/nptest_os2.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += $(RELATIVE_PATH)/nptest_qt.cpp
include $(topsrcdir)/config/config.mk
CXXFLAGS += $(MOZ_QT_CFLAGS)
CFLAGS += $(MOZ_QT_CFLAGS)
EXTRA_DSO_LDOPTS = \
$(MOZ_QT_LIBS) \
$(XLDFLAGS) \
$(XLIBS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS += $(RELATIVE_PATH)/nptest_windows.cpp
RCFILE = nptest.rc
RESFILE = nptest.res
DEFFILE = $(win_srcdir)/nptest.def
OS_LIBS += $(call EXPAND_LIBNAME,msimg32)
# Windows opt builds without PGO break nptest.dll
MOZ_OPTIMIZE=
endif
include $(topsrcdir)/config/rules.mk
ifndef __LP64__
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
EXTRA_DSO_LDOPTS += -framework Carbon
endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CXXFLAGS += $(MOZ_GTK2_CFLAGS)
CFLAGS += $(MOZ_GTK2_CFLAGS)
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS)
endif
install-plugin: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
$(INSTALL) $(srcdir)/Info.plist $(DIST)/bin/plugins/$(COCOA_NAME).plugin/Contents
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins/$(COCOA_NAME).plugin/Contents/MacOS
else
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
endif
endif
libs:: install-plugin

View File

@ -166,10 +166,12 @@ TEST_HARNESS_COMPONENTS := \
# We need the test plugin as some tests rely on it
ifeq (Darwin,$(OS_TARGET))
TEST_HARNESS_PLUGINS := \
Test.plugin/
Test.plugin/ \
SecondTest.plugin/
else
TEST_HARNESS_PLUGINS := \
$(DLL_PREFIX)nptest$(DLL_SUFFIX)
$(DLL_PREFIX)nptest$(DLL_SUFFIX) \
$(DLL_PREFIX)npsecondtest$(DLL_SUFFIX)
endif
# Rules for staging the necessary harness bits for a test package