Bug 982906 - No free lunches! r=bzbarsky
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -12395,24 +12395,22 @@ nsGlobalWindow::GetScrollFrame()
if (presShell) {
return presShell->GetRootScrollFrameAsScrollable();
}
return nullptr;
}
nsresult
nsGlobalWindow::BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI,
- bool *aFreeSecurityPass,
JSContext **aCXused)
{
nsIScriptContext *scx = GetContextInternal();
JSContext *cx = nullptr;
*aBuiltURI = nullptr;
- *aFreeSecurityPass = false;
if (aCXused)
*aCXused = nullptr;
// get JSContext
NS_ASSERTION(scx, "opening window missing its context");
NS_ASSERTION(mDoc, "opening window missing its document");
if (!scx || !mDoc)
return NS_ERROR_FAILURE;
@@ -12443,47 +12441,49 @@ nsGlobalWindow::BuildURIfromBase(const c
if (cx) {
nsIScriptContext *scriptcx = nsJSUtils::GetDynamicScriptContext(cx);
if (scriptcx)
sourceWindow = do_QueryInterface(scriptcx->GetGlobalObject());
}
if (!sourceWindow) {
sourceWindow = this;
- *aFreeSecurityPass = true;
- }
-
- if (sourceWindow) {
- nsCOMPtr<nsIDocument> doc = sourceWindow->GetDoc();
- if (doc) {
- baseURI = doc->GetDocBaseURI();
- charset = doc->GetDocumentCharacterSet();
- }
+ }
+
+ nsCOMPtr<nsIDocument> doc = sourceWindow->GetDoc();
+ if (doc) {
+ baseURI = doc->GetDocBaseURI();
+ charset = doc->GetDocumentCharacterSet();
}
if (aCXused)
*aCXused = cx;
return NS_NewURI(aBuiltURI, nsDependentCString(aURL), charset.get(), baseURI);
}
nsresult
nsGlobalWindow::SecurityCheckURL(const char *aURL)
{
JSContext *cxUsed;
- bool freePass;
nsCOMPtr<nsIURI> uri;
- if (NS_FAILED(BuildURIfromBase(aURL, getter_AddRefs(uri), &freePass, &cxUsed)))
+ if (NS_FAILED(BuildURIfromBase(aURL, getter_AddRefs(uri), &cxUsed))) {
return NS_ERROR_FAILURE;
+ }
+
+ if (!cxUsed) {
+ return NS_OK;
+ }
AutoPushJSContext cx(cxUsed);
- if (!freePass && NS_FAILED(nsContentUtils::GetSecurityManager()->
- CheckLoadURIFromScript(cx, uri)))
+ if (NS_FAILED(nsContentUtils::GetSecurityManager()->
+ CheckLoadURIFromScript(cx, uri))) {
return NS_ERROR_FAILURE;
+ }
return NS_OK;
}
void
nsGlobalWindow::FlushPendingNotifications(mozFlushType aType)
{
if (mDoc) {
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1165,19 +1165,18 @@ protected:
void InsertTimeoutIntoList(nsTimeout *aTimeout);
static void TimerCallback(nsITimer *aTimer, void *aClosure);
// Helper Functions
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
nsresult SecurityCheckURL(const char *aURL);
- nsresult BuildURIfromBase(const char *aURL,
- nsIURI **aBuiltURI,
- bool *aFreeSecurityPass, JSContext **aCXused);
+ nsresult BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI,
+ JSContext **aCXused);
bool PopupWhitelisted();
PopupControlState RevisePopupAbuseLevel(PopupControlState);
void FireAbuseEvents(bool aBlocked, bool aWindow,
const nsAString &aPopupURL,
const nsAString &aPopupWindowName,
const nsAString &aPopupWindowFeatures);
void FireOfflineStatusEvent();