dom/plugins/test/mochitest/test_npruntime_npnsetexception.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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