mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Don't stop loading a XUL document when an overlay is missing and report
warnings about missing overlays to the JS console. Bug 221669, r=ben, sr=jst
This commit is contained in:
parent
32e146e622
commit
d5926230f3
@ -69,6 +69,7 @@ REQUIRES = xpcom \
|
||||
xultmpl \
|
||||
webshell \
|
||||
unicharutil \
|
||||
intl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsXULControllers.cpp
|
||||
|
@ -115,6 +115,9 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
@ -2942,7 +2945,13 @@ nsXULDocument::ResumeWalk()
|
||||
|
||||
nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup);
|
||||
rv = NS_OpenURI(listener, nsnull, uri, nsnull, group);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
// Just move on to the next overlay. NS_OpenURI could fail
|
||||
// just because a channel could not be opened, which can happen
|
||||
// if a file or chrome package does not exist.
|
||||
ReportMissingOverlay(uri);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's a 'chrome:' prototype document, then put it into
|
||||
// the prototype cache; other XUL documents will be reloaded
|
||||
@ -2999,6 +3008,60 @@ nsXULDocument::ResumeWalk()
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULDocument::ReportMissingOverlay(nsIURI* aURI)
|
||||
{
|
||||
NS_PRECONDITION(aURI, "Must have a URI");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIConsoleService> consoleService =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
nsCOMPtr<nsIStringBundleService> stringBundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = stringBundleService->CreateBundle(
|
||||
"chrome://global/locale/xul.properties", getter_AddRefs(bundle));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCAutoString spec;
|
||||
aURI->GetSpec(spec);
|
||||
|
||||
NS_ConvertUTF8toUTF16 utfSpec(spec);
|
||||
const PRUnichar* params[] = { utfSpec.get() };
|
||||
|
||||
nsXPIDLString errorText;
|
||||
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("MissingOverlay").get(),
|
||||
params, NS_ARRAY_LENGTH(params),
|
||||
getter_Copies(errorText));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCAutoString documentURI;
|
||||
mDocumentURI->GetSpec(documentURI);
|
||||
|
||||
rv = errorObject->Init(errorText.get(),
|
||||
NS_ConvertUTF8toUTF16(documentURI).get(),/* file name */
|
||||
EmptyString().get(), /* source line */
|
||||
0, /* line number */
|
||||
0, /* column number */
|
||||
nsIScriptError::warningFlag,
|
||||
"XUL Document");
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
consoleService->LogMessage(errorObject);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, PRBool* aBlock)
|
||||
{
|
||||
@ -4141,20 +4204,14 @@ nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request,
|
||||
if (NS_FAILED(aStatus)) {
|
||||
// If an overlay load fails, we need to nudge the prototype
|
||||
// walk along.
|
||||
#define YELL_IF_MISSING_OVERLAY 1
|
||||
#if defined(DEBUG) || defined(YELL_IF_MISSING_OVERLAY)
|
||||
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if (!aChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
|
||||
printf("*** Failed to load overlay %s\n", spec.get());
|
||||
#endif
|
||||
if (aChannel) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||
if (uri) {
|
||||
mDocument->ReportMissingOverlay(uri);
|
||||
}
|
||||
}
|
||||
|
||||
rv = mDocument->ResumeWalk();
|
||||
}
|
||||
|
3
content/xul/jar.mn
Normal file
3
content/xul/jar.mn
Normal file
@ -0,0 +1,3 @@
|
||||
en-US.jar:
|
||||
locale/en-US/global/xul.properties
|
||||
|
36
content/xul/xul.properties
Normal file
36
content/xul/xul.properties
Normal file
@ -0,0 +1,36 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is xul.properties.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Boris Zbarsky
|
||||
# <bzbarsky@mit.edu>. Portions created by the Initial Developer are Copyright
|
||||
# (C) 2004. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
MissingOverlay=Failed to load overlay from %1$S.
|
Loading…
Reference in New Issue
Block a user