js/xpconnect/tests/chrome/test_bug596580.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/chrome/test_bug596580.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +<window title="Mozilla Bug 596580"
     1.9 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.10 +  <script type="application/javascript"
    1.11 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +
    1.13 +  <!-- test results are displayed in the html:body -->
    1.14 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.15 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=596580"
    1.16 +     target="_blank">Mozilla Bug 596580</a>
    1.17 +  </body>
    1.18 +
    1.19 +  <!-- test code goes here -->
    1.20 +  <script type="application/x-javascript;version=1.8"><![CDATA[
    1.21 +    function init() {
    1.22 +      var f = new Function("let test = 'let is ok'; return test;");
    1.23 +      is(f(), 'let is ok', 'let should be ok');
    1.24 +      SimpleTest.finish();
    1.25 +    }
    1.26 +
    1.27 +    Test = {
    1.28 +      include: function(p) {
    1.29 +	var sawError = false;
    1.30 +	try {
    1.31 +	  Components.classes["@mozilla.org/moz/jssubscript-loader;1"].
    1.32 +	    getService(Components.interfaces["mozIJSSubScriptLoader"]).
    1.33 +	    loadSubScript(p);
    1.34 +	} catch (e) {
    1.35 +	  sawError = true;
    1.36 +	}
    1.37 +	ok(sawError, 'should receive an error loading a not-found file');
    1.38 +      }
    1.39 +    };
    1.40 +
    1.41 +    // If the include method is defined as a global function, it works.
    1.42 +    // try to load a non existing file to produce the error
    1.43 +    Test.include("notfound.js");
    1.44 +
    1.45 +    // If init is called directly, it works.
    1.46 +    setTimeout('init();', 0);
    1.47 +
    1.48 +    SimpleTest.waitForExplicitFinish();
    1.49 +
    1.50 +  ]]></script>
    1.51 +</window>

mercurial