зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356412: Part 2 - Remove script loader path mangling from DOM code. r=bz
As in part 1, this no longer serves any purpose. This patch also removes the otherwise unused WrappersEnabled() method, which was similarly only useful before we had compartment-based security isolation. Its functionality is now handled by compartment flags. Differential Revision: https://phabricator.services.mozilla.com/D10796 --HG-- extra : rebase_source : e4c85eda6cdf430844dea828e2eee3a083f2616d
This commit is contained in:
Родитель
f5e4ac7e08
Коммит
6fb571f4fb
|
@ -605,28 +605,6 @@ nsChromeRegistry::GetDirectionForLocale(const nsACString& aLocale)
|
|||
return uloc_isRightToLeft(locale.get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsChromeRegistry::WrappersEnabled(nsIURI *aURI)
|
||||
{
|
||||
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aURI));
|
||||
if (!chromeURL)
|
||||
return false;
|
||||
|
||||
bool isChrome = false;
|
||||
nsresult rv = chromeURL->SchemeIs("chrome", &isChrome);
|
||||
if (NS_FAILED(rv) || !isChrome)
|
||||
return false;
|
||||
|
||||
nsAutoCString package;
|
||||
rv = chromeURL->GetHostPort(package);
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
uint32_t flags;
|
||||
rv = GetFlagsFromPackage(package, &flags);
|
||||
return NS_SUCCEEDED(rv) && (flags & XPCNATIVEWRAPPERS);
|
||||
}
|
||||
|
||||
already_AddRefed<nsChromeRegistry>
|
||||
nsChromeRegistry::GetSingleton()
|
||||
{
|
||||
|
|
|
@ -49,8 +49,6 @@ public:
|
|||
NS_IMETHOD MustLoadURLRemotely(nsIURI* url,
|
||||
bool* _retval) override;
|
||||
|
||||
// nsIChromeRegistry methods:
|
||||
NS_IMETHOD_(bool) WrappersEnabled(nsIURI *aURI) override;
|
||||
NS_IMETHOD ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult) override;
|
||||
|
||||
// nsChromeRegistry methods:
|
||||
|
|
|
@ -38,11 +38,6 @@ interface nsIChromeRegistry : nsISupports
|
|||
* refresh the chrome list at runtime, looking for new packages/etc
|
||||
*/
|
||||
void checkForNewChrome();
|
||||
|
||||
/**
|
||||
* returns whether XPCNativeWrappers are enabled for aURI.
|
||||
*/
|
||||
[notxpcom] boolean wrappersEnabled(in nsIURI aURI);
|
||||
};
|
||||
|
||||
[scriptable, uuid(93251ddf-5e85-4172-ac2a-31780562974f)]
|
||||
|
|
|
@ -4187,62 +4187,6 @@ nsContentUtils::IsUtf8OnlyPlainTextType(const nsACString& aContentType)
|
|||
aContentType.EqualsLiteral(TEXT_VTT);
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(nsIDocument* aDocument,
|
||||
nsIURI* aURI,
|
||||
nsACString& aScriptURI,
|
||||
nsresult* aRv)
|
||||
{
|
||||
MOZ_ASSERT(aRv);
|
||||
bool scriptFileNameModified = false;
|
||||
*aRv = NS_OK;
|
||||
|
||||
*aRv = aURI->GetSpec(aScriptURI);
|
||||
NS_ENSURE_SUCCESS(*aRv, false);
|
||||
|
||||
if (IsChromeDoc(aDocument)) {
|
||||
nsCOMPtr<nsIChromeRegistry> chromeReg =
|
||||
mozilla::services::GetChromeRegistryService();
|
||||
|
||||
if (!chromeReg) {
|
||||
// If we're running w/o a chrome registry we won't modify any
|
||||
// script file names.
|
||||
|
||||
return scriptFileNameModified;
|
||||
}
|
||||
|
||||
bool docWrappersEnabled =
|
||||
chromeReg->WrappersEnabled(aDocument->GetDocumentURI());
|
||||
|
||||
bool uriWrappersEnabled = chromeReg->WrappersEnabled(aURI);
|
||||
|
||||
nsIURI *docURI = aDocument->GetDocumentURI();
|
||||
|
||||
if (docURI && docWrappersEnabled && !uriWrappersEnabled) {
|
||||
// aURI is a script from a URL that doesn't get wrapper
|
||||
// automation. aDocument is a chrome document that does get
|
||||
// wrapper automation. Prepend the chrome document's URI
|
||||
// followed by the string " -> " to the URI of the script we're
|
||||
// loading here so that script in that URI gets the same wrapper
|
||||
// automation that the chrome document expects.
|
||||
nsAutoCString spec;
|
||||
*aRv = docURI->GetSpec(spec);
|
||||
if (NS_WARN_IF(NS_FAILED(*aRv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
spec.AppendLiteral(" -> ");
|
||||
spec.Append(aScriptURI);
|
||||
|
||||
aScriptURI = spec;
|
||||
|
||||
scriptFileNameModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
return scriptFileNameModified;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsInChromeDocshell(nsIDocument *aDocument)
|
||||
|
|
|
@ -1263,20 +1263,6 @@ public:
|
|||
*/
|
||||
static bool IsUtf8OnlyPlainTextType(const nsACString& aContentType);
|
||||
|
||||
/**
|
||||
* Get the script file name to use when compiling the script
|
||||
* referenced by aURI. In cases where there's no need for any extra
|
||||
* security wrapper automation the script file name that's returned
|
||||
* will be the spec in aURI, else it will be the spec in aDocument's
|
||||
* URI followed by aURI's spec, separated by " -> ". Returns true
|
||||
* if the script file name was modified, false if it's aURI's
|
||||
* spec.
|
||||
*/
|
||||
static bool GetWrapperSafeScriptFilename(nsIDocument *aDocument,
|
||||
nsIURI *aURI,
|
||||
nsACString& aScriptURI,
|
||||
nsresult* aRv);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if aDocument belongs to a chrome docshell for
|
||||
|
|
|
@ -2133,9 +2133,7 @@ ScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
|
|||
{
|
||||
// It's very important to use aRequest->mURI, not the final URI of the channel
|
||||
// aRequest ended up getting script data from, as the script filename.
|
||||
nsresult rv;
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI,
|
||||
aRequest->mURL, &rv);
|
||||
nsresult rv = aRequest->mURI->GetSpec(aRequest->mURL);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -555,19 +555,11 @@ nsXBLService::LoadBindings(Element* aElement, nsIURI* aURL,
|
|||
nsCOMPtr<nsIDocument> document = aElement->OwnerDoc();
|
||||
|
||||
nsAutoCString urlspec;
|
||||
nsresult rv;
|
||||
bool ok = nsContentUtils::GetWrapperSafeScriptFilename(document, aURL,
|
||||
urlspec, &rv);
|
||||
nsresult rv = aURL->GetSpec(urlspec);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
// Block an attempt to load a binding that has special wrapper
|
||||
// automation needs.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (binding) {
|
||||
FlushStyleBindings(aElement);
|
||||
binding = nullptr;
|
||||
|
|
|
@ -2290,9 +2290,8 @@ nsXULPrototypeScript::Compile(JS::SourceBufferHolder& aSrcBuf,
|
|||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
nsresult rv;
|
||||
nsAutoCString urlspec;
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(aDocument, aURI, urlspec, &rv);
|
||||
nsresult rv = aURI->GetSpec(urlspec);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче