4 https://bugzilla.mozilla.org/show_bug.cgi?id=292789
7 <title>Test for Bug
292789</title>
8 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
9 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=292789">Mozilla Bug
292789</a>
15 <div id=
"content" style=
"display: none">
16 <script src=
"chrome://global/content/strres.js"></script>
17 <script src=
"chrome://mozapps/content/xpinstall/xpinstallConfirm.js"></script>
20 <script class=
"testbody" type=
"text/javascript">
22 /** Test for Bug
292789
24 ** Selectively allow access to whitelisted chrome packages
25 ** even for ALLOW_CHROME mechanisms (
<script>, <img
> etc
)
28 SimpleTest
.waitForExplicitFinish();
30 /** <script src=""> test **/
31 function testScriptSrc(aCallback
) {
32 is(typeof srGetStrBundle
, "function",
33 "content can still load <script> from chrome://global");
34 is(typeof XPInstallConfirm
, "undefined",
35 "content should not be able to load <script> from chrome://mozapps");
37 /** make sure the last one didn't pass because someone
40 var resjs
= document
.createElement("script");
41 resjs
.src
= "jar:resource://gre/chrome/toolkit.jar!/content/mozapps/xpinstall/xpinstallConfirm.js";
42 resjs
.onload
= scriptOnload
;
43 document
.getElementById("content").appendChild(resjs
);
45 function scriptOnload() {
46 is(typeof XPInstallConfirm
, "object",
47 "xpinstallConfirm.js has not moved unexpectedly");
49 // trigger the callback
55 /** <img src=""> tests **/
56 var img_global
= "chrome://global/skin/icons/Error.png";
57 var img_mozapps
= "chrome://mozapps/skin/passwordmgr/key.png";
58 var res_mozapps
= "jar:resource://gre/chrome/classic.jar!/skin/classic/mozapps/passwordmgr/key.png";
60 var imgTests
= [[img_global
, "success"],
61 [img_mozapps
, "fail"],
62 [res_mozapps
, "success"]];
66 function runImgTest() {
67 var test
= imgTests
[curImgTest
++];
68 var callback
= curImgTest
== imgTests
.length
? finishTest
: runImgTest
;
69 loadImage(test
[0], test
[1], callback
);
72 function finishTest() {
76 function fail(event
) {
77 is(event
.target
.expected
, "fail",
78 "content should not be allowed to load "+event
.target
.src
);
79 if (event
.target
.callback
)
80 event
.target
.callback();
83 function success(event
) {
84 is(event
.target
.expected
, "success",
85 "content should be able to load "+event
.target
.src
);
86 if (event
.target
.callback
)
87 event
.target
.callback();
90 function loadImage(uri
, expect
, callback
) {
91 var img
= document
.createElement("img");
94 img
.expected
= expect
;
95 img
.callback
= callback
;
97 //document.getElementById("content").appendChild(img);
100 // Start off the script src test, and have it start the img tests when complete.
101 testScriptSrc(runImgTest
);