Bug 1499169 - Split MIME type of nsObjectLoadingContent when retreived from tag; r=bzbarsky

MIME type should be trimmed of parameters whenever it is retreived
from the tag it relates to, otherwise other checks may fail.

Differential Revision: https://phabricator.services.mozilla.com/D10803

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kyle Machulis 2018-11-06 22:31:00 +00:00
parent 3d9ab59490
commit 4d9ee13f3e
3 changed files with 39 additions and 1 deletions

View File

@ -1612,7 +1612,10 @@ nsObjectLoadingContent::UpdateObjectParameters()
thisElement->GetAttr(kNameSpaceID_None, nsGkAtoms::type, rawTypeAttr); thisElement->GetAttr(kNameSpaceID_None, nsGkAtoms::type, rawTypeAttr);
if (!rawTypeAttr.IsEmpty()) { if (!rawTypeAttr.IsEmpty()) {
typeAttr = rawTypeAttr; typeAttr = rawTypeAttr;
CopyUTF16toUTF8(rawTypeAttr, newMime); nsAutoString params;
nsAutoString mime;
nsContentUtils::SplitMimeType(rawTypeAttr, mime, params);
CopyUTF16toUTF8(mime, newMime);
} }
// If we failed to build a valid URI, use the document's base URI // If we failed to build a valid URI, use the document's base URI

View File

@ -237,6 +237,7 @@ support-files =
PASS.html PASS.html
FAIL.html FAIL.html
!/dom/events/test/event_leak_utils.js !/dom/events/test/event_leak_utils.js
../../../browser/extensions/pdfjs/test/file_pdfjs_test.pdf
[test_anchor_area_referrer.html] [test_anchor_area_referrer.html]
[test_anchor_area_referrer_changing.html] [test_anchor_area_referrer_changing.html]
@ -617,6 +618,8 @@ skip-if = toolkit == 'android'
[test_bug1453693.html] [test_bug1453693.html]
skip-if = os == "mac" skip-if = os == "mac"
[test_bug1472427.html] [test_bug1472427.html]
[test_bug1499169.html]
skip-if = toolkit == 'android' # Timeouts on android due to page closing issues with embedded pdf
[test_caretPositionFromPoint.html] [test_caretPositionFromPoint.html]
[test_change_policy.html] [test_change_policy.html]
[test_clearTimeoutIntervalNoArg.html] [test_clearTimeoutIntervalNoArg.html]

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1499139
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1499169</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SpecialPowers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function test() {
const OBJLC = SpecialPowers.Ci.nsIObjectLoadingContent;
let obj = document.getElementById("pdftest");
obj instanceof OBJLC;
obj = SpecialPowers.wrap(obj);
// Make sure we've set our type correctly even though the mime type isn't quite as expected.
ok(obj.displayedType == OBJLC.TYPE_DOCUMENT, "expected document type");
SimpleTest.finish();
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1499169">Mozilla Bug 1499169</a>
<object id="pdftest" onload="test()" data="file_pdfjs_test.pdf" type="application/pdf;charset=UTF-8" width="90%" height="600"></object>
</body>
</html>