diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 32f0386891e..21812ae3c50 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -157,6 +157,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); #include "nsCycleCollector.h" #include "nsCCUncollectableMarker.h" #include "nsIContentPolicy.h" +#include "nsIPropertyBag2.h" #include "nsFrameLoader.h" @@ -1200,6 +1201,16 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) ResetToURI(uri, aLoadGroup, principal); + nsCOMPtr bag = do_QueryInterface(aChannel); + if (bag) { + nsCOMPtr baseURI; + bag->GetPropertyAsInterface(NS_LITERAL_STRING("baseURI"), + NS_GET_IID(nsIURI), getter_AddRefs(baseURI)); + if (baseURI) { + mDocumentBaseURI = baseURI; + } + } + mChannel = aChannel; } diff --git a/mozilla/content/base/test/Makefile.in b/mozilla/content/base/test/Makefile.in index 65ffa216f12..4aa9b36a944 100644 --- a/mozilla/content/base/test/Makefile.in +++ b/mozilla/content/base/test/Makefile.in @@ -83,6 +83,8 @@ _TEST_FILES = test_bug5141.html \ test_bug238409.html \ test_bug276037-1.html \ test_bug276037-2.xhtml \ + test_bug298064.html \ + bug298064-subframe.html \ test_bug308484.html \ test_bug311681.xml \ test_bug322317.html \ diff --git a/mozilla/content/base/test/bug298064-subframe.html b/mozilla/content/base/test/bug298064-subframe.html new file mode 100644 index 00000000000..af497f59050 --- /dev/null +++ b/mozilla/content/base/test/bug298064-subframe.html @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/mozilla/content/base/test/test_bug298064.html b/mozilla/content/base/test/test_bug298064.html new file mode 100644 index 00000000000..25622e83ef1 --- /dev/null +++ b/mozilla/content/base/test/test_bug298064.html @@ -0,0 +1,33 @@ + + + + + Test for Bug 298064 + + + + + +Mozilla Bug 298064 +

+ +
+
+
+ + diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 748786d50a7..ee40edf51c3 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -2087,10 +2087,13 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace) do_QueryInterface(nsContentUtils::GetDocumentFromContext()); // Grab a reference to the calling documents security info (if any) - // and principal as it may be lost in the call to Reset(). + // and URIs as they may be lost in the call to Reset(). nsCOMPtr securityInfo; + nsCOMPtr uri, baseURI; if (callerDoc) { securityInfo = callerDoc->GetSecurityInfo(); + uri = callerDoc->GetDocumentURI(); + baseURI = callerDoc->GetBaseURI(); } nsCOMPtr callerPrincipal; @@ -2121,18 +2124,6 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace) return NS_ERROR_DOM_SECURITY_ERR; } - // The URI for the document after this call. Get it from the calling - // principal (if available), or set it to "about:blank" if no - // principal is reachable. - nsCOMPtr uri; - callerPrincipal->GetURI(getter_AddRefs(uri)); - - if (!uri) { - rv = NS_NewURI(getter_AddRefs(uri), - NS_LITERAL_CSTRING("about:blank")); - NS_ENSURE_SUCCESS(rv, rv); - } - // Stop current loads targeted at the window this document is in. if (mScriptGlobalObject) { nsCOMPtr cv; @@ -2164,6 +2155,9 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace) return rv; } + // We can't depend on channels implementing property bags, so do our + // base URI manually after reset. + // Set the caller principal, if any, on the channel so that we'll // make sure to use it when we reset. rv = channel->SetOwner(callerPrincipal); @@ -2236,6 +2230,9 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace) // null. Reset(channel, group); + if (baseURI) { + mDocumentBaseURI = baseURI; + } if (root) { // Tear down the frames for the root element. diff --git a/mozilla/content/html/document/test/Makefile.in b/mozilla/content/html/document/test/Makefile.in index 333224815aa..fa2b258662b 100644 --- a/mozilla/content/html/document/test/Makefile.in +++ b/mozilla/content/html/document/test/Makefile.in @@ -46,6 +46,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES = test_bug1682.html \ test_bug1823.html \ + test_bug57600.html \ test_bug199692.html \ bug199692-nested.html \ bug199692-nested-d2.html \ @@ -70,6 +71,12 @@ _TEST_FILES = test_bug1682.html \ test_bug404320.html \ test_form-parsing.html \ test_documentAll.html \ + test_bug445004.html \ + bug445004-inner.js \ + bug445004-outer-rel.html \ + bug445004-outer-abs.html \ + bug445004-outer-write.html \ + bug445004-inner.html \ test_bug448564.html \ bug448564-iframe-1.html \ bug448564-iframe-2.html \ diff --git a/mozilla/content/html/document/test/bug445004-inner.html b/mozilla/content/html/document/test/bug445004-inner.html new file mode 100644 index 00000000000..35f03e38611 --- /dev/null +++ b/mozilla/content/html/document/test/bug445004-inner.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/mozilla/content/html/document/test/bug445004-inner.js b/mozilla/content/html/document/test/bug445004-inner.js new file mode 100644 index 00000000000..3675f8e69af --- /dev/null +++ b/mozilla/content/html/document/test/bug445004-inner.js @@ -0,0 +1,23 @@ +document.domain = "example.org"; +function $(str) { return document.getElementById(str); } +function hookLoad(str) { + $(str).onload = function() { window.parent.parent.postMessage('end', '*'); }; + window.parent.parent.postMessage('start', '*'); +} +window.onload = function() { + hookLoad("w"); + $("w").contentWindow.location.href = "test1.example.org.png"; + hookLoad("x"); + var doc = $("x").contentDocument; + doc.write(''); + doc.close(); +}; +function doIt() { + hookLoad("y"); + $("y").contentWindow.location.href = "example.org.png"; + hookLoad("z"); + var doc = $("z").contentDocument; + doc.write(''); + doc.close(); +} +window.addEventListener("message", doIt, false); \ No newline at end of file diff --git a/mozilla/content/html/document/test/bug445004-outer-abs.html b/mozilla/content/html/document/test/bug445004-outer-abs.html new file mode 100644 index 00000000000..80f42a8fc2d --- /dev/null +++ b/mozilla/content/html/document/test/bug445004-outer-abs.html @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/mozilla/content/html/document/test/bug445004-outer-rel.html b/mozilla/content/html/document/test/bug445004-outer-rel.html new file mode 100644 index 00000000000..c539a37b08b --- /dev/null +++ b/mozilla/content/html/document/test/bug445004-outer-rel.html @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/mozilla/content/html/document/test/bug445004-outer-write.html b/mozilla/content/html/document/test/bug445004-outer-write.html new file mode 100644 index 00000000000..7df82c62c94 --- /dev/null +++ b/mozilla/content/html/document/test/bug445004-outer-write.html @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/mozilla/content/html/document/test/test_bug445004.html b/mozilla/content/html/document/test/test_bug445004.html new file mode 100644 index 00000000000..db5f0c1b443 --- /dev/null +++ b/mozilla/content/html/document/test/test_bug445004.html @@ -0,0 +1,139 @@ + + + + + Test for Bug 445004 + + + + + +Mozilla Bug 445004 + +
+
+
+

+ + + + + +

+ + diff --git a/mozilla/content/html/document/test/test_bug57600.html b/mozilla/content/html/document/test/test_bug57600.html new file mode 100644 index 00000000000..22d065c05d4 --- /dev/null +++ b/mozilla/content/html/document/test/test_bug57600.html @@ -0,0 +1,43 @@ + + + + + Test for Bug 57600 + + + + + +Mozilla Bug 57600 + +
+
+
+

+ + +

+ + diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp index a27174ec499..d88d6b49b1f 100644 --- a/mozilla/dom/src/base/nsLocation.cpp +++ b/mozilla/dom/src/base/nsLocation.cpp @@ -245,7 +245,9 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo) // Walk up the docshell hierarchy and find a usable base URI. Basically // anything that would allow a relative uri. - +// XXXbz we don't need this for javascript: URIs anymore. Do we need +// it for about:blank? I would think that we don't, and that we can +// nuke this code. nsresult nsLocation::FindUsableBaseURI(nsIURI * aBaseURI, nsIDocShell * aParent, nsIURI ** aUsableURI) diff --git a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp index 7d214e2bf20..c73088a533a 100644 --- a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -75,6 +75,11 @@ #include "nsIJSContextStack.h" #include "nsIScriptChannel.h" #include "nsIDocument.h" +#include "nsIObjectInputStream.h" +#include "nsIObjectOutputStream.h" +#include "nsIWritablePropertyBag2.h" + +static NS_DEFINE_CID(kJSURICID, NS_JSURI_CID); class nsJSThunk : public nsIInputStream { @@ -382,7 +387,8 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel, class nsJSChannel : public nsIChannel, public nsIStreamListener, - public nsIScriptChannel + public nsIScriptChannel, + public nsIPropertyBag2 { public: nsJSChannel(); @@ -393,6 +399,8 @@ public: NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER NS_DECL_NSISCRIPTCHANNEL + NS_FORWARD_SAFE_NSIPROPERTYBAG(mPropertyBag) + NS_FORWARD_SAFE_NSIPROPERTYBAG2(mPropertyBag) nsresult Init(nsIURI *aURI); @@ -410,6 +418,7 @@ protected: protected: nsCOMPtr mStreamChannel; + nsCOMPtr mPropertyBag; nsCOMPtr mListener; // Our final listener nsCOMPtr mContext; // The context passed to AsyncOpen nsCOMPtr mOriginalInnerWindow; // The inner window our load @@ -463,7 +472,10 @@ nsresult nsJSChannel::StopAll() nsresult nsJSChannel::Init(nsIURI *aURI) { - nsresult rv; + nsRefPtr jsURI; + nsresult rv = aURI->QueryInterface(kJSURICID, + getter_AddRefs(jsURI)); + NS_ENSURE_SUCCESS(rv, rv); // Create the nsIStreamIO layer used by the nsIStreamIOChannel. mIOThunk = new nsJSThunk(); @@ -484,6 +496,13 @@ nsresult nsJSChannel::Init(nsIURI *aURI) rv = mIOThunk->Init(aURI); if (NS_SUCCEEDED(rv)) { mStreamChannel = channel; + mPropertyBag = do_QueryInterface(channel); + nsCOMPtr writableBag = + do_QueryInterface(channel); + if (writableBag && jsURI->GetBaseURI()) { + writableBag->SetPropertyAsInterface(NS_LITERAL_STRING("baseURI"), + jsURI->GetBaseURI()); + } } return rv; @@ -493,17 +512,9 @@ nsresult nsJSChannel::Init(nsIURI *aURI) // nsISupports implementation... // -NS_IMPL_ADDREF(nsJSChannel) -NS_IMPL_RELEASE(nsJSChannel) - -NS_INTERFACE_MAP_BEGIN(nsJSChannel) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel) - NS_INTERFACE_MAP_ENTRY(nsIRequest) - NS_INTERFACE_MAP_ENTRY(nsIChannel) - NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) - NS_INTERFACE_MAP_ENTRY(nsIStreamListener) - NS_INTERFACE_MAP_ENTRY(nsIScriptChannel) -NS_INTERFACE_MAP_END +NS_IMPL_ISUPPORTS7(nsJSChannel, nsIChannel, nsIRequest, nsIRequestObserver, + nsIStreamListener, nsIScriptChannel, nsIPropertyBag, + nsIPropertyBag2) // // nsIRequest implementation... @@ -1138,7 +1149,7 @@ nsJSProtocolHandler::GetProtocolFlags(PRUint32 *result) NS_IMETHODIMP nsJSProtocolHandler::NewURI(const nsACString &aSpec, - const char *aCharset, // ignore charset info + const char *aCharset, nsIURI *aBaseURI, nsIURI **result) { @@ -1148,8 +1159,7 @@ nsJSProtocolHandler::NewURI(const nsACString &aSpec, // provided by standard URLs, so there is no "outer" object given to // CreateInstance. - nsIURI* url; - rv = CallCreateInstance(NS_SIMPLEURI_CONTRACTID, &url); + nsCOMPtr url = do_CreateInstance(NS_SIMPLEURI_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; @@ -1168,11 +1178,13 @@ nsJSProtocolHandler::NewURI(const nsACString &aSpec, } if (NS_FAILED(rv)) { - NS_RELEASE(url); return rv; } - *result = url; + *result = new nsJSURI(aBaseURI, url); + NS_ENSURE_TRUE(*result, NS_ERROR_OUT_OF_MEMORY); + + NS_ADDREF(*result); return rv; } @@ -1207,3 +1219,167 @@ nsJSProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval return NS_OK; } +//////////////////////////////////////////////////////////// +// nsJSURI implementation + +NS_IMPL_ADDREF(nsJSURI) +NS_IMPL_RELEASE(nsJSURI) + +NS_INTERFACE_MAP_BEGIN(nsJSURI) + NS_INTERFACE_MAP_ENTRY(nsIURI) + NS_INTERFACE_MAP_ENTRY(nsISerializable) + NS_INTERFACE_MAP_ENTRY(nsIClassInfo) + NS_INTERFACE_MAP_ENTRY(nsIMutable) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURI) + if (aIID.Equals(kJSURICID)) + foundInterface = static_cast(this); + else +NS_INTERFACE_MAP_END + +// nsISerializable methods: + +NS_IMETHODIMP +nsJSURI::Read(nsIObjectInputStream* aStream) +{ + nsresult rv; + + rv = aStream->ReadObject(PR_TRUE, getter_AddRefs(mSimpleURI)); + if (NS_FAILED(rv)) return rv; + + mMutable = do_QueryInterface(mSimpleURI); + NS_ENSURE_TRUE(mMutable, NS_ERROR_UNEXPECTED); + + PRBool haveBase; + rv = aStream->ReadBoolean(&haveBase); + if (NS_FAILED(rv)) return rv; + + if (haveBase) { + rv = aStream->ReadObject(PR_TRUE, getter_AddRefs(mBaseURI)); + if (NS_FAILED(rv)) return rv; + } + + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::Write(nsIObjectOutputStream* aStream) +{ + nsresult rv; + + rv = aStream->WriteObject(mSimpleURI, PR_TRUE); + if (NS_FAILED(rv)) return rv; + + rv = aStream->WriteBoolean(mBaseURI != nsnull); + if (NS_FAILED(rv)) return rv; + + if (mBaseURI) { + rv = aStream->WriteObject(mBaseURI, PR_TRUE); + if (NS_FAILED(rv)) return rv; + } + + return NS_OK; +} + +// nsIURI methods: + +NS_IMETHODIMP +nsJSURI::Clone(nsIURI** aClone) +{ + nsCOMPtr simpleClone; + nsresult rv = mSimpleURI->Clone(getter_AddRefs(simpleClone)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr baseClone; + if (mBaseURI) { + rv = mBaseURI->Clone(getter_AddRefs(baseClone)); + NS_ENSURE_SUCCESS(rv, rv); + } + + nsIURI* newURI = new nsJSURI(baseClone, simpleClone); + NS_ENSURE_TRUE(newURI, NS_ERROR_OUT_OF_MEMORY); + + NS_ADDREF(*aClone = newURI); + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::Equals(nsIURI* aOther, PRBool *aResult) +{ + if (!aOther) { + *aResult = PR_FALSE; + return NS_OK; + } + + nsRefPtr otherJSUri; + aOther->QueryInterface(kJSURICID, getter_AddRefs(otherJSUri)); + if (!otherJSUri) { + *aResult = PR_FALSE; + return NS_OK; + } + + return mSimpleURI->Equals(otherJSUri->mSimpleURI, aResult); +} + +// nsIClassInfo methods: +NS_IMETHODIMP +nsJSURI::GetInterfaces(PRUint32 *count, nsIID * **array) +{ + *count = 0; + *array = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::GetHelperForLanguage(PRUint32 language, nsISupports **_retval) +{ + *_retval = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::GetContractID(char * *aContractID) +{ + // Make sure to modify any subclasses as needed if this ever + // changes. + *aContractID = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::GetClassDescription(char * *aClassDescription) +{ + *aClassDescription = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::GetClassID(nsCID * *aClassID) +{ + // Make sure to modify any subclasses as needed if this ever + // changes to not call the virtual GetClassIDNoAlloc. + *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + if (!*aClassID) + return NS_ERROR_OUT_OF_MEMORY; + return GetClassIDNoAlloc(*aClassID); +} + +NS_IMETHODIMP +nsJSURI::GetImplementationLanguage(PRUint32 *aImplementationLanguage) +{ + *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::GetFlags(PRUint32 *aFlags) +{ + *aFlags = nsIClassInfo::MAIN_THREAD_ONLY; + return NS_OK; +} + +NS_IMETHODIMP +nsJSURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) +{ + *aClassIDNoAlloc = kJSURICID; + return NS_OK; +} diff --git a/mozilla/dom/src/jsurl/nsJSProtocolHandler.h b/mozilla/dom/src/jsurl/nsJSProtocolHandler.h index c916a182b13..4a05a59eea9 100644 --- a/mozilla/dom/src/jsurl/nsJSProtocolHandler.h +++ b/mozilla/dom/src/jsurl/nsJSProtocolHandler.h @@ -40,6 +40,10 @@ #include "nsIProtocolHandler.h" #include "nsITextToSubURI.h" +#include "nsIURI.h" +#include "nsIMutable.h" +#include "nsISerializable.h" +#include "nsIClassInfo.h" #define NS_JSPROTOCOLHANDLER_CID \ { /* bfc310d2-38a0-11d3-8cd3-0060b0fc14a3 */ \ @@ -49,6 +53,14 @@ {0x8c, 0xd3, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ } +#define NS_JSURI_CID \ +{ /* 58f089ee-512a-42d2-a935-d0c874128930 */ \ + 0x58f089ee, \ + 0x512a, \ + 0x42d2, \ + {0xa9, 0x35, 0xd0, 0xc8, 0x74, 0x12, 0x89, 0x30} \ +} + #define NS_JSPROTOCOLHANDLER_CONTRACTID \ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "javascript" @@ -78,4 +90,58 @@ protected: nsCOMPtr mTextToSubURI; }; +// Use an extra base object to avoid having to manually retype all the +// nsIURI methods. I wish we could just inherit from nsSimpleURI instead. +class nsJSURI_base : public nsIURI, + public nsIMutable +{ +public: + nsJSURI_base(nsIURI* aSimpleURI) : + mSimpleURI(aSimpleURI) + { + mMutable = do_QueryInterface(mSimpleURI); + NS_ASSERTION(aSimpleURI && mMutable, "This isn't going to work out"); + } + virtual ~nsJSURI_base() {} + + // For use only from deserialization + nsJSURI_base() {} + + NS_FORWARD_NSIURI(mSimpleURI->) + NS_FORWARD_NSIMUTABLE(mMutable->) + +protected: + nsCOMPtr mSimpleURI; + nsCOMPtr mMutable; +}; + +class nsJSURI : public nsJSURI_base, + public nsISerializable, + public nsIClassInfo +{ +public: + nsJSURI(nsIURI* aBaseURI, nsIURI* aSimpleURI) : + nsJSURI_base(aSimpleURI), mBaseURI(aBaseURI) + {} + virtual ~nsJSURI() {} + + // For use only from deserialization + nsJSURI() : nsJSURI_base() {} + + NS_DECL_ISUPPORTS + NS_DECL_NSISERIALIZABLE + NS_DECL_NSICLASSINFO + + // Override Clone() and Equals() + NS_IMETHOD Clone(nsIURI** aClone); + NS_IMETHOD Equals(nsIURI* aOther, PRBool *aResult); + + nsIURI* GetBaseURI() const { + return mBaseURI; + } + +private: + nsCOMPtr mBaseURI; +}; + #endif /* nsJSProtocolHandler_h___ */ diff --git a/mozilla/dom/tests/unit/test_bug465752.js b/mozilla/dom/tests/unit/test_bug465752.js new file mode 100644 index 00000000000..9b280a6cc7e --- /dev/null +++ b/mozilla/dom/tests/unit/test_bug465752.js @@ -0,0 +1,61 @@ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * Boris Zbarskt . + * + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. 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 ***** + */ + +function run_test() +{ + const ios = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + const str = "javascript:10"; + var uri = ios.newURI(str, null, null); + var uri2 = ios.newURI(str, null, null); + const str2 = "http://example.org"; + var uri3 = ios.newURI(str2, null, null); + do_check_true(uri.equals(uri)); + do_check_true(uri.equals(uri2)); + do_check_true(uri2.equals(uri)); + do_check_true(uri2.equals(uri2)); + do_check_false(uri3.equals(uri2)); + do_check_false(uri2.equals(uri3)); + + var simple = Components.classes["@mozilla.org/network/simple-uri;1"] + .createInstance(Components.interfaces.nsIURI); + simple.spec = str; + do_check_eq(simple.spec, uri.spec); + do_check_false(simple.equals(uri)); + do_check_false(uri.equals(simple)); +} diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 52fb6265744..90a48124722 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -125,6 +125,7 @@ #include "nsITimelineService.h" #include "nsGfxCIID.h" #include "nsStyleSheetService.h" +#include "ImageErrors.h" #include "nsIPrompt.h" #include "imgIContainer.h" // image animation mode constants @@ -959,7 +960,11 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus) // Now, fire either an OnLoad or OnError event to the document... PRBool restoring = PR_FALSE; - if(NS_SUCCEEDED(aStatus)) { + // XXXbz imagelib kills off the document load for a full-page image with + // NS_IMAGELIB_ERROR_LOAD_ABORTED if it's in the cache. So we want to treat + // that one as a success code; otherwise whether we fire onload for the image + // will depend on whether it's cached! + if((NS_SUCCEEDED(aStatus) || aStatus == NS_IMAGELIB_ERROR_LOAD_ABORTED)) { nsEventStatus status = nsEventStatus_eIgnore; nsEvent event(PR_TRUE, NS_LOAD); event.flags |= NS_EVENT_FLAG_CANT_BUBBLE; diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index 77d383428fd..ce66c58f5ac 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -536,6 +536,8 @@ MAKE_CTOR(CreateCanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D, NS_New NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSURI) + // views are not refcounted, so this is the same as // NS_GENERIC_FACTORY_CONSTRUCTOR without the NS_ADDREF/NS_RELEASE #define NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(_InstanceClass) \ @@ -1251,6 +1253,10 @@ static const nsModuleComponentInfo gComponents[] = { NS_JSPROTOCOLHANDLER_CID, NS_JSPROTOCOLHANDLER_CONTRACTID, nsJSProtocolHandler::Create }, + { "JavaScript URI", + NS_JSURI_CID, + nsnull, + nsJSURIConstructor }, { "Window Command Table", NS_WINDOWCOMMANDTABLE_CID, "", diff --git a/mozilla/layout/reftests/bugs/445004-1-ref.html b/mozilla/layout/reftests/bugs/445004-1-ref.html new file mode 100644 index 00000000000..f56a9d7b770 --- /dev/null +++ b/mozilla/layout/reftests/bugs/445004-1-ref.html @@ -0,0 +1,4 @@ + + + + diff --git a/mozilla/layout/reftests/bugs/445004-1.html b/mozilla/layout/reftests/bugs/445004-1.html new file mode 100644 index 00000000000..2535e016421 --- /dev/null +++ b/mozilla/layout/reftests/bugs/445004-1.html @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/mozilla/layout/reftests/bugs/reftest.list b/mozilla/layout/reftests/bugs/reftest.list index c9067ab99e0..b29991b6c8c 100644 --- a/mozilla/layout/reftests/bugs/reftest.list +++ b/mozilla/layout/reftests/bugs/reftest.list @@ -833,3 +833,4 @@ fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 424074-1-ref2.xul 424074-1-ref3.xul == 436356-2.html 436356-2-ref.html == 440112.html 440112-ref.html == 440149-1.html 440149-1-ref.html +== 445004-1.html 445004-1-ref.html diff --git a/mozilla/layout/reftests/bugs/subdir/445004-ref-subframe.html b/mozilla/layout/reftests/bugs/subdir/445004-ref-subframe.html new file mode 100644 index 00000000000..7f6af3c6dd7 --- /dev/null +++ b/mozilla/layout/reftests/bugs/subdir/445004-ref-subframe.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/mozilla/layout/reftests/bugs/subdir/445004-ref-subsubframe.html b/mozilla/layout/reftests/bugs/subdir/445004-ref-subsubframe.html new file mode 100644 index 00000000000..21e8bed1bff --- /dev/null +++ b/mozilla/layout/reftests/bugs/subdir/445004-ref-subsubframe.html @@ -0,0 +1 @@ + diff --git a/mozilla/layout/reftests/bugs/subdir/445004-subframe.html b/mozilla/layout/reftests/bugs/subdir/445004-subframe.html new file mode 100644 index 00000000000..666cec99339 --- /dev/null +++ b/mozilla/layout/reftests/bugs/subdir/445004-subframe.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + +