Bug 627729 - Force the old HTML parser for document.open()ed documents whose host name ends with ".mail.live.com". r=bzbarsky, a=blocking2.0-final.

This commit is contained in:
Henri Sivonen 2011-02-26 10:57:00 +02:00
parent 71a5cb82e3
commit 0f9a6ac204
5 changed files with 24 additions and 1 deletions

View File

@ -1626,6 +1626,9 @@ protected:
PRPackedBool mIsRegularHTML;
PRPackedBool mIsXUL;
// Sync document.close behavior with document.open() (bug 627729)
PRPackedBool mForceOldParserForHotmail;
enum {
eTriUnset = 0,
eTriFalse,

View File

@ -992,7 +992,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
void
nsHTMLDocument::StopDocumentLoad()
{
if (nsHtml5Module::sEnabled) {
if (nsHtml5Module::sEnabled && !mForceOldParserForHotmail) {
BlockOnload();
if (mWriteState == eDocumentOpened) {
NS_ASSERTION(IsHTML(), "document.open()ed doc is not HTML?");
@ -1962,6 +1962,20 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
// resetting the document.
mSecurityInfo = securityInfo;
mForceOldParserForHotmail = PR_FALSE;
if (nsHtml5Module::sHotmailWorkaround) {
// Bug 627729: Force old parser for document.open()ed docs on Hotmail
nsCOMPtr<nsIURI> thisURI = nsIDocument::GetDocumentURI();
if (thisURI) {
nsCAutoString host;
thisURI->GetHost(host);
if (StringEndsWith(host, NS_LITERAL_CSTRING(".mail.live.com"))) {
loadAsHtml5 = PR_FALSE;
mForceOldParserForHotmail = PR_TRUE;
}
}
}
if (loadAsHtml5) {
mParser = nsHtml5Module::NewHtml5Parser();
rv = NS_OK;

View File

@ -3262,6 +3262,8 @@ pref("accelerometer.enabled", true);
pref("html5.enable", true);
// Toggle which thread the HTML5 parser uses for stream parsing
pref("html5.offmainthread", true);
// Toggle old parser use for document.open() on Hotmail (bug 627729)
pref("html5.hotmailworkaround", true);
// Time in milliseconds between the time a network buffer is seen and the
// timer firing when the timer hasn't fired previously in this parse in the
// off-the-main-thread HTML5 parser.

View File

@ -53,6 +53,7 @@
// static
PRBool nsHtml5Module::sEnabled = PR_FALSE;
PRBool nsHtml5Module::sOffMainThread = PR_TRUE;
PRBool nsHtml5Module::sHotmailWorkaround = PR_TRUE;
nsIThread* nsHtml5Module::sStreamParserThread = nsnull;
nsIThread* nsHtml5Module::sMainThread = nsnull;
@ -62,6 +63,8 @@ nsHtml5Module::InitializeStatics()
{
nsContentUtils::AddBoolPrefVarCache("html5.enable", &sEnabled);
nsContentUtils::AddBoolPrefVarCache("html5.offmainthread", &sOffMainThread);
nsContentUtils::AddBoolPrefVarCache("html5.hotmailworkaround",
&sHotmailWorkaround);
nsHtml5Atoms::AddRefAtoms();
nsHtml5AttributeName::initializeStatics();
nsHtml5ElementName::initializeStatics();

View File

@ -51,6 +51,7 @@ class nsHtml5Module
static nsIThread* GetStreamParserThread();
static PRBool sEnabled;
static PRBool sOffMainThread;
static PRBool sHotmailWorkaround;
private:
#ifdef DEBUG
static PRBool sNsHtml5ModuleInitialized;