1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/chrome/test_bug932906.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=932906 1.9 +--> 1.10 +<window title="Mozilla Bug 932906" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.13 + 1.14 + <!-- test results are displayed in the html:body --> 1.15 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.16 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=932906" 1.17 + target="_blank">Mozilla Bug 932906</a> 1.18 + </body> 1.19 + 1.20 + <!-- test code goes here --> 1.21 + <script type="application/javascript"> 1.22 + <![CDATA[ 1.23 + const Cu = Components.utils; 1.24 + Cu.import('resource://gre/modules/Services.jsm'); 1.25 + 1.26 + /** Test for Bug 932906 **/ 1.27 + SimpleTest.waitForExplicitFinish(); 1.28 + 1.29 + function passToContent(shouldThrow) { 1.30 + try { 1.31 + $('ifr').contentWindow.obs = Services.obs; 1.32 + ok(!shouldThrow, "Didn't throw when passing non-DOM XPCWN to content"); 1.33 + } catch (e) { 1.34 + ok(shouldThrow, "Threw when passing non-DOM XPCWN to content"); 1.35 + ok(/denied/.test(e), "Threw correct exception: " + e); 1.36 + } 1.37 + } 1.38 + 1.39 + var gLoadCount = 0; 1.40 + function loaded() { 1.41 + ++gLoadCount; 1.42 + if (gLoadCount == 1) 1.43 + part1(); 1.44 + else if (gLoadCount == 2) 1.45 + part2(); 1.46 + else 1.47 + ok(false, "Didn't expect three loads"); 1.48 + } 1.49 + 1.50 + function part1() { 1.51 + 1.52 + // Make sure that the pref is what we expect for mochitests. 1.53 + is(Services.prefs.getBoolPref('dom.use_xbl_scopes_for_remote_xul'), true, 1.54 + "Test harness set up like we expect"); 1.55 + 1.56 + 1.57 + // First, test that we can't normally pass non-DOM XPCWNs to content. 1.58 + passToContent(/* shouldThrow = */ true); 1.59 + 1.60 + // Now, make sure we _can_ for the remote xul case. We use SpecialPowers 1.61 + // for the pref munging because it cleans up after us. 1.62 + SpecialPowers.pushPrefEnv({set: [['dom.use_xbl_scopes_for_remote_xul', false]]}, function() { 1.63 + $('ifr').contentWindow.location.reload(); 1.64 + }); 1.65 + } 1.66 + 1.67 + function part2() { 1.68 + passToContent(/* shouldThrow = */ false); 1.69 + SimpleTest.finish(); 1.70 + } 1.71 + 1.72 + ]]> 1.73 + </script> 1.74 + <iframe id="ifr" onload="loaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> 1.75 +</window>