зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1277475 Part 1: Add a chrome and XBL accessor for the sandboxed scripts flag to Document WEBIDL. r=bz
This also incldues changes to use the new function instead of getting and checking the sandbox flags in most places. MozReview-Commit-ID: Cv0vJCdLH4D
This commit is contained in:
Родитель
04160b7177
Коммит
7c3321c672
|
@ -8481,7 +8481,7 @@ nsDocument::IsScriptEnabled()
|
|||
{
|
||||
// If this document is sandboxed without 'allow-scripts'
|
||||
// script is not enabled
|
||||
if (mSandboxFlags & SANDBOXED_SCRIPTS) {
|
||||
if (HasScriptsBlockedBySandbox()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -13223,6 +13223,12 @@ nsIDocument::SetPageUseCounter(UseCounter aUseCounter)
|
|||
contentParent->SetChildDocumentUseCounter(aUseCounter);
|
||||
}
|
||||
|
||||
bool
|
||||
nsIDocument::HasScriptsBlockedBySandbox()
|
||||
{
|
||||
return mSandboxFlags & SANDBOXED_SCRIPTS;
|
||||
}
|
||||
|
||||
static bool
|
||||
MightBeAboutOrChromeScheme(nsIURI* aURI)
|
||||
{
|
||||
|
|
|
@ -2758,6 +2758,8 @@ public:
|
|||
return mUserHasInteracted;
|
||||
}
|
||||
|
||||
bool HasScriptsBlockedBySandbox();
|
||||
|
||||
void ReportHasScrollLinkedEffect();
|
||||
bool HasScrollLinkedEffect() const
|
||||
{
|
||||
|
|
|
@ -1046,7 +1046,7 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
|
|||
MOZ_ASSERT(aRequest->IsLoading());
|
||||
|
||||
// If this document is sandboxed without 'allow-scripts', abort.
|
||||
if (mDocument->GetSandboxFlags() & SANDBOXED_SCRIPTS) {
|
||||
if (mDocument->HasScriptsBlockedBySandbox()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1488,7 +1488,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
|||
|
||||
// inline script
|
||||
// Is this document sandboxed without 'allow-scripts'?
|
||||
if (mDocument->GetSandboxFlags() & SANDBOXED_SCRIPTS) {
|
||||
if (mDocument->HasScriptsBlockedBySandbox()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -830,7 +830,7 @@ EventListenerManager::SetEventHandler(nsIAtom* aName,
|
|||
if (doc) {
|
||||
// Don't allow adding an event listener if the document is sandboxed
|
||||
// without 'allow-scripts'.
|
||||
if (doc->GetSandboxFlags() & SANDBOXED_SCRIPTS) {
|
||||
if (doc->HasScriptsBlockedBySandbox()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
|
|||
// Sandboxed document check: javascript: URI's are disabled
|
||||
// in a sandboxed document unless 'allow-scripts' was specified.
|
||||
nsIDocument* doc = aOriginalInnerWindow->GetExtantDoc();
|
||||
if (doc && (doc->GetSandboxFlags() & SANDBOXED_SCRIPTS)) {
|
||||
if (doc && doc->HasScriptsBlockedBySandbox()) {
|
||||
return NS_ERROR_DOM_RETVAL_UNDEFINED;
|
||||
}
|
||||
|
||||
|
|
|
@ -422,6 +422,12 @@ partial interface Document {
|
|||
[ChromeOnly] readonly attribute boolean userHasInteracted;
|
||||
};
|
||||
|
||||
// Extension to give chrome and XBL JS the ability to determine whether
|
||||
// the document is sandboxed without permission to run scripts.
|
||||
partial interface Document {
|
||||
[Func="IsChromeOrXBL"] readonly attribute boolean hasScriptsBlockedBySandbox;
|
||||
};
|
||||
|
||||
Document implements XPathEvaluator;
|
||||
Document implements GlobalEventHandlers;
|
||||
Document implements TouchEventHandlers;
|
||||
|
|
Загрузка…
Ссылка в новой задаче