Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | - http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 4 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 5 | <?xml-stylesheet |
michael@0 | 6 | href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 7 | type="text/css"?> |
michael@0 | 8 | <!-- |
michael@0 | 9 | https://bugzilla.mozilla.org/show_bug.cgi?id=719994 |
michael@0 | 10 | --> |
michael@0 | 11 | <window title="Test principal inheriting" |
michael@0 | 12 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 13 | |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 16 | |
michael@0 | 17 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 18 | <p id="display"></p> |
michael@0 | 19 | <div id="content" style="display: none"> |
michael@0 | 20 | </div> |
michael@0 | 21 | <pre id="test"> |
michael@0 | 22 | </pre> |
michael@0 | 23 | </body> |
michael@0 | 24 | |
michael@0 | 25 | <script class="testbody" type="application/javascript"> |
michael@0 | 26 | <![CDATA[ |
michael@0 | 27 | |
michael@0 | 28 | /** Test for Bug 719994 **/ |
michael@0 | 29 | |
michael@0 | 30 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 31 | |
michael@0 | 32 | var gFrame; |
michael@0 | 33 | |
michael@0 | 34 | // This test file is loaded in a type=content docshell whose principal is |
michael@0 | 35 | // the system principal. |
michael@0 | 36 | |
michael@0 | 37 | // Using data: URIs here instead of javascript: URIs, since javascript: URIs |
michael@0 | 38 | // fail to load when there's no principal to load them against. This only |
michael@0 | 39 | // matters when these tests fail (produces better error messages). |
michael@0 | 40 | var tests = [ |
michael@0 | 41 | function testInheritFromParent(cb) { |
michael@0 | 42 | gFrame = document.createElement("iframe"); |
michael@0 | 43 | loadListener(gFrame, function () { |
michael@0 | 44 | is(window.inheritedFromParent, true, "load in type=content iframe inherited principal of same type parent"); |
michael@0 | 45 | cb(); |
michael@0 | 46 | }); |
michael@0 | 47 | gFrame.setAttribute("type", "content"); |
michael@0 | 48 | gFrame.setAttribute("src", "data:text/html,<script>parent.inheritedFromParent = true;</script>"); |
michael@0 | 49 | document.documentElement.appendChild(gFrame); |
michael@0 | 50 | }, |
michael@0 | 51 | function testInheritFromCurrent_system(cb) { |
michael@0 | 52 | loadListener(gFrame, function () { |
michael@0 | 53 | is(window.inheritedSystem, undefined, "load in type=content iframe shouldn't inherit system principal from current document"); |
michael@0 | 54 | cb(); |
michael@0 | 55 | }, true); |
michael@0 | 56 | gFrame.setAttribute("src", "data:text/html,<script>parent.inheritedSystem = true;</script>"); |
michael@0 | 57 | }, |
michael@0 | 58 | function testInheritFromCreated(cb) { |
michael@0 | 59 | // Open a new chrome window with a type="content" iframe, so that it has no |
michael@0 | 60 | // same-type parent. |
michael@0 | 61 | // Load a javascript: URI in it to ensure that GetInheritedPrincipal will |
michael@0 | 62 | // force creation of a content viewer. |
michael@0 | 63 | let xulWinURL = 'data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?>' + |
michael@0 | 64 | '<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>'; |
michael@0 | 65 | let newWin = window.openDialog(xulWinURL, "chrome_window", "chrome"); |
michael@0 | 66 | loadListener(newWin, function () { |
michael@0 | 67 | let frame = newWin.document.createElement("iframe"); |
michael@0 | 68 | frame.setAttribute("type", "content"); |
michael@0 | 69 | frame.setAttribute("src", "javascript:'1';"); |
michael@0 | 70 | loadListener(frame, function () { |
michael@0 | 71 | is(frame.contentWindow.document.body.textContent, "1", "content viewer was created"); |
michael@0 | 72 | SimpleTest.executeSoon(function () { |
michael@0 | 73 | newWin.close(); |
michael@0 | 74 | cb(); |
michael@0 | 75 | }) |
michael@0 | 76 | }); |
michael@0 | 77 | newWin.document.documentElement.appendChild(frame); |
michael@0 | 78 | }); |
michael@0 | 79 | } |
michael@0 | 80 | ]; |
michael@0 | 81 | |
michael@0 | 82 | addLoadEvent(function onLoad() { |
michael@0 | 83 | ok(Components.stack, "this test must be run with the system principal"); |
michael@0 | 84 | SimpleTest.executeSoon(nextTest); |
michael@0 | 85 | }); |
michael@0 | 86 | |
michael@0 | 87 | function loadListener(target, func) { |
michael@0 | 88 | target.addEventListener("load", function lis() { |
michael@0 | 89 | target.removeEventListener("load", lis, true); |
michael@0 | 90 | func(); |
michael@0 | 91 | }, true); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | function nextTest() { |
michael@0 | 95 | if (tests.length) { |
michael@0 | 96 | let test = tests.shift(); |
michael@0 | 97 | SimpleTest.executeSoon(function () { |
michael@0 | 98 | info("running " + test.name); |
michael@0 | 99 | test(nextTest); |
michael@0 | 100 | }); |
michael@0 | 101 | } else |
michael@0 | 102 | SimpleTest.executeSoon(SimpleTest.finish); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | ]]> |
michael@0 | 106 | </script> |
michael@0 | 107 | |
michael@0 | 108 | </window> |