caps/tests/mochitest/test_app_principal_equality.html

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:c04c61662633
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=777467
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test app principal's equality</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777467">Mozilla Bug 777467</a>
14 <p id="display"></p>
15 <script>
16 // Initialization.
17 SpecialPowers.addPermission("browser", true, document);
18 SpecialPowers.addPermission("embed-apps", true, document);
19
20 SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
21 SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", false);
22 </script>
23 <div id="content" style="display: none;">
24 <iframe src="error404"></iframe>
25 <iframe mozbrowser src="error404"></iframe>
26 <iframe mozapp="http://example.org/manifest.webapp" mozbrowser src="error404"></iframe>
27 </div>
28 <pre id="test">
29 <script type="application/javascript">
30
31 /** Test for app principal's equality **/
32
33 SimpleTest.waitForExplicitFinish();
34
35 function canAccessDocument(win) {
36 var result = true;
37 try {
38 win.document;
39 } catch(e) {
40 result = false;
41 }
42 return result;
43 }
44
45 addLoadEvent(function() {
46 // Test the witness frame (we can access same-origin frame).
47 is(canAccessDocument(frames[0]), true,
48 "should be able to access the first frame");
49
50 // Test different app/browserElement frames.
51 for (var i=1; i<frames.length; ++i) {
52 is(canAccessDocument(frames[i]), false,
53 "should not be able to access the other frames");
54 }
55
56 // Cleanup.
57 SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
58 SpecialPowers.clearUserPref('dom.ipc.browser_frames.oop_by_default');
59 SpecialPowers.removePermission("browser", window.document);
60 SpecialPowers.removePermission("embed-apps", window.document);
61
62 SimpleTest.finish();
63 });
64
65 </script>
66 </pre>
67 </body>
68 </html>

mercurial