blob: f4311e2c318b9e639d084e700f26c9e322ef296d [file] [log] [blame]
<!DOCTYPE html>
<title>document.contentType</title>
<link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype">
<script src="../../resources/js-test.js"></script>
<body>
<p>
<iframe data-mimetype="text/html"></iframe>
<iframe data-mimetype="text/xml"></iframe>
<iframe data-mimetype="application/xml"></iframe>
<iframe data-mimetype="image/svg+xml"></iframe>
</p>
<script>
window.jsTestIsAsync = true;
var tests = new Array();
window.onmessage = function(e) {
if (e.data)
tests[--expectedMessagesCount]=e.data;
else
testFailed("Null message payload");
if (expectedMessagesCount == 0) {
runTests();
finishJSTest();
}
};
function runTests(){
tests.sort(function(a,b){
if (a.obtained > b.obtained)
return -1;
if (a.obtained < b.obtained)
return 1;
return 0;
});
for (var i = tests.length - 1; i >= 0; i--) {
shouldBe('"' + tests[i].obtained + '"', '"' + tests[i].expected + '"');
};
}
var documentContents = '<script xmlns="http://www.w3.org/1999/xhtml">' +
'parent.postMessage(' +
'{obtained: document.contentType, expected: "{0}"}, "*");' +
'<' + '/script>';
var iframes = document.getElementsByTagName('iframe');
for (var k = 0, f; f = iframes[k]; k++) {
f.src = 'data:' + f.dataset.mimetype + ',' + encodeURIComponent(documentContents.replace('{0}', f.dataset.mimetype));
}
var expectedMessagesCount = iframes.length;
</script>
</body>