Auto merge of #15264 - servo:content-type, r=nox

Always set the Document::contentType attribute in ScriptThread::load().

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15264)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-01-30 05:33:14 -08:00 committed by GitHub
commit cc2011c050
9 changed files with 7 additions and 43 deletions

View file

@ -1710,15 +1710,9 @@ impl ScriptThread {
headers.get().map(|&LastModified(HttpDate(ref tm))| dom_last_modified(tm))
});
let content_type = metadata.content_type.as_ref().and_then(|&Serde(ContentType(ref mimetype))| {
match *mimetype {
Mime(TopLevel::Application, SubLevel::Xml, _) |
Mime(TopLevel::Application, SubLevel::Ext(_), _) |
Mime(TopLevel::Text, SubLevel::Xml, _) |
Mime(TopLevel::Text, SubLevel::Plain, _) => Some(DOMString::from(mimetype.to_string())),
_ => None,
}
});
let content_type = metadata.content_type
.as_ref()
.map(|&Serde(ContentType(ref mimetype))| DOMString::from(mimetype.to_string()));
let loader = DocumentLoader::new_with_threads(self.resource_threads.clone(),
Some(final_url.clone()));

View file

@ -1,5 +0,0 @@
[contenttype_bmp.html]
type: testharness
[BMP document.contentType === 'image/bmp']
expected: FAIL

View file

@ -1,5 +0,0 @@
[contenttype_css.html]
type: testharness
[CSS document.contentType === 'text/css']
expected: FAIL

View file

@ -1,5 +0,0 @@
[contenttype_gif.html]
type: testharness
[GIF document.contentType === 'image/gif']
expected: FAIL

View file

@ -1,5 +0,0 @@
[contenttype_jpg.html]
type: testharness
[JPG document.contentType === 'image/jpeg']
expected: FAIL

View file

@ -1,5 +0,0 @@
[contenttype_png.html]
type: testharness
[PNG document.contentType === 'image/png']
expected: FAIL

View file

@ -1,5 +0,0 @@
[pageload-image.html]
type: testharness
[The document for a standalone media file should have one child in the body.]
expected: FAIL

View file

@ -13,6 +13,7 @@
function frameLoaded() {
var testframe = document.getElementById('testframe');
assert_equals(testframe.contentDocument.contentType, "image/png");
var testframeChildren = testframe.contentDocument.body.childNodes;
assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
assert_equals(testframeChildren[0].nodeName, "IMG", "Only child of body must be an <img> element");
@ -24,7 +25,6 @@
</head>
<body>
<div id="log"></div>
<iframe id="testframe" onload="t.step(frameLoaded)"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oMFgQGMyFwHucAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC"></iframe>
<iframe id="testframe" onload="t.step(frameLoaded)" src="/images/blue.png"></iframe>
</body>
</html>

View file

@ -13,6 +13,7 @@
function frameLoaded() {
var testframe = document.getElementById('testframe');
assert_equals(testframe.contentDocument.contentType, "video/webm");
var testframeChildren = testframe.contentDocument.body.childNodes;
assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
assert_equals(testframeChildren[0].nodeName, "VIDEO", "Only child of body must be an <video> element");
@ -24,7 +25,6 @@
</head>
<body>
<div id="log"></div>
<iframe id="testframe" onload="t.step(frameLoaded)"
src="data:video/webm,"></iframe>
<iframe id="testframe" onload="t.step(frameLoaded)" src="/media/white.webm"></iframe>
</body>
</html>