Bug 722037. Correctly ignore javascript: images in security UI. r=kaie

--HG--
rename : security/manager/ssl/tests/mochitest/mixedcontent/test_securePicture.html => security/manager/ssl/tests/mochitest/mixedcontent/test_javascriptPicture.html
This commit is contained in:
Boris Zbarsky 2012-02-21 18:01:41 -05:00
Родитель 058571b211
Коммит 6566b23698
3 изменённых файлов: 51 добавлений и 16 удалений

Просмотреть файл

@ -795,18 +795,23 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel)
{
if (channel) {
channel->GetURI(getter_AddRefs(uri));
if (uri)
{
bool vs;
if (NS_SUCCEEDED(uri->SchemeIs("javascript", &vs)) && vs)
{
// We ignore the progress events for javascript URLs.
// If a document loading gets triggered, we will see more events.
return NS_OK;
}
}
nsCOMPtr<imgIRequest> imgRequest(do_QueryInterface(aRequest));
if (imgRequest) {
NS_ASSERTION(!channel, "How did that happen, exactly?");
// for image requests, we get the URI from here
imgRequest->GetURI(getter_AddRefs(uri));
}
if (uri) {
bool vs;
if (NS_SUCCEEDED(uri->SchemeIs("javascript", &vs)) && vs) {
// We ignore the progress events for javascript URLs.
// If a document loading gets triggered, we will see more events.
return NS_OK;
}
}
@ -842,11 +847,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
bool isSubDocumentRelevant = true;
// We are only interested in requests that load in the browser window...
nsCOMPtr<imgIRequest> imgRequest(do_QueryInterface(aRequest));
if (imgRequest) {
// for image requests, we get the URI from here
imgRequest->GetURI(getter_AddRefs(uri));
} else { // is not imgRequest
if (!imgRequest) { // is not imgRequest
nsCOMPtr<nsIHttpChannel> httpRequest(do_QueryInterface(aRequest));
if (!httpRequest) {
nsCOMPtr<nsIFileChannel> fileRequest(do_QueryInterface(aRequest));

Просмотреть файл

@ -86,6 +86,7 @@ _TEST_FILES = \
test_dynUnsecurePicturePreload.html \
test_innerHtmlDelayedUnsecurePicture.html \
test_innerHtmlUnsecurePicture.html \
test_javascriptPicture.html \
test_secureAll.html \
test_securePicture.html \
test_unsecureBackground.html \

Просмотреть файл

@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Secure img load</title>
<script type="text/javascript" src="/MochiKit/Base.js"></script>
<script type="text/javascript" src="/MochiKit/DOM.js"></script>
<script type="text/javascript" src="/MochiKit/Style.js"></script>
<script type="text/javascript" src="/MochiKit/Signal.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="mixedContentTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script class="testbody" type="text/javascript">
function runTest()
{
isSecurityState("secure", "javascript: <img> should not break security");
finish();
}
function afterNavigationTest()
{
isSecurityState("secure", "Still secure after renavigation");
finish();
}
</script>
</head>
<body>
<img src="javascript:'Random data'" />
</body>
</html>