当前位置: 首页>>代码示例>>Java>>正文


Java JSException类代码示例

本文整理汇总了Java中netscape.javascript.JSException的典型用法代码示例。如果您正苦于以下问题:Java JSException类的具体用法?Java JSException怎么用?Java JSException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JSException类属于netscape.javascript包,在下文中一共展示了JSException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadResults

import netscape.javascript.JSException; //导入依赖的package包/类
public void loadResults() {
    try {
        JSObject windowObj = (JSObject)webEngine.executeScript("window");
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(testResult);
        windowObj.setMember("result", json);
        try {
            webEngine.executeScript("refreshResult()");
        } catch (JSException js) {
            Logger.error(js, "error updating result");
        }

    } catch (JsonProcessingException e) {
        return;
    }
}
 
开发者ID:loadtestgo,项目名称:pizzascript,代码行数:17,代码来源:ViewResultsPanel.java

示例2: testMethodCallNoParam

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * This test checks what happens when a call to a method is made
 * while parameter is lacking. JS ignores lacking parameter, so
 * we just check that nothing bad happens (and undefined result is returned).
 */
@Test(timeout=10000)
public void testMethodCallNoParam() {
    final String ILLEGAL_ARGUMENT_EXCEPTION_MSG = "java.lang.IllegalArgumentException: wrong number of arguments";
    testObject = new HelperObject();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                engine.executeScript("testObject.doParamImportant();");
            } catch (JSException e) {
                resultObject = e;
                System.out.println("exceptionCaught.getMessage(): " + ((JSException)resultObject).getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertEquals(ILLEGAL_ARGUMENT_EXCEPTION_MSG, ((JSException)resultObject).getMessage());
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:MethodCallsTest.java

示例3: testMethodCallException

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * This test checks what happens when a method throws an exception.
 */
@Test(timeout=10000)
public void testMethodCallException() {
    testObject = new HelperObject();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                resultObject = engine.executeScript("testObject.iThrowException();");
            } catch (JSException e) {
                resultObject = e;
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return resultObject != null;
        }
    });
    Assert.assertEquals(((HelperObject)testObject).e, ((JSException)resultObject).getCause());
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:26,代码来源:MethodCallsTest.java

示例4: testMethodCallException2

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * This test checks what happens when a method throws an exception.
 */
@Test(timeout=10000)
public void testMethodCallException2() {
    testObject = new HelperObject();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                resultObject = engine.executeScript("testObject.iThrowException2();");
            } catch (JSException e) {
                resultObject = e;
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return resultObject != null;
        }
    });
    Assert.assertEquals(((HelperObject)testObject).e2, ((JSException)resultObject).getCause());
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:26,代码来源:MethodCallsTest.java

示例5: testPublicStaticMethod

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Test for accessing a public static method.
 * Checks that public method of a bound object is accessible from JavaScript.
 * http://javafx-jira.kenai.com/browse/RT-19099
 */
@Test(timeout=10000)
public void testPublicStaticMethod() {
    testObject = new HelperObject();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                engine.executeScript("testObject.doSomethingStatic();");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(STATIC_MEMBER_MSG));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:StaticClassMembersTest.java

示例6: testAccessAbsentMethod

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * This test checks that the situation when JS is trying to access an absent
 * method of an exposed object is handled properly.
 */
@Test(timeout=10000)
public void testAccessAbsentMethod() {
    final String UNDEFINED_FUNCTION_ABSENT_MSG = "TypeError: 'undefined' is not a function (evaluating 'testObject.absent()')";
    testObject = new Object();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                resultObject = engine.executeScript("testObject.absent();");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(UNDEFINED_FUNCTION_ABSENT_MSG));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AbsentMembersTest.java

示例7: testProtectedMethod

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Test for accessing a protected method.
 * Checks that protected method of a bound object is not accessible from JavaScript.
 */
@Test(timeout=10000)
public void testProtectedMethod() {
    final String UNDEFINED_FUNCTION_PROTECTED_MSG = "TypeError: 'undefined' is not a function (evaluating 'testObject.protectedMethod()')";
    testObject = new HelperObject();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                resultObject = engine.executeScript("testObject.protectedMethod();");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(UNDEFINED_FUNCTION_PROTECTED_MSG));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AccessModifiersTest.java

示例8: testPrivateMethod

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Test for accessing a private method.
 * Checks that private method of a bound object is not accessible from JavaScript.
 */
@Test(timeout=10000)
public void testPrivateMethod() {
    final String UNDEFINED_FUNCTION_PRIVATE_MSG = "TypeError: 'undefined' is not a function (evaluating 'testObject.privateMethod()')";
    testObject = new HelperObject();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("testObject", testObject);
            try {
                resultObject = engine.executeScript("testObject.privateMethod();");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(UNDEFINED_FUNCTION_PRIVATE_MSG));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AccessModifiersTest.java

示例9: testAddJavaScriptBindingDotName

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Simple test for WebEngine.addJavaScriptBinding call.
 * Checks that a situation with malformed binding name is handled nicely
 * and using this malformed name in JS conforms to JS syntax.
 */
@Test(timeout=10000)
public void testAddJavaScriptBindingDotName() {
    testObject = new Object();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("test.Object", testObject);
            try {
                resultObject = engine.executeScript("test.Object;");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(NO_VARIABLE_MSG2));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AddJavaScriptBindingTest.java

示例10: testAddJavaScriptBindingHashName

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Simple test for WebEngine.addJavaScriptBinding call.
 * Checks that a situation with malformed binding name is handled nicely
 * and using this malformed name in JS conforms to JS syntax.
 */
@Test(timeout=10000)
public void testAddJavaScriptBindingHashName() {
    testObject = new Object();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("test#Object", testObject);
            try {
                resultObject = engine.executeScript("test#Object;");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(INVALID_CHARACTER_MSG));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AddJavaScriptBindingTest.java

示例11: testAddJavaScriptBindingDashName

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Simple test for WebEngine.addJavaScriptBinding call.
 * Checks that a situation with malformed binding name is handled nicely.
 * and using this malformed name in JS conforms to JS syntax.
 */
@Test(timeout=10000)
public void testAddJavaScriptBindingDashName() {
    testObject = new Object();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("test-Object", testObject);
            try {
                resultObject = engine.executeScript("test-Object;");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(NO_VARIABLE_MSG2));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AddJavaScriptBindingTest.java

示例12: testAddJavaScriptBindingQuoteName

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Simple test for WebEngine.addJavaScriptBinding call.
 * Checks that a situation with malformed binding name is handled nicely.
 * and using this malformed name in JS conforms to JS syntax.
 */
@Test(timeout=10000)
public void testAddJavaScriptBindingQuoteName() {
    testObject = new Object();
    resultObject = null;
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngineAndWindow();
            window.setMember("test\"Object", testObject);
            try {
                resultObject = engine.executeScript("test\"Object;");
            } catch (JSException e) {
                resultObject = e;
                System.out.println(e.getMessage());
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
    Assert.assertTrue(resultObject instanceof JSException);
    Assert.assertTrue(((JSException) resultObject).getMessage().equals(UNEXPECTED_EOF_MSG));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:30,代码来源:AddJavaScriptBindingTest.java

示例13: testEvalWrongCode

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * Test for JSObject.eval call with an argument which cannot be evaluated.
 */
@Test(timeout=10000)
public void testEvalWrongCode(){
    Platform.runLater(new Runnable() {
        public void run() {
            initWebEngine();
            JSObject winO = getWindow(engine);
            try {
                winO.eval("asdf");
            } catch (JSException e) {
                resultObject = Boolean.TRUE;
            }
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (resultObject != null);
        }
    });
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:23,代码来源:BridgeEvalTest.java

示例14: enableDebug

import netscape.javascript.JSException; //导入依赖的package包/类
public void enableDebug() {
    try {
        webEngine.executeScript("if (!document.getElementById('FirebugLite')) {\n" +
                "    E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;\n" +
                "    E = E ? document['createElement' + 'NS'](E, 'script') : document['createElement']('script');\n" +
                "    E['setAttribute']('id', 'FirebugLite');\n" +
                "    E['setAttribute']('src', 'https://getfirebug.com/' + 'firebug-lite.js' + '#startOpened');\n" +
                //"    E['setAttribute']('src', '" + fireBugJS + "');\n" +
                "    E['setAttribute']('FirebugLite', '4');\n" +
                "    (document['getElementsByTagName']('head')[0] || document['getElementsByTagName']('body')[0]).appendChild(E);\n" +
                "    E = new Image;\n" +
                "    E['setAttribute']('src', 'https://getfirebug.com/' + '#startOpened');\n" +
                "}\n");
    } catch (JSException ex) {
        String error = ex.toString();
        logger.info("[" + instance + "] " + "JSException on script", ex);
    }
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:19,代码来源:MultiMarkdownFxPreviewEditor.java

示例15: getTypeString

import netscape.javascript.JSException; //导入依赖的package包/类
/**
 * 指定された JSObject のメンバの型を文字列として取得します。
 *
 * @param object 対象となる JSObject。
 * @param name   対象のメンバ名。
 * @return JavaScriptでの型名。メンバが存在しない、何らかの理由で取得に失敗した場合は undefined。
 */
public static String getTypeString(JSObject object, String name) {
    if (object == null)
        return "undefined";

    if (name == null)
        return "undefined";

    try {
        if (hasMember(object, name))
            return (String) object.eval("typeof this." + name);
    } catch (JSException e) {
        //
    }

    return "undefined";
}
 
开发者ID:nanase,项目名称:Nanasetter,代码行数:24,代码来源:JSObjectUtils.java


注:本文中的netscape.javascript.JSException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。