gecko-dev/dom/plugins/test/mochitest/test_npruntime_npnsetexcept...

60 строки
1.6 KiB
HTML

<html>
<head>
<title>NPN_SetException Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTests() {
// test a single exception thrown in scriptable invoke
var plugin = document.getElementById("plugin1");
plugin.throwExceptionNextInvoke();
try {
plugin.npnInvokeTest("badFunction");
ok(false, "exception not thrown");
}
catch (e) {
is(e, "badFunction", "wrong exception thrown");
}
// test multiple exceptions thrown in scriptable invokedefault
plugin.throwExceptionNextInvoke();
try {
plugin("first exception", "second exception");
ok(false, "exception not thrown");
}
catch (e) {
is(e, "second exception", "wrong exception thrown");
}
// test calling exception with NULL message
plugin.throwExceptionNextInvoke();
try {
plugin();
ok(false, "exception not thrown");
}
catch (e) {
is(e.message, "Error calling method on NPObject!", "wrong exception thrown");
}
SimpleTest.finish();
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="100">
</embed>
<div id="verbose">
</div>
</body>
</html>