|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> |
|
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> |
|
4 <!-- |
|
5 https://bugzilla.mozilla.org/show_bug.cgi?id=932906 |
|
6 --> |
|
7 <window title="Mozilla Bug 932906" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
10 |
|
11 <!-- test results are displayed in the html:body --> |
|
12 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
13 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=932906" |
|
14 target="_blank">Mozilla Bug 932906</a> |
|
15 </body> |
|
16 |
|
17 <!-- test code goes here --> |
|
18 <script type="application/javascript"> |
|
19 <![CDATA[ |
|
20 const Cu = Components.utils; |
|
21 Cu.import('resource://gre/modules/Services.jsm'); |
|
22 |
|
23 /** Test for Bug 932906 **/ |
|
24 SimpleTest.waitForExplicitFinish(); |
|
25 |
|
26 function passToContent(shouldThrow) { |
|
27 try { |
|
28 $('ifr').contentWindow.obs = Services.obs; |
|
29 ok(!shouldThrow, "Didn't throw when passing non-DOM XPCWN to content"); |
|
30 } catch (e) { |
|
31 ok(shouldThrow, "Threw when passing non-DOM XPCWN to content"); |
|
32 ok(/denied/.test(e), "Threw correct exception: " + e); |
|
33 } |
|
34 } |
|
35 |
|
36 var gLoadCount = 0; |
|
37 function loaded() { |
|
38 ++gLoadCount; |
|
39 if (gLoadCount == 1) |
|
40 part1(); |
|
41 else if (gLoadCount == 2) |
|
42 part2(); |
|
43 else |
|
44 ok(false, "Didn't expect three loads"); |
|
45 } |
|
46 |
|
47 function part1() { |
|
48 |
|
49 // Make sure that the pref is what we expect for mochitests. |
|
50 is(Services.prefs.getBoolPref('dom.use_xbl_scopes_for_remote_xul'), true, |
|
51 "Test harness set up like we expect"); |
|
52 |
|
53 |
|
54 // First, test that we can't normally pass non-DOM XPCWNs to content. |
|
55 passToContent(/* shouldThrow = */ true); |
|
56 |
|
57 // Now, make sure we _can_ for the remote xul case. We use SpecialPowers |
|
58 // for the pref munging because it cleans up after us. |
|
59 SpecialPowers.pushPrefEnv({set: [['dom.use_xbl_scopes_for_remote_xul', false]]}, function() { |
|
60 $('ifr').contentWindow.location.reload(); |
|
61 }); |
|
62 } |
|
63 |
|
64 function part2() { |
|
65 passToContent(/* shouldThrow = */ false); |
|
66 SimpleTest.finish(); |
|
67 } |
|
68 |
|
69 ]]> |
|
70 </script> |
|
71 <iframe id="ifr" onload="loaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> |
|
72 </window> |