LayoutTests/ChangeLog

 12014-07-01 Tibor Meszaros <tmeszaros.u-szeged@partner.samsung.com>
 2
 3 Document.contentType implementation
 4 https://bugs.webkit.org/show_bug.cgi?id=132269
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * fast/dom/Document/clone-node-expected.txt:
 9 * fast/dom/Document/clone-node.html:
 10 * fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt:
 11 * fast/dom/HTMLDocument/clone-node-quirks-mode.html:
 12 * fast/dom/document-contentType-createDocument-expected.txt: Added.
 13 * fast/dom/document-contentType-createDocument.html: Added.
 14 * fast/dom/document-contentType-data-uri-expected.txt: Added.
 15 * fast/dom/document-contentType-data-uri.html: Added.
 16 * http/tests/dom/document-contentType-expected.txt: Added.
 17 * http/tests/dom/document-contentType-meta-expected.txt: Added.
 18 * http/tests/dom/document-contentType-meta.html: Added.
 19 * http/tests/dom/document-contentType-xhr-expected.txt: Added.
 20 * http/tests/dom/document-contentType-xhr.html: Added.
 21 * http/tests/dom/document-contentType.html: Added.
 22 * http/tests/dom/resources/dummy.css: Added.
 23 (body):
 24 * http/tests/dom/resources/dummy.html: Added.
 25 * http/tests/dom/resources/dummy.js: Added.
 26 * http/tests/dom/resources/dummy.txt: Added.
 27 * http/tests/dom/resources/dummy.xml: Added.
 28 * http/tests/dom/resources/js-test-post-async.js: Added.
 29 * http/tests/dom/resources/js-test-post.js: Added.
 30 * http/tests/dom/resources/js-test-pre.js: Added.
 31 (descriptionQuiet):
 32 (escapeHTML):
 33 (testPassed):
 34 (testFailed):
 35 (areNumbersEqual):
 36 (areArraysEqual):
 37 (isMinusZero):
 38 (isTypedArray):
 39 (isResultCorrect):
 40 (stringify):
 41 (evalAndLog):
 42 (shouldBe):
 43 (shouldBeEqualToNumber):
 44 (dfgShouldBe):
 45 (_waitForCondition):
 46 (.condition):
 47 (shouldBecomeEqual):
 48 (shouldBecomeEqualToString):
 49 (shouldBeType):
 50 (shouldBeCloseTo):
 51 (shouldNotBe):
 52 (shouldBecomeDifferent):
 53 (shouldBeTrue):
 54 (shouldBeTrueQuiet):
 55 (shouldBeFalse):
 56 (shouldBeNaN):
 57 (shouldBeNull):
 58 (shouldBeZero):
 59 (shouldBeEqualToString):
 60 (shouldNotBeEqualToString):
 61 (shouldBeEmptyString):
 62 (shouldEvaluateTo):
 63 (shouldBeNonZero):
 64 (shouldBeNonNull):
 65 (shouldBeUndefined):
 66 (shouldBeDefined):
 67 (shouldBeGreaterThanOrEqual):
 68 (expectTrue):
 69 (shouldNotThrow):
 70 (shouldThrow):
 71 (gc.else.gcRec):
 72 (gc):
 73 (dfgCompiled):
 74 (dfgIncrement):
 75 (noInline):
 76 (isSuccessfullyParsed):
 77 (finishJSTest):
 78 (.worker.onmessage):
 79 (.worker.onerror):
 80 (.worker.port.onmessage):
 81 (startWorker):
 82 (.self.onconnect.workerPort.onmessage):
 83 (.self.onconnect):
 84 (.description):
 85 (.testFailed):
 86 (.testPassed):
 87 (.finishJSTest):
 88 (.debug):
 89 * http/tests/dom/resources/send-mime-type.php: Added.
 90 * http/tests/dom/resources/square20.bmp: Added.
 91 * http/tests/dom/resources/square20.gif: Added.
 92 * http/tests/dom/resources/square20.jpg: Added.
 93 * http/tests/dom/resources/square20.png: Added.
 94
1952014-06-30 Myles C. Maxfield <mmaxfield@apple.com>
296
397 All Indic text is rendered as boxes on iOS

LayoutTests/fast/dom/Document/clone-node-expected.txt

@@On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
66PASS doc.cloneNode(false).__proto__ is Document.prototype
77PASS className(doc.cloneNode(false)) is "Document"
88PASS doc.cloneNode(true).documentElement.localName is "root"
 9PASS doc.cloneNode(true).contentType is "application/xml"
910PASS document.cloneNode(true).compatMode is "CSS1Compat"
1011PASS document.cloneNode(false).URL is document.URL
1112PASS document.cloneNode(false).baseURI is document.baseURI
1213PASS document.cloneNode(false).characterSet is document.characterSet
 14PASS document.cloneNode(true).contentType is "text/html"
1315PASS successfullyParsed is true
1416
1517TEST COMPLETE

LayoutTests/fast/dom/Document/clone-node.html

@@var doc = document.implementation.createDocument('', 'root', null);
1414shouldBe('doc.cloneNode(false).__proto__', 'Document.prototype');
1515shouldBeEqualToString('className(doc.cloneNode(false))', 'Document');
1616shouldBeEqualToString('doc.cloneNode(true).documentElement.localName', 'root');
 17shouldBeEqualToString('doc.cloneNode(true).contentType', 'application/xml');
1718shouldBeEqualToString('document.cloneNode(true).compatMode', 'CSS1Compat');
1819shouldBe('document.cloneNode(false).URL', 'document.URL');
1920shouldBe('document.cloneNode(false).baseURI', 'document.baseURI');
2021shouldBe('document.cloneNode(false).characterSet', 'document.characterSet');
 22shouldBeEqualToString('document.cloneNode(true).contentType', 'text/html');
2123
2224</script>
2325<script src="../../../resources/js-test-post.js"></script>

LayoutTests/fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt

@@PASS document.cloneNode(false).__proto__ is HTMLDocument.prototype
77PASS className(document.cloneNode(false)) is "HTMLDocument"
88PASS document.cloneNode(true).title is document.title
99PASS document.cloneNode(true).compatMode is "BackCompat"
 10PASS document.cloneNode(true).contentType is "text/html"
1011PASS doc.cloneNode(false).__proto__ is HTMLDocument.prototype
1112PASS className(doc.cloneNode(false)) is "HTMLDocument"
1213PASS doc.cloneNode(true).title is doc.title
1314PASS doc.cloneNode(true).compatMode is "CSS1Compat"
 15PASS doc.cloneNode(true).contentType is "text/html"
1416PASS successfullyParsed is true
1517
1618TEST COMPLETE

LayoutTests/fast/dom/HTMLDocument/clone-node-quirks-mode.html

@@shouldBe('document.cloneNode(false).__proto__', 'HTMLDocument.prototype');
1111shouldBeEqualToString('className(document.cloneNode(false))', 'HTMLDocument');
1212shouldBe('document.cloneNode(true).title', 'document.title');
1313shouldBeEqualToString('document.cloneNode(true).compatMode', 'BackCompat');
 14shouldBeEqualToString('document.cloneNode(true).contentType', 'text/html');
1415
1516var doc = document.implementation.createHTMLDocument('title');
1617shouldBe('doc.cloneNode(false).__proto__', 'HTMLDocument.prototype');
1718shouldBeEqualToString('className(doc.cloneNode(false))', 'HTMLDocument');
1819shouldBe('doc.cloneNode(true).title', 'doc.title');
1920shouldBeEqualToString('doc.cloneNode(true).compatMode', 'CSS1Compat');
 21shouldBeEqualToString('doc.cloneNode(true).contentType', 'text/html');
2022
2123</script>
2224<script src="../../../resources/js-test-post.js"></script>

LayoutTests/fast/dom/document-contentType-createDocument-expected.txt

 1PASS doc.contentType is "text/html"
 2PASS doc.contentType is "application/xml"
 3PASS successfullyParsed is true
 4
 5TEST COMPLETE
 6

LayoutTests/fast/dom/document-contentType-createDocument.html

 1<!DOCTYPE html>
 2<title>document.contentType</title>
 3<link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype">
 4<script src="../../resources/js-test.js"></script>
 5<body>
 6<script>
 7var doc = document.implementation.createHTMLDocument('f');
 8shouldBe('doc.contentType', '"text/html"');
 9
 10doc = document.implementation.createDocument(null, 'root', null);
 11shouldBe('doc.contentType', '"application/xml"');
 12</script>

LayoutTests/fast/dom/document-contentType-data-uri-expected.txt

 1PASS "application/xml" is "application/xml"
 2PASS "image/svg+xml" is "image/svg+xml"
 3PASS "text/html" is "text/html"
 4PASS "text/xml" is "text/xml"
 5PASS successfullyParsed is true
 6
 7TEST COMPLETE
 8

LayoutTests/fast/dom/document-contentType-data-uri.html

 1<!DOCTYPE html>
 2<title>document.contentType</title>
 3<link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype">
 4<script src="../../resources/js-test.js"></script>
 5<body>
 6<p>
 7<iframe data-mt="text/html"></iframe>
 8<iframe data-mt="text/xml"></iframe>
 9<iframe data-mt="application/xml"></iframe>
 10<iframe data-mt="image/svg+xml"></iframe>
 11</p>
 12<script>
 13window.jsTestIsAsync = true;
 14var tests = new Array();
 15
 16window.onmessage = function(e) {
 17 if (e.data) {
 18 tests[--expectedMessagesCount]=e.data;
 19 } else
 20 testFailed("Null message payload");
 21
 22 if (expectedMessagesCount == 0) {
 23 runTests();
 24 finishJSTest();
 25 }
 26};
 27
 28function runTests(){
 29 tests.sort(function(a,b){
 30 if (a.obtained > b.obtained)
 31 return -1;
 32 if (a.obtained < b.obtained)
 33 return 1;
 34 return 0;
 35 });
 36
 37 for (var i = tests.length - 1; i >= 0; i--) {
 38 shouldBe('"' + tests[i].obtained + '"', '"' + tests[i].expected + '"');
 39 };
 40}
 41
 42var documentContents = '<script xmlns="http://www.w3.org/1999/xhtml">' +
 43 'parent.postMessage(' +
 44 '{obtained: document.contentType, expected: "{0}"}, "*");' +
 45 '<' + '/script>';
 46
 47var iframes = document.getElementsByTagName('iframe');
 48for (var k = 0, f; f = iframes[k]; k++) {
 49 f.src = 'data:' + f.dataset.mt + ',' + encodeURIComponent(documentContents.replace('{0}', f.dataset.mt));
 50}
 51
 52var expectedMessagesCount = iframes.length;
 53
 54</script>
 55</body>

LayoutTests/http/tests/dom/document-contentType-expected.txt

 1PASS iframes[0].contentDocument.contentType is "text/css"
 2PASS iframes[0].contentDocument.cloneNode(false).contentType is "text/css"
 3PASS iframes[1].contentDocument.contentType is "application/x-javascript"
 4PASS iframes[1].contentDocument.cloneNode(false).contentType is "application/x-javascript"
 5PASS iframes[2].contentDocument.contentType is "text/html"
 6PASS iframes[2].contentDocument.cloneNode(false).contentType is "text/html"
 7PASS iframes[3].contentDocument.contentType is "text/html"
 8PASS iframes[3].contentDocument.cloneNode(false).contentType is "text/html"
 9PASS iframes[4].contentDocument.contentType is "text/xml"
 10PASS iframes[4].contentDocument.cloneNode(false).contentType is "text/xml"
 11PASS iframes[5].contentDocument.contentType is "text/xml"
 12PASS iframes[5].contentDocument.cloneNode(false).contentType is "text/xml"
 13PASS iframes[6].contentDocument.contentType is "text/html"
 14PASS iframes[6].contentDocument.cloneNode(false).contentType is "text/html"
 15PASS iframes[7].contentDocument.contentType is "text/html"
 16PASS iframes[7].contentDocument.cloneNode(false).contentType is "text/html"
 17PASS iframes[8].contentDocument.contentType is "text/plain"
 18PASS iframes[8].contentDocument.cloneNode(false).contentType is "text/plain"
 19PASS iframes[9].contentDocument.contentType is "application/xml"
 20PASS iframes[9].contentDocument.cloneNode(false).contentType is "application/xml"
 21PASS iframes[10].contentDocument.contentType is "image/bmp"
 22PASS iframes[10].contentDocument.cloneNode(false).contentType is "image/bmp"
 23PASS iframes[11].contentDocument.contentType is "image/gif"
 24PASS iframes[11].contentDocument.cloneNode(false).contentType is "image/gif"
 25PASS iframes[12].contentDocument.contentType is "image/jpeg"
 26PASS iframes[12].contentDocument.cloneNode(false).contentType is "image/jpeg"
 27PASS iframes[13].contentDocument.contentType is "image/png"
 28PASS iframes[13].contentDocument.cloneNode(false).contentType is "image/png"
 29PASS successfullyParsed is true
 30
 31TEST COMPLETE
 32

LayoutTests/http/tests/dom/document-contentType-meta-expected.txt

 1PASS document.getElementsByTagName("META")[0].content is "text/xml"
 2PASS successfullyParsed is true
 3
 4TEST COMPLETE
 5

LayoutTests/http/tests/dom/document-contentType-meta.html

 1<!DOCTYPE html>
 2<head>
 3 <title>document.contentType</title>
 4 <link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype">
 5 <meta http-equiv="content-type" content="text/xml">
 6 <script src="resources/js-test-pre.js"></script>
 7</head>
 8<body>
 9 <script>
 10 shouldBeEqualToString('document.getElementsByTagName("META")[0].content', document.getElementsByTagName("META")[0].content);
 11 </script>
 12 <script src="resources/js-test-post.js"></script>
 13</body>

LayoutTests/http/tests/dom/document-contentType-xhr-expected.txt

 1PASS xhr.status is 200
 2PASS xhr.responseXML.contentType is "text/html"
 3PASS xhr.status is 200
 4PASS xhr.responseXML.contentType is "text/xml"
 5PASS xhr.status is 200
 6PASS xhr.responseXML.contentType is "application/xml"
 7PASS xhr.status is 200
 8PASS xhr.responseXML.contentType is "text/html"
 9PASS xhr.status is 200
 10PASS xhr.responseXML.contentType is "text/xml"
 11PASS xhr.status is 200
 12PASS xhr.responseXML.contentType is "application/xml"
 13PASS successfullyParsed is true
 14
 15TEST COMPLETE
 16

LayoutTests/http/tests/dom/document-contentType-xhr.html

 1<!DOCTYPE html>
 2<title>document.contentType</title>
 3<link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype">
 4<script src="resources/js-test-pre.js"></script>
 5<body>
 6
 7<script>
 8window.jsTestIsAsync = true;
 9
 10var toTest = [
 11 { mt: "text/html", uri: "resources/send-mime-type.php?m=text/html" },
 12 { mt: "text/xml", uri: "resources/send-mime-type.php?m=text/xml" },
 13 { mt: "application/xml", uri: "resources/send-mime-type.php?m=application/xml" },
 14 { mt: "text/html", uri: "resources/send-mime-type.php?m=text/html;charset=utf-8" },
 15 { mt: "text/xml", uri: "resources/send-mime-type.php?m=text/xml;charset=utf-8" },
 16 { mt: "application/xml", uri: "resources/send-mime-type.php?m=application/xml;charset=utf-8" }
 17];
 18
 19function onrequestload(expectedMimeType) {
 20 shouldBeEqualToNumber('xhr.status', 200);
 21
 22 if (xhr.responseXML)
 23 shouldBeEqualToString('xhr.responseXML.contentType', expectedMimeType);
 24 else
 25 testFailed("Null document for mime-type " + expectedMimeType);
 26
 27 stepTest();
 28}
 29
 30var xhr;
 31var testCounter = 0;
 32
 33function stepTest() {
 34 if (testCounter!=6) {
 35 xhr = new XMLHttpRequest();
 36 xhr.open('GET', toTest[testCounter].uri, true);
 37 xhr.responseType = 'document';
 38 xhr.onload = onrequestload.bind(null, toTest[testCounter].mt);
 39 xhr.send('');
 40 testCounter++;
 41 } else {
 42 finishJSTest();
 43 }
 44}
 45
 46stepTest();
 47
 48</script>
 49<script src="resources/js-test-post-async.js"></script>
 50</body>

LayoutTests/http/tests/dom/document-contentType.html

 1<!DOCTYPE html>
 2<title>document.contentType</title>
 3<link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype">
 4<script src="resources/js-test-pre.js"></script>
 5<body>
 6<p>
 7<iframe data-mt="text/css" src="resources/dummy.css"></iframe>
 8<iframe data-mt="application/x-javascript" src="resources/dummy.js"></iframe>
 9<iframe data-mt="text/html" src="resources/dummy.html"></iframe>
 10<iframe data-mt="text/html" src="resources/send-mime-type.php"></iframe>
 11<iframe data-mt="text/xml" src="resources/send-mime-type.php?m=text/xml"></iframe>
 12<iframe data-mt="text/xml" src="resources/send-mime-type.php?m=text/xml;charset=utf-8"></iframe>
 13<iframe data-mt="text/html" src="javascript:&quot;hello world&quot;;"></iframe>
 14<iframe data-mt="text/html" src="about:blank"></iframe>
 15<iframe data-mt="text/plain" src="resources/dummy.txt"></iframe>
 16<iframe data-mt="application/xml" src="resources/dummy.xml"></iframe>
 17<iframe data-mt="image/bmp" src="resources/square20.bmp"></iframe>
 18<iframe data-mt="image/gif" src="resources/square20.gif"></iframe>
 19<iframe data-mt="image/jpeg" src="resources/square20.jpg"></iframe>
 20<iframe data-mt="image/png" src="resources/square20.png"></iframe>
 21</p>
 22<script>
 23var iframes;
 24window.onload = function() {
 25 iframes = document.getElementsByTagName('iframe');
 26 for (var k = 0; iframes[k]; k++) {
 27 shouldBeEqualToString('iframes[' + k + '].contentDocument.contentType',
 28 iframes[k].dataset.mt);
 29 shouldBeEqualToString('iframes[' + k + '].contentDocument.cloneNode(false).contentType',
 30 iframes[k].dataset.mt);
 31 }
 32 wasPostTestScriptParsed = true;
 33
 34 if (window.jsTestIsAsync) {
 35 if (window.testRunner)
 36 testRunner.waitUntilDone();
 37 if (window.wasFinishJSTestCalled)
 38 finishJSTest();
 39 } else
 40 finishJSTest();
 41};
 42</script>
 43<body>

LayoutTests/http/tests/dom/resources/dummy.css

 1body {}
02\ No newline at end of file

LayoutTests/http/tests/dom/resources/dummy.html

 1<!DOCTYPE html>
 2<body>Hello world

LayoutTests/http/tests/dom/resources/dummy.js

 1var x;
02\ No newline at end of file

LayoutTests/http/tests/dom/resources/dummy.txt

 1Hello world
02\ No newline at end of file

LayoutTests/http/tests/dom/resources/dummy.xml

 1<?xml version="1.0" encoding="utf-8"?>
 2<root>Text.me</root>

LayoutTests/http/tests/dom/resources/js-test-post-async.js

 1if (!errorMessage)
 2 successfullyParsed = true;
 3shouldBeTrue("successfullyParsed");
 4debug('<br /><span class="pass">TEST COMPLETE</span>');
 5
 6if (window.testRunner)
 7 testRunner.notifyDone();

LayoutTests/http/tests/dom/resources/js-test-post.js

 1wasPostTestScriptParsed = true;
 2
 3if (window.jsTestIsAsync) {
 4 if (window.testRunner)
 5 testRunner.waitUntilDone();
 6 if (window.wasFinishJSTestCalled)
 7 finishJSTest();
 8} else
 9 finishJSTest();

LayoutTests/http/tests/dom/resources/js-test-pre.js

 1// svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump text + pixel results
 2if (self.testRunner)
 3 testRunner.dumpAsText(self.enablePixelTesting);
 4
 5var description, debug, successfullyParsed, errorMessage, silentTestPass, didPassSomeTestsSilently, didFailSomeTests;
 6
 7silentTestPass = false;
 8didPassSomeTestsSilently = false;
 9didFailSomeTests = false;
 10
 11(function() {
 12
 13 function createHTMLElement(tagName)
 14 {
 15 // FIXME: In an XML document, document.createElement() creates an element with a null namespace URI.
 16 // So, we need use document.createElementNS() to explicitly create an element with the specified
 17 // tag name in the HTML namespace. We can remove this function and use document.createElement()
 18 // directly once we fix <https://bugs.webkit.org/show_bug.cgi?id=131074>.
 19 if (document.createElementNS)
 20 return document.createElementNS("http://www.w3.org/1999/xhtml", tagName);
 21 return document.createElement(tagName);
 22 }
 23
 24 function getOrCreate(id, tagName)
 25 {
 26 var element = document.getElementById(id);
 27 if (element)
 28 return element;
 29
 30 element = createHTMLElement(tagName);
 31 element.id = id;
 32 var refNode;
 33 var parent = document.body || document.documentElement;
 34 if (id == "description")
 35 refNode = getOrCreate("console", "div");
 36 else
 37 refNode = parent.firstChild;
 38
 39 parent.insertBefore(element, refNode);
 40 return element;
 41 }
 42
 43 description = function description(msg, quiet)
 44 {
 45 // For MSIE 6 compatibility
 46 var span = createHTMLElement("span");
 47 if (quiet)
 48 span.innerHTML = '<p>' + msg + '</p><p>On success, you will see no "<span class="fail">FAIL</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
 49 else
 50 span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
 51
 52 var description = getOrCreate("description", "p");
 53 if (description.firstChild)
 54 description.replaceChild(span, description.firstChild);
 55 else
 56 description.appendChild(span);
 57 };
 58
 59 debug = function debug(msg)
 60 {
 61 var span = createHTMLElement("span");
 62 getOrCreate("console", "div").appendChild(span); // insert it first so XHTML knows the namespace
 63 span.innerHTML = msg + '<br />';
 64 };
 65
 66 var css =
 67 ".pass {" +
 68 "font-weight: bold;" +
 69 "color: green;" +
 70 "}" +
 71 ".fail {" +
 72 "font-weight: bold;" +
 73 "color: red;" +
 74 "}" +
 75 "#console {" +
 76 "white-space: pre-wrap;" +
 77 "font-family: monospace;" +
 78 "}";
 79
 80 function insertStyleSheet()
 81 {
 82 var styleElement = createHTMLElement("style");
 83 styleElement.textContent = css;
 84 (document.head || document.documentElement).appendChild(styleElement);
 85 }
 86
 87 if (!isWorker())
 88 insertStyleSheet();
 89
 90 self.onerror = function(message)
 91 {
 92 errorMessage = message;
 93 };
 94
 95})();
 96
 97function isWorker()
 98{
 99 // It's conceivable that someone would stub out 'document' in a worker so
 100 // also check for childNodes, an arbitrary DOM-related object that is
 101 // meaningless in a WorkerContext.
 102 return (typeof document === 'undefined' || typeof document.childNodes === 'undefined') && !!self.importScripts;
 103}
 104
 105function descriptionQuiet(msg) { description(msg, true); }
 106
 107function escapeHTML(text)
 108{
 109 return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\0/g, "\\0");
 110}
 111
 112function testPassed(msg)
 113{
 114 if (silentTestPass)
 115 didPassSomeTestsSilently = true;
 116 else
 117 debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
 118}
 119
 120function testFailed(msg)
 121{
 122 didFailSomeTests = true;
 123 debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
 124}
 125
 126function areNumbersEqual(_actual, _expected)
 127{
 128 if (_expected === 0)
 129 return _actual === _expected && (1/_actual) === (1/_expected);
 130 if (_actual === _expected)
 131 return true;
 132 if (typeof(_expected) == "number" && isNaN(_expected))
 133 return typeof(_actual) == "number" && isNaN(_actual);
 134 return false;
 135}
 136
 137function areArraysEqual(_a, _b)
 138{
 139 try {
 140 if (_a.length !== _b.length)
 141 return false;
 142 for (var i = 0; i < _a.length; i++)
 143 if (!areNumbersEqual(_a[i], _b[i]))
 144 return false;
 145 } catch (ex) {
 146 return false;
 147 }
 148 return true;
 149}
 150
 151function isMinusZero(n)
 152{
 153 // the only way to tell 0 from -0 in JS is the fact that 1/-0 is
 154 // -Infinity instead of Infinity
 155 return n === 0 && 1/n < 0;
 156}
 157
 158function isTypedArray(array)
 159{
 160 return array instanceof Int8Array
 161 || array instanceof Int16Array
 162 || array instanceof Int32Array
 163 || array instanceof Uint8Array
 164 || array instanceof Uint8ClampedArray
 165 || array instanceof Uint16Array
 166 || array instanceof Uint32Array
 167 || array instanceof Float32Array
 168 || array instanceof Float64Array;
 169}
 170
 171function isResultCorrect(_actual, _expected)
 172{
 173 if (areNumbersEqual(_actual, _expected))
 174 return true;
 175 if (_expected
 176 && (Object.prototype.toString.call(_expected) ==
 177 Object.prototype.toString.call([])
 178 || isTypedArray(_expected)))
 179 return areArraysEqual(_actual, _expected);
 180 return false;
 181}
 182
 183function stringify(v)
 184{
 185 if (v === 0 && 1/v < 0)
 186 return "-0";
 187 else if (isTypedArray(v))
 188 return v.__proto__.constructor.name + ":[" + Array.prototype.join.call(v, ",") + "]";
 189 else
 190 return "" + v;
 191}
 192
 193function evalAndLog(_a, _quiet)
 194{
 195 if (typeof _a != "string")
 196 debug("WARN: tryAndLog() expects a string argument");
 197
 198 // Log first in case things go horribly wrong or this causes a sync event.
 199 if (!_quiet)
 200 debug(_a);
 201
 202 var _av;
 203 try {
 204 _av = eval(_a);
 205 } catch (e) {
 206 testFailed(_a + " threw exception " + e);
 207 }
 208 return _av;
 209}
 210
 211function shouldBe(_a, _b, quiet)
 212{
 213 if (typeof _a != "string" || typeof _b != "string")
 214 debug("WARN: shouldBe() expects string arguments");
 215 var exception;
 216 var _av;
 217 try {
 218 _av = eval(_a);
 219 } catch (e) {
 220 exception = e;
 221 }
 222 var _bv = eval(_b);
 223
 224 if (exception)
 225 testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + exception);
 226 else if (isResultCorrect(_av, _bv)) {
 227 if (!quiet) {
 228 testPassed(_a + " is " + _b);
 229 }
 230 } else if (typeof(_av) == typeof(_bv))
 231 testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
 232 else
 233 testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
 234}
 235
 236function shouldBeEqualToNumber(a, b)
 237{
 238 if (typeof a !== "string" || typeof b !== "number")
 239 debug("WARN: shouldBeEqualToNumber() expects a string and a number arguments");
 240 var unevaledString = JSON.stringify(b);
 241 shouldBe(a, unevaledString);
 242}
 243
 244function dfgShouldBe(theFunction, _a, _b)
 245{
 246 if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
 247 debug("WARN: dfgShouldBe() expects a function and two strings");
 248 noInline(theFunction);
 249 var exception;
 250 var values = [];
 251
 252 // Defend against tests that muck with numeric properties on array.prototype.
 253 values.__proto__ = null;
 254 values.push = Array.prototype.push;
 255
 256 try {
 257 while (!dfgCompiled({f:theFunction}))
 258 values.push(eval(_a));
 259 values.push(eval(_a));
 260 } catch (e) {
 261 exception = e;
 262 }
 263
 264 var _bv = eval(_b);
 265 if (exception)
 266 testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
 267 else {
 268 var allPassed = true;
 269 for (var i = 0; i < values.length; ++i) {
 270 var _av = values[i];
 271 if (isResultCorrect(_av, _bv))
 272 continue;
 273 if (typeof(_av) == typeof(_bv))
 274 testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
 275 else
 276 testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
 277 allPassed = false;
 278 }
 279 if (allPassed)
 280 testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
 281 }
 282
 283 return values.length;
 284}
 285
 286// Execute condition every 5 milliseconds until it succeeds.
 287function _waitForCondition(condition, completionHandler)
 288{
 289 if (condition())
 290 completionHandler();
 291 else
 292 setTimeout(_waitForCondition, 5, condition, completionHandler);
 293}
 294
 295function shouldBecomeEqual(_a, _b, completionHandler)
 296{
 297 if (typeof _a != "string" || typeof _b != "string")
 298 debug("WARN: shouldBecomeEqual() expects string arguments");
 299
 300 var condition = function() {
 301 var exception;
 302 var _av;
 303 try {
 304 _av = eval(_a);
 305 } catch (e) {
 306 exception = e;
 307 }
 308 var _bv = eval(_b);
 309 if (exception)
 310 testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
 311 if (isResultCorrect(_av, _bv)) {
 312 testPassed(_a + " became " + _b);
 313 return true;
 314 }
 315 return false;
 316 };
 317 _waitForCondition(condition, completionHandler);
 318}
 319
 320function shouldBecomeEqualToString(value, reference, completionHandler)
 321{
 322 if (typeof value !== "string" || typeof reference !== "string")
 323 debug("WARN: shouldBecomeEqualToString() expects string arguments");
 324 var unevaledString = JSON.stringify(reference);
 325 shouldBecomeEqual(value, unevaledString, completionHandler);
 326}
 327
 328function shouldBeType(_a, _type) {
 329 var exception;
 330 var _av;
 331 try {
 332 _av = eval(_a);
 333 } catch (e) {
 334 exception = e;
 335 }
 336
 337 var _typev = eval(_type);
 338 if (_av instanceof _typev) {
 339 testPassed(_a + " is an instance of " + _type);
 340 } else {
 341 testFailed(_a + " is not an instance of " + _type);
 342 }
 343}
 344
 345// Variant of shouldBe()--confirms that result of eval(_to_eval) is within
 346// numeric _tolerance of numeric _target.
 347function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet)
 348{
 349 if (typeof _to_eval != "string") {
 350 testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
 351 return;
 352 }
 353 if (typeof _target != "number") {
 354 testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
 355 return;
 356 }
 357 if (typeof _tolerance != "number") {
 358 testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
 359 return;
 360 }
 361
 362 var _result;
 363 try {
 364 _result = eval(_to_eval);
 365 } catch (e) {
 366 testFailed(_to_eval + " should be within " + _tolerance + " of "
 367 + _target + ". Threw exception " + e);
 368 return;
 369 }
 370
 371 if (typeof(_result) != typeof(_target)) {
 372 testFailed(_to_eval + " should be of type " + typeof _target
 373 + " but was of type " + typeof _result);
 374 } else if (Math.abs(_result - _target) <= _tolerance) {
 375 if (!quiet) {
 376 testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
 377 }
 378 } else {
 379 testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
 380 + ". Was " + _result + ".");
 381 }
 382}
 383
 384function shouldNotBe(_a, _b, quiet)
 385{
 386 if (typeof _a != "string" || typeof _b != "string")
 387 debug("WARN: shouldNotBe() expects string arguments");
 388 var exception;
 389 var _av;
 390 try {
 391 _av = eval(_a);
 392 } catch (e) {
 393 exception = e;
 394 }
 395 var _bv = eval(_b);
 396
 397 if (exception)
 398 testFailed(_a + " should not be " + _bv + ". Threw exception " + exception);
 399 else if (!isResultCorrect(_av, _bv)) {
 400 if (!quiet) {
 401 testPassed(_a + " is not " + _b);
 402 }
 403 } else
 404 testFailed(_a + " should not be " + _bv + ".");
 405}
 406
 407function shouldBecomeDifferent(_a, _b, completionHandler)
 408{
 409 if (typeof _a != "string" || typeof _b != "string")
 410 debug("WARN: shouldBecomeDifferent() expects string arguments");
 411
 412 var condition = function() {
 413 var exception;
 414 var _av;
 415 try {
 416 _av = eval(_a);
 417 } catch (e) {
 418 exception = e;
 419 }
 420 var _bv = eval(_b);
 421 if (exception)
 422 testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
 423 if (!isResultCorrect(_av, _bv)) {
 424 testPassed(_a + " became different from " + _b);
 425 return true;
 426 }
 427 return false;
 428 };
 429 _waitForCondition(condition, completionHandler);
 430}
 431
 432function shouldBeTrue(_a) { shouldBe(_a, "true"); }
 433function shouldBeTrueQuiet(_a) { shouldBe(_a, "true", true); }
 434function shouldBeFalse(_a) { shouldBe(_a, "false"); }
 435function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
 436function shouldBeNull(_a) { shouldBe(_a, "null"); }
 437function shouldBeZero(_a) { shouldBe(_a, "0"); }
 438
 439function shouldBeEqualToString(a, b)
 440{
 441 if (typeof a !== "string" || typeof b !== "string")
 442 debug("WARN: shouldBeEqualToString() expects string arguments");
 443 var unevaledString = JSON.stringify(b);
 444 shouldBe(a, unevaledString);
 445}
 446
 447function shouldNotBeEqualToString(a, b)
 448{
 449 if (typeof a !== "string" || typeof b !== "string")
 450 debug("WARN: shouldBeEqualToString() expects string arguments");
 451 var unevaledString = JSON.stringify(b);
 452 shouldNotBe(a, unevaledString);
 453}
 454function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); }
 455
 456function shouldEvaluateTo(actual, expected) {
 457 // A general-purpose comparator. 'actual' should be a string to be
 458 // evaluated, as for shouldBe(). 'expected' may be any type and will be
 459 // used without being eval'ed.
 460 if (expected == null) {
 461 // Do this before the object test, since null is of type 'object'.
 462 shouldBeNull(actual);
 463 } else if (typeof expected == "undefined") {
 464 shouldBeUndefined(actual);
 465 } else if (typeof expected == "function") {
 466 // All this fuss is to avoid the string-arg warning from shouldBe().
 467 try {
 468 actualValue = eval(actual);
 469 } catch (e) {
 470 testFailed("Evaluating " + actual + ": Threw exception " + e);
 471 return;
 472 }
 473 shouldBe("'" + actualValue.toString().replace(/\n/g, "") + "'",
 474 "'" + expected.toString().replace(/\n/g, "") + "'");
 475 } else if (typeof expected == "object") {
 476 shouldBeTrue(actual + " == '" + expected + "'");
 477 } else if (typeof expected == "string") {
 478 shouldBe(actual, expected);
 479 } else if (typeof expected == "boolean") {
 480 shouldBe("typeof " + actual, "'boolean'");
 481 if (expected)
 482 shouldBeTrue(actual);
 483 else
 484 shouldBeFalse(actual);
 485 } else if (typeof expected == "number") {
 486 shouldBe(actual, stringify(expected));
 487 } else {
 488 debug(expected + " is unknown type " + typeof expected);
 489 shouldBeTrue(actual, "'" +expected.toString() + "'");
 490 }
 491}
 492
 493function shouldBeNonZero(_a)
 494{
 495 var exception;
 496 var _av;
 497 try {
 498 _av = eval(_a);
 499 } catch (e) {
 500 exception = e;
 501 }
 502
 503 if (exception)
 504 testFailed(_a + " should be non-zero. Threw exception " + exception);
 505 else if (_av != 0)
 506 testPassed(_a + " is non-zero.");
 507 else
 508 testFailed(_a + " should be non-zero. Was " + _av);
 509}
 510
 511function shouldBeNonNull(_a)
 512{
 513 var exception;
 514 var _av;
 515 try {
 516 _av = eval(_a);
 517 } catch (e) {
 518 exception = e;
 519 }
 520
 521 if (exception)
 522 testFailed(_a + " should be non-null. Threw exception " + exception);
 523 else if (_av != null)
 524 testPassed(_a + " is non-null.");
 525 else
 526 testFailed(_a + " should be non-null. Was " + _av);
 527}
 528
 529function shouldBeUndefined(_a)
 530{
 531 var exception;
 532 var _av;
 533 try {
 534 _av = eval(_a);
 535 } catch (e) {
 536 exception = e;
 537 }
 538
 539 if (exception)
 540 testFailed(_a + " should be undefined. Threw exception " + exception);
 541 else if (typeof _av == "undefined")
 542 testPassed(_a + " is undefined.");
 543 else
 544 testFailed(_a + " should be undefined. Was " + _av);
 545}
 546
 547function shouldBeDefined(_a)
 548{
 549 var exception;
 550 var _av;
 551 try {
 552 _av = eval(_a);
 553 } catch (e) {
 554 exception = e;
 555 }
 556
 557 if (exception)
 558 testFailed(_a + " should be defined. Threw exception " + exception);
 559 else if (_av !== undefined)
 560 testPassed(_a + " is defined.");
 561 else
 562 testFailed(_a + " should be defined. Was " + _av);
 563}
 564
 565function shouldBeGreaterThanOrEqual(_a, _b) {
 566 if (typeof _a != "string" || typeof _b != "string")
 567 debug("WARN: shouldBeGreaterThanOrEqual expects string arguments");
 568
 569 var exception;
 570 var _av;
 571 try {
 572 _av = eval(_a);
 573 } catch (e) {
 574 exception = e;
 575 }
 576 var _bv = eval(_b);
 577
 578 if (exception)
 579 testFailed(_a + " should be >= " + _b + ". Threw exception " + exception);
 580 else if (typeof _av == "undefined" || _av < _bv)
 581 testFailed(_a + " should be >= " + _b + ". Was " + _av + " (of type " + typeof _av + ").");
 582 else
 583 testPassed(_a + " is >= " + _b);
 584}
 585
 586function expectTrue(v, msg) {
 587 if (v) {
 588 testPassed(msg);
 589 } else {
 590 testFailed(msg);
 591 }
 592}
 593
 594function shouldNotThrow(_a) {
 595 try {
 596 eval(_a);
 597 testPassed(_a + " did not throw exception.");
 598 } catch (e) {
 599 testFailed(_a + " should not throw exception. Threw exception " + e + ".");
 600 }
 601}
 602
 603function shouldThrow(_a, _e)
 604{
 605 var exception;
 606 var _av;
 607 try {
 608 _av = eval(_a);
 609 } catch (e) {
 610 exception = e;
 611 }
 612
 613 var _ev;
 614 if (_e)
 615 _ev = eval(_e);
 616
 617 if (exception) {
 618 if (typeof _e == "undefined" || exception == _ev)
 619 testPassed(_a + " threw exception " + exception + ".");
 620 else
 621 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + ".");
 622 } else if (typeof _av == "undefined")
 623 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined.");
 624 else
 625 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
 626}
 627
 628function shouldHaveHadError(message)
 629{
 630 if (errorMessage) {
 631 if (!message)
 632 testPassed("Got expected error");
 633 else if (errorMessage.indexOf(message) !== -1)
 634 testPassed("Got expected error: '" + message + "'");
 635 else
 636 testFailed("Unexpexted error '" + message + "'");
 637 } else
 638 testFailed("Missing expexted error");
 639 errorMessage = undefined;
 640}
 641
 642function gc() {
 643 if (typeof GCController !== "undefined")
 644 GCController.collect();
 645 else {
 646 var gcRec = function (n) {
 647 if (n < 1)
 648 return {};
 649 var temp = {i: "ab" + i + (i / 100000)};
 650 temp += "foo";
 651 gcRec(n-1);
 652 };
 653 for (var i = 0; i < 1000; i++)
 654 gcRec(10)
 655 }
 656}
 657
 658function dfgCompiled(argument)
 659{
 660 var numberOfCompiles = "compiles" in argument ? argument.compiles : 1;
 661
 662 if (!("f" in argument))
 663 throw new Error("dfgCompiled called with invalid argument.");
 664
 665 if (argument.f instanceof Array) {
 666 for (var i = 0; i < argument.f.length; ++i) {
 667 if (testRunner.numberOfDFGCompiles(argument.f[i]) < numberOfCompiles)
 668 return false;
 669 }
 670 } else {
 671 if (testRunner.numberOfDFGCompiles(argument.f) < numberOfCompiles)
 672 return false;
 673 }
 674
 675 return true;
 676}
 677
 678function dfgIncrement(argument)
 679{
 680 if (!self.testRunner)
 681 return argument.i;
 682
 683 if (argument.i < argument.n)
 684 return argument.i;
 685
 686 if (didFailSomeTests)
 687 return argument.i;
 688
 689 if (!dfgCompiled(argument))
 690 return "start" in argument ? argument.start : 0;
 691
 692 return argument.i;
 693}
 694
 695function noInline(theFunction)
 696{
 697 if (!self.testRunner)
 698 return;
 699
 700 testRunner.neverInlineFunction(theFunction);
 701}
 702
 703function isSuccessfullyParsed()
 704{
 705 // FIXME: Remove this and only report unexpected syntax errors.
 706 if (!errorMessage)
 707 successfullyParsed = true;
 708 shouldBeTrue("successfullyParsed");
 709 if (silentTestPass && didPassSomeTestsSilently)
 710 debug("Passed some tests silently.");
 711 if (silentTestPass && didFailSomeTests)
 712 debug("Some tests failed.");
 713 debug('<br /><span class="pass">TEST COMPLETE</span>');
 714}
 715
 716// It's possible for an async test to call finishJSTest() before js-test-post.js
 717// has been parsed.
 718function finishJSTest()
 719{
 720 wasFinishJSTestCalled = true;
 721 if (!self.wasPostTestScriptParsed)
 722 return;
 723 isSuccessfullyParsed();
 724 if (self.jsTestIsAsync && self.testRunner)
 725 testRunner.notifyDone();
 726}
 727
 728function startWorker(testScriptURL, shared)
 729{
 730 self.jsTestIsAsync = true;
 731 debug('Starting worker: ' + testScriptURL);
 732 var worker = shared ? new SharedWorker(testScriptURL, "Shared Worker") : new Worker(testScriptURL);
 733 worker.onmessage = function(event)
 734 {
 735 var workerPrefix = "[Worker] ";
 736 if (event.data.length < 5 || event.data.charAt(4) != ':') {
 737 debug(workerPrefix + event.data);
 738 return;
 739 }
 740 var code = event.data.substring(0, 4);
 741 var payload = workerPrefix + event.data.substring(5);
 742 if (code == "PASS")
 743 testPassed(payload);
 744 else if (code == "FAIL")
 745 testFailed(payload);
 746 else if (code == "DESC")
 747 description(payload);
 748 else if (code == "DONE")
 749 finishJSTest();
 750 else
 751 debug(workerPrefix + event.data);
 752 };
 753
 754 worker.onerror = function(event)
 755 {
 756 debug('Got error from worker: ' + event.message);
 757 finishJSTest();
 758 }
 759
 760 if (shared) {
 761 worker.port.onmessage = function(event) { worker.onmessage(event); };
 762 worker.port.start();
 763 }
 764 return worker;
 765}
 766
 767if (isWorker()) {
 768 var workerPort = self;
 769 if (self.name == "Shared Worker") {
 770 self.onconnect = function(e) {
 771 workerPort = e.ports[0];
 772 workerPort.onmessage = function(event)
 773 {
 774 var colon = event.data.indexOf(":");
 775 if (colon == -1) {
 776 testFailed("Unrecognized message to shared worker: " + event.data);
 777 return;
 778 }
 779 var code = event.data.substring(0, colon);
 780 var payload = event.data.substring(colon + 1);
 781 try {
 782 if (code == "IMPORT")
 783 importScripts(payload);
 784 else
 785 testFailed("Unrecognized message to shared worker: " + event.data);
 786 } catch (ex) {
 787 testFailed("Caught exception in shared worker onmessage: " + ex);
 788 }
 789 };
 790 };
 791 }
 792 description = function(msg, quiet) {
 793 workerPort.postMessage('DESC:' + msg);
 794 }
 795 testFailed = function(msg) {
 796 workerPort.postMessage('FAIL:' + msg);
 797 }
 798 testPassed = function(msg) {
 799 workerPort.postMessage('PASS:' + msg);
 800 }
 801 finishJSTest = function() {
 802 workerPort.postMessage('DONE:');
 803 }
 804 debug = function(msg) {
 805 workerPort.postMessage(msg);
 806 }
 807}

LayoutTests/http/tests/dom/resources/send-mime-type.php

 1<?php
 2header("HTTP/1.1 200 OK");
 3if (isset($_GET['m']) && $_GET['m'] != "")
 4 header("Content-Type: " . $_GET['m']);
 5echo "<h1>Hello</h1>"
 6?>

LayoutTests/http/tests/dom/resources/square20.bmp

Binary file, nothing to see here

LayoutTests/http/tests/dom/resources/square20.gif


Added


LayoutTests/http/tests/dom/resources/square20.jpg


Added


LayoutTests/http/tests/dom/resources/square20.png


Added


Source/WebCore/ChangeLog

 12014-07-01 Tibor Meszaros <tmeszaros.u-szeged@partner.samsung.com>
 2
 3 Document.contentType implementation
 4 https://bugs.webkit.org/show_bug.cgi?id=132269
 5
 6 Chromium merge from https://codereview.chromium.org/151653004
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 Tests: fast/dom/document-contentType-createDocument.html
 11 fast/dom/document-contentType-data-uri.html
 12 http/tests/dom/document-contentType-meta.html
 13 http/tests/dom/document-contentType-xhr.html
 14 http/tests/dom/document-contentType.html
 15
 16 * dom/Document.cpp:
 17 (WebCore::Document::overrideMIMEType):
 18 (WebCore::Document::contentType):
 19 (WebCore::Document::cloneDataFromDocument):
 20 * dom/Document.h:
 21 * dom/Document.idl:
 22 * xml/XMLHttpRequest.cpp:
 23 (WebCore::XMLHttpRequest::responseXML):
 24
1252014-06-30 Commit Queue <commit-queue@webkit.org>
226
327 Unreviewed, rolling out r170605.

Source/WebCore/dom/Document.cpp

@@String Document::suggestedMIMEType() const
13751375 return String();
13761376}
13771377
 1378void Document::overrideMIMEType(const String& mimeType)
 1379{
 1380 m_mimeType = mimeType;
 1381}
 1382
 1383String Document::contentType() const
 1384{
 1385 if (!m_mimeType.isEmpty())
 1386 return m_mimeType;
 1387
 1388 if (DocumentLoader* documentLoader = loader())
 1389 return documentLoader->responseMIMEType();
 1390
 1391 String mimeType = suggestedMIMEType();
 1392 if (!mimeType.isEmpty())
 1393 return mimeType;
 1394
 1395 return ASCIILiteral("application/xml");
 1396}
 1397
13781398Element* Document::elementFromPoint(int x, int y) const
13791399{
13801400 if (!hasLivingRenderTree())

@@void Document::cloneDataFromDocument(const Document& other)
31593179
31603180 setCompatibilityMode(other.m_compatibilityMode);
31613181 setSecurityOrigin(other.securityOrigin());
 3182 overrideMIMEType(other.contentType());
31623183 setDecoder(other.decoder());
31633184}
31643185

Source/WebCore/dom/Document.h

@@public:
461461
462462 String suggestedMIMEType() const;
463463
 464 void overrideMIMEType(const String&);
 465 String contentType() const; // DOM 4 document.contentType
 466
464467 String contentLanguage() const { return m_contentLanguage; }
465468 void setContentLanguage(const String&);
466469

@@private:
14011404
14021405 String m_baseTarget;
14031406
 1407 // MIME type of the document in case it was cloned or created by XHR.
 1408 String m_mimeType;
 1409
14041410 std::unique_ptr<DOMImplementation> m_implementation;
14051411
14061412 RefPtr<CSSStyleSheet> m_elementSheet;

Source/WebCore/dom/Document.idl

105105 [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
106106 [Default=Undefined] optional DOMString pseudoElement);
107107
 108 // DOM 4
 109 readonly attribute DOMString contentType;
 110
108111 // DOM Level 3 XPath (XPathEvaluator interface)
109112 [ObjCLegacyUnnamedParameters, RaisesException] XPathExpression createExpression([Default=Undefined] optional DOMString expression,
110113 [Default=Undefined] optional XPathNSResolver resolver);

Source/WebCore/xml/XMLHttpRequest.cpp

@@Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
206206 return nullptr;
207207
208208 if (!m_createdDocument) {
209  bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html");
 209 String mimeType = responseMIMEType();
 210 bool isHTML = equalIgnoringCase(mimeType, "text/html");
210211
211212 // The W3C spec requires the final MIME type to be some valid XML type, or text/html.
212213 // If it is text/html, then the responseType of "document" must have been supplied explicitly.

@@Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
222223 // FIXME: Set Last-Modified.
223224 m_responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity());
224225 m_responseDocument->setSecurityOrigin(securityOrigin());
 226 m_responseDocument->overrideMIMEType(mimeType);
225227 if (!m_responseDocument->wellFormed())
226228 m_responseDocument = 0;
227229 }