Bug 753278 - Make document.open() after aborting the parser a no-op. r=smaug.

This commit is contained in:
Henri Sivonen 2012-05-18 15:06:28 +03:00
Родитель e292b33b2f
Коммит e113f5bb05
3 изменённых файлов: 57 добавлений и 1 удалений

Просмотреть файл

@ -579,6 +579,7 @@ _TEST_FILES2 = \
test_bug737087.html \
test_bug433662.html \
test_bug749367.html \
test_bug753278.html \
$(NULL)
_CHROME_FILES = \

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=753278
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 753278</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="runTest();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=753278">Mozilla Bug 753278</a>
<p id="display"></p>
<div id="content" style="display: none">
<iframe></iframe>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 753278 **/
SimpleTest.waitForExplicitFinish();
var f = document.getElementsByTagName("iframe")[0];
function runTest() {
f.contentDocument.open();
f.contentDocument.write('<script>window.location = "data:text/html;charset=utf-8,\\u003Cscript>parent.pass();\\u003C/script>"; document.close(); document.open(); document.write("\\u003Cscript>parent.fail();\\u003C/script>"); document.close();\u003c/script>');
f.contentDocument.close();
}
function pass() {
ok(true, "window.location took precedence");
SimpleTest.finish();
}
function fail() {
ok(false, "window.location should have taken precedence");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -1354,7 +1354,16 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl,
}
// If we already have a parser we ignore the document.open call.
if (mParser) {
if (mParser || mParserAborted) {
// The WHATWG spec says: "If the document has an active parser that isn't
// a script-created parser, and the insertion point associated with that
// parser's input stream is not undefined (that is, it does point to
// somewhere in the input stream), then the method does nothing. Abort
// these steps and return the Document object on which the method was
// invoked."
// Note that aborting a parser leaves the parser "active" with its
// insertion point "not undefined". We track this using mParserAborted,
// because aborting a parser nulls out mParser.
return NS_OK;
}