1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/mochitest/test_bug478438.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=478438 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 478438</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 + <script type="application/javascript;version=1.8"> 1.14 + function fail(s, e) { ok(false, s + e) } 1.15 + function pass(s, e) { ok(true, s) } 1.16 + (pass.opposite = fail).opposite = pass; 1.17 + 1.18 + function test() { 1.19 + if (test.calledAlready) 1.20 + return; 1.21 + test.calledAlready = true; 1.22 + 1.23 + var iwin = document.getElementById("f").contentWindow; 1.24 + 1.25 + function testOne(fn, onAllow, infinitive) { 1.26 + try { fn(); onAllow("able " + infinitive, "") } 1.27 + catch (e) { onAllow.opposite("unable " + infinitive, ": " + e) } 1.28 + } 1.29 + 1.30 + testOne(function() iwin.focus, pass, 1.31 + "to resolve/get allAccess property iwin.focus"); 1.32 + 1.33 + testOne(function() iwin.focus(), pass, 1.34 + "to call allAccess method iwin.focus"); 1.35 + 1.36 + testOne(function() iwin.alert, fail, 1.37 + "to resolve/get restricted property iwin.alert"); 1.38 + 1.39 + testOne(function() iwin.alert(), fail, 1.40 + "to call restricted method iwin.alert"); 1.41 + 1.42 + testOne(function() iwin.location.toString(), fail, 1.43 + "to call restricted method iwin.location.toString"); 1.44 + 1.45 + testOne(function() { iwin.location = "http://example.org" }, pass, 1.46 + "to set writable property iwin.location"); 1.47 + 1.48 + SimpleTest.finish(); 1.49 + } 1.50 + </script> 1.51 +</head> 1.52 +<body> 1.53 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478438">Mozilla Bug 478438</a> 1.54 +<p id="display"></p> 1.55 +<div id="content"> 1.56 + <iframe id="f" src="http://example.com" onload="test()"></iframe> 1.57 +</div> 1.58 +<pre id="test"> 1.59 +<script type="application/javascript"> 1.60 + 1.61 +/** Test for Bug 478438 **/ 1.62 + 1.63 +SimpleTest.waitForExplicitFinish(); 1.64 + 1.65 +</script> 1.66 +</pre> 1.67 +</body> 1.68 +</html>