Backed out changeset 2776db2defa2
authorJosh Aas <joshmoz@gmail.com>
Tue, 16 Dec 2008 14:38:58 -0500
changeset 22852 85ba55beac88bec1575a6ce9b3f6f0f88c8bd818
parent 22840 2776db2defa2ff4cf12f0942da2617983f5225f0
child 22853 256fbfcf4f96bf3d84474dae4f222053c182c9e4
push idunknown
push userunknown
push dateunknown
milestone1.9.2a1pre
backs out2776db2defa2ff4cf12f0942da2617983f5225f0
Backed out changeset 2776db2defa2
modules/plugin/base/public/npfunctions.h
modules/plugin/base/public/npruntime.h
modules/plugin/base/src/nsJSNPRuntime.cpp
modules/plugin/base/src/nsNPAPIPlugin.cpp
modules/plugin/test/Makefile.in
modules/plugin/test/mochitest/Makefile.in
modules/plugin/test/mochitest/test_npruntime.xul
modules/plugin/test/testplugin/Makefile.in
modules/plugin/test/testplugin/nptest.cpp
modules/plugin/test/testplugin/nptest.def
modules/plugin/test/testplugin/nptest.h
modules/plugin/test/testplugin/nptest_gtk2.cpp
modules/plugin/test/testplugin/nptest_macosx.mm
modules/plugin/test/testplugin/nptest_platform.h
modules/plugin/test/testplugin/nptest_utils.cpp
modules/plugin/test/testplugin/nptest_utils.h
modules/plugin/test/testplugin/nptest_windows.cpp
--- a/modules/plugin/base/public/npfunctions.h
+++ b/modules/plugin/base/public/npfunctions.h
@@ -53,34 +53,30 @@ typedef NPError      (*NPP_SetWindowProc
 typedef NPError      (*NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
 typedef NPError      (*NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
 typedef int32_t      (*NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream);
 typedef int32_t      (*NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
 typedef void         (*NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname);
 typedef void         (*NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint);
 typedef int16_t      (*NPP_HandleEventProcPtr)(NPP instance, void* event);
 typedef void         (*NPP_URLNotifyProcPtr)(NPP instance, const char* url, NPReason reason, void* notifyData);
-// Any NPObjects returned to the browser via NPP_GetValue should be retained
-// by the plugin on the way out. The browser is responsible for releasing.
 typedef NPError      (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
 typedef NPError      (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
 
 typedef NPError      (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
 typedef NPError      (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
 typedef NPError      (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* url, const char* window, void* notifyData);
 typedef NPError      (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData);
 typedef NPError      (*NPN_GetURLProcPtr)(NPP instance, const char* url, const char* window);
 typedef NPError      (*NPN_PostURLProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file);
 typedef NPError      (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList);
 typedef NPError      (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
 typedef int32_t      (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer);
 typedef NPError      (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
 typedef void         (*NPN_StatusProcPtr)(NPP instance, const char* message);
-// Browser manages the lifetime of the buffer returned by NPN_UserAgent, don't
-// depend on it sticking around and don't free it.
 typedef const char*  (*NPN_UserAgentProcPtr)(NPP instance);
 typedef void*        (*NPN_MemAllocProcPtr)(uint32_t size);
 typedef void         (*NPN_MemFreeProcPtr)(void* ptr);
 typedef uint32_t     (*NPN_MemFlushProcPtr)(uint32_t size);
 typedef void         (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages);
 typedef void*        (*NPN_GetJavaEnvProcPtr)();
 typedef void*        (*NPN_GetJavaPeerProcPtr)(NPP instance);
 typedef void         (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect);
@@ -240,17 +236,17 @@ typedef struct _NPPluginData {   /* Alte
   char *pProductName;
   char *pProductDescription;
   unsigned long dwProductVersionMS;
   unsigned long dwProductVersionLS;
 } NPPluginData;
 NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData);
 #endif
 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
-NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs);
+NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
 NPError OSCALL NP_Shutdown();
 char*          NP_GetMIMEDescription();
 #ifdef __cplusplus
 }
 #endif
 #endif
 
 #if defined(__OS2__)
--- a/modules/plugin/base/public/npruntime.h
+++ b/modules/plugin/base/public/npruntime.h
@@ -1,11 +1,11 @@
 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
- * Copyright (c) 2004, Apple Computer, Inc. and The Mozilla Foundation. 
+ * Copyright  2004, Apple Computer, Inc. and The Mozilla Foundation. 
  * All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
  * 
  * 1. Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
@@ -110,18 +110,18 @@ extern "C" {
     always wrapped in an NPObject.  The 'interface' of an NPObject is
     described by an NPClass.
 */
 typedef struct NPObject NPObject;
 typedef struct NPClass NPClass;
 
 typedef char NPUTF8;
 typedef struct _NPString {
-    const NPUTF8 *UTF8Characters;
-    uint32_t UTF8Length;
+    const NPUTF8 *utf8characters;
+    uint32_t utf8length;
 } NPString;
 
 typedef enum {
     NPVariantType_Void,
     NPVariantType_Null,
     NPVariantType_Bool,
     NPVariantType_Int32,
     NPVariantType_Double,
@@ -213,49 +213,47 @@ NP_END_MACRO
 #define OBJECT_TO_NPVARIANT(_val, _v)                                         \
 NP_BEGIN_MACRO                                                                \
     (_v).type = NPVariantType_Object;                                         \
     (_v).value.objectValue = _val;                                            \
 NP_END_MACRO
 
 
 /*
-  Type mappings (JavaScript types have been used for illustration
+	Type mappings (JavaScript types have been used for illustration
     purposes):
 
-  JavaScript       to             C (NPVariant with type:)
-  undefined                       NPVariantType_Void
-  null                            NPVariantType_Null
-  Boolean                         NPVariantType_Bool
-  Number                          NPVariantType_Double or NPVariantType_Int32
-  String                          NPVariantType_String
-  Object                          NPVariantType_Object
+	JavaScript       to             C (NPVariant with type:)
+	undefined                       NPVariantType_Void
+	null                            NPVariantType_Null
+	Boolean                         NPVariantType_Bool
+	Number                          NPVariantType_Double or NPVariantType_Int32
+	String                          NPVariantType_String
+	Object                          NPVariantType_Object
 
-  C (NPVariant with type:)   to   JavaScript
-  NPVariantType_Void              undefined
-  NPVariantType_Null              null
-  NPVariantType_Bool              Boolean
-  NPVariantType_Int32             Number
-  NPVariantType_Double            Number
-  NPVariantType_String            String
-  NPVariantType_Object            Object
+	C (NPVariant with type:)   to   JavaScript
+	NPVariantType_Void              undefined
+	NPVariantType_Null              null
+	NPVariantType_Bool              Boolean	
+	NPVariantType_Int32             Number
+	NPVariantType_Double            Number
+	NPVariantType_String            String
+	NPVariantType_Object            Object
 */
 
 typedef void *NPIdentifier;
 
 /*
     NPObjects have methods and properties.  Methods and properties are
     identified with NPIdentifiers.  These identifiers may be reflected
     in script.  NPIdentifiers can be either strings or integers, IOW,
     methods and properties can be identified by either strings or
     integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be
     compared using ==.  In case of any errors, the requested
-    NPIdentifier(s) will be NULL. NPIdentifier lifetime is controlled
-    by the browser. Plugins do not need to worry about memory management
-    with regards to NPIdentifiers.
+    NPIdentifier(s) will be NULL.
 */
 NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);
 void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
                               NPIdentifier *identifiers);
 NPIdentifier NPN_GetIntIdentifier(int32_t intid);
 bool NPN_IdentifierIsString(NPIdentifier identifier);
 
 /*
--- a/modules/plugin/base/src/nsJSNPRuntime.cpp
+++ b/modules/plugin/base/src/nsJSNPRuntime.cpp
@@ -349,17 +349,17 @@ NPVariantToJSVal(NPP npp, JSContext *cx,
         return val;
       }
 
       break;
     }
   case NPVariantType_String :
     {
       const NPString *s = &NPVARIANT_TO_STRING(*variant);
-      NS_ConvertUTF8toUTF16 utf16String(s->UTF8Characters, s->UTF8Length);
+      NS_ConvertUTF8toUTF16 utf16String(s->utf8characters, s->utf8length);
 
       JSString *str =
         ::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar*>
                                                   (utf16String.get()),
                               utf16String.Length());
 
       if (str) {
         return STRING_TO_JSVAL(str);
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -1518,24 +1518,24 @@ bool NP_CALLBACK
   JSAutoTempValueRooter tvr(cx, NS_ARRAY_LENGTH(vec), vec);
   jsval *rval = &vec[1];
 
   if (result) {
     // Initialize the out param to void
     VOID_TO_NPVARIANT(*result);
   }
 
-  if (!script || !script->UTF8Length || !script->UTF8Characters) {
+  if (!script || !script->utf8length || !script->utf8characters) {
     // Nothing to evaluate.
 
     return true;
   }
 
-  NS_ConvertUTF8toUTF16 utf16script(script->UTF8Characters,
-                                    script->UTF8Length);
+  NS_ConvertUTF8toUTF16 utf16script(script->utf8characters,
+                                    script->utf8length);
 
   nsCOMPtr<nsIScriptContext> scx = GetScriptContextFromJSContext(cx);
   NS_ENSURE_TRUE(scx, false);
 
   nsIPrincipal *principal = doc->NodePrincipal();
 
   nsCAutoString specStr;
   const char *spec;
@@ -1563,17 +1563,17 @@ bool NP_CALLBACK
       spec = specStr.get();
     } else {
       spec = nsnull;
     }
   }
 
   NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
                  ("NPN_Evaluate(npp %p, npobj %p, script <<<%s>>>) called\n",
-                  npp, npobj, script->UTF8Characters));
+                  npp, npobj, script->utf8characters));
 
   nsresult rv = scx->EvaluateStringWithValue(utf16script, obj, principal,
                                              spec, 0, 0, rval, nsnull);
 
   return NS_SUCCEEDED(rv) &&
          (!result || JSValToNPVariant(npp, cx, *rval, result));
 }
 
@@ -1758,36 +1758,36 @@ void NP_CALLBACK
   case NPVariantType_Bool :
   case NPVariantType_Int32 :
   case NPVariantType_Double :
     break;
   case NPVariantType_String :
     {
       const NPString *s = &NPVARIANT_TO_STRING(*variant);
 
-      if (s->UTF8Characters) {
+      if (s->utf8characters) {
 #ifdef MOZ_MEMORY_WINDOWS
-        if (malloc_usable_size((void *)s->UTF8Characters) != 0) {
-          PR_Free((void *)s->UTF8Characters);
+        if (malloc_usable_size((void *)s->utf8characters) != 0) {
+          PR_Free((void *)s->utf8characters);
         } else {
-          void *p = (void *)s->UTF8Characters;
+          void *p = (void *)s->utf8characters;
           DWORD nheaps = 0;
           nsAutoTArray<HANDLE, 50> heaps;
           nheaps = GetProcessHeaps(0, heaps.Elements());
           heaps.AppendElements(nheaps);
           GetProcessHeaps(nheaps, heaps.Elements());
           for (DWORD i = 0; i < nheaps; i++) {
             if (InHeap(heaps[i], p)) {
               HeapFree(heaps[i], 0, p);
               break;
             }
           }
         }
 #else
-        PR_Free((void *)s->UTF8Characters);
+        PR_Free((void *)s->utf8characters);
 #endif
       }
       break;
     }
   case NPVariantType_Object:
     {
       NPObject *npobj = NPVARIANT_TO_OBJECT(*variant);
 
--- a/modules/plugin/test/Makefile.in
+++ b/modules/plugin/test/Makefile.in
@@ -15,17 +15,16 @@
 # The Original Code is mozilla.org code.
 #
 # The Initial Developer of the Original Code is mozilla.org
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Dave Townsend <dtownsend@oxymoronical.com>
-#   Josh Aas <josh@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -46,16 +45,9 @@ include $(DEPTH)/config/autoconf.mk
 MODULE = test_plugin
 
 DIRS = testplugin
 
 XPCSHELL_TESTS = \
   unit \
   $(NULL)
 
-# plugin mochitests only work on UNIX variants, including Mac OS X, at this time
-ifneq (,$(filter gtk2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
-ifdef ENABLE_TESTS
-DIRS  += mochitest
-endif
-endif
-
 include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/modules/plugin/test/mochitest/Makefile.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Mozilla Foundation.
-# Portions created by the Initial Developer are Copyright (C) 2007
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-relativesrcdir  = modules/plugin/test
-
-include $(DEPTH)/config/autoconf.mk
-include $(topsrcdir)/config/rules.mk
-
-_TEST_FILES =	test_npruntime.xul
-
-libs:: $(_TEST_FILES)
-	$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
deleted file mode 100644
--- a/modules/plugin/test/mochitest/test_npruntime.xul
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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="Basic Plugin Tests"
-  xmlns:html="http://www.w3.org/1999/xhtml"
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <title>Basic Plugin 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="400" height="400"></embed>
-</body>
-<script class="testbody" type="application/javascript">
-<![CDATA[
-SimpleTest.waitForExplicitFinish();
-
-function runTests() {
-  var pluginElement = document.getElementById("plugin1");
-
-  ok(pluginElement.identifierToStringTest('foo') == "foo", "identifierToStringTest failed");
-
-  SimpleTest.finish();
-}
-]]>
-</script>
-</window>
--- a/modules/plugin/test/testplugin/Makefile.in
+++ b/modules/plugin/test/testplugin/Makefile.in
@@ -49,35 +49,22 @@ MODULE_NAME  = TestPlugin
 REQUIRES = \
   plugin \
   $(NULL)
 
 # Need to custom install plugins
 NO_DIST_INSTALL	= 1
 NO_INSTALL = 1
 
-CPPSRCS   =  \
-  nptest.cpp \
-  nptest_utils.cpp \
-  $(NULL)
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-CMMSRCS = nptest_macosx.mm
+ifeq ($(OS_ARCH),WINNT)
+RCFILE    = nptest.rc
+RESFILE   = nptest.res
 endif
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
-CPPSRCS += nptest_gtk2.cpp
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
-CPPSRCS  += nptest_windows.cpp
-RCFILE    = nptest.rc
-RESFILE   = nptest.res
-DEFFILE   = $(win_srcdir)/nptest.def
-endif
+CPPSRCS   = nptest.cpp
 
 include $(topsrcdir)/config/rules.mk
 
 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
--- a/modules/plugin/test/testplugin/nptest.cpp
+++ b/modules/plugin/test/testplugin/nptest.cpp
@@ -1,515 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (c) 2008, Mozilla Corporation
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the Mozilla Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is mozilla.org
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
  * Contributor(s):
  *   Dave Townsend <dtownsend@oxymoronical.com>
- *   Josh Aas <josh@mozilla.com>
- * 
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nptest.h"
-#include "nptest_utils.h"
-#include "nptest_platform.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#define PLUGIN_NAME        "Test Plug-in"
-#define PLUGIN_DESCRIPTION "Plug-in for testing purposes."
-#define PLUGIN_VERSION     "1.0.0.0"
-
-//
-// static data
-//
-
-static NPNetscapeFuncs* sBrowserFuncs = NULL;
-static NPClass sNPClass;
-
-//
-// identifiers
-//
-
-#define IDENTIFIER_TO_STRING_TEST_METHOD 0
-#define NUM_METHOD_IDENTIFIERS           1
-
-static NPIdentifier sPluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
-static const NPUTF8 *sPluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
-  "identifierToStringTest",
-};
-
-static bool sIdentifiersInitialized = false;
-
-static void initializeIdentifiers()
-{
-  if (!sIdentifiersInitialized) {
-    NPN_GetStringIdentifiers(sPluginMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, sPluginMethodIdentifiers);
-    sIdentifiersInitialized = true;    
-  }
-}
-
-static void clearIdentifiers()
-{
-  memset(sPluginMethodIdentifierNames, 0, NUM_METHOD_IDENTIFIERS * sizeof(NPIdentifier));
-  sIdentifiersInitialized = false;
-}
-
-//
-// function signatures
-//
-
-bool identifierToStringTest(const NPVariant* args, uint32_t argCount, NPVariant* result);
-
-NPObject* scriptableAllocate(NPP npp, NPClass* aClass);
-void scriptableDeallocate(NPObject* npobj);
-void scriptableInvalidate(NPObject* npobj);
-bool scriptableHasMethod(NPObject* npobj, NPIdentifier name);
-bool scriptableInvoke(NPObject* npobj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result);
-bool scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
-bool scriptableHasProperty(NPObject* npobj, NPIdentifier name);
-bool scriptableGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result);
-bool scriptableSetProperty(NPObject* npobj, NPIdentifier name, const NPVariant* value);
-bool scriptableRemoveProperty(NPObject* npobj, NPIdentifier name);
-bool scriptableEnumerate(NPObject* npobj, NPIdentifier** identifier, uint32_t* count);
-bool scriptableConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
-
-//
-// npapi plugin functions
-//
-
-#ifdef XP_UNIX
-NP_EXPORT(char*)
-NP_GetPluginVersion()
-{
-  return PLUGIN_VERSION;
-}
-#endif
+#include "npapi.h"
+#include "npfunctions.h"
 
 #if defined(XP_UNIX)
-NP_EXPORT(char*) NP_GetMIMEDescription()
-#elif defined(XP_WIN)
-char* NP_GetMIMEDescription()
-#endif
-{
-  return "application/x-test:tst:Test mimetype";
-}
-
-#ifdef XP_UNIX
-NP_EXPORT(NPError)
-NP_GetValue(void* future, NPPVariable aVariable, void* aValue) {
-  switch (aVariable) {
-    case NPPVpluginNameString:
-      *((char**)aValue) = PLUGIN_NAME;
-      break;
-    case NPPVpluginDescriptionString:
-      *((char**)aValue) = PLUGIN_DESCRIPTION;
-      break;
-    default:
-      return NPERR_INVALID_PARAM;
-      break;
-  }
-  return NPERR_NO_ERROR;
-}
-#endif
-
-static void fillPluginFunctionTable(NPPluginFuncs* pFuncs)
-{
-  pFuncs->version = 11;
-  pFuncs->size = sizeof(*pFuncs);
-  pFuncs->newp = NPP_New;
-  pFuncs->destroy = NPP_Destroy;
-  pFuncs->setwindow = NPP_SetWindow;
-  pFuncs->newstream = NPP_NewStream;
-  pFuncs->destroystream = NPP_DestroyStream;
-  pFuncs->asfile = NPP_StreamAsFile;
-  pFuncs->writeready = NPP_WriteReady;
-  pFuncs->write = NPP_Write;
-  pFuncs->print = NPP_Print;
-  pFuncs->event = NPP_HandleEvent;
-  pFuncs->urlnotify = NPP_URLNotify;
-  pFuncs->getvalue = NPP_GetValue;
-  pFuncs->setvalue = NPP_SetValue;
-}
-
-#if defined(XP_MACOSX)
-NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs)
-#elif defined(XP_WIN)
-NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs)
-#elif defined(XP_UNIX)
-NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs)
-#endif
-{
-  sBrowserFuncs = bFuncs;
-
-  initializeIdentifiers();
-
-  memset(&sNPClass, 0, sizeof(NPClass));
-  sNPClass.structVersion =  NP_CLASS_STRUCT_VERSION;
-  sNPClass.allocate =       (NPAllocateFunctionPtr)scriptableAllocate;
-  sNPClass.deallocate =     (NPDeallocateFunctionPtr)scriptableDeallocate;
-  sNPClass.invalidate =     (NPInvalidateFunctionPtr)scriptableInvalidate;
-  sNPClass.hasMethod =      (NPHasMethodFunctionPtr)scriptableHasMethod;
-  sNPClass.invoke =         (NPInvokeFunctionPtr)scriptableInvoke;
-  sNPClass.invokeDefault =  (NPInvokeDefaultFunctionPtr)scriptableInvokeDefault;
-  sNPClass.hasProperty =    (NPHasPropertyFunctionPtr)scriptableHasProperty;
-  sNPClass.getProperty =    (NPGetPropertyFunctionPtr)scriptableGetProperty;
-  sNPClass.setProperty =    (NPSetPropertyFunctionPtr)scriptableSetProperty;
-  sNPClass.removeProperty = (NPRemovePropertyFunctionPtr)scriptableRemoveProperty;
-  sNPClass.enumerate =      (NPEnumerationFunctionPtr)scriptableEnumerate;
-  sNPClass.construct =      (NPConstructFunctionPtr)scriptableConstruct;
 
-#if defined(XP_UNIX) && !defined(XP_MACOSX)
-  fillPluginFunctionTable(pFuncs);
-#endif
-
-  return NPERR_NO_ERROR;
-}
-
-#if defined(XP_MACOSX)
-NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs)
-#elif defined(XP_WIN)
-NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
-#endif
-#if defined(XP_MACOSX) || defined(XP_WIN)
-{
-  fillPluginFunctionTable(pFuncs);
-  return NPERR_NO_ERROR;
-}
-#endif
-
-#if defined(XP_UNIX)
-NP_EXPORT(NPError) NP_Shutdown()
-#elif defined(XP_WIN)
-NPError OSCALL NP_Shutdown()
-#endif
-{
-  clearIdentifiers();
-
-  return NPERR_NO_ERROR;
-}
-
-NPError
-NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
-{
-  NPN_SetValue(instance, NPPVpluginWindowBool, NULL);
+#define PLUGIN_NAME         "Test Plug-in"
+#define PLUGIN_DESCRIPTION  "Plug-in for testing purposes."
+#define PLUGIN_VERSION      "1.0.0.0"
 
-  // set up our our instance data
-  InstanceData* instanceData = (InstanceData*)malloc(sizeof(InstanceData));
-  if (!instanceData)
-    return NPERR_OUT_OF_MEMORY_ERROR;
-  memset(instanceData, 0, sizeof(InstanceData));
-  instanceData->npp = instance;
-  instance->pdata = instanceData;
-
-  TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
-  if (!scriptableObject) {
-    printf("NPN_CreateObject failed to create an object, can't create a plugin instance\n");
-    return NPERR_GENERIC_ERROR;
-  }
-  NPN_RetainObject(scriptableObject);
-  scriptableObject->npp = instance;
-  instanceData->scriptableObject = scriptableObject;
-
-  // do platform-specific initialization
-  NPError err = pluginInstanceInit(instanceData);
-  if (err != NPERR_NO_ERROR)
-    return err;
-
-  return NPERR_NO_ERROR;
-}
-
-NPError
-NPP_Destroy(NPP instance, NPSavedData** save)
-{
-  return NPERR_NO_ERROR;
-}
-
-NPError
-NPP_SetWindow(NPP instance, NPWindow* window)
-{
-  InstanceData* instanceData = (InstanceData*)(instance->pdata);
-  instanceData->window = *window;
-  return NPERR_NO_ERROR;
+NP_EXPORT(char*)
+NP_GetPluginVersion(void) {
+    return PLUGIN_VERSION;
 }
 
-NPError
-NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
-{
-  *stype = NP_ASFILEONLY;
-  return NPERR_NO_ERROR;
-}
-
-NPError
-NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
-{
-  return NPERR_NO_ERROR;
-}
-
-int32_t
-NPP_WriteReady(NPP instance, NPStream* stream)
-{
-  return 0;
-}
-
-int32_t
-NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
-{
-  return 0;
-}
-
-void
-NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
-{
-}
-
-void
-NPP_Print(NPP instance, NPPrint* platformPrint)
-{
-}
-
-int16_t
-NPP_HandleEvent(NPP instance, void* event)
-{
-  InstanceData* instanceData = (InstanceData*)(instance->pdata);
-  return pluginHandleEvent(instanceData, event);
-}
-
-void
-NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
-{
-}
-
-NPError
-NPP_GetValue(NPP instance, NPPVariable variable, void* value)
-{
-  if (variable == NPPVpluginScriptableNPObject) {
-    NPObject* object = ((InstanceData*)instance->pdata)->scriptableObject;
-    NPN_RetainObject(object);
-    *((NPObject**)value) = object;
-    return NPERR_NO_ERROR;
-  }
-
-  return NPERR_GENERIC_ERROR;
+NP_EXPORT(char*)
+NP_GetMIMEDescription(void) {
+    return "application/x-test:tst:Test mimetype";
 }
 
-NPError
-NPP_SetValue(NPP instance, NPNVariable variable, void* value)
-{
-  return NPERR_GENERIC_ERROR;
-}
-
-//
-// npapi browser functions
-//
-
-bool
-NPN_SetProperty(NPP instance, NPObject* obj, NPIdentifier propertyName, const NPVariant* value)
-{
-  return sBrowserFuncs->setproperty(instance, obj, propertyName, value);
-}
-
-NPIdentifier
-NPN_GetIntIdentifier(int32_t intid)
-{
-  return sBrowserFuncs->getintidentifier(intid);
-}
-
-NPIdentifier
-NPN_GetStringIdentifier(const NPUTF8* name)
-{
-  return sBrowserFuncs->getstringidentifier(name);
+NP_EXPORT(NPError)
+NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*) {
+    return NPERR_NO_ERROR;
 }
 
-void
-NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers)
-{
-  return sBrowserFuncs->getstringidentifiers(names, nameCount, identifiers);
-}
-
-NPUTF8*
-NPN_UTF8FromIdentifier(NPIdentifier identifier)
-{
-  return sBrowserFuncs->utf8fromidentifier(identifier);
-}
-
-int32_t
-NPN_IntFromIdentifier(NPIdentifier identifier)
-{
-  return sBrowserFuncs->intfromidentifier(identifier);
-}
-
-NPError
-NPN_GetValue(NPP instance, NPNVariable variable, void* value)
-{
-  return sBrowserFuncs->getvalue(instance, variable, value);
-}
-
-NPError
-NPN_SetValue(NPP instance, NPPVariable variable, void* value)
-{
-  return sBrowserFuncs->setvalue(instance, variable, value);
-}
-
-bool
-NPN_HasProperty(NPP instance, NPObject* obj, NPIdentifier propertyName)
-{
-  return sBrowserFuncs->hasproperty(instance, obj, propertyName);
+NP_EXPORT(NPError)
+NP_Shutdown(void) {
+    return NPERR_NO_ERROR;
 }
 
-NPObject*
-NPN_CreateObject(NPP instance, NPClass* aClass)
-{
-  return sBrowserFuncs->createobject(instance, aClass);
-}
-
-const char*
-NPN_UserAgent(NPP instance)
-{
-  return sBrowserFuncs->uagent(instance);
-}
-
-NPObject*
-NPN_RetainObject(NPObject* obj)
-{
-  return sBrowserFuncs->retainobject(obj);
-}
-
-void*
-NPN_MemAlloc(uint32_t size)
-{
-  return sBrowserFuncs->memalloc(size);
-}
-
-void
-NPN_MemFree(void* ptr)
-{
-  return sBrowserFuncs->memfree(ptr);
-}
-
-//
-// npruntime object functions
-//
-
-NPObject*
-scriptableAllocate(NPP npp, NPClass* aClass)
-{
-  TestNPObject* object = (TestNPObject*)NPN_MemAlloc(sizeof(TestNPObject));
-  if (!object)
-    return NULL;
-  memset(object, 0, sizeof(TestNPObject));
-  return object;
-}
-
-void
-scriptableDeallocate(NPObject* npobj)
-{
-  NPN_MemFree(npobj);
-}
-
-void
-scriptableInvalidate(NPObject* npobj)
-{
-}
-
-bool
-scriptableHasMethod(NPObject* npobj, NPIdentifier name)
-{
-  for (int i = 0; i < NUM_METHOD_IDENTIFIERS; i++) {
-    if (name == sPluginMethodIdentifiers[i])
-      return true;
-  }
-  return false;
+NP_EXPORT(NPError) 
+NP_GetValue(void *future, NPPVariable aVariable, void *aValue) {
+   switch (aVariable) {
+     case NPPVpluginNameString:
+       *((char **)aValue) = PLUGIN_NAME;
+       break;
+     case NPPVpluginDescriptionString:
+       *((char **)aValue) = PLUGIN_DESCRIPTION;
+       break;
+     default:
+       return NPERR_INVALID_PARAM;
+       break;
+   }
+   return NPERR_NO_ERROR;
 }
 
-bool
-scriptableInvoke(NPObject* npobj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
-{
-  if (name == sPluginMethodIdentifiers[IDENTIFIER_TO_STRING_TEST_METHOD])
-    return identifierToStringTest(args, argCount, result);
-  return false;
-}
-
-bool
-scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
-{
-  return false;
-}
-
-bool
-scriptableHasProperty(NPObject* npobj, NPIdentifier name)
-{
-  return false;
-}
-
-bool
-scriptableGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result)
-{
-  return false;
-}
-
-bool
-scriptableSetProperty(NPObject* npobj, NPIdentifier name, const NPVariant* value)
-{
-  return false;
-}
-
-bool
-scriptableRemoveProperty(NPObject* npobj, NPIdentifier name)
-{
-  return false;
-}
-
-bool
-scriptableEnumerate(NPObject* npobj, NPIdentifier** identifier, uint32_t* count)
-{
-  return false;
-}
-
-bool
-scriptableConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
-{
-  return false;
-}
-
-//
-// test functions
-//
-
-bool
-identifierToStringTest(const NPVariant* args, uint32_t argCount, NPVariant* result)
-{
-  if (argCount != 1)
-    return false;
-  NPIdentifier identifier = variantToIdentifier(args[0]);
-  if (!identifier)
-    return false;
-  NPUTF8* utf8String = NPN_UTF8FromIdentifier(identifier);
-  if (!utf8String)
-    return false;
-  STRINGZ_TO_NPVARIANT(utf8String, *result);
-  return true;
-}
+#endif
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest.def
+++ /dev/null
@@ -1,7 +0,0 @@
-LIBRARY   NPTEST
-
-EXPORTS
-  NP_GetEntryPoints     @1
-  NP_Initialize         @2
-  NP_Shutdown           @3
-  NP_GetMIMEDescription @4
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (c) 2008, Mozilla Corporation
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the Mozilla Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nptest_h_
-#define nptest_h_
-
-#include "mozilla-config.h"
-
-#include "npapi.h"
-#include "npfunctions.h"
-#include "npruntime.h"
-
-typedef struct TestNPObject : NPObject {
-  NPP npp;
-} TestNPObject;
-
-typedef struct InstanceData {
-  NPP npp;
-  NPWindow window;
-  TestNPObject* scriptableObject;
-} InstanceData;
-
-#endif // nptest_h_
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest_gtk2.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (c) 2008, Mozilla Corporation
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the Mozilla Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#include "nptest_platform.h"
-
-NPError
-pluginInstanceInit(InstanceData* instanceData)
-{
-  return NPERR_NO_ERROR;
-}
-
-int16_t
-pluginHandleEvent(InstanceData* instanceData, void* event)
-{
-  return 0;
-}
-
-void
-pluginDraw(InstanceData* instanceData)
-{
-}
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest_macosx.mm
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (c) 2008, Mozilla Corporation
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the Mozilla Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#include "nptest_platform.h"
-#include <CoreServices/CoreServices.h>
-
-NPError
-pluginInstanceInit(InstanceData* instanceData)
-{
-  NPP npp = instanceData->npp;
-  // select the right drawing model if necessary
-  NPBool supportsCoreGraphics = false;
-  if (NPN_GetValue(npp, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) == NPERR_NO_ERROR && supportsCoreGraphics) {
-    NPN_SetValue(npp, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics);
-  } else {
-    printf("CoreGraphics drawing model not supported, can't create a plugin instance.\n");
-    return NPERR_INCOMPATIBLE_VERSION_ERROR;
-  }
-  return NPERR_NO_ERROR;
-}
-
-int16_t
-pluginHandleEvent(InstanceData* instanceData, void* event)
-{
-  EventRecord* carbonEvent = (EventRecord*)event;
-  if (carbonEvent && (carbonEvent->what == updateEvt)) {
-    pluginDraw(instanceData);
-    return 1;
-  }
-  return 0;
-}
-
-void
-pluginDraw(InstanceData* instanceData)
-{
-  if (!instanceData)
-    return;
-
-  NPP npp = instanceData->npp;
-  if (!npp)
-    return;
-
-  const char* uaString = NPN_UserAgent(npp);
-  if (!uaString)
-    return;
-
-  NPWindow window = instanceData->window;
-
-  CGContextRef cgContext = ((NP_CGContext*)(window.window))->context;
-
-  CFStringRef uaCFString = CFStringCreateWithCString(kCFAllocatorDefault, uaString, kCFStringEncodingASCII);
-
-  float windowWidth = window.width;
-  float windowHeight = window.height;
-
-  // save the cgcontext gstate
-  CGContextSaveGState(cgContext);
-
-  // we get a flipped context
-  CGContextTranslateCTM(cgContext, 0.0, windowHeight);
-  CGContextScaleCTM(cgContext, 1.0, -1.0);
-
-  // draw a gray background for the plugin
-  CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
-  CGContextSetGrayFillColor(cgContext, 0.5, 1.0);
-  CGContextDrawPath(cgContext, kCGPathFill);
-
-  // draw a black frame around the plugin
-  CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
-  CGContextSetGrayStrokeColor(cgContext, 0.0, 1.0);
-  CGContextSetLineWidth(cgContext, 6.0);
-  CGContextStrokePath(cgContext);
-
-  // draw the UA string using ATSUI
-  CGContextSetGrayFillColor(cgContext, 0.0, 1.0);
-  ATSUStyle atsuStyle;
-  ATSUCreateStyle(&atsuStyle);
-  CFIndex stringLength = CFStringGetLength(uaCFString);
-  UniChar* unicharBuffer = (UniChar*)malloc((stringLength + 1) * sizeof(UniChar));
-  CFStringGetCharacters(uaCFString, CFRangeMake(0, stringLength), unicharBuffer);
-  UniCharCount runLengths = kATSUToTextEnd;
-  ATSUTextLayout atsuLayout;
-  ATSUCreateTextLayoutWithTextPtr(unicharBuffer,
-                                  kATSUFromTextBeginning,
-                                  kATSUToTextEnd,
-                                  stringLength,
-                                  1,
-                                  &runLengths,
-                                  &atsuStyle,
-                                  &atsuLayout);
-  ATSUAttributeTag contextTag = kATSUCGContextTag;
-  ByteCount byteSize = sizeof(CGContextRef);
-  ATSUAttributeValuePtr contextATSUPtr = &cgContext;
-  ATSUSetLayoutControls(atsuLayout, 1, &contextTag, &byteSize, &contextATSUPtr);
-  ATSUTextMeasurement lineAscent, lineDescent;
-  ATSUGetLineControl(atsuLayout,
-                     kATSUFromTextBeginning,
-                     kATSULineAscentTag,
-                     sizeof(ATSUTextMeasurement),
-                     &lineAscent,
-                     &byteSize);
-  ATSUGetLineControl(atsuLayout,
-                     kATSUFromTextBeginning,
-                     kATSULineDescentTag,
-                     sizeof(ATSUTextMeasurement),
-                     &lineDescent,
-                     &byteSize);
-  float lineHeight = FixedToFloat(lineAscent) + FixedToFloat(lineDescent);
-  ItemCount softBreakCount;
-  ATSUBatchBreakLines(atsuLayout,
-                      kATSUFromTextBeginning,
-                      stringLength,
-                      FloatToFixed(windowWidth - 10.0),
-                      &softBreakCount);
-  ATSUGetSoftLineBreaks(atsuLayout,
-                        kATSUFromTextBeginning,
-                        kATSUToTextEnd,
-                        0, NULL, &softBreakCount);
-  UniCharArrayOffset* softBreaks = (UniCharArrayOffset*)malloc(softBreakCount * sizeof(UniCharArrayOffset));
-  ATSUGetSoftLineBreaks(atsuLayout,
-                        kATSUFromTextBeginning,
-                        kATSUToTextEnd,
-                        softBreakCount, softBreaks, &softBreakCount);
-  UniCharArrayOffset currentDrawOffset = kATSUFromTextBeginning;
-  unsigned int i = 0;
-  while (i < softBreakCount) {
-    ATSUDrawText(atsuLayout, currentDrawOffset, softBreaks[i], FloatToFixed(5.0), FloatToFixed(windowHeight - 5.0 - (lineHeight * (i + 1.0))));
-    currentDrawOffset = softBreaks[i];
-    i++;
-  }
-  ATSUDrawText(atsuLayout, currentDrawOffset, kATSUToTextEnd, FloatToFixed(5.0), FloatToFixed(windowHeight - 5.0 - (lineHeight * (i + 1.0))));
-  free(unicharBuffer);
-  free(softBreaks);
-
-  // restore the cgcontext gstate
-  CGContextRestoreGState(cgContext);
-}
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest_platform.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (c) 2008, Mozilla Corporation
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the Mozilla Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nptest_platform_h_
-#define nptest_platform_h_
-
-#include "nptest.h"
-
-NPError pluginInstanceInit(InstanceData* instanceData);
-int16_t pluginHandleEvent(InstanceData* instanceData, void* event);
-// draws a gray box with a black border containing the browser UA string
-void    pluginDraw(InstanceData* instanceData);
-
-#endif // nptest_platform_h_
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest_utils.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#include "nptest_utils.h"
-
-#include <string.h>
-
-NPUTF8*
-createCStringFromNPVariant(const NPVariant* variant)
-{
-  size_t length = NPVARIANT_TO_STRING(*variant).UTF8Length;
-  NPUTF8* result = (NPUTF8*)malloc(length + 1);
-  memcpy(result, NPVARIANT_TO_STRING(*variant).UTF8Characters, length);
-  result[length] = '\0';
-  return result;
-}
-
-NPIdentifier
-variantToIdentifier(NPVariant variant)
-{
-  if (NPVARIANT_IS_STRING(variant))
-    return stringVariantToIdentifier(variant);
-  else if (NPVARIANT_IS_INT32(variant))
-    return int32VariantToIdentifier(variant);
-  else if (NPVARIANT_IS_DOUBLE(variant))
-    return doubleVariantToIdentifier(variant);
-  return 0;
-}
-
-NPIdentifier
-stringVariantToIdentifier(NPVariant variant)
-{
-  assert(NPVARIANT_IS_STRING(variant));
-  NPUTF8* utf8String = createCStringFromNPVariant(&variant);
-  NPIdentifier identifier = NPN_GetStringIdentifier(utf8String);
-  free(utf8String);
-  return identifier;
-}
-
-NPIdentifier
-int32VariantToIdentifier(NPVariant variant)
-{
-  assert(NPVARIANT_IS_INT32(variant));
-  int32 integer = NPVARIANT_TO_INT32(variant);
-  return NPN_GetIntIdentifier(integer);
-}
-
-NPIdentifier
-doubleVariantToIdentifier(NPVariant variant)
-{
-  assert(NPVARIANT_IS_DOUBLE(variant));
-  double value = NPVARIANT_TO_DOUBLE(variant);
-  // sadly there is no "getdoubleidentifier"
-  int32 integer = static_cast<int32>(value);
-  return NPN_GetIntIdentifier(integer);
-}
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest_utils.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nptest_utils_h_
-#define nptest_utils_h_
-
-#include "nptest.h"
-
-NPUTF8* createCStringFromNPVariant(const NPVariant* variant);
-
-NPIdentifier variantToIdentifier(NPVariant variant);
-NPIdentifier stringVariantToIdentifier(NPVariant variant);
-NPIdentifier int32VariantToIdentifier(NPVariant variant);
-NPIdentifier doubleVariantToIdentifier(NPVariant variant);
-
-#endif // nptest_utils_h_
deleted file mode 100644
--- a/modules/plugin/test/testplugin/nptest_windows.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * 
- * Copyright (c) 2008, Mozilla Corporation
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the Mozilla Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * Contributor(s):
- *   Josh Aas <josh@mozilla.com>
- * 
- * ***** END LICENSE BLOCK ***** */
-
-#include "nptest_platform.h"
-
-NPError
-pluginInstanceInit(InstanceData* instanceData)
-{
-  return NPERR_NO_ERROR;
-}
-
-int16_t
-pluginHandleEvent(InstanceData* instanceData, void* event)
-{
-  return 0;
-}
-
-void
-pluginDraw(InstanceData* instanceData)
-{
-}