Bug 1499169 - Split MIME type of nsObjectLoadingContent when retreived from tag; r=bzbarsky a=jcristau
authorKyle Machulis <kyle@nonpolynomial.com>
Tue, 06 Nov 2018 22:31:00 +0000
changeset 501109 cd20a71aba8a9f29804c3a848cd12c75750626a7
parent 501108 410f4e7ae2feb52dc23db8892829e1b767477849
child 501110 e578f064314f15077162d153fa1f7c1f84309e37
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, jcristau
bugs1499169
milestone64.0
Bug 1499169 - Split MIME type of nsObjectLoadingContent when retreived from tag; r=bzbarsky a=jcristau 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_bug1499169.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;
   }
 
   ///
--- 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,18 @@ 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_bug1499169.html]
+skip-if = toolkit == 'android' # Timeouts on android due to page closing issues with embedded pdf
 [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_bug1499169.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 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>