Bug 1499169 - Split MIME type of nsObjectLoadingContent when retreived from tag; r=bzbarsky
☠☠ backed out by 0d21fdb4886c ☠ ☠
authorKyle Machulis <kyle@nonpolynomial.com>
Mon, 05 Nov 2018 22:06:23 +0000
changeset 444488 f6f47d5b05b68597739e059cc707573a3d1cea01
parent 444487 e36fa00c208967777b85d23194bc1900ca654cb1
child 444489 fd42da5a8e1a571a356f5a18d7417116dcb63389
push id34996
push userrgurzau@mozilla.com
push dateTue, 06 Nov 2018 09:53:23 +0000
treeherdermozilla-central@e160f0a60e4f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1499169
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/nsObjectLoadingContent.cpp
dom/base/test/mochitest.ini
dom/base/test/test_bug1499139.html
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -1607,17 +1607,20 @@ nsObjectLoadingContent::UpdateObjectPara
            "will use document baseURI instead", this));
     }
   }
 
   nsAutoString rawTypeAttr;
   thisElement->GetAttr(kNameSpaceID_None, nsGkAtoms::type, rawTypeAttr);
   if (!rawTypeAttr.IsEmpty()) {
     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 (!newBaseURI) {
     newBaseURI = docBaseURI;
   }
 
   ///
@@ -1791,17 +1794,16 @@ nsObjectLoadingContent::UpdateObjectPara
   //  2) If we have a loaded channel, we grabbed its mimeType above, use that
   //     type.
   //  3) If we have a plugin type and no URI, use that type.
   //  4) If we have a plugin type and eAllowPluginSkipChannel, use that type.
   //  5) if we have a URI, set type to loading to indicate we'd need a channel
   //     to proceed.
   //  6) Otherwise, type null to indicate unloadable content (fallback)
   //
-
   ObjectType newMime_Type = GetTypeOfContent(newMime, mSkipFakePlugins);
 
   if (stateInvalid) {
     newType = eType_Null;
     newMime.Truncate();
   } else if (newChannel) {
     // If newChannel is set above, we considered it in setting newMime
     newType = newMime_Type;
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -232,16 +232,17 @@ support-files =
   iframe2_bug426646.html
   file1_setting_opener.html
   file2_setting_opener.html
   file3_setting_opener.html
   file4_setting_opener.html
   PASS.html
   FAIL.html
   !/dom/events/test/event_leak_utils.js
+  ../../../browser/extensions/pdfjs/test/file_pdfjs_test.pdf
 
 [test_anchor_area_referrer.html]
 [test_anchor_area_referrer_changing.html]
 [test_anchor_area_referrer_invalid.html]
 [test_anchor_area_referrer_rel.html]
 [test_anonymousContent_api.html]
 [test_anonymousContent_append_after_reflow.html]
 [test_anonymousContent_canvas.html]
@@ -612,16 +613,17 @@ skip-if = toolkit == 'android'
 [test_bug1384661.html]
 [test_bug1399605.html]
 [test_bug1404385.html]
 [test_bug1406102.html]
 [test_bug1421568.html]
 [test_bug1453693.html]
 skip-if = os == "mac"
 [test_bug1472427.html]
+[test_bug1499139.html]
 [test_caretPositionFromPoint.html]
 [test_change_policy.html]
 [test_clearTimeoutIntervalNoArg.html]
 [test_constructor-assignment.html]
 [test_constructor.html]
 [test_copyimage.html]
 subsuite = clipboard
 skip-if = toolkit == 'android' #bug 904183
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_bug1499139.html
@@ -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 1499139</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=1499139">Mozilla Bug 1499139</a>
+    <object id="pdftest" onload="test()" data="file_pdfjs_test.pdf" type="application/pdf;charset=UTF-8" width="90%" height="600"></object>
+  </body>
+</html>