toolkit/mozapps/extensions/test/mochitest/test_bug887098.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=887098
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 887098</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +  <script type="application/javascript">
    1.15 +
    1.16 +  /** Test for Bug 887098 **/
    1.17 +  SimpleTest.waitForExplicitFinish();
    1.18 +
    1.19 +  function loaded() {
    1.20 +    var iwin = $('ifr').contentWindow;
    1.21 +    var href = SpecialPowers.wrap(iwin).location.href;
    1.22 +    if (/file_empty/.test(href)) {
    1.23 +      window.evalRef = iwin.eval;
    1.24 +      window.installTriggerRef = iwin.InstallTrigger; // Force lazy instantiation.
    1.25 +      // about: is privileged, so we need to be privileged to load it.
    1.26 +      SpecialPowers.wrap(iwin).location.href = 'about:';
    1.27 +    } else {
    1.28 +      is(href, 'about:', "Successfully navigated to about:");
    1.29 +      try {
    1.30 +        evalRef('InstallTrigger.install({URL: "chrome://global/skin/global.css"});');
    1.31 +        ok(false, "Should have thrown when trying to install restricted URI from InstallTrigger");
    1.32 +      } catch (e) {
    1.33 +        //XXXgijs this test broke because of the switch to webidl. I'm told
    1.34 +        // it has to do with compartments and the fact that we eval in "about:".
    1.35 +        // Tracking in bug 1007671
    1.36 +        todo(/permission/.test(e), "We should throw a security exception. Got: " + e);
    1.37 +      }
    1.38 +      SimpleTest.finish();
    1.39 +    }
    1.40 +  }
    1.41 +
    1.42 +  </script>
    1.43 +</head>
    1.44 +<body>
    1.45 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=887098">Mozilla Bug 887098</a>
    1.46 +<p id="display"></p>
    1.47 +<div id="content" style="display: none">
    1.48 +
    1.49 +</div>
    1.50 +<iframe onload="loaded();" id="ifr" src="file_empty.html"></iframe>
    1.51 +<pre id="test">
    1.52 +</pre>
    1.53 +</body>
    1.54 +</html>

mercurial