toolkit/identity/tests/chrome/sandbox_content_perms.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/identity/tests/chrome/sandbox_content_perms.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +  <!-- Any copyright is dedicated to the Public Domain.
     1.7 +     - http://creativecommons.org/publicdomain/zero/1.0/ -->
     1.8 +  <head>
     1.9 +    <meta charset="utf-8">
    1.10 +    <title>Page testing content in the Sandbox can't escape</title>
    1.11 +    <script type="application/javascript;version=1.8">
    1.12 +      const TEST_BASE = "http://mochi.test:8888/chrome/toolkit/identity/tests/chrome/"
    1.13 +      const Ci = SpecialPowers.Ci;
    1.14 +
    1.15 +      function expectException(aFunc) {
    1.16 +        try {
    1.17 +          aFunc();
    1.18 +        } catch (ex) {
    1.19 +          return true;
    1.20 +        }
    1.21 +        return false;
    1.22 +      }
    1.23 +
    1.24 +      function CcNotPresent() {
    1.25 +        if (typeof Components === 'undefined')
    1.26 +          return true;
    1.27 +        // Components shim doesn't define Components.classes.
    1.28 +        try {
    1.29 +          return typeof Components.classes === 'undefined';
    1.30 +        } catch (e) {
    1.31 +          return false;
    1.32 +        }
    1.33 +      }
    1.34 +
    1.35 +      // Build an object with test results (true = pass)
    1.36 +      let results = {
    1.37 +        windowTop: window.top == window,
    1.38 +
    1.39 +        qiWindow: expectException(function() {
    1.40 +          let isForced = window.QueryInterface(Ci.nsIInterfaceRequestor)
    1.41 +                               .getInterface(Ci.nsIDOMWindowUtils)
    1.42 +                               .docCharsetIsForced;
    1.43 +        }),
    1.44 +
    1.45 +        ccAccess: !!CcNotPresent(),
    1.46 +      };
    1.47 +
    1.48 +      let resultsJSON = JSON.stringify(results);
    1.49 +
    1.50 +      // Send the results to the mochitest server so the test file can retrieve them.
    1.51 +      let stateURL = TEST_BASE + "sandbox_content.sjs"
    1.52 +      let xhr = new XMLHttpRequest();
    1.53 +      xhr.open("GET", stateURL + "?" + encodeURIComponent(resultsJSON), true);
    1.54 +      xhr.onload = function() {
    1.55 +        if (xhr.status != 200) {
    1.56 +          dump("Failed sending results\n");
    1.57 +        }
    1.58 +      };
    1.59 +      xhr.send();
    1.60 +
    1.61 +    </script>
    1.62 +  </head>
    1.63 +
    1.64 +  <body>
    1.65 +
    1.66 +  </body>
    1.67 +</html>

mercurial