From bab1123e55fa74b77cd3e4ab65bc0ece2698f2f4 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Sun, 28 Sep 2008 15:18:04 -0400 Subject: [PATCH] Bug 433616. Fix the XML parser's bailing out on CSS loads blocked by the security manager, fix a base URI bug in , add some more tests. r=jst, sr=roc --- content/base/src/nsStyleLinkElement.cpp | 6 +++- content/svg/content/src/nsSVGUseElement.cpp | 9 ++++++ dom/src/jsurl/nsJSProtocolHandler.cpp | 7 +++-- .../svg-integration/mask-html-01-resource.svg | 4 +++ layout/reftests/svg/reftest.list | 1 + layout/reftests/svg/use-02-extref-ref.svg | 30 +++++++++++++++++++ .../reftests/svg/use-02-extref-resource.svg | 29 ++++++++++++++++++ layout/reftests/svg/use-02-extref.svg | 28 +++++++++++++++++ 8 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 layout/reftests/svg/use-02-extref-ref.svg create mode 100644 layout/reftests/svg/use-02-extref-resource.svg create mode 100644 layout/reftests/svg/use-02-extref.svg diff --git a/content/base/src/nsStyleLinkElement.cpp b/content/base/src/nsStyleLinkElement.cpp index 06513a09c95..a8e260d6d11 100644 --- a/content/base/src/nsStyleLinkElement.cpp +++ b/content/base/src/nsStyleLinkElement.cpp @@ -314,8 +314,12 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument *aOldDocument, rv = doc->CSSLoader()-> LoadStyleLink(thisContent, uri, title, media, isAlternate, aObserver, &isAlternate); - if (rv == NS_ERROR_FILE_NOT_FOUND) { + if (NS_FAILED(rv)) { + // Don't propagate LoadStyleLink() errors further than this, since some + // consumers (e.g. nsXMLContentSink) will completely abort on innocuous + // things like a stylesheet load being blocked by the security system. doneLoading = PR_TRUE; + isAlternate = PR_FALSE; rv = NS_OK; } } diff --git a/content/svg/content/src/nsSVGUseElement.cpp b/content/svg/content/src/nsSVGUseElement.cpp index 1e218f76bc7..632ddad207a 100644 --- a/content/svg/content/src/nsSVGUseElement.cpp +++ b/content/svg/content/src/nsSVGUseElement.cpp @@ -377,6 +377,15 @@ nsSVGUseElement::CreateAnonymousContent() } } + // Set up its base URI correctly + nsCOMPtr baseURI = targetContent->GetBaseURI(); + if (!baseURI) + return nsnull; + nsCAutoString spec; + baseURI->GetSpec(spec); + newcontent->SetAttr(kNameSpaceID_XML, nsGkAtoms::base, + NS_ConvertUTF8toUTF16(spec), PR_FALSE); + targetContent->AddMutationObserver(this); mClone = newcontent; return mClone; diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp index 7d214e2bf20..4030ed1905d 100644 --- a/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -137,9 +137,10 @@ nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel) // Get the global object owner from the channel nsCOMPtr globalOwner; NS_QueryNotificationCallbacks(aChannel, globalOwner); - NS_ASSERTION(globalOwner, - "Unable to get an nsIScriptGlobalObjectOwner from the " - "channel!"); + if (!globalOwner) { + NS_WARNING("Unable to get an nsIScriptGlobalObjectOwner from the " + "channel!"); + } if (!globalOwner) { return nsnull; } diff --git a/layout/reftests/svg-integration/mask-html-01-resource.svg b/layout/reftests/svg-integration/mask-html-01-resource.svg index d2d23b7fcf6..3410ed63b8e 100644 --- a/layout/reftests/svg-integration/mask-html-01-resource.svg +++ b/layout/reftests/svg-integration/mask-html-01-resource.svg @@ -1,6 +1,10 @@ + +