Bug 1444872. Remove support for the 'type' parameter to document.open. r=qdot

This commit is contained in:
Boris Zbarsky
2018-03-28 18:01:46 -04:00
parent ffbc52ee86
commit 9321f7b0d9
12 changed files with 92 additions and 24 deletions

View File

@@ -1205,7 +1205,7 @@ nsHTMLDocument::Open(JSContext* /* unused */,
already_AddRefed<nsIDocument>
nsHTMLDocument::Open(JSContext* cx,
const nsAString& aType,
const Optional<nsAString>& /* unused */,
const nsAString& aReplace,
ErrorResult& aError)
{
@@ -1225,18 +1225,6 @@ nsHTMLDocument::Open(JSContext* cx,
return nullptr;
}
nsAutoCString contentType;
contentType.AssignLiteral("text/html");
nsAutoString type;
nsContentUtils::ASCIIToLower(aType, type);
nsAutoCString actualType, dummy;
NS_ParseRequestContentType(NS_ConvertUTF16toUTF8(type), actualType, dummy);
if (!actualType.EqualsLiteral("text/html") &&
!type.EqualsLiteral("replace")) {
contentType.AssignLiteral("text/plain");
}
// If we already have a parser we ignore the document.open call.
if (mParser || mParserAborted) {
// The WHATWG spec says: "If the document has an active parser that isn't
@@ -1489,12 +1477,17 @@ nsHTMLDocument::Open(JSContext* cx,
mDidDocumentOpen = true;
nsAutoCString contentType(GetContentTypeInternal());
// Call Reset(), this will now do the full reset
Reset(channel, group);
if (baseURI) {
mDocumentBaseURI = baseURI;
}
// Restore our type, since Reset() resets it.
SetContentTypeInternal(contentType);
// Store the security info of the caller now that we're done
// resetting the document.
mSecurityInfo = securityInfo;
@@ -1512,8 +1505,7 @@ nsHTMLDocument::Open(JSContext* cx,
}
}
// This will be propagated to the parser when someone actually calls write()
SetContentTypeInternal(contentType);
mContentTypeForWriteCalls.AssignLiteral("text/html");
// Prepare the docshell and the document viewer for the impending
// out of band document.write()
@@ -1579,7 +1571,7 @@ nsHTMLDocument::Close(ErrorResult& rv)
++mWriteLevel;
rv = (static_cast<nsHtml5Parser*>(mParser.get()))->Parse(
EmptyString(), nullptr, GetContentTypeInternal(), true);
EmptyString(), nullptr, mContentTypeForWriteCalls, true);
--mWriteLevel;
// Even if that Parse() call failed, do the rest of this method
@@ -1711,7 +1703,7 @@ nsHTMLDocument::WriteCommon(JSContext *cx,
mDocumentURI);
return;
}
nsCOMPtr<nsIDocument> ignored = Open(cx, NS_LITERAL_STRING("text/html"),
nsCOMPtr<nsIDocument> ignored = Open(cx, Optional<nsAString>(),
EmptyString(), aRv);
// If Open() fails, or if it didn't create a parser (as it won't
@@ -1745,10 +1737,10 @@ nsHTMLDocument::WriteCommon(JSContext *cx,
// why pay that price when we don't need to?
if (aNewlineTerminate) {
aRv = (static_cast<nsHtml5Parser*>(mParser.get()))->Parse(
aText + new_line, key, GetContentTypeInternal(), false);
aText + new_line, key, mContentTypeForWriteCalls, false);
} else {
aRv = (static_cast<nsHtml5Parser*>(mParser.get()))->Parse(
aText, key, GetContentTypeInternal(), false);
aText, key, mContentTypeForWriteCalls, false);
}
--mWriteLevel;