toolkit/identity/tests/chrome/sandbox_content_perms.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE html>
michael@0 2 <html>
michael@0 3 <!-- Any copyright is dedicated to the Public Domain.
michael@0 4 - http://creativecommons.org/publicdomain/zero/1.0/ -->
michael@0 5 <head>
michael@0 6 <meta charset="utf-8">
michael@0 7 <title>Page testing content in the Sandbox can't escape</title>
michael@0 8 <script type="application/javascript;version=1.8">
michael@0 9 const TEST_BASE = "http://mochi.test:8888/chrome/toolkit/identity/tests/chrome/"
michael@0 10 const Ci = SpecialPowers.Ci;
michael@0 11
michael@0 12 function expectException(aFunc) {
michael@0 13 try {
michael@0 14 aFunc();
michael@0 15 } catch (ex) {
michael@0 16 return true;
michael@0 17 }
michael@0 18 return false;
michael@0 19 }
michael@0 20
michael@0 21 function CcNotPresent() {
michael@0 22 if (typeof Components === 'undefined')
michael@0 23 return true;
michael@0 24 // Components shim doesn't define Components.classes.
michael@0 25 try {
michael@0 26 return typeof Components.classes === 'undefined';
michael@0 27 } catch (e) {
michael@0 28 return false;
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 // Build an object with test results (true = pass)
michael@0 33 let results = {
michael@0 34 windowTop: window.top == window,
michael@0 35
michael@0 36 qiWindow: expectException(function() {
michael@0 37 let isForced = window.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 38 .getInterface(Ci.nsIDOMWindowUtils)
michael@0 39 .docCharsetIsForced;
michael@0 40 }),
michael@0 41
michael@0 42 ccAccess: !!CcNotPresent(),
michael@0 43 };
michael@0 44
michael@0 45 let resultsJSON = JSON.stringify(results);
michael@0 46
michael@0 47 // Send the results to the mochitest server so the test file can retrieve them.
michael@0 48 let stateURL = TEST_BASE + "sandbox_content.sjs"
michael@0 49 let xhr = new XMLHttpRequest();
michael@0 50 xhr.open("GET", stateURL + "?" + encodeURIComponent(resultsJSON), true);
michael@0 51 xhr.onload = function() {
michael@0 52 if (xhr.status != 200) {
michael@0 53 dump("Failed sending results\n");
michael@0 54 }
michael@0 55 };
michael@0 56 xhr.send();
michael@0 57
michael@0 58 </script>
michael@0 59 </head>
michael@0 60
michael@0 61 <body>
michael@0 62
michael@0 63 </body>
michael@0 64 </html>

mercurial