Bug 455472. Be a little more careful with our handling of application/octet-stream. r=jst

This commit is contained in:
Boris Zbarsky 2009-12-02 23:56:59 -05:00
parent 12996fc34d
commit 2a9811df52
3 changed files with 49 additions and 2 deletions

View File

@ -414,11 +414,15 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
// true:
//
// 1) The channel type is application/octet-stream and we have a
// type hint
// type hint and the type hint is not a document type.
// 2) Our type hint is a type that we support with a plugin.
if ((channelType.EqualsASCII(APPLICATION_OCTET_STREAM) &&
!mContentType.IsEmpty()) ||
!mContentType.IsEmpty() &&
GetTypeOfContent(mContentType) != eType_Document) ||
// Need to check IsSupportedPlugin() in addition to GetTypeOfContent()
// because otherwise the default plug-in's catch-all behavior would
// confuse things.
(IsSupportedPlugin(mContentType) &&
GetTypeOfContent(mContentType) == eType_Plugin)) {
// Set the type we'll use for dispatch on the channel. Otherwise we could

View File

@ -299,6 +299,7 @@ _TEST_FILES = test_bug5141.html \
test_bug444322.html \
bug444322.txt \
bug444322.js \
test_bug455472.html \
test_bug455629.html \
bug455629-helper.svg \
test_bug473162-1.html \

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=455472
-->
<head>
<title>Test for Bug 455472</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=455472">Mozilla Bug 455472</a>
<p id="display"></p>
<script>
var ran = [ false, false, false, false, false ];
</script>
<div id="content" style="display: none">
<iframe src="data:text/html,<script>parent.ran[0]=true</script>"></iframe>
<object type="text/html" data="data:text/html,<script>parent.ran[1]=true</script>"></object>
<embed type="image/svg+xml" src="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20onload='parent.ran[2]=true'/>">
<object type="text/html" data="data:application/octet-stream,<script>parent.ran[3]=true</script>"></object>
<embed type="image/svg+xml" src="data:application/octet-stream,<svg%20xmlns='http://www.w3.org/2000/svg'%20onload='parent.ran[4]=true'/>">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 455472 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var expected = [ true, true, true, false, false ];
is (expected.length, ran.length, "Length mismatch");
for (var i = 0; i < expected.length; ++i) {
is(ran[i], expected[i],
"Unexpected behavior in object " + i + " (0-based)");
}
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>