diff --git a/dom/canvas/CanvasUtils.cpp b/dom/canvas/CanvasUtils.cpp index 5f6df6ede8bd..be8fe5b6058c 100644 --- a/dom/canvas/CanvasUtils.cpp +++ b/dom/canvas/CanvasUtils.cpp @@ -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; } diff --git a/dom/file/uri/FontTableURIProtocolHandler.h b/dom/file/uri/FontTableURIProtocolHandler.h index 96607c162a4a..5f32768b6d4f 100644 --- a/dom/file/uri/FontTableURIProtocolHandler.h +++ b/dom/file/uri/FontTableURIProtocolHandler.h @@ -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 diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index 9934ad70a1a4..929f5596c1ff 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -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; } } diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 88b9bfe94162..c1ba2d0783ba 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -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 params; diff --git a/dom/html/HTMLFormSubmission.cpp b/dom/html/HTMLFormSubmission.cpp index 0e9482747ec0..6b366c74a753 100644 --- a/dom/html/HTMLFormSubmission.cpp +++ b/dom/html/HTMLFormSubmission.cpp @@ -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); diff --git a/dom/html/nsHTMLDNSPrefetch.cpp b/dom/html/nsHTMLDNSPrefetch.cpp index d42063e0c839..1484f525dcc3 100644 --- a/dom/html/nsHTMLDNSPrefetch.cpp +++ b/dom/html/nsHTMLDNSPrefetch.cpp @@ -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 && diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 08a3a90487ea..6e7258b6617e 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -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; diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index e0e7d3b3f55e..e3f5a5828976 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -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 module; if (NS_SUCCEEDED(NS_GetAboutModule(uri, getter_AddRefs(module)))) { uint32_t flags; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 8a565286749b..cd1735b43891 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2860,10 +2860,8 @@ mozilla::ipc::IPCResult ContentParent::RecvGetExternalClipboardFormats( mozilla::ipc::IPCResult ContentParent::RecvPlaySound(const URIParams& aURI) { nsCOMPtr 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); } diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index c27b01fa1f86..d8ff7065ecbf 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -2348,18 +2348,9 @@ RefPtr 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 principal = nsGlobalWindowInner::Cast(aWindow)->GetPrincipal(); diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index bc82c0d2adb2..141508f21295 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -477,16 +477,10 @@ NotificationPermissionRequest::Run() { nsCOMPtr 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 doc = mWindow->GetExtantDoc(); if (doc) { @@ -1623,12 +1617,8 @@ NotificationPermission Notification::GetPermissionInternal( // Allow files to show notifications by default. nsCOMPtr 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; } } diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp index ae4bef6c9bc1..06b59f1a9c42 100644 --- a/dom/performance/PerformanceTiming.cpp +++ b/dom/performance/PerformanceTiming.cpp @@ -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) { diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 99a6ee904dcd..b70656384920 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -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 { diff --git a/dom/script/ScriptLoadRequest.cpp b/dom/script/ScriptLoadRequest.cpp index cf4af9b27784..2dfd1f277274 100644 --- a/dom/script/ScriptLoadRequest.cpp +++ b/dom/script/ScriptLoadRequest.cpp @@ -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; } diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index c8e9753bff1f..5a1ca69538bd 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -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, diff --git a/dom/serviceworkers/ServiceWorkerUtils.cpp b/dom/serviceworkers/ServiceWorkerUtils.cpp index ea8d0570cbfc..982241675868 100644 --- a/dom/serviceworkers/ServiceWorkerUtils.cpp +++ b/dom/serviceworkers/ServiceWorkerUtils.cpp @@ -69,10 +69,8 @@ nsresult ServiceWorkerScopeAndScriptAreValid(const ClientInfo& aClientInfo, nsCOMPtr 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); diff --git a/dom/storage/StorageUtils.cpp b/dom/storage/StorageUtils.cpp index 283fbb1852c7..fbfbaad8c0c8 100644 --- a/dom/storage/StorageUtils.cpp +++ b/dom/storage/StorageUtils.cpp @@ -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 url = do_QueryInterface(uri, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = url->GetDirectory(domainOrigin); diff --git a/dom/url/URL.cpp b/dom/url/URL.cpp index 548c7c25615c..e87f93b5717c 100644 --- a/dom/url/URL.cpp +++ b/dom/url/URL.cpp @@ -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) { diff --git a/dom/webauthn/WebAuthnUtil.cpp b/dom/webauthn/WebAuthnUtil.cpp index 734143090850..725b1e5caae7 100644 --- a/dom/webauthn/WebAuthnUtil.cpp +++ b/dom/webauthn/WebAuthnUtil.cpp @@ -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; } diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp index a21b40fdf49c..305a6c9a7ca7 100644 --- a/dom/websocket/WebSocket.cpp +++ b/dom/websocket/WebSocket.cpp @@ -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; } } diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 7d188cf2e934..77ba64e84a24 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -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) { diff --git a/dom/xbl/nsXBLContentSink.cpp b/dom/xbl/nsXBLContentSink.cpp index 9d62ccd42cad..feed71a9364f 100644 --- a/dom/xbl/nsXBLContentSink.cpp +++ b/dom/xbl/nsXBLContentSink.cpp @@ -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) { diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp index 84057868c06d..1be5e3d2ce27 100644 --- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -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; rv = FetchBindingDocument(aBoundElement, aBoundDocument, documentURI, diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 9cc9b0fc8cd9..aa97f8b0b51e 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -1087,9 +1087,8 @@ void XMLHttpRequestMainThread::GetAllResponseHeaders( // Don't provide Content-Length for data URIs nsCOMPtr 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: "); diff --git a/dom/xml/XMLDocument.cpp b/dom/xml/XMLDocument.cpp index c99f9b641488..34baf03d0847 100644 --- a/dom/xml/XMLDocument.cpp +++ b/dom/xml/XMLDocument.cpp @@ -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 " diff --git a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp index 5154a459a06b..d9d3a29808ca 100644 --- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp @@ -249,8 +249,7 @@ txStylesheetSink::OnStartRequest(nsIRequest* aRequest) { // sniffing themselves. nsCOMPtr 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 serv = diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 9dc25f5dbb8d..104adb4edb7d 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -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 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 script(RootingCx(), GetScriptObject()); - cache->PutScript(mSrcURI, script); - } + if (useXULCache && mSrcURI && mSrcURI->SchemeIs("chrome")) { + JS::Rooted script(RootingCx(), GetScriptObject()); + cache->PutScript(mSrcURI, script); } cache->FinishInputStream(mSrcURI); } else {