зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1558915 - Use infallible nsIURI::SchemeIs in dom/. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D40108 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
864c351bc8
Коммит
f115dd9113
|
@ -76,8 +76,7 @@ bool IsImageExtractionAllowed(Document* aDocument, JSContext* aCx,
|
|||
docURI->GetSpec(docURISpec);
|
||||
|
||||
// Allow local files to extract canvas data.
|
||||
bool isFileURL;
|
||||
if (NS_SUCCEEDED(docURI->SchemeIs("file", &isFileURL)) && isFileURL) {
|
||||
if (docURI->SchemeIs("file")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ class FontTableURIProtocolHandler final
|
|||
};
|
||||
|
||||
inline bool IsFontTableURI(nsIURI* aUri) {
|
||||
bool isFont;
|
||||
return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont;
|
||||
return aUri->SchemeIs(FONTTABLEURI_SCHEME);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -836,18 +836,10 @@ nsresult Geolocation::Init(nsPIDOMWindowInner* aContentDom) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (uri) {
|
||||
bool isHttp;
|
||||
rv = uri->SchemeIs("http", &isHttp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isHttps;
|
||||
rv = uri->SchemeIs("https", &isHttps);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Store the protocol to send via telemetry later.
|
||||
if (isHttp) {
|
||||
if (uri->SchemeIs("http")) {
|
||||
mProtocolType = ProtocolType::HTTP;
|
||||
} else if (isHttps) {
|
||||
} else if (uri->SchemeIs("https")) {
|
||||
mProtocolType = ProtocolType::HTTPS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -651,9 +651,8 @@ nsresult HTMLFormElement::SubmitSubmission(
|
|||
// STATE_STOP. As a result, we have to make sure that we simply pretend
|
||||
// we're not submitting when submitting to a JS URL. That's kinda bogus, but
|
||||
// there we are.
|
||||
bool schemeIsJavaScript = false;
|
||||
if (NS_SUCCEEDED(actionURI->SchemeIs("javascript", &schemeIsJavaScript)) &&
|
||||
schemeIsJavaScript) {
|
||||
bool schemeIsJavaScript = actionURI->SchemeIs("javascript");
|
||||
if (schemeIsJavaScript) {
|
||||
mIsSubmitting = false;
|
||||
}
|
||||
|
||||
|
@ -758,12 +757,7 @@ nsresult HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL,
|
|||
if (!principalURI) {
|
||||
principalURI = OwnerDoc()->GetDocumentURI();
|
||||
}
|
||||
bool formIsHTTPS;
|
||||
rv = principalURI->SchemeIs("https", &formIsHTTPS);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool formIsHTTPS = principalURI->SchemeIs("https");
|
||||
if (!formIsHTTPS) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1508,9 +1502,7 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
|
|||
// Potentially the page uses the CSP directive 'upgrade-insecure-requests'. In
|
||||
// such a case we have to upgrade the action url from http:// to https://.
|
||||
// If the actionURL is not http, then there is nothing to do.
|
||||
bool isHttpScheme = false;
|
||||
rv = actionURL->SchemeIs("http", &isHttpScheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
bool isHttpScheme = actionURL->SchemeIs("http");
|
||||
if (isHttpScheme && document->GetUpgradeInsecureRequests(false)) {
|
||||
// let's use the old specification before the upgrade for logging
|
||||
AutoTArray<nsString, 2> params;
|
||||
|
|
|
@ -245,9 +245,7 @@ nsresult FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
|||
*aPostDataStream = nullptr;
|
||||
|
||||
if (mMethod == NS_FORM_METHOD_POST) {
|
||||
bool isMailto = false;
|
||||
aURI->SchemeIs("mailto", &isMailto);
|
||||
if (isMailto) {
|
||||
if (aURI->SchemeIs("mailto")) {
|
||||
nsAutoCString path;
|
||||
rv = aURI->GetPathQueryRef(path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -283,10 +281,7 @@ nsresult FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
|||
|
||||
} else {
|
||||
// Get the full query string
|
||||
bool schemeIsJavaScript;
|
||||
rv = aURI->SchemeIs("javascript", &schemeIsJavaScript);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (schemeIsJavaScript) {
|
||||
if (aURI->SchemeIs("javascript")) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -666,9 +661,7 @@ nsresult FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
|
|||
// XXX HACK We are using the standard URL mechanism to give the body to the
|
||||
// mailer instead of passing the post data stream to it, since that sounds
|
||||
// hard.
|
||||
bool isMailto = false;
|
||||
aURI->SchemeIs("mailto", &isMailto);
|
||||
if (isMailto) {
|
||||
if (aURI->SchemeIs("mailto")) {
|
||||
nsAutoCString path;
|
||||
rv = aURI->GetPathQueryRef(path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -356,8 +356,7 @@ void nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue() {
|
|||
rv = NS_URIChainHasFlags(hrefURI,
|
||||
nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
|
||||
&isLocalResource);
|
||||
|
||||
hrefURI->SchemeIs("https", &isHttps);
|
||||
isHttps = hrefURI->SchemeIs("https");
|
||||
}
|
||||
|
||||
if (!hostName.IsEmpty() && NS_SUCCEEDED(rv) && !isLocalResource &&
|
||||
|
|
|
@ -476,8 +476,7 @@ nsresult nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||
// Adapted from nsDocShell:
|
||||
// GetSpec can be expensive for some URIs, so check the scheme first.
|
||||
bool isAbout = false;
|
||||
if (uri && NS_SUCCEEDED(uri->SchemeIs("about", &isAbout)) && isAbout) {
|
||||
if (uri && uri->SchemeIs("about")) {
|
||||
if (uri->GetSpecOrDefault().EqualsLiteral("about:blank")) {
|
||||
loadAsHtml5 = false;
|
||||
}
|
||||
|
@ -816,9 +815,7 @@ bool nsHTMLDocument::WillIgnoreCharsetOverride() {
|
|||
}
|
||||
nsIURI* uri = GetOriginalURI();
|
||||
if (uri) {
|
||||
bool schemeIs = false;
|
||||
uri->SchemeIs("about", &schemeIs);
|
||||
if (schemeIs) {
|
||||
if (uri->SchemeIs("about")) {
|
||||
return true;
|
||||
}
|
||||
bool isResource;
|
||||
|
|
|
@ -330,10 +330,7 @@ nsresult IDBFactory::AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
|
|||
MOZ_ALWAYS_SUCCEEDS(principal->GetURI(getter_AddRefs(uri)));
|
||||
MOZ_ASSERT(uri);
|
||||
|
||||
bool isAbout = false;
|
||||
MOZ_ALWAYS_SUCCEEDS(uri->SchemeIs("about", &isAbout));
|
||||
|
||||
if (isAbout) {
|
||||
if (uri->SchemeIs("about")) {
|
||||
nsCOMPtr<nsIAboutModule> module;
|
||||
if (NS_SUCCEEDED(NS_GetAboutModule(uri, getter_AddRefs(module)))) {
|
||||
uint32_t flags;
|
||||
|
|
|
@ -2860,10 +2860,8 @@ mozilla::ipc::IPCResult ContentParent::RecvGetExternalClipboardFormats(
|
|||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvPlaySound(const URIParams& aURI) {
|
||||
nsCOMPtr<nsIURI> soundURI = DeserializeURI(aURI);
|
||||
bool isChrome = false;
|
||||
// If the check here fails, it can only mean that this message was spoofed.
|
||||
if (!soundURI || NS_FAILED(soundURI->SchemeIs("chrome", &isChrome)) ||
|
||||
!isChrome) {
|
||||
if (!soundURI || !soundURI->SchemeIs("chrome")) {
|
||||
// PlaySound only accepts a valid chrome URI.
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
|
|
|
@ -2348,18 +2348,9 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
|||
isChrome ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled", false);
|
||||
bool isSecure = aWindow->IsSecureContext();
|
||||
// Note: isHTTPS is for legacy telemetry only! Use isSecure for security, as
|
||||
// it handles things like https iframes in http pages correctly.
|
||||
bool isHTTPS = false;
|
||||
bool isHandlingUserInput = EventStateManager::IsHandlingUserInput();
|
||||
docURI->SchemeIs("https", &isHTTPS);
|
||||
nsCString host;
|
||||
nsresult rv = docURI->GetHost(host);
|
||||
// Test for some other schemes that ServiceWorker recognizes
|
||||
bool isFile;
|
||||
docURI->SchemeIs("file", &isFile);
|
||||
bool isApp;
|
||||
docURI->SchemeIs("app", &isApp);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
nsGlobalWindowInner::Cast(aWindow)->GetPrincipal();
|
||||
|
|
|
@ -477,16 +477,10 @@ NotificationPermissionRequest::Run() {
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
mPrincipal->GetURI(getter_AddRefs(uri));
|
||||
|
||||
bool isFile = false;
|
||||
if (uri) {
|
||||
uri->SchemeIs("file", &isFile);
|
||||
if (isFile) {
|
||||
mPermission = NotificationPermission::Granted;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFile && !StaticPrefs::dom_webnotifications_allowinsecure() &&
|
||||
!mWindow->IsSecureContext()) {
|
||||
if (uri && uri->SchemeIs("file")) {
|
||||
mPermission = NotificationPermission::Granted;
|
||||
} else if (!StaticPrefs::dom_webnotifications_allowinsecure() &&
|
||||
!mWindow->IsSecureContext()) {
|
||||
mPermission = NotificationPermission::Denied;
|
||||
nsCOMPtr<Document> doc = mWindow->GetExtantDoc();
|
||||
if (doc) {
|
||||
|
@ -1623,12 +1617,8 @@ NotificationPermission Notification::GetPermissionInternal(
|
|||
// Allow files to show notifications by default.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aPrincipal->GetURI(getter_AddRefs(uri));
|
||||
if (uri) {
|
||||
bool isFile;
|
||||
uri->SchemeIs("file", &isFile);
|
||||
if (isFile) {
|
||||
return NotificationPermission::Granted;
|
||||
}
|
||||
if (uri && uri->SchemeIs("file")) {
|
||||
return NotificationPermission::Granted;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,10 +130,7 @@ PerformanceTimingData::PerformanceTimingData(nsITimedChannel* aChannel,
|
|||
}
|
||||
|
||||
if (uri) {
|
||||
nsresult rv = uri->SchemeIs("https", &mSecureConnection);
|
||||
if (NS_FAILED(rv)) {
|
||||
mSecureConnection = false;
|
||||
}
|
||||
mSecureConnection = uri->SchemeIs("https");
|
||||
}
|
||||
|
||||
if (aChannel) {
|
||||
|
|
|
@ -965,9 +965,7 @@ bool _evaluate(NPP npp, NPObject* npobj, NPString* script, NPVariant* result) {
|
|||
// chrome code anyways.
|
||||
|
||||
uri = doc->GetDocumentURI();
|
||||
bool isChrome = false;
|
||||
|
||||
if (uri && NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome) {
|
||||
if (uri && uri->SchemeIs("chrome")) {
|
||||
uri->GetSpec(specStr);
|
||||
spec = specStr.get();
|
||||
} else {
|
||||
|
|
|
@ -198,12 +198,7 @@ bool ScriptLoadRequest::ShouldAcceptBinASTEncoding() const {
|
|||
#ifdef JS_BUILD_BINAST
|
||||
// We accept the BinAST encoding if we're using a secure connection.
|
||||
|
||||
bool isHTTPS = false;
|
||||
nsresult rv = mURI->SchemeIs("https", &isHTTPS);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
Unused << rv;
|
||||
|
||||
if (!isHTTPS) {
|
||||
if (!mURI->SchemeIs("https")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -358,9 +358,7 @@ bool ScriptLoader::IsAboutPageLoadingChromeURI(ScriptLoadRequest* aRequest) {
|
|||
aRequest->TriggeringPrincipal()->GetURI(getter_AddRefs(triggeringURI));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
bool isAbout =
|
||||
(NS_SUCCEEDED(triggeringURI->SchemeIs("about", &isAbout)) && isAbout);
|
||||
if (!isAbout) {
|
||||
if (!triggeringURI->SchemeIs("about")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -378,9 +376,7 @@ bool ScriptLoader::IsAboutPageLoadingChromeURI(ScriptLoadRequest* aRequest) {
|
|||
}
|
||||
|
||||
// if the uri to be loaded is not of scheme chrome:, there is nothing to do.
|
||||
bool isChrome =
|
||||
(NS_SUCCEEDED(aRequest->mURI->SchemeIs("chrome", &isChrome)) && isChrome);
|
||||
if (!isChrome) {
|
||||
if (!aRequest->mURI->SchemeIs("chrome")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3529,22 +3525,8 @@ uint32_t ScriptLoader::NumberOfProcessors() {
|
|||
}
|
||||
|
||||
static bool IsInternalURIScheme(nsIURI* uri) {
|
||||
bool isWebExt;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("moz-extension", &isWebExt)) && isWebExt) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isResource;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("resource", &isResource)) && isResource) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isChrome;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return uri->SchemeIs("moz-extension") || uri->SchemeIs("resource") ||
|
||||
uri->SchemeIs("chrome");
|
||||
}
|
||||
|
||||
nsresult ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
|
||||
|
|
|
@ -69,10 +69,8 @@ nsresult ServiceWorkerScopeAndScriptAreValid(const ClientInfo& aClientInfo,
|
|||
nsCOMPtr<nsIPrincipal> principal = aClientInfo.GetPrincipal();
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
bool isHttp = false;
|
||||
bool isHttps = false;
|
||||
Unused << aScriptURI->SchemeIs("http", &isHttp);
|
||||
Unused << aScriptURI->SchemeIs("https", &isHttps);
|
||||
bool isHttp = aScriptURI->SchemeIs("http");
|
||||
bool isHttps = aScriptURI->SchemeIs("https");
|
||||
NS_ENSURE_TRUE(isHttp || isHttps, NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
||||
nsresult rv = CheckForSlashEscapedCharsInPath(aScopeURI);
|
||||
|
|
|
@ -32,8 +32,7 @@ nsresult GenerateOriginKey(nsIPrincipal* aPrincipal,
|
|||
|
||||
if (domainOrigin.IsEmpty()) {
|
||||
// For the file:/// protocol use the exact directory as domain.
|
||||
bool isScheme = false;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("file", &isScheme)) && isScheme) {
|
||||
if (uri->SchemeIs("file")) {
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(uri, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = url->GetDirectory(domainOrigin);
|
||||
|
|
|
@ -115,11 +115,7 @@ URLSearchParams* URL::SearchParams() {
|
|||
return mSearchParams;
|
||||
}
|
||||
|
||||
bool IsChromeURI(nsIURI* aURI) {
|
||||
bool isChrome = false;
|
||||
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome))) return isChrome;
|
||||
return false;
|
||||
}
|
||||
bool IsChromeURI(nsIURI* aURI) { return aURI->SchemeIs("chrome"); }
|
||||
|
||||
void URL::CreateSearchParamsIfNeeded() {
|
||||
if (!mSearchParams) {
|
||||
|
|
|
@ -32,8 +32,7 @@ bool EvaluateAppID(nsPIDOMWindowInner* aParent, const nsString& aOrigin,
|
|||
}
|
||||
|
||||
// If the facetId (origin) is not HTTPS, reject
|
||||
bool facetIsHttps = false;
|
||||
if (NS_FAILED(facetUri->SchemeIs("https", &facetIsHttps)) || !facetIsHttps) {
|
||||
if (!facetUri->SchemeIs("https")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -51,8 +50,7 @@ bool EvaluateAppID(nsPIDOMWindowInner* aParent, const nsString& aOrigin,
|
|||
}
|
||||
|
||||
// if the appId URL is not HTTPS, reject.
|
||||
bool appIdIsHttps = false;
|
||||
if (NS_FAILED(appIdUri->SchemeIs("https", &appIdIsHttps)) || !appIdIsHttps) {
|
||||
if (!appIdUri->SchemeIs("https")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1647,14 +1647,8 @@ nsresult WebSocketImpl::Init(JSContext* aCx, nsIPrincipal* aLoadingPrincipal,
|
|||
aLoadingPrincipal->GetURI(getter_AddRefs(originURI));
|
||||
}
|
||||
|
||||
if (originURI) {
|
||||
bool originIsHttps = false;
|
||||
rv = originURI->SchemeIs("https", &originIsHttps);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (originIsHttps) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
if (originURI && originURI->SchemeIs("https")) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,10 +158,7 @@ nsresult ChannelFromScriptURL(
|
|||
principal, uri, true /* aInheritForAboutBlank */,
|
||||
false /* aForceInherit */);
|
||||
|
||||
bool isData = false;
|
||||
rv = uri->SchemeIs("data", &isData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isData = uri->SchemeIs("data");
|
||||
bool isURIUniqueOrigin =
|
||||
net::nsIOService::IsDataURIUniqueOpaqueOrigin() && isData;
|
||||
if (inheritAttrs && !isURIUniqueOrigin) {
|
||||
|
|
|
@ -345,12 +345,7 @@ bool nsXBLContentSink::OnOpenContainer(const char16_t** aAtts,
|
|||
|
||||
nsIURI* uri = mDocument->GetDocumentURI();
|
||||
|
||||
bool isChrome = false;
|
||||
bool isRes = false;
|
||||
|
||||
uri->SchemeIs("chrome", &isChrome);
|
||||
uri->SchemeIs("resource", &isRes);
|
||||
mIsChromeOrResource = isChrome || isRes;
|
||||
mIsChromeOrResource = uri->SchemeIs("chrome") || uri->SchemeIs("resource");
|
||||
|
||||
mState = eXBL_InBindings;
|
||||
} else if (aTagName == nsGkAtoms::binding) {
|
||||
|
|
|
@ -341,12 +341,7 @@ nsXBLService::~nsXBLService(void) {}
|
|||
|
||||
// static
|
||||
bool nsXBLService::IsChromeOrResourceURI(nsIURI* aURI) {
|
||||
bool isChrome = false;
|
||||
bool isResource = false;
|
||||
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) &&
|
||||
NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)))
|
||||
return (isChrome || isResource);
|
||||
return false;
|
||||
return aURI->SchemeIs("chrome") || aURI->SchemeIs("resource");
|
||||
}
|
||||
|
||||
// Servo avoids wasting work styling subtrees of elements with XBL bindings by
|
||||
|
@ -428,8 +423,7 @@ static bool IsSystemOrChromeURLPrincipal(nsIPrincipal* aPrincipal) {
|
|||
aPrincipal->GetURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_TRUE(uri, false);
|
||||
|
||||
bool isChrome = false;
|
||||
return NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome;
|
||||
return uri->SchemeIs("chrome");
|
||||
}
|
||||
|
||||
// This function loads a particular XBL file and installs all of the bindings
|
||||
|
@ -683,10 +677,7 @@ static bool MayBindToContent(nsXBLPrototypeBinding* aProtoBinding,
|
|||
// they end up with a null principal (rather than inheriting the document's
|
||||
// principal), which causes them to fail the check above.
|
||||
if (nsContentUtils::AllowXULXBLForPrincipal(aBoundElement->NodePrincipal())) {
|
||||
bool isDataURI = false;
|
||||
nsresult rv = aURI->SchemeIs("data", &isDataURI);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
if (isDataURI) {
|
||||
if (aURI->SchemeIs("data")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -913,9 +904,9 @@ nsresult nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
|||
// document.
|
||||
|
||||
// Always load chrome synchronously
|
||||
bool chrome;
|
||||
if (NS_SUCCEEDED(documentURI->SchemeIs("chrome", &chrome)) && chrome)
|
||||
if (documentURI->SchemeIs("chrome")) {
|
||||
aForceSyncLoad = true;
|
||||
}
|
||||
|
||||
nsCOMPtr<Document> document;
|
||||
rv = FetchBindingDocument(aBoundElement, aBoundDocument, documentURI,
|
||||
|
|
|
@ -1087,9 +1087,8 @@ void XMLHttpRequestMainThread::GetAllResponseHeaders(
|
|||
|
||||
// Don't provide Content-Length for data URIs
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
bool isDataURI;
|
||||
if (NS_FAILED(mChannel->GetURI(getter_AddRefs(uri))) ||
|
||||
NS_FAILED(uri->SchemeIs("data", &isDataURI)) || !isDataURI) {
|
||||
!uri->SchemeIs("data")) {
|
||||
int64_t length;
|
||||
if (NS_SUCCEEDED(mChannel->GetContentLength(&length))) {
|
||||
aResponseHeaders.AppendLiteral("Content-Length: ");
|
||||
|
|
|
@ -317,8 +317,7 @@ bool XMLDocument::Load(const nsAString& aUrl, CallerType aCallerType,
|
|||
// We're called from chrome, check to make sure the URI we're
|
||||
// about to load is also chrome.
|
||||
|
||||
bool isChrome = false;
|
||||
if (NS_FAILED(uri->SchemeIs("chrome", &isChrome)) || !isChrome) {
|
||||
if (!uri->SchemeIs("chrome")) {
|
||||
nsAutoString error;
|
||||
error.AssignLiteral(
|
||||
"Cross site loading using document.load is no "
|
||||
|
|
|
@ -249,8 +249,7 @@ txStylesheetSink::OnStartRequest(nsIRequest* aRequest) {
|
|||
// sniffing themselves.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
bool sniff;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("file", &sniff)) && sniff &&
|
||||
if (uri->SchemeIs("file") &&
|
||||
contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIStreamConverterService> serv =
|
||||
|
|
|
@ -1901,12 +1901,9 @@ nsresult nsXULPrototypeScript::Serialize(
|
|||
|
||||
nsresult nsXULPrototypeScript::SerializeOutOfLine(
|
||||
nsIObjectOutputStream* aStream, nsXULPrototypeDocument* aProtoDoc) {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
bool isChrome = false;
|
||||
if (NS_FAILED(mSrcURI->SchemeIs("chrome", &isChrome)) || !isChrome)
|
||||
if (!mSrcURI->SchemeIs("chrome"))
|
||||
// Don't cache scripts that don't come from chrome uris.
|
||||
return rv;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
if (!cache) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -1924,7 +1921,7 @@ nsresult nsXULPrototypeScript::SerializeOutOfLine(
|
|||
if (exists) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIObjectOutputStream> oos;
|
||||
rv = cache->GetOutputStream(mSrcURI, getter_AddRefs(oos));
|
||||
nsresult rv = cache->GetOutputStream(mSrcURI, getter_AddRefs(oos));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsresult tmp = Serialize(oos, aProtoDoc, nullptr);
|
||||
|
@ -2014,13 +2011,9 @@ nsresult nsXULPrototypeScript::DeserializeOutOfLine(
|
|||
rv = Deserialize(objectInput, aProtoDoc, nullptr, nullptr);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (useXULCache && mSrcURI) {
|
||||
bool isChrome = false;
|
||||
mSrcURI->SchemeIs("chrome", &isChrome);
|
||||
if (isChrome) {
|
||||
JS::Rooted<JSScript*> script(RootingCx(), GetScriptObject());
|
||||
cache->PutScript(mSrcURI, script);
|
||||
}
|
||||
if (useXULCache && mSrcURI && mSrcURI->SchemeIs("chrome")) {
|
||||
JS::Rooted<JSScript*> script(RootingCx(), GetScriptObject());
|
||||
cache->PutScript(mSrcURI, script);
|
||||
}
|
||||
cache->FinishInputStream(mSrcURI);
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче