Bug 461735. Use the final channel URI as the script URI. r+sr=jst, a=beltzner

This commit is contained in:
Boris Zbarsky 2008-11-10 16:09:30 -05:00
parent 7b53df46a7
commit 21d64b0e5f
6 changed files with 58 additions and 5 deletions

View File

@ -108,6 +108,7 @@ public:
nsString mScriptText; // Holds script for loaded scripts
PRUint32 mJSVersion;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mFinalURI;
PRInt32 mLineNo;
};
@ -624,11 +625,10 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
nsCAutoString url;
if (aRequest->mURI) {
rv = aRequest->mURI->GetSpec(url);
if (NS_FAILED(rv)) {
return rv;
}
nsIURI* uri = aRequest->mFinalURI ? aRequest->mFinalURI : aRequest->mURI;
rv = uri->GetSpec(url);
if (NS_FAILED(rv)) {
return rv;
}
PRBool oldProcessingScriptTag = context->GetProcessingScriptTag();
@ -912,6 +912,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
}
nsCOMPtr<nsIChannel> channel = do_QueryInterface(req);
NS_GetFinalChannelURI(channel, getter_AddRefs(aRequest->mFinalURI));
if (aStringLen) {
// Check the charset attribute to determine script charset.
nsAutoString hintCharset;

View File

@ -254,6 +254,10 @@ _TEST_FILES = test_bug5141.html \
file_XHRDocURI.text \
file_XHRDocURI.text^headers^ \
test_bug459424.html \
bug461735-redirect1.sjs \
bug461735-redirect2.sjs \
bug461735-post-redirect.js \
test_bug461735.html \
$(NULL)
# Disabled for now. Mochitest isn't reliable enough for these.

View File

@ -0,0 +1,3 @@
var a = 0;
var b = 0;
c();

View File

@ -0,0 +1,4 @@
function handleRequest(request, response) {
response.setStatusLine(null, 302, "Found");
response.setHeader("Location", "http://example.com/tests/content/base/test/bug461735-post-redirect.js", false);
}

View File

@ -0,0 +1,4 @@
function handleRequest(request, response) {
response.setStatusLine(null, 302, "Found");
response.setHeader("Location", "http://localhost:8888/tests/content/base/test/bug461735-post-redirect.js", false);
}

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=461735
-->
<head>
<title>Test for Bug 461735</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=461735">Mozilla Bug 461735</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
window.onerror = function(message, uri, line) {
is(message, "Script error.", "Should have empty error message");
is(uri, "http://example.com/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI");
is(line, 0, "Shouldn't have a line here");
}
</script>
<script src="bug461735-redirect1.sjs"></script>
<script type="application/javascript">
window.onerror = function(message, uri, line) {
is(message, "c is not defined", "Should have correct error message");
is(uri, "http://localhost:8888/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI");
is(line, 3, "Should have a line here");
}
</script>
<script src="bug461735-redirect2.sjs"></script>
</pre>
</body>
</html>