dom/plugins/test/mochitest/test_npruntime_npnsetexception.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.

     1 <html>
     2 <head>
     3   <title>NPN_SetException Tests</title>
     4   <script type="text/javascript" 
     5           src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="utils.js"></script>
     7   <link rel="stylesheet" type="text/css" 
     8         href="/tests/SimpleTest/test.css" />
     9 </head>
    10 <body onload="runTests()">
    11   <script class="testbody" type="application/javascript">
    12   SimpleTest.waitForExplicitFinish();
    13   setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    15   function runTests() {
    16     // test a single exception thrown in scriptable invoke
    17     var plugin = document.getElementById("plugin1");
    18     plugin.throwExceptionNextInvoke();
    19     try {
    20       plugin.npnInvokeTest("badFunction");
    21       ok(false, "exception not thrown");
    22     }
    23     catch (e) {
    24       is(e, "badFunction", "wrong exception thrown");
    25     }
    27     // test multiple exceptions thrown in scriptable invokedefault
    28     plugin.throwExceptionNextInvoke();
    29     try {
    30       plugin("first exception", "second exception");
    31       ok(false, "exception not thrown");
    32     }
    33     catch (e) {
    34       is(e, "second exception", "wrong exception thrown");
    35     }    
    37     // test calling exception with NULL message
    38     plugin.throwExceptionNextInvoke();
    39     try {
    40       plugin();
    41       ok(false, "exception not thrown");
    42     }
    43     catch (e) {
    44       is(e.message, "Error calling method on NPObject!", "wrong exception thrown");
    45     }    
    47     SimpleTest.finish();
    48   }
    49   </script>
    51   <p id="display"></p>
    53   <embed id="plugin1" type="application/x-test" width="400" height="100">
    54   </embed>
    56   <div id="verbose">
    57   </div>
    58  </body>
    59  </html>

mercurial