| <html> |
| <head> |
| <meta charset="utf-8"> |
| <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"> |
| <script src="../fast/js/resources/js-test-pre.js"></script> |
| <script> |
| if (window.layoutTestController) |
| layoutTestController.overridePreference("WebKitJavaEnabled", "1"); |
| </script> |
| </head> |
| <body> |
| |
| <p>Test that Java objects can be passed to NPAPI plug-ins, and vice versa.</p> |
| <p>Some tests below are written in a way that works around issues with preserving object identity. |
| They can be simplified once these issues are fixed.</p> |
| |
| <div id="console"></div> |
| <embed name="plg" type="application/x-webkit-test-netscape"></embed> |
| <applet CODE="SharedApplet.class" NAME="javaTest" WIDTH=150 HEIGHT=25 MAYSCRIPT></applet> |
| <script> |
| |
| document.plg.remember(document.javaTest.getSelf()); |
| shouldBe('document.plg.getAndForgetRememberedObject() + ""', 'document.javaTest.getSelf() + ""'); |
| document.plg.remember(document.javaTest.getSelf()); |
| shouldBe('document.plg.getAndForgetRememberedObject().getSelf().getSelf() + ""', 'document.javaTest.getSelf() + ""'); |
| |
| shouldBe('document.plg.testHasMethod(document.javaTest, "getSelf")', 'true'); |
| shouldBe('document.plg.testHasMethod(document.javaTest, "doesNotExist")', 'false'); |
| shouldBe('document.plg.testHasMethod(document.javaTest.getSelf(), "getSelf")', 'true'); |
| shouldBe('document.plg.testHasMethod(document.javaTest.getSelf(), "doesNotExist")', 'false'); |
| |
| document.javaTest.remember(document.plg.testObject); |
| shouldBe('document.javaTest.getAndForgetRememberedObject().objectPointer', 'document.plg.testObject.objectPointer'); |
| |
| shouldBe('typeof document.javaTest.testGetMember(document.plg, "testDOMAccess")', '"function"'); |
| |
| // Try calling a plug-in method with a Java object as this, and vice versa. |
| // These should throw an exception. |
| function tryCall(func, thisObj) |
| { |
| var exception = "NO EXCEPTION"; |
| try { |
| func.call(thisObj); |
| } catch (e) { |
| exception = e; |
| } |
| return String(exception); |
| } |
| shouldBe('tryCall(document.javaTest.getSelf, plg.testObject)', '"TypeError: Attempt to invoke non-plug-in method on plug-in object."'); |
| shouldBe('tryCall(plg.testObject.throwException, document.javaTest)', '"TypeError: Attempt to invoke non-Java method on Java object."'); |
| |
| successfullyParsed = true; |
| </script> |
| <script src="../fast/js/resources/js-test-post.js"></script> |
| </body> |
| </html> |