Bug 1225293 - Mochitests for Win64 Silverlight Whitelisting; r=bsmedberg

This commit is contained in:
Kyle Machulis 2015-11-18 14:53:27 -08:00
parent 2e3eab8339
commit 18a59c1a5f
12 changed files with 146 additions and 12 deletions

View File

@ -2034,16 +2034,15 @@ bool
nsPluginHost::ShouldAddPlugin(nsPluginTag* aPluginTag)
{
#if defined(XP_WIN) && (defined(__x86_64__) || defined(_M_X64))
// On 64-bit windows, the only plugin we should load is flash. Use library
// filename and MIME type to check.
// On 64-bit windows, the only plugins we should load are flash and
// silverlight. Use library filename and MIME type to check.
if (StringBeginsWith(aPluginTag->FileName(), NS_LITERAL_CSTRING("NPSWF"), nsCaseInsensitiveCStringComparator()) &&
(aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-shockwave-flash")) ||
aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-shockwave-flash-test")))) {
return true;
}
// Microsoft Silverlight Tests
if (StringBeginsWith(aPluginTag->FileName(), NS_LITERAL_CSTRING("npctrl"), nsCaseInsensitiveCStringComparator()) &&
(aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight-app")) ||
(aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight-test")) ||
aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight-2")) ||
aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight")))) {
return true;

View File

@ -13,6 +13,7 @@
SimpleTest.waitForExplicitFinish();
ok(SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Flash Test Plug-in"), "Should find allowed test flash plugin");
ok(SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Silverlight Test Plug-in"), "Should find allowed test silverlight plugin");
ok(!SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Third Test Plug-in"), "Should not find disallowed plugin");
function findPlugin(pluginName) {
@ -36,29 +37,37 @@
}
function run() {
var pluginElement = document.getElementById("plugin");
var pluginElement = document.getElementById("plugin-flash");
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
pluginElement = document.getElementById("plugin-silverlight");
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
pluginElement = document.getElementById("disallowedPlugin");
is(typeof pluginElement.identifierToStringTest, "undefined", "Should NOT be able to call a function on a disallowed plugin");
ok(navigator.plugins["Flash Test Plug-in"], "Should have queried a plugin named 'Test Plug-in'");
ok(navigator.plugins["Flash Test Plug-in"], "Should have queried a plugin named 'Flash Test Plug-in'");
ok(navigator.plugins["Silverlight Test Plug-in"], "Should have queried a plugin named 'Silverlight Test Plug-in'");
ok(!navigator.plugins["Third Test Plug-in"], "Should NOT have queried a disallowed plugin named 'Third Test Plug-in'");
ok(findPlugin("Flash Test Plug-in"), "Should have found a plugin named 'Test Plug-in'");
ok(findPlugin("Flash Test Plug-in"), "Should have found a plugin named 'Flash Test Plug-in'");
ok(findPlugin("Silverlight Test Plug-in"), "Should have found a plugin named 'Silverlight Test Plug-in'");
ok(!findPlugin("Third Test Plug-in"), "Should NOT found a disallowed plugin named 'Third Test Plug-in'");
ok(navigator.mimeTypes["application/x-shockwave-flash-test"], "Should have queried a MIME type named 'application/x-shockwave-flash-test'");
ok(navigator.mimeTypes["application/x-silverlight-test"], "Should have queried a MIME type named 'application/x-silverlight-test'");
ok(!navigator.mimeTypes["application/x-third-test"], "Should NOT have queried a disallowed type named 'application/x-third-test'");
ok(findMimeType("application/x-shockwave-flash-test"), "Should have found a MIME type named 'application/x-shockwave-flash-test'");
ok(findMimeType("application/x-silverlight-test"), "Should have found a MIME type named 'application/x-silverlight-test'");
ok(!findMimeType("application/x-third-test"), "Should NOT have found a disallowed MIME type named 'application/x-third-test'");
SimpleTest.finish();
}
</script>
<object id="plugin" type="application/x-shockwave-flash-test" width=200 height=200></object>
<object id="plugin-flash" type="application/x-shockwave-flash-test" width=200 height=200></object>
<object id="plugin-silverlight" type="application/x-silverlight-test" width=200 height=200></object>
<object id="disallowedPlugin" type="application/x-third-test" width=200 height=200></object>
</body>
</html>

View File

@ -5,10 +5,10 @@
include $(topsrcdir)/config/rules.mk
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
plugin_file_names = Test.plugin SecondTest.plugin ThirdTest.plugin npswftest.plugin
plugin_file_names = Test.plugin SecondTest.plugin ThirdTest.plugin npswftest.plugin npctrltest.plugin
addon_file_name = testaddon_$(TARGET_XPCOM_ABI).xpi
else
plugin_file_names = $(DLL_PREFIX)nptest$(DLL_SUFFIX) $(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) $(DLL_PREFIX)npthirdtest$(DLL_SUFFIX) $(DLL_PREFIX)npswftest$(DLL_SUFFIX)
plugin_file_names = $(DLL_PREFIX)nptest$(DLL_SUFFIX) $(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) $(DLL_PREFIX)npthirdtest$(DLL_SUFFIX) $(DLL_PREFIX)npswftest$(DLL_SUFFIX) $(DLL_PREFIX)npctrltest$(DLL_SUFFIX)
addon_file_name = testaddon.xpi
endif

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

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>libnpctrltest.dylib</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.SilverlightTestPlugin</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>SILVERLIGHTTEST</string>
<key>CFBundleVersion</key>
<string>1.0.0.0</string>
<key>WebPluginName</key>
<string>Silverlight Test Plug-in</string>
<key>WebPluginDescription</key>
<string>Silverlight plug-in for testing purposes.</string>
<key>WebPluginMIMETypes</key>
<dict>
<key>application/x-silverlight-test</key>
<dict>
<key>WebPluginExtensions</key>
<array>
<string>xaml</string>
</array>
<key>WebPluginTypeDescription</key>
<string>Silverlight test type</string>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,9 @@
#
# 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=npctrltest
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/.
SharedLibrary('npctrltest')
relative_path = 'silverlightplugin'
include('../testplugin.mozbuild')

View File

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

View File

@ -191,6 +191,17 @@ add_task(function test_collect() {
"application/x-shockwave-flash-test"
],
},
"Silverlight Test Plug-in":
{
"version": "1.0.0.0",
"description": "Silverlight plug-in for testing purposes.",
"blocklisted": false,
"disabled": false,
"clicktoplay": false,
"mimeTypes":[
"application/x-silverlight-test"
],
},
};
let pluginTags = Cc["@mozilla.org/plugin/host;1"]

View File

@ -73,6 +73,7 @@ TEST_HARNESS_PLUGINS := \
SecondTest.plugin/ \
ThirdTest.plugin/ \
npswftest.plugin/ \
npctrltest.plugin/ \
JavaTest.plugin/
else
TEST_HARNESS_PLUGINS := \
@ -80,7 +81,8 @@ TEST_HARNESS_PLUGINS := \
$(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) \
$(DLL_PREFIX)npthirdtest$(DLL_SUFFIX) \
$(DLL_PREFIX)nptestjava$(DLL_SUFFIX) \
$(DLL_PREFIX)npswftest$(DLL_SUFFIX)
$(DLL_PREFIX)npswftest$(DLL_SUFFIX) \
$(DLL_PREFIX)npctrltest$(DLL_SUFFIX)
endif
# Rules for staging the necessary harness bits for a test package