js/xpconnect/tests/mochitest/test_bug504877.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:3479d2ab1e7e
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=504877
5 -->
6 <head>
7 <title>Test for Bug 504877</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504877">Mozilla Bug 504877</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
15
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
19
20 /** Test for Bug 504877 **/
21 SimpleTest.waitForExplicitFinish();
22 var p = 0;
23 function go() {
24 var ifr = $('ifr').contentWindow;
25 function test1() {
26 try {
27 ifr.foopy;
28 ok(false, "should have thrown a cross-origin access exception");
29 } catch (e) {
30 ok(/Permission denied/.test(e), "Threw a permission denied exception");
31 }
32
33 var loc = ifr.location;
34 (function() {
35 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
36 ifr.blat = 42;
37
38 is(ifr.blat, 42, "able to set random properties")
39 is(ifr.getblat(), 42, "setting properties propagates");
40 is(ifr.foopy, 42, "able to use UniversalXPConnect to get random properties");
41
42 loc.replace; // resolves the property onto the wrapper.
43 })();
44
45 loc.replace("http://mochi.test:8888/");
46 ok(true, "able to set location on the cross origin(!) frame");
47 }
48
49 function test2() {
50 SimpleTest.finish();
51 }
52
53 switch (++p) {
54 case 1: return test1();
55 case 2: return test2();
56 }
57 }
58
59
60 </script>
61 </pre>
62 <iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/bug504877_helper.html" id="ifr" onload="go()"></iframe>
63 </body>
64 </html>

mercurial