1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/iframesandbox/test_other_auxiliary_navigation_by_location.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=785310 1.8 +html5 sandboxed iframe should not be able to perform top navigation with scripts allowed 1.9 +--> 1.10 +<head> 1.11 +<meta charset="utf-8"> 1.12 +<title>Test for Bug 785310 - iframe sandbox other auxiliary navigation by location tests</title> 1.13 +<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.14 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 + 1.16 +<script> 1.17 + SimpleTest.waitForExplicitFinish(); 1.18 + 1.19 + function runScriptNavigationTest(testCase) { 1.20 + window.onmessage = function(event) { 1.21 + if (event.data != "otherWindow") { 1.22 + ok(false, "event.data: got '" + event.data + "', expected 'otherWindow'"); 1.23 + } 1.24 + ok(false, testCase.desc, "auxiliary navigation was NOT blocked"); 1.25 + runNextTest(); 1.26 + }; 1.27 + try { 1.28 + window["testIframe"].eval(testCase.script); 1.29 + } catch(e) { 1.30 + ok(true, testCase.desc, e.message); 1.31 + runNextTest(); 1.32 + } 1.33 + } 1.34 + 1.35 + var testCaseIndex = -1; 1.36 + testCases = [ 1.37 + { 1.38 + desc: "Test 1: location.replace on auxiliary NOT opened by us should be blocked", 1.39 + script: "parent.openedWindow.location.replace('file_other_auxiliary_navigation_by_location.html')" 1.40 + }, 1.41 + { 1.42 + desc: "Test 2: location.assign on auxiliary NOT opened by us should be blocked", 1.43 + script: "parent.openedWindow.location.assign('file_other_auxiliary_navigation_by_location.html')" 1.44 + }, 1.45 + { 1.46 + desc: "Test 3: location.href on auxiliary NOT opened by us should be blocked", 1.47 + script: "parent.openedWindow.location.href = 'file_other_auxiliary_navigation_by_location.html'" 1.48 + }, 1.49 + { 1.50 + desc: "Test 4: location.hash on auxiliary NOT opened by us should be blocked", 1.51 + script: "parent.openedWindow.location.hash = 'wibble'" 1.52 + } 1.53 + ]; 1.54 + 1.55 + function runNextTest() { 1.56 + ++testCaseIndex; 1.57 + if (testCaseIndex == testCases.length) { 1.58 + openedWindow.close(); 1.59 + SimpleTest.finish(); 1.60 + return; 1.61 + } 1.62 + 1.63 + runScriptNavigationTest(testCases[testCaseIndex]); 1.64 + } 1.65 + 1.66 + window.onmessage = runNextTest; 1.67 + 1.68 + window.onload = function() { 1.69 + window.openedWindow = window.open("file_other_auxiliary_navigation_by_location.html", "otherWindow"); 1.70 + } 1.71 +</script> 1.72 + 1.73 +</head> 1.74 +<body> 1.75 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785310">Mozilla Bug 785310</a> 1.76 +<p id="display"></p> 1.77 +<div id="content"> 1.78 +Tests for Bug 785310 1.79 +</div> 1.80 + 1.81 +<iframe name="testIframe" sandbox="allow-scripts allow-same-origin allow-top-navigation allow-popups"></iframe> 1.82 +</body> 1.83 +</html>