Bug 1279218 - Remove Java Test Plugin and rest of Java references; r=bsmedberg

MozReview-Commit-ID: IzqYDED7Tui

--HG--
extra : rebase_source : 3cae79b61f5d30ae8ea99b96844248f9b4eefac4
This commit is contained in:
Kyle Machulis 2017-07-17 16:45:48 -07:00
Родитель ef8d138ba7
Коммит d33a528823
15 изменённых файлов: 12 добавлений и 359 удалений

Просмотреть файл

@ -1090,18 +1090,6 @@ _releaseobject(NPObject* npobj)
return;
}
// THIS IS A KNOWN LEAK. SEE BUG 1221448.
// If releaseobject is called off the main thread and we have a valid pointer,
// we at least know it was created on the main thread (see _createobject
// implementation). However, forwarding the deletion back to the main thread
// without careful checking could cause bad memory management races. So, for
// now, we leak by warning and then just returning early. But it should fix
// java 7 crashes.
if (!NS_IsMainThread()) {
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_releaseobject called from the wrong thread\n"));
return;
}
int32_t refCnt = PR_ATOMIC_DECREMENT((int32_t*)&npobj->referenceCount);
NS_LOG_RELEASE(npobj, refCnt, "BrowserNPObject");
@ -1292,88 +1280,6 @@ _getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
if (!npobj->_class->getProperty(npobj, property, result))
return false;
// If a Java plugin tries to get the document.URL or document.documentURI
// property from us, don't pass back a value that Java won't be able to
// understand -- one that will make the URL(String) constructor throw a
// MalformedURL exception. Passing such a value causes Java Plugin2 to
// crash (to throw a RuntimeException in Plugin2Manager.getDocumentBase()).
// Also don't pass back a value that Java is likely to mishandle.
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*) npp->ndata;
if (!inst)
return false;
nsNPAPIPlugin* plugin = inst->GetPlugin();
if (!plugin)
return false;
RefPtr<nsPluginHost> host = nsPluginHost::GetInst();
nsPluginTag* pluginTag = host->TagForPlugin(plugin);
if (!pluginTag->mIsJavaPlugin)
return true;
if (!NPVARIANT_IS_STRING(*result))
return true;
NPUTF8* propertyName = _utf8fromidentifier(property);
if (!propertyName)
return true;
bool notURL =
(PL_strcasecmp(propertyName, "URL") &&
PL_strcasecmp(propertyName, "documentURI"));
_memfree(propertyName);
if (notURL)
return true;
NPObject* window_obj = _getwindowobject(npp);
if (!window_obj)
return true;
NPVariant doc_v;
NPObject* document_obj = nullptr;
NPIdentifier doc_id = _getstringidentifier("document");
bool ok = npobj->_class->getProperty(window_obj, doc_id, &doc_v);
_releaseobject(window_obj);
if (ok) {
if (NPVARIANT_IS_OBJECT(doc_v)) {
document_obj = NPVARIANT_TO_OBJECT(doc_v);
} else {
_releasevariantvalue(&doc_v);
return true;
}
} else {
return true;
}
_releaseobject(document_obj);
if (document_obj != npobj)
return true;
NPString urlnp = NPVARIANT_TO_STRING(*result);
nsXPIDLCString url;
url.Assign(urlnp.UTF8Characters, urlnp.UTF8Length);
bool javaCompatible = false;
if (NS_FAILED(NS_CheckIsJavaCompatibleURLString(url, &javaCompatible)))
javaCompatible = false;
if (javaCompatible)
return true;
// If Java won't be able to interpret the original value of document.URL or
// document.documentURI, or is likely to mishandle it, pass back something
// that Java will understand but won't be able to use to access the network,
// and for which same-origin checks will always fail.
if (inst->mFakeURL.IsVoid()) {
// Abort (do an error return) if NS_MakeRandomInvalidURLString() fails.
if (NS_FAILED(NS_MakeRandomInvalidURLString(inst->mFakeURL))) {
_releasevariantvalue(result);
return false;
}
}
_releasevariantvalue(result);
char* fakeurl = (char *) _memalloc(inst->mFakeURL.Length() + 1);
strcpy(fakeurl, inst->mFakeURL);
STRINGZ_TO_NPVARIANT(fakeurl, *result);
return true;
}

Просмотреть файл

@ -141,7 +141,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
#ifdef MOZ_WIDGET_ANDROID
, mOnScreen(true)
#endif
, mHaveJavaC2PJSObjectQuirk(false)
, mCachedParamLength(0)
, mCachedParamNames(nullptr)
, mCachedParamValues(nullptr)
@ -418,8 +417,6 @@ nsNPAPIPluginInstance::Start()
GetMIMEType(&mimetype);
CheckJavaC2PJSObjectQuirk(quirkParamLength, mCachedParamNames, mCachedParamValues);
bool oldVal = mInPluginInitCall;
mInPluginInitCall = true;
@ -464,14 +461,8 @@ nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window)
return NS_OK;
#if MOZ_WIDGET_GTK
// bug 108347, flash plugin on linux doesn't like window->width <=
// 0, but Java needs wants this call.
if (window && window->type == NPWindowTypeWindow &&
(window->width <= 0 || window->height <= 0) &&
(nsPluginHost::GetSpecialType(nsDependentCString(mMIMEType)) !=
nsPluginHost::eSpecialType_Java)) {
// bug 108347, flash plugin on linux doesn't like window->width <= 0
return NS_OK;
}
#endif
if (!mPlugin || !mPlugin->GetLibrary())
@ -1044,10 +1035,6 @@ nsNPAPIPluginInstance::CSSZoomFactorChanged(float aCSSZoomFactor)
nsresult
nsNPAPIPluginInstance::GetJSObject(JSContext *cx, JSObject** outObject)
{
if (mHaveJavaC2PJSObjectQuirk) {
return NS_ERROR_FAILURE;
}
NPObject *npobj = nullptr;
nsresult rv = GetValueFromPlugin(NPPVpluginScriptableNPObject, &npobj);
if (NS_FAILED(rv) || !npobj)
@ -1599,96 +1586,6 @@ nsNPAPIPluginInstance::SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *c
}
}
static bool
GetJavaVersionFromMimetype(nsPluginTag* pluginTag, nsCString& version)
{
for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); ++i) {
nsCString type = pluginTag->MimeTypes()[i];
nsAutoCString jpi("application/x-java-applet;jpi-version=");
int32_t idx = type.Find(jpi, false, 0, -1);
if (idx != 0) {
continue;
}
type.Cut(0, jpi.Length());
if (type.IsEmpty()) {
continue;
}
type.ReplaceChar('_', '.');
version = type;
return true;
}
return false;
}
void
nsNPAPIPluginInstance::CheckJavaC2PJSObjectQuirk(uint16_t paramCount,
const char* const* paramNames,
const char* const* paramValues)
{
if (!mMIMEType || !mPlugin) {
return;
}
nsPluginTagType tagtype;
nsresult rv = GetTagType(&tagtype);
if (NS_FAILED(rv) ||
(tagtype != nsPluginTagType_Applet)) {
return;
}
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
if (!pluginHost) {
return;
}
nsPluginTag* pluginTag = pluginHost->TagForPlugin(mPlugin);
if (!pluginTag ||
!pluginTag->mIsJavaPlugin) {
return;
}
// check the params for "code" being present and non-empty
bool haveCodeParam = false;
bool isCodeParamEmpty = true;
for (uint16_t i = paramCount; i > 0; --i) {
if (PL_strcasecmp(paramNames[i - 1], "code") == 0) {
haveCodeParam = true;
if (strlen(paramValues[i - 1]) > 0) {
isCodeParamEmpty = false;
}
break;
}
}
// Due to the Java version being specified inconsistently across platforms
// check the version via the mimetype for choosing specific Java versions
nsCString javaVersion;
if (!GetJavaVersionFromMimetype(pluginTag, javaVersion)) {
return;
}
mozilla::Version version(javaVersion.get());
if (version >= "1.7.0.4") {
return;
}
if (!haveCodeParam && version >= "1.6.0.34" && version < "1.7") {
return;
}
if (haveCodeParam && !isCodeParamEmpty) {
return;
}
mHaveJavaC2PJSObjectQuirk = true;
}
double
nsNPAPIPluginInstance::GetContentsScaleFactor()
{

Просмотреть файл

@ -334,11 +334,6 @@ protected:
nsresult GetTagType(nsPluginTagType *result);
// check if this is a Java applet and affected by bug 750480
void CheckJavaC2PJSObjectQuirk(uint16_t paramCount,
const char* const* names,
const char* const* values);
nsresult CreateAudioChannelAgentIfNeeded();
// The structure used to communicate between the plugin instance and
@ -419,9 +414,6 @@ private:
nsIntSize mCurrentSize;
#endif
// is this instance Java and affected by bug 750480?
bool mHaveJavaC2PJSObjectQuirk;
static uint32_t gInUnsafePluginCalls;
// The arrays can only be released when the plugin instance is destroyed,

Просмотреть файл

@ -139,7 +139,6 @@ using mozilla::dom::FakePluginMimeEntry;
static const char *kPrefWhitelist = "plugin.allowed_types";
static const char *kPrefLoadInParentPrefix = "plugin.load_in_parent_process.";
static const char *kPrefDisableFullPage = "plugin.disable_full_page_plugin_for_types";
static const char *kPrefJavaMIME = "plugin.java.mime";
// How long we wait before unloading an idle plugin process.
// Defaults to 30 seconds.
@ -1816,20 +1815,6 @@ nsPluginHost::GetSpecialType(const nsACString & aMIMEType)
return eSpecialType_Flash;
}
// Java registers variants of its MIME with parameters, e.g.
// application/x-java-vm;version=1.3
const nsACString &noParam = Substring(aMIMEType, 0, aMIMEType.FindChar(';'));
// The java mime pref may well not be one of these,
// e.g. application/x-java-test used in the test suite
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
if ((!javaMIME.IsEmpty() && noParam.LowerCaseEqualsASCII(javaMIME)) ||
noParam.LowerCaseEqualsASCII("application/x-java-vm") ||
noParam.LowerCaseEqualsASCII("application/x-java-applet") ||
noParam.LowerCaseEqualsASCII("application/x-java-bean")) {
return eSpecialType_Java;
}
return eSpecialType_None;
}
@ -1994,8 +1979,7 @@ ShouldAddPlugin(const nsPluginInfo& info, bool flashOnly)
}
if (info.fMimeTypeArray[i] &&
(!strcmp(info.fMimeTypeArray[i], "application/x-test") ||
!strcmp(info.fMimeTypeArray[i], "application/x-Second-Test") ||
!strcmp(info.fMimeTypeArray[i], "application/x-java-test"))) {
!strcmp(info.fMimeTypeArray[i], "application/x-Second-Test"))) {
return true;
}
}
@ -2379,7 +2363,6 @@ nsPluginHost::SetPluginsInContent(uint32_t aPluginEpoch,
nsTArray<nsCString>(tag.mimeTypes()),
nsTArray<nsCString>(tag.mimeDescriptions()),
nsTArray<nsCString>(tag.extensions()),
tag.isJavaPlugin(),
tag.isFlashPlugin(),
tag.supportsAsyncRender(),
tag.lastModifiedTime(),
@ -2625,7 +2608,6 @@ nsPluginHost::SendPluginsToContent()
tag->MimeTypes(),
tag->MimeDescriptions(),
tag->Extensions(),
tag->mIsJavaPlugin,
tag->mIsFlashPlugin,
tag->mSupportsAsyncRender,
tag->FileName(),
@ -3962,8 +3944,7 @@ nsPluginHost::CanUsePluginForMIMEType(const nsACString& aMIMEType)
MimeTypeIsAllowedForFakePlugin(NS_ConvertUTF8toUTF16(aMIMEType)) ||
aMIMEType.LowerCaseEqualsLiteral("application/x-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-second-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-third-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-java-test")) {
aMIMEType.LowerCaseEqualsLiteral("application/x-third-test")) {
return true;
}

Просмотреть файл

@ -206,10 +206,7 @@ public:
// Needed to whitelist for async init support
eSpecialType_Test,
// Informs some decisions about OOP and quirks
eSpecialType_Flash,
// Binds to the <applet> tag, has various special
// rules around opening channels, codebase, ...
eSpecialType_Java
eSpecialType_Flash
};
static SpecialType GetSpecialType(const nsACString & aMIMEType);

Просмотреть файл

@ -230,7 +230,6 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo,
mContentProcessRunningCount(0),
mHadLocalInstance(false),
mLibrary(nullptr),
mIsJavaPlugin(false),
mIsFlashPlugin(false),
mSupportsAsyncRender(false),
mFullPath(aPluginInfo->fFullPath),
@ -266,7 +265,6 @@ nsPluginTag::nsPluginTag(const char* aName,
mContentProcessRunningCount(0),
mHadLocalInstance(false),
mLibrary(nullptr),
mIsJavaPlugin(false),
mIsFlashPlugin(false),
mSupportsAsyncRender(false),
mFullPath(aFullPath),
@ -293,7 +291,6 @@ nsPluginTag::nsPluginTag(uint32_t aId,
nsTArray<nsCString> aMimeTypes,
nsTArray<nsCString> aMimeDescriptions,
nsTArray<nsCString> aExtensions,
bool aIsJavaPlugin,
bool aIsFlashPlugin,
bool aSupportsAsyncRender,
int64_t aLastModifiedTime,
@ -305,7 +302,6 @@ nsPluginTag::nsPluginTag(uint32_t aId,
mId(aId),
mContentProcessRunningCount(0),
mLibrary(nullptr),
mIsJavaPlugin(aIsJavaPlugin),
mIsFlashPlugin(aIsFlashPlugin),
mSupportsAsyncRender(aSupportsAsyncRender),
mLastModifiedTime(aLastModifiedTime),
@ -350,9 +346,6 @@ void nsPluginTag::InitMime(const char* const* aMimeTypes,
// Look for certain special plugins.
switch (nsPluginHost::GetSpecialType(mimeType)) {
case nsPluginHost::eSpecialType_Java:
mIsJavaPlugin = true;
break;
case nsPluginHost::eSpecialType_Flash:
// VLC sometimes claims to implement the Flash MIME type, and we want
// to allow users to control that separately from Adobe Flash.
@ -688,11 +681,6 @@ nsPluginTag::GetNiceFileName()
return mNiceFileName;
}
if (mIsJavaPlugin) {
mNiceFileName.AssignLiteral("java");
return mNiceFileName;
}
mNiceFileName = MakeNiceFileName(mFileName);
return mNiceFileName;
}

Просмотреть файл

@ -130,7 +130,6 @@ public:
nsTArray<nsCString> aMimeTypes,
nsTArray<nsCString> aMimeDescriptions,
nsTArray<nsCString> aExtensions,
bool aIsJavaPlugin,
bool aIsFlashPlugin,
bool aSupportsAsyncRender,
int64_t aLastModifiedTime,
@ -168,7 +167,6 @@ public:
PRLibrary *mLibrary;
RefPtr<nsNPAPIPlugin> mPlugin;
bool mIsJavaPlugin;
bool mIsFlashPlugin;
bool mSupportsAsyncRender;
nsCString mFullPath; // UTF-8

Просмотреть файл

@ -16,7 +16,6 @@ struct PluginTag
nsCString[] mimeTypes;
nsCString[] mimeDescriptions;
nsCString[] extensions;
bool isJavaPlugin;
bool isFlashPlugin;
bool supportsAsyncRender; // flash specific
nsCString filename;

Просмотреть файл

@ -14,7 +14,7 @@
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_DISABLED, "Second Test Plug-in");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Java Test Plug-in");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Shockwave Flash");
function findPlugin(pluginName) {
for (var i = 0; i < navigator.plugins.length; i++) {
@ -48,19 +48,19 @@
ok(navigator.plugins["Test Plug-in"], "Should have queried a plugin named 'Test Plug-in'");
ok(!navigator.plugins["Second Test Plug-in"], "Should NOT have queried a disabled plugin named 'Second Test Plug-in'");
ok(navigator.plugins["Java Test Plug-in"], "Should have queried a click-to-play plugin named 'Java Test Plug-in'");
ok(navigator.plugins["Shockwave Flash"], "Should have queried a click-to-play plugin named 'Shockwave Flash'");
ok(findPlugin("Test Plug-in"), "Should have found a plugin named 'Test Plug-in'");
ok(!findPlugin("Second Test Plug-in"), "Should NOT found a disabled plugin named 'Second Test Plug-in'");
ok(findPlugin("Java Test Plug-in"), "Should have found a click-to-play plugin named 'Java Test Plug-in'");
ok(findPlugin("Shockwave Flash"), "Should have found a click-to-play plugin named 'Shockwave Flash'");
ok(navigator.mimeTypes["application/x-test"], "Should have queried a MIME type named 'application/x-test'");
ok(!navigator.mimeTypes["application/x-second-test"], "Should NOT have queried a disabled type named 'application/x-second-test'");
ok(navigator.mimeTypes["application/x-java-test"], "Should have queried a click-to-play MIME type named 'application/x-java-test'");
ok(navigator.mimeTypes["application/x-shockwave-flash-test"], "Should have queried a click-to-play MIME type named 'application/x-shockwave-flash-test'");
ok(findMimeType("application/x-test"), "Should have found a MIME type named 'application/x-test'");
ok(!findMimeType("application/x-second-test"), "Should NOT have found a disabled MIME type named 'application/x-second-test'");
ok(findMimeType("application/x-java-test"), "Should have found a click-to-play MIME type named 'application/x-java-test'");
ok(findMimeType("application/x-shockwave-flash-test"), "Should have found a click-to-play MIME type named 'application/x-shockwave-flash-test'");
SimpleTest.finish();
}
@ -68,6 +68,6 @@
<object id="plugin" type="application/x-test" width=200 height=200></object>
<object id="disabledPlugin" type="application/x-second-test" width=200 height=200></object>
<object id="clickToPlayPlugin" type="application/x-java-test" width=200 height=200></object>
<object id="clickToPlayPlugin" type="application/x-shockwave-flash-test" width=200 height=200></object>
</body>
</html>

Просмотреть файл

@ -1,38 +0,0 @@
<?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>

Просмотреть файл

@ -1,11 +0,0 @@
# -*- Mode: python; 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/.
SharedLibrary('nptestjava')
relative_path = 'javaplugin'
cocoa_name = 'JavaTest'
include('../testplugin.mozbuild')

Просмотреть файл

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

Просмотреть файл

@ -1,42 +0,0 @@
#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

Просмотреть файл

@ -1,7 +0,0 @@
/* 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";

Просмотреть файл

@ -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', 'javaplugin', 'thirdplugin', 'flashplugin']
DIRS += ['secondplugin', 'thirdplugin', 'flashplugin']
SharedLibrary('nptest')