|
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); |
|
14 |
|
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 } |
|
26 |
|
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 } |
|
36 |
|
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 } |
|
46 |
|
47 SimpleTest.finish(); |
|
48 } |
|
49 </script> |
|
50 |
|
51 <p id="display"></p> |
|
52 |
|
53 <embed id="plugin1" type="application/x-test" width="400" height="100"> |
|
54 </embed> |
|
55 |
|
56 <div id="verbose"> |
|
57 </div> |
|
58 </body> |
|
59 </html> |