dom/plugins/test/mochitest/test_npruntime_npnsetexception.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_npruntime_npnsetexception.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +<html>
     1.5 +<head>
     1.6 +  <title>NPN_SetException Tests</title>
     1.7 +  <script type="text/javascript" 
     1.8 +          src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="text/javascript" src="utils.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" 
    1.11 +        href="/tests/SimpleTest/test.css" />
    1.12 +</head>
    1.13 +<body onload="runTests()">
    1.14 +  <script class="testbody" type="application/javascript">
    1.15 +  SimpleTest.waitForExplicitFinish();
    1.16 +  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.17 +
    1.18 +  function runTests() {
    1.19 +    // test a single exception thrown in scriptable invoke
    1.20 +    var plugin = document.getElementById("plugin1");
    1.21 +    plugin.throwExceptionNextInvoke();
    1.22 +    try {
    1.23 +      plugin.npnInvokeTest("badFunction");
    1.24 +      ok(false, "exception not thrown");
    1.25 +    }
    1.26 +    catch (e) {
    1.27 +      is(e, "badFunction", "wrong exception thrown");
    1.28 +    }
    1.29 +    
    1.30 +    // test multiple exceptions thrown in scriptable invokedefault
    1.31 +    plugin.throwExceptionNextInvoke();
    1.32 +    try {
    1.33 +      plugin("first exception", "second exception");
    1.34 +      ok(false, "exception not thrown");
    1.35 +    }
    1.36 +    catch (e) {
    1.37 +      is(e, "second exception", "wrong exception thrown");
    1.38 +    }    
    1.39 +
    1.40 +    // test calling exception with NULL message
    1.41 +    plugin.throwExceptionNextInvoke();
    1.42 +    try {
    1.43 +      plugin();
    1.44 +      ok(false, "exception not thrown");
    1.45 +    }
    1.46 +    catch (e) {
    1.47 +      is(e.message, "Error calling method on NPObject!", "wrong exception thrown");
    1.48 +    }    
    1.49 +
    1.50 +    SimpleTest.finish();
    1.51 +  }
    1.52 +  </script>
    1.53 +
    1.54 +  <p id="display"></p>
    1.55 +
    1.56 +  <embed id="plugin1" type="application/x-test" width="400" height="100">
    1.57 +  </embed>
    1.58 +
    1.59 +  <div id="verbose">
    1.60 +  </div>
    1.61 + </body>
    1.62 + </html>

mercurial