2008-04-12 17:55:45 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=292789
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 292789</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2008-04-12 17:55:45 -07:00
|
|
|
<script type="text/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=292789">Mozilla Bug 292789</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
<script src="chrome://global/content/strres.js"></script>
|
|
|
|
<script src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js"></script>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 292789
|
|
|
|
**
|
|
|
|
** Selectively allow access to whitelisted chrome packages
|
|
|
|
** even for ALLOW_CHROME mechanisms (<script>, <img> etc)
|
|
|
|
**/
|
|
|
|
|
2008-04-14 01:50:51 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2008-04-12 17:55:45 -07:00
|
|
|
|
2008-04-14 01:50:51 -07:00
|
|
|
/** <script src=""> test **/
|
|
|
|
function testScriptSrc(aCallback) {
|
|
|
|
is(typeof srGetStrBundle, "function",
|
|
|
|
"content can still load <script> from chrome://global");
|
|
|
|
is(typeof XPInstallConfirm, "undefined",
|
|
|
|
"content should not be able to load <script> from chrome://mozapps");
|
|
|
|
|
|
|
|
/** make sure the last one didn't pass because someone
|
|
|
|
** moved the resource
|
|
|
|
**/
|
|
|
|
var resjs = document.createElement("script");
|
2010-08-10 15:18:40 -07:00
|
|
|
#ifdef MOZ_CHROME_FILE_FORMAT_JAR
|
2008-04-14 01:50:51 -07:00
|
|
|
resjs.src = "jar:resource://gre/chrome/toolkit.jar!/content/mozapps/xpinstall/xpinstallConfirm.js";
|
2010-08-10 15:18:40 -07:00
|
|
|
#else
|
|
|
|
resjs.src = "resource://gre/chrome/toolkit/content/mozapps/xpinstall/xpinstallConfirm.js";
|
|
|
|
#endif
|
2008-04-14 01:50:51 -07:00
|
|
|
resjs.onload = scriptOnload;
|
|
|
|
document.getElementById("content").appendChild(resjs);
|
2008-04-12 17:55:45 -07:00
|
|
|
|
2008-04-14 01:50:51 -07:00
|
|
|
function scriptOnload() {
|
|
|
|
is(typeof XPInstallConfirm, "object",
|
|
|
|
"xpinstallConfirm.js has not moved unexpectedly");
|
|
|
|
|
|
|
|
// trigger the callback
|
|
|
|
if (aCallback)
|
|
|
|
aCallback();
|
|
|
|
}
|
|
|
|
}
|
2008-04-12 17:55:45 -07:00
|
|
|
|
|
|
|
/** <img src=""> tests **/
|
|
|
|
var img_global = "chrome://global/skin/icons/Error.png";
|
|
|
|
var img_mozapps = "chrome://mozapps/skin/passwordmgr/key.png";
|
2010-08-10 15:18:40 -07:00
|
|
|
#ifdef MOZ_CHROME_FILE_FORMAT_JAR
|
2009-08-14 09:32:40 -07:00
|
|
|
var res_mozapps = "jar:resource://gre/chrome/toolkit.jar!/skin/classic/mozapps/passwordmgr/key.png";
|
2010-08-10 15:18:40 -07:00
|
|
|
#else
|
|
|
|
var res_mozapps = "resource://gre/chrome/toolkit/skin/classic/mozapps/passwordmgr/key.png";
|
|
|
|
#endif
|
2008-04-12 17:55:45 -07:00
|
|
|
|
2008-04-14 01:50:51 -07:00
|
|
|
var imgTests = [[img_global, "success"],
|
|
|
|
[img_mozapps, "fail"],
|
|
|
|
[res_mozapps, "success"]];
|
|
|
|
|
|
|
|
var curImgTest = 0;
|
|
|
|
|
|
|
|
function runImgTest() {
|
|
|
|
var test = imgTests[curImgTest++];
|
|
|
|
var callback = curImgTest == imgTests.length ? finishTest : runImgTest;
|
|
|
|
loadImage(test[0], test[1], callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function finishTest() {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2008-04-12 17:55:45 -07:00
|
|
|
function fail(event) {
|
|
|
|
is(event.target.expected, "fail",
|
|
|
|
"content should not be allowed to load "+event.target.src);
|
2008-04-14 01:50:51 -07:00
|
|
|
if (event.target.callback)
|
|
|
|
event.target.callback();
|
2008-04-12 17:55:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function success(event) {
|
|
|
|
is(event.target.expected, "success",
|
|
|
|
"content should be able to load "+event.target.src);
|
2008-04-14 01:50:51 -07:00
|
|
|
if (event.target.callback)
|
|
|
|
event.target.callback();
|
2008-04-12 17:55:45 -07:00
|
|
|
}
|
|
|
|
|
2008-04-14 01:50:51 -07:00
|
|
|
function loadImage(uri, expect, callback) {
|
2008-04-12 17:55:45 -07:00
|
|
|
var img = document.createElement("img");
|
|
|
|
img.onerror = fail;
|
|
|
|
img.onload = success;
|
|
|
|
img.expected = expect;
|
2008-04-14 01:50:51 -07:00
|
|
|
img.callback = callback;
|
2008-04-12 17:55:45 -07:00
|
|
|
img.src = uri;
|
|
|
|
//document.getElementById("content").appendChild(img);
|
|
|
|
}
|
|
|
|
|
2008-04-14 01:50:51 -07:00
|
|
|
// Start off the script src test, and have it start the img tests when complete.
|
|
|
|
testScriptSrc(runImgTest);
|
2008-04-12 17:55:45 -07:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|