1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/mochitest/test_bug504877.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=504877 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 504877</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504877">Mozilla Bug 504877</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script type="application/javascript"> 1.22 + 1.23 +/** Test for Bug 504877 **/ 1.24 +SimpleTest.waitForExplicitFinish(); 1.25 +var p = 0; 1.26 +function go() { 1.27 + var ifr = $('ifr').contentWindow; 1.28 + function test1() { 1.29 + try { 1.30 + ifr.foopy; 1.31 + ok(false, "should have thrown a cross-origin access exception"); 1.32 + } catch (e) { 1.33 + ok(/Permission denied/.test(e), "Threw a permission denied exception"); 1.34 + } 1.35 + 1.36 + var loc = ifr.location; 1.37 + (function() { 1.38 + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 1.39 + ifr.blat = 42; 1.40 + 1.41 + is(ifr.blat, 42, "able to set random properties") 1.42 + is(ifr.getblat(), 42, "setting properties propagates"); 1.43 + is(ifr.foopy, 42, "able to use UniversalXPConnect to get random properties"); 1.44 + 1.45 + loc.replace; // resolves the property onto the wrapper. 1.46 + })(); 1.47 + 1.48 + loc.replace("http://mochi.test:8888/"); 1.49 + ok(true, "able to set location on the cross origin(!) frame"); 1.50 + } 1.51 + 1.52 + function test2() { 1.53 + SimpleTest.finish(); 1.54 + } 1.55 + 1.56 + switch (++p) { 1.57 + case 1: return test1(); 1.58 + case 2: return test2(); 1.59 + } 1.60 +} 1.61 + 1.62 + 1.63 +</script> 1.64 +</pre> 1.65 +<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/bug504877_helper.html" id="ifr" onload="go()"></iframe> 1.66 +</body> 1.67 +</html>