mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 403331: update JAR channel URIs after a redirect. r=bz, r=jwalden (mochitest changes), sr=dveditz
This commit is contained in:
parent
5ddd1d31b3
commit
a838fcc9b6
@ -47,7 +47,7 @@
|
||||
*
|
||||
* The nsIURL methods operate on the <jar-entry> part of the spec.
|
||||
*/
|
||||
[scriptable, uuid(d2746619-1724-4f42-8ca8-dacaf1b269d6)]
|
||||
[scriptable, uuid(b0922a89-f87b-4cb5-8612-305a285fcca7)]
|
||||
interface nsIJARURI : nsIURL {
|
||||
|
||||
/**
|
||||
@ -61,4 +61,10 @@ interface nsIJARURI : nsIURL {
|
||||
* value may contain %-escaped byte sequences.
|
||||
*/
|
||||
attribute AUTF8String JAREntry;
|
||||
|
||||
/**
|
||||
* Create a clone of the JAR URI with a new root URI (the URI for the
|
||||
* actual JAR file).
|
||||
*/
|
||||
nsIJARURI cloneWithJARFile(in nsIURI jarFile);
|
||||
};
|
||||
|
@ -701,15 +701,40 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
|
||||
nsresult status,
|
||||
nsIFile *file)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Grab the security info from our base channel
|
||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
|
||||
if (channel)
|
||||
if (channel) {
|
||||
channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
|
||||
|
||||
|
||||
PRUint32 loadFlags;
|
||||
channel->GetLoadFlags(&loadFlags);
|
||||
if (loadFlags & LOAD_REPLACE) {
|
||||
mLoadFlags |= LOAD_REPLACE;
|
||||
|
||||
if (!mOriginalURI) {
|
||||
SetOriginalURI(mJarURI);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> innerURI;
|
||||
rv = channel->GetURI(getter_AddRefs(innerURI));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIJARURI> newURI;
|
||||
rv = mJarURI->CloneWithJARFile(innerURI,
|
||||
getter_AddRefs(newURI));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mJarURI = newURI;
|
||||
}
|
||||
}
|
||||
status = rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
mJarFile = file;
|
||||
|
||||
nsresult rv = CreateJarInput(nsnull);
|
||||
rv = CreateJarInput(nsnull);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// create input stream pump
|
||||
rv = NS_NewInputStreamPump(getter_AddRefs(mPump), mJarInput);
|
||||
|
@ -499,31 +499,11 @@ nsJARURI::Clone(nsIURI **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> newJARFile;
|
||||
rv = mJARFile->Clone(getter_AddRefs(newJARFile));
|
||||
nsCOMPtr<nsIJARURI> uri;
|
||||
rv = CloneWithJARFile(mJARFile, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_TryToSetImmutable(newJARFile);
|
||||
|
||||
nsCOMPtr<nsIURI> newJAREntryURI;
|
||||
rv = mJAREntry->Clone(getter_AddRefs(newJAREntryURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIURL> newJAREntry(do_QueryInterface(newJAREntryURI));
|
||||
NS_ASSERTION(newJAREntry, "This had better QI to nsIURL!");
|
||||
|
||||
nsJARURI* uri = new nsJARURI();
|
||||
if (uri) {
|
||||
NS_ADDREF(uri);
|
||||
uri->mJARFile = newJARFile;
|
||||
uri->mJAREntry = newJAREntry;
|
||||
*result = uri;
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return CallQueryInterface(uri, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -785,6 +765,42 @@ nsJARURI::SetJAREntry(const nsACString &entryPath)
|
||||
getter_AddRefs(mJAREntry));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::CloneWithJARFile(nsIURI *jarFile, nsIJARURI **result)
|
||||
{
|
||||
if (!jarFile) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> newJARFile;
|
||||
rv = jarFile->Clone(getter_AddRefs(newJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_TryToSetImmutable(newJARFile);
|
||||
|
||||
nsCOMPtr<nsIURI> newJAREntryURI;
|
||||
rv = mJAREntry->Clone(getter_AddRefs(newJAREntryURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIURL> newJAREntry(do_QueryInterface(newJAREntryURI));
|
||||
NS_ASSERTION(newJAREntry, "This had better QI to nsIURL!");
|
||||
|
||||
nsJARURI* uri = new nsJARURI();
|
||||
if (uri) {
|
||||
NS_ADDREF(uri);
|
||||
uri->mJARFile = newJARFile;
|
||||
uri->mJAREntry = newJAREntry;
|
||||
*result = uri;
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -47,4 +47,8 @@ MODULE = test_libjar
|
||||
|
||||
XPCSHELL_TESTS = unit
|
||||
|
||||
ifdef MOZ_MOCHITEST
|
||||
DIRS += mochitest
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
54
modules/libjar/test/mochitest/Makefile.in
Normal file
54
modules/libjar/test/mochitest/Makefile.in
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# ***** 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
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = modules/libjar/test/mochitest
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_bug403331.html \
|
||||
bug403331.zip \
|
||||
bug403331.zip^headers^ \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
BIN
modules/libjar/test/mochitest/bug403331.zip
Normal file
BIN
modules/libjar/test/mochitest/bug403331.zip
Normal file
Binary file not shown.
1
modules/libjar/test/mochitest/bug403331.zip^headers^
Normal file
1
modules/libjar/test/mochitest/bug403331.zip^headers^
Normal file
@ -0,0 +1 @@
|
||||
Content-Type: application/java-archive
|
46
modules/libjar/test/mochitest/test_bug403331.html
Normal file
46
modules/libjar/test/mochitest/test_bug403331.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=403331
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 403331</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<iframe id="testFrame"></iframe>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 403331 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
var testFrame = document.getElementById('testFrame');
|
||||
|
||||
// Try a redirected load from another domain to this one.
|
||||
|
||||
testFrame.onload = function() {
|
||||
// If properly redirected, we'll be able to access elements in the loaded
|
||||
// document.
|
||||
var item = testFrame.contentDocument.getElementById('testitem');
|
||||
is(item.textContent, "testcontents", "Should be able to access the child document");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
testFrame.src = "jar:http://example.org:80/redirect?http://localhost:8888/tests/modules/libjar/test/mochitest/bug403331.zip!/test.html";
|
||||
}
|
||||
|
||||
addLoadEvent(runTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -140,6 +140,8 @@ function runServer()
|
||||
if (environment["CLOSE_WHEN_DONE"])
|
||||
server.registerPathHandler("/server/shutdown", serverShutdown);
|
||||
|
||||
server.registerPathHandler("/redirect", redirect);
|
||||
|
||||
server.setIndexHandler(defaultDirHandler);
|
||||
server.start(SERVER_PORT);
|
||||
|
||||
@ -198,6 +200,12 @@ function serverShutdown(metadata, response)
|
||||
otherDomainServer.stop();
|
||||
}
|
||||
|
||||
function redirect(metadata, response)
|
||||
{
|
||||
response.setStatusLine("1.1", 301, "Moved Permanently");
|
||||
response.setHeader("Location", metadata.queryString);
|
||||
}
|
||||
|
||||
//
|
||||
// DIRECTORY LISTINGS
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user