Bug 739033 - Allow external View Source editor code live dangerously. r=smaug.

This commit is contained in:
Henri Sivonen
2012-03-27 09:27:45 +03:00
parent ea7fa5b364
commit 46fbf2c696
3 changed files with 31 additions and 1 deletions

View File

@@ -61,6 +61,7 @@
#include "mozilla/Util.h" // DebugOnly
#include "sampler.h"
#include "nsIScriptError.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
@@ -121,7 +122,8 @@ nsHtml5TreeOpExecutor::WillParse()
NS_IMETHODIMP
nsHtml5TreeOpExecutor::WillBuildModel(nsDTDMode aDTDMode)
{
if (mDocShell && !GetDocument()->GetScriptGlobalObject()) {
if (mDocShell && !GetDocument()->GetScriptGlobalObject() &&
!IsExternalViewSource()) {
// Not loading as data but script global object not ready
return MarkAsBroken(NS_ERROR_DOM_INVALID_STATE_ERR);
}
@@ -969,6 +971,27 @@ nsHtml5TreeOpExecutor::GetViewSourceBaseURI()
return mViewSourceBaseURI;
}
//static
void
nsHtml5TreeOpExecutor::InitializeStatics()
{
mozilla::Preferences::AddBoolVarCache(&sExternalViewSource,
"view_source.editor.external");
}
bool
nsHtml5TreeOpExecutor::IsExternalViewSource()
{
if (!sExternalViewSource) {
return false;
}
bool isViewSource = false;
if (mDocumentURI) {
mDocumentURI->SchemeIs("view-source", &isViewSource);
}
return isViewSource;
}
// Speculative loading
already_AddRefed<nsIURI>
@@ -1060,3 +1083,4 @@ PRUint32 nsHtml5TreeOpExecutor::sAppendBatchExaminations = 0;
PRUint32 nsHtml5TreeOpExecutor::sLongestTimeOffTheEventLoop = 0;
PRUint32 nsHtml5TreeOpExecutor::sTimesFlushLoopInterrupted = 0;
#endif
bool nsHtml5TreeOpExecutor::sExternalViewSource = false;