Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7183598

JSobject.eval() does not throw exceptions on non-existent JS var/method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 6, 7, 8
    • deploy
    • generic
    • generic

      Issue:
      When try to call non-exsitent JS var/method from within Applet via JSObect.eval(...), no exception is thrown.
      While JSobejct.getMemeber and JSOjbect.call throw JSException as expected.

      source code:
      ====================
       public void start() {
              testname = "JSobjectgetMemberPropertyTest";
              try {
                  win.getMember("nonExistentProerty");
                  t.append(testname + " FAILED: Exception should get thrown \n");
                  MsgPrinter.printMsg(testname
                          + " FAILED: Exception should get thrown");
                  testFlag = false;
              } catch (Exception e) {
                  t.append(testname + " PASSED: " + e.toString() + "\n");
                  MsgPrinter.printMsg(testname + " PASSED: " + e.toString());
              }
              testname = "JSobjectInvalidEvalTest";
              try {
                  win.eval("nonExistentProerty");
                  t.append(testname + " FAILED: Exception should get thrown \n");
                  MsgPrinter.printMsg(testname
                          + " FAILED: Exception should get thrown");
                  testFlag = false;
              } catch (Exception e) {
                  t.append(testname + " PASSED: " + e.toString() + "\n");
                  MsgPrinter.printMsg(testname + " PASSED: " + e.toString());
              }
              testname = "JSobjectCallInvalidMethodTest";
              try {
                  win.call("nomethod", new String[] {});
                  t.append(testname + " FAILED: Exception should get thrown \n");
                  MsgPrinter.printMsg(testname
                          + " FAILED: Exception should get thrown");
                  testFlag = false;
              } catch (Exception e) {
                  t.append(testname + " PASSED: " + e.toString() + "\n");
                  MsgPrinter.printMsg(testname + " PASSED: " + e.toString());
              }
              testname = "JSobjectCallInvalidArgsTest";
              try {
                  win.eval("nomethod('test')");
                  t.append(testname + " FAILED: Exception should get thrown \n");
                  MsgPrinter.printMsg(testname
                          + " FAILED: Exception should get thrown");
                  testFlag = false;
              } catch (Exception e) {
                  t.append(testname + " PASSED: " + e.toString() + "\n");
                  MsgPrinter.printMsg(testname + " PASSED: " + e.toString());
              }
              setStatus();
          }
      =====================

      trace
      ===========
      @@@@ JSobjectgetMemberPropertyTest PASSED: netscape.javascript.JSException: No such property "nonExistentProerty" on JavaScript object
      @@@@ JSobjectInvalidEvalTest FAILED: Exception should get thrown
      @@@@ JSobjectCallInvalidMethodTest PASSED: netscape.javascript.JSException: No such method "nomethod" on JavaScript object
      @@@@ JSobjectCallInvalidArgsTest FAILED: Exception should get thrown
      @@@@ Final status: TEST FAILED
      ===========

      Affected tests:
      LiveConnectTest::testJSObjectException

            vdrozdov Victor Drozdov (Inactive)
            stephenh Stephen Hu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: