Bug 206659 - Disregard case of MIME types in nsPluginTag::InitMime and add tests to verify mixed-case MIME type handling. r=bsmedberg

This commit is contained in:
Birunthan Mohanathas 2013-12-06 10:34:20 -05:00
parent 8ff5233dae
commit 786dc142da
8 changed files with 57 additions and 7 deletions

View File

@ -132,19 +132,29 @@ void nsPluginTag::InitMime(const char* const* aMimeTypes,
}
for (uint32_t i = 0; i < aVariantCount; i++) {
if (!aMimeTypes[i] || !nsPluginHost::IsTypeWhitelisted(aMimeTypes[i])) {
if (!aMimeTypes[i]) {
continue;
}
nsAutoCString mimeType(aMimeTypes[i]);
// Convert the MIME type, which is case insensitive, to lowercase in order
// to properly handle a mixed-case type.
ToLowerCase(mimeType);
if (!nsPluginHost::IsTypeWhitelisted(mimeType.get())) {
continue;
}
// Look for certain special plugins.
if (nsPluginHost::IsJavaMIMEType(aMimeTypes[i])) {
if (nsPluginHost::IsJavaMIMEType(mimeType.get())) {
mIsJavaPlugin = true;
} else if (strcmp(aMimeTypes[i], "application/x-shockwave-flash") == 0) {
} else if (mimeType.EqualsLiteral("application/x-shockwave-flash")) {
mIsFlashPlugin = true;
}
// Fill in our MIME type array.
mMimeTypes.AppendElement(nsCString(aMimeTypes[i]));
mMimeTypes.AppendElement(mimeType);
// Now fill in the MIME descriptions.
if (aMimeDescriptions && aMimeDescriptions[i]) {

View File

@ -0,0 +1,8 @@
function handleRequest(request, response)
{
response.processAsync();
response.setHeader("Content-Type", "application/x-Second-Test", false);
response.write("Hello world.\n");
response.finish();
}

View File

@ -11,6 +11,7 @@ support-files =
loremipsum_file.txt
loremipsum_nocache.txt
loremipsum_nocache.txt^headers^
mixed_case_mime.sjs
neverending.sjs
npruntime_identifiers_subpage.html
plugin-stream-referer.sjs
@ -41,6 +42,7 @@ support-files =
[test_instance_unparent2.html]
[test_instance_unparent3.html]
[test_instantiation.html]
[test_mixed_case_mime.html]
[test_multipleinstanceobjects.html]
[test_newstreamondestroy.html]
[test_npn_asynccall.html]

View File

@ -0,0 +1,29 @@
<body>
<head>
<title>Test mixed case mimetype for plugins</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script>
SimpleTest.expectAssertions(0, 1);
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
function frameLoaded() {
var contentDocument = document.getElementById('testframe').contentDocument;
ok(contentDocument.body.innerHTML.length > 0, "Frame content shouldn't be empty.");
ok(contentDocument.plugins.length > 0, "Frame content should have a plugin.");
var plugin = contentDocument.plugins[0];
is(plugin.type.toLowerCase(), "application/x-second-test", "Should have loaded the second test plugin.");
SimpleTest.finish();
}
</script>
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()" src="mixed_case_mime.sjs"></iframe>
</body>
</html>

View File

@ -24,7 +24,7 @@
<string>Second plug-in for testing purposes.</string>
<key>WebPluginMIMETypes</key>
<dict>
<key>application/x-second-test</key>
<key>application/x-Second-Test</key>
<dict>
<key>WebPluginExtensions</key>
<array>

View File

@ -29,7 +29,7 @@ BEGIN
VALUE "FileOpenName", "Second test type"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "npsecondtest"
VALUE "MIMEType", "application/x-second-test"
VALUE "MIMEType", "application/x-Second-Test"
VALUE "OriginalFilename", "npsecondtest.dll"
VALUE "ProductName", "Second Test Plug-in"
VALUE "ProductVersion", "1.0"

View File

@ -4,4 +4,4 @@
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";
const char *sMimeDescription = "application/x-Second-Test:ts2:Second test type";

View File

@ -619,6 +619,7 @@
"dom/plugins/test/mochitest/test_instance_unparent2.html": "Bug 931116, b2g desktop specific, initial triage",
"dom/plugins/test/mochitest/test_instance_unparent3.html": "Bug 931116, b2g desktop specific, initial triage",
"dom/plugins/test/mochitest/test_instantiation.html": "Bug 931116, b2g desktop specific, initial triage",
"dom/plugins/test/mochitest/test_mixed_case_mime.html": "Bug 931116, b2g desktop specific",
"dom/plugins/test/mochitest/test_multipleinstanceobjects.html": "Bug 931116, b2g desktop specific, initial triage",
"dom/plugins/test/mochitest/test_newstreamondestroy.html": "Bug 931116, b2g desktop specific, initial triage",
"dom/plugins/test/mochitest/test_npn_asynccall.html": "Bug 931116, b2g desktop specific, initial triage",