package textbender.a.b.rhinohideDemo._; import netscape.javascript.*; import org.junit.*; import org.w3c.dom.*; import textbender.g.util.logging.*; import textbender.o.rhinohide.*; import textbender.o.rhinohide._.*; import static org.junit.Assert.*; /** Test of Core Level 1 (unextended). */ public final class Rhinohide_1 { /** This test fails on both Firefox and IE (see source comments), * so there is little point in running it. */ @Test(expected=DOMException.class) public void domException() { final Document document = Core_1_Test.window().getDocument(); try { // document.createAttribute( "bad attribute name" ); //// Firefox throws no DOMException, instead returns null, which in turn causes a StunnedRhinoException. So try this: Text text = document.createTextNode( "short text node" ); text.splitText( -99 ); //// Also fails, in same way. But after the applet exits the JS engine eventually throws the appropriate exception (odd), which shows up in the JS console. //// Also fails on IE, in different way. Throws a JSException that does not wrap a DOMException. } catch( StunnedRhinoException xSR ) { LoggerX.i(getClass()).config( "suppressing " + xSR.toString() ); } // for Firefox catch( JSException xJS ) { LoggerX.i(getClass()).config( "suppressing " + xJS.toString() ); } // for IE LoggerX.i(getClass()).info( "supressing failure of exception test" ); throw new DOMException( DOMException.NOT_SUPPORTED_ERR, "this is a faked exception" ); } }